import { t as applyAnthropicEphemeralCacheControlMarkers } from "./anthropic-payload-policy-CLVOuOH8.js";
import { r as hasCopilotVisionInput, t as buildCopilotDynamicHeaders } from "./copilot-dynamic-headers-hyvRO7MN.js";
import { r as streamWithPayloadPatch } from "./moonshot-thinking-stream-wrappers-BArma5yq.js";
import "./provider-stream-shared-B9byaiFO.js";
import { streamSimple } from "@earendil-works/pi-ai";
//#region extensions/github-copilot/stream.ts
function wrapCopilotAnthropicStream(baseStreamFn) {
	const underlying = baseStreamFn ?? streamSimple;
	return (model, context, options) => {
		if (model.provider !== "github-copilot" || model.api !== "anthropic-messages") return underlying(model, context, options);
		return streamWithPayloadPatch(underlying, model, context, {
			...options,
			headers: {
				...buildCopilotDynamicHeaders({
					messages: context.messages,
					hasImages: hasCopilotVisionInput(context.messages)
				}),
				...options?.headers
			}
		}, applyAnthropicEphemeralCacheControlMarkers);
	};
}
function wrapCopilotProviderStream(ctx) {
	return wrapCopilotAnthropicStream(ctx.streamFn);
}
//#endregion
export { wrapCopilotProviderStream as n, wrapCopilotAnthropicStream as t };
