import { resolveTranscriptionConfig, } from "../transcript/transcription-config.js";
import { fetchLinkContent } from "./content/index.js";
/** Public factory for a link preview client with injectable dependencies. */
export function createLinkPreviewClient(options = {}) {
    const fetchImpl = options.fetch ?? globalThis.fetch;
    const env = typeof options.env === "object" && options.env ? options.env : undefined;
    const scrape = options.scrapeWithFirecrawl ?? null;
    const apifyApiToken = typeof options.apifyApiToken === "string" ? options.apifyApiToken : null;
    const ytDlpPath = typeof options.ytDlpPath === "string" ? options.ytDlpPath : null;
    const falApiKey = typeof options.falApiKey === "string" ? options.falApiKey : null;
    const groqApiKey = typeof options.groqApiKey === "string" ? options.groqApiKey : null;
    const assemblyaiApiKey = typeof options.assemblyaiApiKey === "string" ? options.assemblyaiApiKey : null;
    const deepgramApiKey = typeof options.deepgramApiKey === "string" ? options.deepgramApiKey : null;
    const elevenlabsApiKey = typeof options.elevenlabsApiKey === "string" ? options.elevenlabsApiKey : null;
    const geminiApiKey = typeof options.geminiApiKey === "string" ? options.geminiApiKey : null;
    const openaiApiKey = typeof options.openaiApiKey === "string" ? options.openaiApiKey : null;
    const transcription = resolveTranscriptionConfig({
        env,
        transcription: options.transcription ?? null,
        falApiKey,
        groqApiKey,
        assemblyaiApiKey,
        deepgramApiKey,
        elevenlabsApiKey,
        geminiApiKey,
        openaiApiKey,
    });
    const convertHtmlToMarkdown = options.convertHtmlToMarkdown ?? null;
    const transcriptCache = options.transcriptCache ?? null;
    const mediaCache = options.mediaCache ?? null;
    const readTweetWithBird = typeof options.readTweetWithBird === "function" ? options.readTweetWithBird : null;
    const resolveTwitterCookies = typeof options.resolveTwitterCookies === "function" ? options.resolveTwitterCookies : null;
    const onProgress = typeof options.onProgress === "function" ? options.onProgress : null;
    return {
        fetchLinkContent: (url, contentOptions) => fetchLinkContent(url, contentOptions, {
            fetch: fetchImpl,
            env,
            scrapeWithFirecrawl: scrape,
            apifyApiToken,
            ytDlpPath,
            transcription,
            falApiKey,
            groqApiKey,
            assemblyaiApiKey,
            deepgramApiKey,
            elevenlabsApiKey,
            geminiApiKey,
            openaiApiKey,
            convertHtmlToMarkdown,
            transcriptCache,
            mediaCache,
            readTweetWithBird,
            resolveTwitterCookies,
            onProgress,
        }),
    };
}
//# sourceMappingURL=client.js.map