/* DVIDIA live workstation worker. MIT. MuJoCo 3.15.0 Apache-2.0. See workstation.third-party.txt. */ var Tl=(async function(y={}){var h,u=y,v=typeof window=="object",m=typeof WorkerGlobalScope<"u",A=typeof process=="object"&&process.versions?.node&&process.type!="renderer",O=!v&&!A&&!m;if(A){let{createRequire:e}=await import("module");var P=e(import.meta.url)}var D=[],B="./this.program",$=(e,r)=>{throw r},W=import.meta.url,Y="";function we(e){return u.locateFile?u.locateFile(e,Y):Y+e}var re,se;if(A){if(!(typeof process=="object"&&process.versions?.node&&process.type!="renderer"))throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");var xe=process.versions.node,Ee=xe.split(".").slice(0,3);if(Ee=Ee[0]*1e4+Ee[1]*100+Ee[2].split("-")[0]*1,Ee<16e4)throw new Error("This emscripten-generated code requires node v16.0.0 (detected v"+xe+")");var ie=P("fs");W.startsWith("file:")&&(Y=P("path").dirname(P("url").fileURLToPath(W))+"/"),se=r=>{r=Qe(r)?new URL(r):r;var t=ie.readFileSync(r);return T(Buffer.isBuffer(t)),t},re=async(r,t=!0)=>{r=Qe(r)?new URL(r):r;var n=ie.readFileSync(r,t?void 0:"utf8");return T(t?Buffer.isBuffer(n):typeof n=="string"),n},process.argv.length>1&&(B=process.argv[1].replace(/\\/g,"/")),D=process.argv.slice(2),$=(r,t)=>{throw process.exitCode=r,t}}else if(O){if(typeof process=="object"&&process.versions?.node&&process.type!="renderer"||typeof window=="object"||typeof WorkerGlobalScope<"u")throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)")}else if(v||m){try{Y=new URL(".",W).href}catch{}if(!(typeof window=="object"||typeof WorkerGlobalScope<"u"))throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");m&&(se=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),re=async e=>{if(Qe(e))return new Promise((t,n)=>{var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="arraybuffer",i.onload=()=>{if(i.status==200||i.status==0&&i.response){t(i.response);return}n(i.status)},i.onerror=n,i.send(null)});var r=await fetch(e,{credentials:"same-origin"});if(r.ok)return r.arrayBuffer();throw new Error(r.status+" : "+r.url)}}else throw new Error("environment detection error");var G=console.log.bind(console),x=console.error.bind(console),he="IDBFS is no longer included by default; build with -lidbfs.js",ue="PROXYFS is no longer included by default; build with -lproxyfs.js",be="WORKERFS is no longer included by default; build with -lworkerfs.js",Ae="FETCHFS is no longer included by default; build with -lfetchfs.js",ur="ICASEFS is no longer included by default; build with -licasefs.js",Bl="JSFILEFS is no longer included by default; build with -ljsfilefs.js",Wl="OPFS is no longer included by default; build with -lopfs.js",zl="NODEFS is no longer included by default; build with -lnodefs.js";T(!O,"shell environment detected but not enabled at build time. Add `shell` to `-sENVIRONMENT` to enable.");var Je;typeof WebAssembly!="object"&&x("no native wasm support detected");var Ke=!1,ct;function T(e,r){e||K("Assertion failed"+(r?": "+r:""))}var Qe=e=>e.startsWith("file://");function Cn(){var e=tt();T((e&3)==0),e==0&&(e+=4),R[e>>2]=34821223,R[e+4>>2]=2310721022,R[0]=1668509029}function jr(){if(!Ke){var e=tt();e==0&&(e+=4);var r=R[e>>2],t=R[e+4>>2];(r!=34821223||t!=2310721022)&&K(`Stack overflow! Stack cookie has been overwritten at ${ze(e)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${ze(t)} ${ze(r)}`),R[0]!=1668509029&&K("Runtime error: The application has corrupted its heap memory area (address zero)!")}}class E extends Error{}class xn extends E{}class Ir extends E{constructor(r){super(r),this.excPtr=r;let t=tn(r);this.name=t[0],this.message=t[1]}}var lt=!0;function Hl(...e){!lt&&typeof lt<"u"||console.warn(...e)}(()=>{var e=new Int16Array(1),r=new Int8Array(e.buffer);if(e[0]=25459,r[0]!==115||r[1]!==99)throw"Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)"})();function dr(e){Object.getOwnPropertyDescriptor(u,e)||Object.defineProperty(u,e,{configurable:!0,set(){K(`Attempt to set \`Module.${e}\` after it has already been processed. This can happen, for example, when code is injected via '--post-js' rather than '--pre-js'`)}})}function J(e){return()=>T(!1,`call to '${e}' via reference taken before Wasm module initialization`)}function Mn(e){Object.getOwnPropertyDescriptor(u,e)&&K(`\`Module.${e}\` was supplied but \`${e}\` not included in INCOMING_MODULE_JS_API`)}function ut(e){return e==="FS_createPath"||e==="FS_createDataFile"||e==="FS_createPreloadedFile"||e==="FS_unlink"||e==="addRunDependency"||e==="FS_createLazyFile"||e==="FS_createDevice"||e==="removeRunDependency"}function dt(e,r){typeof globalThis<"u"&&!Object.getOwnPropertyDescriptor(globalThis,e)&&Object.defineProperty(globalThis,e,{configurable:!0,get(){r()}})}function ft(e,r){dt(e,()=>{Pe(`\`${e}\` is not longer defined by emscripten. ${r}`)})}ft("buffer","Please use HEAP8.buffer or wasmMemory.buffer"),ft("asm","Please use wasmExports instead");function $n(e){dt(e,()=>{var r=`\`${e}\` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line`,t=e;t.startsWith("_")||(t="$"+e),r+=` (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE='${t}')`,ut(e)&&(r+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),Pe(r)}),ht(e)}function ht(e){Object.getOwnPropertyDescriptor(u,e)||Object.defineProperty(u,e,{configurable:!0,get(){var r=`'${e}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;ut(e)&&(r+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),K(r)}})}var vt,Nr,Ze,X,ae,pe,Me,C,R,fr,er,de,_t,rr=!1;function pt(){var e=Ze.buffer;X=new Int8Array(e),pe=new Int16Array(e),ae=new Uint8Array(e),Me=new Uint16Array(e),C=new Int32Array(e),R=new Uint32Array(e),fr=new Float32Array(e),er=new Float64Array(e),de=new BigInt64Array(e),_t=new BigUint64Array(e)}T(typeof Int32Array<"u"&&typeof Float64Array<"u"&&Int32Array.prototype.subarray!=null&&Int32Array.prototype.set!=null,"JS engine does not provide full typed array support");function Rn(){if(u.preRun)for(typeof u.preRun=="function"&&(u.preRun=[u.preRun]);u.preRun.length;)Vn(u.preRun.shift());dr("preRun"),mt(yt)}function On(){T(!rr),rr=!0,jr(),!u.noFSInit&&!a.initialized&&a.init(),Te.init(),Ne.__wasm_call_ctors(),a.ignorePermissions=!1}function Dn(){if(jr(),u.postRun)for(typeof u.postRun=="function"&&(u.postRun=[u.postRun]);u.postRun.length;)Hn(u.postRun.shift());dr("postRun"),mt(gt)}var $e=0,tr=null,We={},Re=null;function Lr(e){$e++,u.monitorRunDependencies?.($e),e?(T(!We[e]),We[e]=1,Re===null&&typeof setInterval<"u"&&(Re=setInterval(()=>{if(Ke){clearInterval(Re),Re=null;return}var r=!1;for(var t in We)r||(r=!0,x("still waiting on run dependencies:")),x(`dependency: ${t}`);r&&x("(end of list)")},1e4))):x("warning: run dependency added without ID")}function hr(e){if($e--,u.monitorRunDependencies?.($e),e?(T(We[e]),delete We[e]):x("warning: run dependency removed without ID"),$e==0&&(Re!==null&&(clearInterval(Re),Re=null),tr)){var r=tr;tr=null,r()}}function K(e){u.onAbort?.(e),e="Aborted("+e+")",x(e),Ke=!0;var r=new WebAssembly.RuntimeError(e);throw Nr?.(r),r}function ce(e,r){return(...t)=>{T(rr,`native function \`${e}\` called before runtime initialization`);var n=Ne[e];return T(n,`exported native function \`${e}\` not found`),T(t.length<=r,`native function \`${e}\` called with ${t.length} args but expects ${r}`),n(...t)}}var nr;function jn(){return u.locateFile?we("mujoco.wasm"):new URL("mujoco.wasm",import.meta.url).href}function In(e){if(e==nr&&Je)return new Uint8Array(Je);if(se)return se(e);throw"both async and sync fetching of the wasm failed"}async function Nn(e){if(!Je)try{var r=await re(e);return new Uint8Array(r)}catch{}return In(e)}async function Ln(e,r){try{var t=await Nn(e),n=await WebAssembly.instantiate(t,r);return n}catch(i){x(`failed to asynchronously prepare wasm: ${i}`),Qe(nr)&&x(`warning: Loading from a file URI (${nr}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`),K(i)}}async function Un(e,r,t){if(!e&&typeof WebAssembly.instantiateStreaming=="function"&&!Qe(r)&&!A)try{var n=fetch(r,{credentials:"same-origin"}),i=await WebAssembly.instantiateStreaming(n,t);return i}catch(o){x(`wasm streaming compile failed: ${o}`),x("falling back to ArrayBuffer instantiation")}return Ln(r,t)}function Bn(){return{env:_n,wasi_snapshot_preview1:_n}}async function Wn(){function e(s,c){return Ne=s.exports,Ze=Ne.memory,T(Ze,"memory not found in wasm exports"),pt(),Ar=Ne.__indirect_function_table,T(Ar,"table not found in wasm exports"),Pa(Ne),hr("wasm-instantiate"),Ne}Lr("wasm-instantiate");var r=u;function t(s){return T(u===r,"the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?"),r=null,e(s.instance)}var n=Bn();if(u.instantiateWasm)return new Promise((s,c)=>{try{u.instantiateWasm(n,(l,d)=>{s(e(l,d))})}catch(l){x(`Module.instantiateWasm callback failed with error: ${l}`),c(l)}});nr??=jn();var i=await Un(Je,nr,n),o=t(i);return o}class zn{name="ExitStatus";constructor(r){this.message=`Program terminated with exit(${r})`,this.status=r}}var mt=e=>{for(;e.length>0;)e.shift()(u)},gt=[],Hn=e=>gt.push(e),yt=[],Vn=e=>yt.push(e);function Vl(e,r="i8"){switch(r.endsWith("*")&&(r="*"),r){case"i1":return X[e];case"i8":return X[e];case"i16":return pe[e>>1];case"i32":return C[e>>2];case"i64":return de[e>>3];case"float":return fr[e>>2];case"double":return er[e>>3];case"*":return R[e>>2];default:K(`invalid type for getValue: ${r}`)}}var wt=!0,ze=e=>(T(typeof e=="number"),e>>>=0,"0x"+e.toString(16).padStart(8,"0"));function Gl(e,r,t="i8"){switch(t.endsWith("*")&&(t="*"),t){case"i1":X[e]=r;break;case"i8":X[e]=r;break;case"i16":pe[e>>1]=r;break;case"i32":C[e>>2]=r;break;case"i64":de[e>>3]=BigInt(r);break;case"float":fr[e>>2]=r;break;case"double":er[e>>3]=r;break;case"*":R[e>>2]=r;break;default:K(`invalid type for setValue: ${t}`)}}var b=e=>ln(e),S=()=>dn(),Pe=e=>{Pe.shown||={},Pe.shown[e]||(Pe.shown[e]=1,A&&(e="warning: "+e),x(e))},Et=typeof TextDecoder<"u"?new TextDecoder:void 0,He=(e,r=0,t=NaN)=>{for(var n=r+t,i=r;e[i]&&!(i>=n);)++i;if(i-r>16&&e.buffer&&Et)return Et.decode(e.subarray(r,i));for(var o="";r>10,56320|d&1023)}}return o},Se=(e,r)=>(T(typeof e=="number",`UTF8ToString expects a number (got ${typeof e})`),e?He(ae,e,r):""),Gn=(e,r,t,n)=>K(`Assertion failed: ${Se(e)}, at: `+[r?Se(r):"unknown filename",t,n?Se(n):"unknown function"]),ke=[],vr=0,qn=e=>{var r=new _r(e);return r.get_caught()||(r.set_caught(!0),vr--),r.set_rethrown(!1),ke.push(r),Rr(e),vn(e)},Yn=()=>{if(!ke.length)return 0;var e=ke[ke.length-1];return Rr(e.excPtr),e.excPtr},Fe=0,Xn=()=>{k(0,0),T(ke.length>0);var e=ke.pop();nt(e.excPtr),Fe=0};class _r{constructor(r){this.excPtr=r,this.ptr=r-24}set_type(r){R[this.ptr+4>>2]=r}get_type(){return R[this.ptr+4>>2]}set_destructor(r){R[this.ptr+8>>2]=r}get_destructor(){return R[this.ptr+8>>2]}set_caught(r){r=r?1:0,X[this.ptr+12]=r}get_caught(){return X[this.ptr+12]!=0}set_rethrown(r){r=r?1:0,X[this.ptr+13]=r}get_rethrown(){return X[this.ptr+13]!=0}init(r,t){this.set_adjusted_ptr(0),this.set_type(r),this.set_destructor(t)}set_adjusted_ptr(r){R[this.ptr+16>>2]=r}get_adjusted_ptr(){return R[this.ptr+16>>2]}}var pr=e=>sn(e),Ur=e=>{var r=Fe?.excPtr;if(!r)return pr(0),0;var t=new _r(r);t.set_adjusted_ptr(r);var n=t.get_type();if(!n)return pr(0),r;for(var i of e){if(i===0||i===n)break;var o=t.ptr+16;if(hn(i,n,o))return pr(i),r}return pr(n),r},Jn=()=>Ur([]),Kn=e=>Ur([e]),Qn=(e,r)=>Ur([e,r]),bt=()=>{var e=ke.pop();e||K("no exception to throw");var r=e.excPtr;throw e.get_rethrown()||(ke.push(e),e.set_rethrown(!0),e.set_caught(!1),vr++),Fe=new Ir(r),Fe},Zn=e=>{if(e){var r=new _r(e);ke.push(r),r.set_rethrown(!0),bt()}},ei=(e,r,t)=>{var n=new _r(e);throw n.init(r,t),Fe=new Ir(e),vr++,Fe},ri=()=>vr,ti=e=>{throw Fe||(Fe=new Ir(e)),Fe},z={isAbs:e=>e.charAt(0)==="/",splitPath:e=>{var r=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return r.exec(e).slice(1)},normalizeArray:(e,r)=>{for(var t=0,n=e.length-1;n>=0;n--){var i=e[n];i==="."?e.splice(n,1):i===".."?(e.splice(n,1),t++):t&&(e.splice(n,1),t--)}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=z.isAbs(e),t=e.slice(-1)==="/";return e=z.normalizeArray(e.split("/").filter(n=>!!n),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=z.splitPath(e),t=r[0],n=r[1];return!t&&!n?".":(n&&(n=n.slice(0,-1)),t+n)},basename:e=>e&&e.match(/([^\/]+|\/)\/*$/)[1],join:(...e)=>z.normalize(e.join("/")),join2:(e,r)=>z.normalize(e+"/"+r)},ni=()=>{if(A){var e=P("crypto");return r=>e.randomFillSync(r)}return r=>crypto.getRandomValues(r)},St=e=>{(St=ni())(e)},Ve={resolve:(...e)=>{for(var r="",t=!1,n=e.length-1;n>=-1&&!t;n--){var i=n>=0?e[n]:a.cwd();if(typeof i!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!i)return"";r=i+"/"+r,t=z.isAbs(i)}return r=z.normalizeArray(r.split("/").filter(o=>!!o),!t).join("/"),(t?"/":"")+r||"."},relative:(e,r)=>{e=Ve.resolve(e).slice(1),r=Ve.resolve(r).slice(1);function t(d){for(var f=0;f=0&&d[_]==="";_--);return f>_?[]:d.slice(f,_-f+1)}for(var n=t(e.split("/")),i=t(r.split("/")),o=Math.min(n.length,i.length),s=o,c=0;c{for(var r=0,t=0;t=55296&&n<=57343?(r+=4,++t):r+=3}return r},kt=(e,r,t,n)=>{if(T(typeof e=="string",`stringToUTF8Array expects a string (got ${typeof e})`),!(n>0))return 0;for(var i=t,o=t+n-1,s=0;s=o)break;r[t++]=c}else if(c<=2047){if(t+1>=o)break;r[t++]=192|c>>6,r[t++]=128|c&63}else if(c<=65535){if(t+2>=o)break;r[t++]=224|c>>12,r[t++]=128|c>>6&63,r[t++]=128|c&63}else{if(t+3>=o)break;c>1114111&&Pe("Invalid Unicode code point "+ze(c)+" encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF)."),r[t++]=240|c>>18,r[t++]=128|c>>12&63,r[t++]=128|c>>6&63,r[t++]=128|c&63,s++}}return r[t]=0,t-i},Wr=(e,r,t)=>{var n=t>0?t:Ge(e)+1,i=new Array(n),o=kt(e,i,0,i.length);return r&&(i.length=o),i},ii=()=>{if(!Br.length){var e=null;if(A){var r=256,t=Buffer.alloc(r),n=0,i=process.stdin.fd;try{n=ie.readSync(i,t,0,r)}catch(o){if(o.toString().includes("EOF"))n=0;else throw o}n>0&&(e=t.slice(0,n).toString("utf-8"))}else typeof window<"u"&&typeof window.prompt=="function"&&(e=window.prompt("Input: "),e!==null&&(e+=` `));if(!e)return null;Br=Wr(e,!0)}return Br.shift()},Te={ttys:[],init(){},shutdown(){},register(e,r){Te.ttys[e]={input:[],output:[],ops:r},a.registerDevice(e,Te.stream_ops)},stream_ops:{open(e){var r=Te.ttys[e.node.rdev];if(!r)throw new a.ErrnoError(43);e.tty=r,e.seekable=!1},close(e){e.tty.ops.fsync(e.tty)},fsync(e){e.tty.ops.fsync(e.tty)},read(e,r,t,n,i){if(!e.tty||!e.tty.ops.get_char)throw new a.ErrnoError(60);for(var o=0,s=0;s0&&(G(He(e.output)),e.output=[])},ioctl_tcgets(e){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(e,r,t){return 0},ioctl_tiocgwinsz(e){return[24,80]}},default_tty1_ops:{put_char(e,r){r===null||r===10?(x(He(e.output)),e.output=[]):r!=0&&e.output.push(r)},fsync(e){e.output?.length>0&&(x(He(e.output)),e.output=[])}}},Ft=e=>{K("internal error: mmapAlloc called but `emscripten_builtin_memalign` native symbol not exported")},j={ops_table:null,mount(e){return j.createNode(null,"/",16895,0)},createNode(e,r,t,n){if(a.isBlkdev(t)||a.isFIFO(t))throw new a.ErrnoError(63);j.ops_table||={dir:{node:{getattr:j.node_ops.getattr,setattr:j.node_ops.setattr,lookup:j.node_ops.lookup,mknod:j.node_ops.mknod,rename:j.node_ops.rename,unlink:j.node_ops.unlink,rmdir:j.node_ops.rmdir,readdir:j.node_ops.readdir,symlink:j.node_ops.symlink},stream:{llseek:j.stream_ops.llseek}},file:{node:{getattr:j.node_ops.getattr,setattr:j.node_ops.setattr},stream:{llseek:j.stream_ops.llseek,read:j.stream_ops.read,write:j.stream_ops.write,mmap:j.stream_ops.mmap,msync:j.stream_ops.msync}},link:{node:{getattr:j.node_ops.getattr,setattr:j.node_ops.setattr,readlink:j.node_ops.readlink},stream:{}},chrdev:{node:{getattr:j.node_ops.getattr,setattr:j.node_ops.setattr},stream:a.chrdev_stream_ops}};var i=a.createNode(e,r,t,n);return a.isDir(i.mode)?(i.node_ops=j.ops_table.dir.node,i.stream_ops=j.ops_table.dir.stream,i.contents={}):a.isFile(i.mode)?(i.node_ops=j.ops_table.file.node,i.stream_ops=j.ops_table.file.stream,i.usedBytes=0,i.contents=null):a.isLink(i.mode)?(i.node_ops=j.ops_table.link.node,i.stream_ops=j.ops_table.link.stream):a.isChrdev(i.mode)&&(i.node_ops=j.ops_table.chrdev.node,i.stream_ops=j.ops_table.chrdev.stream),i.atime=i.mtime=i.ctime=Date.now(),e&&(e.contents[r]=i,e.atime=e.mtime=e.ctime=i.atime),i},getFileDataAsTypedArray(e){return e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0)},expandFileStorage(e,r){var t=e.contents?e.contents.length:0;if(!(t>=r)){var n=1024*1024;r=Math.max(r,t*(t>>0),t!=0&&(r=Math.max(r,256));var i=e.contents;e.contents=new Uint8Array(r),e.usedBytes>0&&e.contents.set(i.subarray(0,e.usedBytes),0)}},resizeFileStorage(e,r){if(e.usedBytes!=r)if(r==0)e.contents=null,e.usedBytes=0;else{var t=e.contents;e.contents=new Uint8Array(r),t&&e.contents.set(t.subarray(0,Math.min(r,e.usedBytes))),e.usedBytes=r}},node_ops:{getattr(e){var r={};return r.dev=a.isChrdev(e.mode)?e.id:1,r.ino=e.id,r.mode=e.mode,r.nlink=1,r.uid=0,r.gid=0,r.rdev=e.rdev,a.isDir(e.mode)?r.size=4096:a.isFile(e.mode)?r.size=e.usedBytes:a.isLink(e.mode)?r.size=e.link.length:r.size=0,r.atime=new Date(e.atime),r.mtime=new Date(e.mtime),r.ctime=new Date(e.ctime),r.blksize=4096,r.blocks=Math.ceil(r.size/r.blksize),r},setattr(e,r){for(let t of["mode","atime","mtime","ctime"])r[t]!=null&&(e[t]=r[t]);r.size!==void 0&&j.resizeFileStorage(e,r.size)},lookup(e,r){throw new a.ErrnoError(44)},mknod(e,r,t,n){return j.createNode(e,r,t,n)},rename(e,r,t){var n;try{n=a.lookupNode(r,t)}catch{}if(n){if(a.isDir(e.mode))for(var i in n.contents)throw new a.ErrnoError(55);a.hashRemoveNode(n)}delete e.parent.contents[e.name],r.contents[t]=e,e.name=t,r.ctime=r.mtime=e.parent.ctime=e.parent.mtime=Date.now()},unlink(e,r){delete e.contents[r],e.ctime=e.mtime=Date.now()},rmdir(e,r){var t=a.lookupNode(e,r);for(var n in t.contents)throw new a.ErrnoError(55);delete e.contents[r],e.ctime=e.mtime=Date.now()},readdir(e){return[".","..",...Object.keys(e.contents)]},symlink(e,r,t){var n=j.createNode(e,r,41471,0);return n.link=t,n},readlink(e){if(!a.isLink(e.mode))throw new a.ErrnoError(28);return e.link}},stream_ops:{read(e,r,t,n,i){var o=e.node.contents;if(i>=e.node.usedBytes)return 0;var s=Math.min(e.node.usedBytes-i,n);if(T(s>=0),s>8&&o.subarray)r.set(o.subarray(i,i+s),t);else for(var c=0;c0||t+r{var r=await re(e);return T(r,`Loading data file "${e}" failed (no arrayBuffer).`),new Uint8Array(r)},Tt=(...e)=>a.createDataFile(...e),ai=e=>{for(var r=e;;){if(!We[e])return e;e=r+Math.random()}},At=[],si=(e,r,t,n)=>{typeof Browser<"u"&&Browser.init();var i=!1;return At.forEach(o=>{i||o.canHandle(r)&&(o.handle(e,r,t,n),i=!0)}),i},Pt=(e,r,t,n,i,o,s,c,l,d)=>{var f=r?Ve.resolve(z.join2(e,r)):e,_=ai(`cp ${f}`);function g(p){function w(M){d?.(),c||Tt(e,r,M,n,i,l),o?.(),hr(_)}si(p,f,w,()=>{s?.(),hr(_)})||w(p)}Lr(_),typeof t=="string"?oi(t).then(g,s):g(t)},ci=e=>{var r={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},t=r[e];if(typeof t>"u")throw new Error(`Unknown file open mode: ${e}`);return t},zr=(e,r)=>{var t=0;return e&&(t|=365),r&&(t|=146),t},li=e=>Se(an(e)),Ct={EPERM:63,ENOENT:44,ESRCH:71,EINTR:27,EIO:29,ENXIO:60,E2BIG:1,ENOEXEC:45,EBADF:8,ECHILD:12,EAGAIN:6,EWOULDBLOCK:6,ENOMEM:48,EACCES:2,EFAULT:21,ENOTBLK:105,EBUSY:10,EEXIST:20,EXDEV:75,ENODEV:43,ENOTDIR:54,EISDIR:31,EINVAL:28,ENFILE:41,EMFILE:33,ENOTTY:59,ETXTBSY:74,EFBIG:22,ENOSPC:51,ESPIPE:70,EROFS:69,EMLINK:34,EPIPE:64,EDOM:18,ERANGE:68,ENOMSG:49,EIDRM:24,ECHRNG:106,EL2NSYNC:156,EL3HLT:107,EL3RST:108,ELNRNG:109,EUNATCH:110,ENOCSI:111,EL2HLT:112,EDEADLK:16,ENOLCK:46,EBADE:113,EBADR:114,EXFULL:115,ENOANO:104,EBADRQC:103,EBADSLT:102,EDEADLOCK:16,EBFONT:101,ENOSTR:100,ENODATA:116,ETIME:117,ENOSR:118,ENONET:119,ENOPKG:120,EREMOTE:121,ENOLINK:47,EADV:122,ESRMNT:123,ECOMM:124,EPROTO:65,EMULTIHOP:36,EDOTDOT:125,EBADMSG:9,ENOTUNIQ:126,EBADFD:127,EREMCHG:128,ELIBACC:129,ELIBBAD:130,ELIBSCN:131,ELIBMAX:132,ELIBEXEC:133,ENOSYS:52,ENOTEMPTY:55,ENAMETOOLONG:37,ELOOP:32,EOPNOTSUPP:138,EPFNOSUPPORT:139,ECONNRESET:15,ENOBUFS:42,EAFNOSUPPORT:5,EPROTOTYPE:67,ENOTSOCK:57,ENOPROTOOPT:50,ESHUTDOWN:140,ECONNREFUSED:14,EADDRINUSE:3,ECONNABORTED:13,ENETUNREACH:40,ENETDOWN:38,ETIMEDOUT:73,EHOSTDOWN:142,EHOSTUNREACH:23,EINPROGRESS:26,EALREADY:7,EDESTADDRREQ:17,EMSGSIZE:35,EPROTONOSUPPORT:66,ESOCKTNOSUPPORT:137,EADDRNOTAVAIL:4,ENETRESET:39,EISCONN:30,ENOTCONN:53,ETOOMANYREFS:141,EUSERS:136,EDQUOT:19,ESTALE:72,ENOTSUP:138,ENOMEDIUM:148,EILSEQ:25,EOVERFLOW:61,ECANCELED:11,ENOTRECOVERABLE:56,EOWNERDEAD:62,ESTRPIPE:135},a={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,filesystems:null,syncFSRequests:0,readFiles:{},ErrnoError:class extends Error{name="ErrnoError";constructor(e){super(rr?li(e):""),this.errno=e;for(var r in Ct)if(Ct[r]===e){this.code=r;break}}},FSStream:class{shared={};get object(){return this.node}set object(e){this.node=e}get isRead(){return(this.flags&2097155)!==1}get isWrite(){return(this.flags&2097155)!==0}get isAppend(){return this.flags&1024}get flags(){return this.shared.flags}set flags(e){this.shared.flags=e}get position(){return this.shared.position}set position(e){this.shared.position=e}},FSNode:class{node_ops={};stream_ops={};readMode=365;writeMode=146;mounted=null;constructor(e,r,t,n){e||(e=this),this.parent=e,this.mount=e.mount,this.id=a.nextInode++,this.name=r,this.mode=t,this.rdev=n,this.atime=this.mtime=this.ctime=Date.now()}get read(){return(this.mode&this.readMode)===this.readMode}set read(e){e?this.mode|=this.readMode:this.mode&=~this.readMode}get write(){return(this.mode&this.writeMode)===this.writeMode}set write(e){e?this.mode|=this.writeMode:this.mode&=~this.writeMode}get isFolder(){return a.isDir(this.mode)}get isDevice(){return a.isChrdev(this.mode)}},lookupPath(e,r={}){if(!e)throw new a.ErrnoError(44);r.follow_mount??=!0,z.isAbs(e)||(e=a.cwd()+"/"+e);e:for(var t=0;t<40;t++){for(var n=e.split("/").filter(d=>!!d),i=a.root,o="/",s=0;s>>0)%a.nameTable.length},hashAddNode(e){var r=a.hashName(e.parent.id,e.name);e.name_next=a.nameTable[r],a.nameTable[r]=e},hashRemoveNode(e){var r=a.hashName(e.parent.id,e.name);if(a.nameTable[r]===e)a.nameTable[r]=e.name_next;else for(var t=a.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next}},lookupNode(e,r){var t=a.mayLookup(e);if(t)throw new a.ErrnoError(t);for(var n=a.hashName(e.id,r),i=a.nameTable[n];i;i=i.name_next){var o=i.name;if(i.parent.id===e.id&&o===r)return i}return a.lookup(e,r)},createNode(e,r,t,n){T(typeof e=="object");var i=new a.FSNode(e,r,t,n);return a.hashAddNode(i),i},destroyNode(e){a.hashRemoveNode(e)},isRoot(e){return e===e.parent},isMountpoint(e){return!!e.mounted},isFile(e){return(e&61440)===32768},isDir(e){return(e&61440)===16384},isLink(e){return(e&61440)===40960},isChrdev(e){return(e&61440)===8192},isBlkdev(e){return(e&61440)===24576},isFIFO(e){return(e&61440)===4096},isSocket(e){return(e&49152)===49152},flagsToPermissionString(e){var r=["r","w","rw"][e&3];return e&512&&(r+="w"),r},nodePermissions(e,r){return a.ignorePermissions?0:r.includes("r")&&!(e.mode&292)||r.includes("w")&&!(e.mode&146)||r.includes("x")&&!(e.mode&73)?2:0},mayLookup(e){if(!a.isDir(e.mode))return 54;var r=a.nodePermissions(e,"x");return r||(e.node_ops.lookup?0:2)},mayCreate(e,r){if(!a.isDir(e.mode))return 54;try{var t=a.lookupNode(e,r);return 20}catch{}return a.nodePermissions(e,"wx")},mayDelete(e,r,t){var n;try{n=a.lookupNode(e,r)}catch(o){return o.errno}var i=a.nodePermissions(e,"wx");if(i)return i;if(t){if(!a.isDir(n.mode))return 54;if(a.isRoot(n)||a.getPath(n)===a.cwd())return 10}else if(a.isDir(n.mode))return 31;return 0},mayOpen(e,r){return e?a.isLink(e.mode)?32:a.isDir(e.mode)&&(a.flagsToPermissionString(r)!=="r"||r&576)?31:a.nodePermissions(e,a.flagsToPermissionString(r)):44},checkOpExists(e,r){if(!e)throw new a.ErrnoError(r);return e},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=a.MAX_OPEN_FDS;e++)if(!a.streams[e])return e;throw new a.ErrnoError(33)},getStreamChecked(e){var r=a.getStream(e);if(!r)throw new a.ErrnoError(8);return r},getStream:e=>a.streams[e],createStream(e,r=-1){return T(r>=-1),e=Object.assign(new a.FSStream,e),r==-1&&(r=a.nextfd()),e.fd=r,a.streams[r]=e,e},closeStream(e){a.streams[e]=null},dupStream(e,r=-1){var t=a.createStream(e,r);return t.stream_ops?.dup?.(t),t},doSetAttr(e,r,t){var n=e?.stream_ops.setattr,i=n?e:r;n??=r.node_ops.setattr,a.checkOpExists(n,63),n(i,t)},chrdev_stream_ops:{open(e){var r=a.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open?.(e)},llseek(){throw new a.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,r)=>e<<8|r,registerDevice(e,r){a.devices[e]={stream_ops:r}},getDevice:e=>a.devices[e],getMounts(e){for(var r=[],t=[e];t.length;){var n=t.pop();r.push(n),t.push(...n.mounts)}return r},syncfs(e,r){typeof e=="function"&&(r=e,e=!1),a.syncFSRequests++,a.syncFSRequests>1&&x(`warning: ${a.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var t=a.getMounts(a.root.mount),n=0;function i(s){return T(a.syncFSRequests>0),a.syncFSRequests--,r(s)}function o(s){if(s)return o.errored?void 0:(o.errored=!0,i(s));++n>=t.length&&i(null)}t.forEach(s=>{if(!s.type.syncfs)return o(null);s.type.syncfs(s,e,o)})},mount(e,r,t){if(typeof e=="string")throw e;var n=t==="/",i=!t,o;if(n&&a.root)throw new a.ErrnoError(10);if(!n&&!i){var s=a.lookupPath(t,{follow_mount:!1});if(t=s.path,o=s.node,a.isMountpoint(o))throw new a.ErrnoError(10);if(!a.isDir(o.mode))throw new a.ErrnoError(54)}var c={type:e,opts:r,mountpoint:t,mounts:[]},l=e.mount(c);return l.mount=c,c.root=l,n?a.root=l:o&&(o.mounted=c,o.mount&&o.mount.mounts.push(c)),l},unmount(e){var r=a.lookupPath(e,{follow_mount:!1});if(!a.isMountpoint(r.node))throw new a.ErrnoError(28);var t=r.node,n=t.mounted,i=a.getMounts(n);Object.keys(a.nameTable).forEach(s=>{for(var c=a.nameTable[s];c;){var l=c.name_next;i.includes(c.mount)&&a.destroyNode(c),c=l}}),t.mounted=null;var o=t.mount.mounts.indexOf(n);T(o!==-1),t.mount.mounts.splice(o,1)},lookup(e,r){return e.node_ops.lookup(e,r)},mknod(e,r,t){var n=a.lookupPath(e,{parent:!0}),i=n.node,o=z.basename(e);if(!o)throw new a.ErrnoError(28);if(o==="."||o==="..")throw new a.ErrnoError(20);var s=a.mayCreate(i,o);if(s)throw new a.ErrnoError(s);if(!i.node_ops.mknod)throw new a.ErrnoError(63);return i.node_ops.mknod(i,o,r,t)},statfs(e){return a.statfsNode(a.lookupPath(e,{follow:!0}).node)},statfsStream(e){return a.statfsNode(e.node)},statfsNode(e){var r={bsize:4096,frsize:4096,blocks:1e6,bfree:5e5,bavail:5e5,files:a.nextInode,ffree:a.nextInode-1,fsid:42,flags:2,namelen:255};return e.node_ops.statfs&&Object.assign(r,e.node_ops.statfs(e.mount.opts.root)),r},create(e,r=438){return r&=4095,r|=32768,a.mknod(e,r,0)},mkdir(e,r=511){return r&=1023,r|=16384,a.mknod(e,r,0)},mkdirTree(e,r){var t=e.split("/"),n="";for(var i of t)if(i){(n||z.isAbs(e))&&(n+="/"),n+=i;try{a.mkdir(n,r)}catch(o){if(o.errno!=20)throw o}}},mkdev(e,r,t){return typeof t>"u"&&(t=r,r=438),r|=8192,a.mknod(e,r,t)},symlink(e,r){if(!Ve.resolve(e))throw new a.ErrnoError(44);var t=a.lookupPath(r,{parent:!0}),n=t.node;if(!n)throw new a.ErrnoError(44);var i=z.basename(r),o=a.mayCreate(n,i);if(o)throw new a.ErrnoError(o);if(!n.node_ops.symlink)throw new a.ErrnoError(63);return n.node_ops.symlink(n,i,e)},rename(e,r){var t=z.dirname(e),n=z.dirname(r),i=z.basename(e),o=z.basename(r),s,c,l;if(s=a.lookupPath(e,{parent:!0}),c=s.node,s=a.lookupPath(r,{parent:!0}),l=s.node,!c||!l)throw new a.ErrnoError(44);if(c.mount!==l.mount)throw new a.ErrnoError(75);var d=a.lookupNode(c,i),f=Ve.relative(e,n);if(f.charAt(0)!==".")throw new a.ErrnoError(28);if(f=Ve.relative(r,t),f.charAt(0)!==".")throw new a.ErrnoError(55);var _;try{_=a.lookupNode(l,o)}catch{}if(d!==_){var g=a.isDir(d.mode),p=a.mayDelete(c,i,g);if(p)throw new a.ErrnoError(p);if(p=_?a.mayDelete(l,o,g):a.mayCreate(l,o),p)throw new a.ErrnoError(p);if(!c.node_ops.rename)throw new a.ErrnoError(63);if(a.isMountpoint(d)||_&&a.isMountpoint(_))throw new a.ErrnoError(10);if(l!==c&&(p=a.nodePermissions(c,"w"),p))throw new a.ErrnoError(p);a.hashRemoveNode(d);try{c.node_ops.rename(d,l,o),d.parent=l}catch(w){throw w}finally{a.hashAddNode(d)}}},rmdir(e){var r=a.lookupPath(e,{parent:!0}),t=r.node,n=z.basename(e),i=a.lookupNode(t,n),o=a.mayDelete(t,n,!0);if(o)throw new a.ErrnoError(o);if(!t.node_ops.rmdir)throw new a.ErrnoError(63);if(a.isMountpoint(i))throw new a.ErrnoError(10);t.node_ops.rmdir(t,n),a.destroyNode(i)},readdir(e){var r=a.lookupPath(e,{follow:!0}),t=r.node,n=a.checkOpExists(t.node_ops.readdir,54);return n(t)},unlink(e){var r=a.lookupPath(e,{parent:!0}),t=r.node;if(!t)throw new a.ErrnoError(44);var n=z.basename(e),i=a.lookupNode(t,n),o=a.mayDelete(t,n,!1);if(o)throw new a.ErrnoError(o);if(!t.node_ops.unlink)throw new a.ErrnoError(63);if(a.isMountpoint(i))throw new a.ErrnoError(10);t.node_ops.unlink(t,n),a.destroyNode(i)},readlink(e){var r=a.lookupPath(e),t=r.node;if(!t)throw new a.ErrnoError(44);if(!t.node_ops.readlink)throw new a.ErrnoError(28);return t.node_ops.readlink(t)},stat(e,r){var t=a.lookupPath(e,{follow:!r}),n=t.node,i=a.checkOpExists(n.node_ops.getattr,63);return i(n)},fstat(e){var r=a.getStreamChecked(e),t=r.node,n=r.stream_ops.getattr,i=n?r:t;return n??=t.node_ops.getattr,a.checkOpExists(n,63),n(i)},lstat(e){return a.stat(e,!0)},doChmod(e,r,t,n){a.doSetAttr(e,r,{mode:t&4095|r.mode&-4096,ctime:Date.now(),dontFollow:n})},chmod(e,r,t){var n;if(typeof e=="string"){var i=a.lookupPath(e,{follow:!t});n=i.node}else n=e;a.doChmod(null,n,r,t)},lchmod(e,r){a.chmod(e,r,!0)},fchmod(e,r){var t=a.getStreamChecked(e);a.doChmod(t,t.node,r,!1)},doChown(e,r,t){a.doSetAttr(e,r,{timestamp:Date.now(),dontFollow:t})},chown(e,r,t,n){var i;if(typeof e=="string"){var o=a.lookupPath(e,{follow:!n});i=o.node}else i=e;a.doChown(null,i,n)},lchown(e,r,t){a.chown(e,r,t,!0)},fchown(e,r,t){var n=a.getStreamChecked(e);a.doChown(n,n.node,!1)},doTruncate(e,r,t){if(a.isDir(r.mode))throw new a.ErrnoError(31);if(!a.isFile(r.mode))throw new a.ErrnoError(28);var n=a.nodePermissions(r,"w");if(n)throw new a.ErrnoError(n);a.doSetAttr(e,r,{size:t,timestamp:Date.now()})},truncate(e,r){if(r<0)throw new a.ErrnoError(28);var t;if(typeof e=="string"){var n=a.lookupPath(e,{follow:!0});t=n.node}else t=e;a.doTruncate(null,t,r)},ftruncate(e,r){var t=a.getStreamChecked(e);if(r<0||(t.flags&2097155)===0)throw new a.ErrnoError(28);a.doTruncate(t,t.node,r)},utime(e,r,t){var n=a.lookupPath(e,{follow:!0}),i=n.node,o=a.checkOpExists(i.node_ops.setattr,63);o(i,{atime:r,mtime:t})},open(e,r,t=438){if(e==="")throw new a.ErrnoError(44);r=typeof r=="string"?ci(r):r,r&64?t=t&4095|32768:t=0;var n,i;if(typeof e=="object")n=e;else{i=e.endsWith("/");var o=a.lookupPath(e,{follow:!(r&131072),noent_okay:!0});n=o.node,e=o.path}var s=!1;if(r&64)if(n){if(r&128)throw new a.ErrnoError(20)}else{if(i)throw new a.ErrnoError(31);n=a.mknod(e,t|511,0),s=!0}if(!n)throw new a.ErrnoError(44);if(a.isChrdev(n.mode)&&(r&=-513),r&65536&&!a.isDir(n.mode))throw new a.ErrnoError(54);if(!s){var c=a.mayOpen(n,r);if(c)throw new a.ErrnoError(c)}r&512&&!s&&a.truncate(n,0),r&=-131713;var l=a.createStream({node:n,path:a.getPath(n),flags:r,seekable:!0,position:0,stream_ops:n.stream_ops,ungotten:[],error:!1});return l.stream_ops.open&&l.stream_ops.open(l),s&&a.chmod(n,t&511),u.logReadFiles&&!(r&1)&&(e in a.readFiles||(a.readFiles[e]=1)),l},close(e){if(a.isClosed(e))throw new a.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(r){throw r}finally{a.closeStream(e.fd)}e.fd=null},isClosed(e){return e.fd===null},llseek(e,r,t){if(a.isClosed(e))throw new a.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new a.ErrnoError(70);if(t!=0&&t!=1&&t!=2)throw new a.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read(e,r,t,n,i){if(T(t>=0),n<0||i<0)throw new a.ErrnoError(28);if(a.isClosed(e))throw new a.ErrnoError(8);if((e.flags&2097155)===1)throw new a.ErrnoError(8);if(a.isDir(e.node.mode))throw new a.ErrnoError(31);if(!e.stream_ops.read)throw new a.ErrnoError(28);var o=typeof i<"u";if(!o)i=e.position;else if(!e.seekable)throw new a.ErrnoError(70);var s=e.stream_ops.read(e,r,t,n,i);return o||(e.position+=s),s},write(e,r,t,n,i,o){if(T(t>=0),n<0||i<0)throw new a.ErrnoError(28);if(a.isClosed(e))throw new a.ErrnoError(8);if((e.flags&2097155)===0)throw new a.ErrnoError(8);if(a.isDir(e.node.mode))throw new a.ErrnoError(31);if(!e.stream_ops.write)throw new a.ErrnoError(28);e.seekable&&e.flags&1024&&a.llseek(e,0,2);var s=typeof i<"u";if(!s)i=e.position;else if(!e.seekable)throw new a.ErrnoError(70);var c=e.stream_ops.write(e,r,t,n,i,o);return s||(e.position+=c),c},mmap(e,r,t,n,i){if((n&2)!==0&&(i&2)===0&&(e.flags&2097155)!==2)throw new a.ErrnoError(2);if((e.flags&2097155)===1)throw new a.ErrnoError(2);if(!e.stream_ops.mmap)throw new a.ErrnoError(43);if(!r)throw new a.ErrnoError(28);return e.stream_ops.mmap(e,r,t,n,i)},msync(e,r,t,n,i){return T(t>=0),e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,i):0},ioctl(e,r,t){if(!e.stream_ops.ioctl)throw new a.ErrnoError(59);return e.stream_ops.ioctl(e,r,t)},readFile(e,r={}){if(r.flags=r.flags||0,r.encoding=r.encoding||"binary",r.encoding!=="utf8"&&r.encoding!=="binary")throw new Error(`Invalid encoding type "${r.encoding}"`);var t=a.open(e,r.flags),n=a.stat(e),i=n.size,o=new Uint8Array(i);return a.read(t,o,0,i,0),r.encoding==="utf8"&&(o=He(o)),a.close(t),o},writeFile(e,r,t={}){t.flags=t.flags||577;var n=a.open(e,t.flags,t.mode);if(typeof r=="string"&&(r=new Uint8Array(Wr(r,!0))),ArrayBuffer.isView(r))a.write(n,r,0,r.byteLength,void 0,t.canOwn);else throw new Error("Unsupported data type");a.close(n)},cwd:()=>a.currentPath,chdir(e){var r=a.lookupPath(e,{follow:!0});if(r.node===null)throw new a.ErrnoError(44);if(!a.isDir(r.node.mode))throw new a.ErrnoError(54);var t=a.nodePermissions(r.node,"x");if(t)throw new a.ErrnoError(t);a.currentPath=r.path},createDefaultDirectories(){a.mkdir("/tmp"),a.mkdir("/home"),a.mkdir("/home/web_user")},createDefaultDevices(){a.mkdir("/dev"),a.registerDevice(a.makedev(1,3),{read:()=>0,write:(n,i,o,s,c)=>s,llseek:()=>0}),a.mkdev("/dev/null",a.makedev(1,3)),Te.register(a.makedev(5,0),Te.default_tty_ops),Te.register(a.makedev(6,0),Te.default_tty1_ops),a.mkdev("/dev/tty",a.makedev(5,0)),a.mkdev("/dev/tty1",a.makedev(6,0));var e=new Uint8Array(1024),r=0,t=()=>(r===0&&(St(e),r=e.byteLength),e[--r]);a.createDevice("/dev","random",t),a.createDevice("/dev","urandom",t),a.mkdir("/dev/shm"),a.mkdir("/dev/shm/tmp")},createSpecialDirectories(){a.mkdir("/proc");var e=a.mkdir("/proc/self");a.mkdir("/proc/self/fd"),a.mount({mount(){var r=a.createNode(e,"fd",16895,73);return r.stream_ops={llseek:j.stream_ops.llseek},r.node_ops={lookup(t,n){var i=+n,o=a.getStreamChecked(i),s={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>o.path},id:i+1};return s.parent=s,s},readdir(){return Array.from(a.streams.entries()).filter(([t,n])=>n).map(([t,n])=>t.toString())}},r}},{},"/proc/self/fd")},createStandardStreams(e,r,t){e?a.createDevice("/dev","stdin",e):a.symlink("/dev/tty","/dev/stdin"),r?a.createDevice("/dev","stdout",null,r):a.symlink("/dev/tty","/dev/stdout"),t?a.createDevice("/dev","stderr",null,t):a.symlink("/dev/tty1","/dev/stderr");var n=a.open("/dev/stdin",0),i=a.open("/dev/stdout",1),o=a.open("/dev/stderr",1);T(n.fd===0,`invalid handle for stdin (${n.fd})`),T(i.fd===1,`invalid handle for stdout (${i.fd})`),T(o.fd===2,`invalid handle for stderr (${o.fd})`)},staticInit(){a.nameTable=new Array(4096),a.mount(j,{},"/"),a.createDefaultDirectories(),a.createDefaultDevices(),a.createSpecialDirectories(),a.filesystems={MEMFS:j}},init(e,r,t){T(!a.initialized,"FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)"),a.initialized=!0,e??=u.stdin,r??=u.stdout,t??=u.stderr,a.createStandardStreams(e,r,t)},quit(){a.initialized=!1,rt(0);for(var e of a.streams)e&&a.close(e)},findObject(e,r){var t=a.analyzePath(e,r);return t.exists?t.object:null},analyzePath(e,r){try{var t=a.lookupPath(e,{follow:!r});e=t.path}catch{}var n={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var t=a.lookupPath(e,{parent:!0});n.parentExists=!0,n.parentPath=t.path,n.parentObject=t.node,n.name=z.basename(e),t=a.lookupPath(e,{follow:!r}),n.exists=!0,n.path=t.path,n.object=t.node,n.name=t.node.name,n.isRoot=t.path==="/"}catch(i){n.error=i.errno}return n},createPath(e,r,t,n){e=typeof e=="string"?e:a.getPath(e);for(var i=r.split("/").reverse();i.length;){var o=i.pop();if(o){var s=z.join2(e,o);try{a.mkdir(s)}catch(c){if(c.errno!=20)throw c}e=s}}return s},createFile(e,r,t,n,i){var o=z.join2(typeof e=="string"?e:a.getPath(e),r),s=zr(n,i);return a.create(o,s)},createDataFile(e,r,t,n,i,o){var s=r;e&&(e=typeof e=="string"?e:a.getPath(e),s=r?z.join2(e,r):e);var c=zr(n,i),l=a.create(s,c);if(t){if(typeof t=="string"){for(var d=new Array(t.length),f=0,_=t.length;f<_;++f)d[f]=t.charCodeAt(f);t=d}a.chmod(l,c|146);var g=a.open(l,577);a.write(g,t,0,t.length,0,o),a.close(g),a.chmod(l,c)}},createDevice(e,r,t,n){var i=z.join2(typeof e=="string"?e:a.getPath(e),r),o=zr(!!t,!!n);a.createDevice.major??=64;var s=a.makedev(a.createDevice.major++,0);return a.registerDevice(s,{open(c){c.seekable=!1},close(c){n?.buffer?.length&&n(10)},read(c,l,d,f,_){for(var g=0,p=0;pthis.length-1||p<0)){var w=p%this.chunkSize,M=p/this.chunkSize|0;return this.getter(M)[w]}}setDataGetter(p){this.getter=p}cacheLength(){var p=new XMLHttpRequest;if(p.open("HEAD",t,!1),p.send(null),!(p.status>=200&&p.status<300||p.status===304))throw new Error("Couldn't load "+t+". Status: "+p.status);var w=Number(p.getResponseHeader("Content-length")),M,L=(M=p.getResponseHeader("Accept-Ranges"))&&M==="bytes",I=(M=p.getResponseHeader("Content-Encoding"))&&M==="gzip",V=1024*1024;L||(V=w);var U=(ee,oe)=>{if(ee>oe)throw new Error("invalid range ("+ee+", "+oe+") or no bytes requested!");if(oe>w-1)throw new Error("only "+w+" bytes available! programmer error!");var H=new XMLHttpRequest;if(H.open("GET",t,!1),w!==V&&H.setRequestHeader("Range","bytes="+ee+"-"+oe),H.responseType="arraybuffer",H.overrideMimeType&&H.overrideMimeType("text/plain; charset=x-user-defined"),H.send(null),!(H.status>=200&&H.status<300||H.status===304))throw new Error("Couldn't load "+t+". Status: "+H.status);return H.response!==void 0?new Uint8Array(H.response||[]):Wr(H.responseText||"",!0)},te=this;te.setDataGetter(ee=>{var oe=ee*V,H=(ee+1)*V-1;if(H=Math.min(H,w-1),typeof te.chunks[ee]>"u"&&(te.chunks[ee]=U(oe,H)),typeof te.chunks[ee]>"u")throw new Error("doXHR failed!");return te.chunks[ee]}),(I||!w)&&(V=w=1,w=this.getter(0).length,V=w,G("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=w,this._chunkSize=V,this.lengthKnown=!0}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(typeof XMLHttpRequest<"u"){if(!m)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var s=new o,c={isDevice:!1,contents:s}}else var c={isDevice:!1,url:t};var l=a.createFile(e,r,c,n,i);c.contents?l.contents=c.contents:c.url&&(l.contents=null,l.url=c.url),Object.defineProperties(l,{usedBytes:{get:function(){return this.contents.length}}});var d={},f=Object.keys(l.stream_ops);f.forEach(g=>{var p=l.stream_ops[g];d[g]=(...w)=>(a.forceLoadFile(l),p(...w))});function _(g,p,w,M,L){var I=g.node.contents;if(L>=I.length)return 0;var V=Math.min(I.length-L,M);if(T(V>=0),I.slice)for(var U=0;U(a.forceLoadFile(l),_(g,p,w,M,L)),d.mmap=(g,p,w,M,L)=>{a.forceLoadFile(l);var I=Ft(p);if(!I)throw new a.ErrnoError(48);return _(g,X,I,p,w),{ptr:I,allocated:!0}},l.stream_ops=d,l},absolutePath(){K("FS.absolutePath has been removed; use PATH_FS.resolve instead")},createFolder(){K("FS.createFolder has been removed; use FS.mkdir instead")},createLink(){K("FS.createLink has been removed; use FS.symlink instead")},joinPath(){K("FS.joinPath has been removed; use PATH.join instead")},mmapAlloc(){K("FS.mmapAlloc has been replaced by the top level function mmapAlloc")},standardizePath(){K("FS.standardizePath has been removed; use PATH.normalize instead")}},q={DEFAULT_POLLMASK:5,calculateAt(e,r,t){if(z.isAbs(r))return r;var n;if(e===-100)n=a.cwd();else{var i=q.getStreamFromFD(e);n=i.path}if(r.length==0){if(!t)throw new a.ErrnoError(44);return n}return n+"/"+r},writeStat(e,r){C[e>>2]=r.dev,C[e+4>>2]=r.mode,R[e+8>>2]=r.nlink,C[e+12>>2]=r.uid,C[e+16>>2]=r.gid,C[e+20>>2]=r.rdev,de[e+24>>3]=BigInt(r.size),C[e+32>>2]=4096,C[e+36>>2]=r.blocks;var t=r.atime.getTime(),n=r.mtime.getTime(),i=r.ctime.getTime();return de[e+40>>3]=BigInt(Math.floor(t/1e3)),R[e+48>>2]=t%1e3*1e3*1e3,de[e+56>>3]=BigInt(Math.floor(n/1e3)),R[e+64>>2]=n%1e3*1e3*1e3,de[e+72>>3]=BigInt(Math.floor(i/1e3)),R[e+80>>2]=i%1e3*1e3*1e3,de[e+88>>3]=BigInt(r.ino),0},writeStatFs(e,r){C[e+4>>2]=r.bsize,C[e+40>>2]=r.bsize,C[e+8>>2]=r.blocks,C[e+12>>2]=r.bfree,C[e+16>>2]=r.bavail,C[e+20>>2]=r.files,C[e+24>>2]=r.ffree,C[e+28>>2]=r.fsid,C[e+44>>2]=r.flags,C[e+36>>2]=r.namelen},doMsync(e,r,t,n,i){if(!a.isFile(r.node.mode))throw new a.ErrnoError(43);if(n&2)return 0;var o=ae.slice(e,e+t);a.msync(r,o,i,t,n)},getStreamFromFD(e){var r=a.getStreamChecked(e);return r},varargs:void 0,getStr(e){var r=Se(e);return r}};function ui(e,r,t){try{var n=q.getStreamFromFD(e);if(T(!t),n.fd===r)return-28;if(r<0||r>=a.MAX_OPEN_FDS)return-8;var i=a.getStream(r);return i&&a.close(i),a.dupStream(n,r).fd}catch(o){if(typeof a>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}var mr=()=>{T(q.varargs!=null);var e=C[+q.varargs>>2];return q.varargs+=4,e},qe=mr;function di(e,r,t){q.varargs=t;try{var n=q.getStreamFromFD(e);switch(r){case 0:{var i=mr();if(i<0)return-28;for(;a.streams[i];)i++;var o;return o=a.dupStream(n,i),o.fd}case 1:case 2:return 0;case 3:return n.flags;case 4:{var i=mr();return n.flags|=i,0}case 12:{var i=qe(),s=0;return pe[i+s>>1]=2,0}case 13:case 14:return 0}return-28}catch(c){if(typeof a>"u"||c.name!=="ErrnoError")throw c;return-c.errno}}function fi(e,r){try{return q.writeStat(r,a.fstat(e))}catch(t){if(typeof a>"u"||t.name!=="ErrnoError")throw t;return-t.errno}}function hi(e,r,t){q.varargs=t;try{var n=q.getStreamFromFD(e);switch(r){case 21509:return n.tty?0:-59;case 21505:{if(!n.tty)return-59;if(n.tty.ops.ioctl_tcgets){var i=n.tty.ops.ioctl_tcgets(n),o=qe();C[o>>2]=i.c_iflag||0,C[o+4>>2]=i.c_oflag||0,C[o+8>>2]=i.c_cflag||0,C[o+12>>2]=i.c_lflag||0;for(var s=0;s<32;s++)X[o+s+17]=i.c_cc[s]||0;return 0}return 0}case 21510:case 21511:case 21512:return n.tty?0:-59;case 21506:case 21507:case 21508:{if(!n.tty)return-59;if(n.tty.ops.ioctl_tcsets){for(var o=qe(),c=C[o>>2],l=C[o+4>>2],d=C[o+8>>2],f=C[o+12>>2],_=[],s=0;s<32;s++)_.push(X[o+s+17]);return n.tty.ops.ioctl_tcsets(n.tty,r,{c_iflag:c,c_oflag:l,c_cflag:d,c_lflag:f,c_cc:_})}return 0}case 21519:{if(!n.tty)return-59;var o=qe();return C[o>>2]=0,0}case 21520:return n.tty?-28:-59;case 21531:{var o=qe();return a.ioctl(n,r,o)}case 21523:{if(!n.tty)return-59;if(n.tty.ops.ioctl_tiocgwinsz){var g=n.tty.ops.ioctl_tiocgwinsz(n.tty),o=qe();pe[o>>1]=g[0],pe[o+2>>1]=g[1]}return 0}case 21524:return n.tty?0:-59;case 21515:return n.tty?0:-59;default:return-28}}catch(p){if(typeof a>"u"||p.name!=="ErrnoError")throw p;return-p.errno}}function vi(e,r){try{return e=q.getStr(e),q.writeStat(r,a.lstat(e))}catch(t){if(typeof a>"u"||t.name!=="ErrnoError")throw t;return-t.errno}}function _i(e,r,t,n){try{r=q.getStr(r);var i=n&256,o=n&4096;return n=n&-6401,T(!n,`unknown flags in __syscall_newfstatat: ${n}`),r=q.calculateAt(e,r,o),q.writeStat(t,i?a.lstat(r):a.stat(r))}catch(s){if(typeof a>"u"||s.name!=="ErrnoError")throw s;return-s.errno}}function pi(e,r,t,n){q.varargs=n;try{r=q.getStr(r),r=q.calculateAt(e,r);var i=n?mr():0;return a.open(r,t,i).fd}catch(o){if(typeof a>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}function mi(e,r){try{return e=q.getStr(e),q.writeStat(r,a.stat(e))}catch(t){if(typeof a>"u"||t.name!=="ErrnoError")throw t;return-t.errno}}var gi=()=>K("native code called abort()"),Z=e=>{for(var r="";;){var t=ae[e++];if(!t)return r;r+=String.fromCharCode(t)}},Ye={},Oe={},gr={},ir=class extends Error{constructor(r){super(r),this.name="BindingError"}},N=e=>{throw new ir(e)};function yi(e,r,t={}){var n=r.name;if(e||N(`type "${n}" must have a positive integer typeid pointer`),Oe.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;N(`Cannot register type '${n}' twice`)}if(Oe[e]=r,delete gr[e],Ye.hasOwnProperty(e)){var i=Ye[e];delete Ye[e],i.forEach(o=>o())}}function fe(e,r,t={}){if(r.argPackAdvance===void 0)throw new TypeError("registerType registeredInstance requires argPackAdvance");return yi(e,r,t)}var xt=(e,r,t)=>{switch(r){case 1:return t?n=>X[n]:n=>ae[n];case 2:return t?n=>pe[n>>1]:n=>Me[n>>1];case 4:return t?n=>C[n>>2]:n=>R[n>>2];case 8:return t?n=>de[n>>3]:n=>_t[n>>3];default:throw new TypeError(`invalid integer width (${r}): ${e}`)}},De=e=>{if(e===null)return"null";var r=typeof e;return r==="object"||r==="array"||r==="function"?e.toString():""+e},Mt=(e,r,t,n)=>{if(rn)throw new TypeError(`Passing a number "${De(r)}" from JS side to C/C++ side to an argument of type "${e}", which is outside the valid range [${t}, ${n}]!`)},wi=(e,r,t,n,i)=>{r=Z(r);let o=n===0n,s=c=>c;if(o){let c=t*8;s=l=>BigInt.asUintN(c,l),i=s(i)}fe(e,{name:r,fromWireType:s,toWireType:(c,l)=>{if(typeof l=="number")l=BigInt(l);else if(typeof l!="bigint")throw new TypeError(`Cannot convert "${De(l)}" to ${this.name}`);return Mt(r,l,n,i),l},argPackAdvance:me,readValueFromPointer:xt(r,t,!o),destructorFunction:null})},me=8,Ei=(e,r,t,n)=>{r=Z(r),fe(e,{name:r,fromWireType:function(i){return!!i},toWireType:function(i,o){return o?t:n},argPackAdvance:me,readValueFromPointer:function(i){return this.fromWireType(ae[i])},destructorFunction:null})},bi=e=>({count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}),Hr=e=>{function r(t){return t.$$.ptrType.registeredClass.name}N(r(e)+" instance already deleted")},Vr=!1,$t=e=>{},Si=e=>{e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)},Rt=e=>{e.count.value-=1;var r=e.count.value===0;r&&Si(e)},Ot=(e,r,t)=>{if(r===t)return e;if(t.baseClass===void 0)return null;var n=Ot(e,r,t.baseClass);return n===null?null:t.downcast(n)},Dt={},ki={},Fi=(e,r)=>{for(r===void 0&&N("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r},Ti=(e,r)=>(r=Fi(e,r),ki[r]),Ai=class extends Error{constructor(r){super(r),this.name="InternalError"}},yr=e=>{throw new Ai(e)},wr=(e,r)=>{(!r.ptrType||!r.ptr)&&yr("makeClassHandle requires ptr and ptrType");var t=!!r.smartPtrType,n=!!r.smartPtr;return t!==n&&yr("Both smartPtrType and smartPtr must be specified"),r.count={value:1},or(Object.create(e,{$$:{value:r,writable:!0}}))};function jt(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=Ti(this.registeredClass,r);if(t!==void 0){if(t.$$.count.value===0)return t.$$.ptr=r,t.$$.smartPtr=e,t.clone();var n=t.clone();return this.destructor(e),n}function i(){return this.isSmartPointer?wr(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):wr(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var o=this.registeredClass.getActualType(r),s=Dt[o];if(!s)return i.call(this);var c;this.isConst?c=s.constPointerType:c=s.pointerType;var l=Ot(r,this.registeredClass,c.registeredClass);return l===null?i.call(this):this.isSmartPointer?wr(c.registeredClass.instancePrototype,{ptrType:c,ptr:l,smartPtrType:this,smartPtr:e}):wr(c.registeredClass.instancePrototype,{ptrType:c,ptr:l})}var or=e=>typeof FinalizationRegistry>"u"?(or=r=>r,e):(Vr=new FinalizationRegistry(r=>{console.warn(r.leakWarning),Rt(r.$$)}),or=r=>{var t=r.$$,n=!!t.smartPtr;if(n){var i={$$:t},o=t.ptrType.registeredClass,s=new Error(`Embind found a leaked C++ instance ${o.name} <${ze(t.ptr)}>. We'll free it automatically in this case, but this functionality is not reliable across various environments. Make sure to invoke .delete() manually once you're done with the instance instead. Originally allocated`);"captureStackTrace"in Error&&Error.captureStackTrace(s,jt),i.leakWarning=s.stack.replace(/^Error: /,""),Vr.register(r,i,r)}return r},$t=r=>Vr.unregister(r),or(e)),Er=[],Pi=()=>{for(;Er.length;){var e=Er.pop();e.$$.deleteScheduled=!1,e.delete()}},It,Ci=()=>{let e=br.prototype;Object.assign(e,{isAliasOf(t){if(!(this instanceof br)||!(t instanceof br))return!1;var n=this.$$.ptrType.registeredClass,i=this.$$.ptr;t.$$=t.$$;for(var o=t.$$.ptrType.registeredClass,s=t.$$.ptr;n.baseClass;)i=n.upcast(i),n=n.baseClass;for(;o.baseClass;)s=o.upcast(s),o=o.baseClass;return n===o&&i===s},clone(){if(this.$$.ptr||Hr(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var t=or(Object.create(Object.getPrototypeOf(this),{$$:{value:bi(this.$$)}}));return t.$$.count.value+=1,t.$$.deleteScheduled=!1,t},delete(){this.$$.ptr||Hr(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&N("Object already scheduled for deletion"),$t(this),Rt(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||Hr(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&N("Object already scheduled for deletion"),Er.push(this),Er.length===1&&It&&It(Pi),this.$$.deleteScheduled=!0,this}});let r=Symbol.dispose;r&&(e[r]=e.delete)};function br(){}var Sr=(e,r)=>Object.defineProperty(r,"name",{value:e}),Gr=(e,r,t)=>{if(e[r].overloadTable===void 0){var n=e[r];e[r]=function(...i){return e[r].overloadTable.hasOwnProperty(i.length)||N(`Function '${t}' called with an invalid number of arguments (${i.length}) - expects one of (${e[r].overloadTable})!`),e[r].overloadTable[i.length].apply(this,i)},e[r].overloadTable=[],e[r].overloadTable[n.argCount]=n}},qr=(e,r,t)=>{u.hasOwnProperty(e)?((t===void 0||u[e].overloadTable!==void 0&&u[e].overloadTable[t]!==void 0)&&N(`Cannot register public name '${e}' twice`),Gr(u,e,e),u[e].overloadTable.hasOwnProperty(t)&&N(`Cannot register multiple overloads of a function with the same number of arguments (${t})!`),u[e].overloadTable[t]=r):(u[e]=r,u[e].argCount=t)},xi=48,Mi=57,$i=e=>{T(typeof e=="string"),e=e.replace(/[^a-zA-Z0-9_]/g,"$");var r=e.charCodeAt(0);return r>=xi&&r<=Mi?`_${e}`:e};function Ri(e,r,t,n,i,o,s,c){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=i,this.getActualType=o,this.upcast=s,this.downcast=c,this.pureVirtualFunctions=[]}var kr=(e,r,t)=>{for(;r!==t;)r.upcast||N(`Expected null or instance of ${t.name}, got an instance of ${r.name}`),e=r.upcast(e),r=r.baseClass;return e};function Oi(e,r){if(r===null)return this.isReference&&N(`null is not a valid ${this.name}`),0;r.$$||N(`Cannot pass "${De(r)}" as a ${this.name}`),r.$$.ptr||N(`Cannot pass deleted object as a pointer of type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=kr(r.$$.ptr,t,this.registeredClass);return n}function Di(e,r){var t;if(r===null)return this.isReference&&N(`null is not a valid ${this.name}`),this.isSmartPointer?(t=this.rawConstructor(),e!==null&&e.push(this.rawDestructor,t),t):0;(!r||!r.$$)&&N(`Cannot pass "${De(r)}" as a ${this.name}`),r.$$.ptr||N(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&r.$$.ptrType.isConst&&N(`Cannot convert argument of type ${r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name} to parameter type ${this.name}`);var n=r.$$.ptrType.registeredClass;if(t=kr(r.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(r.$$.smartPtr===void 0&&N("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:N(`Cannot convert argument of type ${r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:t=r.$$.smartPtr;break;case 2:if(r.$$.smartPtrType===this)t=r.$$.smartPtr;else{var i=r.clone();t=this.rawShare(t,Q.toHandle(()=>i.delete())),e!==null&&e.push(this.rawDestructor,t)}break;default:N("Unsupporting sharing policy")}return t}function ji(e,r){if(r===null)return this.isReference&&N(`null is not a valid ${this.name}`),0;r.$$||N(`Cannot pass "${De(r)}" as a ${this.name}`),r.$$.ptr||N(`Cannot pass deleted object as a pointer of type ${this.name}`),r.$$.ptrType.isConst&&N(`Cannot convert argument of type ${r.$$.ptrType.name} to parameter type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=kr(r.$$.ptr,t,this.registeredClass);return n}function Fr(e){return this.fromWireType(R[e>>2])}var Ii=()=>{Object.assign(Tr.prototype,{getPointee(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e},destructor(e){this.rawDestructor?.(e)},argPackAdvance:me,readValueFromPointer:Fr,fromWireType:jt})};function Tr(e,r,t,n,i,o,s,c,l,d,f){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=i,this.pointeeType=o,this.sharingPolicy=s,this.rawGetPointee=c,this.rawConstructor=l,this.rawShare=d,this.rawDestructor=f,!i&&r.baseClass===void 0?n?(this.toWireType=Oi,this.destructorFunction=null):(this.toWireType=ji,this.destructorFunction=null):this.toWireType=Di}var Nt=(e,r,t)=>{u.hasOwnProperty(e)||yr("Replacing nonexistent public symbol"),u[e].overloadTable!==void 0&&t!==void 0?u[e].overloadTable[t]=r:(u[e]=r,u[e].argCount=t)},Lt=[],Ar,F=e=>{var r=Lt[e];return r||(Lt[e]=r=Ar.get(e)),T(Ar.get(e)==r,"JavaScript-side Wasm function table mirror is out of date!"),r},ge=(e,r,t=!1)=>{T(!t,"Async bindings are only supported with JSPI."),e=Z(e);function n(){var o=F(r);return o}var i=n();return typeof i!="function"&&N(`unknown function pointer with signature ${e}: ${r}`),i};class Ni extends Error{}var Ut=e=>{var r=on(e),t=Z(r);return _e(r),t},je=(e,r)=>{var t=[],n={};function i(o){if(!n[o]&&!Oe[o]){if(gr[o]){gr[o].forEach(i);return}t.push(o),n[o]=!0}}throw r.forEach(i),new Ni(`${e}: `+t.map(Ut).join([", "]))},ve=(e,r,t)=>{e.forEach(c=>gr[c]=r);function n(c){var l=t(c);l.length!==e.length&&yr("Mismatched type converter count");for(var d=0;d{Oe.hasOwnProperty(c)?i[l]=Oe[c]:(o.push(c),Ye.hasOwnProperty(c)||(Ye[c]=[]),Ye[c].push(()=>{i[l]=Oe[c],++s,s===o.length&&n(i)}))}),o.length===0&&n(i)},Li=(e,r,t,n,i,o,s,c,l,d,f,_,g)=>{f=Z(f),o=ge(i,o),c&&=ge(s,c),d&&=ge(l,d),g=ge(_,g);var p=$i(f);qr(p,function(){je(`Cannot construct ${f} due to unbound types`,[n])}),ve([e,r,t],n?[n]:[],w=>{w=w[0];var M,L;n?(M=w.registeredClass,L=M.instancePrototype):L=br.prototype;var I=Sr(f,function(...H){if(Object.getPrototypeOf(this)!==V)throw new ir(`Use 'new' to construct ${f}`);if(U.constructor_body===void 0)throw new ir(`${f} has no accessible constructor`);var Le=U.constructor_body[H.length];if(Le===void 0)throw new ir(`Tried to invoke ctor of ${f} with invalid number of parameters (${H.length}) - expected (${Object.keys(U.constructor_body).toString()}) parameters instead!`);return Le.apply(this,H)}),V=Object.create(L,{constructor:{value:I}});I.prototype=V;var U=new Ri(f,I,V,g,M,o,c,d);U.baseClass&&(U.baseClass.__derivedClasses??=[],U.baseClass.__derivedClasses.push(U));var te=new Tr(f,U,!0,!1,!1),ee=new Tr(f+"*",U,!1,!1,!1),oe=new Tr(f+" const*",U,!1,!0,!1);return Dt[e]={pointerType:ee,constPointerType:oe},Nt(p,I),[te,ee,oe]})},Yr=e=>{for(;e.length;){var r=e.pop(),t=e.pop();t(r)}};function Bt(e){for(var r=1;rt){var o=r==t?r:`${r} to ${t}`;i(`function ${n} called with ${e} arguments, expected ${o}`)}}function Bi(e,r,t,n){var i=Bt(e),o=e.length-2,s=[],c=["fn"];r&&c.push("thisWired");for(var l=0;l=2&&e[t].optional;--t)r--;return r}function Pr(e,r,t,n,i,o){var s=r.length;s<2&&N("argTypes array size mismatch! Must at least get return value and 'this' types!"),T(!o,"Async bindings are only supported with JSPI.");for(var c=r[1]!==null&&t!==null,l=Bt(r),d=r[0].name!=="void",f=s-2,_=Wi(r),g=[e,N,n,i,Yr,r[0],r[1]],p=0;p{for(var t=[],n=0;n>2]);return t},Xr=e=>{e=e.trim();let r=e.indexOf("(");return r===-1?e:(T(e.endsWith(")"),"Parentheses for argument names should match."),e.slice(0,r))},zi=(e,r,t,n,i,o,s,c,l)=>{var d=Cr(t,n);r=Z(r),r=Xr(r),o=ge(i,o,c),ve([],[e],f=>{f=f[0];var _=`${f.name}.${r}`;function g(){je(`Cannot call ${_} due to unbound types`,d)}r.startsWith("@@")&&(r=Symbol[r.substring(2)]);var p=f.registeredClass.constructor;return p[r]===void 0?(g.argCount=t-1,p[r]=g):(Gr(p,r,_),p[r].overloadTable[t-1]=g),ve([],d,w=>{var M=[w[0],null].concat(w.slice(1)),L=Pr(_,M,null,o,s,c);if(p[r].overloadTable===void 0?(L.argCount=t-1,p[r]=L):p[r].overloadTable[t-1]=L,f.registeredClass.__derivedClasses)for(let I of f.registeredClass.__derivedClasses)I.constructor.hasOwnProperty(r)||(I.constructor[r]=L);return[]}),[]})},Hi=(e,r,t,n,i,o)=>{T(r>0);var s=Cr(r,t);i=ge(n,i);var c=[o],l=[];ve([],[e],d=>{d=d[0];var f=`constructor ${d.name}`;if(d.registeredClass.constructor_body===void 0&&(d.registeredClass.constructor_body=[]),d.registeredClass.constructor_body[r-1]!==void 0)throw new ir(`Cannot register multiple constructors with identical number of parameters (${r-1}) for class '${d.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return d.registeredClass.constructor_body[r-1]=()=>{je(`Cannot construct ${d.name} due to unbound types`,s)},ve([],s,_=>(_.splice(1,0,null),d.registeredClass.constructor_body[r-1]=Pr(f,_,null,i,o),[])),[]})},Vi=(e,r,t,n,i,o,s,c,l,d)=>{var f=Cr(t,n);r=Z(r),r=Xr(r),o=ge(i,o,l),ve([],[e],_=>{_=_[0];var g=`${_.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),c&&_.registeredClass.pureVirtualFunctions.push(r);function p(){je(`Cannot call ${g} due to unbound types`,f)}var w=_.registeredClass.instancePrototype,M=w[r];return M===void 0||M.overloadTable===void 0&&M.className!==_.name&&M.argCount===t-2?(p.argCount=t-2,p.className=_.name,w[r]=p):(Gr(w,r,g),w[r].overloadTable[t-2]=p),ve([],f,L=>{var I=Pr(g,L,_,o,s,l);return w[r].overloadTable===void 0?(I.argCount=t-2,w[r]=I):w[r].overloadTable[t-2]=I,[]}),[]})},Wt=(e,r,t)=>(e instanceof Object||N(`${t} with invalid "this": ${e}`),e instanceof r.registeredClass.constructor||N(`${t} incompatible with "this" of type ${e.constructor.name}`),e.$$.ptr||N(`cannot call emscripten binding method ${t} on deleted object`),kr(e.$$.ptr,e.$$.ptrType.registeredClass,r.registeredClass)),Gi=(e,r,t,n,i,o,s,c,l,d)=>{r=Z(r),i=ge(n,i),ve([],[e],f=>{f=f[0];var _=`${f.name}.${r}`,g={get(){je(`Cannot access ${_} due to unbound types`,[t,s])},enumerable:!0,configurable:!0};return l?g.set=()=>je(`Cannot access ${_} due to unbound types`,[t,s]):g.set=p=>N(_+" is a read-only property"),Object.defineProperty(f.registeredClass.instancePrototype,r,g),ve([],l?[t,s]:[t],p=>{var w=p[0],M={get(){var I=Wt(this,f,_+" getter");return w.fromWireType(i(o,I))},enumerable:!0};if(l){l=ge(c,l);var L=p[1];M.set=function(I){var V=Wt(this,f,_+" setter"),U=[];l(d,V,L.toWireType(U,I)),Yr(U)}}return Object.defineProperty(f.registeredClass.instancePrototype,r,M),[]}),[]})},qi=(e,r,t)=>{e=Z(e),ve([],[r],n=>(n=n[0],u[e]=n.fromWireType(t),[]))},zt=[],ye=[0,1,,1,null,1,!0,1,!1,1],Jr=e=>{e>9&&--ye[e+1]===0&&(T(ye[e]!==void 0,"Decref for unallocated handle."),ye[e]=void 0,zt.push(e))},Q={toValue:e=>(e||N(`Cannot use deleted val. handle = ${e}`),T(e===2||ye[e]!==void 0&&e%2===0,`invalid handle: ${e}`),ye[e]),toHandle:e=>{switch(e){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{let r=zt.pop()||ye.length;return ye[r]=e,ye[r+1]=1,r}}}},Ht={name:"emscripten::val",fromWireType:e=>{var r=Q.toValue(e);return Jr(e),r},toWireType:(e,r)=>Q.toHandle(r),argPackAdvance:me,readValueFromPointer:Fr,destructorFunction:null},Vt=e=>fe(e,Ht),Yi=(e,r,t)=>{switch(r){case 1:return t?function(n){return this.fromWireType(X[n])}:function(n){return this.fromWireType(ae[n])};case 2:return t?function(n){return this.fromWireType(pe[n>>1])}:function(n){return this.fromWireType(Me[n>>1])};case 4:return t?function(n){return this.fromWireType(C[n>>2])}:function(n){return this.fromWireType(R[n>>2])};default:throw new TypeError(`invalid integer width (${r}): ${e}`)}},Xi=(e,r,t,n)=>{r=Z(r);function i(){}i.values={},fe(e,{name:r,constructor:i,fromWireType:function(o){return this.constructor.values[o]},toWireType:(o,s)=>s.value,argPackAdvance:me,readValueFromPointer:Yi(r,t,n),destructorFunction:null}),qr(r,i)},ar=(e,r)=>{var t=Oe[e];return t===void 0&&N(`${r} has unknown type ${Ut(e)}`),t},Ji=(e,r,t)=>{var n=ar(e,"enum");r=Z(r);var i=n.constructor,o=Object.create(n.constructor.prototype,{value:{value:t},constructor:{value:Sr(`${n.name}_${r}`,function(){})}});i.values[t]=o,i[r]=o},Ki=(e,r)=>{switch(r){case 4:return function(t){return this.fromWireType(fr[t>>2])};case 8:return function(t){return this.fromWireType(er[t>>3])};default:throw new TypeError(`invalid float width (${r}): ${e}`)}},Qi=(e,r,t)=>{r=Z(r),fe(e,{name:r,fromWireType:n=>n,toWireType:(n,i)=>{if(typeof i!="number"&&typeof i!="boolean")throw new TypeError(`Cannot convert ${De(i)} to ${this.name}`);return i},argPackAdvance:me,readValueFromPointer:Ki(r,t),destructorFunction:null})},Zi=(e,r,t,n,i,o,s,c)=>{var l=Cr(r,t);e=Z(e),e=Xr(e),i=ge(n,i,s),qr(e,function(){je(`Cannot call ${e} due to unbound types`,l)},r-1),ve([],l,d=>{var f=[d[0],null].concat(d.slice(1));return Nt(e,Pr(e,f,null,i,o,s),r-1),[]})},eo=(e,r,t,n,i)=>{r=Z(r);let o=n===0,s=l=>l;if(o){var c=32-8*t;s=l=>l<>>c,i=s(i)}fe(e,{name:r,fromWireType:s,toWireType:(l,d)=>{if(typeof d!="number"&&typeof d!="boolean")throw new TypeError(`Cannot convert "${De(d)}" to ${r}`);return Mt(r,d,n,i),d},argPackAdvance:me,readValueFromPointer:xt(r,t,n!==0),destructorFunction:null})},ro=(e,r,t)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array],i=n[r];function o(s){var c=R[s>>2],l=R[s+4>>2];return new i(X.buffer,l,c)}t=Z(t),fe(e,{name:t,fromWireType:o,argPackAdvance:me,readValueFromPointer:o},{ignoreDuplicateRegistrations:!0})},to=Object.assign({optional:!0},Ht),no=(e,r)=>{fe(e,to)},Ie=(e,r,t)=>(T(typeof t=="number","stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"),kt(e,ae,r,t)),io=(e,r)=>{r=Z(r);var t=!0;fe(e,{name:r,fromWireType(n){var i=R[n>>2],o=n+4,s;if(t)for(var c=o,l=0;l<=i;++l){var d=o+l;if(l==i||ae[d]==0){var f=d-c,_=Se(c,f);s===void 0?s=_:(s+="\0",s+=_),c=d+1}}else{for(var g=new Array(i),l=0;l>2]=o,s)if(t)Ie(i,l,o+1);else for(var d=0;d255&&(_e(c),N("String has UTF-16 code units that do not fit in 8 bits")),ae[l+d]=f}else ae.set(i,l);return n!==null&&n.push(_e,c),c},argPackAdvance:me,readValueFromPointer:Fr,destructorFunction(n){_e(n)}})},Gt=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,oo=(e,r)=>{T(e%2==0,"Pointer passed to UTF16ToString must be aligned to two bytes!");for(var t=e>>1,n=t+r/2,i=t;!(i>=n)&&Me[i];)++i;if(i-t>16&&Gt)return Gt.decode(Me.subarray(t,i));for(var o="",s=t;!(s>=n);++s){var c=Me[s];if(c==0)break;o+=String.fromCharCode(c)}return o},ao=(e,r,t)=>{if(T(r%2==0,"Pointer passed to stringToUTF16 must be aligned to two bytes!"),T(typeof t=="number","stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"),t??=2147483647,t<2)return 0;t-=2;for(var n=r,i=t>1]=s,r+=2}return pe[r>>1]=0,r-n},so=e=>e.length*2,co=(e,r)=>{T(e%4==0,"Pointer passed to UTF32ToString must be aligned to four bytes!");for(var t="",n=0;!(n>=r/4);n++){var i=C[e+n*4>>2];if(!i)break;t+=String.fromCodePoint(i)}return t},lo=(e,r,t)=>{if(T(r%4==0,"Pointer passed to stringToUTF32 must be aligned to four bytes!"),T(typeof t=="number","stringToUTF32(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"),t??=2147483647,t<4)return 0;for(var n=r,i=n+t-4,o=0;o65535&&o++,C[r>>2]=s,r+=4,r+4>i)break}return C[r>>2]=0,r-n},uo=e=>{for(var r=0,t=0;t65535&&t++,r+=4}return r},fo=(e,r,t)=>{t=Z(t);var n,i,o,s;r===2?(n=oo,i=ao,s=so,o=c=>Me[c>>1]):r===4&&(n=co,i=lo,s=uo,o=c=>R[c>>2]),fe(e,{name:t,fromWireType:c=>{for(var l=R[c>>2],d,f=c+4,_=0;_<=l;++_){var g=c+4+_*r;if(_==l||o(g)==0){var p=g-f,w=n(f,p);d===void 0?d=w:(d+="\0",d+=w),f=g+r}}return _e(c),d},toWireType:(c,l)=>{typeof l!="string"&&N(`Cannot pass non-string to C++ string type ${t}`);var d=s(l),f=et(4+d+r);return R[f>>2]=d/r,i(l,f+4,d+r),c!==null&&c.push(_e,f),f},argPackAdvance:me,readValueFromPointer:Fr,destructorFunction(c){_e(c)}})},ho=(e,r)=>{Vt(e)},vo=(e,r)=>{r=Z(r),fe(e,{isVoid:!0,name:r,argPackAdvance:0,fromWireType:()=>{},toWireType:(t,n)=>{}})},_o=()=>{throw new xn},qt=(e,r,t)=>{var n=[],i=e.toWireType(n,t);return n.length&&(R[r>>2]=Q.toHandle(n)),i},po=(e,r,t)=>(e=Q.toValue(e),r=ar(r,"emval::as"),qt(r,t,e)),mo=(e,r)=>(e=Q.toValue(e),r=ar(r,"emval::as"),r.toWireType(null,e)),xr=[],go=(e,r,t,n)=>(e=xr[e],r=Q.toValue(r),e(null,r,t,n)),yo={},Kr=e=>{var r=yo[e];return r===void 0?Z(e):r},wo=(e,r,t,n,i)=>(e=xr[e],r=Q.toValue(r),t=Kr(t),e(r,r[t],n,i)),Yt=()=>globalThis,Eo=e=>e===0?Q.toHandle(Yt()):(e=Kr(e),Q.toHandle(Yt()[e])),bo=e=>{var r=xr.length;return xr.push(e),r},So=(e,r)=>{for(var t=new Array(e),n=0;n>2],`parameter ${n}`);return t},ko=(e,r,t)=>{var n=So(e,r),i=n.shift();e--;var o=`return function (obj, func, destructorsRef, args) { `,s=0,c=[];t===0&&c.push("obj");for(var l=["retType"],d=[i],f=0;fw.name).join(", ")}) => ${i.name}>`;return bo(Sr(p,g))},Fo=(e,r)=>(e=Q.toValue(e),r=Q.toValue(r),Q.toHandle(e[r])),To=e=>{e>9&&(ye[e+1]+=1)},Ao=e=>(e=Q.toValue(e),typeof e=="number"),Po=e=>(e=Q.toValue(e),typeof e=="string"),Co=()=>Q.toHandle([]),xo=e=>Q.toHandle(Kr(e)),Mo=e=>{var r=Q.toValue(e);Yr(r),Jr(e)},$o=(e,r)=>{e=ar(e,"_emval_take_value");var t=e.readValueFromPointer(r);return Q.toHandle(t)},Ro=e=>{throw e=Q.toValue(e),e},Oo=e=>e%4===0&&(e%100!==0||e%400===0),Do=[0,31,60,91,121,152,182,213,244,274,305,335],jo=[0,31,59,90,120,151,181,212,243,273,304,334],Xt=e=>{var r=Oo(e.getFullYear()),t=r?Do:jo,n=t[e.getMonth()]+e.getDate()-1;return n},Io=9007199254740992,No=-9007199254740992,Qr=e=>eIo?NaN:Number(e);function Lo(e,r){e=Qr(e);var t=new Date(e*1e3);C[r>>2]=t.getSeconds(),C[r+4>>2]=t.getMinutes(),C[r+8>>2]=t.getHours(),C[r+12>>2]=t.getDate(),C[r+16>>2]=t.getMonth(),C[r+20>>2]=t.getFullYear()-1900,C[r+24>>2]=t.getDay();var n=Xt(t)|0;C[r+28>>2]=n,C[r+36>>2]=-(t.getTimezoneOffset()*60);var i=new Date(t.getFullYear(),0,1),o=new Date(t.getFullYear(),6,1).getTimezoneOffset(),s=i.getTimezoneOffset(),c=(o!=s&&t.getTimezoneOffset()==Math.min(s,o))|0;C[r+32>>2]=c}var Uo=function(e){var r=(()=>{var t=new Date(C[e+20>>2]+1900,C[e+16>>2],C[e+12>>2],C[e+8>>2],C[e+4>>2],C[e>>2],0),n=C[e+32>>2],i=t.getTimezoneOffset(),o=new Date(t.getFullYear(),0,1),s=new Date(t.getFullYear(),6,1).getTimezoneOffset(),c=o.getTimezoneOffset(),l=Math.min(c,s);if(n<0)C[e+32>>2]=+(s!=c&&l==i);else if(n>0!=(l==i)){var d=Math.max(c,s),f=n>0?l:d;t.setTime(t.getTime()+(f-i)*6e4)}C[e+24>>2]=t.getDay();var _=Xt(t)|0;C[e+28>>2]=_,C[e>>2]=t.getSeconds(),C[e+4>>2]=t.getMinutes(),C[e+8>>2]=t.getHours(),C[e+12>>2]=t.getDate(),C[e+16>>2]=t.getMonth(),C[e+20>>2]=t.getYear();var g=t.getTime();return isNaN(g)?-1:g/1e3})();return BigInt(r)},Bo=(e,r,t,n)=>{var i=new Date().getFullYear(),o=new Date(i,0,1),s=new Date(i,6,1),c=o.getTimezoneOffset(),l=s.getTimezoneOffset(),d=Math.max(c,l);R[e>>2]=d*60,C[r>>2]=+(c!=l);var f=p=>{var w=p>=0?"-":"+",M=Math.abs(p),L=String(Math.floor(M/60)).padStart(2,"0"),I=String(M%60).padStart(2,"0");return`UTC${w}${L}${I}`},_=f(c),g=f(l);T(_),T(g),T(Ge(_)<=16,`timezone name truncated to fit in TZNAME_MAX (${_})`),T(Ge(g)<=16,`timezone name truncated to fit in TZNAME_MAX (${g})`),lperformance.now(),Kt=()=>Date.now(),Wo=1,zo=e=>e>=0&&e<=3;function Ho(e,r,t){if(r=Qr(r),!zo(e))return 28;var n;if(e===0)n=Kt();else if(Wo)n=Jt();else return 52;var i=Math.round(n*1e3*1e3);return de[t>>3]=BigInt(i),0}var Mr=[],Vo=(e,r)=>{T(Array.isArray(Mr)),T(r%16==0),Mr.length=0;for(var t;t=ae[e++];){var n=String.fromCharCode(t),i=["d","f","i","p"];i.push("j"),T(i.includes(n),`Invalid character ${t}("${n}") in readEmAsmArgs! Use only [${i}], and do not specify "v" for void return argument.`);var o=t!=105;o&=t!=112,r+=o&&r%8?4:0,Mr.push(t==112?R[r>>2]:t==106?de[r>>3]:t==105?C[r>>2]:er[r>>3]),r+=o?8:4}return Mr},Go=(e,r,t)=>{var n=Vo(r,t);return T(nn.hasOwnProperty(e),`No EM_ASM constant found at address ${e}. The loaded WebAssembly file is likely out of sync with the generated JavaScript.`),nn[e](...n)},qo=(e,r,t)=>Go(e,r,t),Qt=()=>2147483648,Yo=()=>Qt(),Xo=(e,r)=>(T(r,"alignment argument is required"),Math.ceil(e/r)*r),Jo=e=>{var r=Ze.buffer,t=(e-r.byteLength+65535)/65536|0;try{return Ze.grow(t),pt(),1}catch(n){x(`growMemory: Attempted to grow heap from ${r.byteLength} bytes to ${e} bytes, but got error: ${n}`)}},Ko=e=>{var r=ae.length;e>>>=0,T(e>r);var t=Qt();if(e>t)return x(`Cannot enlarge memory, requested ${e} bytes, but the limit is ${t} bytes!`),!1;for(var n=1;n<=4;n*=2){var i=r*(1+.2/n);i=Math.min(i,e+100663296);var o=Math.min(t,Xo(Math.max(e,i),65536)),s=Jo(o);if(s)return!0}return x(`Failed to grow the heap from ${r} bytes to ${o} bytes, not enough memory!`),!1},Zr={},Qo=()=>B||"./this.program",sr=()=>{if(!sr.strings){var e=(typeof navigator=="object"&&navigator.language||"C").replace("-","_")+".UTF-8",r={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:Qo()};for(var t in Zr)Zr[t]===void 0?delete r[t]:r[t]=Zr[t];var n=[];for(var t in r)n.push(`${t}=${r[t]}`);sr.strings=n}return sr.strings},Zo=(e,r)=>{var t=0,n=0;for(var i of sr()){var o=r+t;R[e+n>>2]=o,t+=Ie(i,o,1/0)+1,n+=4}return 0},ea=(e,r)=>{var t=sr();R[e>>2]=t.length;var n=0;for(var i of t)n+=Ge(i)+1;return R[r>>2]=n,0},Zt=0,en=()=>wt||Zt>0,ra=e=>{ct=e,en()||(u.onExit?.(e),Ke=!0),$(e,new zn(e))},ta=(e,r)=>{if(ct=e,mc(),en()&&!r){var t=`program exited (with status: ${e}), but keepRuntimeAlive() is set (counter=${Zt}) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)`;Nr?.(t),x(t)}ra(e)},na=ta;function ia(e){try{var r=q.getStreamFromFD(e);return a.close(r),0}catch(t){if(typeof a>"u"||t.name!=="ErrnoError")throw t;return t.errno}}var oa=(e,r,t,n)=>{for(var i=0,o=0;o>2],c=R[r+4>>2];r+=8;var l=a.read(e,X,s,c,n);if(l<0)return-1;if(i+=l,l>2]=o,0}catch(s){if(typeof a>"u"||s.name!=="ErrnoError")throw s;return s.errno}}function sa(e,r,t,n){r=Qr(r);try{if(isNaN(r))return 61;var i=q.getStreamFromFD(e);return a.llseek(i,r,t),de[n>>3]=BigInt(i.position),i.getdents&&r===0&&t===0&&(i.getdents=null),0}catch(o){if(typeof a>"u"||o.name!=="ErrnoError")throw o;return o.errno}}var ca=(e,r,t,n)=>{for(var i=0,o=0;o>2],c=R[r+4>>2];r+=8;var l=a.write(e,X,s,c,n);if(l<0)return-1;if(i+=l,l>2]=o,0}catch(s){if(typeof a>"u"||s.name!=="ErrnoError")throw s;return s.errno}}var ua=e=>e,da=e=>{var r=u["_"+e];return T(r,"Cannot call unknown function "+e+", make sure it is exported"),r},fa=(e,r)=>{T(e.length>=0,"writeArrayToMemory array must have a length (should be an array or typed array)"),X.set(e,r)},$r=e=>un(e),ha=e=>{var r=Ge(e)+1,t=$r(r);return Ie(e,t,r),t},rn=(e,r,t,n,i)=>{var o={string:w=>{var M=0;return w!=null&&w!==0&&(M=ha(w)),M},array:w=>{var M=$r(w.length);return fa(w,M),M}};function s(w){return r==="string"?Se(w):r==="boolean"?!!w:w}var c=da(e),l=[],d=0;if(T(r!=="array",'Return type should not be "array".'),n)for(var f=0;f(...i)=>rn(e,r,t,i,n),_a=(...e)=>a.createPath(...e),pa=(...e)=>a.unlink(...e),ma=(...e)=>a.createLazyFile(...e),ga=(...e)=>a.createDevice(...e),ya=e=>Rr(e),wa=e=>nt(e),Ea=e=>{var r=S(),t=$r(4),n=$r(4);fn(e,t,n);var i=R[t>>2],o=R[n>>2],s=Se(i);_e(i);var c;return o&&(c=Se(o),_e(o)),b(r),[s,c]},tn=e=>Ea(e);a.createPreloadedFile=Pt,a.staticInit(),Ci(),Ii(),T(ye.length===10),u.noExitRuntime&&(wt=u.noExitRuntime),u.preloadPlugins&&(At=u.preloadPlugins),u.print&&(G=u.print),u.printErr&&(x=u.printErr),u.wasmBinary&&(Je=u.wasmBinary),ka(),u.arguments&&(D=u.arguments),u.thisProgram&&(B=u.thisProgram),T(typeof u.memoryInitializerPrefixURL>"u","Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead"),T(typeof u.pthreadMainPrefixURL>"u","Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead"),T(typeof u.cdInitializerPrefixURL>"u","Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead"),T(typeof u.filePackagePrefixURL>"u","Module.filePackagePrefixURL option was removed, use Module.locateFile instead"),T(typeof u.read>"u","Module.read option was removed"),T(typeof u.readAsync>"u","Module.readAsync option was removed (modify readAsync in JS)"),T(typeof u.readBinary>"u","Module.readBinary option was removed (modify readBinary in JS)"),T(typeof u.setWindowTitle>"u","Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)"),T(typeof u.TOTAL_MEMORY>"u","Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY"),T(typeof u.ENVIRONMENT>"u","Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)"),T(typeof u.STACK_SIZE>"u","STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time"),T(typeof u.wasmMemory>"u","Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally"),T(typeof u.INITIAL_MEMORY>"u","Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically"),u.addRunDependency=Lr,u.removeRunDependency=hr,u.ccall=rn,u.cwrap=va,u.FS_createPreloadedFile=Pt,u.FS_unlink=pa,u.FS_createPath=_a,u.FS_createDevice=ga,u.FS=a,u.FS_createDataFile=Tt,u.FS_createLazyFile=ma,u.MEMFS=j;var ba=["writeI53ToI64","writeI53ToI64Clamped","writeI53ToI64Signaling","writeI53ToU64Clamped","writeI53ToU64Signaling","readI53FromI64","readI53FromU64","convertI32PairToI53","convertI32PairToI53Checked","convertU32PairToI53","getTempRet0","zeroMemory","withStackSave","inetPton4","inetNtop4","inetPton6","inetNtop6","readSockaddr","writeSockaddr","emscriptenLog","runMainThreadEmAsm","jstoi_q","autoResumeAudioContext","getDynCaller","dynCall","handleException","runtimeKeepalivePush","runtimeKeepalivePop","callUserCallback","maybeExit","asmjsMangle","HandleAllocator","getNativeTypeSize","addOnInit","addOnPostCtor","addOnPreMain","addOnExit","STACK_SIZE","STACK_ALIGN","POINTER_SIZE","ASSERTIONS","uleb128Encode","sigToWasmTypes","generateFuncType","convertJsFunctionToWasm","getEmptyTableSlot","updateTableMap","getFunctionAddress","addFunction","removeFunction","reallyNegative","unSign","strLen","reSign","formatString","intArrayToString","stringToAscii","stringToNewUTF8","registerKeyEventCallback","maybeCStringToJsString","findEventTarget","getBoundingClientRect","fillMouseEventData","registerMouseEventCallback","registerWheelEventCallback","registerUiEventCallback","registerFocusEventCallback","fillDeviceOrientationEventData","registerDeviceOrientationEventCallback","fillDeviceMotionEventData","registerDeviceMotionEventCallback","screenOrientation","fillOrientationChangeEventData","registerOrientationChangeEventCallback","fillFullscreenChangeEventData","registerFullscreenChangeEventCallback","JSEvents_requestFullscreen","JSEvents_resizeCanvasForFullscreen","registerRestoreOldStyle","hideEverythingExceptGivenElement","restoreHiddenElements","setLetterbox","softFullscreenResizeWebGLRenderTarget","doRequestFullscreen","fillPointerlockChangeEventData","registerPointerlockChangeEventCallback","registerPointerlockErrorEventCallback","requestPointerLock","fillVisibilityChangeEventData","registerVisibilityChangeEventCallback","registerTouchEventCallback","fillGamepadEventData","registerGamepadEventCallback","registerBeforeUnloadEventCallback","fillBatteryEventData","battery","registerBatteryEventCallback","setCanvasElementSize","getCanvasElementSize","jsStackTrace","getCallstack","convertPCtoSourceLocation","wasiRightsToMuslOFlags","wasiOFlagsToMuslOFlags","safeSetTimeout","setImmediateWrapped","safeRequestAnimationFrame","clearImmediateWrapped","registerPostMainLoop","registerPreMainLoop","getPromise","makePromise","idsToPromises","makePromiseCallback","Browser_asyncPrepareDataCounter","arraySum","addDays","getSocketFromFD","getSocketAddress","FS_mkdirTree","_setNetworkCallback","heapObjectForWebGLType","toTypedArrayIndex","webgl_enable_ANGLE_instanced_arrays","webgl_enable_OES_vertex_array_object","webgl_enable_WEBGL_draw_buffers","webgl_enable_WEBGL_multi_draw","webgl_enable_EXT_polygon_offset_clamp","webgl_enable_EXT_clip_control","webgl_enable_WEBGL_polygon_mode","emscriptenWebGLGet","computeUnpackAlignedImageSize","colorChannelsInGlTextureFormat","emscriptenWebGLGetTexPixelData","emscriptenWebGLGetUniform","webglGetUniformLocation","webglPrepareUniformLocationsBeforeFirstUse","webglGetLeftBracePos","emscriptenWebGLGetVertexAttrib","__glGetActiveAttribOrUniform","writeGLArray","registerWebGlEventCallback","runAndAbortIfError","ALLOC_NORMAL","ALLOC_STACK","allocate","writeStringToMemory","writeAsciiToMemory","demangle","stackTrace","getFunctionArgsName","createJsInvokerSignature","PureVirtualError","registerInheritedInstance","unregisterInheritedInstance","getInheritedInstanceCount","getLiveInheritedInstances","setDelayFunction","count_emval_handles"];ba.forEach($n);var Sa=["run","out","err","callMain","abort","wasmMemory","wasmExports","HEAPF32","HEAPF64","HEAP8","HEAPU8","HEAP16","HEAPU16","HEAP32","HEAPU32","HEAP64","HEAPU64","writeStackCookie","checkStackCookie","INT53_MAX","INT53_MIN","bigintToI53Checked","stackSave","stackRestore","stackAlloc","setTempRet0","ptrToString","exitJS","getHeapMax","growMemory","ENV","ERRNO_CODES","strError","DNS","Protocols","Sockets","timers","warnOnce","readEmAsmArgsArray","readEmAsmArgs","runEmAsmFunction","getExecutableName","keepRuntimeAlive","asyncLoad","alignMemory","mmapAlloc","wasmTable","getUniqueRunDependency","noExitRuntime","addOnPreRun","addOnPostRun","freeTableIndexes","functionsInTableMap","setValue","getValue","PATH","PATH_FS","UTF8Decoder","UTF8ArrayToString","UTF8ToString","stringToUTF8Array","stringToUTF8","lengthBytesUTF8","intArrayFromString","AsciiToString","UTF16Decoder","UTF16ToString","stringToUTF16","lengthBytesUTF16","UTF32ToString","stringToUTF32","lengthBytesUTF32","stringToUTF8OnStack","writeArrayToMemory","JSEvents","specialHTMLTargets","findCanvasEventTarget","currentFullscreenStrategy","restoreOldWindowedStyle","UNWIND_CACHE","ExitStatus","getEnvStrings","checkWasiClock","doReadv","doWritev","initRandomFill","randomFill","emSetImmediate","emClearImmediate_deps","emClearImmediate","promiseMap","uncaughtExceptionCount","exceptionLast","exceptionCaught","ExceptionInfo","findMatchingCatch","getExceptionMessageCommon","Browser","requestFullscreen","requestFullScreen","setCanvasSize","getUserMedia","createContext","getPreloadedImageData__data","wget","MONTH_DAYS_REGULAR","MONTH_DAYS_LEAP","MONTH_DAYS_REGULAR_CUMULATIVE","MONTH_DAYS_LEAP_CUMULATIVE","isLeapYear","ydayFromDate","SYSCALLS","preloadPlugins","FS_modeStringToFlags","FS_getMode","FS_stdin_getChar_buffer","FS_stdin_getChar","FS_readFile","FS_root","FS_mounts","FS_devices","FS_streams","FS_nextInode","FS_nameTable","FS_currentPath","FS_initialized","FS_ignorePermissions","FS_filesystems","FS_syncFSRequests","FS_readFiles","FS_lookupPath","FS_getPath","FS_hashName","FS_hashAddNode","FS_hashRemoveNode","FS_lookupNode","FS_createNode","FS_destroyNode","FS_isRoot","FS_isMountpoint","FS_isFile","FS_isDir","FS_isLink","FS_isChrdev","FS_isBlkdev","FS_isFIFO","FS_isSocket","FS_flagsToPermissionString","FS_nodePermissions","FS_mayLookup","FS_mayCreate","FS_mayDelete","FS_mayOpen","FS_checkOpExists","FS_nextfd","FS_getStreamChecked","FS_getStream","FS_createStream","FS_closeStream","FS_dupStream","FS_doSetAttr","FS_chrdev_stream_ops","FS_major","FS_minor","FS_makedev","FS_registerDevice","FS_getDevice","FS_getMounts","FS_syncfs","FS_mount","FS_unmount","FS_lookup","FS_mknod","FS_statfs","FS_statfsStream","FS_statfsNode","FS_create","FS_mkdir","FS_mkdev","FS_symlink","FS_rename","FS_rmdir","FS_readdir","FS_readlink","FS_stat","FS_fstat","FS_lstat","FS_doChmod","FS_chmod","FS_lchmod","FS_fchmod","FS_doChown","FS_chown","FS_lchown","FS_fchown","FS_doTruncate","FS_truncate","FS_ftruncate","FS_utime","FS_open","FS_close","FS_isClosed","FS_llseek","FS_read","FS_write","FS_mmap","FS_msync","FS_ioctl","FS_writeFile","FS_cwd","FS_chdir","FS_createDefaultDirectories","FS_createDefaultDevices","FS_createSpecialDirectories","FS_createStandardStreams","FS_staticInit","FS_init","FS_quit","FS_findObject","FS_analyzePath","FS_createFile","FS_forceLoadFile","FS_absolutePath","FS_createFolder","FS_createLink","FS_joinPath","FS_mmapAlloc","FS_standardizePath","TTY","PIPEFS","SOCKFS","tempFixedLengthArray","miniTempWebGLFloatBuffers","miniTempWebGLIntBuffers","GL","AL","GLUT","EGL","GLEW","IDBStore","SDL","SDL_gfx","allocateUTF8","allocateUTF8OnStack","print","printErr","jstoi_s","InternalError","BindingError","throwInternalError","throwBindingError","registeredTypes","awaitingDependencies","typeDependencies","tupleRegistrations","structRegistrations","sharedRegisterType","whenDependentTypesAreResolved","getTypeName","getFunctionName","heap32VectorToArray","requireRegisteredType","usesDestructorStack","checkArgCount","getRequiredArgCount","createJsInvoker","UnboundTypeError","GenericWireTypeSize","EmValType","EmValOptionalType","throwUnboundTypeError","ensureOverloadTable","exposePublicSymbol","replacePublicSymbol","createNamedFunction","embindRepr","registeredInstances","getBasestPointer","getInheritedInstance","registeredPointers","registerType","integerReadValueFromPointer","enumReadValueFromPointer","floatReadValueFromPointer","assertIntegerRange","readPointer","runDestructors","craftInvokerFunction","embind__requireFunction","genericPointerToWireType","constNoSmartPtrRawPointerToWireType","nonConstNoSmartPtrRawPointerToWireType","init_RegisteredPointer","RegisteredPointer","RegisteredPointer_fromWireType","runDestructor","releaseClassHandle","finalizationRegistry","detachFinalizer_deps","detachFinalizer","attachFinalizer","makeClassHandle","init_ClassHandle","ClassHandle","throwInstanceAlreadyDeleted","deletionQueue","flushPendingDeletes","delayFunction","RegisteredClass","shallowCopyInternalPointer","downcastPointer","upcastPointer","validateThis","char_0","char_9","makeLegalFunctionName","emval_freelist","emval_handles","emval_symbols","getStringOrSymbol","Emval","emval_get_global","emval_returnValue","emval_lookupTypes","emval_methodCallers","emval_addMethodCaller"];Sa.forEach(ht),u.incrementExceptionRefcount=ya,u.decrementExceptionRefcount=wa,u.getExceptionMessage=tn;function ka(){Mn("fetchSettings")}var nn={684552:()=>{typeof u<"u"&&"mjDISABLESTRING mjENABLESTRING mjFRAMESTRING mjLABELSTRING mjRNDSTRING mjTIMERSTRING mjVISSTRING".split(" ").forEach(function(e){Object.defineProperty(u,e,{get:function(){return u["get_"+e]()},set:function(r){},enumerable:!0,configurable:!0})})}},on=J("___getTypeName"),et=J("_malloc"),Fa=J("___cxa_free_exception"),rt=J("_fflush"),_e=J("_free"),tt=J("_emscripten_stack_get_end"),Ta=J("_emscripten_stack_get_base"),an=J("_strerror"),k=J("_setThrew"),sn=J("__emscripten_tempret_set"),cn=J("_emscripten_stack_init"),Aa=J("_emscripten_stack_get_free"),ln=J("__emscripten_stack_restore"),un=J("__emscripten_stack_alloc"),dn=J("_emscripten_stack_get_current"),nt=J("___cxa_decrement_exception_refcount"),Rr=J("___cxa_increment_exception_refcount"),fn=J("___get_exception_message"),hn=J("___cxa_can_catch"),vn=J("___cxa_get_exception_ptr");function Pa(e){on=ce("__getTypeName",1),et=ce("malloc",1),Fa=ce("__cxa_free_exception",1),rt=ce("fflush",1),_e=ce("free",1),tt=e.emscripten_stack_get_end,Ta=e.emscripten_stack_get_base,an=ce("strerror",1),k=ce("setThrew",2),sn=ce("_emscripten_tempret_set",1),cn=e.emscripten_stack_init,Aa=e.emscripten_stack_get_free,ln=e._emscripten_stack_restore,un=e._emscripten_stack_alloc,dn=e.emscripten_stack_get_current,nt=ce("__cxa_decrement_exception_refcount",1),Rr=ce("__cxa_increment_exception_refcount",1),fn=ce("__get_exception_message",3),hn=ce("__cxa_can_catch",3),vn=ce("__cxa_get_exception_ptr",1)}var _n={__assert_fail:Gn,__cxa_begin_catch:qn,__cxa_current_primary_exception:Yn,__cxa_end_catch:Xn,__cxa_find_matching_catch_2:Jn,__cxa_find_matching_catch_3:Kn,__cxa_find_matching_catch_4:Qn,__cxa_rethrow:bt,__cxa_rethrow_primary_exception:Zn,__cxa_throw:ei,__cxa_uncaught_exceptions:ri,__resumeException:ti,__syscall_dup3:ui,__syscall_fcntl64:di,__syscall_fstat64:fi,__syscall_ioctl:hi,__syscall_lstat64:vi,__syscall_newfstatat:_i,__syscall_openat:pi,__syscall_stat64:mi,_abort_js:gi,_embind_register_bigint:wi,_embind_register_bool:Ei,_embind_register_class:Li,_embind_register_class_class_function:zi,_embind_register_class_constructor:Hi,_embind_register_class_function:Vi,_embind_register_class_property:Gi,_embind_register_constant:qi,_embind_register_emval:Vt,_embind_register_enum:Xi,_embind_register_enum_value:Ji,_embind_register_float:Qi,_embind_register_function:Zi,_embind_register_integer:eo,_embind_register_memory_view:ro,_embind_register_optional:no,_embind_register_std_string:io,_embind_register_std_wstring:fo,_embind_register_user_type:ho,_embind_register_void:vo,_emscripten_throw_longjmp:_o,_emval_as:po,_emval_as_int64:mo,_emval_call:go,_emval_call_method:wo,_emval_decref:Jr,_emval_get_global:Eo,_emval_get_method_caller:ko,_emval_get_property:Fo,_emval_incref:To,_emval_is_number:Ao,_emval_is_string:Po,_emval_new_array:Co,_emval_new_cstring:xo,_emval_run_destructors:Mo,_emval_take_value:$o,_emval_throw:Ro,_localtime_js:Lo,_mktime_js:Uo,_tzset_js:Bo,clock_time_get:Ho,emscripten_asm_const_int:qo,emscripten_date_now:Kt,emscripten_get_heap_max:Yo,emscripten_get_now:Jt,emscripten_resize_heap:Ko,environ_get:Zo,environ_sizes_get:ea,exit:na,fd_close:ia,fd_read:aa,fd_seek:sa,fd_write:la,invoke_ddd:tc,invoke_dddi:ys,invoke_dddidi:ws,invoke_ddidi:gs,invoke_di:Es,invoke_dii:ls,invoke_diii:za,invoke_diiii:ms,invoke_diiiidd:_s,invoke_diiiidi:Ga,invoke_diiiii:Ia,invoke_diiiiii:Qa,invoke_diiiiiii:bs,invoke_diiiiiiiii:Ja,invoke_diiiiiiiiiiii:Ka,invoke_fiii:hc,invoke_i:Na,invoke_id:Bs,invoke_ii:Ma,invoke_iid:$s,invoke_iidddd:sc,invoke_iidiii:as,invoke_iidiiid:is,invoke_iidiiiiidi:ss,invoke_iif:ac,invoke_iii:Ca,invoke_iiid:cs,invoke_iiididdddddd:os,invoke_iiidiiiiiiii:ns,invoke_iiii:Oa,invoke_iiiidddiiiii:ks,invoke_iiiii:Wa,invoke_iiiiid:zs,invoke_iiiiii:Is,invoke_iiiiiii:Os,invoke_iiiiiiii:Ms,invoke_iiiiiiiidd:Hs,invoke_iiiiiiiii:vs,invoke_iiiiiiiiii:Ds,invoke_iiiiiiiiiidddiiiiiiiii:ts,invoke_iiiiiiiiiii:fc,invoke_iiiiiiiiiiii:vc,invoke_iiiiiiiiiiiii:Xs,invoke_iiij:js,invoke_iiji:Ws,invoke_j:uc,invoke_ji:ec,invoke_jiiii:Ns,invoke_jij:rc,invoke_v:Ra,invoke_vi:$a,invoke_vid:Rs,invoke_viddd:Ls,invoke_vidddd:Us,invoke_vidi:ps,invoke_vidiii:es,invoke_vii:ja,invoke_viid:fs,invoke_viiddi:Ys,invoke_viiddidi:qs,invoke_viiddii:Ss,invoke_viidi:ds,invoke_viidii:Va,invoke_viidiii:Cs,invoke_viidiiid:As,invoke_viidiiiii:rs,invoke_viidiiiiidi:xs,invoke_viidiiiiiiii:Za,invoke_viii:xa,invoke_viiid:Ya,invoke_viiidd:Gs,invoke_viiidi:us,invoke_viiididdddddd:Ps,invoke_viiidiiiiiiii:Ts,invoke_viiii:Ua,invoke_viiiiddd:Vs,invoke_viiiidi:nc,invoke_viiiifi:ic,invoke_viiiii:Da,invoke_viiiiid:qa,invoke_viiiiii:La,invoke_viiiiiii:Ha,invoke_viiiiiiii:hs,invoke_viiiiiiiiii:Qs,invoke_viiiiiiiiiidddiiiiiiiii:Fs,invoke_viiiiiiiiiiid:Xa,invoke_viiiiiiiiiiiii:Ks,invoke_viiiiiiiiiiiiiii:_c,invoke_viiiiiiiiiiiiiiiiii:Zs,invoke_viiiij:cc,invoke_viiij:Ba,invoke_viij:lc,invoke_viijii:dc,invoke_vij:oc,invoke_vijjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj:Js,llvm_eh_typeid_for:ua},Ne=await Wn();function Ca(e,r,t){var n=S();try{return F(e)(r,t)}catch(i){if(b(n),!(i instanceof E))throw i;k(1,0)}}function xa(e,r,t,n){var i=S();try{F(e)(r,t,n)}catch(o){if(b(i),!(o instanceof E))throw o;k(1,0)}}function Ma(e,r){var t=S();try{return F(e)(r)}catch(n){if(b(t),!(n instanceof E))throw n;k(1,0)}}function $a(e,r){var t=S();try{F(e)(r)}catch(n){if(b(t),!(n instanceof E))throw n;k(1,0)}}function Ra(e){var r=S();try{F(e)()}catch(t){if(b(r),!(t instanceof E))throw t;k(1,0)}}function Oa(e,r,t,n){var i=S();try{return F(e)(r,t,n)}catch(o){if(b(i),!(o instanceof E))throw o;k(1,0)}}function Da(e,r,t,n,i,o){var s=S();try{F(e)(r,t,n,i,o)}catch(c){if(b(s),!(c instanceof E))throw c;k(1,0)}}function ja(e,r,t){var n=S();try{F(e)(r,t)}catch(i){if(b(n),!(i instanceof E))throw i;k(1,0)}}function Ia(e,r,t,n,i,o){var s=S();try{return F(e)(r,t,n,i,o)}catch(c){if(b(s),!(c instanceof E))throw c;k(1,0)}}function Na(e){var r=S();try{return F(e)()}catch(t){if(b(r),!(t instanceof E))throw t;k(1,0)}}function La(e,r,t,n,i,o,s){var c=S();try{F(e)(r,t,n,i,o,s)}catch(l){if(b(c),!(l instanceof E))throw l;k(1,0)}}function Ua(e,r,t,n,i){var o=S();try{F(e)(r,t,n,i)}catch(s){if(b(o),!(s instanceof E))throw s;k(1,0)}}function Ba(e,r,t,n,i){var o=S();try{F(e)(r,t,n,i)}catch(s){if(b(o),!(s instanceof E))throw s;k(1,0)}}function Wa(e,r,t,n,i){var o=S();try{return F(e)(r,t,n,i)}catch(s){if(b(o),!(s instanceof E))throw s;k(1,0)}}function za(e,r,t,n){var i=S();try{return F(e)(r,t,n)}catch(o){if(b(i),!(o instanceof E))throw o;k(1,0)}}function Ha(e,r,t,n,i,o,s,c){var l=S();try{F(e)(r,t,n,i,o,s,c)}catch(d){if(b(l),!(d instanceof E))throw d;k(1,0)}}function Va(e,r,t,n,i,o){var s=S();try{F(e)(r,t,n,i,o)}catch(c){if(b(s),!(c instanceof E))throw c;k(1,0)}}function Ga(e,r,t,n,i,o,s){var c=S();try{return F(e)(r,t,n,i,o,s)}catch(l){if(b(c),!(l instanceof E))throw l;k(1,0)}}function qa(e,r,t,n,i,o,s){var c=S();try{F(e)(r,t,n,i,o,s)}catch(l){if(b(c),!(l instanceof E))throw l;k(1,0)}}function Ya(e,r,t,n,i){var o=S();try{F(e)(r,t,n,i)}catch(s){if(b(o),!(s instanceof E))throw s;k(1,0)}}function Xa(e,r,t,n,i,o,s,c,l,d,f,_,g){var p=S();try{F(e)(r,t,n,i,o,s,c,l,d,f,_,g)}catch(w){if(b(p),!(w instanceof E))throw w;k(1,0)}}function Ja(e,r,t,n,i,o,s,c,l,d){var f=S();try{return F(e)(r,t,n,i,o,s,c,l,d)}catch(_){if(b(f),!(_ instanceof E))throw _;k(1,0)}}function Ka(e,r,t,n,i,o,s,c,l,d,f,_,g){var p=S();try{return F(e)(r,t,n,i,o,s,c,l,d,f,_,g)}catch(w){if(b(p),!(w instanceof E))throw w;k(1,0)}}function Qa(e,r,t,n,i,o,s){var c=S();try{return F(e)(r,t,n,i,o,s)}catch(l){if(b(c),!(l instanceof E))throw l;k(1,0)}}function Za(e,r,t,n,i,o,s,c,l,d,f,_){var g=S();try{F(e)(r,t,n,i,o,s,c,l,d,f,_)}catch(p){if(b(g),!(p instanceof E))throw p;k(1,0)}}function es(e,r,t,n,i,o){var s=S();try{F(e)(r,t,n,i,o)}catch(c){if(b(s),!(c instanceof E))throw c;k(1,0)}}function rs(e,r,t,n,i,o,s,c,l){var d=S();try{F(e)(r,t,n,i,o,s,c,l)}catch(f){if(b(d),!(f instanceof E))throw f;k(1,0)}}function ts(e,r,t,n,i,o,s,c,l,d,f,_,g,p,w,M,L,I,V,U,te,ee){var oe=S();try{return F(e)(r,t,n,i,o,s,c,l,d,f,_,g,p,w,M,L,I,V,U,te,ee)}catch(H){if(b(oe),!(H instanceof E))throw H;k(1,0)}}function ns(e,r,t,n,i,o,s,c,l,d,f,_){var g=S();try{return F(e)(r,t,n,i,o,s,c,l,d,f,_)}catch(p){if(b(g),!(p instanceof E))throw p;k(1,0)}}function is(e,r,t,n,i,o,s){var c=S();try{return F(e)(r,t,n,i,o,s)}catch(l){if(b(c),!(l instanceof E))throw l;k(1,0)}}function os(e,r,t,n,i,o,s,c,l,d,f,_){var g=S();try{return F(e)(r,t,n,i,o,s,c,l,d,f,_)}catch(p){if(b(g),!(p instanceof E))throw p;k(1,0)}}function as(e,r,t,n,i,o){var s=S();try{return F(e)(r,t,n,i,o)}catch(c){if(b(s),!(c instanceof E))throw c;k(1,0)}}function ss(e,r,t,n,i,o,s,c,l,d){var f=S();try{return F(e)(r,t,n,i,o,s,c,l,d)}catch(_){if(b(f),!(_ instanceof E))throw _;k(1,0)}}function cs(e,r,t,n){var i=S();try{return F(e)(r,t,n)}catch(o){if(b(i),!(o instanceof E))throw o;k(1,0)}}function ls(e,r,t){var n=S();try{return F(e)(r,t)}catch(i){if(b(n),!(i instanceof E))throw i;k(1,0)}}function us(e,r,t,n,i,o){var s=S();try{F(e)(r,t,n,i,o)}catch(c){if(b(s),!(c instanceof E))throw c;k(1,0)}}function ds(e,r,t,n,i){var o=S();try{F(e)(r,t,n,i)}catch(s){if(b(o),!(s instanceof E))throw s;k(1,0)}}function fs(e,r,t,n){var i=S();try{F(e)(r,t,n)}catch(o){if(b(i),!(o instanceof E))throw o;k(1,0)}}function hs(e,r,t,n,i,o,s,c,l){var d=S();try{F(e)(r,t,n,i,o,s,c,l)}catch(f){if(b(d),!(f instanceof E))throw f;k(1,0)}}function vs(e,r,t,n,i,o,s,c,l){var d=S();try{return F(e)(r,t,n,i,o,s,c,l)}catch(f){if(b(d),!(f instanceof E))throw f;k(1,0)}}function _s(e,r,t,n,i,o,s){var c=S();try{return F(e)(r,t,n,i,o,s)}catch(l){if(b(c),!(l instanceof E))throw l;k(1,0)}}function ps(e,r,t,n){var i=S();try{F(e)(r,t,n)}catch(o){if(b(i),!(o instanceof E))throw o;k(1,0)}}function ms(e,r,t,n,i){var o=S();try{return F(e)(r,t,n,i)}catch(s){if(b(o),!(s instanceof E))throw s;k(1,0)}}function gs(e,r,t,n,i){var o=S();try{return F(e)(r,t,n,i)}catch(s){if(b(o),!(s instanceof E))throw s;k(1,0)}}function ys(e,r,t,n){var i=S();try{return F(e)(r,t,n)}catch(o){if(b(i),!(o instanceof E))throw o;k(1,0)}}function ws(e,r,t,n,i,o){var s=S();try{return F(e)(r,t,n,i,o)}catch(c){if(b(s),!(c instanceof E))throw c;k(1,0)}}function Es(e,r){var t=S();try{return F(e)(r)}catch(n){if(b(t),!(n instanceof E))throw n;k(1,0)}}function bs(e,r,t,n,i,o,s,c){var l=S();try{return F(e)(r,t,n,i,o,s,c)}catch(d){if(b(l),!(d instanceof E))throw d;k(1,0)}}function Ss(e,r,t,n,i,o,s){var c=S();try{F(e)(r,t,n,i,o,s)}catch(l){if(b(c),!(l instanceof E))throw l;k(1,0)}}function ks(e,r,t,n,i,o,s,c,l,d,f,_){var g=S();try{return F(e)(r,t,n,i,o,s,c,l,d,f,_)}catch(p){if(b(g),!(p instanceof E))throw p;k(1,0)}}function Fs(e,r,t,n,i,o,s,c,l,d,f,_,g,p,w,M,L,I,V,U,te,ee,oe){var H=S();try{F(e)(r,t,n,i,o,s,c,l,d,f,_,g,p,w,M,L,I,V,U,te,ee,oe)}catch(Le){if(b(H),!(Le instanceof E))throw Le;k(1,0)}}function Ts(e,r,t,n,i,o,s,c,l,d,f,_,g){var p=S();try{F(e)(r,t,n,i,o,s,c,l,d,f,_,g)}catch(w){if(b(p),!(w instanceof E))throw w;k(1,0)}}function As(e,r,t,n,i,o,s,c){var l=S();try{F(e)(r,t,n,i,o,s,c)}catch(d){if(b(l),!(d instanceof E))throw d;k(1,0)}}function Ps(e,r,t,n,i,o,s,c,l,d,f,_,g){var p=S();try{F(e)(r,t,n,i,o,s,c,l,d,f,_,g)}catch(w){if(b(p),!(w instanceof E))throw w;k(1,0)}}function Cs(e,r,t,n,i,o,s){var c=S();try{F(e)(r,t,n,i,o,s)}catch(l){if(b(c),!(l instanceof E))throw l;k(1,0)}}function xs(e,r,t,n,i,o,s,c,l,d,f){var _=S();try{F(e)(r,t,n,i,o,s,c,l,d,f)}catch(g){if(b(_),!(g instanceof E))throw g;k(1,0)}}function Ms(e,r,t,n,i,o,s,c){var l=S();try{return F(e)(r,t,n,i,o,s,c)}catch(d){if(b(l),!(d instanceof E))throw d;k(1,0)}}function $s(e,r,t){var n=S();try{return F(e)(r,t)}catch(i){if(b(n),!(i instanceof E))throw i;k(1,0)}}function Rs(e,r,t){var n=S();try{F(e)(r,t)}catch(i){if(b(n),!(i instanceof E))throw i;k(1,0)}}function Os(e,r,t,n,i,o,s){var c=S();try{return F(e)(r,t,n,i,o,s)}catch(l){if(b(c),!(l instanceof E))throw l;k(1,0)}}function Ds(e,r,t,n,i,o,s,c,l,d){var f=S();try{return F(e)(r,t,n,i,o,s,c,l,d)}catch(_){if(b(f),!(_ instanceof E))throw _;k(1,0)}}function js(e,r,t,n){var i=S();try{return F(e)(r,t,n)}catch(o){if(b(i),!(o instanceof E))throw o;k(1,0)}}function Is(e,r,t,n,i,o){var s=S();try{return F(e)(r,t,n,i,o)}catch(c){if(b(s),!(c instanceof E))throw c;k(1,0)}}function Ns(e,r,t,n,i){var o=S();try{return F(e)(r,t,n,i)}catch(s){if(b(o),!(s instanceof E))throw s;return k(1,0),0n}}function Ls(e,r,t,n,i){var o=S();try{F(e)(r,t,n,i)}catch(s){if(b(o),!(s instanceof E))throw s;k(1,0)}}function Us(e,r,t,n,i,o){var s=S();try{F(e)(r,t,n,i,o)}catch(c){if(b(s),!(c instanceof E))throw c;k(1,0)}}function Bs(e,r){var t=S();try{return F(e)(r)}catch(n){if(b(t),!(n instanceof E))throw n;k(1,0)}}function Ws(e,r,t,n){var i=S();try{return F(e)(r,t,n)}catch(o){if(b(i),!(o instanceof E))throw o;k(1,0)}}function zs(e,r,t,n,i,o){var s=S();try{return F(e)(r,t,n,i,o)}catch(c){if(b(s),!(c instanceof E))throw c;k(1,0)}}function Hs(e,r,t,n,i,o,s,c,l,d){var f=S();try{return F(e)(r,t,n,i,o,s,c,l,d)}catch(_){if(b(f),!(_ instanceof E))throw _;k(1,0)}}function Vs(e,r,t,n,i,o,s,c){var l=S();try{F(e)(r,t,n,i,o,s,c)}catch(d){if(b(l),!(d instanceof E))throw d;k(1,0)}}function Gs(e,r,t,n,i,o){var s=S();try{F(e)(r,t,n,i,o)}catch(c){if(b(s),!(c instanceof E))throw c;k(1,0)}}function qs(e,r,t,n,i,o,s,c){var l=S();try{F(e)(r,t,n,i,o,s,c)}catch(d){if(b(l),!(d instanceof E))throw d;k(1,0)}}function Ys(e,r,t,n,i,o){var s=S();try{F(e)(r,t,n,i,o)}catch(c){if(b(s),!(c instanceof E))throw c;k(1,0)}}function Xs(e,r,t,n,i,o,s,c,l,d,f,_,g){var p=S();try{return F(e)(r,t,n,i,o,s,c,l,d,f,_,g)}catch(w){if(b(p),!(w instanceof E))throw w;k(1,0)}}function Js(e,r,t,n,i,o,s,c,l,d,f,_,g,p,w,M,L,I,V,U,te,ee,oe,H,Le,yc,wc,Ec,bc,Sc,kc,Fc,Tc,Ac,Pc,Cc,xc,Mc,$c,Rc,Oc,Dc,jc,Ic,Nc,Lc,Uc,Bc,Wc,zc,Hc,Vc,Gc,qc,Yc,Xc,Jc,Kc,Qc,Zc,el,rl,tl,nl,il,ol,al,sl,cl,ll,ul,dl,fl,hl,vl,_l,pl,ml,gl,yl,wl,El,bl,Sl,kl){var Fl=S();try{F(e)(r,t,n,i,o,s,c,l,d,f,_,g,p,w,M,L,I,V,U,te,ee,oe,H,Le,yc,wc,Ec,bc,Sc,kc,Fc,Tc,Ac,Pc,Cc,xc,Mc,$c,Rc,Oc,Dc,jc,Ic,Nc,Lc,Uc,Bc,Wc,zc,Hc,Vc,Gc,qc,Yc,Xc,Jc,Kc,Qc,Zc,el,rl,tl,nl,il,ol,al,sl,cl,ll,ul,dl,fl,hl,vl,_l,pl,ml,gl,yl,wl,El,bl,Sl,kl)}catch(mn){if(b(Fl),!(mn instanceof E))throw mn;k(1,0)}}function Ks(e,r,t,n,i,o,s,c,l,d,f,_,g,p){var w=S();try{F(e)(r,t,n,i,o,s,c,l,d,f,_,g,p)}catch(M){if(b(w),!(M instanceof E))throw M;k(1,0)}}function Qs(e,r,t,n,i,o,s,c,l,d,f){var _=S();try{F(e)(r,t,n,i,o,s,c,l,d,f)}catch(g){if(b(_),!(g instanceof E))throw g;k(1,0)}}function Zs(e,r,t,n,i,o,s,c,l,d,f,_,g,p,w,M,L,I,V){var U=S();try{F(e)(r,t,n,i,o,s,c,l,d,f,_,g,p,w,M,L,I,V)}catch(te){if(b(U),!(te instanceof E))throw te;k(1,0)}}function ec(e,r){var t=S();try{return F(e)(r)}catch(n){if(b(t),!(n instanceof E))throw n;return k(1,0),0n}}function rc(e,r,t){var n=S();try{return F(e)(r,t)}catch(i){if(b(n),!(i instanceof E))throw i;return k(1,0),0n}}function tc(e,r,t){var n=S();try{return F(e)(r,t)}catch(i){if(b(n),!(i instanceof E))throw i;k(1,0)}}function nc(e,r,t,n,i,o,s){var c=S();try{F(e)(r,t,n,i,o,s)}catch(l){if(b(c),!(l instanceof E))throw l;k(1,0)}}function ic(e,r,t,n,i,o,s){var c=S();try{F(e)(r,t,n,i,o,s)}catch(l){if(b(c),!(l instanceof E))throw l;k(1,0)}}function oc(e,r,t){var n=S();try{F(e)(r,t)}catch(i){if(b(n),!(i instanceof E))throw i;k(1,0)}}function ac(e,r,t){var n=S();try{return F(e)(r,t)}catch(i){if(b(n),!(i instanceof E))throw i;k(1,0)}}function sc(e,r,t,n,i,o){var s=S();try{return F(e)(r,t,n,i,o)}catch(c){if(b(s),!(c instanceof E))throw c;k(1,0)}}function cc(e,r,t,n,i,o){var s=S();try{F(e)(r,t,n,i,o)}catch(c){if(b(s),!(c instanceof E))throw c;k(1,0)}}function lc(e,r,t,n){var i=S();try{F(e)(r,t,n)}catch(o){if(b(i),!(o instanceof E))throw o;k(1,0)}}function uc(e){var r=S();try{return F(e)()}catch(t){if(b(r),!(t instanceof E))throw t;return k(1,0),0n}}function dc(e,r,t,n,i,o){var s=S();try{F(e)(r,t,n,i,o)}catch(c){if(b(s),!(c instanceof E))throw c;k(1,0)}}function fc(e,r,t,n,i,o,s,c,l,d,f){var _=S();try{return F(e)(r,t,n,i,o,s,c,l,d,f)}catch(g){if(b(_),!(g instanceof E))throw g;k(1,0)}}function hc(e,r,t,n){var i=S();try{return F(e)(r,t,n)}catch(o){if(b(i),!(o instanceof E))throw o;k(1,0)}}function vc(e,r,t,n,i,o,s,c,l,d,f,_){var g=S();try{return F(e)(r,t,n,i,o,s,c,l,d,f,_)}catch(p){if(b(g),!(p instanceof E))throw p;k(1,0)}}function _c(e,r,t,n,i,o,s,c,l,d,f,_,g,p,w,M){var L=S();try{F(e)(r,t,n,i,o,s,c,l,d,f,_,g,p,w,M)}catch(I){if(b(L),!(I instanceof E))throw I;k(1,0)}}var pn;function pc(){cn(),Cn()}function it(){if($e>0){tr=it;return}if(pc(),Rn(),$e>0){tr=it;return}function e(){T(!pn),pn=!0,u.calledRun=!0,!Ke&&(On(),vt?.(u),u.onRuntimeInitialized?.(),dr("onRuntimeInitialized"),T(!u._main,'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'),Dn())}u.setStatus?(u.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>u.setStatus(""),1),e()},1)):e(),jr()}function mc(){var e=G,r=x,t=!1;G=x=n=>{t=!0};try{rt(0),["stdout","stderr"].forEach(n=>{var i=a.analyzePath("/dev/"+n);if(i){var o=i.object,s=o.rdev,c=Te.ttys[s];c?.output?.length&&(t=!0)}})}catch{}G=e,x=r,t&&Pe("stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the Emscripten FAQ), or make sure to emit a newline when you printf etc.")}function gc(){if(u.preInit)for(typeof u.preInit=="function"&&(u.preInit=[u.preInit]);u.preInit.length>0;)u.preInit.shift()();dr("preInit")}gc(),it(),rr?h=u:h=new Promise((e,r)=>{vt=e,Nr=r});for(let e of Object.keys(u))e in y||Object.defineProperty(y,e,{configurable:!0,get(){K(`Access to module property ('${e}') is no longer possible via the module constructor argument; Instead, use the result of the module constructor.`)}});return h}),gn=Tl;var cr=(y,h,u)=>Math.max(h,Math.min(u,y));function Ce(y,h,u){if(!Array.isArray(y)||y.length!==h||!y.every(Number.isFinite))throw new Error(`${u} must contain ${h} finite numbers`);return y.slice()}function ot(y,h){let u=Ce(y,3,"Target");if(u.some((v,m)=>vh[m][1]))throw new Error("Target is outside the workstation workspace");return u}function yn(y,h){let u=Math.hypot(...y);return u>h?y.map(v=>v*h/u):y.slice()}function Al(y,h){let u=h.length,v=y.map((m,A)=>[...m,h[A]]);for(let m=0;mMath.abs(v[A][m])&&(A=P);if(!Number.isFinite(v[A][m])||Math.abs(v[A][m])<1e-14)throw new Error("Controller solve is singular");[v[m],v[A]]=[v[A],v[m]];let O=v[m][m];for(let P=m;P<=u;P+=1)v[m][P]/=O;for(let P=0;Pm[u])}function wn({jacp:y,jacr:h,nv:u,dofIds:v,qpos:m,qposIds:A,target:O,current:P,rotationWorld:D,ctrlRange:B,config:$}){let W=yn(O.map((ie,G)=>ie-P[G]),$.translation_error_cap_m),Y=yn(D,$.rotation_error_cap_rad),we=$.orientation_weight,re=Array.from({length:6},(ie,G)=>v.map(x=>G<3?y[G*u+x]:we*h[(G-3)*u+x])),se=[...W,...Y.map(ie=>ie*we)],xe=re.map((ie,G)=>re.map((x,he)=>ie.reduce((ue,be,Ae)=>ue+be*x[Ae],0)+(G===he?$.damping**2:0))),Ee=Al(xe,se);return v.map((ie,G)=>{let x=re.reduce((ue,be,Ae)=>ue+be[G]*Ee[Ae],0),he=cr(m[A[G]]+cr(x,-$.max_joint_delta_rad,$.max_joint_delta_rad),B[G][0]+$.joint_margin_rad,B[G][1]-$.joint_margin_rad);if(!Number.isFinite(he))throw new Error("Controller produced a non-finite target");return he})}var lr=class{constructor(h=2048){this.capacity=h,this.values=[],this.index=0}add(h){Number.isFinite(h)&&(this.values.lengthv-m);return u[Math.min(u.length-1,Math.floor(h*(u.length-1)))]}};function Ue(y,h){if(typeof y!="string"||y.length>1024||y.startsWith("/")||y.split("/").some(v=>v==="..")||y.includes("\\"))throw new Error("Invalid local asset path");let u=new URL(y,h);if(u.origin!==h.origin||!["http:","https:"].includes(u.protocol))throw new Error("Workstation resources must be same-origin HTTP assets");return u}function Xe(y,h=67108864){if(!y||!Number.isSafeInteger(y.bytes)||y.bytes<0||y.bytes>h||typeof y.sha256!="string"||!/^[a-f0-9]{64}$/.test(y.sha256))throw new Error("Asset size or digest descriptor mismatch")}async function Or(y,h){if(Xe(h),y.length!==h.bytes)throw new Error("Asset size mismatch");if(Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",y)),v=>v.toString(16).padStart(2,"0")).join("")!==h.sha256)throw new Error("Asset checksum mismatch")}async function Pl(y,h){if(!y)throw new Error("Streaming resource responses are required");if(!Number.isSafeInteger(h)||h<0||h>201326592)throw new Error("Invalid resource limit");let u=y.getReader(),v=[],m=0;try{for(;;){let{done:P,value:D}=await u.read();if(P)break;if(m+=D.byteLength,m>h)throw await u.cancel(),new Error("Resource is too large");v.push(D)}}finally{u.releaseLock()}let A=new Uint8Array(m),O=0;for(let P of v)A.set(P,O),O+=P.byteLength;return A}var En="dvidia-robot-simulation-lab.static.hf.space",Cl="us.aws.cdn.hf.co",xl=new Set([408,429,502,503,504]),Ml=Object.freeze({"geometry.bin.gz":{bytes:3574720,sha256:"51365a5a661d8062e28c66abc6bdb843ee410811f84b49d62c5878c265b3631f"},"native-assets.bin.gz":{bytes:7318481,sha256:"9c960598f9b2c0c7459a8bdfc8a544513b4c6ffaff2c8787fa49f728774eb9e7"},"mujoco.wasm.gz":{bytes:2543112,sha256:"ad01772e00939bf6300a953b396d38aa9ec03c05fcda46c3c8d940d56f772b3b"}});function $l(y,h){if(y.protocol!=="https:"||y.host!==En||y.search||y.hash||!h)return null;let u=y.pathname.split("/").pop(),v=Ml[u];return!v||y.pathname!=="/workstation/v01/"+u||h.bytes!==v.bytes||h.sha256!==v.sha256?null:new URL("https://research.dvidia.org/runtime/workstation/"+v.sha256+"/"+u)}var le=class extends Error{constructor(h,u=!1){super(h),this.name="ResourceDownloadError",this.retryable=u}};function Rl(y,h){let u={maxBytes:h?.bytes??67108864,idleTimeoutMs:3e4,timeoutMs:12e4,maxAttempts:3,retryDelayMs:250,...y};for(let[v,m,A]of[["maxBytes",67108864,0],["idleTimeoutMs",12e4,1],["timeoutMs",12e4,1],["maxAttempts",3,1],["retryDelayMs",2e3,0]])if(!Number.isSafeInteger(u[v])||u[v]m)throw new Error(`Invalid resource transport option: ${v}`);if(h&&u.maxBytes{u=()=>A(h.reason),h.addEventListener("abort",u,{once:!0})});try{return await Promise.race([y,v])}finally{h.removeEventListener("abort",u)}}async function Ol(y,h,u,v){if(!y)throw new le("The server returned an empty resource");let m=y.getReader(),A=[],O=0,P=!1;try{for(;;){let $;try{$=await bn(m.read(),u)}catch(W){throw u.aborted?u.reason:new le(`Body download interrupted: ${W.message||"network error"}`,!0)}if($.done){P=!0;break}if(O+=$.value.byteLength,O>h)throw new le("Resource is too large");A.push($.value),$.value.byteLength&&v(O)}}finally{P||m.cancel().catch(()=>{}),m.releaseLock()}let D=new Uint8Array(O),B=0;for(let $ of A)D.set($,B),B+=$.byteLength;return D}async function Be(y,h,u={}){h&&Xe(h);let v=Rl(u,h),m=new URL(y);if(!["http:","https:"].includes(m.protocol)||m.username||m.password)throw new Error("Invalid resource URL");let A=m.protocol==="https:"&&m.host===En,O=$l(m,h),P=performance.now()+v.timeoutMs,D=m.pathname.split("/").pop()||"resource",B=h?.bytes??null,$=(Y,we,re=0)=>v.onProgress?.({path:m.pathname,phase:Y,attempt:we,receivedBytes:re,totalBytes:B}),W=()=>new le("Total download deadline exceeded");for(let Y=1;Y<=v.maxAttempts;Y+=1){let we=P-performance.now();if(we<=0)throw new Error(`Could not download ${D}: total download deadline exceeded`);let re=new AbortController,se=O!==null&&Y===1,xe=se?O:m,Ee=setTimeout(()=>re.abort(W()),we),ie,G=()=>{clearTimeout(ie),ie=setTimeout(()=>re.abort(new le("Download stalled without receiving data",!0)),v.idleTimeoutMs)};try{B=h?.bytes??null,$("downloading",Y),G();let x;try{x=await bn(fetch(xe,{credentials:"omit",referrerPolicy:"no-referrer",redirect:se?"manual":A?"follow":"error",signal:re.signal,...Y>1?{cache:"reload"}:{}}),re.signal)}catch(ur){throw re.signal.aborted?re.signal.reason:new le(`Network request failed: ${ur.message||"network error"}`,!0)}if(G(),se&&(x.type==="opaqueredirect"||x.redirected||x.status>=300&&x.status<400))throw x.body?.cancel().catch(()=>{}),new le("The pinned workstation mirror may not redirect");let he=new URL(x.url);if(se?he.href!==xe.href:he.origin!==m.origin&&!(A&&he.protocol==="https:"&&he.host===Cl))throw x.body?.cancel().catch(()=>{}),new le("Resource redirected outside the permitted workstation host");if(!x.ok)throw x.body?.cancel().catch(()=>{}),new le(`HTTP ${x.status}`,xl.has(x.status)||se&&[404,410].includes(x.status));if(Number(x.headers.get("content-length"))>v.maxBytes)throw x.body?.cancel().catch(()=>{}),new le("Resource is too large");let ue=x.headers.get("content-length"),be=x.headers.get("content-encoding");!h&&(!be||be==="identity")&&/^\d+$/.test(ue??"")&&Number.isSafeInteger(Number(ue))&&Number(ue)<=v.maxBytes&&(B=Number(ue),$("downloading",Y));let Ae=await Ol(x.body,h?.bytes??v.maxBytes,re.signal,ur=>{G(),$("downloading",Y,ur)});return h&&await Or(Ae,h),$("complete",Y,Ae.byteLength),Ae}catch(x){if(!(x instanceof le&&x.retryable&&YsetTimeout(be,ue))}finally{clearTimeout(Ee),clearTimeout(ie)}}}function Sn(y){if(!Array.isArray(y)||y.length>256)throw new Error("Invalid asset manifest");let h=0,u=new Set;for(let v of y){if(Xe(v),u.has(v.path))throw new Error("Duplicate native asset path");if(u.add(v.path),h+=v.bytes,h>201326592)throw new Error("Scene assets exceed worker memory budget")}return h}function kn(y,h){Xe(y);let u=Sn(h);if(y.compression!=="gzip"||y.path!=="native-assets.bin.gz"||!Number.isSafeInteger(y.uncompressed_bytes)||y.uncompressed_bytes!==u)throw new Error("Invalid native asset bundle descriptor");return u}async function Fn(y,h,u){try{let v=new Blob([y]).stream().pipeThrough(new DecompressionStream("gzip"));return await Pl(v,h)}catch(v){throw new Error(`Could not decode ${u}: ${v.message}`)}}async function Dl(y,h,u){let v=kn(h,u);await Or(y,h);let m=await Fn(y,v,h.path);if(m.byteLength!==v)throw new Error("Native asset bundle is truncated");let A=[],O=0;for(let P of u){let D=m.subarray(O,O+P.bytes);await Or(D,P),A.push({path:P.path,bytes:D}),O+=P.bytes}return A}async function Tn(y,h,u={}){Sn(y.assets);for(let m of y.assets)Ue(m.path,h);if(y.native_asset_bundle!==void 0){let m=y.native_asset_bundle;kn(m,y.assets);let A=await Be(Ue(m.path,h),m,u);return Dl(A,m,y.assets)}let v=[];for(let m of y.assets)v.push({path:m.path,bytes:await Be(Ue(m.path,h),m,u)});return v}async function An(y,h,u={}){let v=y.native_wasm;if(v!==void 0&&(Xe(v),v.path!=="mujoco.wasm"))throw new Error("Invalid native WASM descriptor");let m=y.wasm_bundle;if(m===void 0)return Be(Ue("mujoco.wasm",h),v,u);if(Xe(m),!v||m.path!=="mujoco.wasm.gz"||m.compression!=="gzip"||!Number.isSafeInteger(m.uncompressed_bytes)||m.uncompressed_bytes!==v.bytes)throw new Error("Invalid WASM bundle descriptor");let A=await Be(Ue(m.path,h),m,u),O=await Fn(A,v.bytes,m.path);try{await Or(O,v)}catch(P){throw new Error(`Decoded ${v.path} from ${m.path}: ${P.message}`)}return O}var Dr="3.15.0",jl=256,Il=.1,Nl=50,Ll=1e3/60;function Pn(y){if(!y||y.schema!=="dvidia.live-workstation/v1")throw new Error("Unsupported workstation schema");if(y.native_version!==Dr)throw new Error("Native and browser MuJoCo versions must match");if(y.timestep!==.002||y.control_dt!==.02)throw new Error("Unsupported physics/control timestep");if(!Array.isArray(y.assets)||y.assets.length>jl)throw new Error("Invalid asset manifest");if(!Array.isArray(y.bounds_xyz)||y.bounds_xyz.length!==3)throw new Error("Invalid workspace bounds");for(let m of y.bounds_xyz)if(Ce(m,2,"Workspace bounds"),m[0]>=m[1]||m[0]<-2||m[1]>2)throw new Error("Invalid workspace bounds");ot(y.initial_target_xyz,y.bounds_xyz);let h=Ce(y.orientation_wxyz,4,"Tool orientation");if(Math.abs(Math.hypot(...h)-1)>1e-8)throw new Error("Tool orientation must be normalized");for(let m of["joint_names","actuator_names"])if(!Array.isArray(y[m])||y[m].length!==6||!y[m].every(A=>typeof A=="string"&&A.length<100))throw new Error(`Invalid ${m}`);let u=y.controller;for(let m of["orientation_weight","translation_error_cap_m","rotation_error_cap_rad","damping","max_joint_delta_rad","joint_margin_rad","joint_rate_rad_s","gripper_rate_m_s"])if(!Number.isFinite(u?.[m])||u[m]<=0||u[m]>5)throw new Error(`Invalid controller ${m}`);if(Ce(u.gripper_range_m,2,"Gripper range"),u.gripper_range_m[0]!==0||u.gripper_range_m[1]!==.035)throw new Error("Unsupported gripper range");if(!Array.isArray(y.shoe_body_names)||y.shoe_body_names.length>12)throw new Error("Invalid shoe body list");let v=y.interaction_limits?.push_impulse_norm_max_ns;if(!Number.isFinite(v)||v<=0||v>.12)throw new Error("Invalid push impulse limit");return y}var st=class{constructor(h,u,v,m=()=>{}){if(this.mj=h,this.model=u,this.manifest=Pn(v),this.emit=m,u.nq!==15||u.nv!==14||u.nu!==7||u.neq!==1||u.nmocap!==0||u.opt.timestep!==v.timestep)throw new Error("Native PiPER scene contract mismatch");this.data=new h.MjData(u),this.buffers=[];let A=P=>{let D=new h.DoubleBuffer(P);return this.buffers.push(D),D};this.jacp=A(3*u.nv),this.jacr=A(3*u.nv),this.quaternion=A(4),this.rotation=A(3),this.contactForce=A(6);let O=(P,D)=>{let B=h.mj_name2id(u,h.mjtObj[P].value,D);if(B<0)throw new Error(`Missing native model element: ${D}`);return B};this.tcp=O("mjOBJ_SITE",v.tcp_site_name),this.joints=v.joint_names.map(P=>O("mjOBJ_JOINT",P)),this.actuators=v.actuator_names.map(P=>O("mjOBJ_ACTUATOR",P)),this.jawActuator=O("mjOBJ_ACTUATOR",v.gripper_actuator_names[0]),this.jawQpos=u.jnt_qposadr[O("mjOBJ_JOINT","joint7")],this.qposIds=this.joints.map(P=>u.jnt_qposadr[P]),this.dofIds=this.joints.map(P=>u.jnt_dofadr[P]),this.ctrlRange=this.actuators.map(P=>Array.from(u.actuator_ctrlrange.slice(P*2,P*2+2))),this.shoes=Object.fromEntries(v.shoe_body_names.map(P=>[P,O("mjOBJ_BODY",P)])),this.nativeWarnings=this.data.warning,this.nativeWarningEntries=Array.from({length:this.nativeWarnings.size()},(P,D)=>this.nativeWarnings.get(D)),this.dt=v.timestep,this.controlStride=Math.round(v.control_dt/this.dt),this.running=!0,this.benchmarking=!1,this.timer=null,this.statePending=!1,this.reset()}reset(){this.mj.mj_resetData(this.model,this.data);let h=Ce(this.manifest.home_qpos,this.model.nq,"Initial positions"),u=Ce(this.manifest.home_ctrl,this.model.nu,"Initial controls");this.data.qpos.set(h),this.data.ctrl.set(u),this.mj.mj_forward(this.model,this.data),this.target=this.manifest.initial_target_xyz.slice(),this.jaw=u[this.jawActuator],this.desiredJaw=this.jaw,this.desired=this.actuators.map(v=>u[v]),this.steps=0,this.pushes=new Map,this.warnings=[],this.stepSamples=new lr,this.controlSamples=new lr,this.startWall=performance.now(),this.lastWall=this.startWall,this.lastStateWall=0,this.activeWallMs=0,this.lagMs=0,this.accumulator=0,this.peakContacts=0,this.invalidCommands=0,this.statePending=!1,this.initialShoePositions=Object.fromEntries(Object.entries(this.shoes).map(([v,m])=>[v,Array.from(this.data.xpos.slice(3*m,3*m+3))]))}controller(){let h=performance.now(),u=Array.from(this.data.site_xmat.slice(this.tcp*9,this.tcp*9+9));this.mj.mj_jacSite(this.model,this.data,this.jacp,this.jacr,this.tcp),this.mj.mju_mat2Quat(this.quaternion,u),this.mj.mju_subQuat(this.rotation,this.manifest.orientation_wxyz,Array.from(this.quaternion.GetView()));let v=this.rotation.GetView(),m=[0,1,2].map(A=>u[A*3]*v[0]+u[A*3+1]*v[1]+u[A*3+2]*v[2]);this.desired=wn({jacp:this.jacp.GetView(),jacr:this.jacr.GetView(),nv:this.model.nv,dofIds:this.dofIds,qpos:this.data.qpos,qposIds:this.qposIds,target:this.target,current:this.data.site_xpos.slice(this.tcp*3,this.tcp*3+3),rotationWorld:m,ctrlRange:this.ctrlRange,config:this.manifest.controller}),this.desiredJaw=this.jaw,this.controlSamples.add(performance.now()-h)}step(){let h=performance.now();this.steps%this.controlStride===0&&this.controller();let u=this.manifest.controller,v=this.data.ctrl;this.actuators.forEach((m,A)=>{v[m]+=cr(this.desired[A]-v[m],-u.joint_rate_rad_s*this.dt,u.joint_rate_rad_s*this.dt)}),v[this.jawActuator]+=cr(this.desiredJaw-v[this.jawActuator],-u.gripper_rate_m_s*this.dt,u.gripper_rate_m_s*this.dt),this.data.xfrc_applied.fill(0);for(let[m,A]of this.pushes)A.remainingSteps<=0?this.pushes.delete(m):(this.data.xfrc_applied.set(A.force,m*6),A.remainingSteps-=1);if(this.mj.mj_step(this.model,this.data),this.data.xfrc_applied.fill(0),this.mj.mj_forward(this.model,this.data),this.steps+=1,this.peakContacts=Math.max(this.peakContacts,this.data.ncon),![...this.data.qpos,...this.data.qvel,...this.data.qacc,...this.data.ctrl].every(Number.isFinite))throw new Error("Non-finite native physics state; simulation paused");this.checkWarnings(),this.stepSamples.add(performance.now()-h)}checkWarnings(){for(let h=0;h0){let v=this.mj.mju_warningText(h,u.lastinfo);this.warnings.includes(v)||this.warnings.push(v)}}if(this.warnings.length)throw new Error(`Native solver warning; simulation paused: ${this.warnings[0]}`)}applyCommand(h){switch(h.type){case"target":this.target=ot(h.position,this.manifest.bounds_xyz);break;case"gripper":{let u=this.manifest.controller.gripper_range_m;if(!Number.isFinite(h.jaw)||h.jawu[1])throw new Error("Invalid gripper position");this.jaw=h.jaw;break}case"pause":if(typeof h.paused!="boolean")throw new Error("Pause requires a boolean");this.running=!h.paused,this.lastWall=performance.now(),this.accumulator=0;break;case"reset":this.reset();break;case"push":{let u=this.shoes[h.body];if(u===void 0)throw new Error("Push is restricted to a named shoe");let v=Ce(h.impulse,3,"Push impulse"),m=this.manifest.interaction_limits.push_impulse_norm_max_ns;if(Math.hypot(...v)>m+1e-9)throw new Error(`Push exceeds the ${m} N·s impulse limit`);this.pushes.set(u,{force:v.map(A=>A/this.dt),remainingSteps:1});break}default:throw new Error(`Unsupported command: ${String(h.type).slice(0,60)}`)}}state(){let h=Array.from(this.data.site_xpos.slice(this.tcp*3,this.tcp*3+3)),u=Object.fromEntries(Object.entries(this.shoes).map(([P,D])=>{let B=Array.from(this.data.xpos.slice(D*3,D*3+3));return[P,{position:B,height_change_m:B[2]-this.initialShoePositions[P][2]}]})),v=0,m=0,A=0,O=[];for(let P=0;P.001)}return{body_pos:Array.from(this.data.xpos),body_quat:Array.from(this.data.xquat),qpos:Array.from(this.data.qpos),qvel:Array.from(this.data.qvel),ctrl:Array.from(this.data.ctrl),tcp_position:h,target_position:this.target.slice(),jaw:this.jaw,actual_jaw:this.data.qpos[this.jawQpos],commanded_jaw:this.data.ctrl[this.jawActuator],sim_time:this.data.time,paused:!this.running,tracking_error_m:Math.hypot(...h.map((P,D)=>P-this.target[D])),contacts:this.data.ncon,contact_normal_force_total_n:v,contact_normal_force_max_n:m,shoes:u,active_contacts:A,contact_normal_forces_n:O,actuator_force:Array.from(this.data.actuator_force),metrics:{step_ms_p50:this.stepSamples.quantile(.5),step_ms_p95:this.stepSamples.quantile(.95),control_ms_p95:this.controlSamples.quantile(.95),rtf:this.activeWallMs>0?this.data.time*1e3/this.activeWallMs:0,lag_ms:this.lagMs,physics_steps:this.steps,active_wall_ms:this.activeWallMs,peak_contacts:this.peakContacts,invalid_commands:this.invalidCommands,samples_retained:this.stepSamples.values.length},warnings:this.warnings.slice(),engine:`MuJoCo ${Dr} WASM`,observation_origin:"privileged_live_simulator_state"}}start(){let h=()=>{let u=performance.now(),v=Math.max(0,(u-this.lastWall)/1e3);if(this.lastWall=u,this.running&&!this.benchmarking){this.activeWallMs+=v*1e3;let m=this.accumulator+v;this.accumulator=Math.min(m,Il),this.lagMs+=Math.max(0,m-this.accumulator)*1e3;let A=0;try{for(;this.accumulator>=this.dt&&A=Ll&&!this.benchmarking&&!this.statePending&&(this.publishState(),this.lastStateWall=u),this.timer=setTimeout(h,4)};this.lastWall=performance.now(),this.timer=setTimeout(h,0)}publishState(){this.statePending||(this.statePending=!0,this.emit({type:"state",state:this.state()}))}async benchmark(h){if(!Number.isInteger(h.steps)||h.steps<1||h.steps>3e4)throw new Error("Benchmark requires 1–30,000 physics steps");let u=h.commands??[];if(!Array.isArray(u)||u.length>1e3)throw new Error("Too many benchmark commands");if(u.some($=>!Number.isInteger($.step)||$.step<0||$.step>=h.steps||!["target","gripper","push"].includes($.type)))throw new Error("Invalid benchmark schedule");let v=this.running;this.benchmarking=!0,this.reset(),this.running=!1;let m=performance.now(),A=null,O=new Map;for(let $ of u)O.set($.step,[...O.get($.step)??[],$]);let P=[];try{for(let $=0;$setTimeout(W,0))}}catch($){A=$.message}let D=performance.now()-m;this.activeWallMs=D;let B=this.state();return this.benchmarking=!1,this.running=v&&!A,this.lastWall=performance.now(),this.accumulator=0,this.statePending=!1,{schema:"dvidia.live-workstation-benchmark/v1",engine_version:Dr,requested_steps:h.steps,completed_steps:this.steps,simulated_seconds:this.data.time,wall_seconds:D/1e3,real_time_factor:this.data.time*1e3/D,valid:!A&&!this.warnings.length,error:A,final_state:B,trace:P,timestep:this.dt,control_dt:this.manifest.control_dt,scene_sha256:this.manifest.native_scene.sha256,limitations:["Rigid synthetic shoe; material properties are uncalibrated.","Benchmark state is privileged simulator state."]}}dispose(){this.timer!==null&&clearTimeout(this.timer);for(let h of this.buffers)h.delete();this.data.delete(),this.model.delete()}},ne=null,at=!1;async function Ul(y){if(ne||at)throw new Error("The worker has already been initialized");at=!0;let h=null,u=null;try{let v=new URL(y.manifest_url,self.location.href);if(v.origin!==self.location.origin||!["http:","https:"].includes(v.protocol))throw new Error("Manifest must be same-origin");let m=await Be(v,void 0,{maxBytes:2*1024*1024});if(m.length>2*1024*1024)throw new Error("Manifest is too large");let A=Pn(JSON.parse(new TextDecoder().decode(m)));if(!A.native_scene||A.native_scene.path!==A.scene_url)throw new Error("Scene checksum descriptor is missing");self.postMessage({type:"progress",message:A.native_asset_bundle?"Loading the physics engine and one compressed native mesh bundle.":"Loading the physics engine and original native meshes."});let O={onProgress:W=>self.postMessage({type:"progress",download:W})},[P,D,B]=await Promise.all([An(A,v,O),Tn(A,v,O),Be(Ue(A.scene_url,v),A.native_scene,O)]),$=await gn({wasmBinary:P,printErr:W=>{ne&&ne.warnings.length<20&&ne.warnings.push(String(W).slice(0,300))}});if($.mj_versionString()!==Dr)throw new Error("Unexpected MuJoCo WASM version");self.postMessage({type:"progress",message:"Native mesh checksums verified. Compiling the local physics scene."}),u=new $.MjVFS;for(let W of D)u.addBuffer(W.path,W.bytes);h=$.MjModel.from_xml_string(new TextDecoder().decode(B),u),ne=new st($,h,A,W=>self.postMessage(W)),h=null,self.postMessage({type:"ready",manifest:A,state:ne.state()}),ne.start()}finally{u?.delete(),h?.delete(),at=!1}}typeof self<"u"&&typeof self.postMessage=="function"&&typeof document>"u"&&(self.onmessage=async y=>{let h=y.data;try{if(!h||typeof h!="object"||typeof h.type!="string")throw new Error("Invalid worker message");if(h.type==="init"){await Ul(h);return}if(!ne)throw new Error("Workstation is not initialized");if(h.type==="ack"){ne.statePending=!1;return}if(ne.benchmarking)throw new Error("Interactive commands are disabled during deterministic benchmarking");if(h.type==="benchmark"){let u=await ne.benchmark(h);self.postMessage({type:"benchmark_result",request_id:h.request_id,result:u})}else h.type==="state"||ne.applyCommand(h),ne.publishState()}catch(u){ne&&(ne.invalidCommands+=1),self.postMessage({type:"error",request_id:h?.request_id,message:String(u.message).slice(0,500)})}});export{st as WorkstationEngine};