//#region src/voice/tts/service.ts
/** Per-channel encoding for outbound TTS. Only ids that xopc actually delivers on are listed; anything else uses `default`. */
const CHANNEL_OUTPUT_FORMATS = {
	telegram: {
		format: "opus",
		voiceCompatible: true
	},
	/** Weixin ilink: VoiceItem encode_type 7 = MP3 per API types. */
	weixin: {
		format: "mp3",
		voiceCompatible: true
	},
	webchat: {
		format: "mp3",
		voiceCompatible: false
	},
	cli: {
		format: "mp3",
		voiceCompatible: false
	},
	default: {
		format: "mp3",
		voiceCompatible: false
	}
};
function getChannelOutputFormat(channel) {
	if (!channel) return CHANNEL_OUTPUT_FORMATS.default;
	return CHANNEL_OUTPUT_FORMATS[channel.toLowerCase()] || CHANNEL_OUTPUT_FORMATS.default;
}
function getSupportedChannels() {
	return Object.keys(CHANNEL_OUTPUT_FORMATS).filter((k) => k !== "default");
}
function isVoiceCompatibleChannel(channel) {
	return getChannelOutputFormat(channel).voiceCompatible;
}
function shouldUseTTS(config, inboundAudio) {
	if (!config?.enabled) return {
		useTTS: false,
		reason: "TTS disabled"
	};
	const trigger = config.trigger ?? "off";
	switch (trigger) {
		case "off": return {
			useTTS: false,
			reason: "trigger=off"
		};
		case "always": return {
			useTTS: true,
			reason: "trigger=always"
		};
		case "inbound": return inboundAudio === true ? {
			useTTS: true,
			reason: "trigger=inbound + inboundAudio=true"
		} : {
			useTTS: false,
			reason: "trigger=inbound but no inbound audio"
		};
		case "tagged": return {
			useTTS: false,
			reason: "trigger=tagged (directive check in TTS module)"
		};
		default: return {
			useTTS: false,
			reason: `unknown trigger=${trigger}`
		};
	}
}
var TTSService = class {
	constructor(config) {
		this.config = config;
	}
	isEnabled() {
		return this.config.enabled;
	}
	getTriggerMode() {
		return this.config.trigger;
	}
	async speak(text, context) {
		const { speak } = await import("./speak-core.js");
		return speak(text, this.config, { tts: { format: getChannelOutputFormat(context?.channel).format } });
	}
};
//#endregion
export { TTSService, getChannelOutputFormat, getSupportedChannels, isVoiceCompatibleChannel, shouldUseTTS };

//# sourceMappingURL=service.js.map