import { getLatestMediaEngine } from "../tasks/makeMediaEngineTask.js";
import { Task } from "@lit/task";
const makeScrubVideoInitSegmentFetchTask = (host) => {
	return new Task(host, {
		args: () => [host.mediaEngineTask.value],
		onError: (error) => {
			console.error("scrubVideoInitSegmentFetchTask error", error);
		},
		onComplete: (_value) => {},
		task: async ([_mediaEngine], { signal }) => {
			const mediaEngine = await getLatestMediaEngine(host, signal);
			const scrubRendition = mediaEngine.getScrubVideoRendition();
			if (!scrubRendition) throw new Error("No scrub rendition available");
			return mediaEngine.fetchInitSegment({
				...scrubRendition,
				src: mediaEngine.src
			}, signal);
		}
	});
};
export { makeScrubVideoInitSegmentFetchTask };
