const e="function",t="64e10b34-2bf7-4616-9668-f99de5aa046e",{isArray:s}=Array;let{SharedArrayBuffer:n,window:a}=globalThis,{notify:o,wait:r,waitAsync:i}=Atomics,l=null;i||(i=e=>({value:new Promise((t=>{let s=new Worker("data:application/javascript,onmessage%3D(%7Bdata%3Ab%7D)%3D%3E(Atomics.wait(b%2C0)%2CpostMessage(0))");s.onmessage=t,s.postMessage(e)}))}));try{new n(4)}catch(e){n=ArrayBuffer;const r=new WeakMap;if(a){const e=new Map,{prototype:{postMessage:n}}=Worker,a=n=>{const a=n.data?.[t];if(!s(a)){n.stopImmediatePropagation();const{id:t,sb:s}=a;e.get(t)(s)}};l=function(e,...o){const i=e?.[t];if(s(i)){const[e,t]=i;r.set(t,e),this.addEventListener("message",a)}return n.call(this,e,...o)},i=t=>({value:new Promise((s=>{e.set(r.get(t),s)})).then((s=>{e.delete(r.get(t)),r.delete(t);for(let e=0;e<s.length;e++)t[e]=s[e];return"ok"}))})}else{const e=(e,s)=>({[t]:{id:e,sb:s}});o=t=>{postMessage(e(r.get(t),t))},addEventListener("message",(e=>{const n=e.data?.[t];if(s(n)){const[e,t]=n;r.set(t,e)}}))}}
/*! (c) Andrea Giammarchi - ISC */const{Int32Array:c,Map:f,Uint16Array:d}=globalThis,{BYTES_PER_ELEMENT:g}=c,{BYTES_PER_ELEMENT:p}=d,w=new WeakSet,u=new WeakMap,h={value:{then:e=>e()}};let y=0;const m=(a,{parse:m=JSON.parse,stringify:E=JSON.stringify,transform:b,interrupt:A}=JSON)=>{if(!u.has(a)){const M=l||a.postMessage,v=(e,...s)=>M.call(a,{[t]:s},{transfer:e}),T=typeof A===e?A:A?.handler,P=A?.delay||42,k=new TextDecoder("utf-16"),S=(e,t)=>e?i(t,0):(T?((e,t,s)=>{for(;"timed-out"===r(e,0,0,t);)s()})(t,P,T):r(t,0),h);let W=!1;u.set(a,new Proxy(new f,{has:(e,t)=>"string"==typeof t&&!t.startsWith("_"),get:(e,t)=>"then"===t?null:(...e)=>{const s=y++;let o=new c(new n(2*g)),r=[];w.has(e.at(-1)||r)&&w.delete(r=e.pop()),v(r,s,o,t,b?e.map(b):e);const i=a!==globalThis;let l=0;return W&&i&&(l=setTimeout(console.warn,1e3,`💀🔒 - Possible deadlock if proxy.${t}(...args) is awaited`)),S(i,o).value.then((()=>{clearTimeout(l);const e=o[1];if(!e)return;const t=p*e;return o=new c(new n(t+t%g)),v([],s,o),S(i,o).value.then((()=>m(k.decode(new d(o.buffer).slice(0,e)))))}))},set(n,r,i){const l=typeof i;if(l!==e)throw new Error(`Unable to assign ${r} as ${l}`);if(!n.size){const e=new f;a.addEventListener("message",(async a=>{const r=a.data?.[t];if(s(r)){a.stopImmediatePropagation();const[t,s,...i]=r;let l;if(i.length){const[a,o]=i;if(n.has(a)){W=!0;try{const r=await n.get(a)(...o);if(void 0!==r){const n=E(b?b(r):r);e.set(t,n),s[1]=n.length}}catch(e){l=e}finally{W=!1}}else l=new Error(`Unsupported action: ${a}`);s[0]=1}else{const n=e.get(t);e.delete(t);for(let e=new d(s.buffer),t=0;t<n.length;t++)e[t]=n.charCodeAt(t)}if(o(s,0),l)throw l}}))}return!!n.set(r,i)}}))}return u.get(a)};m.transfer=(...e)=>(w.add(e),e);export{m as default};
