libheif-js
Version:
Emscripten distribution of libheif for Node.JS and the browser
3 lines • 81.5 kB
JavaScript
var libheif=(()=>{var nr;var Se=typeof document!="undefined"?(nr=document.currentScript)==null?void 0:nr.src:void 0;return typeof __filename!="undefined"&&(Se||(Se=__filename)),function(Yr={}){var or,a=Yr,sr,Ae,va=new Promise((e,r)=>{sr=e,Ae=r}),qr=typeof window=="object",ue=typeof importScripts=="function",me=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",fr=Object.assign({},a),lr=[],Re="./this.program",dr=(e,r)=>{throw r},U="";function Xr(e){return a.locateFile?a.locateFile(e,U):U+e}var re,Me,ve;if(me){var je=require("fs"),cr=require("path");U=__dirname+"/",re=(e,r)=>(e=Ne(e)?new URL(e):cr.normalize(e),je.readFileSync(e,r?void 0:"utf8")),ve=e=>{var r=re(e,!0);return r.buffer||(r=new Uint8Array(r)),r},Me=(e,r,t,i=!0)=>{e=Ne(e)?new URL(e):cr.normalize(e),je.readFile(e,i?void 0:"utf8",(n,s)=>{n?t(n):r(i?s.buffer:s)})},!a.thisProgram&&process.argv.length>1&&(Re=process.argv[1].replace(/\\/g,"/")),lr=process.argv.slice(2),dr=(e,r)=>{throw process.exitCode=e,r}}else(qr||ue)&&(ue?U=self.location.href:typeof document!="undefined"&&document.currentScript&&(U=document.currentScript.src),Se&&(U=Se),U.startsWith("blob:")?U="":U=U.substr(0,U.replace(/[?#].*/,"").lastIndexOf("/")+1),re=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.send(null),r.responseText},ue&&(ve=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),Me=(e,r,t)=>{if(Ne(e)){var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="arraybuffer",i.onload=()=>{if(i.status==200||i.status==0&&i.response){r(i.response);return}t()},i.onerror=t,i.send(null);return}fetch(e,{credentials:"same-origin"}).then(n=>n.ok?n.arrayBuffer():Promise.reject(new Error(n.status+" : "+n.url))).then(r,t)});var Oe=a.print||console.log.bind(console),te=a.printErr||console.error.bind(console);Object.assign(a,fr),fr=null,a.arguments&&(lr=a.arguments),a.thisProgram&&(Re=a.thisProgram),a.quit&&(dr=a.quit);var Ie;a.wasmBinary&&(Ie=a.wasmBinary);var ge,hr=!1,Gr,A,M,W,ie,w,k,ur,mr;function vr(){var e=ge.buffer;a.HEAP8=A=new Int8Array(e),a.HEAP16=W=new Int16Array(e),a.HEAPU8=M=new Uint8Array(e),a.HEAPU16=ie=new Uint16Array(e),a.HEAP32=w=new Int32Array(e),a.HEAPU32=k=new Uint32Array(e),a.HEAPF32=ur=new Float32Array(e),a.HEAPF64=mr=new Float64Array(e)}var gr=[],pr=[],yr=[],Kr=!1;function Jr(){if(a.preRun)for(typeof a.preRun=="function"&&(a.preRun=[a.preRun]);a.preRun.length;)et(a.preRun.shift());He(gr)}function Qr(){Kr=!0,!a.noFSInit&&!_.init.initialized&&_.init(),_.ignorePermissions=!1,Y.init(),He(pr)}function Zr(){if(a.postRun)for(typeof a.postRun=="function"&&(a.postRun=[a.postRun]);a.postRun.length;)tt(a.postRun.shift());He(yr)}function et(e){gr.unshift(e)}function rt(e){pr.unshift(e)}function tt(e){yr.unshift(e)}var G=0,ze=null,ae=null;function ga(e){return e}function Ue(e){var r;G++,(r=a.monitorRunDependencies)==null||r.call(a,G)}function pe(e){var t;if(G--,(t=a.monitorRunDependencies)==null||t.call(a,G),G==0&&(ze!==null&&(clearInterval(ze),ze=null),ae)){var r=ae;ae=null,r()}}function _e(e){var t;(t=a.onAbort)==null||t.call(a,e),e="Aborted("+e+")",te(e),hr=!0,Gr=1,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw Ae(r),r}var it="data:application/octet-stream;base64,",at=e=>e.startsWith(it),Ne=e=>e.startsWith("file://");function _t(){var e="libheif.wasm";return at(e)?e:Xr(e)}var ye;function nt(e){if(e==ye&&Ie)return new Uint8Array(Ie);if(ve)return ve(e);throw'sync fetching of the wasm failed: you can preload it to Module["wasmBinary"] manually, or emcc.py will do that for you when generating HTML (but not JS)'}function ot(e,r){var t,i=nt(e);t=new WebAssembly.Module(i);var n=new WebAssembly.Instance(t,r);return[n,t]}function st(){return{a:da}}function ft(){var e=st();function r(i,n){return o=i.exports,ge=o.Q,vr(),Sr=o.T,rt(o.R),pe("wasm-instantiate"),o}if(Ue("wasm-instantiate"),a.instantiateWasm)try{return a.instantiateWasm(e,r)}catch(i){te(`Module.instantiateWasm callback failed with error: ${i}`),Ae(i)}ye||(ye=_t());var t=ot(ye,e);return r(t[0])}var E,R,He=e=>{for(;e.length>0;)e.shift()(a)},pa=a.noExitRuntime||!0,wr=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):void 0,Q=(e,r,t)=>{for(var i=r+t,n=r;e[n]&&!(n>=i);)++n;if(n-r>16&&e.buffer&&wr)return wr.decode(e.subarray(r,n));for(var s="";r<n;){var f=e[r++];if(!(f&128)){s+=String.fromCharCode(f);continue}var l=e[r++]&63;if((f&224)==192){s+=String.fromCharCode((f&31)<<6|l);continue}var d=e[r++]&63;if((f&240)==224?f=(f&15)<<12|l<<6|d:f=(f&7)<<18|l<<12|d<<6|e[r++]&63,f<65536)s+=String.fromCharCode(f);else{var h=f-65536;s+=String.fromCharCode(55296|h>>10,56320|h&1023)}}return s},K=(e,r)=>e?Q(M,e,r):"",lt=(e,r,t,i)=>{_e(`Assertion failed: ${K(e)}, at: `+[r?K(r):"unknown filename",t,i?K(i):"unknown function"])};class dt{constructor(r){this.excPtr=r,this.ptr=r-24}set_type(r){k[this.ptr+4>>2]=r}get_type(){return k[this.ptr+4>>2]}set_destructor(r){k[this.ptr+8>>2]=r}get_destructor(){return k[this.ptr+8>>2]}set_caught(r){r=r?1:0,A[this.ptr+12]=r}get_caught(){return A[this.ptr+12]!=0}set_rethrown(r){r=r?1:0,A[this.ptr+13]=r}get_rethrown(){return A[this.ptr+13]!=0}init(r,t){this.set_adjusted_ptr(0),this.set_type(r),this.set_destructor(t)}set_adjusted_ptr(r){k[this.ptr+16>>2]=r}get_adjusted_ptr(){return k[this.ptr+16>>2]}get_exception_ptr(){var r=ha(this.get_type());if(r)return k[this.excPtr>>2];var t=this.get_adjusted_ptr();return t!==0?t:this.excPtr}}var br=0,ct=0,ht=(e,r,t)=>{var i=new dt(e);throw i.init(r,t),br=e,ct++,br};function we(){var e=w[+j.varargs>>2];return j.varargs+=4,e}var Z=we,T={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,i=e.length-1;i>=0;i--){var n=e[i];n==="."?e.splice(i,1):n===".."?(e.splice(i,1),t++):t&&(e.splice(i,1),t--)}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=T.isAbs(e),t=e.substr(-1)==="/";return e=T.normalizeArray(e.split("/").filter(i=>!!i),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=T.splitPath(e),t=r[0],i=r[1];return!t&&!i?".":(i&&(i=i.substr(0,i.length-1)),t+i)},basename:e=>{if(e==="/")return"/";e=T.normalize(e),e=e.replace(/\/$/,"");var r=e.lastIndexOf("/");return r===-1?e:e.substr(r+1)},join:(...e)=>T.normalize(e.join("/")),join2:(e,r)=>T.normalize(e+"/"+r)},ut=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return i=>crypto.getRandomValues(i);if(me)try{var e=require("crypto"),r=e.randomFillSync;if(r)return i=>e.randomFillSync(i);var t=e.randomBytes;return i=>(i.set(t(i.byteLength)),i)}catch{}_e("initRandomDevice")},Er=e=>(Er=ut())(e),L={resolve:(...e)=>{for(var r="",t=!1,i=e.length-1;i>=-1&&!t;i--){var n=i>=0?e[i]:_.cwd();if(typeof n!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!n)return"";r=n+"/"+r,t=T.isAbs(n)}return r=T.normalizeArray(r.split("/").filter(s=>!!s),!t).join("/"),(t?"/":"")+r||"."},relative:(e,r)=>{e=L.resolve(e).substr(1),r=L.resolve(r).substr(1);function t(h){for(var u=0;u<h.length&&h[u]==="";u++);for(var p=h.length-1;p>=0&&h[p]==="";p--);return u>p?[]:h.slice(u,p-u+1)}for(var i=t(e.split("/")),n=t(r.split("/")),s=Math.min(i.length,n.length),f=s,l=0;l<s;l++)if(i[l]!==n[l]){f=l;break}for(var d=[],l=f;l<i.length;l++)d.push("..");return d=d.concat(n.slice(f)),d.join("/")}},We=[],Le=e=>{for(var r=0,t=0;t<e.length;++t){var i=e.charCodeAt(t);i<=127?r++:i<=2047?r+=2:i>=55296&&i<=57343?(r+=4,++t):r+=3}return r},Be=(e,r,t,i)=>{if(!(i>0))return 0;for(var n=t,s=t+i-1,f=0;f<e.length;++f){var l=e.charCodeAt(f);if(l>=55296&&l<=57343){var d=e.charCodeAt(++f);l=65536+((l&1023)<<10)|d&1023}if(l<=127){if(t>=s)break;r[t++]=l}else if(l<=2047){if(t+1>=s)break;r[t++]=192|l>>6,r[t++]=128|l&63}else if(l<=65535){if(t+2>=s)break;r[t++]=224|l>>12,r[t++]=128|l>>6&63,r[t++]=128|l&63}else{if(t+3>=s)break;r[t++]=240|l>>18,r[t++]=128|l>>12&63,r[t++]=128|l>>6&63,r[t++]=128|l&63}}return r[t]=0,t-n};function be(e,r,t){var i=t>0?t:Le(e)+1,n=new Array(i),s=Be(e,n,0,n.length);return r&&(n.length=s),n}var mt=()=>{if(!We.length){var e=null;if(me){var r=256,t=Buffer.alloc(r),i=0,n=process.stdin.fd;try{i=je.readSync(n,t,0,r)}catch(s){if(s.toString().includes("EOF"))i=0;else throw s}i>0&&(e=t.slice(0,i).toString("utf-8"))}else typeof window!="undefined"&&typeof window.prompt=="function"&&(e=window.prompt("Input: "),e!==null&&(e+=`
`));if(!e)return null;We=be(e,!0)}return We.shift()},Y={ttys:[],init(){},shutdown(){},register(e,r){Y.ttys[e]={input:[],output:[],ops:r},_.registerDevice(e,Y.stream_ops)},stream_ops:{open(e){var r=Y.ttys[e.node.rdev];if(!r)throw new _.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,i,n){if(!e.tty||!e.tty.ops.get_char)throw new _.ErrnoError(60);for(var s=0,f=0;f<i;f++){var l;try{l=e.tty.ops.get_char(e.tty)}catch{throw new _.ErrnoError(29)}if(l===void 0&&s===0)throw new _.ErrnoError(6);if(l==null)break;s++,r[t+f]=l}return s&&(e.node.timestamp=Date.now()),s},write(e,r,t,i,n){if(!e.tty||!e.tty.ops.put_char)throw new _.ErrnoError(60);try{for(var s=0;s<i;s++)e.tty.ops.put_char(e.tty,r[t+s])}catch{throw new _.ErrnoError(29)}return i&&(e.node.timestamp=Date.now()),s}},default_tty_ops:{get_char(e){return mt()},put_char(e,r){r===null||r===10?(Oe(Q(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},fsync(e){e.output&&e.output.length>0&&(Oe(Q(e.output,0)),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?(te(Q(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},fsync(e){e.output&&e.output.length>0&&(te(Q(e.output,0)),e.output=[])}}},kr=e=>{_e()},b={ops_table:null,mount(e){return b.createNode(null,"/",16895,0)},createNode(e,r,t,i){if(_.isBlkdev(t)||_.isFIFO(t))throw new _.ErrnoError(63);b.ops_table||(b.ops_table={dir:{node:{getattr:b.node_ops.getattr,setattr:b.node_ops.setattr,lookup:b.node_ops.lookup,mknod:b.node_ops.mknod,rename:b.node_ops.rename,unlink:b.node_ops.unlink,rmdir:b.node_ops.rmdir,readdir:b.node_ops.readdir,symlink:b.node_ops.symlink},stream:{llseek:b.stream_ops.llseek}},file:{node:{getattr:b.node_ops.getattr,setattr:b.node_ops.setattr},stream:{llseek:b.stream_ops.llseek,read:b.stream_ops.read,write:b.stream_ops.write,allocate:b.stream_ops.allocate,mmap:b.stream_ops.mmap,msync:b.stream_ops.msync}},link:{node:{getattr:b.node_ops.getattr,setattr:b.node_ops.setattr,readlink:b.node_ops.readlink},stream:{}},chrdev:{node:{getattr:b.node_ops.getattr,setattr:b.node_ops.setattr},stream:_.chrdev_stream_ops}});var n=_.createNode(e,r,t,i);return _.isDir(n.mode)?(n.node_ops=b.ops_table.dir.node,n.stream_ops=b.ops_table.dir.stream,n.contents={}):_.isFile(n.mode)?(n.node_ops=b.ops_table.file.node,n.stream_ops=b.ops_table.file.stream,n.usedBytes=0,n.contents=null):_.isLink(n.mode)?(n.node_ops=b.ops_table.link.node,n.stream_ops=b.ops_table.link.stream):_.isChrdev(n.mode)&&(n.node_ops=b.ops_table.chrdev.node,n.stream_ops=b.ops_table.chrdev.stream),n.timestamp=Date.now(),e&&(e.contents[r]=n,e.timestamp=n.timestamp),n},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 i=1024*1024;r=Math.max(r,t*(t<i?2:1.125)>>>0),t!=0&&(r=Math.max(r,256));var n=e.contents;e.contents=new Uint8Array(r),e.usedBytes>0&&e.contents.set(n.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=_.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,_.isDir(e.mode)?r.size=4096:_.isFile(e.mode)?r.size=e.usedBytes:_.isLink(e.mode)?r.size=e.link.length:r.size=0,r.atime=new Date(e.timestamp),r.mtime=new Date(e.timestamp),r.ctime=new Date(e.timestamp),r.blksize=4096,r.blocks=Math.ceil(r.size/r.blksize),r},setattr(e,r){r.mode!==void 0&&(e.mode=r.mode),r.timestamp!==void 0&&(e.timestamp=r.timestamp),r.size!==void 0&&b.resizeFileStorage(e,r.size)},lookup(e,r){throw _.genericErrors[44]},mknod(e,r,t,i){return b.createNode(e,r,t,i)},rename(e,r,t){if(_.isDir(e.mode)){var i;try{i=_.lookupNode(r,t)}catch{}if(i)for(var n in i.contents)throw new _.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=t,r.contents[t]=e,r.timestamp=e.parent.timestamp},unlink(e,r){delete e.contents[r],e.timestamp=Date.now()},rmdir(e,r){var t=_.lookupNode(e,r);for(var i in t.contents)throw new _.ErrnoError(55);delete e.contents[r],e.timestamp=Date.now()},readdir(e){var r=[".",".."];for(var t of Object.keys(e.contents))r.push(t);return r},symlink(e,r,t){var i=b.createNode(e,r,41471,0);return i.link=t,i},readlink(e){if(!_.isLink(e.mode))throw new _.ErrnoError(28);return e.link}},stream_ops:{read(e,r,t,i,n){var s=e.node.contents;if(n>=e.node.usedBytes)return 0;var f=Math.min(e.node.usedBytes-n,i);if(f>8&&s.subarray)r.set(s.subarray(n,n+f),t);else for(var l=0;l<f;l++)r[t+l]=s[n+l];return f},write(e,r,t,i,n,s){if(r.buffer===A.buffer&&(s=!1),!i)return 0;var f=e.node;if(f.timestamp=Date.now(),r.subarray&&(!f.contents||f.contents.subarray)){if(s)return f.contents=r.subarray(t,t+i),f.usedBytes=i,i;if(f.usedBytes===0&&n===0)return f.contents=r.slice(t,t+i),f.usedBytes=i,i;if(n+i<=f.usedBytes)return f.contents.set(r.subarray(t,t+i),n),i}if(b.expandFileStorage(f,n+i),f.contents.subarray&&r.subarray)f.contents.set(r.subarray(t,t+i),n);else for(var l=0;l<i;l++)f.contents[n+l]=r[t+l];return f.usedBytes=Math.max(f.usedBytes,n+i),i},llseek(e,r,t){var i=r;if(t===1?i+=e.position:t===2&&_.isFile(e.node.mode)&&(i+=e.node.usedBytes),i<0)throw new _.ErrnoError(28);return i},allocate(e,r,t){b.expandFileStorage(e.node,r+t),e.node.usedBytes=Math.max(e.node.usedBytes,r+t)},mmap(e,r,t,i,n){if(!_.isFile(e.node.mode))throw new _.ErrnoError(43);var s,f,l=e.node.contents;if(!(n&2)&&l.buffer===A.buffer)f=!1,s=l.byteOffset;else{if((t>0||t+r<l.length)&&(l.subarray?l=l.subarray(t,t+r):l=Array.prototype.slice.call(l,t,t+r)),f=!0,s=kr(r),!s)throw new _.ErrnoError(48);A.set(l,s)}return{ptr:s,allocated:f}},msync(e,r,t,i,n){return b.stream_ops.write(e,r,0,i,t,!1),0}}},vt=(e,r,t,i)=>{var n=i?"":`al ${e}`;Me(e,s=>{r(new Uint8Array(s)),n&&pe(n)},s=>{if(t)t();else throw`Loading data file "${e}" failed.`}),n&&Ue(n)},gt=(e,r,t,i,n,s)=>{_.createDataFile(e,r,t,i,n,s)},pt=a.preloadPlugins||[],yt=(e,r,t,i)=>{typeof Browser!="undefined"&&Browser.init();var n=!1;return pt.forEach(s=>{n||s.canHandle(r)&&(s.handle(e,r,t,i),n=!0)}),n},wt=(e,r,t,i,n,s,f,l,d,h)=>{var u=r?L.resolve(T.join2(e,r)):e,p=`cp ${u}`;function g(v){function y(D){h==null||h(),l||gt(e,r,D,i,n,d),s==null||s(),pe(p)}yt(v,u,y,()=>{f==null||f(),pe(p)})||y(v)}Ue(p),typeof t=="string"?vt(t,g,f):g(t)},bt=e=>{var r={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},t=r[e];if(typeof t=="undefined")throw new Error(`Unknown file open mode: ${e}`);return t},Ve=(e,r)=>{var t=0;return e&&(t|=365),r&&(t|=146),t},_={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:class{constructor(e){this.name="ErrnoError",this.errno=e}},genericErrors:{},filesystems:null,syncFSRequests:0,FSStream:class{constructor(){this.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{constructor(e,r,t,i){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=_.nextInode++,this.name=r,this.mode=t,this.node_ops={},this.stream_ops={},this.rdev=i,this.readMode=365,this.writeMode=146}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 _.isDir(this.mode)}get isDevice(){return _.isChrdev(this.mode)}},lookupPath(e,r={}){if(e=L.resolve(e),!e)return{path:"",node:null};var t={follow_mount:!0,recurse_count:0};if(r=Object.assign(t,r),r.recurse_count>8)throw new _.ErrnoError(32);for(var i=e.split("/").filter(p=>!!p),n=_.root,s="/",f=0;f<i.length;f++){var l=f===i.length-1;if(l&&r.parent)break;if(n=_.lookupNode(n,i[f]),s=T.join2(s,i[f]),_.isMountpoint(n)&&(!l||l&&r.follow_mount)&&(n=n.mounted.root),!l||r.follow)for(var d=0;_.isLink(n.mode);){var h=_.readlink(s);s=L.resolve(T.dirname(s),h);var u=_.lookupPath(s,{recurse_count:r.recurse_count+1});if(n=u.node,d++>40)throw new _.ErrnoError(32)}}return{path:s,node:n}},getPath(e){for(var r;;){if(_.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,i=0;i<r.length;i++)t=(t<<5)-t+r.charCodeAt(i)|0;return(e+t>>>0)%_.nameTable.length},hashAddNode(e){var r=_.hashName(e.parent.id,e.name);e.name_next=_.nameTable[r],_.nameTable[r]=e},hashRemoveNode(e){var r=_.hashName(e.parent.id,e.name);if(_.nameTable[r]===e)_.nameTable[r]=e.name_next;else for(var t=_.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next}},lookupNode(e,r){var t=_.mayLookup(e);if(t)throw new _.ErrnoError(t);for(var i=_.hashName(e.id,r),n=_.nameTable[i];n;n=n.name_next){var s=n.name;if(n.parent.id===e.id&&s===r)return n}return _.lookup(e,r)},createNode(e,r,t,i){var n=new _.FSNode(e,r,t,i);return _.hashAddNode(n),n},destroyNode(e){_.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 _.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(!_.isDir(e.mode))return 54;var r=_.nodePermissions(e,"x");return r||(e.node_ops.lookup?0:2)},mayCreate(e,r){try{var t=_.lookupNode(e,r);return 20}catch{}return _.nodePermissions(e,"wx")},mayDelete(e,r,t){var i;try{i=_.lookupNode(e,r)}catch(s){return s.errno}var n=_.nodePermissions(e,"wx");if(n)return n;if(t){if(!_.isDir(i.mode))return 54;if(_.isRoot(i)||_.getPath(i)===_.cwd())return 10}else if(_.isDir(i.mode))return 31;return 0},mayOpen(e,r){return e?_.isLink(e.mode)?32:_.isDir(e.mode)&&(_.flagsToPermissionString(r)!=="r"||r&512)?31:_.nodePermissions(e,_.flagsToPermissionString(r)):44},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=_.MAX_OPEN_FDS;e++)if(!_.streams[e])return e;throw new _.ErrnoError(33)},getStreamChecked(e){var r=_.getStream(e);if(!r)throw new _.ErrnoError(8);return r},getStream:e=>_.streams[e],createStream(e,r=-1){return e=Object.assign(new _.FSStream,e),r==-1&&(r=_.nextfd()),e.fd=r,_.streams[r]=e,e},closeStream(e){_.streams[e]=null},dupStream(e,r=-1){var i,n;var t=_.createStream(e,r);return(n=(i=t.stream_ops)==null?void 0:i.dup)==null||n.call(i,t),t},chrdev_stream_ops:{open(e){var t,i;var r=_.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,(i=(t=e.stream_ops).open)==null||i.call(t,e)},llseek(){throw new _.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,r)=>e<<8|r,registerDevice(e,r){_.devices[e]={stream_ops:r}},getDevice:e=>_.devices[e],getMounts(e){for(var r=[],t=[e];t.length;){var i=t.pop();r.push(i),t.push(...i.mounts)}return r},syncfs(e,r){typeof e=="function"&&(r=e,e=!1),_.syncFSRequests++,_.syncFSRequests>1&&te(`warning: ${_.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var t=_.getMounts(_.root.mount),i=0;function n(f){return _.syncFSRequests--,r(f)}function s(f){if(f)return s.errored?void 0:(s.errored=!0,n(f));++i>=t.length&&n(null)}t.forEach(f=>{if(!f.type.syncfs)return s(null);f.type.syncfs(f,e,s)})},mount(e,r,t){var i=t==="/",n=!t,s;if(i&&_.root)throw new _.ErrnoError(10);if(!i&&!n){var f=_.lookupPath(t,{follow_mount:!1});if(t=f.path,s=f.node,_.isMountpoint(s))throw new _.ErrnoError(10);if(!_.isDir(s.mode))throw new _.ErrnoError(54)}var l={type:e,opts:r,mountpoint:t,mounts:[]},d=e.mount(l);return d.mount=l,l.root=d,i?_.root=d:s&&(s.mounted=l,s.mount&&s.mount.mounts.push(l)),d},unmount(e){var r=_.lookupPath(e,{follow_mount:!1});if(!_.isMountpoint(r.node))throw new _.ErrnoError(28);var t=r.node,i=t.mounted,n=_.getMounts(i);Object.keys(_.nameTable).forEach(f=>{for(var l=_.nameTable[f];l;){var d=l.name_next;n.includes(l.mount)&&_.destroyNode(l),l=d}}),t.mounted=null;var s=t.mount.mounts.indexOf(i);t.mount.mounts.splice(s,1)},lookup(e,r){return e.node_ops.lookup(e,r)},mknod(e,r,t){var i=_.lookupPath(e,{parent:!0}),n=i.node,s=T.basename(e);if(!s||s==="."||s==="..")throw new _.ErrnoError(28);var f=_.mayCreate(n,s);if(f)throw new _.ErrnoError(f);if(!n.node_ops.mknod)throw new _.ErrnoError(63);return n.node_ops.mknod(n,s,r,t)},create(e,r){return r=r!==void 0?r:438,r&=4095,r|=32768,_.mknod(e,r,0)},mkdir(e,r){return r=r!==void 0?r:511,r&=1023,r|=16384,_.mknod(e,r,0)},mkdirTree(e,r){for(var t=e.split("/"),i="",n=0;n<t.length;++n)if(t[n]){i+="/"+t[n];try{_.mkdir(i,r)}catch(s){if(s.errno!=20)throw s}}},mkdev(e,r,t){return typeof t=="undefined"&&(t=r,r=438),r|=8192,_.mknod(e,r,t)},symlink(e,r){if(!L.resolve(e))throw new _.ErrnoError(44);var t=_.lookupPath(r,{parent:!0}),i=t.node;if(!i)throw new _.ErrnoError(44);var n=T.basename(r),s=_.mayCreate(i,n);if(s)throw new _.ErrnoError(s);if(!i.node_ops.symlink)throw new _.ErrnoError(63);return i.node_ops.symlink(i,n,e)},rename(e,r){var t=T.dirname(e),i=T.dirname(r),n=T.basename(e),s=T.basename(r),f,l,d;if(f=_.lookupPath(e,{parent:!0}),l=f.node,f=_.lookupPath(r,{parent:!0}),d=f.node,!l||!d)throw new _.ErrnoError(44);if(l.mount!==d.mount)throw new _.ErrnoError(75);var h=_.lookupNode(l,n),u=L.relative(e,i);if(u.charAt(0)!==".")throw new _.ErrnoError(28);if(u=L.relative(r,t),u.charAt(0)!==".")throw new _.ErrnoError(55);var p;try{p=_.lookupNode(d,s)}catch{}if(h!==p){var g=_.isDir(h.mode),v=_.mayDelete(l,n,g);if(v)throw new _.ErrnoError(v);if(v=p?_.mayDelete(d,s,g):_.mayCreate(d,s),v)throw new _.ErrnoError(v);if(!l.node_ops.rename)throw new _.ErrnoError(63);if(_.isMountpoint(h)||p&&_.isMountpoint(p))throw new _.ErrnoError(10);if(d!==l&&(v=_.nodePermissions(l,"w"),v))throw new _.ErrnoError(v);_.hashRemoveNode(h);try{l.node_ops.rename(h,d,s),h.parent=d}catch(y){throw y}finally{_.hashAddNode(h)}}},rmdir(e){var r=_.lookupPath(e,{parent:!0}),t=r.node,i=T.basename(e),n=_.lookupNode(t,i),s=_.mayDelete(t,i,!0);if(s)throw new _.ErrnoError(s);if(!t.node_ops.rmdir)throw new _.ErrnoError(63);if(_.isMountpoint(n))throw new _.ErrnoError(10);t.node_ops.rmdir(t,i),_.destroyNode(n)},readdir(e){var r=_.lookupPath(e,{follow:!0}),t=r.node;if(!t.node_ops.readdir)throw new _.ErrnoError(54);return t.node_ops.readdir(t)},unlink(e){var r=_.lookupPath(e,{parent:!0}),t=r.node;if(!t)throw new _.ErrnoError(44);var i=T.basename(e),n=_.lookupNode(t,i),s=_.mayDelete(t,i,!1);if(s)throw new _.ErrnoError(s);if(!t.node_ops.unlink)throw new _.ErrnoError(63);if(_.isMountpoint(n))throw new _.ErrnoError(10);t.node_ops.unlink(t,i),_.destroyNode(n)},readlink(e){var r=_.lookupPath(e),t=r.node;if(!t)throw new _.ErrnoError(44);if(!t.node_ops.readlink)throw new _.ErrnoError(28);return L.resolve(_.getPath(t.parent),t.node_ops.readlink(t))},stat(e,r){var t=_.lookupPath(e,{follow:!r}),i=t.node;if(!i)throw new _.ErrnoError(44);if(!i.node_ops.getattr)throw new _.ErrnoError(63);return i.node_ops.getattr(i)},lstat(e){return _.stat(e,!0)},chmod(e,r,t){var i;if(typeof e=="string"){var n=_.lookupPath(e,{follow:!t});i=n.node}else i=e;if(!i.node_ops.setattr)throw new _.ErrnoError(63);i.node_ops.setattr(i,{mode:r&4095|i.mode&-4096,timestamp:Date.now()})},lchmod(e,r){_.chmod(e,r,!0)},fchmod(e,r){var t=_.getStreamChecked(e);_.chmod(t.node,r)},chown(e,r,t,i){var n;if(typeof e=="string"){var s=_.lookupPath(e,{follow:!i});n=s.node}else n=e;if(!n.node_ops.setattr)throw new _.ErrnoError(63);n.node_ops.setattr(n,{timestamp:Date.now()})},lchown(e,r,t){_.chown(e,r,t,!0)},fchown(e,r,t){var i=_.getStreamChecked(e);_.chown(i.node,r,t)},truncate(e,r){if(r<0)throw new _.ErrnoError(28);var t;if(typeof e=="string"){var i=_.lookupPath(e,{follow:!0});t=i.node}else t=e;if(!t.node_ops.setattr)throw new _.ErrnoError(63);if(_.isDir(t.mode))throw new _.ErrnoError(31);if(!_.isFile(t.mode))throw new _.ErrnoError(28);var n=_.nodePermissions(t,"w");if(n)throw new _.ErrnoError(n);t.node_ops.setattr(t,{size:r,timestamp:Date.now()})},ftruncate(e,r){var t=_.getStreamChecked(e);if(!(t.flags&2097155))throw new _.ErrnoError(28);_.truncate(t.node,r)},utime(e,r,t){var i=_.lookupPath(e,{follow:!0}),n=i.node;n.node_ops.setattr(n,{timestamp:Math.max(r,t)})},open(e,r,t){if(e==="")throw new _.ErrnoError(44);r=typeof r=="string"?bt(r):r,r&64?(t=typeof t=="undefined"?438:t,t=t&4095|32768):t=0;var i;if(typeof e=="object")i=e;else{e=T.normalize(e);try{var n=_.lookupPath(e,{follow:!(r&131072)});i=n.node}catch{}}var s=!1;if(r&64)if(i){if(r&128)throw new _.ErrnoError(20)}else i=_.mknod(e,t,0),s=!0;if(!i)throw new _.ErrnoError(44);if(_.isChrdev(i.mode)&&(r&=-513),r&65536&&!_.isDir(i.mode))throw new _.ErrnoError(54);if(!s){var f=_.mayOpen(i,r);if(f)throw new _.ErrnoError(f)}r&512&&!s&&_.truncate(i,0),r&=-131713;var l=_.createStream({node:i,path:_.getPath(i),flags:r,seekable:!0,position:0,stream_ops:i.stream_ops,ungotten:[],error:!1});return l.stream_ops.open&&l.stream_ops.open(l),a.logReadFiles&&!(r&1)&&(_.readFiles||(_.readFiles={}),e in _.readFiles||(_.readFiles[e]=1)),l},close(e){if(_.isClosed(e))throw new _.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(r){throw r}finally{_.closeStream(e.fd)}e.fd=null},isClosed(e){return e.fd===null},llseek(e,r,t){if(_.isClosed(e))throw new _.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new _.ErrnoError(70);if(t!=0&&t!=1&&t!=2)throw new _.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read(e,r,t,i,n){if(i<0||n<0)throw new _.ErrnoError(28);if(_.isClosed(e))throw new _.ErrnoError(8);if((e.flags&2097155)===1)throw new _.ErrnoError(8);if(_.isDir(e.node.mode))throw new _.ErrnoError(31);if(!e.stream_ops.read)throw new _.ErrnoError(28);var s=typeof n!="undefined";if(!s)n=e.position;else if(!e.seekable)throw new _.ErrnoError(70);var f=e.stream_ops.read(e,r,t,i,n);return s||(e.position+=f),f},write(e,r,t,i,n,s){if(i<0||n<0)throw new _.ErrnoError(28);if(_.isClosed(e))throw new _.ErrnoError(8);if(!(e.flags&2097155))throw new _.ErrnoError(8);if(_.isDir(e.node.mode))throw new _.ErrnoError(31);if(!e.stream_ops.write)throw new _.ErrnoError(28);e.seekable&&e.flags&1024&&_.llseek(e,0,2);var f=typeof n!="undefined";if(!f)n=e.position;else if(!e.seekable)throw new _.ErrnoError(70);var l=e.stream_ops.write(e,r,t,i,n,s);return f||(e.position+=l),l},allocate(e,r,t){if(_.isClosed(e))throw new _.ErrnoError(8);if(r<0||t<=0)throw new _.ErrnoError(28);if(!(e.flags&2097155))throw new _.ErrnoError(8);if(!_.isFile(e.node.mode)&&!_.isDir(e.node.mode))throw new _.ErrnoError(43);if(!e.stream_ops.allocate)throw new _.ErrnoError(138);e.stream_ops.allocate(e,r,t)},mmap(e,r,t,i,n){if(i&2&&!(n&2)&&(e.flags&2097155)!==2)throw new _.ErrnoError(2);if((e.flags&2097155)===1)throw new _.ErrnoError(2);if(!e.stream_ops.mmap)throw new _.ErrnoError(43);return e.stream_ops.mmap(e,r,t,i,n)},msync(e,r,t,i,n){return e.stream_ops.msync?e.stream_ops.msync(e,r,t,i,n):0},ioctl(e,r,t){if(!e.stream_ops.ioctl)throw new _.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,i=_.open(e,r.flags),n=_.stat(e),s=n.size,f=new Uint8Array(s);return _.read(i,f,0,s,0),r.encoding==="utf8"?t=Q(f,0):r.encoding==="binary"&&(t=f),_.close(i),t},writeFile(e,r,t={}){t.flags=t.flags||577;var i=_.open(e,t.flags,t.mode);if(typeof r=="string"){var n=new Uint8Array(Le(r)+1),s=Be(r,n,0,n.length);_.write(i,n,0,s,void 0,t.canOwn)}else if(ArrayBuffer.isView(r))_.write(i,r,0,r.byteLength,void 0,t.canOwn);else throw new Error("Unsupported data type");_.close(i)},cwd:()=>_.currentPath,chdir(e){var r=_.lookupPath(e,{follow:!0});if(r.node===null)throw new _.ErrnoError(44);if(!_.isDir(r.node.mode))throw new _.ErrnoError(54);var t=_.nodePermissions(r.node,"x");if(t)throw new _.ErrnoError(t);_.currentPath=r.path},createDefaultDirectories(){_.mkdir("/tmp"),_.mkdir("/home"),_.mkdir("/home/web_user")},createDefaultDevices(){_.mkdir("/dev"),_.registerDevice(_.makedev(1,3),{read:()=>0,write:(i,n,s,f,l)=>f}),_.mkdev("/dev/null",_.makedev(1,3)),Y.register(_.makedev(5,0),Y.default_tty_ops),Y.register(_.makedev(6,0),Y.default_tty1_ops),_.mkdev("/dev/tty",_.makedev(5,0)),_.mkdev("/dev/tty1",_.makedev(6,0));var e=new Uint8Array(1024),r=0,t=()=>(r===0&&(r=Er(e).byteLength),e[--r]);_.createDevice("/dev","random",t),_.createDevice("/dev","urandom",t),_.mkdir("/dev/shm"),_.mkdir("/dev/shm/tmp")},createSpecialDirectories(){_.mkdir("/proc");var e=_.mkdir("/proc/self");_.mkdir("/proc/self/fd"),_.mount({mount(){var r=_.createNode(e,"fd",16895,73);return r.node_ops={lookup(t,i){var n=+i,s=_.getStreamChecked(n),f={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>s.path}};return f.parent=f,f}},r}},{},"/proc/self/fd")},createStandardStreams(){a.stdin?_.createDevice("/dev","stdin",a.stdin):_.symlink("/dev/tty","/dev/stdin"),a.stdout?_.createDevice("/dev","stdout",null,a.stdout):_.symlink("/dev/tty","/dev/stdout"),a.stderr?_.createDevice("/dev","stderr",null,a.stderr):_.symlink("/dev/tty1","/dev/stderr");var e=_.open("/dev/stdin",0),r=_.open("/dev/stdout",1),t=_.open("/dev/stderr",1)},staticInit(){[44].forEach(e=>{_.genericErrors[e]=new _.ErrnoError(e),_.genericErrors[e].stack="<generic error, no stack>"}),_.nameTable=new Array(4096),_.mount(b,{},"/"),_.createDefaultDirectories(),_.createDefaultDevices(),_.createSpecialDirectories(),_.filesystems={MEMFS:b}},init(e,r,t){_.init.initialized=!0,a.stdin=e||a.stdin,a.stdout=r||a.stdout,a.stderr=t||a.stderr,_.createStandardStreams()},quit(){_.init.initialized=!1;for(var e=0;e<_.streams.length;e++){var r=_.streams[e];r&&_.close(r)}},findObject(e,r){var t=_.analyzePath(e,r);return t.exists?t.object:null},analyzePath(e,r){try{var t=_.lookupPath(e,{follow:!r});e=t.path}catch{}var i={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var t=_.lookupPath(e,{parent:!0});i.parentExists=!0,i.parentPath=t.path,i.parentObject=t.node,i.name=T.basename(e),t=_.lookupPath(e,{follow:!r}),i.exists=!0,i.path=t.path,i.object=t.node,i.name=t.node.name,i.isRoot=t.path==="/"}catch(n){i.error=n.errno}return i},createPath(e,r,t,i){e=typeof e=="string"?e:_.getPath(e);for(var n=r.split("/").reverse();n.length;){var s=n.pop();if(s){var f=T.join2(e,s);try{_.mkdir(f)}catch{}e=f}}return f},createFile(e,r,t,i,n){var s=T.join2(typeof e=="string"?e:_.getPath(e),r),f=Ve(i,n);return _.create(s,f)},createDataFile(e,r,t,i,n,s){var f=r;e&&(e=typeof e=="string"?e:_.getPath(e),f=r?T.join2(e,r):e);var l=Ve(i,n),d=_.create(f,l);if(t){if(typeof t=="string"){for(var h=new Array(t.length),u=0,p=t.length;u<p;++u)h[u]=t.charCodeAt(u);t=h}_.chmod(d,l|146);var g=_.open(d,577);_.write(g,t,0,t.length,0,s),_.close(g),_.chmod(d,l)}},createDevice(e,r,t,i){var n=T.join2(typeof e=="string"?e:_.getPath(e),r),s=Ve(!!t,!!i);_.createDevice.major||(_.createDevice.major=64);var f=_.makedev(_.createDevice.major++,0);return _.registerDevice(f,{open(l){l.seekable=!1},close(l){var d;(d=i==null?void 0:i.buffer)!=null&&d.length&&i(10)},read(l,d,h,u,p){for(var g=0,v=0;v<u;v++){var y;try{y=t()}catch{throw new _.ErrnoError(29)}if(y===void 0&&g===0)throw new _.ErrnoError(6);if(y==null)break;g++,d[h+v]=y}return g&&(l.node.timestamp=Date.now()),g},write(l,d,h,u,p){for(var g=0;g<u;g++)try{i(d[h+g])}catch{throw new _.ErrnoError(29)}return u&&(l.node.timestamp=Date.now()),g}}),_.mkdev(n,s,f)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if(typeof XMLHttpRequest!="undefined")throw new Error("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.");if(re)try{e.contents=be(re(e.url),!0),e.usedBytes=e.contents.length}catch{throw new _.ErrnoError(29)}else throw new Error("Cannot load without read() or XMLHttpRequest.")},createLazyFile(e,r,t,i,n){class s{constructor(){this.lengthKnown=!1,this.chunks=[]}get(v){if(!(v>this.length-1||v<0)){var y=v%this.chunkSize,D=v/this.chunkSize|0;return this.getter(D)[y]}}setDataGetter(v){this.getter=v}cacheLength(){var v=new XMLHttpRequest;if(v.open("HEAD",t,!1),v.send(null),!(v.status>=200&&v.status<300||v.status===304))throw new Error("Couldn't load "+t+". Status: "+v.status);var y=Number(v.getResponseHeader("Content-length")),D,$=(D=v.getResponseHeader("Accept-Ranges"))&&D==="bytes",C=(D=v.getResponseHeader("Content-Encoding"))&&D==="gzip",c=1024*1024;$||(c=y);var m=(x,I)=>{if(x>I)throw new Error("invalid range ("+x+", "+I+") or no bytes requested!");if(I>y-1)throw new Error("only "+y+" bytes available! programmer error!");var S=new XMLHttpRequest;if(S.open("GET",t,!1),y!==c&&S.setRequestHeader("Range","bytes="+x+"-"+I),S.responseType="arraybuffer",S.overrideMimeType&&S.overrideMimeType("text/plain; charset=x-user-defined"),S.send(null),!(S.status>=200&&S.status<300||S.status===304))throw new Error("Couldn't load "+t+". Status: "+S.status);return S.response!==void 0?new Uint8Array(S.response||[]):be(S.responseText||"",!0)},F=this;F.setDataGetter(x=>{var I=x*c,S=(x+1)*c-1;if(S=Math.min(S,y-1),typeof F.chunks[x]=="undefined"&&(F.chunks[x]=m(I,S)),typeof F.chunks[x]=="undefined")throw new Error("doXHR failed!");return F.chunks[x]}),(C||!y)&&(c=y=1,y=this.getter(0).length,c=y,Oe("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=y,this._chunkSize=c,this.lengthKnown=!0}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(typeof XMLHttpRequest!="undefined"){if(!ue)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var f=new s,l={isDevice:!1,contents:f}}else var l={isDevice:!1,url:t};var d=_.createFile(e,r,l,i,n);l.contents?d.contents=l.contents:l.url&&(d.contents=null,d.url=l.url),Object.defineProperties(d,{usedBytes:{get:function(){return this.contents.length}}});var h={},u=Object.keys(d.stream_ops);u.forEach(g=>{var v=d.stream_ops[g];h[g]=(...y)=>(_.forceLoadFile(d),v(...y))});function p(g,v,y,D,$){var C=g.node.contents;if($>=C.length)return 0;var c=Math.min(C.length-$,D);if(C.slice)for(var m=0;m<c;m++)v[y+m]=C[$+m];else for(var m=0;m<c;m++)v[y+m]=C.get($+m);return c}return h.read=(g,v,y,D,$)=>(_.forceLoadFile(d),p(g,v,y,D,$)),h.mmap=(g,v,y,D,$)=>{_.forceLoadFile(d);var C=kr(v);if(!C)throw new _.ErrnoError(48);return p(g,A,C,v,y),{ptr:C,allocated:!0}},d.stream_ops=h,d}},j={DEFAULT_POLLMASK:5,calculateAt(e,r,t){if(T.isAbs(r))return r;var i;if(e===-100)i=_.cwd();else{var n=j.getStreamFromFD(e);i=n.path}if(r.length==0){if(!t)throw new _.ErrnoError(44);return i}return T.join2(i,r)},doStat(e,r,t){var i=e(r);w[t>>2]=i.dev,w[t+4>>2]=i.mode,k[t+8>>2]=i.nlink,w[t+12>>2]=i.uid,w[t+16>>2]=i.gid,w[t+20>>2]=i.rdev,R=[i.size>>>0,(E=i.size,+Math.abs(E)>=1?E>0?+Math.floor(E/4294967296)>>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],w[t+24>>2]=R[0],w[t+28>>2]=R[1],w[t+32>>2]=4096,w[t+36>>2]=i.blocks;var n=i.atime.getTime(),s=i.mtime.getTime(),f=i.ctime.getTime();return R=[Math.floor(n/1e3)>>>0,(E=Math.floor(n/1e3),+Math.abs(E)>=1?E>0?+Math.floor(E/4294967296)>>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],w[t+40>>2]=R[0],w[t+44>>2]=R[1],k[t+48>>2]=n%1e3*1e3,R=[Math.floor(s/1e3)>>>0,(E=Math.floor(s/1e3),+Math.abs(E)>=1?E>0?+Math.floor(E/4294967296)>>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],w[t+56>>2]=R[0],w[t+60>>2]=R[1],k[t+64>>2]=s%1e3*1e3,R=[Math.floor(f/1e3)>>>0,(E=Math.floor(f/1e3),+Math.abs(E)>=1?E>0?+Math.floor(E/4294967296)>>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],w[t+72>>2]=R[0],w[t+76>>2]=R[1],k[t+80>>2]=f%1e3*1e3,R=[i.ino>>>0,(E=i.ino,+Math.abs(E)>=1?E>0?+Math.floor(E/4294967296)>>>0:~~+Math.ceil((E-+(~~E>>>0))/4294967296)>>>0:0)],w[t+88>>2]=R[0],w[t+92>>2]=R[1],0},doMsync(e,r,t,i,n){if(!_.isFile(r.node.mode))throw new _.ErrnoError(43);if(i&2)return 0;var s=M.slice(e,e+t);_.msync(r,s,n,t,i)},getStreamFromFD(e){var r=_.getStreamChecked(e);return r},varargs:void 0,getStr(e){var r=K(e);return r}};function Et(e,r,t){j.varargs=t;try{var i=j.getStreamFromFD(e);switch(r){case 0:{var n=we();if(n<0)return-28;for(;_.streams[n];)n++;var s;return s=_.dupStream(i,n),s.fd}case 1:case 2:return 0;case 3:return i.flags;case 4:{var n=we();return i.flags|=n,0}case 12:{var n=Z(),f=0;return W[n+f>>1]=2,0}case 13:case 14:return 0}return-28}catch(l){if(typeof _=="undefined"||l.name!=="ErrnoError")throw l;return-l.errno}}function kt(e,r,t){j.varargs=t;try{var i=j.getStreamFromFD(e);switch(r){case 21509:return i.tty?0:-59;case 21505:{if(!i.tty)return-59;if(i.tty.ops.ioctl_tcgets){var n=i.tty.ops.ioctl_tcgets(i),s=Z();w[s>>2]=n.c_iflag||0,w[s+4>>2]=n.c_oflag||0,w[s+8>>2]=n.c_cflag||0,w[s+12>>2]=n.c_lflag||0;for(var f=0;f<32;f++)A[s+f+17]=n.c_cc[f]||0;return 0}return 0}case 21510:case 21511:case 21512:return i.tty?0:-59;case 21506:case 21507:case 21508:{if(!i.tty)return-59;if(i.tty.ops.ioctl_tcsets){for(var s=Z(),l=w[s>>2],d=w[s+4>>2],h=w[s+8>>2],u=w[s+12>>2],p=[],f=0;f<32;f++)p.push(A[s+f+17]);return i.tty.ops.ioctl_tcsets(i.tty,r,{c_iflag:l,c_oflag:d,c_cflag:h,c_lflag:u,c_cc:p})}return 0}case 21519:{if(!i.tty)return-59;var s=Z();return w[s>>2]=0,0}case 21520:return i.tty?-28:-59;case 21531:{var s=Z();return _.ioctl(i,r,s)}case 21523:{if(!i.tty)return-59;if(i.tty.ops.ioctl_tiocgwinsz){var g=i.tty.ops.ioctl_tiocgwinsz(i.tty),s=Z();W[s>>1]=g[0],W[s+2>>1]=g[1]}return 0}case 21524:return i.tty?0:-59;case 21515:return i.tty?0:-59;default:return-28}}catch(v){if(typeof _=="undefined"||v.name!=="ErrnoError")throw v;return-v.errno}}function xt(e,r,t,i){j.varargs=i;try{r=j.getStr(r),r=j.calculateAt(e,r);var n=i?we():0;return _.open(r,t,n).fd}catch(s){if(typeof _=="undefined"||s.name!=="ErrnoError")throw s;return-s.errno}}function Pt(e,r,t){try{return r=j.getStr(r),r=j.calculateAt(e,r),t===0?_.unlink(r):t===512?_.rmdir(r):_e("Invalid flags passed to unlinkat"),0}catch(i){if(typeof _=="undefined"||i.name!=="ErrnoError")throw i;return-i.errno}}var Ct=()=>{_e("")},Ee={},Ye=e=>{for(;e.length;){var r=e.pop(),t=e.pop();t(r)}};function ne(e){return this.fromWireType(k[e>>2])}var ee={},J={},ke={},xr,xe=e=>{throw new xr(e)},qe=(e,r,t)=>{e.forEach(function(l){ke[l]=r});function i(l){var d=t(l);d.length!==e.length&&xe("Mismatched type converter count");for(var h=0;h<e.length;++h)N(e[h],d[h])}var n=new Array(r.length),s=[],f=0;r.forEach((l,d)=>{J.hasOwnProperty(l)?n[d]=J[l]:(s.push(l),ee.hasOwnProperty(l)||(ee[l]=[]),ee[l].push(()=>{n[d]=J[l],++f,f===s.length&&i(n)}))}),s.length===0&&i(n)},Tt=e=>{var r=Ee[e];delete Ee[e];var t=r.rawConstructor,i=r.rawDestructor,n=r.fields,s=n.map(f=>f.getterReturnType).concat(n.map(f=>f.setterArgumentType));qe([e],s,f=>{var l={};return n.forEach((d,h)=>{var u=d.fieldName,p=f[h],g=d.getter,v=d.getterContext,y=f[h+n.length],D=d.setter,$=d.setterContext;l[u]={read:C=>p.fromWireType(g(v,C)),write:(C,c)=>{var m=[];D($,C,y.toWireType(m,c)),Ye(m)}}}),[{name:r.name,fromWireType:d=>{var h={};for(var u in l)h[u]=l[u].read(d);return i(d),h},toWireType:(d,h)=>{for(var u in l)if(!(u in h))throw new TypeError(`Missing field: "${u}"`);var p=t();for(u in l)l[u].write(p,h[u]);return d!==null&&d.push(i,p),p},argPackAdvance:H,readValueFromPointer:ne,destructorFunction:i}]})},Dt=(e,r,t,i,n)=>{},$t=()=>{for(var e=new Array(256),r=0;r<256;++r)e[r]=String.fromCharCode(r);Pr=e},Pr,O=e=>{for(var r="",t=e;M[t];)r+=Pr[M[t++]];return r},oe,P=e=>{throw new oe(e)};function Ft(e,r,t={}){var i=r.name;if(e||P(`type "${i}" must have a positive integer typeid pointer`),J.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;P(`Cannot register type '${i}' twice`)}if(J[e]=r,delete ke[e],ee.hasOwnProperty(e)){var n=ee[e];delete ee[e],n.forEach(s=>s())}}function N(e,r,t={}){if(!("argPackAdvance"in r))throw new TypeError("registerType registeredInstance requires argPackAdvance");return Ft(e,r,t)}var H=8,St=(e,r,t,i)=>{r=O(r),N(e,{name:r,fromWireType:function(n){return!!n},toWireType:function(n,s){return s?t:i},argPackAdvance:H,readValueFromPointer:function(n){return this.fromWireType(M[n])},destructorFunction:null})},At=e=>({count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}),Xe=e=>{function r(t){return t.$$.ptrType.registeredClass.name}P(r(e)+" instance already deleted")},Ge=!1,Cr=e=>{},Rt=e=>{e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)},Tr=e=>{e.count.value-=1;var r=e.count.value===0;r&&Rt(e)},Dr=(e,r,t)=>{if(r===t)return e;if(t.baseClass===void 0)return null;var i=Dr(e,r,t.baseClass);return i===null?null:t.downcast(i)},$r={},Mt=()=>Object.keys(le).length,jt=()=>{var e=[];for(var r in le)le.hasOwnProperty(r)&&e.push(le[r]);return e},se=[],Ke=()=>{for(;se.length;){var e=se.pop();e.$$.deleteScheduled=!1,e.delete()}},fe,Ot=e=>{fe=e,se.length&&fe&&fe(Ke)},It=()=>{a.getInheritedInstanceCount=Mt,a.getLiveInheritedInstances=jt,a.flushPendingDeletes=Ke,a.setDelayFunction=Ot},le={},zt=(e,r)=>{for(r===void 0&&P("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r},Ut=(e,r)=>(r=zt(e,r),le[r]),Pe=(e,r)=>{(!r.ptrType||!r.ptr)&&xe("makeClassHandle requires ptr and ptrType");var t=!!r.smartPtrType,i=!!r.smartPtr;return t!==i&&xe("Both smartPtrType and smartPtr must be specified"),r.count={value:1},de(Object.create(e,{$$:{value:r,writable:!0}}))};function Nt(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=Ut(this.registeredClass,r);if(t!==void 0){if(t.$$.count.value===0)return t.$$.ptr=r,t.$$.smartPtr=e,t.clone();var i=t.clone();return this.destructor(e),i}function n(){return this.isSmartPointer?Pe(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):Pe(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var s=this.registeredClass.getActualType(r),f=$r[s];if(!f)return n.call(this);var l;this.isConst?l=f.constPointerType:l=f.pointerType;var d=Dr(r,this.registeredClass,l.registeredClass);return d===null?n.call(this):this.isSmartPointer?Pe(l.registeredClass.instancePrototype,{ptrType:l,ptr:d,smartPtrType:this,smartPtr:e}):Pe(l.registeredClass.instancePrototype,{ptrType:l,ptr:d})}var de=e=>typeof FinalizationRegistry=="undefined"?(de=r=>r,e):(Ge=new FinalizationRegistry(r=>{Tr(r.$$)}),de=r=>{var t=r.$$,i=!!t.smartPtr;if(i){var n={$$:t};Ge.register(r,n,r)}return r},Cr=r=>Ge.unregister(r),de(e)),Ht=()=>{Object.assign(Ce.prototype,{isAliasOf(e){if(!(this instanceof Ce)||!(e instanceof Ce))return!1;var r=this.$$.ptrType.registeredClass,t=this.$$.ptr;e.$$=e.$$;for(var i=e.$$.ptrType.registeredClass,n=e.$$.ptr;r.baseClass;)t=r.upcast(t),r=r.baseClass;for(;i.baseClass;)n=i.upcast(n),i=i.baseClass;return r===i&&t===n},clone(){if(this.$$.ptr||Xe(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e=de(Object.create(Object.getPrototypeOf(this),{$$:{value:At(this.$$)}}));return e.$$.count.value+=1,e.$$.deleteScheduled=!1,e},delete(){this.$$.ptr||Xe(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&P("Object already scheduled for deletion"),Cr(this),Tr(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||Xe(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&P("Object already scheduled for deletion"),se.push(this),se.length===1&&fe&&fe(Ke),this.$$.deleteScheduled=!0,this}})};function Ce(){}var ce=(e,r)=>Object.defineProperty(r,"name",{value:e}),Wt=(e,r,t)=>{if(e[r].overloadTable===void 0){var i=e[r];e[r]=function(...n){return e[r].overloadTable.hasOwnProperty(n.length)||P(`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[i.argCount]=i}},Je=(e,r,t)=>{a.hasOwnProperty(e)?((t===void 0||a[e].overloadTable!==void 0&&a[e].overloadTable[t]!==void 0)&&P(`Cannot register public name '${e}' twice`),Wt(a,e,e),a.hasOwnProperty(t)&&P(`Cannot register multiple overloads of a function with the same number of arguments (${t})!`),a[e].overloadTable[t]=r):(a[e]=r,t!==void 0&&(a[e].numArguments=t))},Lt=48,Bt=57,Vt=e=>{if(e===void 0)return"_unknown";e=e.replace(/[^a-zA-Z0-9_]/g,"$");var r=e.charCodeAt(0);return r>=Lt&&r<=Bt?`_${e}`:e};function Yt(e,r,t,i,n,s,f,l){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=i,this.baseClass=n,this.getActualType=s,this.upcast=f,this.downcast=l,this.pureVirtualFunctions=[]}var Qe=(e,r,t)=>{for(;r!==t;)r.upcast||P(`Expected null or instance of ${t.name}, got an instance of ${r.name}`),e=r.upcast(e),r=r.baseClass;return e};function qt(e,r){if(r===null)return this.isReference&&P(`null is not a valid ${this.name}`),0;r.$$||P(`Cannot pass "${tr(r)}" as a ${this.name}`),r.$$.ptr||P(`Cannot pass deleted object as a pointer of type ${this.name}`);var t=r.$$.ptrType.registeredClass,i=Qe(r.$$.ptr,t,this.registeredClass);return i}function Xt(e,r){var t;if(r===null)return this.isReference&&P(`null is not a valid ${this.name}`),this.isSmartPointer?(t=this.rawConstructor(),e!==null&&e.push(this.rawDestructor,t),t):0;(!r||!r.$$)&&P(`Cannot pass "${tr(r)}" as a ${this.name}`),r.$$.ptr||P(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&r.$$.ptrType.isConst&&P(`Cannot convert argument of type ${r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name} to parameter type ${this.name}`);var i=r.$$.ptrType.registeredClass;if(t=Qe(r.$$.ptr,i,this.registeredClass),this.isSmartPointer)switch(r.$$.smartPtr===void 0&&P("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:P(`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 n=r.clone();t=this.rawShare(t,z.toHandle(()=>n.delete())),e!==null&&e.push(this.rawDestructor,t)}break;default:P("Unsupporting sharing policy")}return t}function Gt(e,r){if(r===null)return this.isReference&&P(`null is not a valid ${this.name}`),0;r.$$||P(`Cannot pass "${tr(r)}" as a ${this.name}`),r.$$.ptr||P(`Cannot pass deleted object as a pointer of type ${this.name}`),r.$$.ptrType.isConst&&P(`Cannot convert argument of type ${r.$$.ptrType.name} to parameter type ${this.name}`);var t=r.$$.ptrType.registeredClass,i=Qe(r.$$.ptr,t,this.registeredClass);return i}var Kt=()=>{Object.assign(Te.prototype,{getPointee(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e},destructor(e){var r;(r=this.rawDestructor)==null||r.call(this,e)},argPackAdvance:H,readValueFromPointer:ne,fromWireType:Nt})};function Te(e,r,t,i,n,s,f,l,d,h,u){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=i,this.isSmartPointer=n,this.pointeeType=s,this.sharingPolicy=f,this.rawGetPointee=l,this.rawConstructor=d,this.rawShare=h,this.rawDestructor=u,!n&&r.baseClass===void 0?i?(this.toWireType=qt,this.destructorFunction=null):(this.toWireType=Gt,this.destructorFunction=null):this.toWireType=Xt}var Fr=(e,r,t)=>{a.hasOwnProperty(e)||xe("Replacing nonexistent public symbol"),a[e].overloadTable!==void 0&&t!==void 0?a[e].overloadTable[t]=r:(a[e]=r,a[e].argCount=t)},Jt=(e,r,t)=>{e=e.replace(/p/g,"i");var i=a["dynCall_"+e];return i(r,...t)},De=[],Sr,Ar=e=>{var r=De[e];return r||(e>=De.length&&(De.length=e+1),De[e]=r=Sr.get(e)),r},Qt=(e,r,t=[])=>{if(e.includes("j"))return Jt(e,r,t);var i=Ar(r)(...t);return i},Zt=(e,r)=>(...t)=>Qt(e,r,t),B=(e,r)=>{e=O(e);function t(){return e.includes("j")?Zt(e,r):Ar(r)}var i=t();return typeof i!="function"&&P(`unknown function pointer with signature ${e}: ${r}`),i},ei=(e,r)=>{var t=ce(r,function(i){this.name=r,this.message=i;var n=new Error(i).stack;n!==void 0&&(this.stack=this.toString()+`
`+n.replace(/^Error(:[^\n]*)?\n/,""))});return t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},t},Rr,Mr=e=>{var r=ca(e),t=O(r);return q(r),t},jr=(e,r)=>{var t=[],i={};function n(s){if(!i[s]&&!J[s]){if(ke[s]){ke[s].forEach(n);return}t.push(s),i[s]=!0}}throw r.forEach(n),new Rr(`${e}: `+t.map(Mr).join([", "]))},ri=(e,r,t,i,n,s,f,l,d,h,u,p,g)=>{u=O(u),s=B(n,s),l&&(l=B(f,l)),h&&(h=B(d,h)),g=B(p,g);var v=Vt(u);Je(v,function(){jr(`Cannot construct ${u} due to unbound types`,[i])}),qe([e,r,t],i?[i]:[],y=>{var S