import type { JaitDB } from "../../db/connection.js";
import type { UserSecretService } from "../user-secrets.js";
import { type OAuthClientCredentials } from "./oauth.js";
import type { EmailAccount, EmailFolder, EmailMessageFull, EmailMessageSummary, EmailProvider, ListMessagesOptions, SendMessageInput } from "./types.js";
export declare class EmailService {
    private readonly db;
    private readonly secrets;
    private readonly clients;
    private readonly pending;
    constructor(db: JaitDB, secrets: UserSecretService);
    /** Resolve OAuth app credentials: per-user secret first, then env. */
    resolveCredentials(provider: EmailProvider, userId: string | null): OAuthClientCredentials | null;
    /** Which providers are ready to connect (have OAuth app credentials). */
    configuredProviders(userId: string | null): Record<EmailProvider, boolean>;
    saveAppCredentials(userId: string | null, provider: EmailProvider, creds: OAuthClientCredentials): void;
    startConnect(params: {
        userId: string | null;
        provider: EmailProvider;
        redirectUri: string;
    }): {
        authUrl: string;
    };
    completeConnect(params: {
        code: string;
        state: string;
    }): Promise<EmailAccount>;
    listAccounts(userId: string | null): EmailAccount[];
    getAccount(userId: string | null, accountId: string): EmailAccount | null;
    /** Resolve an account by id, or fall back to the user's first account. */
    resolveAccount(userId: string | null, accountId?: string): EmailAccount;
    disconnect(userId: string | null, accountId: string): boolean;
    private upsertAccount;
    private storeTokens;
    private loadTokens;
    private findTokenSecretId;
    private validAccessToken;
    listMessages(userId: string | null, accountId: string | undefined, opts: ListMessagesOptions): Promise<{
        account: EmailAccount;
        messages: EmailMessageSummary[];
    }>;
    getMessage(userId: string | null, accountId: string | undefined, id: string): Promise<EmailMessageFull>;
    sendMessage(userId: string | null, accountId: string | undefined, input: SendMessageInput): Promise<{
        id: string;
    }>;
    tagMessage(userId: string | null, accountId: string | undefined, id: string, add: string[], remove: string[]): Promise<void>;
    deleteMessage(userId: string | null, accountId: string | undefined, id: string): Promise<void>;
    listFolders(userId: string | null, accountId: string | undefined): Promise<EmailFolder[]>;
    private gcPending;
}
//# sourceMappingURL=service.d.ts.map