/**
 * WebAssembly SQLite metadata index for mailx (Android/browser).
 * API-compatible with @bobfrankston/mailx-store's MailxDB.
 * Uses sql.js (SQLite compiled to WebAssembly) for in-browser SQLite.
 *
 * Database is persisted to IndexedDB on every write operation.
 * Bodies are stored in IndexedDB via WebMessageStore (not filesystem).
 */
import type { MessageEnvelope, Folder, EmailAddress, PagedResult, MessageQuery } from "@bobfrankston/mailx-types";
export declare class WebMailxDB {
    private db;
    private ready;
    private saveTimer;
    constructor(dbName?: string);
    private init;
    /** Wait for DB initialization */
    waitReady(): Promise<void>;
    /** Persist DB to IndexedDB (debounced — batches rapid writes) */
    private scheduleSave;
    /** Force immediate persist */
    flush(): Promise<void>;
    close(): void;
    private run;
    private get;
    private all;
    private lastId;
    upsertAccount(id: string, name: string, email: string, configJson: string): void;
    getAccounts(): {
        id: string;
        name: string;
        email: string;
        lastSync: number;
    }[];
    getAccountConfigs(): {
        id: string;
        name: string;
        email: string;
        configJson: string;
    }[];
    updateLastSync(accountId: string, timestamp: number): void;
    upsertFolder(accountId: string, folderPath: string, name: string, specialUse: string, delimiter: string): number;
    getFolders(accountId: string): Folder[];
    deleteFolder(folderId: number): void;
    markFolderRead(folderId: number): void;
    deleteAllMessages(accountId: string, folderId: number): void;
    updateFolderCounts(folderId: number, total: number, unread: number): void;
    updateFolderSync(folderId: number, uidvalidity: number, highestModseq: string): void;
    getFolderSync(folderId: number): {
        uidvalidity: number;
        highestModseq: string;
    };
    upsertMessage(msg: {
        accountId: string;
        folderId: number;
        uid: number;
        messageId: string;
        inReplyTo: string;
        references: string[];
        date: number;
        subject: string;
        from: EmailAddress;
        to: EmailAddress[];
        cc: EmailAddress[];
        flags: string[];
        size: number;
        hasAttachments: boolean;
        preview: string;
        bodyPath: string;
    }): number;
    getMessages(query: MessageQuery): PagedResult<MessageEnvelope>;
    getUnifiedInbox(page?: number, pageSize?: number): PagedResult<MessageEnvelope>;
    getMessageByUid(accountId: string, uid: number, folderId?: number): MessageEnvelope;
    getMessageBodyPath(accountId: string, uid: number): string;
    updateMessageFlags(accountId: string, uid: number, flags: string[]): void;
    updateBodyPath(accountId: string, uid: number, bodyPath: string): void;
    getMessagesWithoutBody(accountId: string, limit?: number): {
        uid: number;
        folderId: number;
    }[];
    getHighestUid(accountId: string, folderId: number): number;
    getOldestDate(accountId: string, folderId: number): number;
    getMessageCount(accountId: string, folderId: number): number;
    getUidsForFolder(accountId: string, folderId: number): number[];
    deleteMessage(accountId: string, uid: number): void;
    recalcFolderCounts(folderId: number): void;
    beginTransaction(): void;
    commitTransaction(): void;
    rollbackTransaction(): void;
    recordSentAddress(name: string, email: string): void;
    seedContactsFromMessages(): number;
    searchContacts(query: string, limit?: number): {
        name: string;
        email: string;
        source: string;
        useCount: number;
    }[];
    /** Address-book listing. Same shape as mailx-store/db.ts:listContacts so
     *  the address-book modal renders identically on desktop and Android. */
    listContacts(query: string, page?: number, pageSize?: number): {
        items: any[];
        total: number;
        page: number;
        pageSize: number;
    };
    upsertContact(name: string, email: string): void;
    deleteContactLocal(email: string): void;
    /** Q49 heuristic: has the user ever sent to `recipientEmail` with a
     *  non-empty Cc? Scans Sent folder(s). Used by compose to auto-expand
     *  the Cc row on reply to a frequent-Cc'd recipient. */
    hasCcHistoryTo(recipientEmail: string): boolean;
    searchMessages(query: string, page?: number, pageSize?: number, accountId?: string, folderId?: number): PagedResult<MessageEnvelope>;
    queueSyncAction(accountId: string, action: string, uid: number, folderId: number, extra?: {
        targetFolderId?: number;
        flags?: string[];
        rawMessage?: string;
    }): void;
    getPendingSyncActions(accountId: string): any[];
    completeSyncAction(id: number): void;
    failSyncAction(id: number, error: string): void;
    /** Delete a queued sync action by (accountId, action, uid) — used by the
     *  send path which tracks queued sends via a unique negative uid rather
     *  than threading the row id through the async send pipeline. */
    completeSyncActionByUid(accountId: string, action: string, uid: number): void;
    /** Mark a send-queue action failed by uid — same tracking-key rationale. */
    failSyncActionByUid(accountId: string, action: string, uid: number, error: string): void;
    getPendingSyncCount(accountId: string): number;
    getTotalPendingSyncCount(): number;
    /** Reset the entire database */
    resetStore(): Promise<void>;
    private rowToEnvelope;
}
//# sourceMappingURL=db.d.ts.map