import { withoutTrailingSlash } from "@ai-sdk/provider-utils";
import { ClarkChatLanguageModel } from "./clark-language-model.js";
/**
Create a Clark AI provider instance.
 */
export function createClark(options = {
    upstreamProvider: "bedrock",
}) {
    const path = options.path;
    let baseURL = withoutTrailingSlash(options.baseURL) ??
        "https://app.superblocks.com/api/v1/ai/inference";
    if (path) {
        const fixedPath = path.startsWith("/") ? path : `/${path}`;
        baseURL = `${baseURL}${withoutTrailingSlash(fixedPath)}`;
    }
    const getHeaders = () => ({
        ...options.headers,
    });
    const createChatModel = (modelId) => new ClarkChatLanguageModel(modelId, {
        provider: "clark.chat",
        baseURL: `${baseURL}/${options.upstreamProvider}`,
        headers: getHeaders,
        fetch: options.fetch,
    });
    const provider = function (modelId) {
        if (new.target) {
            throw new Error("The Clark model function cannot be called with the new keyword.");
        }
        return createChatModel(modelId);
    };
    provider.languageModel = createChatModel;
    provider.chat = createChatModel;
    const embeddingModel = () => {
        throw new Error("Embedding is not supported for Clark");
    };
    provider.embedding = embeddingModel;
    provider.textEmbedding = embeddingModel;
    provider.textEmbeddingModel = embeddingModel;
    const imageModel = () => {
        throw new Error("Image generation is not supported for Clark");
    };
    provider.imageModel = imageModel;
    return provider;
}
/**
Default Clark provider instance.
 */
export const clark = createClark();
//# sourceMappingURL=clark-provider.js.map