import { OnModuleDestroy, OnModuleInit, OnApplicationBootstrap } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { Repository, DataSource } from 'typeorm';
import { Session, SessionStatus } from './entities/session.entity';
import { CreateSessionDto, SessionConfigResponseDto, UpdateSessionConfigDto } from './dto';
import { EngineRegistry } from '../../engine/engine-registry.service';
import { SessionLivenessWatchdog } from './session-liveness-watchdog.service';
import { SessionErrorStore } from './session-error-store.service';
import { SessionRestrictionStore } from './session-restriction-store.service';
import { PresenceStore, type ChatPresence } from './presence-store.service';
import { SessionEngineLifecycle } from './session-engine-lifecycle.service';
import { SessionOwnershipService } from './session-ownership.service';
import { ListOptions } from '../../common/utils/paginate';
import { IWhatsAppEngine, ChatSummary, ChatState } from '../../engine/interfaces/whatsapp-engine.interface';
import { HookManager } from '../../core/hooks';
export declare const AUTOSTART_THROTTLE_MS = 2000;
export declare class SessionService implements OnModuleDestroy, OnModuleInit, OnApplicationBootstrap {
    private readonly sessionRepository;
    private readonly dataSource;
    private readonly engineRegistry;
    private readonly watchdog;
    private readonly sessionErrors;
    private readonly sessionRestrictions;
    private readonly presence;
    private readonly hookManager;
    private readonly engineLifecycle;
    private readonly configService?;
    private readonly ownership?;
    private readonly logger;
    private get engines();
    private autoStartRun;
    private shuttingDown;
    constructor(sessionRepository: Repository<Session>, dataSource: DataSource, engineRegistry: EngineRegistry, watchdog: SessionLivenessWatchdog, sessionErrors: SessionErrorStore, sessionRestrictions: SessionRestrictionStore, presence: PresenceStore, hookManager: HookManager, engineLifecycle: SessionEngineLifecycle, configService?: ConfigService | undefined, ownership?: SessionOwnershipService | undefined);
    onModuleInit(): Promise<void>;
    onApplicationBootstrap(): void;
    private autoStartSessions;
    onModuleDestroy(): Promise<void>;
    create(dto: CreateSessionDto): Promise<Session>;
    findAll(allowedSessions?: string[] | null, opts?: ListOptions): Promise<Session[]>;
    findOne(id: string): Promise<Session>;
    private attachRuntimeState;
    private projectConfig;
    getConfig(id: string): Promise<SessionConfigResponseDto>;
    updateConfig(id: string, dto: UpdateSessionConfigDto): Promise<SessionConfigResponseDto>;
    delete(id: string): Promise<void>;
    private discardStopMarkForMissingSession;
    private assertNotHeldElsewhere;
    start(id: string): Promise<Session>;
    private startWithTransientRetry;
    stop(id: string): Promise<Session>;
    logout(id: string): Promise<Session>;
    forceKill(id: string): Promise<Session>;
    private releaseUnlessEngineActive;
    getQRCode(id: string): Promise<{
        qrCode: string;
        status: SessionStatus;
    }>;
    requestPairingCode(id: string, phoneNumber: string): Promise<{
        pairingCode: string;
        status: SessionStatus;
    }>;
    getEngine(id: string): IWhatsAppEngine | undefined;
    private requireEngine;
    getGroups(id: string, opts?: ListOptions): Promise<{
        id: string;
        name: string;
        linkedParentJID?: string | null;
    }[]>;
    getChats(id: string, opts?: ListOptions): Promise<ChatSummary[]>;
    subscribeToPresence(id: string, chatId: string): Promise<void>;
    setOnlinePresence(id: string, available: boolean): Promise<void>;
    getPresence(id: string, chatId: string): Promise<ChatPresence | null>;
    sendSeen(id: string, chatId: string, messageIds?: string[]): Promise<boolean>;
    markUnread(id: string, chatId: string): Promise<boolean>;
    clearChatMessages(id: string, chatId: string): Promise<boolean>;
    archiveChat(id: string, chatId: string, archive: boolean): Promise<boolean>;
    muteChat(id: string, chatId: string, muteUntil: number | null): Promise<void>;
    pinChat(id: string, chatId: string, pin: boolean): Promise<boolean>;
    deleteChat(id: string, chatId: string): Promise<boolean>;
    sendChatState(id: string, chatId: string, state: ChatState): Promise<void>;
    getStats(allowedSessions?: string[] | null): Promise<{
        total: number;
        active: number;
        ready: number;
        disconnected: number;
        byStatus: Record<string, number>;
        memoryUsage: {
            heapUsed: number;
            heapTotal: number;
            rss: number;
        };
    }>;
    isActive(id: string): boolean;
    getActiveSessionIds(): string[];
    stopOrphanEngines(sessionIds: string[]): Promise<{
        stopped: string[];
        notRunning: string[];
        failed: string[];
    }>;
}
