import { ProviderClass } from '@builderbot/bot';
import type { BotContext, Button, SendOptions } from '@builderbot/bot/dist/types';
import type { PathOrFileDescriptor } from 'fs';
import NodeCache from 'node-cache';
import type polka from 'polka';
import type { IStickerOptions } from 'wa-sticker-formatter';
import { BaileysEventMap, WAMessage, WASocket, proto } from './sherpaWrapper';
import type { SherpaGlobalVendorArgs } from './type';
declare class SherpaProvider extends ProviderClass<WASocket> {
    globalVendorArgs: SherpaGlobalVendorArgs;
    private reconnectAttempts;
    private maxReconnectAttempts;
    private reconnectDelay;
    private healthCheckInterval?;
    private presenceInterval?;
    private periodicCleanupInterval?;
    private badSessionCount;
    msgRetryCounterCache?: NodeCache;
    userDevicesCache?: NodeCache;
    private logger;
    private logStream;
    private idsDuplicates;
    private mapSet;
    constructor(args: Partial<SherpaGlobalVendorArgs>);
    /**
     * Setup cleanup handlers
     * @description
     * - Remove existing listeners to prevent duplicates
     * - Add new listeners
     * - Add cleanup function to all listeners
     * - Add cleanup function to uncaughtException and unhandledRejection
     * - Add cleanup function to SIGINT, SIGTERM, SIGUSR1, SIGUSR2
     * - Add cleanup function to process.exit
     */
    private setupCleanupHandlers;
    private setupPeriodicCleanup;
    private cleanup;
    releaseSessionFiles(): Promise<void>;
    protected beforeHttpServerInit(): void;
    protected afterHttpServerInit(): void;
    indexHome: polka.Middleware;
    protected getMessage: (key: {
        remoteJid: string;
        id: string;
    }) => Promise<proto.Message>;
    protected saveCredsGlobal: (() => Promise<void>) | null;
    /**
     * Iniciar todo Sherpa
     */
    protected initVendor: () => Promise<import("whaileys").BaileysEventEmitter & {
        process(handler: (events: Partial<import("whaileys/lib/Types").BaileysEventMap>) => void | Promise<void>): () => void;
        buffer(): boolean;
        createBufferedFunction<A extends any[], T_1>(work: (...args: A) => Promise<T_1>): (...args: A) => Promise<T_1>;
        flush(): Promise<void>;
        processInBuffer(task: Promise<any>): any;
    }>;
    /**
     * Extrae el número de teléfono (from) de un mensaje
     * @param messageCtx - Contexto del mensaje
     * @returns El número de teléfono extraído
     */
    private extractFromFromMessage;
    /**
     * Map native events that the Provider class expects
     * to have a standard set of events
     * @returns
     */
    protected busEvents: () => {
        event: keyof BaileysEventMap;
        func: (arg?: any, arg2?: any) => any;
    }[];
    /**
     * @param {string} orderId
     * @param {string} orderToken
     * @example await getOrderDetails('order-id', 'order-token')
     */
    getOrderDetails: (orderId: string, orderToken: string) => Promise<import("whaileys").OrderDetails>;
    /**
     * @deprecated sendPoll is not available in whaileys provider
     * @param {string} number
     * @param {string} text
     * @param {object} poll
     * @returns {Promise<false>}
     */
    sendPoll: (numberIn: string, text: string, poll: {
        options: string[];
        multiselect: any;
    }) => Promise<false>;
    /**
     * Obtener LID (Local Identifier) para un número de teléfono (PN)
     * @param {string} phoneNumber - Número de teléfono en formato JID (e.g., '1234567890@s.whatsapp.net')
     * @returns {Promise<string|null>} - El LID correspondiente o null si no se encuentra
     * @example await getLIDForPN('1234567890@s.whatsapp.net')
     */
    getLIDForPN: (phoneNumber: string) => Promise<any>;
    /**
     * Obtener número de teléfono (PN) para un LID (Local Identifier)
     * @param {string} lid - Local Identifier
     * @returns {Promise<string|null>} - El número de teléfono correspondiente o null si no se encuentra
     * @example await getPNForLID('lid:xxxxxx')
     */
    getPNForLID: (lid: string) => Promise<any>;
    /**
     * @param {string} number
     * @param {string} message
     * @example await sendMessage('+XXXXXXXXXXX', 'https://dominio.com/imagen.jpg' | 'img/imagen.jpg')
     */
    sendMedia: (number: string, imageUrl: string, text: string) => Promise<proto.WebMessageInfo>;
    /**
     * Returns true only when the underlying WebSocket is fully open (readyState === 1).
     * Used as a guard before any send call to avoid silent message loss during reconnects.
     */
    private isVendorReady;
    /**
     * Enviar imagen
     * @param {*} number
     * @param {*} imageUrl
     * @param {*} text
     * @returns
     */
    sendImage: (number: string, filePath: string, text: any) => Promise<proto.WebMessageInfo>;
    /**
     * Enviar video
     * @param {*} number
     * @param {*} imageUrl
     * @param {*} text
     * @returns
     */
    sendVideo: (number: string, filePath: PathOrFileDescriptor, text: any) => Promise<proto.WebMessageInfo>;
    /**
     * Enviar audio
     * @alpha
     * @param {string} number
     * @param {string} message
     * @param {boolean} voiceNote optional
     * @example await sendMessage('+XXXXXXXXXXX', 'audio.mp3')
     */
    sendAudio: (number: string, audioUrl: string) => Promise<proto.WebMessageInfo>;
    /**
     *
     * @param {string} number
     * @param {string} message
     * @returns
     */
    sendText: (number: string, message: string) => Promise<proto.WebMessageInfo>;
    /**
     *
     * @param {string} number
     * @param {string} filePath
     * @example await sendMessage('+XXXXXXXXXXX', './document/file.pdf')
     */
    sendFile: (number: string, filePath: string, text: string) => Promise<proto.WebMessageInfo>;
    /**
     * @deprecated Buttons are not available in this provider, please use sendButtons instead
     * @private
     * @param {string} number
     * @param {string} text
     * @param {string} footer
     * @param {Array} buttons
     * @example await sendMessage("+XXXXXXXXXXX", "Your Text", "Your Footer", [{"buttonId": "id", "buttonText": {"displayText": "Button"}, "type": 1}])
     */
    sendButtons: (number: string, text: string, buttons: Button[]) => Promise<proto.WebMessageInfo>;
    /**
     * TODO: Necesita terminar de implementar el sendMedia y sendButton guiarse:
     * https://github.com/leifermendez/bot-whatsapp/blob/4e0fcbd8347f8a430adb43351b5415098a5d10df/packages/provider/src/web-whatsapp/index.js#L165
     * @param {string} number
     * @param {string} message
     * @example await sendMessage('+XXXXXXXXXXX', 'Hello World')
     */
    sendMessage: (numberIn: string, message: string, options?: SendOptions) => Promise<any>;
    /**
     * @param {string} remoteJid
     * @param {string} latitude
     * @param {string} longitude
     * @param {any} messages
     * @example await sendLocation("xxxxxxxxxxx@c.us" || "xxxxxxxxxxxxxxxxxx@g.us", "xx.xxxx", "xx.xxxx", messages)
     */
    sendLocation: (remoteJid: string, latitude: any, longitude: any, messages?: any) => Promise<{
        status: string;
    }>;
    /**
     * @param {string} remoteJid
     * @param {string} contactNumber
     * @param {string} displayName
     * @param {string} orgName
     * @param {any} messages - optional
     * @example await sendContact("xxxxxxxxxxx@c.us" || "xxxxxxxxxxxxxxxxxx@g.us", "+xxxxxxxxxxx", "Robin Smith", messages)
     */
    sendContact: (remoteJid: any, contactNumber: {
        replaceAll: (arg0: string, arg1: string) => any;
    }, displayName: string, orgName: string, messages?: any) => Promise<{
        status: string;
    }>;
    /**
     * @param {string} remoteJid
     * @param {string} WAPresence
     * @example await sendPresenceUpdate("xxxxxxxxxxx@c.us" || "xxxxxxxxxxxxxxxxxx@g.us", "recording")
     */
    sendPresenceUpdate: (remoteJid: any, WAPresence: any) => Promise<void>;
    /**
     * @param {string} remoteJid
     * @param {string} url
     * @param {object} stickerOptions
     * @param {any} messages - optional
     * @example await sendSticker("xxxxxxxxxxx@c.us" || "xxxxxxxxxxxxxxxxxx@g.us", "https://dn/image.png" || "https://dn/image.gif" || "https://dn/image.mp4", {pack: 'User', author: 'Me'} messages)
     */
    sendSticker: (remoteJid: any, url: string | Buffer, stickerOptions: Partial<IStickerOptions>, messages?: any) => Promise<void>;
    private getMimeType;
    private generateFileName;
    /**
     * Return Path absolute
     * @param ctx
     * @param options
     * @returns
     */
    saveFile: (ctx: Partial<WAMessage & BotContext>, options?: {
        path: string;
    }) => Promise<string>;
    /**
     * Starts a periodic health check that verifies the WebSocket connection is alive.
     * If the connection is detected as dead (zombie), it triggers a reconnect.
     * Also sends periodic presence updates as an application-level heartbeat
     * to prevent WhatsApp from considering the connection inactive.
     */
    private startHealthCheck;
    private stopHealthCheck;
    private shouldReconnect;
    private delayedReconnect;
}
export { SherpaProvider };
//# sourceMappingURL=sherpa.d.ts.map