import { ASSEMBLYAI_TRANSCRIPTION_MODEL_ID } from "./assemblyai.js";
const CLOUD_PROVIDER_DESCRIPTORS = [
    {
        provider: "assemblyai",
        label: "AssemblyAI",
        standaloneLabel: "AssemblyAI",
        modelId: () => ASSEMBLYAI_TRANSCRIPTION_MODEL_ID,
    },
    {
        provider: "gemini",
        label: "Gemini",
        standaloneLabel: "Gemini",
        modelId: ({ geminiModelId }) => `google/${geminiModelId}`,
    },
    {
        provider: "openai",
        label: "OpenAI",
        standaloneLabel: "Whisper/OpenAI",
        modelId: () => "whisper-1",
    },
    {
        provider: "fal",
        label: "FAL",
        standaloneLabel: "Whisper/FAL",
        modelId: () => "fal-ai/wizper",
    },
    {
        provider: "deepgram",
        label: "Deepgram",
        standaloneLabel: "Deepgram",
        modelId: ({ deepgramModelId }) => `deepgram/${deepgramModelId}`,
    },
];
function getCloudProviderDescriptor(provider) {
    const descriptor = CLOUD_PROVIDER_DESCRIPTORS.find((entry) => entry.provider === provider);
    if (!descriptor)
        throw new Error(`Unknown cloud provider: ${provider}`);
    return descriptor;
}
function resolveCloudProviderOrderFromAvailability(availability) {
    return resolveCloudProviderOrder({
        assemblyaiApiKey: availability.hasAssemblyAi ? "1" : null,
        geminiApiKey: availability.hasGemini ? "1" : null,
        openaiApiKey: availability.hasOpenai ? "1" : null,
        falApiKey: availability.hasFal ? "1" : null,
        deepgramApiKey: availability.hasDeepgram ? "1" : null,
    });
}
export function resolveCloudProviderOrder(state) {
    const order = [];
    if (state.assemblyaiApiKey)
        order.push("assemblyai");
    if (state.geminiApiKey)
        order.push("gemini");
    if (state.openaiApiKey)
        order.push("openai");
    if (state.falApiKey)
        order.push("fal");
    if (state.deepgramApiKey)
        order.push("deepgram");
    return order;
}
export function cloudProviderLabel(provider, chained) {
    const descriptor = getCloudProviderDescriptor(provider);
    return chained ? descriptor.label : descriptor.standaloneLabel;
}
export function formatCloudFallbackTargets(providers) {
    return providers.map((provider) => cloudProviderLabel(provider, true)).join("/");
}
export function buildCloudProviderHint(availability) {
    const parts = resolveCloudProviderOrderFromAvailability(availability);
    return parts.length > 0 ? parts.join("->") : null;
}
export function buildCloudModelIdChain({ availability, geminiModelId, deepgramModelId, }) {
    const parts = resolveCloudProviderOrderFromAvailability(availability).map((provider) => getCloudProviderDescriptor(provider).modelId({ geminiModelId, deepgramModelId }));
    return parts.length > 0 ? parts.join("->") : null;
}
//# sourceMappingURL=cloud-providers.js.map