!function(){let t;t=null,self.addEventListener("message",async e=>{let{id:s,python:o}=e.data;if(!t&&(self.importScripts("https://cdn.jsdelivr.net/pyodide/v0.26.3/full/pyodide.js"),(t=await self.loadPyodide())&&(await t.loadPackage("numpy"),await t.loadPackage("pandas"))),!t)throw Error("Failed to initialize Pyodide");try{let e;t.runPython("\n import sys\n from io import StringIO\n sys.stdout = StringIO()\n "),await t.loadPackagesFromImports(o);let a=await t.runPythonAsync(o),r=t.runPython("sys.stdout.getvalue()");if(t.runPython("sys.stdout = sys.__stdout__"),null!=a)try{e=t.toPy(a).toJs({dict_converter:Object.fromEntries})}catch(t){console.warn("Failed to convert result to JSON-safe format:",t),e=String(a)}else e=null;let n={id:s,results:{stdout:r,result:e}};self.postMessage(n)}catch(e){let t={id:s,error:e instanceof Error?e.message:String(e)};self.postMessage(t)}}),_N_E={}}();