import { d as replaceRuntimeAuthProfileStoreSnapshots } from "../store-CGdIujI-.js";
import "../auth-profiles-v_WDJq4c.js";
import { t as buildCurrentProviderAuthStateSnapshot } from "../model-provider-auth-DcFrP2Vz.js";
import { parentPort, workerData } from "node:worker_threads";
//#region src/agents/model-provider-auth.worker.ts
function isWorkerInput(value) {
	return !!value && typeof value === "object" && "cfg" in value && (!("runtimeAuthStores" in value) || Array.isArray(value.runtimeAuthStores)) && (!("runtimeAuthLookups" in value) || Array.isArray(value.runtimeAuthLookups)) && (!("omitFalseProviderAuth" in value) || typeof value.omitFalseProviderAuth === "boolean");
}
async function runProviderAuthWarmWorkerInput(input) {
	if (!isWorkerInput(input)) return {
		status: "failed",
		error: "invalid provider auth warm worker input"
	};
	try {
		if (input.runtimeAuthStores?.length) replaceRuntimeAuthProfileStoreSnapshots(input.runtimeAuthStores);
		return {
			status: "ok",
			snapshot: await buildCurrentProviderAuthStateSnapshot(input.cfg, {
				readOnlyAuthStore: true,
				runtimeAuthLookups: new Map(input.runtimeAuthLookups?.map(({ agentId, lookup }) => [agentId, lookup])),
				omitFalseProviderAuth: input.omitFalseProviderAuth
			})
		};
	} catch (error) {
		return {
			status: "failed",
			error: String(error)
		};
	}
}
if (parentPort) parentPort.postMessage.bind(parentPort)(await runProviderAuthWarmWorkerInput(workerData));
//#endregion
export { runProviderAuthWarmWorkerInput };
