import fs from"node:fs";import path from"node:path";import{createRequire}from"node:module";import{parentPort,workerData}from"node:worker_threads";import{pathToFileURL}from"node:url";const f=await import(workerData.facadePath),e=await import(workerData.envelopePath);globalThis.__dirname=`${workerData.buildDirectory}${path.sep}`;globalThis.require=createRequire(import.meta.url);const m=await import(pathToFileURL(path.join(workerData.buildDirectory,"FreeCADWebPartBoxProbe.js"))),k=await m.default({wasmBinary:fs.readFileSync(path.join(workerData.buildDirectory,"FreeCADWebPartBoxProbe.wasm"))}),q=new e.FacadeSerialQueue();parentPort.postMessage({kind:"ready",action:f.PART_PYTHON_COMMAND});parentPort.on("message",async x=>{if(e.isFacadeCancel(x)){if(!q.cancel(x))parentPort.postMessage(e.createFailure(x.requestId,"cancel_rejected","request is not active"));return}if(f.isPartPythonRequest(x)){const s=x.requestId==="part-python-cancel-1"?new Promise(r=>setTimeout(()=>r(k),25)):k;parentPort.postMessage(await f.dispatchPartPython(q,x,s));return}parentPort.postMessage(e.createFailure("invalid","invalid_request","Part Python envelope invalid"))});