UNPKG

@nutrient-sdk/node

Version:

Convert documents in your Node.js apps.

18 lines 80.2 kB
/*! * Nutrient for Node.js 1.1.0 (https://www.nutrient.io/nodejs) * * Copyright © 2024-2025 PSPDFKit GmbH. All rights reserved. * * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT. * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES. * This notice may not be removed from this file. * * Nutrient uses several open source third-party components: https://www.nutrient.io/legal/acknowledgements/nodejs-acknowledgements/ */ var e,r=(e="undefined"!=typeof document?document.currentScript?.src:void 0,"undefined"!=typeof __filename&&(e=e||__filename),function(r={}){var t,n,o,a,i,s,l,u,d,c,f,h,p,m,v,y,g,w,E,b,_,k,$,C,P,T,D=new Promise((e,r)=>{t=e,n=r}),F="object"==typeof window,S="undefined"!=typeof WorkerGlobalScope,M="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node&&"renderer"!=process.type,A=Object.assign({},r),j="./this.program",x=(e,r)=>{throw r},O="";if(M){var R=require("fs");require("path"),O=__dirname+"/",a=e=>(e=Z(e)?new URL(e):e,R.readFileSync(e)),o=async(e,r=!0)=>(e=Z(e)?new URL(e):e,R.readFileSync(e,r?void 0:"utf8")),!r.thisProgram&&process.argv.length>1&&(j=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),x=(e,r)=>{throw process.exitCode=e,r}}else(F||S)&&(S?O=self.location.href:"undefined"!=typeof document&&document.currentScript&&(O=document.currentScript.src),e&&(O=e),O=O.startsWith("blob:")?"":O.substr(0,O.replace(/[?#].*/,"").lastIndexOf("/")+1),S&&(a=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),o=async e=>{if(Z(e))return new Promise((r,t)=>{var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=()=>{if(200==n.status||0==n.status&&n.response)return void r(n.response);t(n.status)},n.onerror=t,n.send(null)});var r=await fetch(e,{credentials:"same-origin"});if(r.ok)return r.arrayBuffer();throw Error(r.status+" : "+r.url)});var N=r.print||console.log.bind(console),z=r.printErr||console.error.bind(console);Object.assign(r,A),A=null,r.arguments&&r.arguments,r.thisProgram&&(j=r.thisProgram);var U=r.wasmBinary,W=!1;function L(){var e=i.buffer;r.HEAP8=l=new Int8Array(e),r.HEAP16=d=new Int16Array(e),r.HEAPU8=u=new Uint8Array(e),r.HEAPU16=c=new Uint16Array(e),r.HEAP32=f=new Int32Array(e),r.HEAPU32=h=new Uint32Array(e),r.HEAPF32=p=new Float32Array(e),r.HEAPF64=m=new Float64Array(e)}var H=[],I=[],B=[],V=!1,Y=0,q=null;function G(e){Y++,r.monitorRunDependencies?.(Y)}function X(e){if(Y--,r.monitorRunDependencies?.(Y),0==Y&&q){var t=q;q=null,t()}}function J(e){r.onAbort?.(e),z(e="Aborted("+e+")"),W=!0,e+=". Build with -sASSERTIONS for more info.",V&&tx();var t=new WebAssembly.RuntimeError(e);throw n(t),t}var K=e=>e.startsWith("data:application/octet-stream;base64,"),Z=e=>e.startsWith("file://");async function Q(e){if(!U)try{var r=await o(e);return new Uint8Array(r)}catch{}if(e==v&&U)return new Uint8Array(U);if(a)return a(e);throw"both async and sync fetching of the wasm failed"}async function ee(e,r){try{var t=await Q(e);return await WebAssembly.instantiate(t,r)}catch(e){z(`failed to asynchronously prepare wasm: ${e}`),J(e)}}async function er(e,r,t){if(!e&&"function"==typeof WebAssembly.instantiateStreaming&&!K(r)&&!Z(r)&&!M&&"function"==typeof fetch)try{var n=fetch(r,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(n,t)}catch(e){z(`wasm streaming compile failed: ${e}`),z("falling back to ArrayBuffer instantiation")}return ee(r,t)}async function et(){function e(e,r){var t;return i=(P=e.exports).Ca,L(),$=P.Ha,t=P.Da,I.unshift(t),X("wasm-instantiate"),P}G("wasm-instantiate");var t={a:tD};if(r.instantiateWasm)try{return r.instantiateWasm(t,e)}catch(e){z(`Module.instantiateWasm callback failed with error: ${e}`),n(e)}v??=function(){var e="nutrient-viewer.wasm.wasm";return K(e)?e:r.locateFile?r.locateFile(e,O):O+e}();try{var o=await er(U,v,t);return e(o.instance),o}catch(e){n(e);return}}var en={3158468:()=>"undefined"!=typeof wasmOffsetConverter};class eo{name="ExitStatus";constructor(e){this.message=`Program terminated with exit(${e})`,this.status=e}}var ea=e=>{for(;e.length>0;)e.shift()(r)},ei=r.noExitRuntime||!0,es={isAbs:e=>"/"===e.charAt(0),splitPath:e=>/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1),normalizeArray:(e,r)=>{for(var t=0,n=e.length-1;n>=0;n--){var o=e[n];"."===o?e.splice(n,1):".."===o?(e.splice(n,1),t++):t&&(e.splice(n,1),t--)}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=es.isAbs(e),t="/"===e.substr(-1);return(e=es.normalizeArray(e.split("/").filter(e=>!!e),!r).join("/"))||r||(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=es.splitPath(e),t=r[0],n=r[1];return t||n?(n&&(n=n.substr(0,n.length-1)),t+n):"."},basename:e=>{if("/"===e)return"/";var r=(e=(e=es.normalize(e)).replace(/\/$/,"")).lastIndexOf("/");return -1===r?e:e.substr(r+1)},join:(...e)=>es.normalize(e.join("/")),join2:(e,r)=>es.normalize(e+"/"+r)},el=()=>{if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues)return e=>crypto.getRandomValues(e);if(M)try{var e=require("crypto");if(e.randomFillSync)return r=>e.randomFillSync(r);var r=e.randomBytes;return e=>(e.set(r(e.byteLength)),e)}catch(e){}J("initRandomDevice")},eu=e=>(eu=el())(e),ed={resolve:(...e)=>{for(var r="",t=!1,n=e.length-1;n>=-1&&!t;n--){var o=n>=0?e[n]:eM.cwd();if("string"!=typeof o)throw TypeError("Arguments to path.resolve must be strings");if(!o)return"";r=o+"/"+r,t=es.isAbs(o)}return r=es.normalizeArray(r.split("/").filter(e=>!!e),!t).join("/"),(t?"/":"")+r||"."},relative:(e,r)=>{function t(e){for(var r=0;r<e.length&&""===e[r];r++);for(var t=e.length-1;t>=0&&""===e[t];t--);return r>t?[]:e.slice(r,t-r+1)}e=ed.resolve(e).substr(1),r=ed.resolve(r).substr(1);for(var n=t(e.split("/")),o=t(r.split("/")),a=Math.min(n.length,o.length),i=a,s=0;s<a;s++)if(n[s]!==o[s]){i=s;break}for(var l=[],s=i;s<n.length;s++)l.push("..");return(l=l.concat(o.slice(i))).join("/")}},ec="undefined"!=typeof TextDecoder?new TextDecoder:void 0,ef=(e,r=0,t=NaN)=>{for(var n=r+t,o=r;e[o]&&!(o>=n);)++o;if(o-r>16&&e.buffer&&ec)return ec.decode(e.subarray(r,o));for(var a="";r<o;){var i=e[r++];if(!(128&i)){a+=String.fromCharCode(i);continue}var s=63&e[r++];if((224&i)==192){a+=String.fromCharCode((31&i)<<6|s);continue}var l=63&e[r++];if((i=(240&i)==224?(15&i)<<12|s<<6|l:(7&i)<<18|s<<12|l<<6|63&e[r++])<65536)a+=String.fromCharCode(i);else{var u=i-65536;a+=String.fromCharCode(55296|u>>10,56320|1023&u)}}return a},eh=[],ep=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n<=127?r++:n<=2047?r+=2:n>=55296&&n<=57343?(r+=4,++t):r+=3}return r},em=(e,r,t,n)=>{if(!(n>0))return 0;for(var o=t,a=t+n-1,i=0;i<e.length;++i){var s=e.charCodeAt(i);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++i)),s<=127){if(t>=a)break;r[t++]=s}else if(s<=2047){if(t+1>=a)break;r[t++]=192|s>>6,r[t++]=128|63&s}else if(s<=65535){if(t+2>=a)break;r[t++]=224|s>>12,r[t++]=128|s>>6&63,r[t++]=128|63&s}else{if(t+3>=a)break;r[t++]=240|s>>18,r[t++]=128|s>>12&63,r[t++]=128|s>>6&63,r[t++]=128|63&s}}return r[t]=0,t-o};function ev(e,r,t){var n=Array(t>0?t:ep(e)+1),o=em(e,n,0,n.length);return r&&(n.length=o),n}var ey=()=>{if(!eh.length){var e=null;if(M){var r=Buffer.alloc(256),t=0,n=process.stdin.fd;try{t=R.readSync(n,r,0,256)}catch(e){if(e.toString().includes("EOF"))t=0;else throw e}t>0&&(e=r.slice(0,t).toString("utf-8"))}else"undefined"!=typeof window&&"function"==typeof window.prompt&&null!==(e=window.prompt("Input: "))&&(e+="\n");if(!e)return null;eh=ev(e,!0)}return eh.shift()},eg={ttys:[],init(){},shutdown(){},register(e,r){eg.ttys[e]={input:[],output:[],ops:r},eM.registerDevice(e,eg.stream_ops)},stream_ops:{open(e){var r=eg.ttys[e.node.rdev];if(!r)throw new eM.ErrnoError(43);e.tty=r,e.seekable=!1},close(e){e.tty.ops.fsync(e.tty)},fsync(e){e.tty.ops.fsync(e.tty)},read(e,r,t,n,o){if(!e.tty||!e.tty.ops.get_char)throw new eM.ErrnoError(60);for(var a,i=0,s=0;s<n;s++){try{a=e.tty.ops.get_char(e.tty)}catch(e){throw new eM.ErrnoError(29)}if(void 0===a&&0===i)throw new eM.ErrnoError(6);if(null==a)break;i++,r[t+s]=a}return i&&(e.node.atime=Date.now()),i},write(e,r,t,n,o){if(!e.tty||!e.tty.ops.put_char)throw new eM.ErrnoError(60);try{for(var a=0;a<n;a++)e.tty.ops.put_char(e.tty,r[t+a])}catch(e){throw new eM.ErrnoError(29)}return n&&(e.node.mtime=e.node.ctime=Date.now()),a}},default_tty_ops:{get_char:e=>ey(),put_char(e,r){null===r||10===r?(N(ef(e.output)),e.output=[]):0!=r&&e.output.push(r)},fsync(e){e.output&&e.output.length>0&&(N(ef(e.output)),e.output=[])},ioctl_tcgets:e=>({c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}),ioctl_tcsets:(e,r,t)=>0,ioctl_tiocgwinsz:e=>[24,80]},default_tty1_ops:{put_char(e,r){null===r||10===r?(z(ef(e.output)),e.output=[]):0!=r&&e.output.push(r)},fsync(e){e.output&&e.output.length>0&&(z(ef(e.output)),e.output=[])}}},ew=(e,r)=>{u.fill(0,e,e+r)},eE=(e,r)=>Math.ceil(e/r)*r,eb=e=>{e=eE(e,65536);var r=tA(65536,e);return r&&ew(r,e),r},e_={ops_table:null,mount:e=>e_.createNode(null,"/",16895,0),createNode(e,r,t,n){if(eM.isBlkdev(t)||eM.isFIFO(t))throw new eM.ErrnoError(63);e_.ops_table||={dir:{node:{getattr:e_.node_ops.getattr,setattr:e_.node_ops.setattr,lookup:e_.node_ops.lookup,mknod:e_.node_ops.mknod,rename:e_.node_ops.rename,unlink:e_.node_ops.unlink,rmdir:e_.node_ops.rmdir,readdir:e_.node_ops.readdir,symlink:e_.node_ops.symlink},stream:{llseek:e_.stream_ops.llseek}},file:{node:{getattr:e_.node_ops.getattr,setattr:e_.node_ops.setattr},stream:{llseek:e_.stream_ops.llseek,read:e_.stream_ops.read,write:e_.stream_ops.write,allocate:e_.stream_ops.allocate,mmap:e_.stream_ops.mmap,msync:e_.stream_ops.msync}},link:{node:{getattr:e_.node_ops.getattr,setattr:e_.node_ops.setattr,readlink:e_.node_ops.readlink},stream:{}},chrdev:{node:{getattr:e_.node_ops.getattr,setattr:e_.node_ops.setattr},stream:eM.chrdev_stream_ops}};var o=eM.createNode(e,r,t,n);return eM.isDir(o.mode)?(o.node_ops=e_.ops_table.dir.node,o.stream_ops=e_.ops_table.dir.stream,o.contents={}):eM.isFile(o.mode)?(o.node_ops=e_.ops_table.file.node,o.stream_ops=e_.ops_table.file.stream,o.usedBytes=0,o.contents=null):eM.isLink(o.mode)?(o.node_ops=e_.ops_table.link.node,o.stream_ops=e_.ops_table.link.stream):eM.isChrdev(o.mode)&&(o.node_ops=e_.ops_table.chrdev.node,o.stream_ops=e_.ops_table.chrdev.stream),o.atime=o.mtime=o.ctime=Date.now(),e&&(e.contents[r]=o,e.atime=e.mtime=e.ctime=o.atime),o},getFileDataAsTypedArray:e=>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)){r=Math.max(r,t*(t<1048576?2:1.125)>>>0),0!=t&&(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(0==r)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=eM.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,eM.isDir(e.mode)?r.size=4096:eM.isFile(e.mode)?r.size=e.usedBytes:eM.isLink(e.mode)?r.size=e.link.length:r.size=0,r.atime=new Date(e.atime),r.mtime=new Date(e.mtime),r.ctime=new Date(e.ctime),r.blksize=4096,r.blocks=Math.ceil(r.size/r.blksize),r},setattr(e,r){for(let t of["mode","atime","mtime","ctime"])r[t]&&(e[t]=r[t]);void 0!==r.size&&e_.resizeFileStorage(e,r.size)},lookup(e,r){throw e_.doesNotExistError},mknod:(e,r,t,n)=>e_.createNode(e,r,t,n),rename(e,r,t){var n;try{n=eM.lookupNode(r,t)}catch(e){}if(n){if(eM.isDir(e.mode))for(var o in n.contents)throw new eM.ErrnoError(55);eM.hashRemoveNode(n)}delete e.parent.contents[e.name],r.contents[t]=e,e.name=t,r.ctime=r.mtime=e.parent.ctime=e.parent.mtime=Date.now()},unlink(e,r){delete e.contents[r],e.ctime=e.mtime=Date.now()},rmdir(e,r){var t=eM.lookupNode(e,r);for(var n in t.contents)throw new eM.ErrnoError(55);delete e.contents[r],e.ctime=e.mtime=Date.now()},readdir:e=>[".","..",...Object.keys(e.contents)],symlink(e,r,t){var n=e_.createNode(e,r,41471,0);return n.link=t,n},readlink(e){if(!eM.isLink(e.mode))throw new eM.ErrnoError(28);return e.link}},stream_ops:{read(e,r,t,n,o){var a=e.node.contents;if(o>=e.node.usedBytes)return 0;var i=Math.min(e.node.usedBytes-o,n);if(i>8&&a.subarray)r.set(a.subarray(o,o+i),t);else for(var s=0;s<i;s++)r[t+s]=a[o+s];return i},write(e,r,t,n,o,a){if(r.buffer===l.buffer&&(a=!1),!n)return 0;var i=e.node;if(i.mtime=i.ctime=Date.now(),r.subarray&&(!i.contents||i.contents.subarray)){if(a)return i.contents=r.subarray(t,t+n),i.usedBytes=n,n;else if(0===i.usedBytes&&0===o)return i.contents=r.slice(t,t+n),i.usedBytes=n,n;else if(o+n<=i.usedBytes)return i.contents.set(r.subarray(t,t+n),o),n}if(e_.expandFileStorage(i,o+n),i.contents.subarray&&r.subarray)i.contents.set(r.subarray(t,t+n),o);else for(var s=0;s<n;s++)i.contents[o+s]=r[t+s];return i.usedBytes=Math.max(i.usedBytes,o+n),n},llseek(e,r,t){var n=r;if(1===t?n+=e.position:2===t&&eM.isFile(e.node.mode)&&(n+=e.node.usedBytes),n<0)throw new eM.ErrnoError(28);return n},allocate(e,r,t){e_.expandFileStorage(e.node,r+t),e.node.usedBytes=Math.max(e.node.usedBytes,r+t)},mmap(e,r,t,n,o){if(!eM.isFile(e.node.mode))throw new eM.ErrnoError(43);var a,i,s=e.node.contents;if(!(2&o)&&s&&s.buffer===l.buffer)i=!1,a=s.byteOffset;else{if(i=!0,!(a=eb(r)))throw new eM.ErrnoError(48);s&&((t>0||t+r<s.length)&&(s=s.subarray?s.subarray(t,t+r):Array.prototype.slice.call(s,t,t+r)),l.set(s,a))}return{ptr:a,allocated:i}},msync:(e,r,t,n,o)=>(e_.stream_ops.write(e,r,0,n,t,!1),0)}},ek=async e=>new Uint8Array(await o(e)),e$=(e,r,t,n,o,a)=>{eM.createDataFile(e,r,t,n,o,a)},eC=r.preloadPlugins||[],eP=(e,r,t,n)=>{"undefined"!=typeof Browser&&Browser.init();var o=!1;return eC.forEach(a=>{!o&&a.canHandle(r)&&(a.handle(e,r,t,n),o=!0)}),o},eT=(e,r,t,n,o,a,i,s,l,u)=>{var d=r?ed.resolve(es.join2(e,r)):e,c=`cp ${d}`;function f(t){function f(t){u?.(),s||e$(e,r,t,n,o,l),a?.(),X(c)}eP(t,d,f,()=>{i?.(),X(c)})||f(t)}G(c),"string"==typeof t?ek(t).then(f,i):f(t)},eD=e=>{var r={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[e];if(void 0===r)throw Error(`Unknown file open mode: ${e}`);return r},eF=(e,r)=>{var t=0;return e&&(t|=365),r&&(t|=146),t},eS={DIR_MODE:16895,FILE_MODE:33279,reader:null,mount(e){S||J(void 0),eS.reader??=new FileReaderSync;var r=eS.createNode(null,"/",eS.DIR_MODE,0),t={};function n(e){for(var n=e.split("/"),o=r,a=0;a<n.length-1;a++){var i=n.slice(0,a+1).join("/");t[i]||=eS.createNode(o,n[a],eS.DIR_MODE,0),o=t[i]}return o}function o(e){var r=e.split("/");return r[r.length-1]}return Array.prototype.forEach.call(e.opts.files||[],function(e){eS.createNode(n(e.name),o(e.name),eS.FILE_MODE,0,e,e.lastModifiedDate)}),(e.opts.blobs||[]).forEach(e=>{eS.createNode(n(e.name),o(e.name),eS.FILE_MODE,0,e.data)}),(e.opts.packages||[]).forEach(e=>{e.metadata.files.forEach(r=>{var t=r.filename.substr(1);eS.createNode(n(t),o(t),eS.FILE_MODE,0,e.blob.slice(r.start,r.end))})}),r},createNode(e,r,t,n,o,a){var i=eM.createNode(e,r,t);return i.mode=t,i.node_ops=eS.node_ops,i.stream_ops=eS.stream_ops,i.atime=i.mtime=i.ctime=(a||new Date).getTime(),eS.FILE_MODE===eS.DIR_MODE&&J(void 0),t===eS.FILE_MODE?(i.size=o.size,i.contents=o):(i.size=4096,i.contents={}),e&&(e.contents[r]=i),i},node_ops:{getattr:e=>({dev:1,ino:e.id,mode:e.mode,nlink:1,uid:0,gid:0,rdev:0,size:e.size,atime:new Date(e.atime),mtime:new Date(e.mtime),ctime:new Date(e.ctime),blksize:4096,blocks:Math.ceil(e.size/4096)}),setattr(e,r){for(let t of["mode","atime","mtime","ctime"])r[t]&&(e[t]=r[t])},lookup(e,r){throw new eM.ErrnoError(44)},mknod(e,r,t,n){throw new eM.ErrnoError(63)},rename(e,r,t){throw new eM.ErrnoError(63)},unlink(e,r){throw new eM.ErrnoError(63)},rmdir(e,r){throw new eM.ErrnoError(63)},readdir(e){var r=[".",".."];for(var t of Object.keys(e.contents))r.push(t);return r},symlink(e,r,t){throw new eM.ErrnoError(63)}},stream_ops:{read(e,r,t,n,o){if(o>=e.node.size)return 0;var a=e.node.contents.slice(o,o+n),i=eS.reader.readAsArrayBuffer(a);return r.set(new Uint8Array(i),t),a.size},write(e,r,t,n,o){throw new eM.ErrnoError(29)},llseek(e,r,t){var n=r;if(1===t?n+=e.position:2===t&&eM.isFile(e.node.mode)&&(n+=e.node.size),n<0)throw new eM.ErrnoError(28);return n}}},eM={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:class{name="ErrnoError";constructor(e){this.errno=e}},filesystems:null,syncFSRequests:0,readFiles:{},FSStream:class{shared={};get object(){return this.node}set object(e){this.node=e}get isRead(){return(2097155&this.flags)!=1}get isWrite(){return(2097155&this.flags)!=0}get isAppend(){return 1024&this.flags}get flags(){return this.shared.flags}set flags(e){this.shared.flags=e}get position(){return this.shared.position}set position(e){this.shared.position=e}},FSNode:class{node_ops={};stream_ops={};readMode=365;writeMode=146;mounted=null;constructor(e,r,t,n){e||(e=this),this.parent=e,this.mount=e.mount,this.id=eM.nextInode++,this.name=r,this.mode=t,this.rdev=n,this.atime=this.mtime=this.ctime=Date.now()}get read(){return(this.mode&this.readMode)===this.readMode}set read(e){e?this.mode|=this.readMode:this.mode&=~this.readMode}get write(){return(this.mode&this.writeMode)===this.writeMode}set write(e){e?this.mode|=this.writeMode:this.mode&=~this.writeMode}get isFolder(){return eM.isDir(this.mode)}get isDevice(){return eM.isChrdev(this.mode)}},lookupPath(e,r={}){if(!e)return{path:"",node:null};r.follow_mount??=!0,es.isAbs(e)||(e=eM.cwd()+"/"+e);e:for(var t=0;t<40;t++){for(var n=e.split("/").filter(e=>!!e&&"."!==e),o=eM.root,a="/",i=0;i<n.length;i++){var s=i===n.length-1;if(s&&r.parent)break;if(".."===n[i]){a=es.dirname(a),o=o.parent;continue}a=es.join2(a,n[i]);try{o=eM.lookupNode(o,n[i])}catch(e){if(e?.errno===44&&s&&r.noent_okay)return{path:a};throw e}if(eM.isMountpoint(o)&&(!s||r.follow_mount)&&(o=o.mounted.root),eM.isLink(o.mode)&&(!s||r.follow)){if(!o.node_ops.readlink)throw new eM.ErrnoError(52);var l=o.node_ops.readlink(o);es.isAbs(l)||(l=es.dirname(a)+"/"+l),e=l+"/"+n.slice(i+1).join("/");continue e}}return{path:a,node:o}}throw new eM.ErrnoError(32)},getPath(e){for(var r;;){if(eM.isRoot(e)){var t=e.mount.mountpoint;if(!r)return t;return"/"!==t[t.length-1]?`${t}/${r}`:t+r}r=r?`${e.name}/${r}`:e.name,e=e.parent}},hashName(e,r){for(var t=0,n=0;n<r.length;n++)t=(t<<5)-t+r.charCodeAt(n)|0;return(e+t>>>0)%eM.nameTable.length},hashAddNode(e){var r=eM.hashName(e.parent.id,e.name);e.name_next=eM.nameTable[r],eM.nameTable[r]=e},hashRemoveNode(e){var r=eM.hashName(e.parent.id,e.name);if(eM.nameTable[r]===e)eM.nameTable[r]=e.name_next;else for(var t=eM.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next}},lookupNode(e,r){var t=eM.mayLookup(e);if(t)throw new eM.ErrnoError(t);for(var n=eM.hashName(e.id,r),o=eM.nameTable[n];o;o=o.name_next){var a=o.name;if(o.parent.id===e.id&&a===r)return o}return eM.lookup(e,r)},createNode(e,r,t,n){var o=new eM.FSNode(e,r,t,n);return eM.hashAddNode(o),o},destroyNode(e){eM.hashRemoveNode(e)},isRoot:e=>e===e.parent,isMountpoint:e=>!!e.mounted,isFile:e=>(61440&e)==32768,isDir:e=>(61440&e)==16384,isLink:e=>(61440&e)==40960,isChrdev:e=>(61440&e)==8192,isBlkdev:e=>(61440&e)==24576,isFIFO:e=>(61440&e)==4096,isSocket:e=>(49152&e)==49152,flagsToPermissionString(e){var r=["r","w","rw"][3&e];return 512&e&&(r+="w"),r},nodePermissions:(e,r)=>eM.ignorePermissions?0:r.includes("r")&&!(292&e.mode)||r.includes("w")&&!(146&e.mode)||r.includes("x")&&!(73&e.mode)?2:0,mayLookup(e){if(!eM.isDir(e.mode))return 54;var r=eM.nodePermissions(e,"x");return r||2*!e.node_ops.lookup},mayCreate(e,r){if(!eM.isDir(e.mode))return 54;try{return eM.lookupNode(e,r),20}catch(e){}return eM.nodePermissions(e,"wx")},mayDelete(e,r,t){try{n=eM.lookupNode(e,r)}catch(e){return e.errno}var n,o=eM.nodePermissions(e,"wx");if(o)return o;if(t){if(!eM.isDir(n.mode))return 54;if(eM.isRoot(n)||eM.getPath(n)===eM.cwd())return 10}else if(eM.isDir(n.mode))return 31;return 0},mayOpen:(e,r)=>e?eM.isLink(e.mode)?32:eM.isDir(e.mode)&&("r"!==eM.flagsToPermissionString(r)||512&r)?31:eM.nodePermissions(e,eM.flagsToPermissionString(r)):44,MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=eM.MAX_OPEN_FDS;e++)if(!eM.streams[e])return e;throw new eM.ErrnoError(33)},getStreamChecked(e){var r=eM.getStream(e);if(!r)throw new eM.ErrnoError(8);return r},getStream:e=>eM.streams[e],createStream:(e,r=-1)=>(e=Object.assign(new eM.FSStream,e),-1==r&&(r=eM.nextfd()),e.fd=r,eM.streams[r]=e,e),closeStream(e){eM.streams[e]=null},dupStream(e,r=-1){var t=eM.createStream(e,r);return t.stream_ops?.dup?.(t),t},chrdev_stream_ops:{open(e){var r=eM.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open?.(e)},llseek(){throw new eM.ErrnoError(70)}},major:e=>e>>8,minor:e=>255&e,makedev:(e,r)=>e<<8|r,registerDevice(e,r){eM.devices[e]={stream_ops:r}},getDevice:e=>eM.devices[e],getMounts(e){for(var r=[],t=[e];t.length;){var n=t.pop();r.push(n),t.push(...n.mounts)}return r},syncfs(e,r){"function"==typeof e&&(r=e,e=!1),eM.syncFSRequests++,eM.syncFSRequests>1&&z(`warning: ${eM.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var t=eM.getMounts(eM.root.mount),n=0;function o(e){return eM.syncFSRequests--,r(e)}function a(e){if(e)return a.errored?void 0:(a.errored=!0,o(e));++n>=t.length&&o(null)}t.forEach(r=>{if(!r.type.syncfs)return a(null);r.type.syncfs(r,e,a)})},mount(e,r,t){var n,o="/"===t,a=!t;if(o&&eM.root)throw new eM.ErrnoError(10);if(!o&&!a){var i=eM.lookupPath(t,{follow_mount:!1});if(t=i.path,n=i.node,eM.isMountpoint(n))throw new eM.ErrnoError(10);if(!eM.isDir(n.mode))throw new eM.ErrnoError(54)}var s={type:e,opts:r,mountpoint:t,mounts:[]},l=e.mount(s);return l.mount=s,s.root=l,o?eM.root=l:n&&(n.mounted=s,n.mount&&n.mount.mounts.push(s)),l},unmount(e){var r=eM.lookupPath(e,{follow_mount:!1});if(!eM.isMountpoint(r.node))throw new eM.ErrnoError(28);var t=r.node,n=t.mounted,o=eM.getMounts(n);Object.keys(eM.nameTable).forEach(e=>{for(var r=eM.nameTable[e];r;){var t=r.name_next;o.includes(r.mount)&&eM.destroyNode(r),r=t}}),t.mounted=null;var a=t.mount.mounts.indexOf(n);t.mount.mounts.splice(a,1)},lookup:(e,r)=>e.node_ops.lookup(e,r),mknod(e,r,t){var n=eM.lookupPath(e,{parent:!0}).node,o=es.basename(e);if(!o||"."===o||".."===o)throw new eM.ErrnoError(28);var a=eM.mayCreate(n,o);if(a)throw new eM.ErrnoError(a);if(!n.node_ops.mknod)throw new eM.ErrnoError(63);return n.node_ops.mknod(n,o,r,t)},statfs(e){var r={bsize:4096,frsize:4096,blocks:1e6,bfree:5e5,bavail:5e5,files:eM.nextInode,ffree:eM.nextInode-1,fsid:42,flags:2,namelen:255},t=eM.lookupPath(e,{follow:!0}).node;return t?.node_ops.statfs&&Object.assign(r,t.node_ops.statfs(t.mount.opts.root)),r},create:(e,r=438)=>(r&=4095,r|=32768,eM.mknod(e,r,0)),mkdir:(e,r=511)=>(r&=1023,r|=16384,eM.mknod(e,r,0)),mkdirTree(e,r){for(var t=e.split("/"),n="",o=0;o<t.length;++o)if(t[o]){n+="/"+t[o];try{eM.mkdir(n,r)}catch(e){if(20!=e.errno)throw e}}},mkdev:(e,r,t)=>(void 0===t&&(t=r,r=438),r|=8192,eM.mknod(e,r,t)),symlink(e,r){if(!ed.resolve(e))throw new eM.ErrnoError(44);var t=eM.lookupPath(r,{parent:!0}).node;if(!t)throw new eM.ErrnoError(44);var n=es.basename(r),o=eM.mayCreate(t,n);if(o)throw new eM.ErrnoError(o);if(!t.node_ops.symlink)throw new eM.ErrnoError(63);return t.node_ops.symlink(t,n,e)},rename(e,r){var t,n,o,a,i=es.dirname(e),s=es.dirname(r),l=es.basename(e),u=es.basename(r);if(n=eM.lookupPath(e,{parent:!0}).node,o=eM.lookupPath(r,{parent:!0}).node,!n||!o)throw new eM.ErrnoError(44);if(n.mount!==o.mount)throw new eM.ErrnoError(75);var d=eM.lookupNode(n,l),c=ed.relative(e,s);if("."!==c.charAt(0))throw new eM.ErrnoError(28);if("."!==(c=ed.relative(r,i)).charAt(0))throw new eM.ErrnoError(55);try{a=eM.lookupNode(o,u)}catch(e){}if(d!==a){var f=eM.isDir(d.mode),h=eM.mayDelete(n,l,f);if(h||(h=a?eM.mayDelete(o,u,f):eM.mayCreate(o,u)))throw new eM.ErrnoError(h);if(!n.node_ops.rename)throw new eM.ErrnoError(63);if(eM.isMountpoint(d)||a&&eM.isMountpoint(a))throw new eM.ErrnoError(10);if(o!==n&&(h=eM.nodePermissions(n,"w")))throw new eM.ErrnoError(h);eM.hashRemoveNode(d);try{n.node_ops.rename(d,o,u),d.parent=o}catch(e){throw e}finally{eM.hashAddNode(d)}}},rmdir(e){var r=eM.lookupPath(e,{parent:!0}).node,t=es.basename(e),n=eM.lookupNode(r,t),o=eM.mayDelete(r,t,!0);if(o)throw new eM.ErrnoError(o);if(!r.node_ops.rmdir)throw new eM.ErrnoError(63);if(eM.isMountpoint(n))throw new eM.ErrnoError(10);r.node_ops.rmdir(r,t),eM.destroyNode(n)},readdir(e){var r=eM.lookupPath(e,{follow:!0}).node;if(!r.node_ops.readdir)throw new eM.ErrnoError(54);return r.node_ops.readdir(r)},unlink(e){var r=eM.lookupPath(e,{parent:!0}).node;if(!r)throw new eM.ErrnoError(44);var t=es.basename(e),n=eM.lookupNode(r,t),o=eM.mayDelete(r,t,!1);if(o)throw new eM.ErrnoError(o);if(!r.node_ops.unlink)throw new eM.ErrnoError(63);if(eM.isMountpoint(n))throw new eM.ErrnoError(10);r.node_ops.unlink(r,t),eM.destroyNode(n)},readlink(e){var r=eM.lookupPath(e).node;if(!r)throw new eM.ErrnoError(44);if(!r.node_ops.readlink)throw new eM.ErrnoError(28);return r.node_ops.readlink(r)},stat(e,r){var t=eM.lookupPath(e,{follow:!r}).node;if(!t)throw new eM.ErrnoError(44);if(!t.node_ops.getattr)throw new eM.ErrnoError(63);return t.node_ops.getattr(t)},lstat:e=>eM.stat(e,!0),chmod(e,r,t){var n;if(!(n="string"==typeof e?eM.lookupPath(e,{follow:!t}).node:e).node_ops.setattr)throw new eM.ErrnoError(63);n.node_ops.setattr(n,{mode:4095&r|-4096&n.mode,ctime:Date.now()})},lchmod(e,r){eM.chmod(e,r,!0)},fchmod(e,r){var t=eM.getStreamChecked(e);eM.chmod(t.node,r)},chown(e,r,t,n){var o;if(!(o="string"==typeof e?eM.lookupPath(e,{follow:!n}).node:e).node_ops.setattr)throw new eM.ErrnoError(63);o.node_ops.setattr(o,{timestamp:Date.now()})},lchown(e,r,t){eM.chown(e,r,t,!0)},fchown(e,r,t){var n=eM.getStreamChecked(e);eM.chown(n.node,r,t)},truncate(e,r){if(r<0)throw new eM.ErrnoError(28);if("string"==typeof e){var t;t=eM.lookupPath(e,{follow:!0}).node}else t=e;if(!t.node_ops.setattr)throw new eM.ErrnoError(63);if(eM.isDir(t.mode))throw new eM.ErrnoError(31);if(!eM.isFile(t.mode))throw new eM.ErrnoError(28);var n=eM.nodePermissions(t,"w");if(n)throw new eM.ErrnoError(n);t.node_ops.setattr(t,{size:r,timestamp:Date.now()})},ftruncate(e,r){var t=eM.getStreamChecked(e);if((2097155&t.flags)==0)throw new eM.ErrnoError(28);eM.truncate(t.node,r)},utime(e,r,t){var n=eM.lookupPath(e,{follow:!0}).node;n.node_ops.setattr(n,{atime:r,mtime:t})},open(e,t,n=438){if(""===e)throw new eM.ErrnoError(44);if(n=64&(t="string"==typeof t?eD(t):t)?4095&n|32768:0,"object"==typeof e)o=e;else{var o,a=eM.lookupPath(e,{follow:!(131072&t),noent_okay:!0});o=a.node,e=a.path}var i=!1;if(64&t)if(o){if(128&t)throw new eM.ErrnoError(20)}else o=eM.mknod(e,n,0),i=!0;if(!o)throw new eM.ErrnoError(44);if(eM.isChrdev(o.mode)&&(t&=-513),65536&t&&!eM.isDir(o.mode))throw new eM.ErrnoError(54);if(!i){var s=eM.mayOpen(o,t);if(s)throw new eM.ErrnoError(s)}512&t&&!i&&eM.truncate(o,0),t&=-131713;var l=eM.createStream({node:o,path:eM.getPath(o),flags:t,seekable:!0,position:0,stream_ops:o.stream_ops,ungotten:[],error:!1});return l.stream_ops.open&&l.stream_ops.open(l),!r.logReadFiles||1&t||e in eM.readFiles||(eM.readFiles[e]=1),l},close(e){if(eM.isClosed(e))throw new eM.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(e){throw e}finally{eM.closeStream(e.fd)}e.fd=null},isClosed:e=>null===e.fd,llseek(e,r,t){if(eM.isClosed(e))throw new eM.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new eM.ErrnoError(70);if(0!=t&&1!=t&&2!=t)throw new eM.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read(e,r,t,n,o){if(n<0||o<0)throw new eM.ErrnoError(28);if(eM.isClosed(e)||(2097155&e.flags)==1)throw new eM.ErrnoError(8);if(eM.isDir(e.node.mode))throw new eM.ErrnoError(31);if(!e.stream_ops.read)throw new eM.ErrnoError(28);var a=void 0!==o;if(a){if(!e.seekable)throw new eM.ErrnoError(70)}else o=e.position;var i=e.stream_ops.read(e,r,t,n,o);return a||(e.position+=i),i},write(e,r,t,n,o,a){if(n<0||o<0)throw new eM.ErrnoError(28);if(eM.isClosed(e)||(2097155&e.flags)==0)throw new eM.ErrnoError(8);if(eM.isDir(e.node.mode))throw new eM.ErrnoError(31);if(!e.stream_ops.write)throw new eM.ErrnoError(28);e.seekable&&1024&e.flags&&eM.llseek(e,0,2);var i=void 0!==o;if(i){if(!e.seekable)throw new eM.ErrnoError(70)}else o=e.position;var s=e.stream_ops.write(e,r,t,n,o,a);return i||(e.position+=s),s},allocate(e,r,t){if(eM.isClosed(e))throw new eM.ErrnoError(8);if(r<0||t<=0)throw new eM.ErrnoError(28);if((2097155&e.flags)==0)throw new eM.ErrnoError(8);if(!eM.isFile(e.node.mode)&&!eM.isDir(e.node.mode))throw new eM.ErrnoError(43);if(!e.stream_ops.allocate)throw new eM.ErrnoError(138);e.stream_ops.allocate(e,r,t)},mmap(e,r,t,n,o){if((2&n)!=0&&(2&o)==0&&(2097155&e.flags)!=2||(2097155&e.flags)==1)throw new eM.ErrnoError(2);if(!e.stream_ops.mmap)throw new eM.ErrnoError(43);if(!r)throw new eM.ErrnoError(28);return e.stream_ops.mmap(e,r,t,n,o)},msync:(e,r,t,n,o)=>e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,o):0,ioctl(e,r,t){if(!e.stream_ops.ioctl)throw new eM.ErrnoError(59);return e.stream_ops.ioctl(e,r,t)},readFile(e,r={}){if(r.flags=r.flags||0,r.encoding=r.encoding||"binary","utf8"!==r.encoding&&"binary"!==r.encoding)throw Error(`Invalid encoding type "${r.encoding}"`);var t,n=eM.open(e,r.flags),o=eM.stat(e).size,a=new Uint8Array(o);return eM.read(n,a,0,o,0),"utf8"===r.encoding?t=ef(a):"binary"===r.encoding&&(t=a),eM.close(n),t},writeFile(e,r,t={}){t.flags=t.flags||577;var n=eM.open(e,t.flags,t.mode);if("string"==typeof r){var o=new Uint8Array(ep(r)+1),a=em(r,o,0,o.length);eM.write(n,o,0,a,void 0,t.canOwn)}else if(ArrayBuffer.isView(r))eM.write(n,r,0,r.byteLength,void 0,t.canOwn);else throw Error("Unsupported data type");eM.close(n)},cwd:()=>eM.currentPath,chdir(e){var r=eM.lookupPath(e,{follow:!0});if(null===r.node)throw new eM.ErrnoError(44);if(!eM.isDir(r.node.mode))throw new eM.ErrnoError(54);var t=eM.nodePermissions(r.node,"x");if(t)throw new eM.ErrnoError(t);eM.currentPath=r.path},createDefaultDirectories(){eM.mkdir("/tmp"),eM.mkdir("/home"),eM.mkdir("/home/web_user")},createDefaultDevices(){eM.mkdir("/dev"),eM.registerDevice(eM.makedev(1,3),{read:()=>0,write:(e,r,t,n,o)=>n,llseek:()=>0}),eM.mkdev("/dev/null",eM.makedev(1,3)),eg.register(eM.makedev(5,0),eg.default_tty_ops),eg.register(eM.makedev(6,0),eg.default_tty1_ops),eM.mkdev("/dev/tty",eM.makedev(5,0)),eM.mkdev("/dev/tty1",eM.makedev(6,0));var e=new Uint8Array(1024),r=0,t=()=>(0===r&&(r=eu(e).byteLength),e[--r]);eM.createDevice("/dev","random",t),eM.createDevice("/dev","urandom",t),eM.mkdir("/dev/shm"),eM.mkdir("/dev/shm/tmp")},createSpecialDirectories(){eM.mkdir("/proc");var e=eM.mkdir("/proc/self");eM.mkdir("/proc/self/fd"),eM.mount({mount(){var r=eM.createNode(e,"fd",16895,73);return r.stream_ops={llseek:e_.stream_ops.llseek},r.node_ops={lookup(e,r){var t=+r,n=eM.getStreamChecked(t),o={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>n.path},id:t+1};return o.parent=o,o},readdir:()=>Array.from(eM.streams.entries()).filter(([e,r])=>r).map(([e,r])=>e.toString())},r}},{},"/proc/self/fd")},createStandardStreams(e,r,t){e?eM.createDevice("/dev","stdin",e):eM.symlink("/dev/tty","/dev/stdin"),r?eM.createDevice("/dev","stdout",null,r):eM.symlink("/dev/tty","/dev/stdout"),t?eM.createDevice("/dev","stderr",null,t):eM.symlink("/dev/tty1","/dev/stderr"),eM.open("/dev/stdin",0),eM.open("/dev/stdout",1),eM.open("/dev/stderr",1)},staticInit(){eM.nameTable=Array(4096),eM.mount(e_,{},"/"),eM.createDefaultDirectories(),eM.createDefaultDevices(),eM.createSpecialDirectories(),eM.filesystems={MEMFS:e_,WORKERFS:eS}},init(e,t,n){eM.initialized=!0,e??=r.stdin,t??=r.stdout,n??=r.stderr,eM.createStandardStreams(e,t,n)},quit(){eM.initialized=!1;for(var e=0;e<eM.streams.length;e++){var r=eM.streams[e];r&&eM.close(r)}},findObject(e,r){var t=eM.analyzePath(e,r);return t.exists?t.object:null},analyzePath(e,r){try{var t=eM.lookupPath(e,{follow:!r});e=t.path}catch(e){}var n={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var t=eM.lookupPath(e,{parent:!0});n.parentExists=!0,n.parentPath=t.path,n.parentObject=t.node,n.name=es.basename(e),t=eM.lookupPath(e,{follow:!r}),n.exists=!0,n.path=t.path,n.object=t.node,n.name=t.node.name,n.isRoot="/"===t.path}catch(e){n.error=e.errno}return n},createPath(e,r,t,n){e="string"==typeof e?e:eM.getPath(e);for(var o=r.split("/").reverse();o.length;){var a=o.pop();if(a){var i=es.join2(e,a);try{eM.mkdir(i)}catch(e){}e=i}}return i},createFile(e,r,t,n,o){var a=es.join2("string"==typeof e?e:eM.getPath(e),r),i=eF(n,o);return eM.create(a,i)},createDataFile(e,r,t,n,o,a){var i=r;e&&(e="string"==typeof e?e:eM.getPath(e),i=r?es.join2(e,r):e);var s=eF(n,o),l=eM.create(i,s);if(t){if("string"==typeof t){for(var u=Array(t.length),d=0,c=t.length;d<c;++d)u[d]=t.charCodeAt(d);t=u}eM.chmod(l,146|s);var f=eM.open(l,577);eM.write(f,t,0,t.length,0,a),eM.close(f),eM.chmod(l,s)}},createDevice(e,r,t,n){var o=es.join2("string"==typeof e?e:eM.getPath(e),r),a=eF(!!t,!!n);eM.createDevice.major??=64;var i=eM.makedev(eM.createDevice.major++,0);return eM.registerDevice(i,{open(e){e.seekable=!1},close(e){n?.buffer?.length&&n(10)},read(e,r,n,o,a){for(var i,s=0,l=0;l<o;l++){try{i=t()}catch(e){throw new eM.ErrnoError(29)}if(void 0===i&&0===s)throw new eM.ErrnoError(6);if(null==i)break;s++,r[n+l]=i}return s&&(e.node.atime=Date.now()),s},write(e,r,t,o,a){for(var i=0;i<o;i++)try{n(r[t+i])}catch(e){throw new eM.ErrnoError(29)}return o&&(e.node.mtime=e.node.ctime=Date.now()),i}}),eM.mkdev(o,a,i)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if("undefined"!=typeof XMLHttpRequest)throw 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.");try{e.contents=a(e.url),e.usedBytes=e.contents.length}catch(e){throw new eM.ErrnoError(29)}},createLazyFile(e,r,t,n,o){if("undefined"!=typeof XMLHttpRequest){if(!S)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var a={isDevice:!1,contents:new class{lengthKnown=!1;chunks=[];get(e){if(!(e>this.length-1)&&!(e<0)){var r=e%this.chunkSize,t=e/this.chunkSize|0;return this.getter(t)[r]}}setDataGetter(e){this.getter=e}cacheLength(){var e,r=new XMLHttpRequest;if(r.open("HEAD",t,!1),r.send(null),!(r.status>=200&&r.status<300||304===r.status))throw Error("Couldn't load "+t+". Status: "+r.status);var n=Number(r.getResponseHeader("Content-length")),o=(e=r.getResponseHeader("Accept-Ranges"))&&"bytes"===e,a=(e=r.getResponseHeader("Content-Encoding"))&&"gzip"===e,i=1048576;o||(i=n);var s=(e,r)=>{if(e>r)throw Error("invalid range ("+e+", "+r+") or no bytes requested!");if(r>n-1)throw Error("only "+n+" bytes available! programmer error!");var o=new XMLHttpRequest;if(o.open("GET",t,!1),n!==i&&o.setRequestHeader("Range","bytes="+e+"-"+r),o.responseType="arraybuffer",o.overrideMimeType&&o.overrideMimeType("text/plain; charset=x-user-defined"),o.send(null),!(o.status>=200&&o.status<300||304===o.status))throw Error("Couldn't load "+t+". Status: "+o.status);return void 0!==o.response?new Uint8Array(o.response||[]):ev(o.responseText||"",!0)},l=this;l.setDataGetter(e=>{var r=e*i,t=(e+1)*i-1;if(t=Math.min(t,n-1),void 0===l.chunks[e]&&(l.chunks[e]=s(r,t)),void 0===l.chunks[e])throw Error("doXHR failed!");return l.chunks[e]}),(a||!n)&&(i=n=1,i=n=this.getter(0).length,N("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=n,this._chunkSize=i,this.lengthKnown=!0}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}}}else var a={isDevice:!1,url:t};var i=eM.createFile(e,r,a,n,o);a.contents?i.contents=a.contents:a.url&&(i.contents=null,i.url=a.url),Object.defineProperties(i,{usedBytes:{get:function(){return this.contents.length}}});var s={};function u(e,r,t,n,o){var a=e.node.contents;if(o>=a.length)return 0;var i=Math.min(a.length-o,n);if(a.slice)for(var s=0;s<i;s++)r[t+s]=a[o+s];else for(var s=0;s<i;s++)r[t+s]=a.get(o+s);return i}return Object.keys(i.stream_ops).forEach(e=>{var r=i.stream_ops[e];s[e]=(...e)=>(eM.forceLoadFile(i),r(...e))}),s.read=(e,r,t,n,o)=>(eM.forceLoadFile(i),u(e,r,t,n,o)),s.mmap=(e,r,t,n,o)=>{eM.forceLoadFile(i);var a=eb(r);if(!a)throw new eM.ErrnoError(48);return u(e,l,a,r,t),{ptr:a,allocated:!0}},i.stream_ops=s,i}},eA=(e,r)=>e?ef(u,e,r):"",ej={DEFAULT_POLLMASK:5,calculateAt(e,r,t){if(es.isAbs(r))return r;if(-100===e)n=eM.cwd();else{var n;n=ej.getStreamFromFD(e).path}if(0==r.length){if(!t)throw new eM.ErrnoError(44);return n}return n+"/"+r},doStat(e,r,t){var n=e(r);f[t>>2]=n.dev,f[t+4>>2]=n.mode,h[t+8>>2]=n.nlink,f[t+12>>2]=n.uid,f[t+16>>2]=n.gid,f[t+20>>2]=n.rdev,g=[n.size>>>0,+Math.abs(y=n.size)>=1?y>0?Math.floor(y/0x100000000)>>>0:~~Math.ceil((y-(~~y>>>0))/0x100000000)>>>0:0],f[t+24>>2]=g[0],f[t+28>>2]=g[1],f[t+32>>2]=4096,f[t+36>>2]=n.blocks;var o=n.atime.getTime(),a=n.mtime.getTime(),i=n.ctime.getTime();return g=[Math.floor(o/1e3)>>>0,+Math.abs(y=Math.floor(o/1e3))>=1?y>0?Math.floor(y/0x100000000)>>>0:~~Math.ceil((y-(~~y>>>0))/0x100000000)>>>0:0],f[t+40>>2]=g[0],f[t+44>>2]=g[1],h[t+48>>2]=o%1e3*1e6,g=[Math.floor(a/1e3)>>>0,+Math.abs(y=Math.floor(a/1e3))>=1?y>0?Math.floor(y/0x100000000)>>>0:~~Math.ceil((y-(~~y>>>0))/0x100000000)>>>0:0],f[t+56>>2]=g[0],f[t+60>>2]=g[1],h[t+64>>2]=a%1e3*1e6,g=[Math.floor(i/1e3)>>>0,+Math.abs(y=Math.floor(i/1e3))>=1?y>0?Math.floor(y/0x100000000)>>>0:~~Math.ceil((y-(~~y>>>0))/0x100000000)>>>0:0],f[t+72>>2]=g[0],f[t+76>>2]=g[1],h[t+80>>2]=i%1e3*1e6,g=[n.ino>>>0,+Math.abs(y=n.ino)>=1?y>0?Math.floor(y/0x100000000)>>>0:~~Math.ceil((y-(~~y>>>0))/0x100000000)>>>0:0],f[t+88>>2]=g[0],f[t+92>>2]=g[1],0},doMsync(e,r,t,n,o){if(!eM.isFile(r.node.mode))throw new eM.ErrnoError(43);if(2&n)return 0;var a=u.slice(e,e+t);eM.msync(r,a,o,t,n)},getStreamFromFD:e=>eM.getStreamChecked(e),varargs:void 0,getStr:e=>eA(e)},ex=()=>{var e=f[ej.varargs>>2];return ej.varargs+=4,e},eO=(e,r)=>r+2097152>>>0<4194305-!!e?(e>>>0)+0x100000000*r:NaN,eR=(e,r,t)=>em(e,u,r,t),eN=(e,r)=>Object.defineProperty(r,"name",{value:e}),ez=[],eU=[],eW=e=>{throw new w(e)},eL={toValue:e=>(e||eW("Cannot use deleted val. handle = "+e),eU[e]),toHandle:e=>{switch(e){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{let r=ez.pop()||eU.length;return eU[r]=e,eU[r+1]=1,r}}}},eH=(e,r)=>{var t=eN(r,function(e){this.name=r,this.message=e;var t=Error(e).stack;void 0!==t&&(this.stack=this.toString()+"\n"+t.replace(/^Error(:[^\n]*)?\n/,""))});return t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return void 0===this.message?this.name:`${this.name}: ${this.message}`},t},eI=e=>{for(var r="",t=e;u[t];)r+=b[u[t++]];return r},eB={},eV=(e,r)=>{for(void 0===r&&eW("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r},eY=(e,r,t)=>{r=eV(e,r),eB.hasOwnProperty(r)?eW(`Tried to register registered instance: ${r}`):eB[r]=t},eq={},eG=e=>{var r=tF(e),t=eI(r);return tM(r),t},eX=(e,r)=>{var t=eq[e];return void 0===t&&eW(`${r} has unknown type ${eG(e)}`),t},eJ=(e,r)=>{r=eV(e,r),eB.hasOwnProperty(r)?delete eB[r]:eW(`Tried to unregister unregistered instance: ${r}`)},eK=e=>{},eZ=!1,eQ=e=>{e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)},e0=e=>{e.count.value-=1,0===e.count.value&&eQ(e)},e1=(e,r,t)=>{if(r===t)return e;if(void 0===t.baseClass)return null;var n=e1(e,r,t.baseClass);return null===n?null:t.downcast(n)},e2={},e4=(e,r)=>eB[r=eV(e,r)],e3=e=>{throw new _(e)},e5=(e,r)=>(r.ptrType&&r.ptr||e3("makeClassHandle requires ptr and ptrType"),!!r.smartPtrType!=!!r.smartPtr&&e3("Both smartPtrType and smartPtr must be specified"),r.count={value:1},e6(Object.create(e,{$$:{value:r,writable:!0}}))),e6=e=>"undefined"==typeof FinalizationRegistry?(e6=e=>e,e):(eZ=new FinalizationRegistry(e=>{e0(e.$$)}),e6=e=>{var r=e.$$;return r.smartPtr&&eZ.register(e,{$$:r},e),e},eK=e=>eZ.unregister(e),e6(e)),e8={},e9=e=>{for(;e.length;){var r=e.pop();e.pop()(r)}};function e7(e){return this.fromWireType(h[e>>2])}var re={},rr={},rt=(e,r,t)=>{function n(r){var n=t(r);n.length!==e.length&&e3("Mismatched type converter count");for(var o=0;o<e.length;++o)rn(e[o],n[o])}e.forEach(e=>rr[e]=r);var o=Array(r.length),a=[],i=0;r.forEach((e,r)=>{eq.hasOwnProperty(e)?o[r]=eq[e]:(a.push(e),re.hasOwnProperty(e)||(re[e]=[]),re[e].push(()=>{o[r]=eq[e],++i===a.length&&n(o)}))}),0===a.length&&n(o)};function rn(e,r,t={}){return function(e,r,t={}){var n=r.name;if(e||eW(`type "${n}" must have a positive integer typeid pointer`),eq.hasOwnProperty(e))if(t.ignoreDuplicateRegistrations)return;else eW(`Cannot register type '${n}' twice`);if(eq[e]=r,delete rr[e],re.hasOwnProperty(e)){var o=re[e];delete re[e],o.forEach(e=>e())}}(e,r,t)}var ro=e=>({count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}),ra=e=>{eW(e.$$.ptrType.registeredClass.name+" instance already deleted")},ri=[],rs=()=>{for(;ri.length;){var e=ri.pop();e.$$.deleteScheduled=!1,e.delete()}};function rl(){}var ru=(e,r,t)=>{if(void 0===e[r].overloadTable){var n=e[r];e[r]=function(...n){return e[r].overloadTable.hasOwnProperty(n.length)||eW(`Function '${t}' called with an invalid number of arguments (${n.length}) - expects one of (${e[r].overloadTable})!`),e[r].overloadTable[n.length].apply(this,n)},e[r].overloadTable=[],e[r].overloadTable[n.argCount]=n}},rd=(e,t,n)=>{r.hasOwnProperty(e)?((void 0===n||void 0!==r[e].overloadTable&&void 0!==r[e].overloadTable[n])&&eW(`Cannot register public name '${e}' twice`),ru(r,e,e),r[e].overloadTable.hasOwnProperty(n)&&eW(`Cannot register multiple overloads of a function with the same number of arguments (${n})!`),r[e].overloadTable[n]=t):(r[e]=t,r[e].argCount=n)},rc=e=>{var r=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return r>=48&&r<=57?`_${e}`:e};function rf(e,r,t,n,o,a,i,s){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=o,this.getActualType=a,this.upcast=i,this.downcast=s,this.pureVirtualFunctions=[]}var rh=(e,r,t)=>{for(;r!==t;)r.upcast||eW(`Expected null or instance of ${t.name}, got an instance of ${r.name}`),e=r.upcast(e),r=r.baseClass;return e};function rp(e,r){if(null===r)return this.isReference&&eW(`null is not a valid ${this.name}`),0;r.$$||eW(`Cannot pass "${rj(r)}" as a ${this.name}`),r.$$.ptr||eW(`Cannot pass deleted object as a pointer of type ${this.name}`);var t=r.$$.ptrType.registeredClass;return rh(r.$$.ptr,t,this.registeredClass)}function rm(e,r){if(null===r)return(this.isReference&&eW(`null is not a valid ${this.name}`),this.isSmartPointer)?(t=this.rawConstructor(),null!==e&&e.push(this.rawDestructor,t),t):0;r&&r.$$||eW(`Cannot pass "${rj(r)}" as a ${this.name}`),r.$$.ptr||eW(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&r.$$.ptrType.isConst&&eW(`Cannot convert argument of type ${r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name} to parameter type ${this.name}`);var t,n=r.$$.ptrType.registeredClass;if(t=rh(r.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(void 0===r.$$.smartPtr&&eW("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:eW(`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 o=r.clone();t=this.rawShare(t,eL.toHandle(()=>o.delete())),null!==e&&e.push(this.rawDestructor,t)}break;default:eW("Unsupporting sharing policy")}return t}function rv(e,r){if(null===r)return this.isReference&&eW(`null is not a valid ${this.name}`),0;r.$$||eW(`Cannot pass "${rj(r)}" as a ${this.name}`),r.$$.ptr||eW(`Cannot pass deleted object as a pointer of type ${this.name}`),r.$$.ptrType.isConst&&eW(`Cannot convert argument of type ${r.$$.ptrType.name} to parameter type ${this.name}`);var t=r.$$.ptrType.registeredClass;return rh(r.$$.ptr,t,this.registeredClass)}function ry(e,r,t,n,o,a,i,s,l,u,d){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=o,this.pointeeType=a,this.sharingPolicy=i,this.rawGetPointee=s,this.rawConstructor=l,this.rawShare=u,this.rawDestructor=d,o||void 0!==r.baseClass?this.toWireType=rm:(n?this.toWireType=rp:this.toWireType=rv,this.destructorFunction=null)}var rg=(e,t,n)=>{r.hasOwnProperty(e)||e3("Replacing nonexistent public symbol"),void 0!==r[e].overloadTable&&void 0!==n?r[e].overloadTable[n]=t:(r[e]=t,r[e].argCount=n)},rw=(e,t,n)=>(0,r["dynCall_"+(e=e.replace(/p/g,"i"))])(t,...n),rE=e=>$.get(e),rb=(e,r,t=[])=>e.includes("j")?rw(e,r,t):rE(r)(...t),r_=(e,r)=>(...t)=>rb(e,r,t),rk=(e,r)=>{var t=(e=eI(e)).includes("j")?r_(e,r):rE(r);return"function"!=typeof t&&eW(`unknown function pointer with signature ${e}: ${r}`),t},r$=(e,r)=>{var t=[],n={};throw r.forEach(function e(r){if(!n[r]&&!eq[r]){if(rr[r])return void rr[r].forEach(e);t.push(r),n[r]=!0}}),new C(`${e}: `+t.map(eG).join([", "]))};function rC(e){for(var r=1;r<e.length;++r)if(null!==e[r]&&void 0===e[r].destructorFunction)return!0;return!1}function rP(e,r){if(!(e instanceof Function))throw TypeError(`new_ called with constructor type ${typeof e} which is not a function`);var t=eN(e.name||"unknownFunctionName",function(){});t.prototype=e.prototype;var n=new t,o=e.apply(n,r);return o instanceof Object?o:n}function rT(e,r,t,n,o,a){var i=r.length;i<2&&eW("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var s=null!==r[1]&&null!==t,l=rC(r),u="void"!==r[0].name,d=[e,eW,n,o,e9,r[0],r[1]],c=0;c<i-2;++c)d.push(r[c+2]);if(!l)for(var c=s?1:2;c<r.length;++c)null!==r[c].destructorFunction&&d.push(r[c].destructorFunction);let[f,h]=function(e,r,t,n){var o=rC(e),a=e.length-2,i=[],s=["fn"];r&&s.push("thisWired");for(var l=0;l<a;++l)i.push(`arg${l}`),s.push(`arg${l}Wired`);i=i.join(","),s=s.join(",");var u=`return function (${i}) { `;o&&(u+="var destructors = [];\n");var d=o?"destructors":"null",c=["humanName","throwBindingError","invoker","fn","runDestructors","retType","classParam"];r&&(u+=`var thisWired = classParam['toWireType'](${d}, this); `);for(var l=0;l<a;++l)u+=`var arg${l}Wired = argType${l}['toWireType'](${d}, arg${l}); `,c.push(`argType${l}`);if(u+=(t||n?"var rv = ":"")+`invoker(${s}); `,o)u+="runDestructors(destructors);\n";else for(var l=r?1:2;l<e.length;++l){var f=1===l?"thisWired":"arg"+(l-2)+"Wired";null!==e[l].destructorFunction&&(u+=`${f}_dtor(${f}); `,c.push(`${f}_dtor`))}return t&&(u+="var ret = retType['fromWireType'](rv);\nreturn ret;\n"),[c,u+="}\n"]}(r,s,u,a);return f.push(h),eN(e,rP(Function,f)(...d))}var rD=(e,r)=>{for(var t=[],n=0;n<e;n++)t.push(h[r+4*n>>2]);return t},rF=e=>{let r=(e=e.trim()).indexOf("(");return -1!==r?e.substr(0,r):e},rS=(e,r,t)=>(e instanceof Object||eW(`${t} with invalid "this": ${e}`),e instanceof r.registeredClass.constructor||eW(`${t} incompatible with "this" of type ${e.constructor.name}`),e.$$.ptr||eW(`cannot call emscripten binding method ${t} on deleted object`),rh(e.$$.ptr,e.$$.ptrType.registeredClass,r.registeredClass)),rM=e=>{e>9&&0==--eU[e+1]&&(eU[e]=void 0,ez.push(e))},rA={name:"emscripten::val",fromWireType:e=>{var r=eL.toValue(e);return rM(e),r},toWireType:(e,r)=>eL.toHandle(r),argPackAdvance:8,readValueFromPointer:e7,destructorFunction:null},rj=e=>{if(null===e)return"null";var r=typeof e;return"object"===r||"array"===r||"function"===r?e.toString():""+e},rx=(e,r)=>{switch(r){case 4:return function(e){return this.fromWireType(p[e>>2])};case 8:return function(e){return this.fromWireType(m[e>>3])};default:throw TypeError(`invalid float width (${r}): ${e}`)}},rO=(e,r,t)=>{switch(r){case 1:return t?e=>l[e]:e=>u[e];case 2:return t?e=>d[e>>1]:e=>c[e>>1];case 4:return t?e=>f[e>>2]:e=>h[e>>2];default:throw TypeError(`invalid integer width (${r}): ${e}`)}},rR=Object.assign({optional:!0},rA),rN="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,rz=(e,r)=>{for(var t=e,n=t>>1,o=n+r/2;!(n>=o)&&c[n];)++n;if((t=n<<1)-e>32&&rN)return rN.decode(u.subarray(e,t));for(var a="",i=0;!(i>=r/2);++i){var s=d[e+2*i>>1];if(0==s)break;a+=String.fromCharCode(s)}return a},rU=(e,r,t)=>{if((t??=0x7fffffff)<2)return 0;for(var n=r,o=(t-=2)<2*e.length?t/2:e.length,a=0;a<o;++a){var i=e.charCodeAt(a);d[r>>1]=i,r+=2}return d[r>>1]=0,r-n},rW=e=>2*e.length,rL=(e,r)=>{for(var t=0,n="";!(t>=r/4);){var o=f[e+4*t>>2];if(0==o)break;if(++t,o>=65536){var a=o-65536;n+=String.fromCharCode(55296|a>>10,56320|1023&a)}else n+=String.fromCharCode(o)}return n},rH=(e,r,t)=>{if((t??=0x7fffffff)<4)return 0;for(var n=r,o=n+t-4,a=0;a<e.length;++a){var i=e.charCodeAt(a);if(i>=55296&&i<=57343&&(i=65536+((1023&i)<<10)|1023&e.charCodeAt(++a)),f[r>>2]=i,(r+=4)+4>o)break}return f[r>>2]=0,r-n},rI=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n>=55296&&n<=57343&&++t,r+=4}return r},rB=0,rV=(e,r,t)=>{var n=[],o=e.toWireType(n,t);return n.length&&(h[r>>2]=eL.toHandle(n)),o},rY=[],rq={},rG=e=>{var r=rq[e];return void 0===r?eI(e):r},rX=()=>"object"==typeof globalThis?globalThis:Function("return this")(),rJ=e=>{var r=rY.length;return rY.push(e),r},rK=(e,r)=>{for(var t=Array(e),n=0;n<e;++n)t[n]=eX(h[r+4*n>>2],"parameter "+n);return t},rZ=e=>e%4==0&&(e