/**
 * SpeechRTC — VolcEngine bidirectional TTS client with managed session reuse.
 *
 * 协议层（constants, helpers, SpeechRTCTransport）已拆分至 SpeechRTC.transport.js。
 */
import { EVENT, SESSION_STATE } from './SpeechRTC.transport';
/** _waitForEvent 等待者 */
interface SpeechRTCWaiter {
    values: unknown[];
    resolve: (payload: unknown) => void;
    reject: (error: unknown) => void;
}
/** 会话池条目 */
interface SpeechRTCPoolEntry {
    key: string;
    session: SpeechRTCSession;
    lastUsedAt: number;
}
/** SpeechRTCTransport 的结构化调用表面（供 Session 使用） */
interface ITransport {
    connectId: string;
    prepareSession(session: unknown): Promise<void>;
    releaseSession(session: unknown): void;
    sendEvent(eventCode: number, payload: unknown, sessionId?: string): Promise<void>;
    shutdown(options?: unknown): Promise<void>;
    _closeSocket(options?: unknown): void;
    _tryCancelStaleSession(sessionId: string): void;
    [key: string]: unknown;
}
declare class SpeechRTC {
    static EVENT: {
        NONE: number;
        START_CONNECTION: number;
        FINISH_CONNECTION: number;
        CONNECTION_STARTED: number;
        CONNECTION_FAILED: number;
        CONNECTION_FINISHED: number;
        START_SESSION: number;
        CANCEL_SESSION: number;
        FINISH_SESSION: number;
        SESSION_STARTED: number;
        SESSION_CANCELED: number;
        SESSION_FINISHED: number;
        SESSION_FAILED: number;
        USAGE_RESPONSE: number;
        TASK_REQUEST: number;
        UPDATE_CONFIG: number;
        AUDIO_MUTED: number;
        TTS_SENTENCE_START: number;
        TTS_SENTENCE_END: number;
        TTS_RESPONSE: number;
        TTS_ENDED: number;
        PODCAST_ROUND_START: number;
        PODCAST_ROUND_RESPONSE: number;
        PODCAST_ROUND_END: number;
        SOURCE_SUBTITLE_START: number;
        SOURCE_SUBTITLE_RESPONSE: number;
        SOURCE_SUBTITLE_END: number;
        TRANSLATION_SUBTITLE_START: number;
        TRANSLATION_SUBTITLE_RESPONSE: number;
        TRANSLATION_SUBTITLE_END: number;
    };
    static SESSION_STATE: {
        IDLE: string;
        CONNECTING: string;
        CONNECTED: string;
        STARTING: string;
        ACTIVE: string;
        FINISHING: string;
        FINISHED: string;
        CANCELED: string;
        CLOSED: string;
        FAILED: string;
    };
    sdk: unknown;
    options: Record<string, unknown>;
    maxParallelSessions: number;
    _sessionPool: SpeechRTCPoolEntry[];
    _transports: Set<Record<string, unknown>>;
    [key: string]: unknown;
    constructor(sdk: unknown, options?: Record<string, unknown>);
    createSession(config?: Record<string, unknown>): SpeechRTCSession;
    createTextStream(config?: Record<string, unknown>): SpeechRTCSession;
    synthesize(text: string, config?: Record<string, unknown>): Promise<unknown>;
    synthesizeChunks(chunks: unknown, config?: Record<string, unknown>): Promise<unknown>;
    shutdown(options?: Record<string, unknown>): Promise<void>;
    _createSessionInstance(config?: Record<string, unknown>, metadata?: Record<string, unknown>): SpeechRTCSession;
    _buildTextStreamPoolKey(config?: Record<string, unknown>): string;
    _findPooledSession(poolKey: string): SpeechRTCPoolEntry | null;
    _touchPooledSession(entry: SpeechRTCPoolEntry): void;
    _evictLeastRecentlyUsedInactiveSession(): SpeechRTCPoolEntry | null;
}
declare class SpeechRTCSession {
    speechRTC: Record<string, unknown>;
    transport: ITransport;
    sdk: unknown;
    options: Record<string, unknown>;
    isPooledStream: boolean;
    poolKey: string;
    _onStateChange: ((state?: unknown, session?: unknown) => void) | null;
    state: unknown;
    isConnected: boolean;
    isSessionActive: boolean;
    _listeners: Record<string, Array<(payload?: unknown) => void>>;
    _waiters: Map<unknown, SpeechRTCWaiter[]>;
    _audioContext: AudioContext | null;
    _audioTime: number;
    _activeSources: Set<unknown>;
    _encodedChunks: unknown[];
    _sessionResult: Record<string, unknown> | null;
    _usage: unknown;
    _sentenceText: string;
    _sessionIdleTimer: ReturnType<typeof setTimeout> | null;
    _audioUrl: string | null;
    [key: string]: unknown;
    constructor(speechRTC: Record<string, unknown>, config?: Record<string, unknown>, runtime?: Record<string, unknown>);
    on(event: string, callback: (payload?: unknown) => void): this;
    off(event: string, callback: (payload?: unknown) => void): this;
    emit(event: string, payload?: unknown): void;
    start(): Promise<this>;
    sendText(text: string, options?: Record<string, unknown>): Promise<void>;
    sendTextChunks(chunks: unknown, options?: Record<string, unknown>): Promise<unknown>;
    streamText(chunks: unknown, options?: Record<string, unknown>): Promise<unknown>;
    appendText(text: string, options?: Record<string, unknown>): Promise<void>;
    interrupt(options?: Record<string, unknown>): Promise<this>;
    beginText(text?: string, options?: Record<string, unknown>): Promise<this>;
    finish(options?: Record<string, unknown>): Promise<unknown>;
    cancel(options?: Record<string, unknown>): Promise<void>;
    stop(options?: Record<string, unknown>): Promise<unknown>;
    close(options?: Record<string, unknown>): Promise<unknown>;
    synthesize(text: string, options?: Record<string, unknown>): Promise<unknown>;
    synthesizeChunks(chunks: unknown, options?: Record<string, unknown>): Promise<unknown>;
    _sendSessionStart(): Promise<void>;
    _buildSessionStartPayload(): Record<string, unknown>;
    _handleFrame(frame: Record<string, unknown>): Promise<void>;
    _handleAudioFrame(frame: Record<string, unknown>): Promise<void>;
    _ensureAudioContext(): Promise<AudioContext | null>;
    _playPCMChunk(bytes: Uint8Array): Promise<void>;
    _buildAudioUrl(): string | null;
    _armSessionIdleTimer(): void;
    _clearSessionIdleTimer(): void;
    _handleSessionIdleTimeout(): Promise<void>;
    _waitForEvent(eventCodes: unknown, timeout?: number): Promise<unknown>;
    _resolveWaiters(key: unknown, payload: unknown): void;
    _resolveAllWaiters(error: unknown): void;
    _removeWaiter(waiter: SpeechRTCWaiter, skipKey?: unknown): void;
    _setState(state: unknown): void;
    _createProtocolError(frame: Record<string, unknown>, message: string): Error;
    _fail(error: unknown, source: string): void;
    _resetForReuse(): void;
    getRemainingPlaybackTime(): number;
    _closeAudio(): Promise<void>;
}
export { SpeechRTCSession, EVENT as SPEECH_RTC_EVENT, SESSION_STATE as SPEECH_RTC_SESSION_STATE };
export default SpeechRTC;
//# sourceMappingURL=SpeechRTC.d.ts.map