import { __commonJS } from "./shared/chunk-DSsiIF1Z.mjs";
import { PluginContextData, bindingifyPlugin, init_bindingify_plugin, init_plugin_context_data } from "./shared/src-ib3YzbjY.mjs";
import "./shared/dist-CAn6dxW6.mjs";
import "./shared/parse-ast-index-NgEigHGy.mjs";
import { registerPlugins } from "./rolldown-binding.wasi.cjs";
import { parentPort, workerData } from "node:worker_threads";

//#region src/parallel-plugin-worker.ts
var require_parallel_plugin_worker = __commonJS({ "src/parallel-plugin-worker.ts"() {
	init_bindingify_plugin();
	init_plugin_context_data();
	const { registryId, pluginInfos, threadNumber } = workerData;
	(async () => {
		try {
			const plugins = await Promise.all(pluginInfos.map(async (pluginInfo) => {
				const pluginModule = await import(pluginInfo.fileUrl);
				const definePluginImpl = pluginModule.default;
				const plugin = await definePluginImpl(pluginInfo.options, { threadNumber });
				return {
					index: pluginInfo.index,
					plugin: bindingifyPlugin(plugin, {}, {}, new PluginContextData(), [], () => {}, "info", false)
				};
			}));
			registerPlugins(registryId, plugins);
			parentPort.postMessage({ type: "success" });
		} catch (error) {
			parentPort.postMessage({
				type: "error",
				error
			});
		} finally {
			parentPort.unref();
		}
	})();
} });

//#endregion
export default require_parallel_plugin_worker();
