  `,t=[],e=1e4;function r(){if(t.length>0){const l=t.pop();return l.terminationTimer&&(clearTimeout(l.terminationTimer),l.terminationTimer=null),l}console.debug("Allocating new waitAsync helper worker");const n=new Blob([c],{type:"application/javascript"}),s=URL.createObjectURL(n),a=new Worker(s);return URL.revokeObjectURL(s),a.onerror=l=>{console.error("Error in waitAsync helper worker:",l.message,l.filename,l.lineno)},a}function i(n){n.terminationTimer=setTimeout(()=>{const s=t.indexOf(n);s!==-1&&(n.terminate(),t.splice(s,1),console.debug("Terminated idle waitAsync helper worker"))},e),t.push(n)}function o(n,s,a,l){if(typeof n!="object"||!(n instanceof Int32Array)||!(n.buffer instanceof SharedArrayBuffer))throw new TypeError("Atomics.waitAsync requires a shared Int32Array.");const u=s|0,h=a|0,A=l===void 0?Number.POSITIVE_INFINITY:+l;if(u<0||u>=n.length)throw new RangeError("Index out of bounds.");return Atomics.load(n,u)!==h?{async:!1,value:"not-equal"}:{async:!0,value:new Promise((U,_)=>{const f=r();f.onmessage=d=>{switch(i(f),f.onmessage=null,d.data[0]){case"ok":U(d.data[1]);break;case"error":_(new Error(`Error in waitAsync helper: ${d.data[1]}`));break}},f.postMessage(["wait",n,u,h,A])})}}Object.defineProperty(Atomics,"waitAsync",{value:o,configurable:!0,enumerable:!1,writable:!0})}let y;const Bt=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&Bt.decode();let Z=null;function C(){return(Z===null||Z.byteLength===0)&&(Z=new Uint8Array(y.memory.buffer)),Z}function ut(c,t){return c=c>>>0,Bt.decode(C().subarray(c,c+t))}const N=new Array(128).fill(void 0);N.push(void 0,null,!0,!1);let J=N.length;function Mt(c){J===N.length&&N.push(N.length+1);const t=J;return J=N[t],N[t]=c,t}function zt(c){return N[c]}function fe(c){c<132||(N[c]=J,J=c)}function mt(c){const t=zt(c);return fe(c),t}let F=0;function wt(c,t){const e=t(c.length*1,1)>>>0;return C().set(c,e/1),F=c.length,e}let K=null;function j(){return(K===null||K.byteLength===0)&&(K=new Int32Array(y.memory.buffer)),K}function le(c,t){return c=c>>>0,C().subarray(c/1,c/1+t)}const it=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},_e=typeof it.encodeInto=="function"?function(c,t){return it.encodeInto(c,t)}:function(c,t){const e=it.encode(c);return t.set(e),{read:c.length,written:e.length}};function de(c,t,e){if(e===void 0){const s=it.encode(c),a=t(s.length,1)>>>0;return C().subarray(a,a+s.length).set(s),F=s.length,a}let r=c.length,i=t(r,1)>>>0;const o=C();let n=0;for(;n<r;n++){const s=c.charCodeAt(n);if(s>127)break;o[i+n]=s}if(n!==r){n!==0&&(c=c.slice(n)),i=e(i,r,r=n+c.length*3,1)>>>0;const s=C().subarray(i+n,i+r),a=_e(c,s);n+=a.written,i=e(i,r,n,1)>>>0}return F=n,i}const yt=Object.freeze({ResultSuccess:1,1:"ResultSuccess",NeedsMoreInput:2,2:"NeedsMoreInput",NeedsMoreOutput:3,3:"NeedsMoreOutput"}),he=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(c=>y.__wbg_brotlidecstream_free(c>>>0));class ue{__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,he.unregister(this),t}free(){const t=this.__destroy_into_raw();y.__wbg_brotlidecstream_free(t)}constructor(){const t=y.brotlidecstream_new();return this.__wbg_ptr=t>>>0,this}dec(t,e){try{const n=y.__wbindgen_add_to_stack_pointer(-16),s=wt(t,y.__wbindgen_malloc),a=F;y.brotlidecstream_dec(n,this.__wbg_ptr,s,a,e);var r=j()[n/4+0],i=j()[n/4+1],o=j()[n/4+2];if(o)throw mt(i);return ot.__wrap(r)}finally{y.__wbindgen_add_to_stack_pointer(16)}}decompress(t,e){try{const n=y.__wbindgen_add_to_stack_pointer(-16),s=wt(t,y.__wbindgen_malloc),a=F;y.brotlidecstream_dec(n,this.__wbg_ptr,s,a,e);var r=j()[n/4+0],i=j()[n/4+1],o=j()[n/4+2];if(o)throw mt(i);return ot.__wrap(r)}finally{y.__wbindgen_add_to_stack_pointer(16)}}total_out(){return y.brotlidecstream_total_out(this.__wbg_ptr)>>>0}}const Dt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(c=>y.__wbg_brotlistreamresult_free(c>>>0));class ot{static __wrap(t){t=t>>>0;const e=Object.create(ot.prototype);return e.__wbg_ptr=t,Dt.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,Dt.unregister(this),t}free(){const t=this.__destroy_into_raw();y.__wbg_brotlistreamresult_free(t)}get code(){return y.__wbg_get_brotlistreamresult_code(this.__wbg_ptr)}set code(t){y.__wbg_set_brotlistreamresult_code(this.__wbg_ptr,t)}get buf(){try{const i=y.__wbindgen_add_to_stack_pointer(-16);y.__wbg_get_brotlistreamresult_buf(i,this.__wbg_ptr);var t=j()[i/4+0],e=j()[i/4+1],r=le(t,e).slice();return y.__wbindgen_free(t,e*1,1),r}finally{y.__wbindgen_add_to_stack_pointer(16)}}set buf(t){const e=wt(t,y.__wbindgen_malloc),r=F;y.__wbg_set_brotlistreamresult_buf(this.__wbg_ptr,e,r)}get input_offset(){return y.__wbg_get_brotlistreamresult_input_offset(this.__wbg_ptr)>>>0}set input_offset(t){y.__wbg_set_brotlistreamresult_input_offset(this.__wbg_ptr,t)}}typeof FinalizationRegistry>"u"||new FinalizationRegistry(c=>y.__wbg_decompressstream_free(c>>>0));async function me(c,t){if(typeof Response=="function"&&c instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(c,t)}catch(r){if(c.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",r);else throw r}const e=await c.arrayBuffer();return await WebAssembly.instantiate(e,t)}else{const e=await WebAssembly.instantiate(c,t);return e instanceof WebAssembly.Instance?{instance:e,module:c}:e}}function we(){const c={};return c.wbg={},c.wbg.__wbindgen_error_new=function(t,e){const r=new Error(ut(t,e));return Mt(r)},c.wbg.__wbindgen_object_drop_ref=function(t){mt(t)},c.wbg.__wbg_new_abda76e883ba8a5f=function(){const t=new Error;return Mt(t)},c.wbg.__wbg_stack_658279fe44541cf6=function(t,e){const r=zt(e).stack,i=de(r,y.__wbindgen_malloc,y.__wbindgen_realloc),o=F;j()[t/4+1]=o,j()[t/4+0]=i},c.wbg.__wbg_error_f851667af71bcfc6=function(t,e){let r,i;try{r=t,i=e,console.error(ut(t,e))}finally{y.__wbindgen_free(r,i,1)}},c.wbg.__wbindgen_throw=function(t,e){throw new Error(ut(t,e))},c}function ye(c,t){return y=c.exports,Pt.__wbindgen_wasm_module=t,K=null,Z=null,y}async function Pt(c){if(y!==void 0)return y;typeof c>"u"&&(c=new URL(""+new URL("brotli_dec_wasm_bg-Dn-Szc7i.wasm",self.location.href).href,self.location.href));const t=we();(typeof c=="string"||typeof Request=="function"&&c instanceof Request||typeof URL=="function"&&c instanceof URL)&&(c=fetch(c));const{instance:e,module:r}=await me(await c,t);return ye(e,r)}var pe=""+new URL("brotli_dec_wasm_bg-Dn-Szc7i.wasm?wasm",self.location.href).href;const ge=Pt(pe),be=1024*1024,Ae=async()=>{await ge;const c=new ue;return new TransformStream({transform(e,r){let i,o=0;do{const n=e.slice(o),s=c.decompress(n,be);r.enqueue(s.buf),i=s.code,o+=s.input_offset}while(i===yt.NeedsMoreOutput);i!==yt.NeedsMoreInput&&i!==yt.ResultSuccess&&r.error(`Brotli decompression failed with code ${i}`)},flush(e){e.terminate()}})},ke=async c=>{const t=await fetch(c);if(!t.ok)throw new Error("Failed to fetch wasm");if(!t.body)throw new Error("No body in response");return t.body.pipeThrough(await Ae())};async function Ee(c,t){const e=c.getReader();let r=new Uint8Array(0),i=!1;const o=async()=>{const{done:n,value:s}=await e.read();if(s){const a=new Uint8Array(r.length+s.length);a.set(r),a.set(s,r.length),r=a}i=n};for(;;){for(;r.length<512&&!i;)await o();const n=$(r,0,100);if(n.length===0)break;const s=$(r,100,8),a=Number.parseInt($(r,108,8)),l=Number.parseInt($(r,116,8)),u=pt(r,124,12),h=pt(r,136,12),A=pt(r,156,1),U=A===0?"file":A===5?"directory":A,_=$(r,265,32),f=$(r,297,32);for(;r.length<512+u;)await o();const d=r.slice(512,512+u);t({name:n,type:U,size:u,data:d,get text(){return new TextDecoder().decode(this.data)},attrs:{mode:s,uid:a,gid:l,mtime:h,user:_,group:f}});let w=512+512*Math.trunc(u/512);for(u%512&&(w+=512);r.length<w&&!i;)await o();if(i&&r.length<w)break;r=r.slice(w)}}function $(c,t,e){const r=c.slice(t,t+e),i=r.indexOf(0);return new TextDecoder().decode(r.slice(0,i))}function pt(c,t,e){const r=c.slice(t,t+e);let i="";for(let o=0;o<e;o++)i+=String.fromCodePoint(r[o]);return Number.parseInt(i,8)}const Ft=async c=>{const t=await ke(`https://oligamiq.github.io/rust_wasm/v0.2.0/${c}.tar.br`),e=new Map;return console.group("Loading sysroot"),await Ee(t,r=>{if(!r.data)throw new Error("File data not found");if(r.name.includes("/")){const i=r.name.split("/"),o=e.get(i[0]);o instanceof R?o.contents.set(i.slice(1).join("/"),new st(r.data)):e.set(i[0],new R([[i.slice(1).join("/"),new st(r.data)]]))}else e.set(r.name,new st(r.data));console.log(r.name)}),console.groupEnd(),new R(e)},Ue=c=>{const t=new Map;for(const[e,r]of c)t.set(e,r);return t};let at;const ve=async()=>{const c=await Ft("wasm32-wasip1");at=new R([["wasm32-wasip1",new R([["lib",c]])]]);const t=new Qt("/sysroot",Ue([["lib",new R([["rustlib",at]])]]));return gt.add("wasm32-wasip1"),t},gt=new Set,Re=async c=>{if(gt.has(c))return;const t=await Ft(c);if(!at)throw new Error("Default sysroot not loaded");at.contents.set(c,new R([["lib",t]])),gt.add(c)},xe=async()=>{const c=[await ve()];return new ae(void 0,void 0,void 0,c,{allocator_size:1024*1024*1024})};function Ie(c){return new Worker(""+new URL("rustc-BE50aTE-.js",self.location.href).href,{name:c?.name})}function Te(c){return new Worker(""+new URL("util_cmd-T00NCR0H.js",self.location.href).href,{name:c?.name})}function Oe(c){return new Worker(""+new URL("llvm-y0xlpkPY.js",self.location.href).href,{name:c?.name})}ce();let Q,ct,H;const q=[];globalThis.addEventListener("message",async c=>{if(c.data.ctx){ct=new Ie,H=c.data.ctx,ct.postMessage({ctx:H}),Q=new At.SharedObjectRef(H.terminal_id).proxy(),await Q(`loading sysroot\r
  `,t=[],e=1e4;function r(){if(t.length>0){const l=t.pop();return l.terminationTimer&&(clearTimeout(l.terminationTimer),l.terminationTimer=null),l}console.debug("Allocating new waitAsync helper worker");const n=new Blob([c],{type:"application/javascript"}),s=URL.createObjectURL(n),a=new Worker(s);return URL.revokeObjectURL(s),a.onerror=l=>{console.error("Error in waitAsync helper worker:",l.message,l.filename,l.lineno)},a}function i(n){n.terminationTimer=setTimeout(()=>{const s=t.indexOf(n);s!==-1&&(n.terminate(),t.splice(s,1),console.debug("Terminated idle waitAsync helper worker"))},e),t.push(n)}function o(n,s,a,l){if(typeof n!="object"||!(n instanceof Int32Array)||!(n.buffer instanceof SharedArrayBuffer))throw new TypeError("Atomics.waitAsync requires a shared Int32Array.");const u=s|0,h=a|0,A=l===void 0?Number.POSITIVE_INFINITY:+l;if(u<0||u>=n.length)throw new RangeError("Index out of bounds.");return Atomics.load(n,u)!==h?{async:!1,value:"not-equal"}:{async:!0,value:new Promise((U,_)=>{const f=r();f.onmessage=d=>{switch(i(f),f.onmessage=null,d.data[0]){case"ok":U(d.data[1]);break;case"error":_(new Error(`Error in waitAsync helper: ${d.data[1]}`));break}},f.postMessage(["wait",n,u,h,A])})}}Object.defineProperty(Atomics,"waitAsync",{value:o,configurable:!0,enumerable:!1,writable:!0})}let y;const Bt=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&Bt.decode();let Z=null;function C(){return(Z===null||Z.byteLength===0)&&(Z=new Uint8Array(y.memory.buffer)),Z}function ut(c,t){return c=c>>>0,Bt.decode(C().subarray(c,c+t))}const N=new Array(128).fill(void 0);N.push(void 0,null,!0,!1);let J=N.length;function Mt(c){J===N.length&&N.push(N.length+1);const t=J;return J=N[t],N[t]=c,t}function zt(c){return N[c]}function fe(c){c<132||(N[c]=J,J=c)}function mt(c){const t=zt(c);return fe(c),t}let F=0;function wt(c,t){const e=t(c.length*1,1)>>>0;return C().set(c,e/1),F=c.length,e}let K=null;function j(){return(K===null||K.byteLength===0)&&(K=new Int32Array(y.memory.buffer)),K}function le(c,t){return c=c>>>0,C().subarray(c/1,c/1+t)}const it=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},_e=typeof it.encodeInto=="function"?function(c,t){return it.encodeInto(c,t)}:function(c,t){const e=it.encode(c);return t.set(e),{read:c.length,written:e.length}};function de(c,t,e){if(e===void 0){const s=it.encode(c),a=t(s.length,1)>>>0;return C().subarray(a,a+s.length).set(s),F=s.length,a}let r=c.length,i=t(r,1)>>>0;const o=C();let n=0;for(;n<r;n++){const s=c.charCodeAt(n);if(s>127)break;o[i+n]=s}if(n!==r){n!==0&&(c=c.slice(n)),i=e(i,r,r=n+c.length*3,1)>>>0;const s=C().subarray(i+n,i+r),a=_e(c,s);n+=a.written,i=e(i,r,n,1)>>>0}return F=n,i}const yt=Object.freeze({ResultSuccess:1,1:"ResultSuccess",NeedsMoreInput:2,2:"NeedsMoreInput",NeedsMoreOutput:3,3:"NeedsMoreOutput"}),he=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(c=>y.__wbg_brotlidecstream_free(c>>>0));class ue{__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,he.unregister(this),t}free(){const t=this.__destroy_into_raw();y.__wbg_brotlidecstream_free(t)}constructor(){const t=y.brotlidecstream_new();return this.__wbg_ptr=t>>>0,this}dec(t,e){try{const n=y.__wbindgen_add_to_stack_pointer(-16),s=wt(t,y.__wbindgen_malloc),a=F;y.brotlidecstream_dec(n,this.__wbg_ptr,s,a,e);var r=j()[n/4+0],i=j()[n/4+1],o=j()[n/4+2];if(o)throw mt(i);return ot.__wrap(r)}finally{y.__wbindgen_add_to_stack_pointer(16)}}decompress(t,e){try{const n=y.__wbindgen_add_to_stack_pointer(-16),s=wt(t,y.__wbindgen_malloc),a=F;y.brotlidecstream_dec(n,this.__wbg_ptr,s,a,e);var r=j()[n/4+0],i=j()[n/4+1],o=j()[n/4+2];if(o)throw mt(i);return ot.__wrap(r)}finally{y.__wbindgen_add_to_stack_pointer(16)}}total_out(){return y.brotlidecstream_total_out(this.__wbg_ptr)>>>0}}const Dt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(c=>y.__wbg_brotlistreamresult_free(c>>>0));class ot{static __wrap(t){t=t>>>0;const e=Object.create(ot.prototype);return e.__wbg_ptr=t,Dt.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,Dt.unregister(this),t}free(){const t=this.__destroy_into_raw();y.__wbg_brotlistreamresult_free(t)}get code(){return y.__wbg_get_brotlistreamresult_code(this.__wbg_ptr)}set code(t){y.__wbg_set_brotlistreamresult_code(this.__wbg_ptr,t)}get buf(){try{const i=y.__wbindgen_add_to_stack_pointer(-16);y.__wbg_get_brotlistreamresult_buf(i,this.__wbg_ptr);var t=j()[i/4+0],e=j()[i/4+1],r=le(t,e).slice();return y.__wbindgen_free(t,e*1,1),r}finally{y.__wbindgen_add_to_stack_pointer(16)}}set buf(t){const e=wt(t,y.__wbindgen_malloc),r=F;y.__wbg_set_brotlistreamresult_buf(this.__wbg_ptr,e,r)}get input_offset(){return y.__wbg_get_brotlistreamresult_input_offset(this.__wbg_ptr)>>>0}set input_offset(t){y.__wbg_set_brotlistreamresult_input_offset(this.__wbg_ptr,t)}}typeof FinalizationRegistry>"u"||new FinalizationRegistry(c=>y.__wbg_decompressstream_free(c>>>0));async function me(c,t){if(typeof Response=="function"&&c instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(c,t)}catch(r){if(c.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",r);else throw r}const e=await c.arrayBuffer();return await WebAssembly.instantiate(e,t)}else{const e=await WebAssembly.instantiate(c,t);return e instanceof WebAssembly.Instance?{instance:e,module:c}:e}}function we(){const c={};return c.wbg={},c.wbg.__wbindgen_error_new=function(t,e){const r=new Error(ut(t,e));return Mt(r)},c.wbg.__wbindgen_object_drop_ref=function(t){mt(t)},c.wbg.__wbg_new_abda76e883ba8a5f=function(){const t=new Error;return Mt(t)},c.wbg.__wbg_stack_658279fe44541cf6=function(t,e){const r=zt(e).stack,i=de(r,y.__wbindgen_malloc,y.__wbindgen_realloc),o=F;j()[t/4+1]=o,j()[t/4+0]=i},c.wbg.__wbg_error_f851667af71bcfc6=function(t,e){let r,i;try{r=t,i=e,console.error(ut(t,e))}finally{y.__wbindgen_free(r,i,1)}},c.wbg.__wbindgen_throw=function(t,e){throw new Error(ut(t,e))},c}function ye(c,t){return y=c.exports,Pt.__wbindgen_wasm_module=t,K=null,Z=null,y}async function Pt(c){if(y!==void 0)return y;typeof c>"u"&&(c=new URL(""+new URL("brotli_dec_wasm_bg-Dn-Szc7i.wasm",self.location.href).href,self.location.href));const t=we();(typeof c=="string"||typeof Request=="function"&&c instanceof Request||typeof URL=="function"&&c instanceof URL)&&(c=fetch(c));const{instance:e,module:r}=await me(await c,t);return ye(e,r)}var pe=""+new URL("brotli_dec_wasm_bg-Dn-Szc7i.wasm?wasm",self.location.href).href;const ge=Pt(pe),be=1024*1024,Ae=async()=>{await ge;const c=new ue;return new TransformStream({transform(e,r){let i,o=0;do{const n=e.slice(o),s=c.decompress(n,be);r.enqueue(s.buf),i=s.code,o+=s.input_offset}while(i===yt.NeedsMoreOutput);i!==yt.NeedsMoreInput&&i!==yt.ResultSuccess&&r.error(`Brotli decompression failed with code ${i}`)},flush(e){e.terminate()}})},ke=async c=>{const t=await fetch(c);if(!t.ok)throw new Error("Failed to fetch wasm");if(!t.body)throw new Error("No body in response");return t.body.pipeThrough(await Ae())};async function Ee(c,t){const e=c.getReader();let r=new Uint8Array(0),i=!1;const o=async()=>{const{done:n,value:s}=await e.read();if(s){const a=new Uint8Array(r.length+s.length);a.set(r),a.set(s,r.length),r=a}i=n};for(;;){for(;r.length<512&&!i;)await o();const n=$(r,0,100);if(n.length===0)break;const s=$(r,100,8),a=Number.parseInt($(r,108,8)),l=Number.parseInt($(r,116,8)),u=pt(r,124,12),h=pt(r,136,12),A=pt(r,156,1),U=A===0?"file":A===5?"directory":A,_=$(r,265,32),f=$(r,297,32);for(;r.length<512+u;)await o();const d=r.slice(512,512+u);t({name:n,type:U,size:u,data:d,get text(){return new TextDecoder().decode(this.data)},attrs:{mode:s,uid:a,gid:l,mtime:h,user:_,group:f}});let w=512+512*Math.trunc(u/512);for(u%512&&(w+=512);r.length<w&&!i;)await o();if(i&&r.length<w)break;r=r.slice(w)}}function $(c,t,e){const r=c.slice(t,t+e),i=r.indexOf(0);return new TextDecoder().decode(r.slice(0,i))}function pt(c,t,e){const r=c.slice(t,t+e);let i="";for(let o=0;o<e;o++)i+=String.fromCodePoint(r[o]);return Number.parseInt(i,8)}const Ft=async c=>{const t=await ke(`https://oligamiq.github.io/rust_wasm/v0.2.0/${c}.tar.br`),e=new Map;return console.group("Loading sysroot"),await Ee(t,r=>{if(!r.data)throw new Error("File data not found");if(r.name.includes("/")){const i=r.name.split("/"),o=e.get(i[0]);o instanceof R?o.contents.set(i.slice(1).join("/"),new st(r.data)):e.set(i[0],new R([[i.slice(1).join("/"),new st(r.data)]]))}else e.set(r.name,new st(r.data));console.log(r.name)}),console.groupEnd(),new R(e)},Ue=c=>{const t=new Map;for(const[e,r]of c)t.set(e,r);return t};let at;const ve=async()=>{const c=await Ft("wasm32-wasip1");at=new R([["wasm32-wasip1",new R([["lib",c]])]]);const t=new Qt("/sysroot",Ue([["lib",new R([["rustlib",at]])]]));return gt.add("wasm32-wasip1"),t},gt=new Set,Re=async c=>{if(gt.has(c))return;const t=await Ft(c);if(!at)throw new Error("Default sysroot not loaded");at.contents.set(c,new R([["lib",t]])),gt.add(c)},xe=async()=>{const c=[await ve()];return new ae(void 0,void 0,void 0,c,{allocator_size:1024*1024*1024})};function Ie(c){return new Worker(""+new URL("rustc-BE50aTE-.js",self.location.href).href,{name:c?.name})}function Te(c){return new Worker(""+new URL("util_cmd-T00NCR0H.js",self.location.href).href,{name:c?.name})}function Oe(c){return new Worker(""+new URL("llvm-y0xlpkPY.js",self.location.href).href,{name:c?.name})}ce();let Q,ct,H;const q=[];globalThis.addEventListener("message",async c=>{if(c.data.ctx){ct=new Ie,H=c.data.ctx,ct.postMessage({ctx:H}),Q=new At.SharedObjectRef(H.terminal_id).proxy(),await Q(`loading sysroot\r
