/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
import { purgeFromCodeOptimized } from "../purger/optimized/purgeFromCode.js";
import { parentPort } from "node:worker_threads";
//#region src/css/purgeWorker.ts
let sharedConfig = null;
parentPort?.on("message", async (msg) => {
	if (msg.type === "init") {
		sharedConfig = msg.config;
		parentPort?.postMessage({ type: "ready" });
		return;
	}
	if (msg.type === "task") {
		if (!sharedConfig) {
			parentPort?.postMessage({
				type: "error",
				id: msg.id,
				error: "Worker not initialized"
			});
			return;
		}
		try {
			const result = await purgeFromCodeOptimized(msg.code, {
				...sharedConfig,
				colorModes: msg.colorModes,
				variantDefaults: msg.variantDefaults,
				runtimeConfigValues: msg.runtimeConfigValues,
				includeAllClassNamePrimitives: msg.includeAllClassNamePrimitives,
				filePath: msg.filePath
			});
			parentPort?.postMessage({
				type: "result",
				id: msg.id,
				result
			});
		} catch (error) {
			parentPort?.postMessage({
				type: "error",
				id: msg.id,
				error: error instanceof Error ? error.message : String(error)
			});
		}
		return;
	}
	if (msg.type === "done") process.exit(0);
});
//#endregion

//# sourceMappingURL=purgeWorker.js.map