/**
 * WhatsApp channel connector (baileys / WhatsApp Web).
 *
 * Connects using the multi-file auth state (QR link on first run, then
 * persisted credentials). Emits a QR data-URL for the UI, surfaces inbound
 * text messages, and sends replies.
 *
 * baileys + qrcode are lazy-imported by the default factories so unit tests can
 * inject fakes without importing the native-ish deps.
 */
import type { ChannelConnector, ChannelConnectorEvents, ChannelStatus, InboundMessage, OutboundMessage } from "../types.js";
export interface WAMessageKey {
    remoteJid?: string | null;
    fromMe?: boolean | null;
    participant?: string | null;
    id?: string | null;
}
export interface WAMessage {
    key: WAMessageKey;
    pushName?: string | null;
    message?: Record<string, unknown> | null;
    messageTimestamp?: number | Long | null;
}
interface Long {
    toNumber(): number;
    low: number;
}
export interface WASocketLike {
    ev: {
        on(event: string, listener: (arg: unknown) => void): void;
    };
    sendMessage(jid: string, content: {
        text: string;
    }): Promise<unknown>;
    user?: {
        id?: string;
        lid?: string;
    } | null;
    end?(error?: Error): void;
    ws?: {
        close(): void;
    };
    logout?(): Promise<void>;
}
export interface AuthStateHandle {
    state: unknown;
    saveCreds: () => Promise<void>;
}
export interface WhatsAppConnectorDeps {
    /** Directory for persisted credentials. Default ~/.jait/channels/whatsapp. */
    authDir?: string;
    /** baileys socket factory. Default: dynamic import of baileys makeWASocket. */
    makeSocket?: (opts: {
        auth: unknown;
        printQRInTerminal: boolean;
        browser: unknown;
    }) => WASocketLike;
    /** Auth-state loader. Default: baileys useMultiFileAuthState. */
    loadAuthState?: (dir: string) => Promise<AuthStateHandle>;
    /** QR encoder → data-URL. Default: qrcode.toDataURL. */
    encodeQr?: (text: string) => Promise<string>;
    /** Status code that means "logged out" (no auto-reconnect). Default 401. */
    loggedOutStatusCode?: number;
    log?: (msg: string, ...args: unknown[]) => void;
}
/** Extract plain text from a baileys message, if any. */
export declare function extractText(message: Record<string, unknown> | null | undefined): string;
/** Bare number portion of a JID, e.g. "49170...:5@s.whatsapp.net" → "49170...". */
export declare function bareJid(jid: string | null | undefined): string;
export declare class WhatsAppConnector implements ChannelConnector {
    readonly id = "whatsapp";
    readonly label = "WhatsApp";
    private readonly authDir;
    private readonly deps;
    private sock;
    private _status;
    private _qr;
    /** Bare ids that identify this account (phone-number JID and LID alias). */
    private selfBares;
    private events;
    private stopping;
    constructor(deps?: WhatsAppConnectorDeps);
    status(): ChannelStatus;
    currentQr(): string | null;
    private log;
    private setStatus;
    start(events: ChannelConnectorEvents): Promise<void>;
    private loadAuth;
    private buildSocket;
    private encodeQr;
    private connect;
    /** Convert a baileys message to an InboundMessage, or null if not text. */
    toInbound(m: WAMessage): InboundMessage | null;
    send(msg: OutboundMessage): Promise<void>;
    stop(): Promise<void>;
}
export {};
//# sourceMappingURL=connector.d.ts.map