import { isLocalFileUrl, resolveLocalFileMtime } from "@steipete/summarize-core/content/local-file";
import { isDirectVideoInput } from "@steipete/summarize-core/content/url";
export function shouldPreferTranscriptForTarget({ targetUrl, videoMode, slides, }) {
    return videoMode === "transcript" || (Boolean(slides) && isDirectVideoInput(targetUrl));
}
export function resolveUrlFetchOptions({ targetUrl, flags, markdown, cacheMode, }) {
    const localFile = isLocalFileUrl(targetUrl);
    const options = {
        timeoutMs: flags.timeoutMs,
        maxCharacters: typeof flags.maxExtractCharacters === "number" && flags.maxExtractCharacters > 0
            ? flags.maxExtractCharacters
            : undefined,
        youtubeTranscript: flags.youtubeMode,
        mediaTranscript: shouldPreferTranscriptForTarget({
            targetUrl,
            videoMode: flags.videoMode,
            slides: flags.slides,
        })
            ? "prefer"
            : "auto",
        embeddedVideo: flags.videoMode === "transcript" && flags.embeddedVideoMode === "auto"
            ? "prefer"
            : flags.embeddedVideoMode,
        transcriptTimestamps: flags.transcriptTimestamps,
        transcriptDiarization: flags.transcriptDiarization,
        transcriptVideoDownload: Boolean(flags.slides && flags.transcriptDiarization),
        firecrawl: flags.firecrawlMode,
        format: markdown.markdownRequested ? "markdown" : "text",
        markdownMode: markdown.markdownRequested ? markdown.effectiveMarkdownMode : undefined,
        cacheMode,
        fileMtime: localFile ? resolveLocalFileMtime(targetUrl) : null,
        throwOnAssetLikeHtmlError: flags.throwOnAssetLikeHtmlError ?? false,
    };
    return {
        localFile,
        options,
    };
}
//# sourceMappingURL=fetch-options.js.map