UNPKG

@qs-coder/libheif-js

Version:

Emscripten distribution of libheif for Node.JS and the browser

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