import { BaseProvider } from "../BaseProvider.js";
import { DEFAULT_GEMINI_BASE_URL } from "../../constants.js";
import { Capabilities } from "./Capabilities.js";
import { GeminiChat } from "./Chat.js";
import { GeminiStreaming } from "./Streaming.js";
import { GeminiModels } from "./Models.js";
import { GeminiImage } from "./Image.js";
import { GeminiEmbeddings } from "./Embeddings.js";
import { GeminiTranscription } from "./Transcription.js";
export class GeminiProvider extends BaseProvider {
    options;
    baseUrl;
    chatHandler;
    streamingHandler;
    modelsHandler;
    imageHandler;
    embeddingHandler;
    transcriptionHandler;
    capabilities = {
        supportsVision: (model) => Capabilities.supportsVision(model),
        supportsTools: (model) => Capabilities.supportsTools(model),
        supportsStructuredOutput: (model) => Capabilities.supportsStructuredOutput(model),
        supportsEmbeddings: (model) => Capabilities.supportsEmbeddings(model),
        supportsImageGeneration: (model) => Capabilities.supportsImageGeneration(model),
        supportsTranscription: (model) => Capabilities.supportsTranscription(model),
        supportsModeration: (model) => Capabilities.supportsModeration(model),
        supportsReasoning: (_model) => false,
        supportsDeveloperRole: (_model) => true,
        getContextWindow: (model) => Capabilities.getContextWindow(model)
    };
    constructor(options) {
        super();
        this.options = options;
        this.baseUrl = options.baseUrl ?? DEFAULT_GEMINI_BASE_URL;
        this.chatHandler = new GeminiChat(this.baseUrl, options.apiKey);
        this.streamingHandler = new GeminiStreaming(this.baseUrl, options.apiKey);
        this.modelsHandler = new GeminiModels(this.baseUrl, options.apiKey);
        this.imageHandler = new GeminiImage(this.baseUrl, options.apiKey);
        this.embeddingHandler = new GeminiEmbeddings(this.baseUrl, options.apiKey);
        this.transcriptionHandler = new GeminiTranscription(this.baseUrl, options.apiKey);
    }
    apiBase() {
        return this.baseUrl;
    }
    headers() {
        return {
            "Content-Type": "application/json"
        };
    }
    providerName() {
        return "Gemini";
    }
    defaultModel(_feature) {
        return "gemini-2.0-flash-exp";
    }
    async chat(request) {
        return this.chatHandler.execute(request);
    }
    async *stream(request) {
        yield* this.streamingHandler.execute(request);
    }
    async listModels() {
        return this.modelsHandler.execute();
    }
    async paint(request) {
        return this.imageHandler.execute(request);
    }
    async embed(request) {
        return this.embeddingHandler.execute(request);
    }
    async transcribe(request) {
        return this.transcriptionHandler.execute(request);
    }
}
