const e=require(`../constants/vite.constants.cjs`),t=require(`./worker.registry.cjs`),n=require(`./WorkerWrapper.cjs`);var r=class r{constructor(){}static resolveWorkerURL=async e=>{let{getWorkerViteURL:t}=await Promise.resolve().then(()=>require(`./viteWorkerURL.constant.cjs`));return(await t())[e]};static async createBrowserWorker(e){let t=await r.resolveWorkerURL(e);return new Worker(t,{type:`module`})}static async createNodeWorker(e){let{Worker:n}=await import(`worker_threads`),r=await import(`path`),{existsSync:i}=await import(`fs`),a=t.workerNodeURL[e].replace(`.js`,`.cjs`),o,s=r.join(__dirname,a),c=s.replace(`.cjs`,`.js`),l=null;if(i(s)?l=s:i(c)&&(l=c),l)o=l;else{let e=__dirname;for(let t=0;t<12;t+=1){let t=r.join(e,`dist`,`libs`,`shared`,`common`,`webworker`,a);if(i(t)){o=t;break}let n=r.dirname(e);if(n===e)break;e=n}}if(!o)throw Error(`Worker bundle not found (${a}). Run "nx run shared-common:postbuild:node-workers".`);return new n(o)}static async createWorker(t){return e.isNode?r.createNodeWorker(t):r.createBrowserWorker(t)}static async getWebWorker(e){return new n.WorkerWrapper(await r.createWorker(e))}};exports.WorkerFactory=r;