/**
 * WhatsApp Service
 *
 * Manages WhatsApp connection via Baileys (WhatsApp Web multi-device protocol).
 * Handles QR code pairing, auth state persistence, and bidirectional messaging.
 *
 * @module services/whatsapp
 */
import { EventEmitter } from 'events';
import type { WhatsAppConfig, WhatsAppIncomingMessage, WhatsAppOutgoingMessage, WhatsAppServiceStatus, WhatsAppConversationContext } from '../../types/whatsapp.types.js';
/**
 * Events emitted by WhatsAppService
 */
export interface WhatsAppServiceEvents {
    message: (message: WhatsAppIncomingMessage) => void;
    qr: (qrCode: string) => void;
    connected: () => void;
    disconnected: (reason?: string) => void;
    error: (error: Error) => void;
}
/**
 * WhatsApp Service singleton
 *
 * Manages the Baileys WebSocket connection, QR pairing flow,
 * and message send/receive lifecycle.
 *
 * @example
 * ```typescript
 * const service = getWhatsAppService();
 * await service.initialize({ allowedContacts: ['+1234567890'] });
 * service.on('message', (msg) => console.log(msg.text));
 * ```
 */
export declare class WhatsAppService extends EventEmitter {
    private logger;
    private sock;
    private config;
    private connected;
    private currentQrCode;
    private messagesSent;
    private messagesReceived;
    private phoneNumber;
    private conversationContexts;
    private reconnectAttempts;
    private reconnectTimer;
    private static readonly MAX_RECONNECT_DELAY_MS;
    private static readonly MAX_RECONNECT_ATTEMPTS;
    /**
     * Initialize the WhatsApp connection.
     * Sets up Baileys socket, auth state persistence, and event handlers.
     *
     * @param config - WhatsApp configuration
     */
    initialize(config: WhatsAppConfig): Promise<void>;
    /**
     * Process an incoming Baileys message and emit as WhatsAppIncomingMessage.
     *
     * Extracts text from various WhatsApp message types (conversation, extendedTextMessage),
     * validates the sender against the allowed contacts list, and emits a normalized
     * message event for the bridge to handle.
     *
     * Messages are silently ignored if:
     * - Sent by this account (fromMe = true)
     * - No text content present (images, stickers, etc.)
     * - Sender not in allowedContacts list (when configured)
     *
     * @param rawMsg - Raw Baileys message object containing key, message content, and metadata
     */
    private handleIncomingMessage;
    /**
     * Send a text message via WhatsApp.
     *
     * @param msg - Outgoing message with destination and text
     * @throws Error if not connected or message too long
     */
    sendMessage(msg: WhatsAppOutgoingMessage): Promise<void>;
    /**
     * Send a file (document) via WhatsApp.
     *
     * @param chatId - Destination chat JID
     * @param filePath - Absolute path to the file on disk
     * @param caption - Optional caption for the file
     * @throws Error if not connected or file too large
     */
    sendFile(chatId: string, filePath: string, caption?: string): Promise<void>;
    /**
     * Disconnect from WhatsApp gracefully.
     */
    disconnect(): Promise<void>;
    /**
     * Get current connection status.
     *
     * @returns WhatsApp service status object
     */
    getStatus(): WhatsAppServiceStatus;
    /**
     * Check if WhatsApp is currently connected.
     *
     * @returns True if connected
     */
    isConnected(): boolean;
    /**
     * Get the current QR code for pairing.
     *
     * @returns QR code string or null if not pending
     */
    getQRCode(): string | null;
    /**
     * Get or create a conversation context for a chat.
     *
     * @param chatId - Chat JID
     * @param contactName - Contact display name
     * @returns Conversation context for message routing
     */
    getConversationContext(chatId: string, contactName: string): WhatsAppConversationContext;
}
/**
 * Get WhatsApp service singleton
 *
 * @returns WhatsAppService instance
 */
export declare function getWhatsAppService(): WhatsAppService;
/**
 * Reset WhatsApp service singleton (for testing)
 */
export declare function resetWhatsAppService(): void;
//# sourceMappingURL=whatsapp.service.d.ts.map