export class ModelRouter {
    mappings;
    passthrough;
    fallback;
    constructor(config) {
        this.mappings = new Map(config.modelMappings.map((m) => [m.from, m]));
        this.passthrough = new Set(config.passthroughModels ?? []);
        this.fallback = config.fallbackChain;
    }
    resolve(requestedModel) {
        const mapping = this.mappings.get(requestedModel);
        if (mapping) {
            return { provider: mapping.provider, model: mapping.to };
        }
        if (this.passthrough.has(requestedModel)) {
            return { provider: "anthropic", model: requestedModel };
        }
        if (requestedModel.startsWith("gemini-")) {
            return { provider: "vertex", model: requestedModel };
        }
        if (requestedModel.startsWith("claude-")) {
            return { provider: "anthropic", model: requestedModel };
        }
        return { provider: null, model: requestedModel };
    }
    isClaudeTarget(requestedModel) {
        return this.resolve(requestedModel).provider === "anthropic";
    }
    getFallbackChain() {
        return this.fallback;
    }
    /** Return the raw model mapping entries (used by /v1/models). */
    getModelMappings() {
        return Array.from(this.mappings.values());
    }
    /** Return models configured for passthrough (used by /v1/models). */
    getPassthroughModels() {
        return Array.from(this.passthrough);
    }
}