brotli_dec_wasm_bg-Dn-Szc7i.wasm
brotli_dec_wasm_bg-Dn-Szc7i.wasm?wasm
`),await Re(r),Q(`loaded sysroot ${r}\r
`);const e=t.get_ref();ct.postMessage({wasi_ref:e}),new At.SharedObject(r=>{(async()=>(Q(`loading sysroot ${r}\r
`);const t=await xe();await Q(`loaded sysroot\r
`)))()},H.load_additional_sysroot_id),q.push(e),q.length===2&&Wt(q,H)}else if(c.data.wasi_ref){const{wasi_ref:t}=c.data;ct.postMessage({wasi_ref_ui:t}),q.push(t),q.length===2&&Wt(q,H)}});const Wt=(c,t)=>{const e=new Te,r=new Oe;e.postMessage({wasi_refs:c,ctx:t}),r.postMessage({wasi_refs:c,ctx:t})}})();
  `,t=[],e=1e4;function r(){if(t.length>0){const l=t.pop();return l.terminationTimer&&(clearTimeout(l.terminationTimer),l.terminationTimer=null),l}console.debug("Allocating new waitAsync helper worker");const n=new Blob([c],{type:"application/javascript"}),s=URL.createObjectURL(n),a=new Worker(s);return URL.revokeObjectURL(s),a.onerror=l=>{console.error("Error in waitAsync helper worker:",l.message,l.filename,l.lineno)},a}function i(n){n.terminationTimer=setTimeout(()=>{const s=t.indexOf(n);s!==-1&&(n.terminate(),t.splice(s,1),console.debug("Terminated idle waitAsync helper worker"))},e),t.push(n)}function o(n,s,a,l){if(typeof n!="object"||!(n instanceof Int32Array)||!(n.buffer instanceof SharedArrayBuffer))throw new TypeError("Atomics.waitAsync requires a shared Int32Array.");const u=s|0,h=a|0,A=l===void 0?Number.POSITIVE_INFINITY:+l;if(u<0||u>=n.length)throw new RangeError("Index out of bounds.");return Atomics.load(n,u)!==h?{async:!1,value:"not-equal"}:{async:!0,value:new Promise((U,_)=>{const f=r();f.onmessage=d=>{switch(i(f),f.onmessage=null,d.data[0]){case"ok":U(d.data[1]);break;case"error":_(new Error(`Error in waitAsync helper: ${d.data[1]}`));break}},f.postMessage(["wait",n,u,h,A])})}}Object.defineProperty(Atomics,"waitAsync",{value:o,configurable:!0,enumerable:!1,writable:!0})}let y;const Bt=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&Bt.decode();let Z=null;function C(){return(Z===null||Z.byteLength===0)&&(Z=new Uint8Array(y.memory.buffer)),Z}function ut(c,t){return c=c>>>0,Bt.decode(C().subarray(c,c+t))}const N=new Array(128).fill(void 0);N.push(void 0,null,!0,!1);let J=N.length;function Mt(c){J===N.length&&N.push(N.length+1);const t=J;return J=N[t],N[t]=c,t}function zt(c){return N[c]}function fe(c){c<132||(N[c]=J,J=c)}function mt(c){const t=zt(c);return fe(c),t}let F=0;function wt(c,t){const e=t(c.length*1,1)>>>0;return C().set(c,e/1),F=c.length,e}let K=null;function j(){return(K===null||K.byteLength===0)&&(K=new Int32Array(y.memory.buffer)),K}function le(c,t){return c=c>>>0,C().subarray(c/1,c/1+t)}const it=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},_e=typeof it.encodeInto=="function"?function(c,t){return it.encodeInto(c,t)}:function(c,t){const e=it.encode(c);return t.set(e),{read:c.length,written:e.length}};function de(c,t,e){if(e===void 0){const s=it.encode(c),a=t(s.length,1)>>>0;return C().subarray(a,a+s.length).set(s),F=s.length,a}let r=c.length,i=t(r,1)>>>0;const o=C();let n=0;for(;n<r;n++){const s=c.charCodeAt(n);if(s>127)break;o[i+n]=s}if(n!==r){n!==0&&(c=c.slice(n)),i=e(i,r,r=n+c.length*3,1)>>>0;const s=C().subarray(i+n,i+r),a=_e(c,s);n+=a.written,i=e(i,r,n,1)>>>0}return F=n,i}const yt=Object.freeze({ResultSuccess:1,1:"ResultSuccess",NeedsMoreInput:2,2:"NeedsMoreInput",NeedsMoreOutput:3,3:"NeedsMoreOutput"}),he=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(c=>y.__wbg_brotlidecstream_free(c>>>0));class ue{__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,he.unregister(this),t}free(){const t=this.__destroy_into_raw();y.__wbg_brotlidecstream_free(t)}constructor(){const t=y.brotlidecstream_new();return this.__wbg_ptr=t>>>0,this}dec(t,e){try{const n=y.__wbindgen_add_to_stack_pointer(-16),s=wt(t,y.__wbindgen_malloc),a=F;y.brotlidecstream_dec(n,this.__wbg_ptr,s,a,e);var r=j()[n/4+0],i=j()[n/4+1],o=j()[n/4+2];if(o)throw mt(i);return ot.__wrap(r)}finally{y.__wbindgen_add_to_stack_pointer(16)}}decompress(t,e){try{const n=y.__wbindgen_add_to_stack_pointer(-16),s=wt(t,y.__wbindgen_malloc),a=F;y.brotlidecstream_dec(n,this.__wbg_ptr,s,a,e);var r=j()[n/4+0],i=j()[n/4+1],o=j()[n/4+2];if(o)throw mt(i);return ot.__wrap(r)}finally{y.__wbindgen_add_to_stack_pointer(16)}}total_out(){return y.brotlidecstream_total_out(this.__wbg_ptr)>>>0}}const Dt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(c=>y.__wbg_brotlistreamresult_free(c>>>0));class ot{static __wrap(t){t=t>>>0;const e=Object.create(ot.prototype);return e.__wbg_ptr=t,Dt.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,Dt.unregister(this),t}free(){const t=this.__destroy_into_raw();y.__wbg_brotlistreamresult_free(t)}get code(){return y.__wbg_get_brotlistreamresult_code(this.__wbg_ptr)}set code(t){y.__wbg_set_brotlistreamresult_code(this.__wbg_ptr,t)}get buf(){try{const i=y.__wbindgen_add_to_stack_pointer(-16);y.__wbg_get_brotlistreamresult_buf(i,this.__wbg_ptr);var t=j()[i/4+0],e=j()[i/4+1],r=le(t,e).slice();return y.__wbindgen_free(t,e*1,1),r}finally{y.__wbindgen_add_to_stack_pointer(16)}}set buf(t){const e=wt(t,y.__wbindgen_malloc),r=F;y.__wbg_set_brotlistreamresult_buf(this.__wbg_ptr,e,r)}get input_offset(){return y.__wbg_get_brotlistreamresult_input_offset(this.__wbg_ptr)>>>0}set input_offset(t){y.__wbg_set_brotlistreamresult_input_offset(this.__wbg_ptr,t)}}typeof FinalizationRegistry>"u"||new FinalizationRegistry(c=>y.__wbg_decompressstream_free(c>>>0));async function me(c,t){if(typeof Response=="function"&&c instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(c,t)}catch(r){if(c.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",r);else throw r}const e=await c.arrayBuffer();return await WebAssembly.instantiate(e,t)}else{const e=await WebAssembly.instantiate(c,t);return e instanceof WebAssembly.Instance?{instance:e,module:c}:e}}function we(){const c={};return c.wbg={},c.wbg.__wbindgen_error_new=function(t,e){const r=new Error(ut(t,e));return Mt(r)},c.wbg.__wbindgen_object_drop_ref=function(t){mt(t)},c.wbg.__wbg_new_abda76e883ba8a5f=function(){const t=new Error;return Mt(t)},c.wbg.__wbg_stack_658279fe44541cf6=function(t,e){const r=zt(e).stack,i=de(r,y.__wbindgen_malloc,y.__wbindgen_realloc),o=F;j()[t/4+1]=o,j()[t/4+0]=i},c.wbg.__wbg_error_f851667af71bcfc6=function(t,e){let r,i;try{r=t,i=e,console.error(ut(t,e))}finally{y.__wbindgen_free(r,i,1)}},c.wbg.__wbindgen_throw=function(t,e){throw new Error(ut(t,e))},c}function ye(c,t){return y=c.exports,Pt.__wbindgen_wasm_module=t,K=null,Z=null,y}async function Pt(c){if(y!==void 0)return y;typeof c>"u"&&(c=new URL(""+new URL("brotli_dec_wasm_bg-Dn-Szc7i.wasm",self.location.href).href,self.location.href));const t=we();(typeof c=="string"||typeof Request=="function"&&c instanceof Request||typeof URL=="function"&&c instanceof URL)&&(c=fetch(c));const{instance:e,module:r}=await me(await c,t);return ye(e,r)}var pe=""+new URL("brotli_dec_wasm_bg-Dn-Szc7i.wasm?wasm",self.location.href).href;const ge=Pt(pe),be=1024*1024,Ae=async()=>{await ge;const c=new ue;return new TransformStream({transform(e,r){let i,o=0;do{const n=e.slice(o),s=c.decompress(n,be);r.enqueue(s.buf),i=s.code,o+=s.input_offset}while(i===yt.NeedsMoreOutput);i!==yt.NeedsMoreInput&&i!==yt.ResultSuccess&&r.error(`Brotli decompression failed with code ${i}`)},flush(e){e.terminate()}})},ke=async c=>{const t=await fetch(c);if(!t.ok)throw new Error("Failed to fetch wasm");if(!t.body)throw new Error("No body in response");return t.body.pipeThrough(await Ae())};async function Ee(c,t){const e=c.getReader();let r=new Uint8Array(0),i=!1;const o=async()=>{const{done:n,value:s}=await e.read();if(s){const a=new Uint8Array(r.length+s.length);a.set(r),a.set(s,r.length),r=a}i=n};for(;;){for(;r.length<512&&!i;)await o();const n=$(r,0,100);if(n.length===0)break;const s=$(r,100,8),a=Number.parseInt($(r,108,8)),l=Number.parseInt($(r,116,8)),u=pt(r,124,12),h=pt(r,136,12),A=pt(r,156,1),U=A===0?"file":A===5?"directory":A,_=$(r,265,32),f=$(r,297,32);for(;r.length<512+u;)await o();const d=r.slice(512,512+u);t({name:n,type:U,size:u,data:d,get text(){return new TextDecoder().decode(this.data)},attrs:{mode:s,uid:a,gid:l,mtime:h,user:_,group:f}});let w=512+512*Math.trunc(u/512);for(u%512&&(w+=512);r.length<w&&!i;)await o();if(i&&r.length<w)break;r=r.slice(w)}}function $(c,t,e){const r=c.slice(t,t+e),i=r.indexOf(0);return new TextDecoder().decode(r.slice(0,i))}function pt(c,t,e){const r=c.slice(t,t+e);let i="";for(let o=0;o<e;o++)i+=String.fromCodePoint(r[o]);return Number.parseInt(i,8)}const Ft=async c=>{const t=await ke(`https://oligamiq.github.io/rust_wasm/v0.2.0/${c}.tar.br`),e=new Map;return console.group("Loading sysroot"),await Ee(t,r=>{if(!r.data)throw new Error("File data not found");if(r.name.includes("/")){const i=r.name.split("/"),o=e.get(i[0]);o instanceof R?o.contents.set(i.slice(1).join("/"),new st(r.data)):e.set(i[0],new R([[i.slice(1).join("/"),new st(r.data)]]))}else e.set(r.name,new st(r.data));console.log(r.name)}),console.groupEnd(),new R(e)},Ue=c=>{const t=new Map;for(const[e,r]of c)t.set(e,r);return t};let at;const ve=async()=>{const c=await Ft("wasm32-wasip1");at=new R([["wasm32-wasip1",new R([["lib",c]])]]);const t=new Qt("/sysroot",Ue([["lib",new R([["rustlib",at]])]]));return gt.add("wasm32-wasip1"),t},gt=new Set,Re=async c=>{if(gt.has(c))return;const t=await Ft(c);if(!at)throw new Error("Default sysroot not loaded");at.contents.set(c,new R([["lib",t]])),gt.add(c)},xe=async()=>{const c=[await ve()];return new ae(void 0,void 0,void 0,c,{allocator_size:1024*1024*1024})};function Ie(c){return new Worker(""+new URL("rustc-BE50aTE-.js",self.location.href).href,{name:c?.name})}function Te(c){return new Worker(""+new URL("util_cmd-T00NCR0H.js",self.location.href).href,{name:c?.name})}function Oe(c){return new Worker(""+new URL("llvm-y0xlpkPY.js",self.location.href).href,{name:c?.name})}ce();let Q,ct,H;const q=[];globalThis.addEventListener("message",async c=>{if(c.data.ctx){ct=new Ie,H=c.data.ctx,ct.postMessage({ctx:H}),Q=new At.SharedObjectRef(H.terminal_id).proxy(),await Q(`loading sysroot\r


非常有价值！从 worker 文件中我找到了关键信息：

1. **sysroot 下载地址**：`https://oligamiq.github.io/rust_wasm/v0.2.0/{target}.tar.br`
   - 例如：`https://oligamiq.github.io/rust_wasm/v0.2.0/wasm32-wasip1.tar.br`
   - 格式是 brotli 压缩的 tar 文件

2. **WASM 文件**：
   - `brotli_dec_wasm_bg-Dn-Szc7i.wasm` - brotli 解码器 WASM

3. **其他 Worker 文件**：
   - `rustc-BE50aTE-.js` - rustc worker
   - `util_cmd-T00NCR0H.js` - 工具命令 worker
   - `llvm-y0xlpkPY.js` - llvm worker

4. **Monaco 编辑器 worker**：
   - `editor.worker-D97G_pyA.js`
   - `json.worker-CfN83P36.js`
   - `css.worker-CZFUz3tL.js`
   - `html.worker-DiL2AjlA.js`
   - `ts.worker-ClNqREBk.js`

5. **项目依赖 npm 包**：
   - `@oligami/browser_wasi_shim-threads`
   - `@oligami/shared-object`

这个项目太大了，完整的 rubrc 需要：
- 前端 JS/CSS
- 多个 Web Worker
- brotli 解码器 WASM
- rust_wasm sysroot tar.br 文件（每个目标一个）
- 多个 npm 包

sysroot 文件可能很大（几十到几百MB）。而且这个项目需要 COOP/COEP 头部（Cross-Origin-Opener-Policy 和 Cross-Origin-Embedder-Policy），还需要 SharedArrayBuffer。

让我考虑一个更简单的方案。实际上，对于 Rust 编译器，有一个更简单的选择：

1. **使用 Rust Playground 的 API** - 不是离线的
2. **使用 rustpython** - 这是 Python 解释器，不是 Rust 编译器
3. **使用更小的 Rust 编译器**

让我尝试另一种方式：自己编写一个简化版的 Rust 解释器。

不，用户要求的是"编译器"，不是解释器。让我再搜索一下。

实际上，有一个叫 `rustc` 的 WASM 编译器可以通过 `rustup` 工具链获取。让我看看有没有更简单的方式。

或者，我可以尝试使用 `mrustc` 或者 `rust-script` 的 WASM 版本。

但最简单的方式可能是：下载 rubrc 项目的资源，看看是否可行。

让我先下载 sysroot 文件看看大小。

bash

export http_proxy=http://192.168.1.1:17892
export https_proxy=http://192.168.1.1:17892

# 下载 rubrc 的 wasm32-wasip1 sysroot 看看大小
# 查看是否存在这个文件
wget -q --spider "https://oligamiq.github.io/rust_wasm/v0.2.0/wasm32-wasip1.tar.br" && echo "EXISTS" || echo "NOT FOUND"

# 下载看看大小
wget -q "https://oligamiq.github.io/rust_wasm/v0.2.0/wasm32-wasip1.tar.br"
ls -lh wasm32-wasip1.tar.br 2>/dev/null

# 下载其他资源看看大小
wget -q --spider "https://oligamiq.github.io/rust_wasm/v0.2.0/x86_64-unknown-linux-gnu.tar.br" && echo "x86_64 EXISTS" || echo "x86_64 NOT FOUND"

# 下载 brotli wasm
curl -sI "https://oligamiq.github.io/rubrc/assets/brotli_dec_wasm_bg-Dn-Szc7i.wasm" | grep -E "Content-Length|HTTP|Content-Type"

# 下载其他 worker 文件看看大小
wget -q "https://oligamiq.github.io/rubrc/assets/rustc-BE50aTE-.js"
wget -q "https://oligamiq.github.io/rubrc/assets/util_cmd-T00NCR0H.js"
wget -q "https://oligamiq.github.io/rubrc/assets/llvm-y0xlpkPY.js"
ls -lh rustc-BE50aTE-.js util_cmd-T00NCR0H.js llvm-y0xlpkPY.js 2>/dev/null

# 下载 brotli wasm
wget -q "https://oligamiq.github.io/rubrc/assets/brotli_dec_wasm_bg-Dn-Szc7i.wasm"
ls -lh brotli_dec_wasm_bg-Dn-Szc7i.wasm 2>/dev/null


EXISTS
-rw-r--r-- 1 root root 19M  6月 5日 23:28 wasm32-wasip1.tar.br
x86_64 EXISTS
HTTP/1.1 200 Connection established
HTTP/2 200
-rw-r--r-- 1 root root 64K 12月25日 00:18 llvm-y0xlpkPY.js
-rw-r--r-- 1 root root 64K 12月25日 00:18 rustc-BE50aTE-.js
-rw-r--r-- 1 root root 59K 12月25日 00:18 util_cmd-T00NCR0H.js
-rw-r--r-- 1 root root 202K 12月25日 00:18 brotli_dec_wasm_bg-Dn-Szc7i.wasm


sysroot 文件 19MB！这只是 wasm32-wasip1 一个目标的 sysroot。完整的 rubrc 项目需要多个 sysroot 文件。

整个项目大小可能超过 100MB。这对于离线使用来说太大了。

让我重新思考。用户要求一个 Rust 的离线编译器。我需要找一个更轻量的方案。

实际上，让我尝试另一个方式：有没有更简单的 Rust 解释器或编译器？

一个选择是：使用 `rustpython`（用 Rust 写的 Python 解释器）—— 不，这不是 Rust 编译器。

另一个选择：用 `mrustc` 编译为 WASM。mrustc 是 C++ 写的，可以用 Emscripten 编译为 WASM。

或者，我可以尝试用 `rustc` 的 WASM 目标。实际上，rustc 本身可以通过 wasm32-unknown-unknown 编译为 WASM。

让我搜索一下有没有更简单的 Rust 编译器 WASM 项目。

另外一个思路：使用 `rust-script` 或者 `cargo` 的简化版。

让我再搜索一下。

export http_proxy=http://192.168.1.1:17892
export https_proxy=http://192.168.1.1:17892

# 搜索其他 Rust WASM 编译器项目
# 1. 搜索 "rust compiler wasm" github
# 2. 搜索 "rustc wasm32"
# 3. 搜索 "rust interpreter wasm"

# 搜索 rust interpreter 的 WASM 版本
# 看看有没有 rust-interpreter 之类的项目

curl -s "https://api.github.com/search/repositories?q=rust+interpreter+wasm&per_page=5" | python3 -c "
import sys, json
data = json.load(sys.stdin)
for item in data.get('items', []):
    print(f'{item['full_name']}: {item['description'][:80] if item['description'] else 'N/A'}')
    print(f'  Stars: {item['stargazers_count']}, URL: {item['html_url']}')
    print()
"

echo "---"

# 搜索 rust compiler in browser
# 尝试搜索 rust-playground 的 wasm 版本
curl -s "https://api.github.com/search/repositories?q=rust+playground+wasm&per_page=5" | python3 -c "
import sys, json
data = json.load(sys.stdin)
for item in data.get('items', []):
    print(f'{item['full_name']}: {item['description'][:80] if item['description'] else 'N/A'}')
    print(f'  Stars: {item['stargazers_count']}, URL: {item['html_url']}')
    print()
"


RustPython/RustPython: A Python Interpreter written in Rust
  Stars: 22107, URL: https://github.com/RustPython/RustPython

wasmi-labs/wasmi: Efficient and versatile WebAssembly interpreter for embedded systems.
  Stars: 2131, URL: https://github.com/wasmi-labs/wasmi

wasm3/wasm3-rs: Rust wrapper for Wasm3, the fastest WebAssembly interpreter
  Stars: 175, URL: https://github.com/wasm3/wasm3-rs

boa-dev/boa: Boa is an embeddable Javascript engine written in Rust.
  Stars: 7300, URL: https://github.com/boa-dev/boa

yblein/rust-wasm: A simple and spec-compliant WebAssembly interpreter
  Stars: 95, URL: https://github.com/yblein/rust-wasm

---
solana-playground/solana-playground: Quickly develop, deploy and test Solana programs from browsers
  Stars: 938, URL: https://github.com/solana-playground/solana-playground

artichoke/playground: 🎡 Artichoke Ruby Wasm Playground
  Stars: 45, URL: https://github.com/artichoke/playground

use-ink/ink-playground: Browser Based Playground for editing, sharing & compiling ink! Smart Contracts
  Stars: 26, URL: https://github.com/use-ink/ink-playground

alexichepura/bevy_garage: Gamelike car simulation playground.
  Stars: 171, URL: https://github.com/alexichepura/bevy_garage

jlkiri/typerust: Online Rust playground
  Stars: 32, URL: https://github.com/jlkiri/typerust


让我搜索一下 `typerust`，看起来是一个在线 Rust playground。还有 `rustpython` 可以编译到 WASM。

不过，用户要求的是 Rust **编译器**，不是 Rust 写的解释器。

让我再想想。用户想要的是：
1. 在浏览器中编写 Rust 代码
2. 编译并运行
3. 离线可用

现有的 rubrc 项目确实太大了（19MB+ sysroot，加上其他资源可能超过 100MB）。

让我尝试另一种方式：使用 `rustpython` 的 WASM 版本来运行 Python 代码——但这不对，用户要的是 Rust 编译器。

让我尝试用 `mrustc` 的 WASM 版本。或者尝试下载 `rubrc` 项目，但只下载一个目标（wasm32-wasip1）的 sysroot，这样可以减小体积。

实际上，rubrc 项目的 sysroot 是 19MB（brotli 压缩后的 tar 文件）。解压后可能会更大。

让我计算一下：
- wasm32-wasip1.tar.br: 19MB
- brotli_dec_wasm_bg: 202KB
- 前端 JS: ~4MB
- 其他 worker: ~200KB
- brotli WASM 解压后的 sysroot 可能更大

总共可能超过 50MB。这个体积太大了。

让我尝试另一个方案：使用 `rust-script` 的简化版，或者使用 `cargo` 的 web 版本。

或者，我可以尝试用 `rustc` 的 `wasm32-unknown-unknown` 目标编译一个简化版的 Rust 编译器。

实际上，让我重新思考。对于 Rust 来说，有一个更简单的方式：使用 `rust-analyzer` 的 WASM 版本？不，这是 IDE 工具。

让我尝试另一个方式：使用 `rui` 或者 `rust-script` 的 web 版本。

或者，我可以尝试用 `deno` 的 WASM 版本？不，这不是 Rust。

让我搜索一下有没有 `rust` 的 `wasm` 编译器，特别是小型的。

有一个叫 `rust-script` 的工具可以编译 Rust 脚本。让我看看能不能找到它的 WASM 版本。

另外，让我看看 `typerust` 项目。

export http_proxy=http://192.168.1.1:17892
export https_proxy=http://192.168.1.1:17892

# 查看 typerust 项目
curl -s "https://api.github.com/repos/jlkiri/typerust" | python3 -c "
import sys, json
data = json.load(sys.stdin)
print(f'Name: {data['full_name']}')
print(f'Description: {data['description']}')
print(f'Stars: {data['stargazers_count']}')
print(f'URL: {data['html_url']}')
print(f'Homepage: {data['homepage']}')
"

# 查看 rustpython 的 WASM 版本
# RustPython 可以编译到 WASM，运行 Python 代码
# 但这不是 Rust 编译器

# 搜索有没有 rust 编译器 wasm 版本
# 搜索 "rustc wasm target"

curl -s "https://api.github.com/search/repositories?q=rustc+wasm+compiler&per_page=5" | python3 -c "
import sys, json
data = json.load(sys.stdin)
for item in data.get('items', []):
    print(f'{item['full_name']}: {item['description'][:80] if item['description'] else 'N/A'}')
    print(f'  Stars: {item['stargazers_count']}, URL: {item['html_url']}')
    print()
"

echo "---"

# 搜索 rust 编译器的 wasm 版本
# 看看 rust-lang 官方有没有 wasm 编译器
curl -s "https://api.github.com/search/repositories?q=rust+compiler+webassembly+frontend&per_page=5" | python3 -c "
import sys, json
data = json.load(sys.stdin)
for item in data.get('items', []):
    print(f'{item['full_name']}: {item['description'][:80] if item['description'] else 'N/A'}')
    print(f'  Stars: {item['stargazers_count']}, URL: {item['html_url']}')
    print()
"


Traceback (most recent call last):
  File "<string>", line 4, in <module>
    print(f'Name: {data['full_name']}')
                   ~~~~^^^^^^^^^^^^^
KeyError: 'full_name'
oligamiq/rubrc: Rust compiler that runs in the browser!
  Stars: 56, URL: https://github.com/oligamiq/rubrc

dxiv/dxa-wasm: DEXA compiler compiled to WebAssembly for in-browser use: dxa.dev playground, AS
  Stars: 2, URL: https://github.com/dxiv/dxa-wasm

patriksvensson/rustcalc: A simple experiment showing a Rust library compiled to WASM and used in a simple
  Stars: 2, URL: https://github.com/patriksvensson/rustcalc

aaronmunsters/rustc-to-wasm-compiler: Rust crate to compile simple Rust to Wasm using rustc
  Stars: 0, URL: https://github.com/aaronmunsters/rustc-to-wasm-compiler

macovedj/rusty: tinkering with compiling http without cargo and with a rustc.wasm
  Stars: 0, URL: https://github.com/macovedj/rusty

---
Drive4Code/robot_frontend: Uses WebAssembly to compile rust to the web
  Stars: 0, URL: https://github.com/Drive4Code/robot_frontend

sguzman/yew-rust-example: An simple example using a the emsdk compiler plus the yew+rust+webassembly frame
  Stars: 0, URL: https://github.com/sguzman/yew-rust-example

0xRustPro/solana-rust-frontend: Rust can compile to WebAssembly (WASM), letting you write frontend code in Rust
  Stars: 0, URL: https://github.com/0xRustPro/solana-rust-frontend

LuigimonSoft/leptos-basic-template: A basic template for building a frontend application using Leptos with Rust, com
  Stars: 0, URL: https://github.com/LuigimonSoft/leptos-basic-template

indrajithc/hello-webassembly: This repository contains a sample Rust project compiled into WebAssembly using w
  Stars: 1, URL: https://github.com/indrajithc/hello-webassembly


搜索结果没有更合适的 Rust WASM 编译器。rubrc 是目前唯一找到的在浏览器中运行的 Rust 编译器。

让我重新评估一下 rubrc 方案：

1. **sysroot 文件**: `wasm32-wasip1.tar.br` = 19MB
2. **brotli 解码器**: 202KB
3. **前端**: ~4MB
4. **其他 worker**: ~200KB

解压后的 sysroot 可能更大。让我看看解压后的大小。

实际上，我可以尝试只下载一个 sysroot（wasm32-wasip1），然后尝试配置 rubrc 项目。

但首先，让我看看 rubrc 项目是否真的能工作。让我尝试下载整个项目并运行。

不过，考虑到：
1. 项目需要 COOP/COEP 头部（Cross-Origin-Opener-Policy 和 Cross-Origin-Embedder-Policy）
2. 需要 SharedArrayBuffer
3. 需要多个 npm 包（@oligami/browser_wasi_shim-threads, @oligami/shared-object）
4. sysroot 文件很大

让我尝试一个更轻量的方案：使用 `rustpython` 的 WASM 版本来运行 Python 代码。但这不对，用户要的是 Rust 编译器。

或者，让我尝试用 `rustc` 的 `wasm32-unknown-unknown` 目标编译 rustc 本身。但这需要大量工作。

让我尝试下载 rubrc 的关键资源，然后看看是否能配置为一个可用的离线版本。

实际上，让我先看看 rubrc 的 npm 包。`@oligami/browser_wasi_shim-threads` 和 `@oligami/shared-object` 是 npm 包，可以从 npm 下载。

让我尝试另一种方式：用 `npm` 下载 rubrc 项目，然后看看它需要什么。

或者，我可以尝试直接下载整个 rubrc 项目并运行。

让我先尝试下载 rubrc 的完整资源，然后测试是否能工作。

实际上，考虑到 rubrc 的复杂性，让我重新思考一个更简单的方案。

有一个叫 `rust-script` 的工具，可以编译 Rust 脚本。但我不确定是否有 WASM 版本。

另一个方案：使用 `cargo` 的 web 版本。但我不知道是否有现成的项目。

让我尝试一个更直接的方式：使用 `rustc` 的 `wasm32-wasi` 目标，通过 wasmer-js 或类似工具来运行。

实际上，用户说"支持编译常用 rust 代码"。这意味着：
- 变量声明
- 函数
- 控制流
- 打印输出

我不需要完整的 Rust 标准库。

让我尝试一个完全不同的方案：使用 Rust 到 JavaScript 的转换器。

或者，我可以使用 `rustpython` 的 WASM 版本——但这运行的是 Python 代码，不是 Rust 代码。

让我重新思考...

实际上，有一个更简单的方式：使用 `rustc` 的 `wasm32-unknown-unknown` 目标编译一个 Rust 代码的 WASM 运行时，然后让用户编写 Rust 代码，编译后执行。

但这需要一个 Rust 编译器来编译 Rust 代码。

让我回到 rubrc 方案。虽然它很大，但它是唯一找到的在浏览器中运行的完整 Rust 编译器。

让我尝试配置 rubrc 项目，只下载一个 sysroot（wasm32-wasip1），然后看看是否能工作。

首先，我需要下载：
1. 前端资源
2. npm 包
3. sysroot 文件

让我先尝试下载 npm 包。

export http_proxy=http://192.168.1.1:17892
export https_proxy=http://192.168.1.1:17892

# 查看 rubrc 的 npm 包依赖
# 查看 package.json
curl -s "https://raw.githubusercontent.com/oligamiq/rubrc/main/package.json" | head -40

echo "---"

# 下载 npm 包看看大小
mkdir -p /tmp/rubrc-npm
cd /tmp/rubrc-npm

# 下载 @oligami/browser_wasi_shim-threads
npm pack @oligami/browser_wasi_shim-threads 2>&1 | tail -5
npm pack @oligami/shared-object 2>&1 | tail -5

# 查看包大小
ls -lh *.tgz 2>/dev/null


{
  "name": "rubrc",
  "version": "1.2.0",
  "description": "rubrc root",
  "private": true,
  "directories": {
    "lib": "lib",
    "page": "page"
  },
  "author": "oligami <nziq53@gmail.com> (https://github.com/oligamiq)",
  "license": "MIT OR Apache-2.0",
  "type": "module",
  "scripts": {
    "build": "bun run --cwd lib build && bun run --cwd page build"
  },
  "devDependencies": {
    "@biomejs/biome": "2.3.5",
    "@swc/cli": "^0.7.9",
    "@swc/core": "^1.15.7",
    "@types/tar-stream": "^3.1.4",
    "autoprefixer": "^10.4.23",
    "better-typescript-lib": "^2.12.0",
    "npm-watch": "^0.13.0",
    "solid-devtools": "^0.34.4",
    "tailwindcss": "^4.1.18",
    "typescript": "^5.9.3",
    "unplugin-swc": "^1.5.9",
    "vite": "^7.3.0",
    "vite-plugin-dts": "^4.5.4",
    "vite-plugin-solid": "^2.11.10"
  },
  "workspaces": ["./lib", "./page"],
  "dependencies": {
    "rubrc": "^1.2.0"
  }
}
---
npm notice shasum: 89aa464bc8bd81acbca792365e529d175e4f88c1
npm notice integrity: sha512-BVCyyXyI1AE7v[...]q+WBLlFJWwEVA==
npm notice total files: 38
npm notice
oligami-browser_wasi_shim-threads-0.3.6.tgz
npm notice shasum: d87f47910bc5e8f141095cea3a1b77f87f708201
npm notice integrity: sha512-1N5k8IL+JjD0l[...]pgzXxq+IIO7fg==
npm notice total files: 30
npm notice
oligami-shared-object-0.1.1.tgz
-rw-r--r-- 1 root root 343K  6月11日 00:59 oligami-browser_wasi_shim-threads-0.3.6.tgz
-rw-r--r-- 1 root root  83K  6月11日 00:59 oligami-shared-object-0.1.1.tgz


npm 包大小：
- browser_wasi_shim-threads: 343KB
- shared-object: 83KB

这还算可以。

现在让我看看 rubrc 项目的完整大小：
- sysroot (wasm32-wasip1.tar.br): 19MB
- 前端: ~4MB
- npm 包: ~426KB
- brotli wasm: 202KB
- 其他 worker: ~200KB

总计约 24MB（gzip 后可能更小）。

但问题是：rubrc 需要 COOP/COEP 头部，SharedArrayBuffer，以及复杂的配置。

让我尝试一种更简单的方案。既然 rubrc 的 sysroot 很大（19MB），让我看看是否有办法只下载一个更小的 sysroot，或者使用其他编译器。

实际上，让我重新考虑。用户要求"优先网上找现成的项目"。rubrc 是目前唯一找到的 Rust 浏览器编译器。

让我尝试下载并配置 rubrc 项目。但首先，我需要解决一些问题：

1. COOP/COEP 头部：nginx 需要配置这些头部
2. SharedArrayBuffer：需要 Cross-Origin-Isolation
3. 资源路径：需要修改 JS 文件中的 fetch 路径

这些问题都可以解决。

让我尝试下载 rubrc 的完整资源并配置。

不过，让我先看看 rubrc 是否真的能编译简单的 Rust 代码。让我先尝试下载关键资源，然后创建一个简化版的前端。

实际上，考虑到 rubrc 的复杂性（需要 COOP/COEP，SharedArrayBuffer，多个 worker，19MB sysroot），让我尝试另一种方式：

1. 下载 rubrc 的编译器资源
2. 创建一个简化版的前端（不使用 Monaco 编辑器，使用简单的 textarea）
3. 只支持 wasm32-wasip1 目标

让我先下载所有需要的资源。

实际上，我需要下载的资源：
1. 前端 HTML/JS/CSS
2. wasm32-wasip1.tar.br sysroot
3. brotli_dec_wasm_bg WASM
4. npm 包（browser_wasi_shim-threads, shared-object）
5. 多个 worker 文件

让我开始下载。

export http_proxy=http://192.168.1.1:17892
export https_proxy=http://192.168.1.1:17892

# 创建 rust-wasm 目录
mkdir -p /shumengya/www/rust-wasm
mkdir -p /shumengya/www/rust-wasm/assets

cd /shumengya/www/rust-wasm

# 下载前端资源
wget -q "https://oligamiq.github.io/rubrc/"
wget -q "https://oligamiq.github.io/rubrc/mini-coi.js"
wget -q "https://oligamiq.github.io/rubrc/favicon.png"
wget -q "https://oligamiq.github.io/rubrc/assets/index-zNXj6S8E.js"
wget -q "https://oligamiq.github.io/rubrc/assets/index-CbdARTq8.css"
wget -q "https://oligamiq.github.io/rubrc/assets/worker-CsBA4KtP.js"
wget -q "https://oligamiq.github.io/rubrc/assets/index-DBjFvkbi.js"
wget -q "https://oligamiq.github.io/rubrc/assets/index-DITC4IKB.js"
wget -q "https://oligamiq.github.io/rubrc/assets/rustc-BE50aTE-.js"
wget -q "https://oligamiq.github.io/rubrc/assets/util_cmd-T00NCR0H.js"
wget -q "https://oligamiq.github.io/rubrc/assets/llvm-y0xlpkPY.js"
wget -q "https://oligamiq.github.io/rubrc/assets/brotli_dec_wasm_bg-Dn-Szc7i.wasm"

# 下载 Monaco 编辑器 worker
# 从主 JS 文件提取 worker 文件名
for worker in $(grep -oE '[a-z]+\.worker-[A-Za-z0-9_-]+\.js' assets/index-zNXj6S8E.js 2>/dev/null || grep -oE '[a-z]+\.worker-[A-Za-z0-9_-]+\.js' index-zNXj6S8E.js | sort -u); do
  wget -q "https://oligamiq.github.io/rubrc/assets/$worker" 2>&1
  echo "Download: $worker"
done

# 下载 sysroot
wget -q "https://oligamiq.github.io/rust_wasm/v0.2.0/wasm32-wasip1.tar.br"

# 查看文件大小
ls -lh
ls -lh assets/ 2>/dev/null | head -20

# 查看总大小
du -sh /shumengya/www/rust-wasm


Download: css.worker-CZFUz3tL.js
Download: editor.worker-D97G_pyA.js
Download: html.worker-DiL2AjlA.js
Download: json.worker-CfN83P36.js
Download: ts.worker-ClNqREBk.js
总计 29M
drwxr-xr-x 2 root root 4.0K  6月11日 00:59 assets
-rw-r--r-- 1 root root 202K 12月25日 00:18 brotli_dec_wasm_bg-Dn-Szc7i.wasm
-rw-r--r-- 1 root root 970K 12月25日 00:18 css.worker-CZFUz3tL.js
-rw-r--r-- 1 root root 214K 12月25日 00:18 editor.worker-D97G_pyA.js
-rw-r--r-- 1 root root 166K 12月25日 00:18 favicon.png
-rw-r--r-- 1 root root 641K 12月25日 00:18 html.worker-DiL2AjlA.js
-rw-r--r-- 1 root root 6.9K 12月25日 00:18 index-CbdARTq8.css
-rw-r--r-- 1 root root 3.1M 12月25日 00:18 index-DBjFvkbi.js
-rw-r--r-- 1 root root 9.8K 12月25日 00:18 index-DITC4IKB.js
-rw-r--r-- 1 root root  607 12月25日 00:18 index.html
-rw-r--r-- 1 root root 353K 12月25日 00:18 index-zNXj6S8E.js
-rw-r--r-- 1 root root 339K 12月25日 00:18 json.worker-CfN83P36.js
-rw-r--r-- 1 root root  64K 12月25日 00:18 llvm-y0xlpkPY.js
-rw-r--r-- 1 root root 1.3K 12月25日 00:18 mini-coi.js
-rw-r--r-- 1 root root  64K 12月25日 00:18 rustc-BE50aTE-.js
-rw-r--r-- 1 root root 4.7M 12月25日 00:18 ts.worker-ClNqREBk.js
-rw-r--r-- 1 root root  59K 12月25日 00:18 util_cmd-T00NCR0H.js
-rw-r--r-- 1 root root  19M  6月 5日 23:28 wasm32-wasip1.tar.br
-rw-r--r-- 1 root root  47K 12月25日 00:18 worker-CsBA4KtP.js
总计 0
29M	/shumengya/www/rust-wasm


资源下载完成了，总共 29MB。

现在需要处理：
1. 移动 worker 文件到正确的位置（assets 目录）
2. 下载 npm 包并提取到 node_modules
3. 修改前端代码，去掉 npm 包的引用，改为本地引用
4. 配置 nginx 的 COOP/COEP 头部
5. 处理 sysroot 的本地路径

让我先整理文件结构，然后看看 rubrc 的 index.html 中的引用。

关键问题：rubrc 的 index.html 引用了 `mini-coi.js`，这是用来处理 cross-origin isolation 的。然后引用了 `assets/index-*.js` 和 `assets/index-*.css`。

但是 rubrc 的 JS 文件中使用了 `import` 语句来引用 npm 包（如 `@oligami/browser_wasi_shim-threads`）。这些 import 在浏览器中不会自动解析，需要 Vite 或类似的打包工具来处理。

这意味着我不能直接使用 rubrc 的打包后的 JS 文件，因为它已经通过 Vite 打包了，所有 npm 依赖都被打包进了 JS 文件中。

让我检查一下打包后的 JS 文件是否包含 npm 包的代码。

cd /shumengya/www/rust-wasm

# 检查 JS 文件是否包含 npm 包代码
# 查看 @oligami 的引用
grep -c "@oligami" index-zNXj6S8E.js

# 查看 shared-object 引用
grep -c "SharedObject\|SharedObjectRef" index-zNXj6S8E.js

# 查看 browser_wasi_shim 引用
grep -c "browser_wasi\|wasi_shim" index-zNXj6S8E.js

# 查看 worker 文件中的引用
grep -c "@oligami" worker-CsBA4KtP.js

# 查看 worker 文件中的 SharedObject 引用
grep -c "SharedObject\|SharedObjectRef" worker-CsBA4KtP.js

# 查看是否有 npm 包代码已经内联
# 查看文件中的 import 语句
grep -n "import.*from" index-zNXj6S8E.js | head -10

# 查看 worker 文件中的 import
grep -n "import.*from" worker-CsBA4KtP.js | head -10


0
5
0
0
3


JS 文件中的 `@oligami` 引用为 0，说明 npm 包已经被 Vite 打包进了 JS 文件中。`SharedObject` 和 `SharedObjectRef` 在 index 中有 5 处引用，在 worker 中有 3 处引用。

这意味着我可以直接使用这些打包后的 JS 文件，不需要额外下载 npm 包。

但是，有一个问题：worker 文件中的 `SharedObject` 和 `SharedObjectRef` 是哪里来的？如果 npm 包已经被打包进了 JS 文件，那么 worker 文件中也应该已经包含了这些代码。

让我检查一下 worker 文件中的代码。

cd /shumengya/www/rust-wasm

# 查看 worker 文件中的 SharedObject 引用
# 查看 worker 文件中的 At 对象引用（SharedObject 的别名）
grep -n "At\.SharedObject\|SharedObject\|SharedObjectRef" worker-CsBA4KtP.js | head -10

# 查看 worker 文件中的类定义
# 查看是否有 At 对象的定义
# 搜索 "new At" 或 "At." 的引用
grep -n "At\." worker-CsBA4KtP.js | head -10

# 查看 worker 文件中的 npm 包代码
# 查看是否有 "oligami" 或 "browser_wasi" 的引用
grep -n "oligami\|browser_wasi\|shared-object" worker-CsBA4KtP.js | head -10

# 查看 worker 文件中的 import 语句
grep -n "import\|export" worker-CsBA4KtP.js | head -10

# 查看 worker 文件中的 self 引用
# 查看 worker 如何加载 WASM 文件
# 搜索 "new URL" 或 "wasm" 引用
grep -n "new URL\|\.wasm" worker-CsBA4KtP.js | head -10


1:(function(){"use strict";var G={exports:{}},$t=G.exports,bt;function Ht(){return bt||(bt=1,(function(c,t){(function(e,r){r(t)})($t,(function(e){class r{kept_object;room_id;id;bc;constructor(n,s){this.kept_object=n,this.room_id=`shared-object-${s}`,this.id="parent",this.bc=new globalThis.BroadcastChannel(this.room_id),this.register()}register(){const n=this.bc;n.onmessage=s=>{const a=s.data;if(a.msg===void 0)throw new Error("Invalid message");this.is_my_msg(a)||a.to===this.id&&(a.msg==="func_call::call"&&this.func_call(a),a.msg==="get::get"&&this.get(a))}}is_my_msg(n){return n.from===this.id}func_call(n){const s=this.bc,{names:a,args:l,id:u}=n;try{if(a.length===1&&a[0]===".self"){const U=this.kept_object(...l);s.postMessage({msg:"func_call::return",ret:U,id:u,from:this.id,to:n.from});return}let h=this.kept_object;for(const U of a)h=h[U];const A=h(...l);s.postMessage({msg:"func_call::return",ret:A,id:u,from:this.id,to:n.from})}catch(h){s.postMessage({msg:"func_call::error",error:h,id:u,from:this.id,to:n.from})}}get(n){const s=this.bc,{names:a,id:l}=n;try{let u=this.kept_object;for(const h of a)u=u[h];s.postMessage({msg:"get::return",ret:u,id:l,from:this.id,to:n.from,can_post:!0})}catch(u){if(u.name==="DataCloneError"){s.postMessage({msg:"get::data_clone_error",error:u,id:l,from:this.id,to:n.from,can_post:!1});return}s.postMessage({msg:"get::error",error:u,id:l,from:this.id,to:n.from,can_post:!1})}}}class i{room_id;id;map=new Map;bc;callbacks=[];constructor(n){this.room_id=`shared-object-${n}`,this.id=this.get_id(),this.bc=new globalThis.BroadcastChannel(this.room_id),this.register()}is_my_msg(n){return n.from===this.id}proxy(){return new Proxy(()=>{},{get:(n,s)=>this.get([s]),apply:(n,s,a)=>this.call([".self"],a)})}addCallback(n){this.callbacks.push(n)}removeCallback(n){const s=this.callbacks.indexOf(n);s!==-1&&this.callbacks.splice(s,1)}register(){const n=this.bc;n.onmessage=s=>{const a=s.data;if(a.msg===void 0)throw new Error("Invalid message");if(!this.is_my_msg(a)&&a.to===this.id){if(a.msg.startsWith("func_call::")){const l=this.map.get(a.id);if(l!==void 0)l(a),this.map.delete(a.id);else throw new Error("what happened? unreachable code")}if(a.msg.startsWith("get::")){const l=this.map.get(a.id);if(l!==void 0)l(a),this.map.delete(a.id);else throw new Error("what happened? unreachable code")}}}}get_id(){return Math.random().toString(36).slice(2)}check_msg_error(n){if(n.msg.endsWith("::error"))throw n.error}get(n){const{promise:s,resolve:a}=Promise.withResolvers(),l=this.get_id();this.map.set(l,a),this.postMessage({msg:"get::get",names:n,id:l,from:this.id,to:"parent"});let u=!1;const A=(async()=>{const _=await s;if(this.check_msg_error(_),_.msg==="get::return"||_.msg==="get::data_clone_error"){u&&console.warn(`Warning!
2:Objects that cannot be transferred are being retrieved.`);const f=_;return f.can_post?f.ret:new Proxy(()=>{},{get:(d,m)=>m==="then"?(u=!0,Promise.resolve(A)):this.get([...n,m]),apply:(d,m,w)=>this.call(n,w)})}throw new Error("what happened? unreachable code")})();return new Proxy(()=>{},{get:(_,f)=>f==="then"?(u=!0,A.then.bind(A)):this.get([...n,f]),apply:(_,f,d)=>this.call(n,d)})}async call(n,s){const{promise:a,resolve:l}=Promise.withResolvers(),u=this.get_id();this.map.set(u,l),this.postMessage({msg:"func_call::call",names:n,args:s,id:u});const h=await a;if(this.check_msg_error(h),h.msg==="func_call::return")return h.ret;throw new Error("what happened? unreachable code")}async call_callback(n){const{name:s,args:a,id:l}=n;try{if(n.msg==="callback::call"){const u=this.callbacks.find(A=>A.name===s);if(u===void 0)throw new Error("function not found");const h=u(...a);if(h instanceof Promise){this.postMessage({msg:"callback::promise",id:l});const A=await h;this.postMessage({msg:"callback::promise_return",ret:A,id:l})}else this.postMessage({msg:"callback::return",ret:h,id:l})}}catch(u){this.postMessage({msg:"callback::error",error:u,id:l})}}postMessage(n){this.bc.postMessage({...n,from:this.id,to:"parent"})}}e.SharedObject=r,e.SharedObjectRef=i,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}))})(G,G.exports)),G.exports}var At=Ht();const v=0,S=8,tt=20,et=28,kt=31,D=44,B=54,Et=55,k=58,ft=63,Ut=76,vt=64,qt=0,Gt=1,Rt=2,O=3,rt=4;class lt{head_length(){return 24}name_length(){return this.dir_name.byteLength}write_head_bytes(t,e){t.setBigUint64(e,this.d_next,!0),t.setBigUint64(e+8,this.d_ino,!0),t.setUint32(e+16,this.dir_name.length,!0),t.setUint8(e+20,this.d_type)}write_name_bytes(t,e,r){t.set(this.dir_name.slice(0,Math.min(this.dir_name.byteLength,r)),e)}constructor(t,e,r,i){const o=new TextEncoder().encode(r);this.d_next=t,this.d_ino=e,this.d_namlen=o.byteLength,this.d_type=i,this.dir_name=o}}const Yt=1;class xt{write_bytes(t,e){t.setUint8(e,this.fs_filetype),t.setUint16(e+2,this.fs_flags,!0),t.setBigUint64(e+8,this.fs_rights_base,!0),t.setBigUint64(e+16,this.fs_rights_inherited,!0)}constructor(t,e){this.fs_rights_base=0n,this.fs_rights_inherited=0n,this.fs_filetype=t,this.fs_flags=e}}const _t=1,Y=2,It=4,Tt=8;class Ot{write_bytes(t,e){t.setBigUint64(e,this.dev,!0),t.setBigUint64(e+8,this.ino,!0),t.setUint8(e+16,this.filetype),t.setBigUint64(e+24,this.nlink,!0),t.setBigUint64(e+32,this.size,!0),t.setBigUint64(e+38,this.atim,!0),t.setBigUint64(e+46,this.mtim,!0),t.setBigUint64(e+52,this.ctim,!0)}constructor(t,e,r){this.dev=0n,this.nlink=0n,this.atim=0n,this.mtim=0n,this.ctim=0n,this.ino=t,this.filetype=e,this.size=r}}const Vt=0;class Xt{write_bytes(t,e){t.setUint32(e,this.pr_name.byteLength,!0)}constructor(t){this.pr_name=new TextEncoder().encode(t)}}class dt{static dir(t){const e=new dt;return e.tag=Vt,e.inner=new Xt(t),e}write_bytes(t,e){t.setUint32(e,this.tag,!0),this.inner.write_bytes(t,e+4)}}let Zt=class{enable(t){this.log=Jt(t===void 0?!0:t,this.prefix)}get enabled(){return this.isEnabled}constructor(t){this.isEnabled=t,this.prefix="wasi:",this.enable(t)}};function Jt(c,t){return c?console.log.bind(console,"%c%s","color: #265BA0",t):()=>{}}const V=new Zt(!1);class Lt{fd_allocate(t,e){return k}fd_close(){return 0}fd_fdstat_get(){return{ret:k,fdstat:null}}fd_fdstat_set_flags(t){return k}fd_fdstat_set_rights(t,e){return k}fd_filestat_get(){return{ret:k,filestat:null}}fd_filestat_set_size(t){return k}fd_filestat_set_times(t,e,r){return k}fd_pread(t,e){return{ret:k,data:new Uint8Array}}fd_prestat_get(){return{ret:k,prestat:null}}fd_pwrite(t,e){return{ret:k,nwritten:0}}fd_read(t){return{ret:k,data:new Uint8Array}}fd_readdir_single(t){return{ret:k,dirent:null}}fd_seek(t,e){return{ret:k,offset:0n}}fd_sync(){return 0}fd_tell(){return{ret:k,offset:0n}}fd_write(t){return{ret:k,nwritten:0}}path_create_directory(t){return k}path_filestat_get(t,e){return{ret:k,filestat:null}}path_filestat_set_times(t,e,r,i,o){return k}path_link(t,e,r){return k}path_unlink(t){return{ret:k,inode_obj:null}}path_lookup(t,e){return{ret:k,inode_obj:null}}path_open(t,e,r,i,o,n){return{ret:B,fd_obj:null}}path_readlink(t){return{ret:k,data:null}}path_remove_directory(t){return k}path_rename(t,e,r){return k}path_unlink_file(t){return k}}class P{static issue_ino(){return P.next_ino++}static root_ino(){return 0n}constructor(){this.ino=P.issue_ino()}}P.next_ino=1n;class Kt extends Lt{fd_allocate(t,e){if(!(this.file.size>t+e)){const r=new Uint8Array(Number(t+e));r.set(this.file.data,0),this.file.data=r}return v}fd_fdstat_get(){return{ret:0,fdstat:new xt(rt,0)}}fd_filestat_set_size(t){if(this.file.size>t)this.file.data=new Uint8Array(this.file.data.buffer.slice(0,Number(t)));else{const e=new Uint8Array(Number(t));e.set(this.file.data,0),this.file.data=e}return v}fd_read(t){const e=this.file.data.slice(Number(this.file_pos),Number(this.file_pos+BigInt(t)));return this.file_pos+=BigInt(e.length),{ret:0,data:e}}fd_pread(t,e){return{ret:0,data:this.file.data.slice(Number(e),Number(e+BigInt(t)))}}fd_seek(t,e){let r;switch(e){case qt:r=t;break;case Gt:r=this.file_pos+t;break;case Rt:r=BigInt(this.file.data.byteLength)+t;break;default:return{ret:et,offset:0n}}return r<0?{ret:et,offset:0n}:(this.file_pos=r,{ret:0,offset:this.file_pos})}fd_tell(){return{ret:0,offset:this.file_pos}}fd_write(t){if(this.file.readonly)return{ret:S,nwritten:0};if(this.file_pos+BigInt(t.byteLength)>this.file.size){const e=this.file.data;this.file.data=new Uint8Array(Number(this.file_pos+BigInt(t.byteLength))),this.file.data.set(e)}return this.file.data.set(t,Number(this.file_pos)),this.file_pos+=BigInt(t.byteLength),{ret:0,nwritten:t.byteLength}}fd_pwrite(t,e){if(this.file.readonly)return{ret:S,nwritten:0};if(e+BigInt(t.byteLength)>this.file.size){const r=this.file.data;this.file.data=new Uint8Array(Number(e+BigInt(t.byteLength))),this.file.data.set(r)}return this.file.data.set(t,Number(e)),{ret:0,nwritten:t.byteLength}}fd_filestat_get(){return{ret:0,filestat:this.file.stat()}}constructor(t){super(),this.file_pos=0n,this.file=t}}class St extends Lt{fd_seek(t,e){return{ret:S,offset:0n}}fd_tell(){return{ret:S,offset:0n}}fd_allocate(t,e){return S}fd_fdstat_get(){return{ret:0,fdstat:new xt(O,0)}}fd_readdir_single(t){if(V.enabled&&(V.log("readdir_single",t),V.log(t,this.dir.contents.keys())),t==0n)return{ret:v,dirent:new lt(1n,this.dir.ino,".",O)};if(t==1n)return{ret:v,dirent:new lt(2n,this.dir.parent_ino(),"..",O)};if(t>=BigInt(this.dir.contents.size)+2n)return{ret:0,dirent:null};const[e,r]=Array.from(this.dir.contents.entries())[Number(t-2n)];return{ret:0,dirent:new lt(t+1n,r.ino,e,r.stat().filetype)}}path_filestat_get(t,e){const{ret:r,path:i}=M.from(e);if(i==null)return{ret:r,filestat:null};const{ret:o,entry:n}=this.dir.get_entry_for_path(i);return n==null?{ret:o,filestat:null}:{ret:0,filestat:n.stat()}}path_lookup(t,e){const{ret:r,path:i}=M.from(t);if(i==null)return{ret:r,inode_obj:null};const{ret:o,entry:n}=this.dir.get_entry_for_path(i);return n==null?{ret:o,inode_obj:null}:{ret:v,inode_obj:n}}path_open(t,e,r,i,o,n){const{ret:s,path:a}=M.from(e);if(a==null)return{ret:s,fd_obj:null};let{ret:l,entry:u}=this.dir.get_entry_for_path(a);if(u==null){if(l!=D)return{ret:l,fd_obj:null};if((r&_t)==_t){const{ret:h,entry:A}=this.dir.create_entry_for_path(e,(r&Y)==Y);if(A==null)return{ret:h,fd_obj:null};u=A}else return{ret:D,fd_obj:null}}else if((r&It)==It)return{ret:tt,fd_obj:null};return(r&Y)==Y&&u.stat().filetype!==O?{ret:B,fd_obj:null}:u.path_open(r,i,n)}path_create_directory(t){return this.path_open(0,t,_t|Y,0n,0n,0).ret}path_link(t,e,r){const{ret:i,path:o}=M.from(t);if(o==null)return i;if(o.is_dir)return D;const{ret:n,parent_entry:s,filename:a,entry:l}=this.dir.get_parent_dir_and_entry_for_path(o,!0);if(s==null||a==null)return n;if(l!=null){const u=e.stat().filetype==O,h=l.stat().filetype==O;if(u&&h)if(r&&l instanceof R){if(l.contents.size!=0)return Et}else return tt;else{if(u&&!h)return B;if(!u&&h)return kt;if(!(e.stat().filetype==rt&&l.stat().filetype==rt))return tt}}return!r&&e.stat().filetype==O?ft:(s.contents.set(a,e),v)}path_unlink(t){const{ret:e,path:r}=M.from(t);if(r==null)return{ret:e,inode_obj:null};const{ret:i,parent_entry:o,filename:n,entry:s}=this.dir.get_parent_dir_and_entry_for_path(r,!0);return o==null||n==null?{ret:i,inode_obj:null}:s==null?{ret:D,inode_obj:null}:(o.contents.delete(n),{ret:v,inode_obj:s})}path_unlink_file(t){const{ret:e,path:r}=M.from(t);if(r==null)return e;const{ret:i,parent_entry:o,filename:n,entry:s}=this.dir.get_parent_dir_and_entry_for_path(r,!1);return o==null||n==null||s==null?i:s.stat().filetype===O?kt:(o.contents.delete(n),v)}path_remove_directory(t){const{ret:e,path:r}=M.from(t);if(r==null)return e;const{ret:i,parent_entry:o,filename:n,entry:s}=this.dir.get_parent_dir_and_entry_for_path(r,!1);return o==null||n==null||s==null?i:!(s instanceof R)||s.stat().filetype!==O?B:s.contents.size!==0?Et:o.contents.delete(n)?v:D}fd_filestat_get(){return{ret:0,filestat:this.dir.stat()}}fd_filestat_set_size(t){return S}fd_read(t){return{ret:S,data:new Uint8Array}}fd_pread(t,e){return{ret:S,data:new Uint8Array}}fd_write(t){return{ret:S,nwritten:0}}fd_pwrite(t,e){return{ret:S,nwritten:0}}constructor(t){super(),this.dir=t}}class Qt extends St{fd_prestat_get(){return{ret:0,prestat:dt.dir(this.prestat_name)}}constructor(t,e){super(new R(e)),this.prestat_name=t}}class st extends P{path_open(t,e,r){if(this.readonly&&(e&BigInt(vt))==BigInt(vt))return{ret:ft,fd_obj:null};if((t&Tt)==Tt){if(this.readonly)return{ret:ft,fd_obj:null};this.data=new Uint8Array([])}const i=new Kt(this);return r&Yt&&i.fd_seek(0n,Rt),{ret:v,fd_obj:i}}get size(){return BigInt(this.data.byteLength)}stat(){return new Ot(this.ino,rt,this.size)}constructor(t,e){super(),this.data=new Uint8Array(t),this.readonly=!!e?.readonly}}let M=class Ct{static from(t){const e=new Ct;if(e.is_dir=t.endsWith("/"),t.startsWith("/"))return{ret:Ut,path:null};if(t.includes("\0"))return{ret:et,path:null};for(const r of t.split("/"))if(!(r===""||r===".")){if(r===".."){if(e.parts.pop()==null)return{ret:Ut,path:null};continue}e.parts.push(r)}return{ret:v,path:e}}to_path_string(){let t=this.parts.join("/");return this.is_dir&&(t+="/"),t}constructor(){this.parts=[],this.is_dir=!1}};class R extends P{parent_ino(){return this.parent==null?P.root_ino():this.parent.ino}path_open(t,e,r){return{ret:v,fd_obj:new St(this)}}stat(){return new Ot(this.ino,O,0n)}get_entry_for_path(t){let e=this;for(const r of t.parts){if(!(e instanceof R))return{ret:B,entry:null};const i=e.contents.get(r);if(i!==void 0)e=i;else return V.log(r),{ret:D,entry:null}}return t.is_dir&&e.stat().filetype!=O?{ret:B,entry:null}:{ret:v,entry:e}}get_parent_dir_and_entry_for_path(t,e){const r=t.parts.pop();if(r===void 0)return{ret:et,parent_entry:null,filename:null,entry:null};const{ret:i,entry:o}=this.get_entry_for_path(t);if(o==null)return{ret:i,parent_entry:null,filename:null,entry:null};if(!(o instanceof R))return{ret:B,parent_entry:null,filename:null,entry:null};const n=o.contents.get(r);return n===void 0?e?{ret:v,parent_entry:o,filename:r,entry:null}:{ret:D,parent_entry:null,filename:null,entry:null}:t.is_dir&&n.stat().filetype!=O?{ret:B,parent_entry:null,filename:null,entry:null}:{ret:v,parent_entry:o,filename:r,entry:n}}create_entry_for_path(t,e){const{ret:r,path:i}=M.from(t);if(i==null)return{ret:r,entry:null};let{ret:o,parent_entry:n,filename:s,entry:a}=this.get_parent_dir_and_entry_for_path(i,!0);if(n==null||s==null)return{ret:o,entry:null};if(a!=null)return{ret:tt,entry:null};V.log("create",i);let l;return e?l=new R(new Map):l=new st(new ArrayBuffer(0)),n.contents.set(s,l),a=l,{ret:v,entry:a}}constructor(t){super(),this.parent=null,t instanceof Array?this.contents=new Map(t):this.contents=t;for(const e of this.contents.values())e instanceof R&&(e.parent=this)}}const L=0,b=8,jt=37,te=58,ee=61;class X{static read_bytes(t,e){const r=new X;return r.buf=t.getUint32(e,!0),r.buf_len=t.getUint32(e+4,!0),r}static read_bytes_array(t,e,r){const i=[];for(let o=0;o<r;o++)i.push(X.read_bytes(t,e+8*o));return i}}let re=class{enable(t){this.log=se(t===void 0?!0:t,this.prefix)}get enabled(){return this.isEnabled}constructor(t){this.isEnabled=t,this.prefix="wasi:",this.enable(t)}};function se(c,t){return c?console.log.bind(console,"%c%s","color: #265BA0",t):()=>{}}new re(!1);class ne{fds;stdin;stdout;stderr;default_allow_fds;constructor(t,e,r,i,o){this.fds=t,this.stdin=e,this.stdout=r,this.stderr=i,this.default_allow_fds=o,this.fds_map=new Array(t.length);for(let n=0;n<t.length;n++)this.fds_map[n]=[]}get_new_fd_lock=new Array;fds_map;async get_new_fd(){return new Promise(e=>{this.get_new_fd_lock.push(async()=>{let i=-1;for(let s=0;s<this.fds.length;s++)if(this.fds[s]===void 0){i=s;break}i===-1&&(i=this.fds.length,this.fds.push(void 0),this.fds_map.push([]));const[o,n]=this.can_set_new_fd(i);o||await n,e([async()=>{this.get_new_fd_lock.shift();const s=this.get_new_fd_lock[0];s!==void 0&&s(),await this.notify_set_fd(i)},i])})===1&&this.get_new_fd_lock[0]()})}fd_advise(t){return this.fds[t]!==void 0?L:b}fd_allocate(t,e,r){return this.fds[t]!==void 0?this.fds[t].fd_allocate(e,r):b}async fd_close(t){if(this.fds[t]!==void 0){const e=this.fds[t].fd_close();return this.fds[t]=void 0,await this.notify_rm_fd(t),e}return b}fd_datasync(t){return this.fds[t]!==void 0?this.fds[t].fd_sync():b}fd_fdstat_get(t){if(this.fds[t]!==void 0){const{ret:e,fdstat:r}=this.fds[t].fd_fdstat_get();return r!=null?[r,e]:[void 0,e]}return[void 0,b]}fd_fdstat_set_flags(t,e){return this.fds[t]!==void 0?this.fds[t].fd_fdstat_set_flags(e):b}fd_fdstat_set_rights(t,e,r){return this.fds[t]!==void 0?this.fds[t].fd_fdstat_set_rights(e,r):b}fd_filestat_get(t){if(this.fds[t]!==void 0){const{ret:e,filestat:r}=this.fds[t].fd_filestat_get();return r!=null?[r,e]:[void 0,e]}return[void 0,b]}fd_filestat_set_size(t,e){return this.fds[t]!==void 0?this.fds[t].fd_filestat_set_size(e):b}fd_filestat_set_times(t,e,r,i){return this.fds[t]!==void 0?this.fds[t].fd_filestat_set_times(e,r,i):b}fd_pread(t,e,r){if(this.fds[t]!==void 0){let i=0,o=new Uint8Array(0);for(const n of e){const{ret:s,data:a}=this.fds[t].fd_pread(n.buf_len,r);if(s!==L)return[[i,o],s];const l=new Uint8Array(o.byteLength+a.byteLength);if(l.set(o),l.set(a,o.byteLength),o=l,i+=a.byteLength,a.byteLength!==n.buf_len)break}return[[i,o],L]}return[void 0,b]}fd_prestat_get(t){if(this.fds[t]!==void 0){const{ret:e,prestat:r}=this.fds[t].fd_prestat_get();return r!=null?[r,e]:[void 0,e]}return[void 0,b]}fd_prestat_dir_name(t,e){if(this.fds[t]!==void 0){const{ret:r,prestat:i}=this.fds[t].fd_prestat_get();if(i){const o=i.inner.pr_name;return o.length<=e?[o,r]:[o.slice(0,e),jt]}return[void 0,r]}return[void 0,b]}fd_pwrite(t,e,r){if(this.fds[t]!==void 0){const{ret:i,nwritten:o}=this.fds[t].fd_pwrite(e,r);return[o,i]}return[void 0,b]}fd_read(t,e){if(this.fds[t]!==void 0){let r=0,i=new Uint8Array(0);for(const o of e){const{ret:n,data:s}=this.fds[t].fd_read(o.buf_len);if(n!==L)return[[r,i],n];const a=new Uint8Array(i.byteLength+s.byteLength);if(a.set(i),a.set(s,i.byteLength),i=a,r+=s.byteLength,s.byteLength!==o.buf_len)break}return[[r,i],L]}return[void 0,b]}fd_readdir(t,e,r){if(this.fds[t]!==void 0){const i=new Uint8Array(e);let o=0,n=0;for(;;){const{ret:s,dirent:a}=this.fds[t].fd_readdir_single(r);if(s!==L)return[[i,o],s];if(a==null)break;if(e-o<a.head_length()){o=e;break}const l=new ArrayBuffer(a.head_length());if(a.write_head_bytes(new DataView(l),0),i.set(new Uint8Array(l).slice(0,Math.min(l.byteLength,e-o)),n),n+=l.byteLength,o+=l.byteLength,e-o<a.name_length()){o=e;break}a.write_name_bytes(i,n,e-o),n+=a.name_length(),o+=a.name_length(),r=a.d_next}return[[i,o],L]}return[void 0,b]}fd_seek(t,e,r){if(this.fds[t]!==void 0){const{ret:i,offset:o}=this.fds[t].fd_seek(e,r);return[o,i]}return[void 0,b]}fd_sync(t){return this.fds[t]!==void 0?this.fds[t].fd_sync():b}fd_tell(t){if(this.fds[t]!==void 0){const{ret:e,offset:r}=this.fds[t].fd_tell();return[r,e]}return[void 0,b]}async fd_write(t,e){if(this.fds[t]!==void 0){const r=this.fds[t].fd_write(e);let i,o;return r instanceof Promise?{ret:i,nwritten:o}=await r:{ret:i,nwritten:o}=r,[o,i]}return[void 0,b]}path_create_directory(t,e){return this.fds[t]!==void 0?this.fds[t].path_create_directory(e):b}path_filestat_get(t,e,r){if(this.fds[t]!==void 0){const{ret:i,filestat:o}=this.fds[t].path_filestat_get(e,r);return o!=null?[o,i]:[void 0,i]}return[void 0,b]}path_filestat_set_times(t,e,r,i,o,n){return this.fds[t]!==void 0?this.fds[t].path_filestat_set_times(e,r,i,o,n):b}path_link(t,e,r,i,o){if(this.fds[t]!==void 0&&this.fds[i]!==void 0){const{ret:n,inode_obj:s}=this.fds[t].path_lookup(r,e);return s==null?n:this.fds[i].path_link(o,s,!1)}return b}async path_open(t,e,r,i,o,n,s){if(this.fds[t]!==void 0){const{ret:a,fd_obj:l}=this.fds[t].path_open(e,r,i,o,n,s);if(a!==L)return[void 0,a];const[u,h]=await this.get_new_fd();if(!l)throw"fd_obj should not be null";return this.fds[h]=l,await u(),[h,L]}return[void 0,b]}path_readlink(t,e,r){if(this.fds[t]!==void 0){const{ret:i,data:o}=this.fds[t].path_readlink(e);if(o!=null){const n=new TextEncoder().encode(o);return n.byteLength>r?[n.slice(0,r),ee]:[n,i]}return[void 0,i]}return[void 0,b]}path_remove_directory(t,e){return this.fds[t]!==void 0?this.fds[t].path_remove_directory(e):b}path_rename(t,e,r,i){if(this.fds[t]!==void 0&&this.fds[r]!==void 0){let{ret:o,inode_obj:n}=this.fds[t].path_unlink(e);if(n==null)return o;if(o=this.fds[r].path_link(i,n,!0),o!==L&&this.fds[t].path_link(e,n,!0)!==L)throw"path_link should always return success when relinking an inode back to the original place";return o}return b}path_symlink(t,e,r){return this.fds[e]!==void 0?te:b}path_unlink_file(t,e){return this.fds[t]!==void 0?this.fds[t].path_unlink_file(e):b}}class nt{share_arrays_memory;constructor(t=new SharedArrayBuffer(10*1024*1024)){this.share_arrays_memory=t;const e=new Int32Array(this.share_arrays_memory);Atomics.store(e,0,0),Atomics.store(e,1,0),Atomics.store(e,2,12)}static init_self(t){return new nt(t.share_arrays_memory)}async async_write(t,e,r){const i=new Int32Array(this.share_arrays_memory);for(;;){let o;const{value:n}=Atomics.waitAsync(i,0,1);if(n instanceof Promise?o=await n:o=n,o==="timed-out")throw new Error("timed-out lock");if(Atomics.compareExchange(i,0,0,1)!==0)continue;const a=this.write_inner(t,e,r);return Atomics.store(i,0,0),Atomics.notify(i,0,1),a}}block_write(t,e,r){for(;;){const i=new Int32Array(this.share_arrays_memory);if(Atomics.wait(i,0,1)==="timed-out")throw new Error("timed-out lock");if(Atomics.compareExchange(i,0,0,1)!==0)continue;const s=this.write_inner(t,e,r);return Atomics.store(i,0,0),Atomics.notify(i,0,1),s}}write_inner(t,e,r){const i=new Int32Array(this.share_arrays_memory),o=new Uint8Array(this.share_arrays_memory),n=Atomics.add(i,1,1);let s;n===0?s=Atomics.store(i,2,12):s=Atomics.load(i,2);const a=this.share_arrays_memory.byteLength,l=t.byteLength,u=s+l;if(a<u)throw new Error(`size is bigger than memory.
22:  `,t=[],e=1e4;function r(){if(t.length>0){const l=t.pop();return l.terminationTimer&&(clearTimeout(l.terminationTimer),l.terminationTimer=null),l}console.debug("Allocating new waitAsync helper worker");const n=new Blob([c],{type:"application/javascript"}),s=URL.createObjectURL(n),a=new Worker(s);return URL.revokeObjectURL(s),a.onerror=l=>{console.error("Error in waitAsync helper worker:",l.message,l.filename,l.lineno)},a}function i(n){n.terminationTimer=setTimeout(()=>{const s=t.indexOf(n);s!==-1&&(n.terminate(),t.splice(s,1),console.debug("Terminated idle waitAsync helper worker"))},e),t.push(n)}function o(n,s,a,l){if(typeof n!="object"||!(n instanceof Int32Array)||!(n.buffer instanceof SharedArrayBuffer))throw new TypeError("Atomics.waitAsync requires a shared Int32Array.");const u=s|0,h=a|0,A=l===void 0?Number.POSITIVE_INFINITY:+l;if(u<0||u>=n.length)throw new RangeError("Index out of bounds.");return Atomics.load(n,u)!==h?{async:!1,value:"not-equal"}:{async:!0,value:new Promise((U,_)=>{const f=r();f.onmessage=d=>{switch(i(f),f.onmessage=null,d.data[0]){case"ok":U(d.data[1]);break;case"error":_(new Error(`Error in waitAsync helper: ${d.data[1]}`));break}},f.postMessage(["wait",n,u,h,A])})}}Object.defineProperty(Atomics,"waitAsync",{value:o,configurable:!0,enumerable:!1,writable:!0})}let y;const Bt=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&Bt.decode();let Z=null;function C(){return(Z===null||Z.byteLength===0)&&(Z=new Uint8Array(y.memory.buffer)),Z}function ut(c,t){return c=c>>>0,Bt.decode(C().subarray(c,c+t))}const N=new Array(128).fill(void 0);N.push(void 0,null,!0,!1);let J=N.length;function Mt(c){J===N.length&&N.push(N.length+1);const t=J;return J=N[t],N[t]=c,t}function zt(c){return N[c]}function fe(c){c<132||(N[c]=J,J=c)}function mt(c){const t=zt(c);return fe(c),t}let F=0;function wt(c,t){const e=t(c.length*1,1)>>>0;return C().set(c,e/1),F=c.length,e}let K=null;function j(){return(K===null||K.byteLength===0)&&(K=new Int32Array(y.memory.buffer)),K}function le(c,t){return c=c>>>0,C().subarray(c/1,c/1+t)}const it=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},_e=typeof it.encodeInto=="function"?function(c,t){return it.encodeInto(c,t)}:function(c,t){const e=it.encode(c);return t.set(e),{read:c.length,written:e.length}};function de(c,t,e){if(e===void 0){const s=it.encode(c),a=t(s.length,1)>>>0;return C().subarray(a,a+s.length).set(s),F=s.length,a}let r=c.length,i=t(r,1)>>>0;const o=C();let n=0;for(;n<r;n++){const s=c.charCodeAt(n);if(s>127)break;o[i+n]=s}if(n!==r){n!==0&&(c=c.slice(n)),i=e(i,r,r=n+c.length*3,1)>>>0;const s=C().subarray(i+n,i+r),a=_e(c,s);n+=a.written,i=e(i,r,n,1)>>>0}return F=n,i}const yt=Object.freeze({ResultSuccess:1,1:"ResultSuccess",NeedsMoreInput:2,2:"NeedsMoreInput",NeedsMoreOutput:3,3:"NeedsMoreOutput"}),he=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(c=>y.__wbg_brotlidecstream_free(c>>>0));class ue{__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,he.unregister(this),t}free(){const t=this.__destroy_into_raw();y.__wbg_brotlidecstream_free(t)}constructor(){const t=y.brotlidecstream_new();return this.__wbg_ptr=t>>>0,this}dec(t,e){try{const n=y.__wbindgen_add_to_stack_pointer(-16),s=wt(t,y.__wbindgen_malloc),a=F;y.brotlidecstream_dec(n,this.__wbg_ptr,s,a,e);var r=j()[n/4+0],i=j()[n/4+1],o=j()[n/4+2];if(o)throw mt(i);return ot.__wrap(r)}finally{y.__wbindgen_add_to_stack_pointer(16)}}decompress(t,e){try{const n=y.__wbindgen_add_to_stack_pointer(-16),s=wt(t,y.__wbindgen_malloc),a=F;y.brotlidecstream_dec(n,this.__wbg_ptr,s,a,e);var r=j()[n/4+0],i=j()[n/4+1],o=j()[n/4+2];if(o)throw mt(i);return ot.__wrap(r)}finally{y.__wbindgen_add_to_stack_pointer(16)}}total_out(){return y.brotlidecstream_total_out(this.__wbg_ptr)>>>0}}const Dt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(c=>y.__wbg_brotlistreamresult_free(c>>>0));class ot{static __wrap(t){t=t>>>0;const e=Object.create(ot.prototype);return e.__wbg_ptr=t,Dt.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,Dt.unregister(this),t}free(){const t=this.__destroy_into_raw();y.__wbg_brotlistreamresult_free(t)}get code(){return y.__wbg_get_brotlistreamresult_code(this.__wbg_ptr)}set code(t){y.__wbg_set_brotlistreamresult_code(this.__wbg_ptr,t)}get buf(){try{const i=y.__wbindgen_add_to_stack_pointer(-16);y.__wbg_get_brotlistreamresult_buf(i,this.__wbg_ptr);var t=j()[i/4+0],e=j()[i/4+1],r=le(t,e).slice();return y.__wbindgen_free(t,e*1,1),r}finally{y.__wbindgen_add_to_stack_pointer(16)}}set buf(t){const e=wt(t,y.__wbindgen_malloc),r=F;y.__wbg_set_brotlistreamresult_buf(this.__wbg_ptr,e,r)}get input_offset(){return y.__wbg_get_brotlistreamresult_input_offset(this.__wbg_ptr)>>>0}set input_offset(t){y.__wbg_set_brotlistreamresult_input_offset(this.__wbg_ptr,t)}}typeof FinalizationRegistry>"u"||new FinalizationRegistry(c=>y.__wbg_decompressstream_free(c>>>0));async function me(c,t){if(typeof Response=="function"&&c instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(c,t)}catch(r){if(c.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",r);else throw r}const e=await c.arrayBuffer();return await WebAssembly.instantiate(e,t)}else{const e=await WebAssembly.instantiate(c,t);return e instanceof WebAssembly.Instance?{instance:e,module:c}:e}}function we(){const c={};return c.wbg={},c.wbg.__wbindgen_error_new=function(t,e){const r=new Error(ut(t,e));return Mt(r)},c.wbg.__wbindgen_object_drop_ref=function(t){mt(t)},c.wbg.__wbg_new_abda76e883ba8a5f=function(){const t=new Error;return Mt(t)},c.wbg.__wbg_stack_658279fe44541cf6=function(t,e){const r=zt(e).stack,i=de(r,y.__wbindgen_malloc,y.__wbindgen_realloc),o=F;j()[t/4+1]=o,j()[t/4+0]=i},c.wbg.__wbg_error_f851667af71bcfc6=function(t,e){let r,i;try{r=t,i=e,console.error(ut(t,e))}finally{y.__wbindgen_free(r,i,1)}},c.wbg.__wbindgen_throw=function(t,e){throw new Error(ut(t,e))},c}function ye(c,t){return y=c.exports,Pt.__wbindgen_wasm_module=t,K=null,Z=null,y}async function Pt(c){if(y!==void 0)return y;typeof c>"u"&&(c=new URL(""+new URL("brotli_dec_wasm_bg-Dn-Szc7i.wasm",self.location.href).href,self.location.href));const t=we();(typeof c=="string"||typeof Request=="function"&&c instanceof Request||typeof URL=="function"&&c instanceof URL)&&(c=fetch(c));const{instance:e,module:r}=await me(await c,t);return ye(e,r)}var pe=""+new URL("brotli_dec_wasm_bg-Dn-Szc7i.wasm?wasm",self.location.href).href;const ge=Pt(pe),be=1024*1024,Ae=async()=>{await ge;const c=new ue;return new TransformStream({transform(e,r){let i,o=0;do{const n=e.slice(o),s=c.decompress(n,be);r.enqueue(s.buf),i=s.code,o+=s.input_offset}while(i===yt.NeedsMoreOutput);i!==yt.NeedsMoreInput&&i!==yt.ResultSuccess&&r.error(`Brotli decompression failed with code ${i}`)},flush(e){e.terminate()}})},ke=async c=>{const t=await fetch(c);if(!t.ok)throw new Error("Failed to fetch wasm");if(!t.body)throw new Error("No body in response");return t.body.pipeThrough(await Ae())};async function Ee(c,t){const e=c.getReader();let r=new Uint8Array(0),i=!1;const o=async()=>{const{done:n,value:s}=await e.read();if(s){const a=new Uint8Array(r.length+s.length);a.set(r),a.set(s,r.length),r=a}i=n};for(;;){for(;r.length<512&&!i;)await o();const n=$(r,0,100);if(n.length===0)break;const s=$(r,100,8),a=Number.parseInt($(r,108,8)),l=Number.parseInt($(r,116,8)),u=pt(r,124,12),h=pt(r,136,12),A=pt(r,156,1),U=A===0?"file":A===5?"directory":A,_=$(r,265,32),f=$(r,297,32);for(;r.length<512+u;)await o();const d=r.slice(512,512+u);t({name:n,type:U,size:u,data:d,get text(){return new TextDecoder().decode(this.data)},attrs:{mode:s,uid:a,gid:l,mtime:h,user:_,group:f}});let w=512+512*Math.trunc(u/512);for(u%512&&(w+=512);r.length<w&&!i;)await o();if(i&&r.length<w)break;r=r.slice(w)}}function $(c,t,e){const r=c.slice(t,t+e),i=r.indexOf(0);return new TextDecoder().decode(r.slice(0,i))}function pt(c,t,e){const r=c.slice(t,t+e);let i="";for(let o=0;o<e;o++)i+=String.fromCodePoint(r[o]);return Number.parseInt(i,8)}const Ft=async c=>{const t=await ke(`https://oligamiq.github.io/rust_wasm/v0.2.0/${c}.tar.br`),e=new Map;return console.group("Loading sysroot"),await Ee(t,r=>{if(!r.data)throw new Error("File data not found");if(r.name.includes("/")){const i=r.name.split("/"),o=e.get(i[0]);o instanceof R?o.contents.set(i.slice(1).join("/"),new st(r.data)):e.set(i[0],new R([[i.slice(1).join("/"),new st(r.data)]]))}else e.set(r.name,new st(r.data));console.log(r.name)}),console.groupEnd(),new R(e)},Ue=c=>{const t=new Map;for(const[e,r]of c)t.set(e,r);return t};let at;const ve=async()=>{const c=await Ft("wasm32-wasip1");at=new R([["wasm32-wasip1",new R([["lib",c]])]]);const t=new Qt("/sysroot",Ue([["lib",new R([["rustlib",at]])]]));return gt.add("wasm32-wasip1"),t},gt=new Set,Re=async c=>{if(gt.has(c))return;const t=await Ft(c);if(!at)throw new Error("Default sysroot not loaded");at.contents.set(c,new R([["lib",t]])),gt.add(c)},xe=async()=>{const c=[await ve()];return new ae(void 0,void 0,void 0,c,{allocator_size:1024*1024*1024})};function Ie(c){return new Worker(""+new URL("rustc-BE50aTE-.js",self.location.href).href,{name:c?.name})}function Te(c){return new Worker(""+new URL("util_cmd-T00NCR0H.js",self.location.href).href,{name:c?.name})}function Oe(c){return new Worker(""+new URL("llvm-y0xlpkPY.js",self.location.href).href,{name:c?.name})}ce();let Q,ct,H;const q=[];globalThis.addEventListener("message",async c=>{if(c.data.ctx){ct=new Ie,H=c.data.ctx,ct.postMessage({ctx:H}),Q=new At.SharedObjectRef(H.terminal_id).proxy(),await Q(`loading sysroot\r
22:  `,t=[],e=1e4;function r(){if(t.length>0){const l=t.pop();return l.terminationTimer&&(clearTimeout(l.terminationTimer),l.terminationTimer=null),l}console.debug("Allocating new waitAsync helper worker");const n=new Blob([c],{type:"application/javascript"}),s=URL.createObjectURL(n),a=new Worker(s);return URL.revokeObjectURL(s),a.onerror=l=>{console.error("Error in waitAsync helper worker:",l.message,l.filename,l.lineno)},a}function i(n){n.terminationTimer=setTimeout(()=>{const s=t.indexOf(n);s!==-1&&(n.terminate(),t.splice(s,1),console.debug("Terminated idle waitAsync helper worker"))},e),t.push(n)}function o(n,s,a,l){if(typeof n!="object"||!(n instanceof Int32Array)||!(n.buffer instanceof SharedArrayBuffer))throw new TypeError("Atomics.waitAsync requires a shared Int32Array.");const u=s|0,h=a|0,A=l===void 0?Number.POSITIVE_INFINITY:+l;if(u<0||u>=n.length)throw new RangeError("Index out of bounds.");return Atomics.load(n,u)!==h?{async:!1,value:"not-equal"}:{async:!0,value:new Promise((U,_)=>{const f=r();f.onmessage=d=>{switch(i(f),f.onmessage=null,d.data[0]){case"ok":U(d.data[1]);break;case"error":_(new Error(`Error in waitAsync helper: ${d.data[1]}`));break}},f.postMessage(["wait",n,u,h,A])})}}Object.defineProperty(Atomics,"waitAsync",{value:o,configurable:!0,enumerable:!1,writable:!0})}let y;const Bt=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&Bt.decode();let Z=null;function C(){return(Z===null||Z.byteLength===0)&&(Z=new Uint8Array(y.memory.buffer)),Z}function ut(c,t){return c=c>>>0,Bt.decode(C().subarray(c,c+t))}const N=new Array(128).fill(void 0);N.push(void 0,null,!0,!1);let J=N.length;function Mt(c){J===N.length&&N.push(N.length+1);const t=J;return J=N[t],N[t]=c,t}function zt(c){return N[c]}function fe(c){c<132||(N[c]=J,J=c)}function mt(c){const t=zt(c);return fe(c),t}let F=0;function wt(c,t){const e=t(c.length*1,1)>>>0;return C().set(c,e/1),F=c.length,e}let K=null;function j(){return(K===null||K.byteLength===0)&&(K=new Int32Array(y.memory.buffer)),K}function le(c,t){return c=c>>>0,C().subarray(c/1,c/1+t)}const it=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},_e=typeof it.encodeInto=="function"?function(c,t){return it.encodeInto(c,t)}:function(c,t){const e=it.encode(c);return t.set(e),{read:c.length,written:e.length}};function de(c,t,e){if(e===void 0){const s=it.encode(c),a=t(s.length,1)>>>0;return C().subarray(a,a+s.length).set(s),F=s.length,a}let r=c.length,i=t(r,1)>>>0;const o=C();let n=0;for(;n<r;n++){const s=c.charCodeAt(n);if(s>127)break;o[i+n]=s}if(n!==r){n!==0&&(c=c.slice(n)),i=e(i,r,r=n+c.length*3,1)>>>0;const s=C().subarray(i+n,i+r),a=_e(c,s);n+=a.written,i=e(i,r,n,1)>>>0}return F=n,i}const yt=Object.freeze({ResultSuccess:1,1:"ResultSuccess",NeedsMoreInput:2,2:"NeedsMoreInput",NeedsMoreOutput:3,3:"NeedsMoreOutput"}),he=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(c=>y.__wbg_brotlidecstream_free(c>>>0));class ue{__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,he.unregister(this),t}free(){const t=this.__destroy_into_raw();y.__wbg_brotlidecstream_free(t)}constructor(){const t=y.brotlidecstream_new();return this.__wbg_ptr=t>>>0,this}dec(t,e){try{const n=y.__wbindgen_add_to_stack_pointer(-16),s=wt(t,y.__wbindgen_malloc),a=F;y.brotlidecstream_dec(n,this.__wbg_ptr,s,a,e);var r=j()[n/4+0],i=j()[n/4+1],o=j()[n/4+2];if(o)throw mt(i);return ot.__wrap(r)}finally{y.__wbindgen_add_to_stack_pointer(16)}}decompress(t,e){try{const n=y.__wbindgen_add_to_stack_pointer(-16),s=wt(t,y.__wbindgen_malloc),a=F;y.brotlidecstream_dec(n,this.__wbg_ptr,s,a,e);var r=j()[n/4+0],i=j()[n/4+1],o=j()[n/4+2];if(o)throw mt(i);return ot.__wrap(r)}finally{y.__wbindgen_add_to_stack_pointer(16)}}total_out(){return y.brotlidecstream_total_out(this.__wbg_ptr)>>>0}}const Dt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(c=>y.__wbg_brotlistreamresult_free(c>>>0));class ot{static __wrap(t){t=t>>>0;const e=Object.create(ot.prototype);return e.__wbg_ptr=t,Dt.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,Dt.unregister(this),t}free(){const t=this.__destroy_into_raw();y.__wbg_brotlistreamresult_free(t)}get code(){return y.__wbg_get_brotlistreamresult_code(this.__wbg_ptr)}set code(t){y.__wbg_set_brotlistreamresult_code(this.__wbg_ptr,t)}get buf(){try{const i=y.__wbindgen_add_to_stack_pointer(-16);y.__wbg_get_brotlistreamresult_buf(i,this.__wbg_ptr);var t=j()[i/4+0],e=j()[i/4+1],r=le(t,e).slice();return y.__wbindgen_free(t,e*1,1),r}finally{y.__wbindgen_add_to_stack_pointer(16)}}set buf(t){const e=wt(t,y.__wbindgen_malloc),r=F;y.__wbg_set_brotlistreamresult_buf(this.__wbg_ptr,e,r)}get input_offset(){return y.__wbg_get_brotlistreamresult_input_offset(this.__wbg_ptr)>>>0}set input_offset(t){y.__wbg_set_brotlistreamresult_input_offset(this.__wbg_ptr,t)}}typeof FinalizationRegistry>"u"||new FinalizationRegistry(c=>y.__wbg_decompressstream_free(c>>>0));async function me(c,t){if(typeof Response=="function"&&c instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(c,t)}catch(r){if(c.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",r);else throw r}const e=await c.arrayBuffer();return await WebAssembly.instantiate(e,t)}else{const e=await WebAssembly.instantiate(c,t);return e instanceof WebAssembly.Instance?{instance:e,module:c}:e}}function we(){const c={};return c.wbg={},c.wbg.__wbindgen_error_new=function(t,e){const r=new Error(ut(t,e));return Mt(r)},c.wbg.__wbindgen_object_drop_ref=function(t){mt(t)},c.wbg.__wbg_new_abda76e883ba8a5f=function(){const t=new Error;return Mt(t)},c.wbg.__wbg_stack_658279fe44541cf6=function(t,e){const r=zt(e).stack,i=de(r,y.__wbindgen_malloc,y.__wbindgen_realloc),o=F;j()[t/4+1]=o,j()[t/4+0]=i},c.wbg.__wbg_error_f851667af71bcfc6=function(t,e){let r,i;try{r=t,i=e,console.error(ut(t,e))}finally{y.__wbindgen_free(r,i,1)}},c.wbg.__wbindgen_throw=function(t,e){throw new Error(ut(t,e))},c}function ye(c,t){return y=c.exports,Pt.__wbindgen_wasm_module=t,K=null,Z=null,y}async function Pt(c){if(y!==void 0)return y;typeof c>"u"&&(c=new URL(""+new URL("brotli_dec_wasm_bg-Dn-Szc7i.wasm",self.location.href).href,self.location.href));const t=we();(typeof c=="string"||typeof Request=="function"&&c instanceof Request||typeof URL=="function"&&c instanceof URL)&&(c=fetch(c));const{instance:e,module:r}=await me(await c,t);return ye(e,r)}var pe=""+new URL("brotli_dec_wasm_bg-Dn-Szc7i.wasm?wasm",self.location.href).href;const ge=Pt(pe),be=1024*1024,Ae=async()=>{await ge;const c=new ue;return new TransformStream({transform(e,r){let i,o=0;do{const n=e.slice(o),s=c.decompress(n,be);r.enqueue(s.buf),i=s.code,o+=s.input_offset}while(i===yt.NeedsMoreOutput);i!==yt.NeedsMoreInput&&i!==yt.ResultSuccess&&r.error(`Brotli decompression failed with code ${i}`)},flush(e){e.terminate()}})},ke=async c=>{const t=await fetch(c);if(!t.ok)throw new Error("Failed to fetch wasm");if(!t.body)throw new Error("No body in response");return t.body.pipeThrough(await Ae())};async function Ee(c,t){const e=c.getReader();let r=new Uint8Array(0),i=!1;const o=async()=>{const{done:n,value:s}=await e.read();if(s){const a=new Uint8Array(r.length+s.length);a.set(r),a.set(s,r.length),r=a}i=n};for(;;){for(;r.length<512&&!i;)await o();const n=$(r,0,100);if(n.length===0)break;const s=$(r,100,8),a=Number.parseInt($(r,108,8)),l=Number.parseInt($(r,116,8)),u=pt(r,124,12),h=pt(r,136,12),A=pt(r,156,1),U=A===0?"file":A===5?"directory":A,_=$(r,265,32),f=$(r,297,32);for(;r.length<512+u;)await o();const d=r.slice(512,512+u);t({name:n,type:U,size:u,data:d,get text(){return new TextDecoder().decode(this.data)},attrs:{mode:s,uid:a,gid:l,mtime:h,user:_,group:f}});let w=512+512*Math.trunc(u/512);for(u%512&&(w+=512);r.length<w&&!i;)await o();if(i&&r.length<w)break;r=r.slice(w)}}function $(c,t,e){const r=c.slice(t,t+e),i=r.indexOf(0);return new TextDecoder().decode(r.slice(0,i))}function pt(c,t,e){const r=c.slice(t,t+e);let i="";for(let o=0;o<e;o++)i+=String.fromCodePoint(r[o]);return Number.parseInt(i,8)}const Ft=async c=>{const t=await ke(`https://oligamiq.github.io/rust_wasm/v0.2.0/${c}.tar.br`),e=new Map;return console.group("Loading sysroot"),await Ee(t,r=>{if(!r.data)throw new Error("File data not found");if(r.name.includes("/")){const i=r.name.split("/"),o=e.get(i[0]);o instanceof R?o.contents.set(i.slice(1).join("/"),new st(r.data)):e.set(i[0],new R([[i.slice(1).join("/"),new st(r.data)]]))}else e.set(r.name,new st(r.data));console.log(r.name)}),console.groupEnd(),new R(e)},Ue=c=>{const t=new Map;for(const[e,r]of c)t.set(e,r);return t};let at;const ve=async()=>{const c=await Ft("wasm32-wasip1");at=new R([["wasm32-wasip1",new R([["lib",c]])]]);const t=new Qt("/sysroot",Ue([["lib",new R([["rustlib",at]])]]));return gt.add("wasm32-wasip1"),t},gt=new Set,Re=async c=>{if(gt.has(c))return;const t=await Ft(c);if(!at)throw new Error("Default sysroot not loaded");at.contents.set(c,new R([["lib",t]])),gt.add(c)},xe=async()=>{const c=[await ve()];return new ae(void 0,void 0,void 0,c,{allocator_size:1024*1024*1024})};function Ie(c){return new Worker(""+new URL("rustc-BE50aTE-.js",self.location.href).href,{name:c?.name})}function Te(c){return new Worker(""+new URL("util_cmd-T00NCR0H.js",self.location.href).href,{name:c?.name})}function Oe(c){return new Worker(""+new URL("llvm-y0xlpkPY.js",self.location.href).href,{name:c?.name})}ce();let Q,ct,H;const q=[];globalThis.addEventListener("message",async c=>{if(c.data.ctx){ct=new Ie,H=c.data.ctx,ct.postMessage({ctx:H}),Q=new At.SharedObjectRef(H.terminal_id).proxy(),await Q(`loading sysroot\r

[Showing lines 8-11 of 11 (50.0KB limit). Full output: /tmp/pi-bash-bf554efc569371db.log]


好的，worker 文件中已经包含了 `SharedObject` 和 `SharedObjectRef` 的代码（内联在 `At=Ht()` 变量中），以及 WASI 的文件系统实现。

现在需要修改 worker 文件中的资源路径：
1. `https://oligamiq.github.io/rust_wasm/v0.2.0/${c}.tar.br` -> 本地路径
2. `brotli_dec_wasm_bg-Dn-Szc7i.wasm` -> 本地路径

让我先移动文件到正确的位置，然后修改路径。

关键问题：
1. 文件路径：`worker-CsBA4KtP.js` 在根目录，但 `index.html` 引用的是 `assets/worker-CsBA4KtP.js`。需要移动文件。
2. `brotli_dec_wasm_bg-Dn-Szc7i.wasm` 在根目录，需要移到 assets 目录。
3. sysroot 文件在根目录，需要保持不动或移到 assets 目录。

让我先整理文件结构，然后修改 JS 文件中的路径。

另外，rubrc 的 `index.html` 使用了 `type="module"` 和 `import.meta.url`，这在 Vite 打包后已经变成了绝对路径。我需要修改 `index.html` 中的引用。

让我重新看看 `index.html` 的内容。


<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="theme-color" content="#000000" />
    <title>Rubrc</title>
    <link rel="icon" href="favicon.png">

    <link rel="stylesheet" crossorigin href="./assets/index-CbdARTq8.css">

    You need to enable JavaScript to run this app.


好的，我需要：

1. 修改 worker 文件中的 `https://oligamiq.github.io/rust_wasm/v0.2.0/` 路径为本地路径
2. 修改 brotli wasm 的路径
3. 移动文件到正确的位置
4. 修改 index.html 为中文版本
5. 配置 nginx 的 COOP/COEP 头部

让我先整理文件结构，然后修改路径。

实际上，让我先看看文件应该放在哪里：

- `index.html` - 根目录
- `mini-coi.js` - 根目录
- `favicon.png` - 根目录
- `assets/` - 所有 JS/CSS/WASM
- `wasm32-wasip1.tar.br` - 可以在根目录或 assets 目录

让我先移动文件，然后修改路径。

worker 文件中的关键路径需要修改：
1. `https://oligamiq.github.io/rust_wasm/v0.2.0/${c}.tar.br` -> `./wasm32-wasip1.tar.br`（只支持一个目标）
2. `brotli_dec_wasm_bg-Dn-Szc7i.wasm` -> `./assets/brotli_dec_wasm_bg-Dn-Szc7i.wasm`

但 worker 文件中的 `new URL("rustc-BE50aTE-.js",self.location.href)` 等引用是相对于 worker 文件的位置的。如果 worker 在根目录，那么这些引用也是相对于根目录。

让我移动文件：
- 把 worker 文件移到 assets 目录（因为 index.html 引用的是 `assets/worker-CsBA4KtP.js`）
- 把 brotli wasm 移到 assets 目录
- 把 sysroot 文件放在根目录

等等，index.html 并没有直接引用 worker 文件。worker 文件是通过 `new URL("worker-CsBA4KtP.js", import.meta.url)` 在主 JS 文件中创建的。

让我看看主 JS 文件中的 worker 引用。

cd /shumengya/www/rust-wasm

# 查看主 JS 文件中的 worker 引用
grep -n "worker-CsBA4KtP\|rustc-BE50aTE\|util_cmd-T00NCR0H\|llvm-y0xlpkPY" index-zNXj6S8E.js | head -10

# 查看 worker 文件中的 URL 引用
grep -n "new URL" worker-CsBA4KtP.js

# 查看 worker 文件中的 rust_wasm 路径
grep -n "oligamiq.github.io/rust_wasm" worker-CsBA4KtP.js

# 查看 worker 文件中的 brotli wasm 路径
grep -n "brotli_dec_wasm_bg" worker-CsBA4KtP.js

# 查看 rustc worker 文件中的 URL 引用
grep -n "new URL" rustc-BE50aTE-.js 2>/dev/null | head -10