/**
 * @fileoverview Messenger thread aggregation service for chat, issue,
 * approval, budget, failed-run, join-request, and custom grouped threads.
 *
 * @see doc/product/domains/collaboration/chat-messenger-im.md - Messenger and chat thread behavior
 * @see doc/product/surfaces/surface-domain-map.md - surface-to-domain routing map
 * @see doc/product/domains/control-plane/dashboard-calendar-inbox.md - operator inbox signals
 */
import type { Db } from "@rudderhq/db";
import { type MessengerApprovalThreadItem, type MessengerBudgetThreadItem, type MessengerCustomGroupsResponse, type MessengerHeartbeatRunThreadItem, type MessengerIssueThreadItem, type MessengerJoinRequestThreadItem, type MessengerSystemThreadKind, type MessengerThreadDetail, type MessengerThreadSummary, type MessengerThreadSummaryPage } from "@rudderhq/shared";
import { chatService } from "./chats.js";
type ThreadReadState = {
    lastReadAt: Date;
};
type IssueThreadDetailOptions = {
    includeDetail: boolean;
    limit?: number;
    cursor?: string | null;
};
type ThreadSummaryListOptions = {
    splitIssues?: boolean;
};
type ThreadSummaryPageOptions = ThreadSummaryListOptions & {
    limit?: number;
    cursor?: string | null;
};
type ChatConversationRow = Awaited<ReturnType<ReturnType<typeof chatService>["list"]>>[number];
type ChatMessageRow = Awaited<ReturnType<ReturnType<typeof chatService>["listMessages"]>>[number];
export declare function messengerService(db: Db): {
    listCustomGroups: (orgId: string, userId: string) => Promise<MessengerCustomGroupsResponse>;
    listThreadTitles: (orgId: string, userId: string, threadKeys: string[]) => Promise<string[]>;
    listCustomGroupThreadTitles: (orgId: string, userId: string, groupId: string) => Promise<string[]>;
    createCustomGroup: (orgId: string, userId: string, name: string, icon?: string | null) => Promise<{
        id: string;
        orgId: string;
        createdAt: Date;
        updatedAt: Date;
        name: string;
        icon: string | null;
        collapsed: boolean;
        sortOrder: number;
        userId: string;
        pinnedAt: Date | null;
    }>;
    createCustomGroupWithEntries: (orgId: string, userId: string, name: string, icon: string | null, threadKeys: string[]) => Promise<MessengerCustomGroupsResponse>;
    updateCustomGroup: (orgId: string, userId: string, groupId: string, patch: {
        name?: string;
        icon?: string | null;
        collapsed?: boolean;
        pinned?: boolean;
        sortOrder?: number;
    }) => Promise<{
        id: string;
        orgId: string;
        userId: string;
        name: string;
        icon: string | null;
        sortOrder: number;
        collapsed: boolean;
        pinnedAt: Date | null;
        createdAt: Date;
        updatedAt: Date;
    }>;
    separateCustomGroup: (orgId: string, userId: string, groupId: string) => Promise<{
        id: string;
        orgId: string;
        createdAt: Date;
        updatedAt: Date;
        name: string;
        icon: string | null;
        collapsed: boolean;
        sortOrder: number;
        userId: string;
        pinnedAt: Date | null;
    }>;
    deleteCustomGroup: (orgId: string, userId: string, groupId: string) => Promise<{
        id: string;
        orgId: string;
        createdAt: Date;
        updatedAt: Date;
        name: string;
        icon: string | null;
        collapsed: boolean;
        sortOrder: number;
        userId: string;
        pinnedAt: Date | null;
    }>;
    reorderCustomGroups: (orgId: string, userId: string, groupIds: string[]) => Promise<MessengerCustomGroupsResponse>;
    assignThreadToCustomGroup: (orgId: string, userId: string, groupId: string, threadKey: string) => Promise<{
        id: string;
        orgId: string;
        createdAt: Date;
        updatedAt: Date;
        sortOrder: number;
        threadKey: string;
        userId: string;
        groupId: string;
    }>;
    removeThreadFromCustomGroups: (orgId: string, userId: string, threadKey: string) => Promise<{
        threadKey: string;
    }>;
    reorderCustomGroupEntries: (orgId: string, userId: string, groupId: string, threadKeys: string[]) => Promise<MessengerCustomGroupsResponse>;
    listThreadSummaries: (orgId: string, userId: string, options?: ThreadSummaryListOptions) => Promise<MessengerThreadSummary[]>;
    listThreadSummaryPage: (orgId: string, userId: string, options?: ThreadSummaryPageOptions) => Promise<MessengerThreadSummaryPage>;
    getChatThread: (conversationId: string, userId: string) => Promise<{
        conversation: ChatConversationRow;
        messages: ChatMessageRow[];
    } | null>;
    getIssuesThread: (orgId: string, userId: string, options?: Pick<IssueThreadDetailOptions, "limit" | "cursor">) => Promise<{
        summary: MessengerThreadSummary;
        detail: MessengerThreadDetail<MessengerIssueThreadItem>;
    }>;
    countUnreadIssueThreadEntries: (orgId: string, userId: string) => Promise<number>;
    getApprovalsThread: (orgId: string, userId: string) => Promise<{
        summary: MessengerThreadSummary;
        detail: {
            threadKey: string;
            kind: "approvals";
            title: string;
            subtitle: string;
            preview: string | null;
            latestActivityAt: Date;
            lastReadAt: Date | null;
            unreadCount: number;
            needsAttention: boolean;
            isPinned: false;
            href: string;
            description: string;
            items: MessengerApprovalThreadItem[];
        };
    }>;
    getSystemThread: (orgId: string, userId: string, threadKind: MessengerSystemThreadKind) => Promise<{
        summary: MessengerThreadSummary;
        detail: {
            threadKey: string;
            kind: "budget-alerts";
            title: string;
            subtitle: string;
            preview: string | null;
            latestActivityAt: Date;
            lastReadAt: Date | null;
            unreadCount: number;
            needsAttention: boolean;
            isPinned: false;
            href: string;
            description: string;
            items: MessengerBudgetThreadItem[];
        };
    } | {
        summary: MessengerThreadSummary;
        detail: {
            threadKey: string;
            kind: "failed-runs";
            title: string;
            subtitle: string;
            preview: string | null;
            latestActivityAt: Date;
            lastReadAt: Date | null;
            unreadCount: number;
            needsAttention: boolean;
            isPinned: false;
            href: string;
            description: string;
            items: MessengerHeartbeatRunThreadItem[];
        };
    } | {
        summary: MessengerThreadSummary;
        detail: {
            threadKey: string;
            kind: "join-requests";
            title: string;
            subtitle: string;
            preview: string | null;
            latestActivityAt: Date;
            lastReadAt: Date | null;
            unreadCount: number;
            needsAttention: boolean;
            isPinned: false;
            href: string;
            description: string;
            items: MessengerJoinRequestThreadItem[];
        };
    } | null>;
    getThreadState: (orgId: string, userId: string, threadKey: string) => Promise<{
        id: string;
        orgId: string;
        createdAt: Date;
        updatedAt: Date;
        threadKey: string;
        userId: string;
        lastReadAt: Date;
        pinnedAt: Date | null;
    }>;
    dismissUnreadThreads: (orgId: string, userId: string) => Promise<{
        dismissedCount: number;
        dismissedThreadKeys: string[];
    }>;
    markThreadRead: (orgId: string, userId: string, threadKey: string, readAt?: Date) => Promise<ThreadReadState | null>;
    setThreadRead: (orgId: string, userId: string, threadKey: string, readAt?: Date) => Promise<ThreadReadState | null>;
    setThreadPinned: (orgId: string, userId: string, threadKey: string, pinned: boolean) => Promise<{
        threadKey: string;
        pinned: boolean;
    } | null>;
};
export {};
//# sourceMappingURL=messenger.d.ts.map