x_ite
Version:
X_ITE X3D Browser and VRML Viewer — View and Manipulate X3D, VRML, glTF and Other 3D Sources in HTML
1 lines • 100 kB
JavaScript
var LIBKTX,createKtxModule=async function(e={},r){var t=e,n=!!globalThis.WorkerGlobalScope;t.onRuntimeInitialized=function(){t.ktxTexture=t.texture,t.ErrorCode=t.error_code,t.TranscodeTarget=t.transcode_fmt,t.TranscodeFlags=t.transcode_flag_bits};var a,o,i="./this.program",s=(e,r)=>{throw r},u="";try{u=new URL(".",r).href}catch{}n&&(o=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),a=async e=>{if(h(e))return new Promise((r,t)=>{var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=()=>{200==n.status||0==n.status&&n.response?r(n.response):t(n.status)},n.onerror=t,n.send(null)});var r=await fetch(e,{credentials:"same-origin"});if(r.ok)return r.arrayBuffer();throw new Error(r.status+" : "+r.url)};var f,c,l,d=console.log.bind(console),m=console.error.bind(console),p=!1,h=e=>e.startsWith("file://");class v{}class g extends v{}var y,b,w,E,x,_,k,B,T,P,C,$=!1;function A(){var e=rn.buffer;t.HEAP8=x=new Int8Array(e),b=new Int16Array(e),C=new Uint8Array(e),B=new Uint16Array(e),w=new Int32Array(e),T=new Uint32Array(e),_=new Float32Array(e),k=new Float64Array(e),E=new BigInt64Array(e),P=new BigUint64Array(e)}function S(e){t.onAbort?.(e),m(e=`Aborted(${e})`),p=!0,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw l?.(r),r}function D(){return e="libktx.wasm",t.locateFile?t.locateFile(e,u):u+e;var e}async function F(e){if(!f)try{var r=await a(e);return new Uint8Array(r)}catch{}return function(e){if(e==y&&f)return new Uint8Array(f);if(o)return o(e);throw"both async and sync fetching of the wasm failed"}(e)}async function L(e,r,t){if(!e&&!h(r))try{var n=fetch(r,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(n,t)}catch(e){m(`wasm streaming compile failed: ${e}`),m("falling back to ArrayBuffer instantiation")}return async function(e,r){try{var t=await F(e);return await WebAssembly.instantiate(t,r)}catch(e){m(`failed to asynchronously prepare wasm: ${e}`),S(e)}}(r,t)}class I{name="ExitStatus";constructor(e){this.message=`Program terminated with exit(${e})`,this.status=e}}var M=e=>{for(;e.length>0;)e.shift()(t)},R=[],N=e=>R.push(e),V=[],W=e=>V.push(e),O=!0,j=e=>Jt(e),U=()=>en();class G{constructor(e){this.excPtr=e,this.ptr=e-24}set_type(e){T[this.ptr+4>>2]=e}get_type(){return T[this.ptr+4>>2]}set_destructor(e){T[this.ptr+8>>2]=e}get_destructor(){return T[this.ptr+8>>2]}set_caught(e){e=e?1:0,x[this.ptr+12]=e}get_caught(){return 0!=x[this.ptr+12]}set_rethrown(e){e=e?1:0,x[this.ptr+13]=e}get_rethrown(){return 0!=x[this.ptr+13]}init(e,r){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(r)}set_adjusted_ptr(e){T[this.ptr+16>>2]=e}get_adjusted_ptr(){return T[this.ptr+16>>2]}}var z=()=>{var e=w[+he.varargs>>2];return he.varargs+=4,e},X=z,q={isAbs:e=>"/"===e.charAt(0),splitPath:e=>/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1),normalizeArray:(e,r)=>{for(var t=0,n=e.length-1;n>=0;n--){var a=e[n];"."===a?e.splice(n,1):".."===a?(e.splice(n,1),t++):t&&(e.splice(n,1),t--)}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=q.isAbs(e),t="/"===e.slice(-1);return(e=q.normalizeArray(e.split("/").filter(e=>!!e),!r).join("/"))||r||(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=q.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)=>q.normalize(e.join("/")),join2:(e,r)=>q.normalize(e+"/"+r)},H=e=>(H=e=>(crypto.getRandomValues(e),0))(e),Q={resolve:(...e)=>{for(var r="",t=!1,n=e.length-1;n>=-1&&!t;n--){var a=n>=0?e[n]:me.cwd();if("string"!=typeof a)throw new TypeError("Arguments to path.resolve must be strings");if(!a)return"";r=a+"/"+r,t=q.isAbs(a)}return(t?"/":"")+(r=q.normalizeArray(r.split("/").filter(e=>!!e),!t).join("/"))||"."},relative:(e,r)=>{function t(e){for(var r=0;r<e.length&&""===e[r];r++);for(var t=e.length-1;t>=0&&""===e[t];t--);return r>t?[]:e.slice(r,t-r+1)}e=Q.resolve(e).slice(1),r=Q.resolve(r).slice(1);for(var n=t(e.split("/")),a=t(r.split("/")),o=Math.min(n.length,a.length),i=o,s=0;s<o;s++)if(n[s]!==a[s]){i=s;break}var u=[];for(s=i;s<n.length;s++)u.push("..");return(u=u.concat(a.slice(i))).join("/")}},K=globalThis.TextDecoder&&new TextDecoder,Z=(e,r,t,n)=>{var a=r+t;if(n)return a;for(;e[r]&&!(r>=a);)++r;return r},Y=(e,r=0,t,n)=>{var a=Z(e,r,t,n);if(a-r>16&&e.buffer&&K)return K.decode(e.subarray(r,a));for(var o="";r<a;){var i=e[r++];if(128&i){var s=63&e[r++];if(192!=(224&i)){var u=63&e[r++];if((i=224==(240&i)?(15&i)<<12|s<<6|u:(7&i)<<18|s<<12|u<<6|63&e[r++])<65536)o+=String.fromCharCode(i);else{var f=i-65536;o+=String.fromCharCode(55296|f>>10,56320|1023&f)}}else o+=String.fromCharCode((31&i)<<6|s)}else o+=String.fromCharCode(i)}return o},J=[],ee=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n<=127?r++:n<=2047?r+=2:n>=55296&&n<=57343?(r+=4,++t):r+=3}return r},re=(e,r,t,n)=>{if(!(n>0))return 0;for(var a=t,o=t+n-1,i=0;i<e.length;++i){var s=e.codePointAt(i);if(s<=127){if(t>=o)break;r[t++]=s}else if(s<=2047){if(t+1>=o)break;r[t++]=192|s>>6,r[t++]=128|63&s}else if(s<=65535){if(t+2>=o)break;r[t++]=224|s>>12,r[t++]=128|s>>6&63,r[t++]=128|63&s}else{if(t+3>=o)break;r[t++]=240|s>>18,r[t++]=128|s>>12&63,r[t++]=128|s>>6&63,r[t++]=128|63&s,i++}}return r[t]=0,t-a},te=(e,r,t)=>{var n=t>0?t:ee(e)+1,a=new Array(n),o=re(e,a,0,a.length);return r&&(a.length=o),a},ne={ttys:[],init(){},shutdown(){},register(e,r){ne.ttys[e]={input:[],output:[],ops:r},me.registerDevice(e,ne.stream_ops)},stream_ops:{open(e){var r=ne.ttys[e.node.rdev];if(!r)throw new me.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,a){if(!e.tty||!e.tty.ops.get_char)throw new me.ErrnoError(60);for(var o=0,i=0;i<n;i++){var s;try{s=e.tty.ops.get_char(e.tty)}catch(e){throw new me.ErrnoError(29)}if(void 0===s&&0===o)throw new me.ErrnoError(6);if(null==s)break;o++,r[t+i]=s}return o&&(e.node.atime=Date.now()),o},write(e,r,t,n,a){if(!e.tty||!e.tty.ops.put_char)throw new me.ErrnoError(60);try{for(var o=0;o<n;o++)e.tty.ops.put_char(e.tty,r[t+o])}catch(e){throw new me.ErrnoError(29)}return n&&(e.node.mtime=e.node.ctime=Date.now()),o}},default_tty_ops:{get_char:e=>(()=>{if(!J.length){var e=null;if(globalThis.window?.prompt&&null!==(e=window.prompt("Input: "))&&(e+="\n"),!e)return null;J=te(e,!0)}return J.shift()})(),put_char(e,r){null===r||10===r?(d(Y(e.output)),e.output=[]):0!=r&&e.output.push(r)},fsync(e){e.output?.length>0&&(d(Y(e.output)),e.output=[])},ioctl_tcgets:e=>({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)=>0,ioctl_tiocgwinsz:e=>[24,80]},default_tty1_ops:{put_char(e,r){null===r||10===r?(m(Y(e.output)),e.output=[]):0!=r&&e.output.push(r)},fsync(e){e.output?.length>0&&(m(Y(e.output)),e.output=[])}}},ae=(e,r)=>Math.ceil(e/r)*r,oe=e=>{e=ae(e,65536);var r=Zt(65536,e);return r&&((e,r)=>{C.fill(0,e,e+r)})(r,e),r},ie={ops_table:null,mount:e=>ie.createNode(null,"/",16895,0),createNode(e,r,t,n){if(me.isBlkdev(t)||me.isFIFO(t))throw new me.ErrnoError(63);ie.ops_table||={dir:{node:{getattr:ie.node_ops.getattr,setattr:ie.node_ops.setattr,lookup:ie.node_ops.lookup,mknod:ie.node_ops.mknod,rename:ie.node_ops.rename,unlink:ie.node_ops.unlink,rmdir:ie.node_ops.rmdir,readdir:ie.node_ops.readdir,symlink:ie.node_ops.symlink},stream:{llseek:ie.stream_ops.llseek}},file:{node:{getattr:ie.node_ops.getattr,setattr:ie.node_ops.setattr},stream:{llseek:ie.stream_ops.llseek,read:ie.stream_ops.read,write:ie.stream_ops.write,mmap:ie.stream_ops.mmap,msync:ie.stream_ops.msync}},link:{node:{getattr:ie.node_ops.getattr,setattr:ie.node_ops.setattr,readlink:ie.node_ops.readlink},stream:{}},chrdev:{node:{getattr:ie.node_ops.getattr,setattr:ie.node_ops.setattr},stream:me.chrdev_stream_ops}};var a=me.createNode(e,r,t,n);return me.isDir(a.mode)?(a.node_ops=ie.ops_table.dir.node,a.stream_ops=ie.ops_table.dir.stream,a.contents={}):me.isFile(a.mode)?(a.node_ops=ie.ops_table.file.node,a.stream_ops=ie.ops_table.file.stream,a.usedBytes=0,a.contents=ie.emptyFileContents??=new Uint8Array(0)):me.isLink(a.mode)?(a.node_ops=ie.ops_table.link.node,a.stream_ops=ie.ops_table.link.stream):me.isChrdev(a.mode)&&(a.node_ops=ie.ops_table.chrdev.node,a.stream_ops=ie.ops_table.chrdev.stream),a.atime=a.mtime=a.ctime=Date.now(),e&&(e.contents[r]=a,e.atime=e.mtime=e.ctime=a.atime),a},getFileDataAsTypedArray:e=>e.contents.subarray(0,e.usedBytes),expandFileStorage(e,r){var t=e.contents.length;if(!(t>=r)){r=Math.max(r,t*(t<1048576?2:1.125)>>>0),t&&(r=Math.max(r,256));var n=ie.getFileDataAsTypedArray(e);e.contents=new Uint8Array(r),e.contents.set(n)}},resizeFileStorage(e,r){if(e.usedBytes!=r){var t=e.contents;e.contents=new Uint8Array(r),e.contents.set(t.subarray(0,Math.min(r,e.usedBytes))),e.usedBytes=r}},node_ops:{getattr(e){var r={};return r.dev=me.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,me.isDir(e.mode)?r.size=4096:me.isFile(e.mode)?r.size=e.usedBytes:me.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(const t of["mode","atime","mtime","ctime"])null!=r[t]&&(e[t]=r[t]);void 0!==r.size&&ie.resizeFileStorage(e,r.size)},lookup(e,r){throw ie.doesNotExistError||(ie.doesNotExistError=new me.ErrnoError(44),ie.doesNotExistError.stack="<generic error, no stack>"),ie.doesNotExistError},mknod:(e,r,t,n)=>ie.createNode(e,r,t,n),rename(e,r,t){var n;try{n=me.lookupNode(r,t)}catch(e){}if(n){if(me.isDir(e.mode))for(var a in n.contents)throw new me.ErrnoError(55);me.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=me.lookupNode(e,r);for(var n in t.contents)throw new me.ErrnoError(55);delete e.contents[r],e.ctime=e.mtime=Date.now()},readdir:e=>[".","..",...Object.keys(e.contents)],symlink(e,r,t){var n=ie.createNode(e,r,41471,0);return n.link=t,n},readlink(e){if(!me.isLink(e.mode))throw new me.ErrnoError(28);return e.link}},stream_ops:{read(e,r,t,n,a){var o=e.node.contents;if(a>=e.node.usedBytes)return 0;var i=Math.min(e.node.usedBytes-a,n);return r.set(o.subarray(a,a+i),t),i},write(e,r,t,n,a,o){if(r.buffer===x.buffer&&(o=!1),!n)return 0;var i=e.node;return i.mtime=i.ctime=Date.now(),o?(i.contents=r.subarray(t,t+n),i.usedBytes=n):0===i.usedBytes&&0===a?(i.contents=r.slice(t,t+n),i.usedBytes=n):(ie.expandFileStorage(i,a+n),i.contents.set(r.subarray(t,t+n),a),i.usedBytes=Math.max(i.usedBytes,a+n)),n},llseek(e,r,t){var n=r;if(1===t?n+=e.position:2===t&&me.isFile(e.node.mode)&&(n+=e.node.usedBytes),n<0)throw new me.ErrnoError(28);return n},mmap(e,r,t,n,a){if(!me.isFile(e.node.mode))throw new me.ErrnoError(43);var o,i,s=e.node.contents;if(2&a||s.buffer!==x.buffer){if(i=!0,!(o=oe(r)))throw new me.ErrnoError(48);s&&((t>0||t+r<s.length)&&(s=s.subarray?s.subarray(t,t+r):Array.prototype.slice.call(s,t,t+r)),x.set(s,o))}else i=!1,o=s.byteOffset;return{ptr:o,allocated:i}},msync:(e,r,t,n,a)=>(ie.stream_ops.write(e,r,0,n,t,!1),0)}},se=e=>("string"==typeof e&&(e=te(e,!0)),e.subarray||(e=new Uint8Array(e)),e),ue=(e,r)=>{var t=0;return e&&(t|=365),r&&(t|=146),t},fe=0,ce=null,le=[],de=async(e,r,n,o,i,s,u,f)=>{var c=r?Q.resolve(q.join2(e,r)):e;fe++,t.monitorRunDependencies?.(fe);try{var l=n;"string"==typeof n&&(l=await(async e=>{var r=await a(e);return new Uint8Array(r)})(n)),l=await(async(e,r)=>{for(var t of("undefined"!=typeof Browser&&Browser.init(),le))if(t.canHandle(r))return t.handle(e,r);return e})(l,c),f?.(),s||((...e)=>{me.createDataFile(...e)})(e,r,l,o,i,u)}finally{(()=>{if(fe--,t.monitorRunDependencies?.(fe),0==fe&&ce){var e=ce;ce=null,e()}})()}},me={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,filesystems:null,syncFSRequests:0,ErrnoError:class{name="ErrnoError";constructor(e){this.errno=e}},FSStream:class{shared={};get object(){return this.node}set object(e){this.node=e}get isRead(){return 1!=(2097155&this.flags)}get isWrite(){return!!(2097155&this.flags)}get isAppend(){return 1024&this.flags}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=me.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 me.isDir(this.mode)}get isDevice(){return me.isChrdev(this.mode)}},lookupPath(e,r={}){if(!e)throw new me.ErrnoError(44);r.follow_mount??=!0,q.isAbs(e)||(e=me.cwd()+"/"+e);e:for(var t=0;t<40;t++){for(var n=e.split("/").filter(e=>!!e),a=me.root,o="/",i=0;i<n.length;i++){var s=i===n.length-1;if(s&&r.parent)break;if("."!==n[i])if(".."!==n[i]){o=q.join2(o,n[i]);try{a=me.lookupNode(a,n[i])}catch(e){if(44===e?.errno&&s&&r.noent_okay)return{path:o};throw e}if(!me.isMountpoint(a)||s&&!r.follow_mount||(a=a.mounted.root),me.isLink(a.mode)&&(!s||r.follow)){if(!a.node_ops.readlink)throw new me.ErrnoError(52);var u=a.node_ops.readlink(a);q.isAbs(u)||(u=q.dirname(o)+"/"+u),e=u+"/"+n.slice(i+1).join("/");continue e}}else{if(o=q.dirname(o),me.isRoot(a)){e=o+"/"+n.slice(i+1).join("/"),t--;continue e}a=a.parent}}return{path:o,node:a}}throw new me.ErrnoError(32)},getPath(e){for(var r;;){if(me.isRoot(e)){var t=e.mount.mountpoint;return r?"/"!==t[t.length-1]?`${t}/${r}`:t+r:t}r=r?`${e.name}/${r}`:e.name,e=e.parent}},hashName(e,r){for(var t=0,n=0;n<r.length;n++)t=(t<<5)-t+r.charCodeAt(n)|0;return(e+t>>>0)%me.nameTable.length},hashAddNode(e){var r=me.hashName(e.parent.id,e.name);e.name_next=me.nameTable[r],me.nameTable[r]=e},hashRemoveNode(e){var r=me.hashName(e.parent.id,e.name);if(me.nameTable[r]===e)me.nameTable[r]=e.name_next;else for(var t=me.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next}},lookupNode(e,r){var t=me.mayLookup(e);if(t)throw new me.ErrnoError(t);for(var n=me.hashName(e.id,r),a=me.nameTable[n];a;a=a.name_next){var o=a.name;if(a.parent.id===e.id&&o===r)return a}return me.lookup(e,r)},createNode(e,r,t,n){var a=new me.FSNode(e,r,t,n);return me.hashAddNode(a),a},destroyNode(e){me.hashRemoveNode(e)},isRoot:e=>e===e.parent,isMountpoint:e=>!!e.mounted,isFile:e=>32768==(61440&e),isDir:e=>16384==(61440&e),isLink:e=>40960==(61440&e),isChrdev:e=>8192==(61440&e),isBlkdev:e=>24576==(61440&e),isFIFO:e=>4096==(61440&e),isSocket:e=>!(49152&~e),flagsToPermissionString(e){var r=["r","w","rw"][3&e];return 512&e&&(r+="w"),r},nodePermissions:(e,r)=>me.ignorePermissions||(!r.includes("r")||292&e.mode)&&(!r.includes("w")||146&e.mode)&&(!r.includes("x")||73&e.mode)?0:2,mayLookup(e){if(!me.isDir(e.mode))return 54;var r=me.nodePermissions(e,"x");return r||(e.node_ops.lookup?0:2)},mayCreate(e,r){if(!me.isDir(e.mode))return 54;try{return me.lookupNode(e,r),20}catch(e){}return me.nodePermissions(e,"wx")},mayDelete(e,r,t){var n;try{n=me.lookupNode(e,r)}catch(e){return e.errno}var a=me.nodePermissions(e,"wx");if(a)return a;if(t){if(!me.isDir(n.mode))return 54;if(me.isRoot(n)||me.getPath(n)===me.cwd())return 10}else if(me.isDir(n.mode))return 31;return 0},mayOpen(e,r){if(!e)return 44;if(me.isLink(e.mode))return 32;var t=me.flagsToPermissionString(r);return me.isDir(e.mode)&&("r"!==t||576&r)?31:me.nodePermissions(e,t)},checkOpExists(e,r){if(!e)throw new me.ErrnoError(r);return e},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=me.MAX_OPEN_FDS;e++)if(!me.streams[e])return e;throw new me.ErrnoError(33)},getStreamChecked(e){var r=me.getStream(e);if(!r)throw new me.ErrnoError(8);return r},getStream:e=>me.streams[e],createStream:(e,r=-1)=>(e=Object.assign(new me.FSStream,e),-1==r&&(r=me.nextfd()),e.fd=r,me.streams[r]=e,e),closeStream(e){me.streams[e]=null},dupStream(e,r=-1){var t=me.createStream(e,r);return t.stream_ops?.dup?.(t),t},doSetAttr(e,r,t){var n=e?.stream_ops.setattr,a=n?e:r;n??=r.node_ops.setattr,me.checkOpExists(n,63);try{n(a,t)}catch(e){if(e instanceof RangeError)throw new me.ErrnoError(22);throw e}},chrdev_stream_ops:{open(e){var r=me.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open?.(e)},llseek(){throw new me.ErrnoError(70)}},major:e=>e>>8,minor:e=>255&e,makedev:(e,r)=>e<<8|r,registerDevice(e,r){me.devices[e]={stream_ops:r}},getDevice:e=>me.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){"function"==typeof e&&(r=e,e=!1),me.syncFSRequests++,me.syncFSRequests>1&&m(`warning: ${me.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var t=me.getMounts(me.root.mount),n=0;function a(e){return me.syncFSRequests--,r(e)}function o(e){if(e)return o.errored?void 0:(o.errored=!0,a(e));++n>=t.length&&a(null)}for(var i of t)i.type.syncfs?i.type.syncfs(i,e,o):o(null)},mount(e,r,t){var n,a="/"===t,o=!t;if(a&&me.root)throw new me.ErrnoError(10);if(!a&&!o){var i=me.lookupPath(t,{follow_mount:!1});if(t=i.path,n=i.node,me.isMountpoint(n))throw new me.ErrnoError(10);if(!me.isDir(n.mode))throw new me.ErrnoError(54)}var s={type:e,opts:r,mountpoint:t,mounts:[]},u=e.mount(s);return u.mount=s,s.root=u,a?me.root=u:n&&(n.mounted=s,n.mount&&n.mount.mounts.push(s)),u},unmount(e){var r=me.lookupPath(e,{follow_mount:!1});if(!me.isMountpoint(r.node))throw new me.ErrnoError(28);var t=r.node,n=t.mounted,a=me.getMounts(n);for(var[o,i]of Object.entries(me.nameTable))for(;i;){var s=i.name_next;a.includes(i.mount)&&me.destroyNode(i),i=s}t.mounted=null;var u=t.mount.mounts.indexOf(n);t.mount.mounts.splice(u,1)},lookup:(e,r)=>e.node_ops.lookup(e,r),mknod(e,r,t){var n=me.lookupPath(e,{parent:!0}).node,a=q.basename(e);if(!a)throw new me.ErrnoError(28);if("."===a||".."===a)throw new me.ErrnoError(20);var o=me.mayCreate(n,a);if(o)throw new me.ErrnoError(o);if(!n.node_ops.mknod)throw new me.ErrnoError(63);return n.node_ops.mknod(n,a,r,t)},statfs:e=>me.statfsNode(me.lookupPath(e,{follow:!0}).node),statfsStream:e=>me.statfsNode(e.node),statfsNode(e){var r={bsize:4096,frsize:4096,blocks:1e6,bfree:5e5,bavail:5e5,files:me.nextInode,ffree:me.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)=>(r&=4095,r|=32768,me.mknod(e,r,0)),mkdir:(e,r=511)=>(r&=1023,r|=16384,me.mknod(e,r,0)),mkdirTree(e,r){var t=e.split("/"),n="";for(var a of t)if(a){(n||q.isAbs(e))&&(n+="/"),n+=a;try{me.mkdir(n,r)}catch(e){if(20!=e.errno)throw e}}},mkdev:(e,r,t)=>(void 0===t&&(t=r,r=438),r|=8192,me.mknod(e,r,t)),symlink(e,r){if(!Q.resolve(e))throw new me.ErrnoError(44);var t=me.lookupPath(r,{parent:!0}).node;if(!t)throw new me.ErrnoError(44);var n=q.basename(r),a=me.mayCreate(t,n);if(a)throw new me.ErrnoError(a);if(!t.node_ops.symlink)throw new me.ErrnoError(63);return t.node_ops.symlink(t,n,e)},rename(e,r){var t,n,a=q.dirname(e),o=q.dirname(r),i=q.basename(e),s=q.basename(r);if(t=me.lookupPath(e,{parent:!0}).node,n=me.lookupPath(r,{parent:!0}).node,!t||!n)throw new me.ErrnoError(44);if(t.mount!==n.mount)throw new me.ErrnoError(75);var u,f=me.lookupNode(t,i),c=Q.relative(e,o);if("."!==c.charAt(0))throw new me.ErrnoError(28);if("."!==(c=Q.relative(r,a)).charAt(0))throw new me.ErrnoError(55);try{u=me.lookupNode(n,s)}catch(e){}if(f!==u){var l=me.isDir(f.mode),d=me.mayDelete(t,i,l);if(d)throw new me.ErrnoError(d);if(d=u?me.mayDelete(n,s,l):me.mayCreate(n,s))throw new me.ErrnoError(d);if(!t.node_ops.rename)throw new me.ErrnoError(63);if(me.isMountpoint(f)||u&&me.isMountpoint(u))throw new me.ErrnoError(10);if(n!==t&&(d=me.nodePermissions(t,"w")))throw new me.ErrnoError(d);me.hashRemoveNode(f);try{t.node_ops.rename(f,n,s),f.parent=n}catch(e){throw e}finally{me.hashAddNode(f)}}},rmdir(e){var r=me.lookupPath(e,{parent:!0}).node,t=q.basename(e),n=me.lookupNode(r,t),a=me.mayDelete(r,t,!0);if(a)throw new me.ErrnoError(a);if(!r.node_ops.rmdir)throw new me.ErrnoError(63);if(me.isMountpoint(n))throw new me.ErrnoError(10);r.node_ops.rmdir(r,t),me.destroyNode(n)},readdir(e){var r=me.lookupPath(e,{follow:!0}).node;return me.checkOpExists(r.node_ops.readdir,54)(r)},unlink(e){var r=me.lookupPath(e,{parent:!0}).node;if(!r)throw new me.ErrnoError(44);var t=q.basename(e),n=me.lookupNode(r,t),a=me.mayDelete(r,t,!1);if(a)throw new me.ErrnoError(a);if(!r.node_ops.unlink)throw new me.ErrnoError(63);if(me.isMountpoint(n))throw new me.ErrnoError(10);r.node_ops.unlink(r,t),me.destroyNode(n)},readlink(e){var r=me.lookupPath(e).node;if(!r)throw new me.ErrnoError(44);if(!r.node_ops.readlink)throw new me.ErrnoError(28);return r.node_ops.readlink(r)},stat(e,r){var t=me.lookupPath(e,{follow:!r}).node;return me.checkOpExists(t.node_ops.getattr,63)(t)},fstat(e){var r=me.getStreamChecked(e),t=r.node,n=r.stream_ops.getattr,a=n?r:t;return n??=t.node_ops.getattr,me.checkOpExists(n,63),n(a)},lstat:e=>me.stat(e,!0),doChmod(e,r,t,n){me.doSetAttr(e,r,{mode:4095&t|-4096&r.mode,ctime:Date.now(),dontFollow:n})},chmod(e,r,t){var n;n="string"==typeof e?me.lookupPath(e,{follow:!t}).node:e,me.doChmod(null,n,r,t)},lchmod(e,r){me.chmod(e,r,!0)},fchmod(e,r){var t=me.getStreamChecked(e);me.doChmod(t,t.node,r,!1)},doChown(e,r,t){me.doSetAttr(e,r,{timestamp:Date.now(),dontFollow:t})},chown(e,r,t,n){var a;a="string"==typeof e?me.lookupPath(e,{follow:!n}).node:e,me.doChown(null,a,n)},lchown(e,r,t){me.chown(e,r,t,!0)},fchown(e,r,t){var n=me.getStreamChecked(e);me.doChown(n,n.node,!1)},doTruncate(e,r,t){if(me.isDir(r.mode))throw new me.ErrnoError(31);if(!me.isFile(r.mode))throw new me.ErrnoError(28);var n=me.nodePermissions(r,"w");if(n)throw new me.ErrnoError(n);me.doSetAttr(e,r,{size:t,timestamp:Date.now()})},truncate(e,r){if(r<0)throw new me.ErrnoError(28);var t;t="string"==typeof e?me.lookupPath(e,{follow:!0}).node:e,me.doTruncate(null,t,r)},ftruncate(e,r){var t=me.getStreamChecked(e);if(r<0||!(2097155&t.flags))throw new me.ErrnoError(28);me.doTruncate(t,t.node,r)},utime(e,r,t){var n=me.lookupPath(e,{follow:!0}).node;me.checkOpExists(n.node_ops.setattr,63)(n,{atime:r,mtime:t})},open(e,r,t=438){if(""===e)throw new me.ErrnoError(44);var n,a;if(t=64&(r=(e=>{if("string"!=typeof e)return e;var r={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[e];if(void 0===r)throw new Error(`Unknown file open mode: ${e}`);return r})(r))?4095&t|32768:0,"object"==typeof e)n=e;else{a=e.endsWith("/");var o=me.lookupPath(e,{follow:!(131072&r),noent_okay:!0});n=o.node,e=o.path}var i=!1;if(64&r)if(n){if(128&r)throw new me.ErrnoError(20)}else{if(a)throw new me.ErrnoError(31);n=me.mknod(e,511|t,0),i=!0}if(!n)throw new me.ErrnoError(44);if(me.isChrdev(n.mode)&&(r&=-513),65536&r&&!me.isDir(n.mode))throw new me.ErrnoError(54);if(!i){var s=me.mayOpen(n,r);if(s)throw new me.ErrnoError(s)}512&r&&!i&&me.truncate(n,0),r&=-131713;var u=me.createStream({node:n,path:me.getPath(n),flags:r,seekable:!0,position:0,stream_ops:n.stream_ops,ungotten:[],error:!1});return u.stream_ops.open&&u.stream_ops.open(u),i&&me.chmod(n,511&t),u},close(e){if(me.isClosed(e))throw new me.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(e){throw e}finally{me.closeStream(e.fd)}e.fd=null},isClosed:e=>null===e.fd,llseek(e,r,t){if(me.isClosed(e))throw new me.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new me.ErrnoError(70);if(0!=t&&1!=t&&2!=t)throw new me.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read(e,r,t,n,a){if(n<0||a<0)throw new me.ErrnoError(28);if(me.isClosed(e))throw new me.ErrnoError(8);if(1==(2097155&e.flags))throw new me.ErrnoError(8);if(me.isDir(e.node.mode))throw new me.ErrnoError(31);if(!e.stream_ops.read)throw new me.ErrnoError(28);var o=void 0!==a;if(o){if(!e.seekable)throw new me.ErrnoError(70)}else a=e.position;var i=e.stream_ops.read(e,r,t,n,a);return o||(e.position+=i),i},write(e,r,t,n,a,o){if(n<0||a<0)throw new me.ErrnoError(28);if(me.isClosed(e))throw new me.ErrnoError(8);if(!(2097155&e.flags))throw new me.ErrnoError(8);if(me.isDir(e.node.mode))throw new me.ErrnoError(31);if(!e.stream_ops.write)throw new me.ErrnoError(28);e.seekable&&1024&e.flags&&me.llseek(e,0,2);var i=void 0!==a;if(i){if(!e.seekable)throw new me.ErrnoError(70)}else a=e.position;var s=e.stream_ops.write(e,r,t,n,a,o);return i||(e.position+=s),s},mmap(e,r,t,n,a){if(2&n&&!(2&a)&&2!=(2097155&e.flags))throw new me.ErrnoError(2);if(1==(2097155&e.flags))throw new me.ErrnoError(2);if(!e.stream_ops.mmap)throw new me.ErrnoError(43);if(!r)throw new me.ErrnoError(28);return e.stream_ops.mmap(e,r,t,n,a)},msync:(e,r,t,n,a)=>e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,a):0,ioctl(e,r,t){if(!e.stream_ops.ioctl)throw new me.ErrnoError(59);return e.stream_ops.ioctl(e,r,t)},readFile(e,r={}){r.flags=r.flags||0,r.encoding=r.encoding||"binary","utf8"!==r.encoding&&"binary"!==r.encoding&&S(`Invalid encoding type "${r.encoding}"`);var t=me.open(e,r.flags),n=me.stat(e).size,a=new Uint8Array(n);return me.read(t,a,0,n,0),"utf8"===r.encoding&&(a=Y(a)),me.close(t),a},writeFile(e,r,t={}){t.flags=t.flags||577;var n=me.open(e,t.flags,t.mode);r=se(r),me.write(n,r,0,r.byteLength,void 0,t.canOwn),me.close(n)},cwd:()=>me.currentPath,chdir(e){var r=me.lookupPath(e,{follow:!0});if(null===r.node)throw new me.ErrnoError(44);if(!me.isDir(r.node.mode))throw new me.ErrnoError(54);var t=me.nodePermissions(r.node,"x");if(t)throw new me.ErrnoError(t);me.currentPath=r.path},createDefaultDirectories(){me.mkdir("/tmp"),me.mkdir("/home"),me.mkdir("/home/web_user")},createDefaultDevices(){me.mkdir("/dev"),me.registerDevice(me.makedev(1,3),{read:()=>0,write:(e,r,t,n,a)=>n,llseek:()=>0}),me.mkdev("/dev/null",me.makedev(1,3)),ne.register(me.makedev(5,0),ne.default_tty_ops),ne.register(me.makedev(6,0),ne.default_tty1_ops),me.mkdev("/dev/tty",me.makedev(5,0)),me.mkdev("/dev/tty1",me.makedev(6,0));var e=new Uint8Array(1024),r=0,t=()=>(0===r&&(H(e),r=e.byteLength),e[--r]);me.createDevice("/dev","random",t),me.createDevice("/dev","urandom",t),me.mkdir("/dev/shm"),me.mkdir("/dev/shm/tmp")},createSpecialDirectories(){me.mkdir("/proc");var e=me.mkdir("/proc/self");me.mkdir("/proc/self/fd"),me.mount({mount(){var r=me.createNode(e,"fd",16895,73);return r.stream_ops={llseek:ie.stream_ops.llseek},r.node_ops={lookup(e,r){var t=+r,n=me.getStreamChecked(t),a={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>n.path},id:t+1};return a.parent=a,a},readdir:()=>Array.from(me.streams.entries()).filter(([e,r])=>r).map(([e,r])=>e.toString())},r}},{},"/proc/self/fd")},createStandardStreams(e,r,t){e?me.createDevice("/dev","stdin",e):me.symlink("/dev/tty","/dev/stdin"),r?me.createDevice("/dev","stdout",null,r):me.symlink("/dev/tty","/dev/stdout"),t?me.createDevice("/dev","stderr",null,t):me.symlink("/dev/tty1","/dev/stderr"),me.open("/dev/stdin",0),me.open("/dev/stdout",1),me.open("/dev/stderr",1)},staticInit(){me.nameTable=new Array(4096),me.mount(ie,{},"/"),me.createDefaultDirectories(),me.createDefaultDevices(),me.createSpecialDirectories(),me.filesystems={MEMFS:ie}},init(e,r,n){me.initialized=!0,e??=t.stdin,r??=t.stdout,n??=t.stderr,me.createStandardStreams(e,r,n)},quit(){for(var e of(me.initialized=!1,me.streams))e&&me.close(e)},findObject(e,r){var t=me.analyzePath(e,r);return t.exists?t.object:null},analyzePath(e,r){try{e=(n=me.lookupPath(e,{follow:!r})).path}catch(e){}var t={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var n=me.lookupPath(e,{parent:!0});t.parentExists=!0,t.parentPath=n.path,t.parentObject=n.node,t.name=q.basename(e),n=me.lookupPath(e,{follow:!r}),t.exists=!0,t.path=n.path,t.object=n.node,t.name=n.node.name,t.isRoot="/"===n.path}catch(e){t.error=e.errno}return t},createPath(e,r,t,n){e="string"==typeof e?e:me.getPath(e);for(var a=r.split("/").reverse();a.length;){var o=a.pop();if(o){var i=q.join2(e,o);try{me.mkdir(i)}catch(e){if(20!=e.errno)throw e}e=i}}return i},createFile(e,r,t,n,a){var o=q.join2("string"==typeof e?e:me.getPath(e),r),i=ue(n,a);return me.create(o,i)},createDataFile(e,r,t,n,a,o){var i=r;e&&(e="string"==typeof e?e:me.getPath(e),i=r?q.join2(e,r):e);var s=ue(n,a),u=me.create(i,s);if(t){t=se(t),me.chmod(u,146|s);var f=me.open(u,577);me.write(f,t,0,t.length,0,o),me.close(f),me.chmod(u,s)}},createDevice(e,r,t,n){var a=q.join2("string"==typeof e?e:me.getPath(e),r),o=ue(!!t,!!n);me.createDevice.major??=64;var i=me.makedev(me.createDevice.major++,0);return me.registerDevice(i,{open(e){e.seekable=!1},close(e){n?.buffer?.length&&n(10)},read(e,r,n,a,o){for(var i=0,s=0;s<a;s++){var u;try{u=t()}catch(e){throw new me.ErrnoError(29)}if(void 0===u&&0===i)throw new me.ErrnoError(6);if(null==u)break;i++,r[n+s]=u}return i&&(e.node.atime=Date.now()),i},write(e,r,t,a,o){for(var i=0;i<a;i++)try{n(r[t+i])}catch(e){throw new me.ErrnoError(29)}return a&&(e.node.mtime=e.node.ctime=Date.now()),i}}),me.mkdev(a,o,i)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if(globalThis.XMLHttpRequest)S("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");else try{e.contents=o(e.url)}catch(e){throw new me.ErrnoError(29)}},createLazyFile(e,r,t,a,o){class i{lengthKnown=!1;chunks=[];get(e){if(!(e>this.length-1||e<0)){var r=e%this.chunkSize,t=e/this.chunkSize|0;return this.getter(t)[r]}}setDataGetter(e){this.getter=e}cacheLength(){var e=new XMLHttpRequest;e.open("HEAD",t,!1),e.send(null),e.status>=200&&e.status<300||304===e.status||S("Couldn't load "+t+". Status: "+e.status);var r,n=Number(e.getResponseHeader("Content-length")),a=(r=e.getResponseHeader("Accept-Ranges"))&&"bytes"===r,o=(r=e.getResponseHeader("Content-Encoding"))&&"gzip"===r,i=1048576;a||(i=n);var s=this;s.setDataGetter(e=>{var r=e*i,a=(e+1)*i-1;return a=Math.min(a,n-1),void 0===s.chunks[e]&&(s.chunks[e]=((e,r)=>{e>r&&S("invalid range ("+e+", "+r+") or no bytes requested!"),r>n-1&&S("only "+n+" bytes available! programmer error!");var a=new XMLHttpRequest;return a.open("GET",t,!1),n!==i&&a.setRequestHeader("Range","bytes="+e+"-"+r),a.responseType="arraybuffer",a.overrideMimeType&&a.overrideMimeType("text/plain; charset=x-user-defined"),a.send(null),a.status>=200&&a.status<300||304===a.status||S("Couldn't load "+t+". Status: "+a.status),void 0!==a.response?new Uint8Array(a.response||[]):te(a.responseText||"",!0)})(r,a)),void 0===s.chunks[e]&&S("doXHR failed!"),s.chunks[e]}),!o&&n||(i=n=1,n=this.getter(0).length,i=n,d("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=n,this._chunkSize=i,this.lengthKnown=!0}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(globalThis.XMLHttpRequest){n||S("Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc");var s={isDevice:!1,contents:new i}}else s={isDevice:!1,url:t};var u=me.createFile(e,r,s,a,o);s.contents?u.contents=s.contents:s.url&&(u.contents=null,u.url=s.url),Object.defineProperties(u,{usedBytes:{get:function(){return this.contents.length}}});var f={};for(const[e,r]of Object.entries(u.stream_ops))f[e]=(...e)=>(me.forceLoadFile(u),r(...e));function c(e,r,t,n,a){var o=e.node.contents;if(a>=o.length)return 0;var i=Math.min(o.length-a,n);if(o.slice)for(var s=0;s<i;s++)r[t+s]=o[a+s];else for(s=0;s<i;s++)r[t+s]=o.get(a+s);return i}return f.read=(e,r,t,n,a)=>(me.forceLoadFile(u),c(e,r,t,n,a)),f.mmap=(e,r,t,n,a)=>{me.forceLoadFile(u);var o=oe(r);if(!o)throw new me.ErrnoError(48);return c(e,x,o,r,t),{ptr:o,allocated:!0}},u.stream_ops=f,u}},pe=(e,r,t)=>e?Y(C,e,r,t):"",he={currentUmask:18,calculateAt(e,r,t){if(q.isAbs(r))return r;var n;if(n=-100===e?me.cwd():he.getStreamFromFD(e).path,0==r.length){if(!t)throw new me.ErrnoError(44);return n}return n+"/"+r},writeStat(e,r){T[e>>2]=r.dev,T[e+4>>2]=r.mode,T[e+8>>2]=r.nlink,T[e+12>>2]=r.uid,T[e+16>>2]=r.gid,T[e+20>>2]=r.rdev,E[e+24>>3]=BigInt(r.size),w[e+32>>2]=4096,w[e+36>>2]=r.blocks;var t=r.atime.getTime(),n=r.mtime.getTime(),a=r.ctime.getTime();return E[e+40>>3]=BigInt(Math.floor(t/1e3)),T[e+48>>2]=t%1e3*1e3*1e3,E[e+56>>3]=BigInt(Math.floor(n/1e3)),T[e+64>>2]=n%1e3*1e3*1e3,E[e+72>>3]=BigInt(Math.floor(a/1e3)),T[e+80>>2]=a%1e3*1e3*1e3,E[e+88>>3]=BigInt(r.ino),0},writeStatFs(e,r){T[e+4>>2]=r.bsize,T[e+60>>2]=r.bsize,E[e+8>>3]=BigInt(r.blocks),E[e+16>>3]=BigInt(r.bfree),E[e+24>>3]=BigInt(r.bavail),E[e+32>>3]=BigInt(r.files),E[e+40>>3]=BigInt(r.ffree),T[e+48>>2]=r.fsid,T[e+64>>2]=r.flags,T[e+56>>2]=r.namelen},doMsync(e,r,t,n,a){if(!me.isFile(r.node.mode))throw new me.ErrnoError(43);if(2&n)return 0;var o=C.slice(e,e+t);me.msync(r,o,a,t,n)},getStreamFromFD:e=>me.getStreamChecked(e),varargs:void 0,getStr:e=>pe(e)},ve={},ge=e=>{for(;e.length;){var r=e.pop();e.pop()(r)}};function ye(e){return this.fromWireType(T[e>>2])}var be={},we={},Ee={},xe=class extends Error{constructor(e){super(e),this.name="InternalError"}},_e=e=>{throw new xe(e)},ke=(e,r,t)=>{function n(r){var n=t(r);n.length!==e.length&&_e("Mismatched type converter count");for(var a=0;a<e.length;++a)Ce(e[a],n[a])}e.forEach(e=>Ee[e]=r);var a=new Array(r.length),o=[],i=0;for(let[e,t]of r.entries())we.hasOwnProperty(t)?a[e]=we[t]:(o.push(t),be.hasOwnProperty(t)||(be[t]=[]),be[t].push(()=>{a[e]=we[t],++i===o.length&&n(a)}));0===o.length&&n(a)},Be=e=>{for(var r="";;){var t=C[e++];if(!t)return r;r+=String.fromCharCode(t)}},Te=class extends Error{constructor(e){super(e),this.name="BindingError"}},Pe=e=>{throw new Te(e)};function Ce(e,r,t={}){return function(e,r,t={}){var n=r.name;if(e||Pe(`type "${n}" must have a positive integer typeid pointer`),we.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;Pe(`Cannot register type '${n}' twice`)}if(we[e]=r,delete Ee[e],be.hasOwnProperty(e)){var a=be[e];delete be[e],a.forEach(e=>e())}}(e,r,t)}var $e=(e,r,t)=>{switch(r){case 1:return t?e=>x[e]:e=>C[e];case 2:return t?e=>b[e>>1]:e=>B[e>>1];case 4:return t?e=>w[e>>2]:e=>T[e>>2];case 8:return t?e=>E[e>>3]:e=>P[e>>3];default:throw new TypeError(`invalid integer width (${r}): ${e}`)}},Ae=e=>{Pe(e.$$.ptrType.registeredClass.name+" instance already deleted")},Se=!1,De=e=>{},Fe=e=>{e.count.value-=1,0===e.count.value&&(e=>{e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)})(e)},Le=e=>globalThis.FinalizationRegistry?(Se=new FinalizationRegistry(e=>{Fe(e.$$)}),Le=e=>{var r=e.$$;if(r.smartPtr){var t={$$:r};Se.register(e,t,e)}return e},De=e=>Se.unregister(e),Le(e)):(Le=e=>e,e),Ie=[];function Me(){}var Re=(e,r)=>Object.defineProperty(r,"name",{value:e}),Ne={},Ve=(e,r,t)=>{if(void 0===e[r].overloadTable){var n=e[r];e[r]=function(...n){return e[r].overloadTable.hasOwnProperty(n.length)||Pe(`Function '${t}' called with an invalid number of arguments (${n.length}) - expects one of (${e[r].overloadTable})!`),e[r].overloadTable[n.length].apply(this,n)},e[r].overloadTable=[],e[r].overloadTable[n.argCount]=n}},We=(e,r,n)=>{t.hasOwnProperty(e)?((void 0===n||void 0!==t[e].overloadTable&&void 0!==t[e].overloadTable[n])&&Pe(`Cannot register public name '${e}' twice`),Ve(t,e,e),t[e].overloadTable.hasOwnProperty(n)&&Pe(`Cannot register multiple overloads of a function with the same number of arguments (${n})!`),t[e].overloadTable[n]=r):(t[e]=r,t[e].argCount=n)};function Oe(e,r,t,n,a,o,i,s){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=a,this.getActualType=o,this.upcast=i,this.downcast=s,this.pureVirtualFunctions=[]}var je=(e,r,t)=>{for(;r!==t;)r.upcast||Pe(`Expected null or instance of ${t.name}, got an instance of ${r.name}`),e=r.upcast(e),r=r.baseClass;return e},Ue=e=>{if(null===e)return"null";var r=typeof e;return"object"===r||"array"===r||"function"===r?e.toString():""+e};function Ge(e,r){if(null===r)return this.isReference&&Pe(`null is not a valid ${this.name}`),0;r.$$||Pe(`Cannot pass "${Ue(r)}" as a ${this.name}`),r.$$.ptr||Pe(`Cannot pass deleted object as a pointer of type ${this.name}`);var t=r.$$.ptrType.registeredClass;return je(r.$$.ptr,t,this.registeredClass)}function ze(e,r){var t;if(null===r)return this.isReference&&Pe(`null is not a valid ${this.name}`),this.isSmartPointer?(t=this.rawConstructor(),null!==e&&e.push(this.rawDestructor,t),t):0;r&&r.$$||Pe(`Cannot pass "${Ue(r)}" as a ${this.name}`),r.$$.ptr||Pe(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&r.$$.ptrType.isConst&&Pe(`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=je(r.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(void 0===r.$$.smartPtr&&Pe("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:Pe(`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 a=r.clone();t=this.rawShare(t,pr.toHandle(()=>a.delete())),null!==e&&e.push(this.rawDestructor,t)}break;default:Pe("Unsupported sharing policy")}return t}function Xe(e,r){if(null===r)return this.isReference&&Pe(`null is not a valid ${this.name}`),0;r.$$||Pe(`Cannot pass "${Ue(r)}" as a ${this.name}`),r.$$.ptr||Pe(`Cannot pass deleted object as a pointer of type ${this.name}`),r.$$.ptrType.isConst&&Pe(`Cannot convert argument of type ${r.$$.ptrType.name} to parameter type ${this.name}`);var t=r.$$.ptrType.registeredClass;return je(r.$$.ptr,t,this.registeredClass)}var qe=(e,r,t)=>{if(r===t)return e;if(void 0===t.baseClass)return null;var n=qe(e,r,t.baseClass);return null===n?null:t.downcast(n)},He={},Qe=(e,r)=>(r=((e,r)=>{for(void 0===r&&Pe("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r})(e,r),He[r]),Ke=(e,r)=>(r.ptrType&&r.ptr||_e("makeClassHandle requires ptr and ptrType"),!!r.smartPtrType!=!!r.smartPtr&&_e("Both smartPtrType and smartPtr must be specified"),r.count={value:1},Le(Object.create(e,{$$:{value:r,writable:!0}})));function Ze(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=Qe(this.registeredClass,r);if(void 0!==t){if(0===t.$$.count.value)return t.$$.ptr=r,t.$$.smartPtr=e,t.clone();var n=t.clone();return this.destructor(e),n}function a(){return this.isSmartPointer?Ke(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):Ke(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var o,i=this.registeredClass.getActualType(r),s=Ne[i];if(!s)return a.call(this);o=this.isConst?s.constPointerType:s.pointerType;var u=qe(r,this.registeredClass,o.registeredClass);return null===u?a.call(this):this.isSmartPointer?Ke(o.registeredClass.instancePrototype,{ptrType:o,ptr:u,smartPtrType:this,smartPtr:e}):Ke(o.registeredClass.instancePrototype,{ptrType:o,ptr:u})}function Ye(e,r,t,n,a,o,i,s,u,f,c){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=a,this.pointeeType=o,this.sharingPolicy=i,this.rawGetPointee=s,this.rawConstructor=u,this.rawShare=f,this.rawDestructor=c,a||void 0!==r.baseClass?this.toWireType=ze:n?(this.toWireType=Ge,this.destructorFunction=null):(this.toWireType=Xe,this.destructorFunction=null)}var Je=[],er=e=>{var r=Je[e];return r||(Je[e]=r=tn.get(e)),r},rr=(e,r,t=!1)=>{e=Be(e);var n=er(r);return"function"!=typeof n&&Pe(`unknown function pointer with signature ${e}: ${r}`),n};class tr extends Error{}var nr=e=>{var r=Ht(e),t=Be(r);return Kt(r),t},ar=(e,r)=>{var t=[],n={};throw r.forEach(function e(r){n[r]||we[r]||(Ee[r]?Ee[r].forEach(e):(t.push(r),n[r]=!0))}),new tr(`${e}: `+t.map(nr).join([", "]))},or=(e,r)=>{for(var t=[],n=0;n<e;n++)t.push(T[r+4*n>>2]);return t};function ir(e){for(var r=1;r<e.length;++r)if(null!==e[r]&&void 0===e[r].destructorFunction)return!0;return!1}function sr(e,r,t,n,a,o){var i=r.length;i<2&&Pe("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var s=null!==r[1]&&null!==t,u=ir(r),f=!r[0].isVoid,c=r[0],l=r[1],d=[e,Pe,n,a,ge,c.fromWireType.bind(c),l?.toWireType.bind(l)],m=2;m<i;++m){var p=r[m];d.push(p.toWireType.bind(p))}if(!u)for(m=s?1:2;m<r.length;++m)null!==r[m].destructorFunction&&d.push(r[m].destructorFunction);let h=function(e,r,t,n){var a=ir(e),o=e.length-2,i=[],s=["fn"];r&&s.push("thisWired");for(var u=0;u<o;++u)i.push(`arg${u}`),s.push(`arg${u}Wired`);i=i.join(","),s=s.join(",");var f=`return function (${i}) {\n`;a&&(f+="var destructors = [];\n");var c=a?"destructors":"null",l=["humanName","throwBindingError","invoker","fn","runDestructors","fromRetWire","toClassParamWire"];for(r&&(f+=`var thisWired = toClassParamWire(${c}, this);\n`),u=0;u<o;++u){var d=`toArg${u}Wire`;f+=`var arg${u}Wired = ${d}(${c}, arg${u});\n`,l.push(d)}if(f+=(t||n?"var rv = ":"")+`invoker(${s});\n`,a)f+="runDestructors(destructors);\n";else for(u=r?1:2;u<e.length;++u){var m=1===u?"thisWired":"arg"+(u-2)+"Wired";null!==e[u].destructorFunction&&(f+=`${m}_dtor(${m});\n`,l.push(`${m}_dtor`))}return t&&(f+="var ret = fromRetWire(rv);\nreturn ret;\n"),f+="}\n",new Function(l,f)}(r,s,f,o);var v=h(...d);return Re(e,v)}var ur,fr,cr=(e,r,t)=>(e instanceof Object||Pe(`${t} with invalid "this": ${e}`),e instanceof r.registeredClass.constructor||Pe(`${t} incompatible with "this" of type ${e.constructor.name}`),e.$$.ptr||Pe(`cannot call emscripten binding method ${t} on deleted object`),je(e.$$.ptr,e.$$.ptrType.registeredClass,r.registeredClass)),lr=[],dr=[0,1,,1,null,1,!0,1,!1,1],mr=e=>{e>9&&0===--dr[e+1]&&(dr[e],dr[e]=void 0,lr.push(e))},pr={toValue:e=>(e||Pe(`Cannot use deleted val. handle = ${e}`),dr[e]),toHandle:e=>{switch(e){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{const r=lr.pop()||dr.length;return dr[r]=e,dr[r+1]=1,r}}}},hr={name:"emscripten::val",fromWireType:e=>{var r=pr.toValue(e);return mr(e),r},toWireType:(e,r)=>pr.toHandle(r),readValueFromPointer:ye,destructorFunction:null},vr=(e,r,t)=>{switch(r){case 1:return t?function(e){return this.fromWireType(x[e])}:function(e){return this.fromWireType(C[e])};case 2:return t?function(e){return this.fromWireType(b[e>>1])}:function(e){return this.fromWireType(B[e>>1])};case 4:return t?function(e){return this.fromWireType(w[e>>2])}:function(e){return this.fromWireType(T[e>>2])};default:throw new TypeError(`invalid integer width (${r}): ${e}`)}},gr=(e,r)=>{var t=we[e];return void 0===t&&Pe(`${r} has unknown type ${nr(e)}`),t},yr=(e,r)=>{switch(r){case 4:return function(e){return this.fromWireType(_[e>>2])};case 8:return function(e){return this.fromWireType(k[e>>3])};default:throw new TypeError(`invalid float width (${r}): ${e}`)}},br=(e,r,t)=>re(e,C,r,t),wr=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,Er=(e,r,t)=>{var n=e>>1,a=Z(B,n,r/2,t);if(a-n>16&&wr)return wr.decode(B.subarray(n,a));for(var o="",i=n;i<a;++i){var s=B[i];o+=String.fromCharCode(s)}return o},xr=(e,r,t)=>{if(t??=2147483647,t<2)return 0;for(var n=r,a=(t-=2)<2*e.length?t/2:e.length,o=0;o<a;++o){var i=e.charCodeAt(o);b[r>>1]=i,r+=2}return b[r>>1]=0,r-n},_r=e=>2*e.length,kr=(e,r,t)=>{for(var n="",a=e>>2,o=0;!(o>=r/4);o++){var i=T[a+o];if(!i&&!t)break;n+=String.fromCodePoint(i)}return n},Br=(e,r,t)=>{if(t??=2147483647,t<4)return 0;for(var n=r,a=n+t-4,o=0;o<e.length;++o){var i=e.codePointAt(o);if(i>65535&&o++,w[r>>2]=i,(r+=4)+4>a)break}return w[r>>2]=0,r-n},Tr=e=>{for(var r=0,t=0;t<e.length;++t)e.codePointAt(t)>65535&&t++,r+=4;return r},Pr=[],Cr=(e,r,t)=>{var n=[],a=e(n,t);return n.length&&(T[r>>2]=pr.toHandle(n)),a},$r={},Ar=e=>{var r=$r[e];return void 0===r?Be(e):r},Sr=e=>e<-9007199254740992||e>9007199254740992?NaN:Number(e),Dr=()=>performance.now(),Fr=()=>Date.now(),Lr=e=>{var r=["ANGLE_instanced_arrays","EXT_blend_minmax","EXT_disjoint_timer_query","EXT_frag_depth","EXT_shader_texture_lod","EXT_sRGB","OES_element_index_uint","OES_fbo_render_mipmap","OES_standard_derivatives","OES_texture_float","OES_texture_half_float","OES_texture_half_float_linear","OES_vertex_array_object","WEBGL_color_buffer_float","WEBGL_depth_texture","WEBGL_draw_buffers","EXT_color_buffer_float","EXT_conservative_depth","EXT_disjoint_timer_query_webgl2","EXT_texture_norm16","NV_shader_noperspective_interpolation","WEBGL_clip_cull_distance","EXT_clip_control","EXT_color_buffer_half_float","EXT_depth_clamp","EXT_float_blend","EXT_polygon_offset_clamp","EXT_texture_compression_bptc","EXT_texture_compression_rgtc","EXT_texture_filter_anisotropic","KHR_parallel_shader_compile","OES_texture_float_linear","WEBGL_blend_func_extended","WEBGL_compressed_texture_astc","WEBGL_compressed_texture_etc","WEBGL_compressed_texture_etc1","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_s3tc_srgb","WEBGL_debug_renderer_info","WEBGL_debug_shaders","WEBGL_lose_context","WEBGL_multi_draw","WEBGL_polygon_mode"];return(e.getSupportedExtensions()||[]).filter(e=>r.includes(e))},Ir={counter:1,buffers:[],mappedBuffers:{},programs:[],framebuffers:[],renderbuffers:[],textures:[],shaders:[],vaos:[],contexts:[],offscreenCanvases:{},queries:[],samplers:[],transformFeedbacks:[],syncs:[],byteSizeByTypeRoot:5120,byteSizeByType:[1,1,2,2,4,4,4,2,3,4,8],stringCache:{},stringiCache:{},unpackAlignment:4,unpackRowLength:0,recordError:e=>{Ir.lastError||(Ir.lastError=e)},getNewId:e=>{for(var r=Ir.counter++,t=e.length;t<r;t++)e[t]=null;for(;e[r];)r=Ir.counter++;return r},genObject:(e,r,t,n)=>{for(var a=0;a<e;a++){var o=ur[t](),i=o&&Ir.getNewId(n);o?(o.name=i,n[i]=o):Ir.recordError(1282),w[r+4*a>>2]=i}},MAX_TEMP_BUFFER_SIZE:2097152,numTempVertexBuffersPerSize:64,log2ceilLookup:e=>32-Math.clz32(0===e?0:e-1),generateTempBuffers:(e,r)=>{var t=Ir.log2ceilLookup(Ir.MAX_TEMP_BUFFER_SIZE);r.tempVertexBufferCounters1=[],r.tempVertexBufferCounters2=[],r.tempVertexBufferCounters1.length=r.tempVertexBufferCounters2.length=t+1,r.tempVertexBuffers1=[],r.tempVertexBuffers2=[],r.tempVertexBuffers1.length=r.tempVertexBuffers2.length=t+1,r.tempIndexBuffers=[],r.tempIndexBuffers.length=t+1;for(var n=0;n<=t;++n){r.tempIndexBuffers[n]=null,r.tempVertexBufferCounters1[n]=r.tempVertexBufferCounters2[n]=0;var a=Ir.numTempVertexBuffersPerSize;r.tempVertexBuffers1[n]=[],r.tempVertexBuffers2[n]=[];var o=r.tempVertexBuffers1[n],i=r.tempVertexBuffers2[n];o.length=i.length=a;for(var s=0;s<a;++s)o[s]=i[s]=null}if(e){r.tempQuadIndexBuffer=ur.createBuffer(),r.GLctx.bindBuffer(34963,r.tempQuadIndexBuffer);for(var u=Ir.MAX_TEMP_BUFFER_SIZE>>1,f=new Uint16Array(u),c=(n=0,0);f[n++]=c,!(n>=u||(f[n++]=c+1,n>=u)||(f[n++]=c+2,n>=u)||(f[n++]=c,n>=u)||(f[n++]=c+2,n>=u)||(f[n++]=c+3,n>=u));)c+=4;r.GLctx.bufferData(34963,f,35044),r.GLctx.bindBuffer(34963,null)}},getTempVertexBuffer:e=>{var r=Ir.log2ceilLookup(e),t=Ir.currentContext.tempVertexBuffers1[r],n=Ir.currentContext.tempVertexBufferCounters1[r];Ir.currentContext.tempVertexBufferCounters1[r]=Ir.currentContext.tempVertexBufferCounters1[r]+1&Ir.numTempVertexBuffersPerSize-1;var a=t[n];if(a)return a;var o=ur.getParameter(34964);return t[n]=ur.createBuffer(),ur.bindBuffer(34962,t[n]),ur.bufferData(34962,1<<r,35048),ur.bindBuffer(34962,o),t[n]},getTempIndexBuffer:e=>{var r=Ir.log2ceilLookup(e),t=Ir.currentContext.tempIndexBuffers[r];if(t)return t;var n=ur.getParameter(34965);return Ir.currentContext.tempIndexBuffers[r]=ur.createBuffer(),ur.bindBuffer(34963,Ir.currentContext.tempIndexBuffers[r]),ur.bufferData(34963,1<<r,35048),ur.bindBuffer(34963,n),Ir.currentContext.tempIndexBuffers[r]},newRenderingFrameStarted:()=>{if(Ir.currentContext){var e=Ir.currentContext.tempVertexBuffers1;Ir.currentContext.tempVertexBuffers1=Ir.currentContext.tempVertexBuffers2,Ir.currentContext.tempVertexBuffers2=e,e=Ir.currentContext.tempVertexBufferCounters1,Ir.currentContext.tempVertexBufferCounters1=Ir.currentContext.tempVertexBufferCounters2,Ir.currentContext.tempVertexBufferCounters2=e;for(var r=Ir.log2ceilLookup(Ir.MAX_TEMP_BUFFER_SIZE),t=0;t<=r;++t)Ir.currentContext.tempVertexBufferCounters1[t]=0}},getSource:(e,r,t,n)=>{for(var a="",o=0;o<r;++o){var i=n?T[n+4*o>>2]:void 0;a+=pe(T[t+4*o>>2],i)}return a},calcBufLength:(e,r,t,n)=>t>0?n*t:e*Ir.byteSizeByType[r-Ir.byteSizeByTypeRoot]*n,usedTempBuffers:[],preDrawHandleClientVertexAttribBindings:e=>{Ir.resetBufferBinding=!1;for(var r=0;r<Ir.currentContext.maxVertexAttribs;++r){var t=Ir.currentContext.clientBuffers[r];if(t.clientside&&t.enabled){Ir.resetBufferBinding=!0;var n=Ir.calcBufLength(t.size,t.type,t.stride,e),a=Ir.getTempVertexBuffer(n);ur.bindBuffer(34962,a),ur.bufferSubData(34962,0,C.subarray(t.ptr,t.ptr+n)),t.vertexAttribPointerAdaptor.call(ur,r,t.size,t.type,t.normalized,t.stride,0)}}},postDrawHandleClientVertexAttribBindings:()=>{Ir.resetBufferBinding&&ur.bindBuffer(34962,Ir.buffers[ur.currentArrayBufferBinding])},createContext:(e,r)=>{if(t.preinitializedWebGLContext){var n=t.preinitializedWebGLContext;r.majorVersion=Number(n.getParameter(n.VERSION).match(/^WebGL (\d+).\d+/)[1])}else e.getContextSafariWebGL2Fixed||(e.getContextSafariWebGL2Fixed=e.getContext,e.getContext=function(r,t){var n=e.getContextSafariWebGL2Fixed(r,t);return"webgl"==r==n instanceof WebGLRenderingContext?n:null}),n=r.majorVersion>1?e.getContext("webgl2",r):e.getContext("webgl",r);return n?Ir.registerContext(n,r):0},registerContext:(e,r)=>{var t=Ir.getNewId(Ir.contexts),n={handle:t,attributes:r,version:r.majorVers