import { getFileExtension } from "./mime.js";
const VOICE_AUDIO_EXTENSIONS = new Set([".oga", ".ogg", ".opus", ".mp3", ".m4a"]);
/**
 * MIME types compatible with voice messages.
 * Telegram sendVoice supports OGG/Opus, MP3, and M4A.
 * https://core.telegram.org/bots/api#sendvoice
 */
const VOICE_MIME_TYPES = new Set([
    "audio/ogg",
    "audio/opus",
    "audio/mpeg",
    "audio/mp3",
    "audio/mp4",
    "audio/x-m4a",
    "audio/m4a",
]);
export function isVoiceCompatibleAudio(opts) {
    const mime = opts.contentType?.toLowerCase().trim();
    if (mime) {
        const baseMime = mime.split(";")[0].trim();
        if (VOICE_MIME_TYPES.has(baseMime)) {
            return true;
        }
    }
    const fileName = opts.fileName?.trim();
    if (!fileName)
        return false;
    const ext = getFileExtension(fileName);
    if (!ext)
        return false;
    return VOICE_AUDIO_EXTENSIONS.has(ext);
}
