Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More β†’
Socket
Sign inDemoInstall
Socket

polyscript

Package Overview
Dependencies
Maintainers
0
Versions
157
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

polyscript - npm Package Compare versions

Comparing version 0.14.3 to 0.14.4

2

esm/interpreter/pyodide.js

@@ -82,3 +82,3 @@ import { create } from 'gc-hook';

type,
module: (version = '0.26.1') =>
module: (version = '0.26.2') =>
`https://cdn.jsdelivr.net/pyodide/v${version}/full/pyodide.mjs`,

@@ -85,0 +85,0 @@ async engine({ loadPyodide }, config, url, baseURL) {

@@ -8,3 +8,3 @@ /* c8 ignore start */

const { Worker } = coincident(JSON);
export default (...args) => new Worker(URL.createObjectURL(new Blob(["const e=\"object\"==typeof self?self:globalThis,t=t=>((t,n)=>{const r=(e,n)=>(t.set(n,e),e),s=o=>{if(t.has(o))return t.get(o);const[a,i]=n[o];switch(a){case 0:case-1:return r(i,o);case 1:{const e=r([],o);for(const t of i)e.push(s(t));return e}case 2:{const e=r({},o);for(const[t,n]of i)e[s(t)]=s(n);return e}case 3:return r(new Date(i),o);case 4:{const{source:e,flags:t}=i;return r(new RegExp(e,t),o)}case 5:{const e=r(new Map,o);for(const[t,n]of i)e.set(s(t),s(n));return e}case 6:{const e=r(new Set,o);for(const t of i)e.add(s(t));return e}case 7:{const{name:t,message:n}=i;return r(new e[t](n),o)}case 8:return r(BigInt(i),o);case\"BigInt\":return r(Object(BigInt(i)),o)}return r(new e[a](i),o)};return s})(new Map,t)(0),n=\"\",{toString:r}={},{keys:s}=Object,o=e=>{const t=typeof e;if(\"object\"!==t||!e)return[0,t];const s=r.call(e).slice(8,-1);switch(s){case\"Array\":return[1,n];case\"Object\":return[2,n];case\"Date\":return[3,n];case\"RegExp\":return[4,n];case\"Map\":return[5,n];case\"Set\":return[6,n]}return s.includes(\"Array\")?[1,s]:s.includes(\"Error\")?[7,s]:[2,s]},a=([e,t])=>0===e&&(\"function\"===t||\"symbol\"===t),i=(e,{json:t,lossy:n}={})=>{const r=[];return((e,t,n,r)=>{const i=(e,t)=>{const s=r.push(e)-1;return n.set(t,s),s},c=r=>{if(n.has(r))return n.get(r);let[l,u]=o(r);switch(l){case 0:{let t=r;switch(u){case\"bigint\":l=8,t=r.toString();break;case\"function\":case\"symbol\":if(e)throw new TypeError(\"unable to serialize \"+u);t=null;break;case\"undefined\":return i([-1],r)}return i([l,t],r)}case 1:{if(u)return i([u,[...r]],r);const e=[],t=i([l,e],r);for(const t of r)e.push(c(t));return t}case 2:{if(u)switch(u){case\"BigInt\":return i([u,r.toString()],r);case\"Boolean\":case\"Number\":case\"String\":return i([u,r.valueOf()],r)}if(t&&\"toJSON\"in r)return c(r.toJSON());const n=[],p=i([l,n],r);for(const t of s(r))!e&&a(o(r[t]))||n.push([c(t),c(r[t])]);return p}case 3:return i([l,r.toISOString()],r);case 4:{const{source:e,flags:t}=r;return i([l,{source:e,flags:t}],r)}case 5:{const t=[],n=i([l,t],r);for(const[n,s]of r)(e||!a(o(n))&&!a(o(s)))&&t.push([c(n),c(s)]);return n}case 6:{const t=[],n=i([l,t],r);for(const n of r)!e&&a(o(n))||t.push(c(n));return n}}const{message:p}=r;return i([l,{name:u,message:p}],r)};return c})(!(t||n),!!t,new Map,r)(e),r},{parse:c,stringify:l}=JSON,u={json:!0,lossy:!0};var p=Object.freeze({__proto__:null,parse:e=>t(c(e)),stringify:e=>l(i(e,u))});const f=\"array\",d=\"function\",h=\"null\",y=\"number\",g=\"object\",w=\"symbol\",m=\"undefined\",_=\"apply\",b=\"construct\",E=\"defineProperty\",v=\"deleteProperty\",T=\"get\",x=\"getOwnPropertyDescriptor\",k=\"getPrototypeOf\",S=\"has\",O=\"isExtensible\",A=\"ownKeys\",j=\"preventExtensions\",R=\"set\",P=\"setPrototypeOf\";var $=Object.freeze({__proto__:null,APPLY:_,CONSTRUCT:b,DEFINE_PROPERTY:E,DELETE_PROPERTY:v,GET:T,GET_OWN_PROPERTY_DESCRIPTOR:x,GET_PROTOTYPE_OF:k,HAS:S,IS_EXTENSIBLE:O,OWN_KEYS:A,PREVENT_EXTENSION:j,SET:R,SET_PROTOTYPE_OF:P});function I(){return this}const N=new FinalizationRegistry((([e,t,n])=>{n&&console.debug(`Held value ${String(t)} not relevant anymore`),e(t)})),M=Object.create(null),F=(e,t,{debug:n,handler:r,return:s,token:o=e}=M)=>{const a=s||new Proxy(e,r||M),i=[a,[t,e,!!n]];return!1!==o&&i.push(o),N.register(...i),a},{Object:H,Proxy:W,Reflect:D}=globalThis,{isArray:C}=Array,{ownKeys:L}=D,{create:B,hasOwn:q,values:U}=H,J=(e,t)=>t===f?e[0]:t===d?e():t===g?e.$:e,z=(e,t,n,r)=>{const s={type:{value:t}},o=q(e,\"valueOf\");for(const a of U($)){let i=r(e[a]||D[a]);if(o&&a===T){const{valueOf:r}=e,{value:s}=i;i={value(e,o,...a){return o===n?r.call(this,J(e,t)):s.call(this,e,o,...a)}}}s[a]=i}return B(e,s)},G=(e,t,n,r=e)=>{if(r===e)switch(typeof e){case g:case m:r||(r=!1);case d:break;default:r=!1,t===e&&(t=H(e))}const s=new W(t,n),{destruct:o}=n;return o?F(e,o,{token:r,return:s}):s},Y=e=>t=>{const n=typeof t;return n===g?t?e.get(t)?.[0]??(e=>C(e)?f:g)(t):h:n},K=e=>t=>{let n=typeof t;switch(n){case g:if(!t){n=h;break}case d:const r=e.get(t);r&&([n,t]=r)}return[n,t]},X=e=>((e=>{N.unregister(e)})(e),e);var V=e=>{const t=new WeakMap,n=Symbol(),r={},s=(e,n,r)=>(t.set(e,[n,r]),e),o={proxy:r,release:X,pair:K(t),typeOf:Y(t),isProxy:e=>t.has(e),valueOf:e=>e[n]??e.valueOf()};for(const t of L(e)){if(q(o,t))continue;const a=e[t];switch(t){case f:{const e=z(a,t,n,(e=>({value([t],...n){return e.call(this,t,...n)}})));r[t]=(t,...n)=>s(G(t,[t],e,...n),f,t);break}case d:{const e=z(a,t,n,(e=>({value(t,...n){return e.call(this,t(),...n)}})));r[t]=(t,...n)=>{return s(G(t,(r=t,I.bind(r)),e,...n),d,t);var r};break}case g:{const e=z(a,t,n,(e=>({value({$:t},...n){return e.call(this,t,...n)}})));r[t]=(t,...n)=>s(G(t,{$:t},e,...n),g,t);break}default:{const e=z(a,t,n,(e=>({value:e})));r[t]=(n,...r)=>s(G(n,n,e,...r),t,n);break}}}return o};let Z=0;const Q=new Map,ee=new Map,te=e=>ee.get(e),ne=e=>{if(!Q.has(e)){let t;for(;ee.has(t=Z++););Q.set(e,t),ee.set(t,e)}return Q.get(e)},{ArrayBuffer:re,Atomics:se,Promise:oe}=globalThis,{isArray:ae}=Array,{create:ie,getPrototypeOf:ce,values:le}=Object,ue=ce(Int32Array),pe=ie(se),fe=({currentTarget:e,type:t,origin:n,lastEventId:r,source:s,ports:o},a)=>e.dispatchEvent(new MessageEvent(t,{data:a,origin:n,lastEventId:r,source:s,ports:o})),de=()=>oe.withResolvers();let he=0;const ye=new Map,ge=(e,t)=>class extends e{constructor(e,...n){super(e,...n),e instanceof t&&ye.set(this,[he++,0,de()])}},we=new WeakSet,me=e=>(we.add(e),e),_e=(e,t)=>{const{data:n}=e,r=ae(n)&&(n.at(0)===t||0===n.at(1)&&!t);return r&&(e.stopImmediatePropagation(),e.preventDefault()),r},be=e=>null!==e&&\"object\"==typeof e&&!we.has(e),Ee=new WeakMap,ve=(e,t,n)=>{if(ye.has(e))t.set(e,ye.get(e)[0]);else if(!(e instanceof ue||e instanceof re))for(const r of le(e))be(r)&&!n.has(r)&&(n.add(r),ve(r,t,n))},Te=(...e)=>({value:new oe((t=>{let n=new Worker(\"data:application/javascript,onmessage%3De%3D%3EpostMessage(!Atomics.wait(...e.data))\");n.onmessage=()=>t(\"ok\"),n.postMessage(e)}))}),xe=(e,t)=>{const n=ye.get(e),[r,s,{promise:o}]=n;return n[1]=t,[r,o]};let{BigInt64Array:ke,Int32Array:Se,SharedArrayBuffer:Oe,addEventListener:Ae,postMessage:je}=globalThis,Re=!0,Pe=e=>e,$e=!1;const Ie=de();try{new Oe(4),pe.waitAsync||(pe.waitAsync=Te),Ie.resolve()}catch(e){const t=je,n=Ae,r=[];let s=\"\",o=\"\";Oe=class extends re{},ke=ge(ke,Oe),Se=ge(Se,Oe),Pe=me,$e=!0,pe.notify=(e,n)=>{const[r]=(e=>Ee.get(e))(e);return t([s,1,e,r,n]),0},pe.waitAsync=(...e)=>{const[t,n]=xe(...e);return{value:n}},pe.wait=(e,t,...n)=>{const[r]=xe(e,t,...n),a=new XMLHttpRequest;a.responseType=\"json\",a.open(\"POST\",`${o}?sabayon`,!1),a.setRequestHeader(\"Content-Type\",\"application/json\"),a.send(`[\"${s}\",${r},${t}]`);const{response:i}=a;ye.delete(e);for(let t=0;t<i.length;t++)e[t]=i[t];return\"ok\"},n(\"message\",(e=>{if(_e(e,s)){const[t,n,...r]=e.data;switch(n){case 0:s=t,o=r.at(0)?.serviceWorker||\"\",o||(pe.wait=null,Ie.resolve());break;case 1:((e,t,n)=>{for(const[r,[s,o,{resolve:a}]]of ye)if(t===s&&n===o){for(let t=0;t<e.length;t++)r[t]=e[t];ye.delete(r),a(\"ok\");break}})(...r);break;case 2:((e,t,n)=>{for(const[n,r]of t)Ee.set(n,[r,e.currentTarget]);fe(e,n)})(e,...r);break;case 3:Ie.resolve()}}else if(Re){const{currentTarget:t,type:n,origin:s,lastEventId:o,source:a,ports:i}=e;r.push([{currentTarget:t,type:n,origin:s,lastEventId:o,source:a,ports:i},e.data])}})),Ae=(e,...t)=>{if(n(e,...t),r.length)for(const e of r.splice(0))fe(...e)},je=(e,...n)=>t(((e,t)=>{const n=new Map;return be(t)&&ve(t,n,new Set),n.size?[e,2,n,t]:t})(s,e),...n)}await Ie.promise,Re=!1;const{BYTES_PER_ELEMENT:Ne}=Int32Array,{BYTES_PER_ELEMENT:Me}=Uint16Array,{notify:Fe}=pe,He=new TextDecoder(\"utf-16\"),We=new WeakSet,De=(...e)=>(We.add(e),e);let Ce=\"\";const Le=(e,t,n,r)=>{const[s]=r,o=n.get(s);if(!o)throw new Error(`Unknown proxy.${s}()`);e(o,t,r)};let Be=0;const qe=([e,t,n,r,s,o,a,i,c],l)=>(...u)=>{let p=\"\"!==Ce,f=0;p&&\"=\"!==Ce[0]&&\"-\"!==Ce[0]&&(f=((e,t)=>setTimeout(console.warn,3e3,`πŸ’€πŸ”’ - proxy.${e}() in proxy.${t}()`))(l,Ce));const d=Be++,h=[];We.has(u.at(-1)||h)&&We.delete(h=u.pop());const y=n(i?u.map(i):u);let g=t(2*Ne);return a([e,2,l,d,g,y,r],{transfer:h}),c(g,0).value.then((()=>{p&&clearTimeout(f);const n=g[1];if(!n)return;const r=Me*n;return g=t(r+r%Ne),a([e,1,d,g]),c(g,0).value.then((()=>{const e=new Uint16Array(g.buffer),t=o?e.subarray(0,n):e.slice(0,n);return s(He.decode(t))}))}))},Ue=(e,t)=>new Proxy(t,{get:(t,n)=>{let r;return\"then\"!==n&&(r=t.get(n),r||(r=qe(e,n),t.set(n,r))),r},set:(e,t,n)=>\"then\"!==t&&!!e.set(t,n)}),{wait:Je,waitAsync:ze}=pe;var Ge=({parse:e,stringify:t,transform:n,interrupt:r}=JSON)=>{const s=((e,t)=>async(n,r,[s,o,a,i,c])=>{c&&(Ce=s);try{const s=await n(...i);if(void 0!==s){const n=e(t?t(s):s);r.set(o,n),a[1]=n.length}}finally{c&&(Ce=\"\"),a[0]=1,Fe(a,0)}})(t,n),o=de(),a=new Map,i=new Map;let c=\"\",l=Je;if(Je&&r){const{handler:e,timeout:t=42}=r;l=(n,r,s)=>{for(;\"timed-out\"===(s=Je(n,r,0,t));)e();return s}}return Ae(\"message\",(t=>{if(_e(t,c)){const[r,u,...p]=t.data;switch(u){case 0:{const t=!!Je;c=r,o.resolve({polyfill:$e,sync:t,transfer:De,proxy:Ue([c,e=>new Se(new Oe(e)),Pe,t,e,$e,je,n,t?(...e)=>({value:{then:t=>t(l(...e))}}):ze],a)});break}case 2:a.size?Le(s,i,a,p):setTimeout(Le,0,s,i,a,p);break;case 1:((e,[t,n])=>{const r=e.get(t);e.delete(t);for(let e=new Uint16Array(n.buffer),t=0,{length:s}=r;t<s;t++)e[t]=r.charCodeAt(t);Fe(n,0)})(i,p)}}})),o.promise},Ye=Object.fromEntries([f,\"bigint\",\"boolean\",d,h,y,g,\"string\",w,m].map(((e,t)=>[e,t])));const Ke=\"destruct\",{[A]:Xe}=Reflect,Ve=new Map(Xe(Symbol).filter((e=>typeof Symbol[e]===w)).map((e=>[Symbol[e],e]))),Ze=e=>Ve.get(e)||`.${Symbol.keyFor(e)||\"\"}`,Qe=\"b87ec809-9df6-4389-a29e-bc91090db4dc\",et=\"=\"+Qe,tt=\"-\"+Qe,{[_]:nt}=Reflect;const rt={object(...e){return this.string(function(e){for(var t=e[0],n=1,r=arguments.length;n<r;n++)t+=arguments[n]+e[n];return t}(...e))},string(e){for(const t of e.split(/[\\r\\n]+/))if(t.trim().length){/^(\\s+)/.test(t)&&(e=e.replace(new RegExp(\"^\"+RegExp.$1,\"gm\"),\"\"));break}return e}},st=new WeakMap,ot=e=>{const t=e||console,n={buffered:it,stderr:(t.stderr||console.error).bind(t),stdout:(t.stdout||console.log).bind(t)};return{stderr:(...e)=>n.stderr(...e),stdout:(...e)=>n.stdout(...e),async get(e){const t=await e;return st.set(t,n),t}}},at=new TextDecoder,it=(e,t=10)=>{const n=[];return r=>{if(r instanceof Uint8Array)for(const s of r)s===t?e(at.decode(new Uint8Array(n.splice(0)))):n.push(s);else e(r)}},ct=(e,...t)=>rt[typeof e](e,...t),{isArray:lt}=Array,{assign:ut,create:pt,defineProperties:ft,defineProperty:dt,entries:ht}=Object,{all:yt,resolve:gt}=new Proxy(Promise,{get:(e,t)=>e[t].bind(e)}),wt=(e,t=location.href)=>new URL(e,t.replace(/^blob:/,\"\")).href,mt=(e,t,n,r=!1,s=CustomEvent)=>{e.dispatchEvent(new s(`${t}:${n}`,{bubbles:!0,detail:{worker:r}}))},_t=e=>Function(`'use strict';return (${e})`)(),bt=e=>e.replace(/^(?:\\n|\\r\\n)/,\"\"),Et=Symbol.for(\"polyscript.js_modules\"),vt=new Map;dt(globalThis,Et,{value:vt}),new Proxy(vt,{get:(e,t)=>e.get(t),has:(e,t)=>e.has(t),ownKeys:e=>[...e.keys()]});const Tt=(e,t)=>!t.startsWith(\"_\"),xt=(e,t)=>new Proxy(e,{has:Tt,get:(e,n)=>e[t][n]}),kt=(e,t)=>import(e).then((e=>{vt.set(t,{...e})})),St=e=>new Promise(((t,n)=>{document.querySelector(`link[rel=\"stylesheet\"][href=\"${e}\"]`)?t():document.head.append(ut(document.createElement(\"link\"),{rel:\"stylesheet\",href:e,onload:t,onerror:n}))})),Ot=e=>/\\.css$/i.test(new URL(e).pathname),At=(e,t)=>e.has(t),jt=e=>[...e.keys()];var Rt=(e,t,n,r)=>{const s=globalThis[Et];if(n)for(let[e,t]of ht(n)){let n=s.get(t);n&&!lt(n)||(s.set(t,n||(n=[])),n.push(e))}return((e,t,n,r)=>new Proxy(e,{has:At,ownKeys:jt,get:(e,s)=>{let o=e.get(s);if(lt(o)){let a=o;o=null;for(let e of a)e=wt(e,r),Ot(e)?n.importCSS(e):(n.importJS(e,s),o=t[Et].get(s));e.set(s,o)}return o}}))(s,e,t,r)};const Pt=new Map,$t=e=>Pt.get(e),It=(e,t)=>{try{return Function(\"require\",t)($t)}catch(t){st.get(e).stderr(t)}};var Nt={type:\"dummy\",module:()=>\"data:application/javascript,\",engine:e=>ot().get(e),registerJSModule(e,t,n){Pt.set(t,n)},run:It,runAsync:It,runEvent:async(e,t,n)=>{try{await Function(\"require\",\"e\",`return ${t}(e)`)($t,n)}catch(t){st.get(e).stderr(t)}},transform:(e,t)=>t,writeFile(){}};const Mt=Object.getOwnPropertyDescriptors(Response.prototype),Ft=e=>\"function\"==typeof e,Ht={get:(e,t)=>Mt.hasOwnProperty(t)?((e,t,{get:n,value:r})=>n||!Ft(r)?e.then((e=>e[t])):(...n)=>e.then((e=>e[t](...n))))(e,t,Mt[t]):((e,t)=>Ft(t)?t.bind(e):t)(e,e[t])};var Wt=(e,...t)=>new Proxy(fetch(e,...t),Ht);Promise.withResolvers||(Promise.withResolvers=function(){var e,t,n=new this((function(n,r){e=n,t=r}));return{resolve:e,reject:t,promise:n}});const Dt=!globalThis.window,Ct=({FS:e,PATH:t,PATH_FS:n},r,s)=>{const o=n.resolve(r),a=t.dirname(o);return e.mkdirTree?e.mkdirTree(a):Bt(e,a),e.writeFile(o,new Uint8Array(s),{canOwn:!0})},Lt=e=>{const t=e.split(\"/\");return t.pop(),t.join(\"/\")},Bt=(e,t)=>{const n=[];for(const r of t.split(\"/\"))\".\"!==r&&\"..\"!==r&&(n.push(r),r&&e.mkdir(n.join(\"/\")))},qt=(e,t)=>{const n=[];for(const e of t.split(\"/\"))switch(e){case\"\":case\".\":break;case\"..\":n.pop();break;default:n.push(e)}return[e.cwd()].concat(n).join(\"/\").replace(/^\\/+/,\"/\")},Ut=e=>{const t=e.map((e=>e.trim().replace(/(^[/]*|[/]*$)/g,\"\"))).filter((e=>\"\"!==e&&\".\"!==e)).join(\"/\");return e[0].startsWith(\"/\")?`/${t}`:t},Jt=(e,t)=>Wt(wt(e,t)).arrayBuffer(),zt=(e,t,n,r)=>yt((e=>{for(const{files:t,to_file:n,from:r=\"\"}of e){if(void 0!==t&&void 0!==n)throw new Error(\"Cannot use 'to_file' and 'files' parameters together!\");if(void 0===t&&void 0===n&&r.endsWith(\"/\"))throw new Error(`Couldn't determine the filename from the path ${r}, please supply 'to_file' parameter.`)}return e.flatMap((({from:e=\"\",to_folder:t=\".\",to_file:n,files:r})=>{if(lt(r))return r.map((n=>({url:Ut([e,n]),path:Ut([t,n])})));const s=n||e.slice(1+e.lastIndexOf(\"/\"));return[{url:e,path:Ut([t,s])}]}))})(n).map((({url:n,path:s})=>Jt(n,r).then((n=>e.writeFile(t,s,n)))))),Gt=(e,t)=>t.endsWith(\"/\")?`${t}${e.split(\"/\").pop()}`:t,Yt=(e,t)=>e.replace(/\\{.+?\\}/g,(e=>{if(!t.has(e))throw new SyntaxError(`Invalid template: ${e}`);return t.get(e)})),Kt=(e,t,n,r)=>yt((e=>{const t=new Map,n=new Set,r=[];for(const[s,o]of ht(e))if(/^\\{.+\\}$/.test(s)){if(t.has(s))throw new SyntaxError(`Duplicated template: ${s}`);t.set(s,Yt(o,t))}else{const e=Yt(s,t),a=Gt(e,Yt(o||\"./\",t));if(n.has(a))throw new SyntaxError(`Duplicated destination: ${a}`);n.add(a),r.push({url:e,path:a})}return r})(n).map((({url:n,path:s})=>Jt(n,r).then((r=>e.writeFile(t,s,r,n)))))),Xt=({main:e,worker:t},n)=>{const r=[];if(t&&Dt)for(let[e,s]of ht(t))e=wt(e,n),r.push(kt(e,s));if(e&&!Dt)for(let[t,s]of ht(e))t=wt(t,n),Ot(t)?St(t):r.push(kt(t,s));return yt(r)},{assign:Vt}=Object,Zt=\"entries\",Qt=\"readonly\",en=\"readwrite\",tn={durability:\"default\",prefix:\"IDBMap\"},nn=({target:{result:e}})=>e;class rn extends EventTarget{#e;#t;#n;async#r(e,t){const n=(await this.#e).transaction(Zt,t,this.#t);return new Promise(((t,r)=>Vt(e(n.objectStore(Zt)),{onsuccess:t,onerror:r})))}constructor(e,{durability:t=tn.durability,prefix:n=tn.prefix}=tn){super(),this.#n=n,this.#t={durability:t},this.#e=new Promise(((t,n)=>{Vt(indexedDB.open(`${this.#n}/${e}`),{onupgradeneeded({target:{result:e,transaction:n}}){e.objectStoreNames.length||e.createObjectStore(Zt),n.oncomplete=()=>t(e)},onsuccess(e){t(nn(e))},onerror(e){n(e),this.dispatchEvent(e)}})})).then((e=>{const t=this.dispatchEvent.bind(this);for(const n in e)n.startsWith(\"on\")&&(e[n]=t);return e}))}dispatchEvent(e){const{type:t,message:n,isTrusted:r}=e;return super.dispatchEvent(r?Vt(new Event(t),{message:n}):e)}async close(){(await this.#e).close()}get size(){return this.#r((e=>e.count()),Qt).then(nn)}async clear(){await this.#r((e=>e.clear()),en)}async delete(e){await this.#r((t=>t.delete(e)),en)}async entries(){const e=await this.keys();return Promise.all(e.map((e=>this.get(e).then((t=>[e,t])))))}async forEach(e,t=this){for(const[n,r]of await this.entries())await e.call(t,r,n,this)}async get(e){return await this.#r((t=>t.get(e)),Qt).then(nn)}async has(e){return void 0!==await this.#r((t=>t.getKey(e)),Qt).then(nn)}async keys(){return await this.#r((e=>e.getAllKeys()),Qt).then(nn)}async set(e,t){return await this.#r((n=>n.put(t,e)),en),this}async values(){const e=await this.keys();return Promise.all(e.map((e=>this.get(e))))}get[Symbol.toStringTag](){return this.#n}}class sn extends Map{#s;#o;constructor(...e){super(),this.#s=new rn(...e),this.#o=this.#s.entries().then((e=>{for(const[t,n]of e)super.set(t,n)}))}async sync(){await this.#o}clear(){return this.#o=this.#o.then((()=>this.#s.clear())),super.clear()}delete(e){return this.#o=this.#o.then((()=>this.#s.delete(e))),super.delete(e)}set(e,t){return this.#o=this.#o.then((()=>this.#s.set(e,t))),super.set(e,t)}}const on=new WeakMap,an=(e,t,n)=>{\"polyscript\"===t&&(n.lazy_py_modules=async(...t)=>(await on.get(e)(t),t.map((t=>e.pyimport(t)))),n.storage=async e=>{const t=new sn(e);return await t.sync(),t},n.JSON=p),e.registerJsModule(t,n)},cn=(e,t)=>{if(e.endsWith(\"/*\")){if(/\\.(zip|whl|tgz|tar(?:\\.gz)?)$/.test(t))return RegExp.$1;throw new Error(`Unsupported archive ${t}`)}return\"\"},ln=(e,t,...n)=>{try{return e.runPython(ct(t),...n)}catch(t){st.get(e).stderr(t)}},un=async(e,t,...n)=>{try{return await e.runPythonAsync(ct(t),...n)}catch(t){st.get(e).stderr(t)}},pn=async(e,t,n)=>{const[r,...s]=t.split(\".\");let o,a=e.globals.get(r);for(const e of s)[o,a]=[a,a[e]];try{await a.call(o,n)}catch(t){st.get(e).stderr(t)}};var fn=(new TextEncoder).encode('from uio import StringIO\\nimport sys\\n\\nclass Response:\\n def __init__(self, f):\\n self.raw = f\\n self.encoding = \"utf-8\"\\n self._cached = None\\n\\n def close(self):\\n if self.raw:\\n self.raw.close()\\n self.raw = None\\n self._cached = None\\n\\n @property\\n def content(self):\\n if self._cached is None:\\n try:\\n self._cached = self.raw.read()\\n finally:\\n self.raw.close()\\n self.raw = None\\n return self._cached\\n\\n @property\\n def text(self):\\n return str(self.content, self.encoding)\\n\\n def json(self):\\n import ujson\\n\\n return ujson.loads(self.content)\\n\\n\\n# TODO try to support streaming xhr requests, a-la pyodide-http\\nHEADERS_TO_IGNORE = (\"user-agent\",)\\n\\n\\ntry:\\n import js\\nexcept Exception as err:\\n raise OSError(\"This version of urequests can only be used in the browser\")\\n\\n# TODO try to support streaming xhr requests, a-la pyodide-http\\n\\nHEADERS_TO_IGNORE = (\"user-agent\",)\\n\\n\\ndef request(\\n method,\\n url,\\n data=None,\\n json=None,\\n headers={},\\n stream=None,\\n auth=None,\\n timeout=None,\\n parse_headers=True,\\n):\\n from js import XMLHttpRequest\\n\\n xhr = XMLHttpRequest.new()\\n xhr.withCredentials = False\\n\\n if auth is not None:\\n import ubinascii\\n\\n username, password = auth\\n xhr.open(method, url, False, username, password)\\n else:\\n xhr.open(method, url, False)\\n\\n for name, value in headers.items():\\n if name.lower() not in HEADERS_TO_IGNORE:\\n xhr.setRequestHeader(name, value)\\n\\n if timeout:\\n xhr.timeout = int(timeout * 1000)\\n\\n if json is not None:\\n assert data is None\\n import ujson\\n\\n data = ujson.dumps(json)\\n # s.write(b\"Content-Type: application/json\\\\r\\\\n\")\\n xhr.setRequestHeader(\"Content-Type\", \"application/json\")\\n\\n xhr.send(data)\\n\\n # Emulates the construction process in the original urequests\\n resp = Response(StringIO(xhr.responseText))\\n resp.status_code = xhr.status\\n resp.reason = xhr.statusText\\n resp.headers = xhr.getAllResponseHeaders()\\n\\n return resp\\n\\n\\n# Other methods - head, post, put, patch, delete - are not used by\\n# mip and therefore not included\\n\\n\\ndef get(url, **kw):\\n return request(\"GET\", url, **kw)\\n\\n\\n# Content below this line is from the Micropython MIP package and is covered\\n# by the applicable MIT license:\\n# \\n# THE SOFTWARE IS PROVIDED β€œAS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, \\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER \\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING \\n# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER \\n# DEALINGS IN THE SOFTWARE.\\n\\n# MicroPython package installer\\n# MIT license; Copyright (c) 2022 Jim Mussared\\n\\n\\n_PACKAGE_INDEX = const(\"https://micropython.org/pi/v2\")\\n_CHUNK_SIZE = 128\\n\\n\\n# This implements os.makedirs(os.dirname(path))\\ndef _ensure_path_exists(path):\\n import os\\n\\n split = path.split(\"/\")\\n\\n # Handle paths starting with \"/\".\\n if not split[0]:\\n split.pop(0)\\n split[0] = \"/\" + split[0]\\n\\n prefix = \"\"\\n for i in range(len(split) - 1):\\n prefix += split[i]\\n try:\\n os.stat(prefix)\\n except:\\n os.mkdir(prefix)\\n prefix += \"/\"\\n\\n\\n# Copy from src (stream) to dest (function-taking-bytes)\\ndef _chunk(src, dest):\\n buf = memoryview(bytearray(_CHUNK_SIZE))\\n while True:\\n n = src.readinto(buf)\\n if n == 0:\\n break\\n dest(buf if n == _CHUNK_SIZE else buf[:n])\\n\\n\\n# Check if the specified path exists and matches the hash.\\ndef _check_exists(path, short_hash):\\n import os\\n\\n try:\\n import binascii\\n import hashlib\\n\\n with open(path, \"rb\") as f:\\n hs256 = hashlib.sha256()\\n _chunk(f, hs256.update)\\n existing_hash = str(binascii.hexlify(hs256.digest())[: len(short_hash)], \"utf-8\")\\n return existing_hash == short_hash\\n except:\\n return False\\n\\n\\ndef _rewrite_url(url, branch=None):\\n if not branch:\\n branch = \"HEAD\"\\n if url.startswith(\"github:\"):\\n url = url[7:].split(\"/\")\\n url = (\\n \"https://raw.githubusercontent.com/\"\\n + url[0]\\n + \"/\"\\n + url[1]\\n + \"/\"\\n + branch\\n + \"/\"\\n + \"/\".join(url[2:])\\n )\\n return url\\n\\n\\ndef _download_file(url, dest):\\n response = get(url)\\n try:\\n if response.status_code != 200:\\n print(\"Error\", response.status_code, \"requesting\", url)\\n return False\\n\\n print(\"Copying:\", dest)\\n _ensure_path_exists(dest)\\n with open(dest, \"wb\") as f:\\n _chunk(response.raw, f.write)\\n\\n return True\\n finally:\\n response.close()\\n\\n\\ndef _install_json(package_json_url, index, target, version, mpy):\\n response = get(_rewrite_url(package_json_url, version))\\n try:\\n if response.status_code != 200:\\n print(\"Package not found:\", package_json_url)\\n return False\\n\\n package_json = response.json()\\n finally:\\n response.close()\\n for target_path, short_hash in package_json.get(\"hashes\", ()):\\n fs_target_path = target + \"/\" + target_path\\n if _check_exists(fs_target_path, short_hash):\\n print(\"Exists:\", fs_target_path)\\n else:\\n file_url = \"{}/file/{}/{}\".format(index, short_hash[:2], short_hash)\\n if not _download_file(file_url, fs_target_path):\\n print(\"File not found: {} {}\".format(target_path, short_hash))\\n return False\\n for target_path, url in package_json.get(\"urls\", ()):\\n fs_target_path = target + \"/\" + target_path\\n if not _download_file(_rewrite_url(url, version), fs_target_path):\\n print(\"File not found: {} {}\".format(target_path, url))\\n return False\\n for dep, dep_version in package_json.get(\"deps\", ()):\\n if not _install_package(dep, index, target, dep_version, mpy):\\n return False\\n return True\\n\\n\\ndef _install_package(package, index, target, version, mpy):\\n if (\\n package.startswith(\"http://\")\\n or package.startswith(\"https://\")\\n or package.startswith(\"github:\")\\n ):\\n if package.endswith(\".py\") or package.endswith(\".mpy\"):\\n print(\"Downloading {} to {}\".format(package, target))\\n return _download_file(\\n _rewrite_url(package, version), target + \"/\" + package.rsplit(\"/\")[-1]\\n )\\n else:\\n if not package.endswith(\".json\"):\\n if not package.endswith(\"/\"):\\n package += \"/\"\\n package += \"package.json\"\\n print(\"Installing {} to {}\".format(package, target))\\n else:\\n if not version:\\n version = \"latest\"\\n print(\"Installing {} ({}) from {} to {}\".format(package, version, index, target))\\n\\n mpy_version = (\\n sys.implementation._mpy & 0xFF if mpy and hasattr(sys.implementation, \"_mpy\") else \"py\"\\n )\\n\\n # WARNING: mpy_version fails miserably with 1.22.0-380\\n package = \"{}/package/{}/{}/{}.json\".format(index, \"py\", package, version)\\n\\n return _install_json(package, index, target, version, mpy)\\n\\n\\ndef install(package, index=None, target=None, version=None, mpy=True):\\n if not target:\\n for p in sys.path:\\n if p.endswith(\"/lib\"):\\n target = p\\n break\\n else:\\n print(\"Unable to find lib dir in sys.path\")\\n return\\n\\n if not index:\\n index = _PACKAGE_INDEX\\n\\n if _install_package(package, index.rstrip(\"/\"), target, version, mpy):\\n print(\"Done\")\\n else:\\n print(\"Package may be partially installed\")\\n');const dn=async e=>(await import(\"./toml-DiUM0_qs.js\")).parse(e),hn=(e,t)=>{try{e.mkdir(t)}catch(e){}};var yn={type:\"micropython\",module:(e=\"1.24.0-preview-114\")=>`https://cdn.jsdelivr.net/npm/@micropython/micropython-webassembly-pyscript@${e}/micropython.mjs`,async engine({loadMicroPython:e},t,n,r){const{stderr:s,stdout:o,get:a}=ot({stderr:it(console.error),stdout:it(console.log)});n=n.replace(/\\.m?js$/,\".wasm\");const i=await a(e({linebuffer:!1,stderr:s,stdout:o,url:n})),c=gn.bind(this,i,r);return on.set(i,c),t.files&&await Kt(this,i,t.files,r),t.fetch&&await zt(this,i,t.fetch,r),t.js_modules&&await Xt(t.js_modules,r),this.writeFile(i,\"./mip.py\",fn),t.packages&&await c(t.packages),i},registerJSModule:an,run:ln,runAsync:un,runEvent:pn,transform:(e,t)=>e.PyProxy.toJs(t),writeFile:(e,t,n,r)=>{const{FS:s,_module:{PATH:o,PATH_FS:a}}=e,i={FS:s,PATH:o,PATH_FS:a},c=cn(t,r);if(c){const r=t.slice(0,-1);switch(\"./\"!==r&&s.mkdir(r),c){case\"whl\":case\"zip\":{const e=new Blob([n],{type:\"application/zip\"});return import(\"./zip-gl8b5xR3.js\").then((async({BlobReader:t,Uint8ArrayWriter:n,ZipReader:a})=>{const i=new a(new t(e));for(const e of await i.getEntries()){const{directory:t,filename:a}=e,i=r+a;if(t)hn(s,i);else{hn(s,o.dirname(i));const t=await e.getData(new n);s.writeFile(i,t,{canOwn:!0})}}i.close()}))}case\"tgz\":case\"tar.gz\":{const t=\"./_.tar.gz\";return Ct(i,t,n),void e.runPython(`\\n import os, gzip, tarfile\\n tar = tarfile.TarFile(fileobj=gzip.GzipFile(fileobj=open(\"${t}\", \"rb\")))\\n for f in tar:\\n name = f\"${r}{f.name}\"\\n if f.type == tarfile.DIRTYPE:\\n if f.name != \"./\":\\n os.mkdir(name.strip(\"/\"))\\n else:\\n dir = os.path.dirname(name)\\n if not os.path.exists(dir):\\n os.mkdir(dir)\\n source = tar.extractfile(f)\\n with open(name, \"wb\") as dest:\\n dest.write(source.read())\\n dest.close()\\n tar.close()\\n os.remove(\"${t}\")\\n `)}}}return Ct(i,t,n)}};async function gn(e,t,n){let r;for(const s of n)if(s.endsWith(\".whl\")){const n=wt(s,t),r=await Wt(n).arrayBuffer();await this.writeFile(e,\"./*\",r,n)}else r||(r=e.pyimport(\"mip\")),r.install(s)}const wn={dict_converter:Object.fromEntries};let mn=!1;const _n=e=>(...t)=>{try{return mn=!0,e(...t)}finally{mn=!1}};let bn=!1;const En=()=>{if(bn)return;bn=!0;const e=new WeakMap,t=e=>e.destroy(),n=n=>{for(let r=0;r<n.length;r++){const s=n[r];if(\"function\"==typeof s&&\"copy\"in s){mn=!1;let o=e.get(s)?.deref();if(!o)try{o=F(s.copy(),t),e.set(s,new WeakRef(o))}catch(e){console.error(e)}o&&(n[r]=o),mn=!0}}},{call:r}=Function,s=r.bind(r,r.apply);Object.defineProperties(Function.prototype,{apply:{value(e,t){return mn&&n(t),s(this,e,t)}},call:{value(e,...t){return mn&&n(t),s(this,e,t)}}})};var vn={type:\"pyodide\",module:(e=\"0.26.1\")=>`https://cdn.jsdelivr.net/pyodide/v${e}/full/pyodide.mjs`,async engine({loadPyodide:e},t,n,r){Dt||\"auto\"!==t.experimental_create_proxy||En();const{stderr:s,stdout:o,get:a}=ot(),i=n.slice(0,n.lastIndexOf(\"/\")),c=await a(e({stderr:s,stdout:o,indexURL:i})),l=xn.bind(c);return on.set(c,l),t.files&&await Kt(this,c,t.files,r),t.fetch&&await zt(this,c,t.fetch,r),t.js_modules&&await Xt(t.js_modules,r),t.packages&&await l(t.packages),c},registerJSModule:an,run:_n(ln),runAsync:_n(un),runEvent:_n(pn),transform:(e,t)=>Tn.call(e,t),writeFile:(e,t,n,r)=>{const s=cn(t,r);if(s)return e.unpackArchive(n,s,{extractDir:t.slice(0,-1)});const{FS:o,PATH:a,_module:{PATH_FS:i}}=e;return Ct({FS:o,PATH:a,PATH_FS:i},t,n)}};function Tn(e){const{ffi:{PyProxy:t}}=this;if(e&&\"object\"==typeof e){if(e instanceof t)return e.toJs(wn);if(e instanceof Map)return new Map([...e.entries()]);if(lt(e))return e.map(Tn,this)}return e}async function xn(e){await this.loadPackage(\"micropip\");const t=this.pyimport(\"micropip\");await t.install(e,{keep_going:!0}),t.destroy()}const kn=\"ruby-wasm-wasi\",Sn=kn.replace(/\\W+/g,\"_\");var On={type:kn,experimental:!0,module:(e=\"2.6.2\")=>`https://cdn.jsdelivr.net/npm/@ruby/3.2-wasm-wasi@${e}/dist/browser/+esm`,async engine({DefaultRubyVM:e},t,n,r){n=n.replace(/\\/browser\\/\\+esm$/,\"/ruby.wasm\");const s=await Wt(n).arrayBuffer(),o=await WebAssembly.compile(s),{vm:a}=await e(o);return t.files&&await Kt(this,a,t.files,r),t.fetch&&await zt(this,a,t.fetch,r),t.js_modules&&await Xt(t.js_modules,r),a},registerJSModule(e,t,n){t=t.replace(/\\W+/g,\"__\");const r=`__module_${Sn}_${t}`;globalThis[r]=n,this.run(e,`require \"js\";$${t}=JS.global[:${r}]`),delete globalThis[r]},run:(e,t,...n)=>e.eval(ct(t),...n),runAsync:(e,t,...n)=>e.evalAsync(ct(t),...n),async runEvent(e,t,n){if(/^xworker\\.(on\\w+)$/.test(t)){const{$1:t}=RegExp,r=`__module_${Sn}_event`;globalThis[r]=n,this.run(e,`require \"js\";$xworker.call(\"${t}\",JS.global[:${r}])`),delete globalThis[r]}else{const r=this.run(e,`method(:${t})`);await r.call(t,e.wrap(n))}},transform:(e,t)=>t,writeFile:()=>{throw new Error(`writeFile is not supported in ${kn}`)}};var An={type:\"wasmoon\",module:(e=\"1.16.0\")=>`https://cdn.jsdelivr.net/npm/wasmoon@${e}/+esm`,async engine({LuaFactory:e,LuaLibraries:t},n,r,s){const{stderr:o,stdout:a,get:i}=ot(),c=await i((new e).createEngine());return c.global.getTable(t.Base,(e=>{c.global.setField(e,\"print\",a),c.global.setField(e,\"printErr\",o)})),n.files&&await Kt(this,c,n.files,s),n.fetch&&await zt(this,c,n.fetch,s),n.js_modules&&await Xt(n.js_modules,s),c},registerJSModule:(e,t,n)=>{e.global.set(t,n)},run:(e,t,...n)=>{try{return e.doStringSync(ct(t),...n)}catch(t){st.get(e).stderr(t)}},runAsync:async(e,t,...n)=>{try{return await e.doString(ct(t),...n)}catch(t){st.get(e).stderr(t)}},runEvent:async(e,t,n)=>{const[r,...s]=t.split(\".\");let o,a=e.global.get(r);for(const e of s)[o,a]=[a,a[e]];try{await a.call(o,n)}catch(t){st.get(e).stderr(t)}},transform:(e,t)=>t,writeFile:({cmodule:{module:{FS:e}}},t,n)=>((e,t,n)=>(Bt(e,Lt(t)),t=qt(e,t),e.writeFile(t,new Uint8Array(n),{canOwn:!0})))(e,t,n)};const jn=new WeakMap,Rn=async(e,t)=>{const{shelter:n,destroy:r,io:s}=jn.get(e),{output:o,result:a}=await n.captureR(ct(t));for(const{type:e,data:t}of o)s[e](t);return F(a,r,{token:!1})};var Pn={type:\"webr\",experimental:!0,module:(e=\"0.4.0\")=>`https://cdn.jsdelivr.net/npm/webr@${e}/dist/webr.mjs`,async engine(e,t,n,r){const{get:s}=ot(),o=new e.WebR;await s(o.init().then((()=>o)));const a=await new o.Shelter;return jn.set(o,{module:e,shelter:a,destroy:a.destroy.bind(a),io:st.get(o)}),t.files&&await Kt(this,o,t.files,r),t.fetch&&await zt(this,o,t.fetch,r),t.js_modules&&await Xt(t.js_modules,r),o},registerJSModule(e,t){console.warn(`Experimental interpreter: module ${t} is not supported (yet)`)},run:Rn,runAsync:Rn,async runEvent(e,t,n){await e.evalRVoid(`${t}(event)`,{env:{event:{type:[n.type]}}})},transform:(e,t)=>(console.log(\"transforming\",t),t),writeFile:()=>{}};const $n=new Map,In=new Map,Nn=new Proxy(new Map,{get(e,t){if(!e.has(t)){const[n,...r]=t.split(\"@\"),s=$n.get(n),o=/^(?:\\.?\\.?\\/|https?:\\/\\/)/i.test(r)?r.join(\"@\"):s.module(...r);e.set(t,{url:o,module:import(o),engine:s.engine.bind(s)})}const{url:n,module:r,engine:s}=e.get(t);return(e,o)=>r.then((r=>(In.set(t,e),s(r,e,n,o))))}}),Mn=e=>{for(const t of[].concat(e.type))$n.set(t,e)};for(const e of[Nt,yn,vn,On,An,Pn])Mn(e);const{parse:Fn}=JSON,Hn=e=>{try{return Fn(e)}catch(t){return dn(e)}},Wn=(e,t,n,r={})=>{if(t){const[e,s]=((e,t=\"./config.txt\")=>{let n=typeof e;return\"string\"===n&&/\\.(json|toml|txt)$/.test(e)?n=RegExp.$1:e=t,[wt(e),n]})(t,n);\"json\"===s?r=Wt(e).json():\"toml\"===s?r=Wt(e).text().then(dn):\"string\"===s?r=Hn(t):\"object\"===s&&t?r=t:\"txt\"===s&&\"string\"==typeof r&&(r=Hn(r)),t=e}return gt(r).then((n=>Nn[e](n,t)))},Dn=\"BeforeRun\",Cn=\"AfterRun\",Ln=[`code${Dn}`,`code${Dn}Async`,`code${Cn}`,`code${Cn}Async`],Bn=[\"onWorker\",\"onReady\",`on${Dn}`,`on${Dn}Async`,`on${Cn}`,`on${Cn}Async`];function qn(e,t){const{run:n,runAsync:r}=$n.get(this.type);return{...e,run:n.bind(this,t),runAsync:r.bind(this,t)}}const Un=(e,t,n,r,s,o)=>{if(s||o){const a=qn.bind(e,t),i=r?\"runAsync\":\"run\",c=e[i];e[i]=r?async function(e,t,...r){s&&await s.call(this,a(e),n);const i=await c.call(this,e,t,...r);return o&&await o.call(this,a(e),n),i}:function(e,t,...r){s&&s.call(this,a(e),n);const i=c.call(this,e,t,...r);return o&&o.call(this,a(e),n),i}}};let Jn,zn,Gn;const Yn=(e,t)=>{addEventListener(e,t||(async t=>{try{await Jn,zn(`xworker.on${e}`,t)}catch(e){postMessage(e)}}),!!t&&{once:!0})},{parse:Kn,stringify:Xn}=p,{proxy:Vn,sync:Zn,polyfill:Qn,window:er,isWindowProxy:tr}=await(async e=>{const t=await Ge(e),n=e?.transform||(e=>e),{[et]:r}=t.proxy,s=new Map,o=(e,t)=>{let n=s.get(e)?.deref();return n||s.set(e,new WeakRef(n=t(e))),n},a=([e,t])=>{switch(e){case Ye[g]:return null==t?globalThis:typeof t===y?o(t,p.object):t;case Ye[f]:return typeof t===y?o(t,p.array):t;case Ye[d]:return typeof t===y?o(t,p.function):te(parseInt(t));case Ye[w]:return(e=>{if(e.startsWith(\".\"))return Symbol.for(e.slice(1));for(const[t,n]of Ve)if(n===e)return t})(t);default:return t}},i=e=>{let[t,r]=m(e);switch(t){case g:if(r==globalThis||null==r)r=null;else if(typeof r===g&&!(r instanceof ue)){r=n(r);for(const e in r)r[e]=i(r[e])}return[Ye[g],r];case f:return[Ye[f],typeof r===y?r:n(r).map(i)];case d:return[Ye[d],typeof r===d?String(ne(n(r))):r];case w:return[Ye[w],Ze(e)];default:return[Ye[t],r]}},c=(...e)=>a(r(...e)),l={[E]:(e,t,n)=>c(E,e,i(t),i(n)),[v]:(e,t)=>c(v,e,i(t)),[T]:(e,t)=>c(T,e,i(t)),[k]:e=>c(k,e),[x]:(e,t)=>{const n=c(x,e,i(t));if(n){const{get:e,set:t,value:r}=n;e&&(n.get=a(e)),t&&(n.set=a(t)),r&&(n.value=a(r))}return n},[S]:(e,t)=>c(S,e,i(t)),[O]:e=>c(O,e),[A]:e=>c(A,e).map(a),[j]:e=>c(j,e),[R]:(e,t,n)=>c(R,e,i(t),i(n)),[P]:(e,t)=>c(P,e,i(t)),[Ke](e){s.delete(e),r(Ke,e)}},u={object:l,array:l,function:{...l,[_]:(e,...t)=>c(_,e,...t.map(i)),[b]:(e,...t)=>c(b,e,...t.map(i))}},{proxy:p,isProxy:h,pair:m}=V(u),$=p.object(null);return t.proxy[tt]=(e,t,...n)=>{const r=parseInt(t);switch(e){case _:{const[e,t]=n;return i(nt(te(r),a(e),t.map(a)))}case Ke:(e=>{const[t,n]=typeof e===y?[ee,Q]:[Q,ee],r=t.has(e);r&&(n.delete(t.get(e)),t.delete(e))})(r)}},{...t,window:$,isWindowProxy:h}})({parse:Kn,stringify:Xn,transform:e=>Gn?Gn(e):e}),nr={polyfill:Qn,sync:Vn,window:Zn?er:null,isWindowProxy:tr,onmessage:console.info,onerror:console.error,onmessageerror:console.warn,postMessage:postMessage.bind(self)};Yn(\"message\",(({data:{options:e,config:t,configURL:n,code:r,hooks:s}})=>{Jn=(async()=>{try{const{id:o,tag:a,type:i,custom:c,version:l,config:u,async:p}=e,f=((e,t=\"\")=>`${e}@${t}`.replace(/@$/,\"\"))(i,l),d=await Wn(f,t,n,u),{js_modules:h}=In.get(f),y=h?.main,g=pt($n.get(i)),w=((e,t,n,r)=>({type:t,config:n,interpreter:r,io:st.get(r),run:(t,...n)=>e.run(r,t,...n),runAsync:(t,...n)=>e.runAsync(r,t,...n),runEvent:(...t)=>e.runEvent(r,...t)}))(g,c||i,u||{},d);let m=\"run\";if(p&&(m+=\"Async\"),s){let e,t,n=\"\",r=\"\";for(const e of Ln){const t=s[e];if(t){const s=e.endsWith(\"Async\");(s&&p||!s&&!p)&&(e.startsWith(\"codeBefore\")?n=t:r=t)}}(n||r)&&((e,t,n,r)=>{const s=e[t].bind(e);e[t]=\"run\"===t?(e,t,...o)=>{n&&s(e,n,...o);const a=s(e,bt(t),...o);return r&&s(e,r,...o),a}:async(e,t,...o)=>{n&&await s(e,n,...o);const a=await s(e,bt(t),...o);return r&&await s(e,r,...o),a}})(g,m,n,r);for(const n of Bn.slice(2)){const r=s[n];if(r){const s=n.endsWith(\"Async\");if(s&&p||!s&&!p){const s=_t(r);n.startsWith(\"onBefore\")?e=s:t=s}}}Un(g,w,nr,p,e,t)}let _,b,E,v=null,T=\"\";Zn&&(({CustomEvent:_,document:b}=er),v=o&&b.getElementById(o)||null,E=e=>mt(v,c||i,e,!0,_));const x=Rt(er,Vn,y,t);if(((e,t,n,r)=>{if(\"pyodide\"===e)return;const s=\"polyscript.js_modules\";for(const e of Reflect.ownKeys(r))t.registerJSModule(n,`${s}.${e}`,xt(r,e));t.registerJSModule(n,s,r)})(i,g,d,x),g.registerJSModule(d,\"polyscript\",{xworker:nr,currentScript:v,config:w.config,js_modules:x,get target(){return!T&&v&&(\"SCRIPT\"===a?v.after(ut(b.createElement(`script-${c||i}`),{id:T=`${o}-target`})):(T=o,v.replaceChildren(),v.style.display=\"block\")),T}}),zn=g.runEvent.bind(g,d),Gn=g.transform.bind(g,d),v&&E(\"ready\"),s?.onReady&&_t(s?.onReady).call(g,qn.call(g,w,d),nr),await g[m](d,r),[\"micropython\",\"pyodide\"].includes(g.type)){const e=\"polyscript\",t=`__${e}_workers__`,n=\"__export__\";d.runPython([`import js as ${t}`,`${t}.${t} = \"${n}\" in locals() and ${n} or []`,`del ${t}`].join(\"\\n\"));const r=[...globalThis[t]];delete globalThis[t],r.length&&d.runPython([`from ${e} import xworker as ${t}`,...r.map((e=>`${t}.sync.${e} = ${e}`)),`del ${t}`].join(\"\\n\"))}return v&&E(\"done\"),postMessage(\"polyscript:done\"),d}catch(e){postMessage(e)}})(),Yn(\"error\"),Yn(\"message\"),Yn(\"messageerror\")}));\n".replace(re,place)],{type:'application/javascript'})), ...args)
export default (...args) => new Worker(URL.createObjectURL(new Blob(["const e=\"object\"==typeof self?self:globalThis,t=t=>((t,n)=>{const r=(e,n)=>(t.set(n,e),e),s=o=>{if(t.has(o))return t.get(o);const[a,i]=n[o];switch(a){case 0:case-1:return r(i,o);case 1:{const e=r([],o);for(const t of i)e.push(s(t));return e}case 2:{const e=r({},o);for(const[t,n]of i)e[s(t)]=s(n);return e}case 3:return r(new Date(i),o);case 4:{const{source:e,flags:t}=i;return r(new RegExp(e,t),o)}case 5:{const e=r(new Map,o);for(const[t,n]of i)e.set(s(t),s(n));return e}case 6:{const e=r(new Set,o);for(const t of i)e.add(s(t));return e}case 7:{const{name:t,message:n}=i;return r(new e[t](n),o)}case 8:return r(BigInt(i),o);case\"BigInt\":return r(Object(BigInt(i)),o)}return r(new e[a](i),o)};return s})(new Map,t)(0),n=\"\",{toString:r}={},{keys:s}=Object,o=e=>{const t=typeof e;if(\"object\"!==t||!e)return[0,t];const s=r.call(e).slice(8,-1);switch(s){case\"Array\":return[1,n];case\"Object\":return[2,n];case\"Date\":return[3,n];case\"RegExp\":return[4,n];case\"Map\":return[5,n];case\"Set\":return[6,n]}return s.includes(\"Array\")?[1,s]:s.includes(\"Error\")?[7,s]:[2,s]},a=([e,t])=>0===e&&(\"function\"===t||\"symbol\"===t),i=(e,{json:t,lossy:n}={})=>{const r=[];return((e,t,n,r)=>{const i=(e,t)=>{const s=r.push(e)-1;return n.set(t,s),s},c=r=>{if(n.has(r))return n.get(r);let[l,u]=o(r);switch(l){case 0:{let t=r;switch(u){case\"bigint\":l=8,t=r.toString();break;case\"function\":case\"symbol\":if(e)throw new TypeError(\"unable to serialize \"+u);t=null;break;case\"undefined\":return i([-1],r)}return i([l,t],r)}case 1:{if(u)return i([u,[...r]],r);const e=[],t=i([l,e],r);for(const t of r)e.push(c(t));return t}case 2:{if(u)switch(u){case\"BigInt\":return i([u,r.toString()],r);case\"Boolean\":case\"Number\":case\"String\":return i([u,r.valueOf()],r)}if(t&&\"toJSON\"in r)return c(r.toJSON());const n=[],p=i([l,n],r);for(const t of s(r))!e&&a(o(r[t]))||n.push([c(t),c(r[t])]);return p}case 3:return i([l,r.toISOString()],r);case 4:{const{source:e,flags:t}=r;return i([l,{source:e,flags:t}],r)}case 5:{const t=[],n=i([l,t],r);for(const[n,s]of r)(e||!a(o(n))&&!a(o(s)))&&t.push([c(n),c(s)]);return n}case 6:{const t=[],n=i([l,t],r);for(const n of r)!e&&a(o(n))||t.push(c(n));return n}}const{message:p}=r;return i([l,{name:u,message:p}],r)};return c})(!(t||n),!!t,new Map,r)(e),r},{parse:c,stringify:l}=JSON,u={json:!0,lossy:!0};var p=Object.freeze({__proto__:null,parse:e=>t(c(e)),stringify:e=>l(i(e,u))});const f=\"array\",d=\"function\",h=\"null\",y=\"number\",g=\"object\",w=\"symbol\",m=\"undefined\",_=\"apply\",b=\"construct\",E=\"defineProperty\",v=\"deleteProperty\",T=\"get\",x=\"getOwnPropertyDescriptor\",k=\"getPrototypeOf\",S=\"has\",O=\"isExtensible\",A=\"ownKeys\",j=\"preventExtensions\",R=\"set\",P=\"setPrototypeOf\";var $=Object.freeze({__proto__:null,APPLY:_,CONSTRUCT:b,DEFINE_PROPERTY:E,DELETE_PROPERTY:v,GET:T,GET_OWN_PROPERTY_DESCRIPTOR:x,GET_PROTOTYPE_OF:k,HAS:S,IS_EXTENSIBLE:O,OWN_KEYS:A,PREVENT_EXTENSION:j,SET:R,SET_PROTOTYPE_OF:P});function I(){return this}const N=new FinalizationRegistry((([e,t,n])=>{n&&console.debug(`Held value ${String(t)} not relevant anymore`),e(t)})),M=Object.create(null),F=(e,t,{debug:n,handler:r,return:s,token:o=e}=M)=>{const a=s||new Proxy(e,r||M),i=[a,[t,e,!!n]];return!1!==o&&i.push(o),N.register(...i),a},{Object:H,Proxy:W,Reflect:D}=globalThis,{isArray:C}=Array,{ownKeys:L}=D,{create:B,hasOwn:q,values:U}=H,J=(e,t)=>t===f?e[0]:t===d?e():t===g?e.$:e,z=(e,t,n,r)=>{const s={type:{value:t}},o=q(e,\"valueOf\");for(const a of U($)){let i=r(e[a]||D[a]);if(o&&a===T){const{valueOf:r}=e,{value:s}=i;i={value(e,o,...a){return o===n?r.call(this,J(e,t)):s.call(this,e,o,...a)}}}s[a]=i}return B(e,s)},G=(e,t,n,r=e)=>{if(r===e)switch(typeof e){case g:case m:r||(r=!1);case d:break;default:r=!1,t===e&&(t=H(e))}const s=new W(t,n),{destruct:o}=n;return o?F(e,o,{token:r,return:s}):s},Y=e=>t=>{const n=typeof t;return n===g?t?e.get(t)?.[0]??(e=>C(e)?f:g)(t):h:n},K=e=>t=>{let n=typeof t;switch(n){case g:if(!t){n=h;break}case d:const r=e.get(t);r&&([n,t]=r)}return[n,t]},X=e=>((e=>{N.unregister(e)})(e),e);var V=e=>{const t=new WeakMap,n=Symbol(),r={},s=(e,n,r)=>(t.set(e,[n,r]),e),o={proxy:r,release:X,pair:K(t),typeOf:Y(t),isProxy:e=>t.has(e),valueOf:e=>e[n]??e.valueOf()};for(const t of L(e)){if(q(o,t))continue;const a=e[t];switch(t){case f:{const e=z(a,t,n,(e=>({value([t],...n){return e.call(this,t,...n)}})));r[t]=(t,...n)=>s(G(t,[t],e,...n),f,t);break}case d:{const e=z(a,t,n,(e=>({value(t,...n){return e.call(this,t(),...n)}})));r[t]=(t,...n)=>{return s(G(t,(r=t,I.bind(r)),e,...n),d,t);var r};break}case g:{const e=z(a,t,n,(e=>({value({$:t},...n){return e.call(this,t,...n)}})));r[t]=(t,...n)=>s(G(t,{$:t},e,...n),g,t);break}default:{const e=z(a,t,n,(e=>({value:e})));r[t]=(n,...r)=>s(G(n,n,e,...r),t,n);break}}}return o};let Z=0;const Q=new Map,ee=new Map,te=e=>ee.get(e),ne=e=>{if(!Q.has(e)){let t;for(;ee.has(t=Z++););Q.set(e,t),ee.set(t,e)}return Q.get(e)},{ArrayBuffer:re,Atomics:se,Promise:oe}=globalThis,{isArray:ae}=Array,{create:ie,getPrototypeOf:ce,values:le}=Object,ue=ce(Int32Array),pe=ie(se),fe=({currentTarget:e,type:t,origin:n,lastEventId:r,source:s,ports:o},a)=>e.dispatchEvent(new MessageEvent(t,{data:a,origin:n,lastEventId:r,source:s,ports:o})),de=()=>oe.withResolvers();let he=0;const ye=new Map,ge=(e,t)=>class extends e{constructor(e,...n){super(e,...n),e instanceof t&&ye.set(this,[he++,0,de()])}},we=new WeakSet,me=e=>(we.add(e),e),_e=(e,t)=>{const{data:n}=e,r=ae(n)&&(n.at(0)===t||0===n.at(1)&&!t);return r&&(e.stopImmediatePropagation(),e.preventDefault()),r},be=e=>null!==e&&\"object\"==typeof e&&!we.has(e),Ee=new WeakMap,ve=(e,t,n)=>{if(ye.has(e))t.set(e,ye.get(e)[0]);else if(!(e instanceof ue||e instanceof re))for(const r of le(e))be(r)&&!n.has(r)&&(n.add(r),ve(r,t,n))},Te=(...e)=>({value:new oe((t=>{let n=new Worker(\"data:application/javascript,onmessage%3De%3D%3EpostMessage(!Atomics.wait(...e.data))\");n.onmessage=()=>t(\"ok\"),n.postMessage(e)}))}),xe=(e,t)=>{const n=ye.get(e),[r,s,{promise:o}]=n;return n[1]=t,[r,o]};let{BigInt64Array:ke,Int32Array:Se,SharedArrayBuffer:Oe,addEventListener:Ae,postMessage:je}=globalThis,Re=!0,Pe=e=>e,$e=!1;const Ie=de();try{new Oe(4),pe.waitAsync||(pe.waitAsync=Te),Ie.resolve()}catch(e){const t=je,n=Ae,r=[];let s=\"\",o=\"\";Oe=class extends re{},ke=ge(ke,Oe),Se=ge(Se,Oe),Pe=me,$e=!0,pe.notify=(e,n)=>{const[r]=(e=>Ee.get(e))(e);return t([s,1,e,r,n]),0},pe.waitAsync=(...e)=>{const[t,n]=xe(...e);return{value:n}},pe.wait=(e,t,...n)=>{const[r]=xe(e,t,...n),a=new XMLHttpRequest;a.responseType=\"json\",a.open(\"POST\",`${o}?sabayon`,!1),a.setRequestHeader(\"Content-Type\",\"application/json\"),a.send(`[\"${s}\",${r},${t}]`);const{response:i}=a;ye.delete(e);for(let t=0;t<i.length;t++)e[t]=i[t];return\"ok\"},n(\"message\",(e=>{if(_e(e,s)){const[t,n,...r]=e.data;switch(n){case 0:s=t,o=r.at(0)?.serviceWorker||\"\",o||(pe.wait=null,Ie.resolve());break;case 1:((e,t,n)=>{for(const[r,[s,o,{resolve:a}]]of ye)if(t===s&&n===o){for(let t=0;t<e.length;t++)r[t]=e[t];ye.delete(r),a(\"ok\");break}})(...r);break;case 2:((e,t,n)=>{for(const[n,r]of t)Ee.set(n,[r,e.currentTarget]);fe(e,n)})(e,...r);break;case 3:Ie.resolve()}}else if(Re){const{currentTarget:t,type:n,origin:s,lastEventId:o,source:a,ports:i}=e;r.push([{currentTarget:t,type:n,origin:s,lastEventId:o,source:a,ports:i},e.data])}})),Ae=(e,...t)=>{if(n(e,...t),r.length)for(const e of r.splice(0))fe(...e)},je=(e,...n)=>t(((e,t)=>{const n=new Map;return be(t)&&ve(t,n,new Set),n.size?[e,2,n,t]:t})(s,e),...n)}await Ie.promise,Re=!1;const{BYTES_PER_ELEMENT:Ne}=Int32Array,{BYTES_PER_ELEMENT:Me}=Uint16Array,{notify:Fe}=pe,He=new TextDecoder(\"utf-16\"),We=new WeakSet,De=(...e)=>(We.add(e),e);let Ce=\"\";const Le=(e,t,n,r)=>{const[s]=r,o=n.get(s);if(!o)throw new Error(`Unknown proxy.${s}()`);e(o,t,r)};let Be=0;const qe=([e,t,n,r,s,o,a,i,c],l)=>(...u)=>{let p=\"\"!==Ce,f=0;p&&\"=\"!==Ce[0]&&\"-\"!==Ce[0]&&(f=((e,t)=>setTimeout(console.warn,3e3,`πŸ’€πŸ”’ - proxy.${e}() in proxy.${t}()`))(l,Ce));const d=Be++,h=[];We.has(u.at(-1)||h)&&We.delete(h=u.pop());const y=n(i?u.map(i):u);let g=t(2*Ne);return a([e,2,l,d,g,y,r],{transfer:h}),c(g,0).value.then((()=>{p&&clearTimeout(f);const n=g[1];if(!n)return;const r=Me*n;return g=t(r+r%Ne),a([e,1,d,g]),c(g,0).value.then((()=>{const e=new Uint16Array(g.buffer),t=o?e.subarray(0,n):e.slice(0,n);return s(He.decode(t))}))}))},Ue=(e,t)=>new Proxy(t,{get:(t,n)=>{let r;return\"then\"!==n&&(r=t.get(n),r||(r=qe(e,n),t.set(n,r))),r},set:(e,t,n)=>\"then\"!==t&&!!e.set(t,n)}),{wait:Je,waitAsync:ze}=pe;var Ge=({parse:e,stringify:t,transform:n,interrupt:r}=JSON)=>{const s=((e,t)=>async(n,r,[s,o,a,i,c])=>{c&&(Ce=s);try{const s=await n(...i);if(void 0!==s){const n=e(t?t(s):s);r.set(o,n),a[1]=n.length}}finally{c&&(Ce=\"\"),a[0]=1,Fe(a,0)}})(t,n),o=de(),a=new Map,i=new Map;let c=\"\",l=Je;if(Je&&r){const{handler:e,timeout:t=42}=r;l=(n,r,s)=>{for(;\"timed-out\"===(s=Je(n,r,0,t));)e();return s}}return Ae(\"message\",(t=>{if(_e(t,c)){const[r,u,...p]=t.data;switch(u){case 0:{const t=!!Je;c=r,o.resolve({polyfill:$e,sync:t,transfer:De,proxy:Ue([c,e=>new Se(new Oe(e)),Pe,t,e,$e,je,n,t?(...e)=>({value:{then:t=>t(l(...e))}}):ze],a)});break}case 2:a.size?Le(s,i,a,p):setTimeout(Le,0,s,i,a,p);break;case 1:((e,[t,n])=>{const r=e.get(t);e.delete(t);for(let e=new Uint16Array(n.buffer),t=0,{length:s}=r;t<s;t++)e[t]=r.charCodeAt(t);Fe(n,0)})(i,p)}}})),o.promise},Ye=Object.fromEntries([f,\"bigint\",\"boolean\",d,h,y,g,\"string\",w,m].map(((e,t)=>[e,t])));const Ke=\"destruct\",{[A]:Xe}=Reflect,Ve=new Map(Xe(Symbol).filter((e=>typeof Symbol[e]===w)).map((e=>[Symbol[e],e]))),Ze=e=>Ve.get(e)||`.${Symbol.keyFor(e)||\"\"}`,Qe=\"b87ec809-9df6-4389-a29e-bc91090db4dc\",et=\"=\"+Qe,tt=\"-\"+Qe,{[_]:nt}=Reflect;const rt={object(...e){return this.string(function(e){for(var t=e[0],n=1,r=arguments.length;n<r;n++)t+=arguments[n]+e[n];return t}(...e))},string(e){for(const t of e.split(/[\\r\\n]+/))if(t.trim().length){/^(\\s+)/.test(t)&&(e=e.replace(new RegExp(\"^\"+RegExp.$1,\"gm\"),\"\"));break}return e}},st=new WeakMap,ot=e=>{const t=e||console,n={buffered:it,stderr:(t.stderr||console.error).bind(t),stdout:(t.stdout||console.log).bind(t)};return{stderr:(...e)=>n.stderr(...e),stdout:(...e)=>n.stdout(...e),async get(e){const t=await e;return st.set(t,n),t}}},at=new TextDecoder,it=(e,t=10)=>{const n=[];return r=>{if(r instanceof Uint8Array)for(const s of r)s===t?e(at.decode(new Uint8Array(n.splice(0)))):n.push(s);else e(r)}},ct=(e,...t)=>rt[typeof e](e,...t),{isArray:lt}=Array,{assign:ut,create:pt,defineProperties:ft,defineProperty:dt,entries:ht}=Object,{all:yt,resolve:gt}=new Proxy(Promise,{get:(e,t)=>e[t].bind(e)}),wt=(e,t=location.href)=>new URL(e,t.replace(/^blob:/,\"\")).href,mt=(e,t,n,r=!1,s=CustomEvent)=>{e.dispatchEvent(new s(`${t}:${n}`,{bubbles:!0,detail:{worker:r}}))},_t=e=>Function(`'use strict';return (${e})`)(),bt=e=>e.replace(/^(?:\\n|\\r\\n)/,\"\"),Et=Symbol.for(\"polyscript.js_modules\"),vt=new Map;dt(globalThis,Et,{value:vt}),new Proxy(vt,{get:(e,t)=>e.get(t),has:(e,t)=>e.has(t),ownKeys:e=>[...e.keys()]});const Tt=(e,t)=>!t.startsWith(\"_\"),xt=(e,t)=>new Proxy(e,{has:Tt,get:(e,n)=>e[t][n]}),kt=(e,t)=>import(e).then((e=>{vt.set(t,{...e})})),St=e=>new Promise(((t,n)=>{document.querySelector(`link[rel=\"stylesheet\"][href=\"${e}\"]`)?t():document.head.append(ut(document.createElement(\"link\"),{rel:\"stylesheet\",href:e,onload:t,onerror:n}))})),Ot=e=>/\\.css$/i.test(new URL(e).pathname),At=(e,t)=>e.has(t),jt=e=>[...e.keys()];var Rt=(e,t,n,r)=>{const s=globalThis[Et];if(n)for(let[e,t]of ht(n)){let n=s.get(t);n&&!lt(n)||(s.set(t,n||(n=[])),n.push(e))}return((e,t,n,r)=>new Proxy(e,{has:At,ownKeys:jt,get:(e,s)=>{let o=e.get(s);if(lt(o)){let a=o;o=null;for(let e of a)e=wt(e,r),Ot(e)?n.importCSS(e):(n.importJS(e,s),o=t[Et].get(s));e.set(s,o)}return o}}))(s,e,t,r)};const Pt=new Map,$t=e=>Pt.get(e),It=(e,t)=>{try{return Function(\"require\",t)($t)}catch(t){st.get(e).stderr(t)}};var Nt={type:\"dummy\",module:()=>\"data:application/javascript,\",engine:e=>ot().get(e),registerJSModule(e,t,n){Pt.set(t,n)},run:It,runAsync:It,runEvent:async(e,t,n)=>{try{await Function(\"require\",\"e\",`return ${t}(e)`)($t,n)}catch(t){st.get(e).stderr(t)}},transform:(e,t)=>t,writeFile(){}};const Mt=Object.getOwnPropertyDescriptors(Response.prototype),Ft=e=>\"function\"==typeof e,Ht={get:(e,t)=>Mt.hasOwnProperty(t)?((e,t,{get:n,value:r})=>n||!Ft(r)?e.then((e=>e[t])):(...n)=>e.then((e=>e[t](...n))))(e,t,Mt[t]):((e,t)=>Ft(t)?t.bind(e):t)(e,e[t])};var Wt=(e,...t)=>new Proxy(fetch(e,...t),Ht);Promise.withResolvers||(Promise.withResolvers=function(){var e,t,n=new this((function(n,r){e=n,t=r}));return{resolve:e,reject:t,promise:n}});const Dt=!globalThis.window,Ct=({FS:e,PATH:t,PATH_FS:n},r,s)=>{const o=n.resolve(r),a=t.dirname(o);return e.mkdirTree?e.mkdirTree(a):Bt(e,a),e.writeFile(o,new Uint8Array(s),{canOwn:!0})},Lt=e=>{const t=e.split(\"/\");return t.pop(),t.join(\"/\")},Bt=(e,t)=>{const n=[];for(const r of t.split(\"/\"))\".\"!==r&&\"..\"!==r&&(n.push(r),r&&e.mkdir(n.join(\"/\")))},qt=(e,t)=>{const n=[];for(const e of t.split(\"/\"))switch(e){case\"\":case\".\":break;case\"..\":n.pop();break;default:n.push(e)}return[e.cwd()].concat(n).join(\"/\").replace(/^\\/+/,\"/\")},Ut=e=>{const t=e.map((e=>e.trim().replace(/(^[/]*|[/]*$)/g,\"\"))).filter((e=>\"\"!==e&&\".\"!==e)).join(\"/\");return e[0].startsWith(\"/\")?`/${t}`:t},Jt=(e,t)=>Wt(wt(e,t)).arrayBuffer(),zt=(e,t,n,r)=>yt((e=>{for(const{files:t,to_file:n,from:r=\"\"}of e){if(void 0!==t&&void 0!==n)throw new Error(\"Cannot use 'to_file' and 'files' parameters together!\");if(void 0===t&&void 0===n&&r.endsWith(\"/\"))throw new Error(`Couldn't determine the filename from the path ${r}, please supply 'to_file' parameter.`)}return e.flatMap((({from:e=\"\",to_folder:t=\".\",to_file:n,files:r})=>{if(lt(r))return r.map((n=>({url:Ut([e,n]),path:Ut([t,n])})));const s=n||e.slice(1+e.lastIndexOf(\"/\"));return[{url:e,path:Ut([t,s])}]}))})(n).map((({url:n,path:s})=>Jt(n,r).then((n=>e.writeFile(t,s,n)))))),Gt=(e,t)=>t.endsWith(\"/\")?`${t}${e.split(\"/\").pop()}`:t,Yt=(e,t)=>e.replace(/\\{.+?\\}/g,(e=>{if(!t.has(e))throw new SyntaxError(`Invalid template: ${e}`);return t.get(e)})),Kt=(e,t,n,r)=>yt((e=>{const t=new Map,n=new Set,r=[];for(const[s,o]of ht(e))if(/^\\{.+\\}$/.test(s)){if(t.has(s))throw new SyntaxError(`Duplicated template: ${s}`);t.set(s,Yt(o,t))}else{const e=Yt(s,t),a=Gt(e,Yt(o||\"./\",t));if(n.has(a))throw new SyntaxError(`Duplicated destination: ${a}`);n.add(a),r.push({url:e,path:a})}return r})(n).map((({url:n,path:s})=>Jt(n,r).then((r=>e.writeFile(t,s,r,n)))))),Xt=({main:e,worker:t},n)=>{const r=[];if(t&&Dt)for(let[e,s]of ht(t))e=wt(e,n),r.push(kt(e,s));if(e&&!Dt)for(let[t,s]of ht(e))t=wt(t,n),Ot(t)?St(t):r.push(kt(t,s));return yt(r)},{assign:Vt}=Object,Zt=\"entries\",Qt=\"readonly\",en=\"readwrite\",tn={durability:\"default\",prefix:\"IDBMap\"},nn=({target:{result:e}})=>e;class rn extends EventTarget{#e;#t;#n;async#r(e,t){const n=(await this.#e).transaction(Zt,t,this.#t);return new Promise(((t,r)=>Vt(e(n.objectStore(Zt)),{onsuccess:t,onerror:r})))}constructor(e,{durability:t=tn.durability,prefix:n=tn.prefix}=tn){super(),this.#n=n,this.#t={durability:t},this.#e=new Promise(((t,n)=>{Vt(indexedDB.open(`${this.#n}/${e}`),{onupgradeneeded({target:{result:e,transaction:n}}){e.objectStoreNames.length||e.createObjectStore(Zt),n.oncomplete=()=>t(e)},onsuccess(e){t(nn(e))},onerror(e){n(e),this.dispatchEvent(e)}})})).then((e=>{const t=this.dispatchEvent.bind(this);for(const n in e)n.startsWith(\"on\")&&(e[n]=t);return e}))}dispatchEvent(e){const{type:t,message:n,isTrusted:r}=e;return super.dispatchEvent(r?Vt(new Event(t),{message:n}):e)}async close(){(await this.#e).close()}get size(){return this.#r((e=>e.count()),Qt).then(nn)}async clear(){await this.#r((e=>e.clear()),en)}async delete(e){await this.#r((t=>t.delete(e)),en)}async entries(){const e=await this.keys();return Promise.all(e.map((e=>this.get(e).then((t=>[e,t])))))}async forEach(e,t=this){for(const[n,r]of await this.entries())await e.call(t,r,n,this)}async get(e){return await this.#r((t=>t.get(e)),Qt).then(nn)}async has(e){return void 0!==await this.#r((t=>t.getKey(e)),Qt).then(nn)}async keys(){return await this.#r((e=>e.getAllKeys()),Qt).then(nn)}async set(e,t){return await this.#r((n=>n.put(t,e)),en),this}async values(){const e=await this.keys();return Promise.all(e.map((e=>this.get(e))))}get[Symbol.toStringTag](){return this.#n}}class sn extends Map{#s;#o;constructor(...e){super(),this.#s=new rn(...e),this.#o=this.#s.entries().then((e=>{for(const[t,n]of e)super.set(t,n)}))}async sync(){await this.#o}clear(){return this.#o=this.#o.then((()=>this.#s.clear())),super.clear()}delete(e){return this.#o=this.#o.then((()=>this.#s.delete(e))),super.delete(e)}set(e,t){return this.#o=this.#o.then((()=>this.#s.set(e,t))),super.set(e,t)}}const on=new WeakMap,an=(e,t,n)=>{\"polyscript\"===t&&(n.lazy_py_modules=async(...t)=>(await on.get(e)(t),t.map((t=>e.pyimport(t)))),n.storage=async e=>{const t=new sn(e);return await t.sync(),t},n.JSON=p),e.registerJsModule(t,n)},cn=(e,t)=>{if(e.endsWith(\"/*\")){if(/\\.(zip|whl|tgz|tar(?:\\.gz)?)$/.test(t))return RegExp.$1;throw new Error(`Unsupported archive ${t}`)}return\"\"},ln=(e,t,...n)=>{try{return e.runPython(ct(t),...n)}catch(t){st.get(e).stderr(t)}},un=async(e,t,...n)=>{try{return await e.runPythonAsync(ct(t),...n)}catch(t){st.get(e).stderr(t)}},pn=async(e,t,n)=>{const[r,...s]=t.split(\".\");let o,a=e.globals.get(r);for(const e of s)[o,a]=[a,a[e]];try{await a.call(o,n)}catch(t){st.get(e).stderr(t)}};var fn=(new TextEncoder).encode('from uio import StringIO\\nimport sys\\n\\nclass Response:\\n def __init__(self, f):\\n self.raw = f\\n self.encoding = \"utf-8\"\\n self._cached = None\\n\\n def close(self):\\n if self.raw:\\n self.raw.close()\\n self.raw = None\\n self._cached = None\\n\\n @property\\n def content(self):\\n if self._cached is None:\\n try:\\n self._cached = self.raw.read()\\n finally:\\n self.raw.close()\\n self.raw = None\\n return self._cached\\n\\n @property\\n def text(self):\\n return str(self.content, self.encoding)\\n\\n def json(self):\\n import ujson\\n\\n return ujson.loads(self.content)\\n\\n\\n# TODO try to support streaming xhr requests, a-la pyodide-http\\nHEADERS_TO_IGNORE = (\"user-agent\",)\\n\\n\\ntry:\\n import js\\nexcept Exception as err:\\n raise OSError(\"This version of urequests can only be used in the browser\")\\n\\n# TODO try to support streaming xhr requests, a-la pyodide-http\\n\\nHEADERS_TO_IGNORE = (\"user-agent\",)\\n\\n\\ndef request(\\n method,\\n url,\\n data=None,\\n json=None,\\n headers={},\\n stream=None,\\n auth=None,\\n timeout=None,\\n parse_headers=True,\\n):\\n from js import XMLHttpRequest\\n\\n xhr = XMLHttpRequest.new()\\n xhr.withCredentials = False\\n\\n if auth is not None:\\n import ubinascii\\n\\n username, password = auth\\n xhr.open(method, url, False, username, password)\\n else:\\n xhr.open(method, url, False)\\n\\n for name, value in headers.items():\\n if name.lower() not in HEADERS_TO_IGNORE:\\n xhr.setRequestHeader(name, value)\\n\\n if timeout:\\n xhr.timeout = int(timeout * 1000)\\n\\n if json is not None:\\n assert data is None\\n import ujson\\n\\n data = ujson.dumps(json)\\n # s.write(b\"Content-Type: application/json\\\\r\\\\n\")\\n xhr.setRequestHeader(\"Content-Type\", \"application/json\")\\n\\n xhr.send(data)\\n\\n # Emulates the construction process in the original urequests\\n resp = Response(StringIO(xhr.responseText))\\n resp.status_code = xhr.status\\n resp.reason = xhr.statusText\\n resp.headers = xhr.getAllResponseHeaders()\\n\\n return resp\\n\\n\\n# Other methods - head, post, put, patch, delete - are not used by\\n# mip and therefore not included\\n\\n\\ndef get(url, **kw):\\n return request(\"GET\", url, **kw)\\n\\n\\n# Content below this line is from the Micropython MIP package and is covered\\n# by the applicable MIT license:\\n# \\n# THE SOFTWARE IS PROVIDED β€œAS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, \\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER \\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING \\n# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER \\n# DEALINGS IN THE SOFTWARE.\\n\\n# MicroPython package installer\\n# MIT license; Copyright (c) 2022 Jim Mussared\\n\\n\\n_PACKAGE_INDEX = const(\"https://micropython.org/pi/v2\")\\n_CHUNK_SIZE = 128\\n\\n\\n# This implements os.makedirs(os.dirname(path))\\ndef _ensure_path_exists(path):\\n import os\\n\\n split = path.split(\"/\")\\n\\n # Handle paths starting with \"/\".\\n if not split[0]:\\n split.pop(0)\\n split[0] = \"/\" + split[0]\\n\\n prefix = \"\"\\n for i in range(len(split) - 1):\\n prefix += split[i]\\n try:\\n os.stat(prefix)\\n except:\\n os.mkdir(prefix)\\n prefix += \"/\"\\n\\n\\n# Copy from src (stream) to dest (function-taking-bytes)\\ndef _chunk(src, dest):\\n buf = memoryview(bytearray(_CHUNK_SIZE))\\n while True:\\n n = src.readinto(buf)\\n if n == 0:\\n break\\n dest(buf if n == _CHUNK_SIZE else buf[:n])\\n\\n\\n# Check if the specified path exists and matches the hash.\\ndef _check_exists(path, short_hash):\\n import os\\n\\n try:\\n import binascii\\n import hashlib\\n\\n with open(path, \"rb\") as f:\\n hs256 = hashlib.sha256()\\n _chunk(f, hs256.update)\\n existing_hash = str(binascii.hexlify(hs256.digest())[: len(short_hash)], \"utf-8\")\\n return existing_hash == short_hash\\n except:\\n return False\\n\\n\\ndef _rewrite_url(url, branch=None):\\n if not branch:\\n branch = \"HEAD\"\\n if url.startswith(\"github:\"):\\n url = url[7:].split(\"/\")\\n url = (\\n \"https://raw.githubusercontent.com/\"\\n + url[0]\\n + \"/\"\\n + url[1]\\n + \"/\"\\n + branch\\n + \"/\"\\n + \"/\".join(url[2:])\\n )\\n return url\\n\\n\\ndef _download_file(url, dest):\\n response = get(url)\\n try:\\n if response.status_code != 200:\\n print(\"Error\", response.status_code, \"requesting\", url)\\n return False\\n\\n print(\"Copying:\", dest)\\n _ensure_path_exists(dest)\\n with open(dest, \"wb\") as f:\\n _chunk(response.raw, f.write)\\n\\n return True\\n finally:\\n response.close()\\n\\n\\ndef _install_json(package_json_url, index, target, version, mpy):\\n response = get(_rewrite_url(package_json_url, version))\\n try:\\n if response.status_code != 200:\\n print(\"Package not found:\", package_json_url)\\n return False\\n\\n package_json = response.json()\\n finally:\\n response.close()\\n for target_path, short_hash in package_json.get(\"hashes\", ()):\\n fs_target_path = target + \"/\" + target_path\\n if _check_exists(fs_target_path, short_hash):\\n print(\"Exists:\", fs_target_path)\\n else:\\n file_url = \"{}/file/{}/{}\".format(index, short_hash[:2], short_hash)\\n if not _download_file(file_url, fs_target_path):\\n print(\"File not found: {} {}\".format(target_path, short_hash))\\n return False\\n for target_path, url in package_json.get(\"urls\", ()):\\n fs_target_path = target + \"/\" + target_path\\n if not _download_file(_rewrite_url(url, version), fs_target_path):\\n print(\"File not found: {} {}\".format(target_path, url))\\n return False\\n for dep, dep_version in package_json.get(\"deps\", ()):\\n if not _install_package(dep, index, target, dep_version, mpy):\\n return False\\n return True\\n\\n\\ndef _install_package(package, index, target, version, mpy):\\n if (\\n package.startswith(\"http://\")\\n or package.startswith(\"https://\")\\n or package.startswith(\"github:\")\\n ):\\n if package.endswith(\".py\") or package.endswith(\".mpy\"):\\n print(\"Downloading {} to {}\".format(package, target))\\n return _download_file(\\n _rewrite_url(package, version), target + \"/\" + package.rsplit(\"/\")[-1]\\n )\\n else:\\n if not package.endswith(\".json\"):\\n if not package.endswith(\"/\"):\\n package += \"/\"\\n package += \"package.json\"\\n print(\"Installing {} to {}\".format(package, target))\\n else:\\n if not version:\\n version = \"latest\"\\n print(\"Installing {} ({}) from {} to {}\".format(package, version, index, target))\\n\\n mpy_version = (\\n sys.implementation._mpy & 0xFF if mpy and hasattr(sys.implementation, \"_mpy\") else \"py\"\\n )\\n\\n # WARNING: mpy_version fails miserably with 1.22.0-380\\n package = \"{}/package/{}/{}/{}.json\".format(index, \"py\", package, version)\\n\\n return _install_json(package, index, target, version, mpy)\\n\\n\\ndef install(package, index=None, target=None, version=None, mpy=True):\\n if not target:\\n for p in sys.path:\\n if p.endswith(\"/lib\"):\\n target = p\\n break\\n else:\\n print(\"Unable to find lib dir in sys.path\")\\n return\\n\\n if not index:\\n index = _PACKAGE_INDEX\\n\\n if _install_package(package, index.rstrip(\"/\"), target, version, mpy):\\n print(\"Done\")\\n else:\\n print(\"Package may be partially installed\")\\n');const dn=async e=>(await import(\"./toml-DiUM0_qs.js\")).parse(e),hn=(e,t)=>{try{e.mkdir(t)}catch(e){}};var yn={type:\"micropython\",module:(e=\"1.24.0-preview-114\")=>`https://cdn.jsdelivr.net/npm/@micropython/micropython-webassembly-pyscript@${e}/micropython.mjs`,async engine({loadMicroPython:e},t,n,r){const{stderr:s,stdout:o,get:a}=ot({stderr:it(console.error),stdout:it(console.log)});n=n.replace(/\\.m?js$/,\".wasm\");const i=await a(e({linebuffer:!1,stderr:s,stdout:o,url:n})),c=gn.bind(this,i,r);return on.set(i,c),t.files&&await Kt(this,i,t.files,r),t.fetch&&await zt(this,i,t.fetch,r),t.js_modules&&await Xt(t.js_modules,r),this.writeFile(i,\"./mip.py\",fn),t.packages&&await c(t.packages),i},registerJSModule:an,run:ln,runAsync:un,runEvent:pn,transform:(e,t)=>e.PyProxy.toJs(t),writeFile:(e,t,n,r)=>{const{FS:s,_module:{PATH:o,PATH_FS:a}}=e,i={FS:s,PATH:o,PATH_FS:a},c=cn(t,r);if(c){const r=t.slice(0,-1);switch(\"./\"!==r&&s.mkdir(r),c){case\"whl\":case\"zip\":{const e=new Blob([n],{type:\"application/zip\"});return import(\"./zip-gl8b5xR3.js\").then((async({BlobReader:t,Uint8ArrayWriter:n,ZipReader:a})=>{const i=new a(new t(e));for(const e of await i.getEntries()){const{directory:t,filename:a}=e,i=r+a;if(t)hn(s,i);else{hn(s,o.dirname(i));const t=await e.getData(new n);s.writeFile(i,t,{canOwn:!0})}}i.close()}))}case\"tgz\":case\"tar.gz\":{const t=\"./_.tar.gz\";return Ct(i,t,n),void e.runPython(`\\n import os, gzip, tarfile\\n tar = tarfile.TarFile(fileobj=gzip.GzipFile(fileobj=open(\"${t}\", \"rb\")))\\n for f in tar:\\n name = f\"${r}{f.name}\"\\n if f.type == tarfile.DIRTYPE:\\n if f.name != \"./\":\\n os.mkdir(name.strip(\"/\"))\\n else:\\n dir = os.path.dirname(name)\\n if not os.path.exists(dir):\\n os.mkdir(dir)\\n source = tar.extractfile(f)\\n with open(name, \"wb\") as dest:\\n dest.write(source.read())\\n dest.close()\\n tar.close()\\n os.remove(\"${t}\")\\n `)}}}return Ct(i,t,n)}};async function gn(e,t,n){let r;for(const s of n)if(s.endsWith(\".whl\")){const n=wt(s,t),r=await Wt(n).arrayBuffer();await this.writeFile(e,\"./*\",r,n)}else r||(r=e.pyimport(\"mip\")),r.install(s)}const wn={dict_converter:Object.fromEntries};let mn=!1;const _n=e=>(...t)=>{try{return mn=!0,e(...t)}finally{mn=!1}};let bn=!1;const En=()=>{if(bn)return;bn=!0;const e=new WeakMap,t=e=>e.destroy(),n=n=>{for(let r=0;r<n.length;r++){const s=n[r];if(\"function\"==typeof s&&\"copy\"in s){mn=!1;let o=e.get(s)?.deref();if(!o)try{o=F(s.copy(),t),e.set(s,new WeakRef(o))}catch(e){console.error(e)}o&&(n[r]=o),mn=!0}}},{call:r}=Function,s=r.bind(r,r.apply);Object.defineProperties(Function.prototype,{apply:{value(e,t){return mn&&n(t),s(this,e,t)}},call:{value(e,...t){return mn&&n(t),s(this,e,t)}}})};var vn={type:\"pyodide\",module:(e=\"0.26.2\")=>`https://cdn.jsdelivr.net/pyodide/v${e}/full/pyodide.mjs`,async engine({loadPyodide:e},t,n,r){Dt||\"auto\"!==t.experimental_create_proxy||En();const{stderr:s,stdout:o,get:a}=ot(),i=n.slice(0,n.lastIndexOf(\"/\")),c=await a(e({stderr:s,stdout:o,indexURL:i})),l=xn.bind(c);return on.set(c,l),t.files&&await Kt(this,c,t.files,r),t.fetch&&await zt(this,c,t.fetch,r),t.js_modules&&await Xt(t.js_modules,r),t.packages&&await l(t.packages),c},registerJSModule:an,run:_n(ln),runAsync:_n(un),runEvent:_n(pn),transform:(e,t)=>Tn.call(e,t),writeFile:(e,t,n,r)=>{const s=cn(t,r);if(s)return e.unpackArchive(n,s,{extractDir:t.slice(0,-1)});const{FS:o,PATH:a,_module:{PATH_FS:i}}=e;return Ct({FS:o,PATH:a,PATH_FS:i},t,n)}};function Tn(e){const{ffi:{PyProxy:t}}=this;if(e&&\"object\"==typeof e){if(e instanceof t)return e.toJs(wn);if(e instanceof Map)return new Map([...e.entries()]);if(lt(e))return e.map(Tn,this)}return e}async function xn(e){await this.loadPackage(\"micropip\");const t=this.pyimport(\"micropip\");await t.install(e,{keep_going:!0}),t.destroy()}const kn=\"ruby-wasm-wasi\",Sn=kn.replace(/\\W+/g,\"_\");var On={type:kn,experimental:!0,module:(e=\"2.6.2\")=>`https://cdn.jsdelivr.net/npm/@ruby/3.2-wasm-wasi@${e}/dist/browser/+esm`,async engine({DefaultRubyVM:e},t,n,r){n=n.replace(/\\/browser\\/\\+esm$/,\"/ruby.wasm\");const s=await Wt(n).arrayBuffer(),o=await WebAssembly.compile(s),{vm:a}=await e(o);return t.files&&await Kt(this,a,t.files,r),t.fetch&&await zt(this,a,t.fetch,r),t.js_modules&&await Xt(t.js_modules,r),a},registerJSModule(e,t,n){t=t.replace(/\\W+/g,\"__\");const r=`__module_${Sn}_${t}`;globalThis[r]=n,this.run(e,`require \"js\";$${t}=JS.global[:${r}]`),delete globalThis[r]},run:(e,t,...n)=>e.eval(ct(t),...n),runAsync:(e,t,...n)=>e.evalAsync(ct(t),...n),async runEvent(e,t,n){if(/^xworker\\.(on\\w+)$/.test(t)){const{$1:t}=RegExp,r=`__module_${Sn}_event`;globalThis[r]=n,this.run(e,`require \"js\";$xworker.call(\"${t}\",JS.global[:${r}])`),delete globalThis[r]}else{const r=this.run(e,`method(:${t})`);await r.call(t,e.wrap(n))}},transform:(e,t)=>t,writeFile:()=>{throw new Error(`writeFile is not supported in ${kn}`)}};var An={type:\"wasmoon\",module:(e=\"1.16.0\")=>`https://cdn.jsdelivr.net/npm/wasmoon@${e}/+esm`,async engine({LuaFactory:e,LuaLibraries:t},n,r,s){const{stderr:o,stdout:a,get:i}=ot(),c=await i((new e).createEngine());return c.global.getTable(t.Base,(e=>{c.global.setField(e,\"print\",a),c.global.setField(e,\"printErr\",o)})),n.files&&await Kt(this,c,n.files,s),n.fetch&&await zt(this,c,n.fetch,s),n.js_modules&&await Xt(n.js_modules,s),c},registerJSModule:(e,t,n)=>{e.global.set(t,n)},run:(e,t,...n)=>{try{return e.doStringSync(ct(t),...n)}catch(t){st.get(e).stderr(t)}},runAsync:async(e,t,...n)=>{try{return await e.doString(ct(t),...n)}catch(t){st.get(e).stderr(t)}},runEvent:async(e,t,n)=>{const[r,...s]=t.split(\".\");let o,a=e.global.get(r);for(const e of s)[o,a]=[a,a[e]];try{await a.call(o,n)}catch(t){st.get(e).stderr(t)}},transform:(e,t)=>t,writeFile:({cmodule:{module:{FS:e}}},t,n)=>((e,t,n)=>(Bt(e,Lt(t)),t=qt(e,t),e.writeFile(t,new Uint8Array(n),{canOwn:!0})))(e,t,n)};const jn=new WeakMap,Rn=async(e,t)=>{const{shelter:n,destroy:r,io:s}=jn.get(e),{output:o,result:a}=await n.captureR(ct(t));for(const{type:e,data:t}of o)s[e](t);return F(a,r,{token:!1})};var Pn={type:\"webr\",experimental:!0,module:(e=\"0.4.0\")=>`https://cdn.jsdelivr.net/npm/webr@${e}/dist/webr.mjs`,async engine(e,t,n,r){const{get:s}=ot(),o=new e.WebR;await s(o.init().then((()=>o)));const a=await new o.Shelter;return jn.set(o,{module:e,shelter:a,destroy:a.destroy.bind(a),io:st.get(o)}),t.files&&await Kt(this,o,t.files,r),t.fetch&&await zt(this,o,t.fetch,r),t.js_modules&&await Xt(t.js_modules,r),o},registerJSModule(e,t){console.warn(`Experimental interpreter: module ${t} is not supported (yet)`)},run:Rn,runAsync:Rn,async runEvent(e,t,n){await e.evalRVoid(`${t}(event)`,{env:{event:{type:[n.type]}}})},transform:(e,t)=>(console.log(\"transforming\",t),t),writeFile:()=>{}};const $n=new Map,In=new Map,Nn=new Proxy(new Map,{get(e,t){if(!e.has(t)){const[n,...r]=t.split(\"@\"),s=$n.get(n),o=/^(?:\\.?\\.?\\/|https?:\\/\\/)/i.test(r)?r.join(\"@\"):s.module(...r);e.set(t,{url:o,module:import(o),engine:s.engine.bind(s)})}const{url:n,module:r,engine:s}=e.get(t);return(e,o)=>r.then((r=>(In.set(t,e),s(r,e,n,o))))}}),Mn=e=>{for(const t of[].concat(e.type))$n.set(t,e)};for(const e of[Nt,yn,vn,On,An,Pn])Mn(e);const{parse:Fn}=JSON,Hn=e=>{try{return Fn(e)}catch(t){return dn(e)}},Wn=(e,t,n,r={})=>{if(t){const[e,s]=((e,t=\"./config.txt\")=>{let n=typeof e;return\"string\"===n&&/\\.(json|toml|txt)$/.test(e)?n=RegExp.$1:e=t,[wt(e),n]})(t,n);\"json\"===s?r=Wt(e).json():\"toml\"===s?r=Wt(e).text().then(dn):\"string\"===s?r=Hn(t):\"object\"===s&&t?r=t:\"txt\"===s&&\"string\"==typeof r&&(r=Hn(r)),t=e}return gt(r).then((n=>Nn[e](n,t)))},Dn=\"BeforeRun\",Cn=\"AfterRun\",Ln=[`code${Dn}`,`code${Dn}Async`,`code${Cn}`,`code${Cn}Async`],Bn=[\"onWorker\",\"onReady\",`on${Dn}`,`on${Dn}Async`,`on${Cn}`,`on${Cn}Async`];function qn(e,t){const{run:n,runAsync:r}=$n.get(this.type);return{...e,run:n.bind(this,t),runAsync:r.bind(this,t)}}const Un=(e,t,n,r,s,o)=>{if(s||o){const a=qn.bind(e,t),i=r?\"runAsync\":\"run\",c=e[i];e[i]=r?async function(e,t,...r){s&&await s.call(this,a(e),n);const i=await c.call(this,e,t,...r);return o&&await o.call(this,a(e),n),i}:function(e,t,...r){s&&s.call(this,a(e),n);const i=c.call(this,e,t,...r);return o&&o.call(this,a(e),n),i}}};let Jn,zn,Gn;const Yn=(e,t)=>{addEventListener(e,t||(async t=>{try{await Jn,zn(`xworker.on${e}`,t)}catch(e){postMessage(e)}}),!!t&&{once:!0})},{parse:Kn,stringify:Xn}=p,{proxy:Vn,sync:Zn,polyfill:Qn,window:er,isWindowProxy:tr}=await(async e=>{const t=await Ge(e),n=e?.transform||(e=>e),{[et]:r}=t.proxy,s=new Map,o=(e,t)=>{let n=s.get(e)?.deref();return n||s.set(e,new WeakRef(n=t(e))),n},a=([e,t])=>{switch(e){case Ye[g]:return null==t?globalThis:typeof t===y?o(t,p.object):t;case Ye[f]:return typeof t===y?o(t,p.array):t;case Ye[d]:return typeof t===y?o(t,p.function):te(parseInt(t));case Ye[w]:return(e=>{if(e.startsWith(\".\"))return Symbol.for(e.slice(1));for(const[t,n]of Ve)if(n===e)return t})(t);default:return t}},i=e=>{let[t,r]=m(e);switch(t){case g:if(r==globalThis||null==r)r=null;else if(typeof r===g&&!(r instanceof ue)){r=n(r);for(const e in r)r[e]=i(r[e])}return[Ye[g],r];case f:return[Ye[f],typeof r===y?r:n(r).map(i)];case d:return[Ye[d],typeof r===d?String(ne(n(r))):r];case w:return[Ye[w],Ze(e)];default:return[Ye[t],r]}},c=(...e)=>a(r(...e)),l={[E]:(e,t,n)=>c(E,e,i(t),i(n)),[v]:(e,t)=>c(v,e,i(t)),[T]:(e,t)=>c(T,e,i(t)),[k]:e=>c(k,e),[x]:(e,t)=>{const n=c(x,e,i(t));if(n){const{get:e,set:t,value:r}=n;e&&(n.get=a(e)),t&&(n.set=a(t)),r&&(n.value=a(r))}return n},[S]:(e,t)=>c(S,e,i(t)),[O]:e=>c(O,e),[A]:e=>c(A,e).map(a),[j]:e=>c(j,e),[R]:(e,t,n)=>c(R,e,i(t),i(n)),[P]:(e,t)=>c(P,e,i(t)),[Ke](e){s.delete(e),r(Ke,e)}},u={object:l,array:l,function:{...l,[_]:(e,...t)=>c(_,e,...t.map(i)),[b]:(e,...t)=>c(b,e,...t.map(i))}},{proxy:p,isProxy:h,pair:m}=V(u),$=p.object(null);return t.proxy[tt]=(e,t,...n)=>{const r=parseInt(t);switch(e){case _:{const[e,t]=n;return i(nt(te(r),a(e),t.map(a)))}case Ke:(e=>{const[t,n]=typeof e===y?[ee,Q]:[Q,ee],r=t.has(e);r&&(n.delete(t.get(e)),t.delete(e))})(r)}},{...t,window:$,isWindowProxy:h}})({parse:Kn,stringify:Xn,transform:e=>Gn?Gn(e):e}),nr={polyfill:Qn,sync:Vn,window:Zn?er:null,isWindowProxy:tr,onmessage:console.info,onerror:console.error,onmessageerror:console.warn,postMessage:postMessage.bind(self)};Yn(\"message\",(({data:{options:e,config:t,configURL:n,code:r,hooks:s}})=>{Jn=(async()=>{try{const{id:o,tag:a,type:i,custom:c,version:l,config:u,async:p}=e,f=((e,t=\"\")=>`${e}@${t}`.replace(/@$/,\"\"))(i,l),d=await Wn(f,t,n,u),{js_modules:h}=In.get(f),y=h?.main,g=pt($n.get(i)),w=((e,t,n,r)=>({type:t,config:n,interpreter:r,io:st.get(r),run:(t,...n)=>e.run(r,t,...n),runAsync:(t,...n)=>e.runAsync(r,t,...n),runEvent:(...t)=>e.runEvent(r,...t)}))(g,c||i,u||{},d);let m=\"run\";if(p&&(m+=\"Async\"),s){let e,t,n=\"\",r=\"\";for(const e of Ln){const t=s[e];if(t){const s=e.endsWith(\"Async\");(s&&p||!s&&!p)&&(e.startsWith(\"codeBefore\")?n=t:r=t)}}(n||r)&&((e,t,n,r)=>{const s=e[t].bind(e);e[t]=\"run\"===t?(e,t,...o)=>{n&&s(e,n,...o);const a=s(e,bt(t),...o);return r&&s(e,r,...o),a}:async(e,t,...o)=>{n&&await s(e,n,...o);const a=await s(e,bt(t),...o);return r&&await s(e,r,...o),a}})(g,m,n,r);for(const n of Bn.slice(2)){const r=s[n];if(r){const s=n.endsWith(\"Async\");if(s&&p||!s&&!p){const s=_t(r);n.startsWith(\"onBefore\")?e=s:t=s}}}Un(g,w,nr,p,e,t)}let _,b,E,v=null,T=\"\";Zn&&(({CustomEvent:_,document:b}=er),v=o&&b.getElementById(o)||null,E=e=>mt(v,c||i,e,!0,_));const x=Rt(er,Vn,y,t);if(((e,t,n,r)=>{if(\"pyodide\"===e)return;const s=\"polyscript.js_modules\";for(const e of Reflect.ownKeys(r))t.registerJSModule(n,`${s}.${e}`,xt(r,e));t.registerJSModule(n,s,r)})(i,g,d,x),g.registerJSModule(d,\"polyscript\",{xworker:nr,currentScript:v,config:w.config,js_modules:x,get target(){return!T&&v&&(\"SCRIPT\"===a?v.after(ut(b.createElement(`script-${c||i}`),{id:T=`${o}-target`})):(T=o,v.replaceChildren(),v.style.display=\"block\")),T}}),zn=g.runEvent.bind(g,d),Gn=g.transform.bind(g,d),v&&E(\"ready\"),s?.onReady&&_t(s?.onReady).call(g,qn.call(g,w,d),nr),await g[m](d,r),[\"micropython\",\"pyodide\"].includes(g.type)){const e=\"polyscript\",t=`__${e}_workers__`,n=\"__export__\";d.runPython([`import js as ${t}`,`${t}.${t} = \"${n}\" in locals() and ${n} or []`,`del ${t}`].join(\"\\n\"));const r=[...globalThis[t]];delete globalThis[t],r.length&&d.runPython([`from ${e} import xworker as ${t}`,...r.map((e=>`${t}.sync.${e} = ${e}`)),`del ${t}`].join(\"\\n\"))}return v&&E(\"done\"),postMessage(\"polyscript:done\"),d}catch(e){postMessage(e)}})(),Yn(\"error\"),Yn(\"message\"),Yn(\"messageerror\")}));\n".replace(re,place)],{type:'application/javascript'})), ...args)
/* c8 ignore stop */
{
"name": "polyscript",
"version": "0.14.3",
"version": "0.14.4",
"description": "PyScript single core to rule them all",

@@ -89,4 +89,4 @@ "main": "./esm/index.js",

"worker": {
"blob": "sha256-8aAxB/a1uoulnOjj6nNa2WkuNijTqucD8FzBxAW4XP4="
"blob": "sha256-TcNhn9gQ+KzsuVdb4meFvtbYIbGO2LqYd62IMVpt9UM="
}
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc