/**
 * AudioEngine.utils.js — AudioEngine 内部工具层
 *
 * 包含：
 * - 常量（DB 名称、语音参数键、超时配置、音符映射等）
 * - IndexedDB 辅助函数（_openDB / _getFromDB / _saveToDB / _clearDB）
 * - Blob/ArrayBuffer 类型检查工具
 * - MIDI 工具（_midiToFrequency / _noteNameToMidi / _normalizeMidiSequence 等）
 * - 音频超时估算（_estimateDurationFromText / _timeoutFromBuffer 等）
 * - 缓存键构建（_buildCacheKey / _extractSpeechParams）
 *
 * 供 AudioEngine.js 主类导入使用，不直接暴露给外部。
 */
declare const DB_NAME = "keepwork-audio-cache";
declare const STORE_NAME = "audio-blobs";
declare const DB_VERSION = 1;
/** Speech parameter keys that affect audio output (sorted for deterministic serialization) */
declare const SPEECH_PARAM_KEYS: string[];
/** Estimated average reading speed: characters per second for CJK text */
declare const CJK_CHARS_PER_SECOND = 4.5;
/** Estimated average reading speed: words per second for Latin text */
declare const LATIN_WORDS_PER_SECOND = 2.5;
/** Minimum timeout in ms for text-length-based estimates */
declare const MIN_TEXT_TIMEOUT = 2000;
/** Maximum timeout in ms for text-length-based estimates */
declare const MAX_TEXT_TIMEOUT = 60000;
/** Extra padding added to estimated duration (ms) */
declare const TIMEOUT_PADDING = 1500;
/** Minimum timeout for URL/fallback playback when actual duration is unknown */
declare const MIN_UNKNOWN_AUDIO_TIMEOUT = 5000;
/** Conservative multiplier for estimated durations when metadata is unavailable */
declare const UNKNOWN_AUDIO_TIMEOUT_MULTIPLIER = 1.8;
/** Extra loading budget for SDK TTS fallback before audio playback begins */
declare const SPEAK_FALLBACK_LOAD_PADDING = 8000;
/** Maximum timeout for SDK TTS fallback including network loading */
declare const MAX_SPEAK_FALLBACK_TIMEOUT = 90000;
declare const AUDIO_RECORD_TYPE = "audioBlob";
declare const MIDI_RECORD_TYPE = "midiSequence";
declare const NOTE_NAME_TO_SEMITONE: Record<string, number>;
declare function _openDB(): Promise<IDBDatabase>;
declare function _getFromDB(cacheKey: string): Promise<unknown>;
declare function _saveToDB(cacheKey: string, blob: unknown): Promise<void>;
declare function _isBlob(value: unknown): value is Blob;
declare function _isArrayBuffer(value: unknown): value is ArrayBuffer;
declare function _isArrayBufferView(value: unknown): value is ArrayBufferView;
declare function _isAudioUrl(value: unknown): boolean;
declare function _createAudioBlobFromData(data: unknown, mimeType?: string): Blob | null;
declare function _getAudioSourceFromOptions(options: Record<string, unknown> | null | undefined): unknown;
declare function _getMidiSequenceFromOptions(options: Record<string, unknown> | null | undefined): unknown;
declare function _midiToFrequency(note: number): number;
declare function _noteNameToMidi(noteName: unknown): number | null;
declare function _normalizeMidiNoteValue(value: unknown): number | null;
declare function _normalizeMidiSequence(sequence: unknown, options?: Record<string, unknown>): Record<string, unknown> | null;
declare function _normalizeOutputVolume(value: unknown, fallback?: number): number;
declare function _clearDB(): Promise<void>;
declare function _extractSpeechParams(options: Record<string, unknown> | null | undefined): Record<string, unknown> | null;
declare function _buildCacheKey(text: string, options: Record<string, unknown> | null | undefined): string;
/**
 * Estimate audio duration in ms from text content.
 * Uses CJK character count or Latin word count as heuristic.
 */
declare function _estimateDurationFromText(text: string): number;
/** Derive timeout from an AudioBuffer's actual duration. */
declare function _timeoutFromBuffer(audioBuffer: AudioBuffer | null | undefined): number | null;
/** Derive timeout from HTMLMediaElement metadata. */
declare function _timeoutFromMediaDuration(duration: number): number | null;
/** Conservative timeout when actual audio duration is not known. */
declare function _timeoutForUnknownAudio(text: string): number;
/** Conservative timeout for SDK-managed TTS playback (includes loading budget). */
declare function _timeoutForSpeakFallback(text: string): number;
export { DB_NAME, STORE_NAME, DB_VERSION, SPEECH_PARAM_KEYS, CJK_CHARS_PER_SECOND, LATIN_WORDS_PER_SECOND, MIN_TEXT_TIMEOUT, MAX_TEXT_TIMEOUT, TIMEOUT_PADDING, MIN_UNKNOWN_AUDIO_TIMEOUT, UNKNOWN_AUDIO_TIMEOUT_MULTIPLIER, SPEAK_FALLBACK_LOAD_PADDING, MAX_SPEAK_FALLBACK_TIMEOUT, AUDIO_RECORD_TYPE, MIDI_RECORD_TYPE, NOTE_NAME_TO_SEMITONE, _openDB, _getFromDB, _saveToDB, _clearDB, _isBlob, _isArrayBuffer, _isArrayBufferView, _isAudioUrl, _createAudioBlobFromData, _getAudioSourceFromOptions, _getMidiSequenceFromOptions, _midiToFrequency, _noteNameToMidi, _normalizeMidiNoteValue, _normalizeMidiSequence, _normalizeOutputVolume, _extractSpeechParams, _buildCacheKey, _estimateDurationFromText, _timeoutFromBuffer, _timeoutFromMediaDuration, _timeoutForUnknownAudio, _timeoutForSpeakFallback, };
//# sourceMappingURL=AudioEngine.utils.d.ts.map