export interface ImapServerConfig {
    port?: number;
    sslPort?: number;
    host?: string;
    region?: string;
    bucket: string;
    prefix?: string;
    domain: string;
    users: Record<string, {
        password: string;
        email: string;
    }>;
    tls?: {
        key: string;
        cert: string;
    };
}
/**
 * IMAP Server that reads emails from S3
 */
export declare class ImapServer {
    private config;
    private s3;
    private server?;
    private tlsServer?;
    private sessions;
    private messageCache;
    private flagsCache;
    private uidMappingCache;
    private nextUidCache;
    private cacheTimestamp;
    private uidCounter;
    private readonly CACHE_TTL_MS;
    constructor(config: ImapServerConfig);
    /**
     * Start the IMAP server
     */
    start(): Promise<void>;
    /**
     * Stop the IMAP server
     */
    stop(): Promise<void>;
    /**
     * Handle new connection
     */
    private handleConnection;
    /**
     * Send response to client
     */
    private send;
    /**
     * Process IMAP command
     */
    private processCommand;
    /**
     * Handle CAPABILITY command
     */
    private handleCapability;
    /**
     * Handle LOGOUT command
     */
    private handleLogout;
    /**
     * Handle LOGIN command
     */
    private handleLogin;
    /**
     * Handle AUTHENTICATE command
     */
    private handleAuthenticate;
    /**
     * Handle SELECT command
     */
    private handleSelect;
    /**
     * Handle EXAMINE command (read-only SELECT)
     */
    private handleExamine;
    /**
     * Handle NOOP command - check for new messages
     */
    private handleNoop;
    /**
     * Handle CHECK command - request a checkpoint/sync
     */
    private handleCheck;
    /**
     * Handle LIST command
     */
    private handleList;
    /**
     * Handle LSUB command (subscribed folders)
     */
    private handleLsub;
    /**
     * Handle STATUS command
     */
    private handleStatus;
    /**
     * Handle FETCH command
     */
    private handleFetch;
    /**
     * Handle UID command (UID FETCH, UID SEARCH, etc.)
     */
    private handleUid;
    /**
     * Handle UID FETCH
     */
    private handleUidFetch;
    /**
     * Handle SEARCH command
     */
    private handleSearch;
    /**
     * Handle UID SEARCH
     */
    private handleUidSearch;
    /**
     * Handle STORE command
     * STORE sequence-set flags-operation flags
     * Example: STORE 1 +FLAGS (\Deleted)
     */
    private handleStore;
    /**
     * Handle UID STORE
     * UID STORE uid-set flags-operation flags
     */
    private handleUidStore;
    /**
     * Handle COPY command
     * COPY sequence-set mailbox
     */
    private handleCopy;
    /**
     * Handle UID COPY
     * UID COPY uid-set mailbox
     */
    private handleUidCopy;
    /**
     * Handle MOVE command (RFC 6851)
     * MOVE sequence-set mailbox
     */
    private handleMove;
    /**
     * Handle UID MOVE command (RFC 6851)
     * UID MOVE uid-set mailbox
     */
    private handleUidMove;
    /**
     * Handle UID EXPUNGE command (UIDPLUS extension)
     * UID EXPUNGE uid-set - expunges only specified UIDs
     */
    private handleUidExpunge;
    /**
     * Handle CLOSE command
     */
    private handleClose;
    /**
     * Handle EXPUNGE command
     * Removes messages marked with \Deleted flag
     */
    private handleExpunge;
    /**
     * Handle IDLE command
     */
    private handleIdle;
    /**
     * Handle STARTTLS command
     */
    private handleStartTls;
    /**
     * Handle NAMESPACE command
     */
    private handleNamespace;
    /**
     * Load messages from S3 for the selected folder
     */
    private loadMessages;
    /**
     * Load all messages from all folders for the "All Mail" virtual folder
     * Uses persistent UIDs for stable message identification across sessions
     */
    private loadAllMailFolder;
    /**
     * Load messages from S3 for a specific folder (used by STATUS command)
     * Uses persistent UIDs for stable message identification across sessions
     */
    private loadMessagesForFolder;
    /**
     * Parse email headers
     */
    private parseHeaders;
    /**
     * Build FETCH response
     */
    private buildFetchResponse;
    /**
     * Build ENVELOPE response
     */
    private buildEnvelope;
    /**
     * Format date for IMAP
     */
    private formatImapDate;
    /**
     * Parse IMAP sequence set (e.g., "1:*", "1,3,5", "1:10")
     */
    private parseSequenceSet;
    /**
     * Get UID validity value for a mailbox
     */
    private getUidValidity;
    /**
     * Get the S3 prefix for a folder
     */
    private getFolderPrefix;
    /**
     * Check if a folder is the virtual "All Mail" folder
     */
    private isAllMailFolder;
    /**
     * Load flags from S3
     */
    private loadFlags;
    /**
     * Save flags to S3
     */
    private saveFlags;
    /**
     * Load UID mapping from S3 (maps S3 keys to persistent UIDs)
     */
    private loadUidMapping;
    /**
     * Save UID mapping to S3
     */
    private saveUidMapping;
    /**
     * Get or assign a UID for a message (S3 key)
     * Returns existing UID if message was seen before, assigns new UID otherwise
     */
    private getOrAssignUid;
    /**
     * Get messages for a specific folder
     */
    private getMessagesForFolder;
    /**
     * Set messages for a specific folder
     */
    private setMessagesForFolder;
    /**
     * Get UID counter for a folder
     */
    private getUidCounterForFolder;
    /**
     * Set UID counter for a folder
     */
    private setUidCounterForFolder;
    /**
     * Handle XLIST command (deprecated Gmail extension, but some clients use it)
     */
    private handleXlist;
    /**
     * Handle CREATE command
     */
    private handleCreate;
    /**
     * Handle DELETE command
     */
    private handleDelete;
    /**
     * Handle SUBSCRIBE command
     */
    private handleSubscribe;
    /**
     * Handle UNSUBSCRIBE command
     */
    private handleUnsubscribe;
    /**
     * Handle RENAME command
     */
    private handleRename;
    /**
     * Handle APPEND command
     */
    private handleAppend;
}
/**
 * Create and start an IMAP server
 */
export declare function startImapServer(config: ImapServerConfig): Promise<ImapServer>;
