UNPKG

jq-web-wasm

Version:

a hack that makes jq run in the browser with emscripten.

4 lines 64 kB
var Se=function(R){R=R||{};var c=typeof R<"u"?R:{},be=!1,Ke=[],Ae="",Z=[],Te=[],Fe=[];function Mr(e){for(var r=[],n=unescape(encodeURIComponent(e)),o=0;o<n.length;o++)r.push(n.charCodeAt(o));return r}function Ze(e){for(var r=new Uint8Array(e),n="",o=0;o<r.length;++o)n+=String.fromCharCode(r[o]);return decodeURIComponent(escape(n))}c=Object.assign({noInitialRun:!0,noExitRuntime:!0,onRuntimeInitialized:function(){be=!0,Ke.forEach(function(e){e()})},preRun:function(){t.init(function(){return Z.length?Z.pop():Ae?(Z=Mr(Ae),Ae="",Z.push(null),Z.reverse(),Z.pop()):null},function(r){r&&Te.push(r)},function(r){r&&Fe.push(r)})}},c);var ae={},Y;for(Y in c)c.hasOwnProperty(Y)&&(ae[Y]=c[Y]);var se=[],Me="./this.program",ue=function(e,r){throw r},fe=!1,W=!1,ce=!1,$e=!1,Qe=!1;fe=typeof window=="object",W=typeof importScripts=="function",$e=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",ce=$e&&!fe&&!W,Qe=!fe&&!ce&&!W;var B="";function Rr(e){return c.locateFile?c.locateFile(e,B):B+e}var te,Or,le,Nr;if(ce){B=__dirname+"/";var Re,Ce;te=function(r,n){var o;return Re||(Re=require("fs")),Ce||(Ce=require("path")),r=Ce.normalize(r),o=Re.readFileSync(r),n?o:o.toString()},le=function(r){var n=te(r,!0);return n.buffer||(n=new Uint8Array(n)),Oe(n.buffer),n},process.argv.length>1&&(Me=process.argv[1].replace(/\\/g,"/")),se=process.argv.slice(2),process.on("uncaughtException",function(e){if(!(e instanceof Xe))throw e}),process.on("unhandledRejection",F),ue=function(e){process.exit(e)},c.inspect=function(){return"[Emscripten Module object]"}}else Qe?(typeof read<"u"&&(te=function(r){return read(r)}),le=function(r){var n;return typeof readbuffer=="function"?new Uint8Array(readbuffer(r)):(n=read(r,"binary"),Oe(typeof n=="object"),n)},typeof scriptArgs<"u"?se=scriptArgs:typeof arguments<"u"&&(se=arguments),typeof quit=="function"&&(ue=function(e){quit(e)}),typeof print<"u"&&(typeof console>"u"&&(console={}),console.log=print,console.warn=console.error=typeof printErr<"u"?printErr:print)):(fe||W)&&(W?B=self.location.href:document.currentScript&&(B=document.currentScript.src),B.indexOf("blob:")!==0?B=B.substr(0,B.lastIndexOf("/")+1):B="",te=function(r){var n=new XMLHttpRequest;return n.open("GET",r,!1),n.send(null),n.responseText},W&&(le=function(r){var n=new XMLHttpRequest;return n.open("GET",r,!1),n.responseType="arraybuffer",n.send(null),new Uint8Array(n.response)}),Or=function(r,n,o){var i=new XMLHttpRequest;i.open("GET",r,!0),i.responseType="arraybuffer",i.onload=function(){if(i.status==200||i.status==0&&i.response){n(i.response);return}o()},i.onerror=o,i.send(null)},Nr=function(e){document.title=e});var Le=c.print||console.log.bind(console),C=c.printErr||console.warn.bind(console);for(Y in ae)ae.hasOwnProperty(Y)&&(c[Y]=ae[Y]);ae=null,c.arguments&&(se=c.arguments),c.thisProgram&&(Me=c.thisProgram),c.quit&&(ue=c.quit);function Pr(e){var r=l[We>>2],n=r+e+15&-16;return n>wr()&&F(),l[We>>2]=n,r}function xr(e){switch(e){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:{if(e[e.length-1]==="*")return 4;if(e[0]==="i"){var r=parseInt(e.substr(1));return Oe(r%8===0,"getNativeTypeSize invalid bits "+r+", type "+e),r/8}else return 0}}}var de;c.wasmBinary&&(de=c.wasmBinary);var ve;c.noExitRuntime&&(ve=c.noExitRuntime),typeof WebAssembly!="object"&&C("no native wasm support detected");function zr(e,r,n,o){switch(n=n||"i8",n.charAt(n.length-1)==="*"&&(n="i32"),n){case"i1":O[e>>0]=r;break;case"i8":O[e>>0]=r;break;case"i16":Ye[e>>1]=r;break;case"i32":l[e>>2]=r;break;case"i64":P=[r>>>0,(T=r,+ze(T)>=1?T>0?(Be(+ge(T/4294967296),4294967295)|0)>>>0:~~+he((T-+(~~T>>>0))/4294967296)>>>0:0)],l[e>>2]=P[0],l[e+4>>2]=P[1];break;case"float":sr[e>>2]=r;break;case"double":ur[e>>3]=r;break;default:F("invalid type for setValue: "+n)}}var $,Br=new WebAssembly.Table({initial:177,maximum:177+0,element:"anyfunc"}),He=!1,er=0;function Oe(e,r){e||F("Assertion failed: "+r)}var rr=0,Ir=3;function nr(e,r,n,o){var i,a;typeof e=="number"?(i=!0,a=e):(i=!1,a=e.length);var s=typeof r=="string"?r:null,u;if(n==Ir?u=o:u=[kr,Ve,Pr][n](Math.max(a,s?1:r.length)),i){var d;for(o=u,Oe((u&3)==0),d=u+(a&-4);o<d;o+=4)l[o>>2]=0;for(d=u+a;o<d;)O[o++>>0]=0;return u}if(s==="i8")return e.subarray||e.slice?G.set(e,u):G.set(new Uint8Array(e),u),u;for(var v=0,g,w,h;v<a;){var p=e[v];if(g=s||r[v],g===0){v++;continue}g=="i64"&&(g="i32"),zr(u+v,p,g),h!==g&&(w=xr(g),h=g),v+=w}return u}var tr=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function oe(e,r,n){for(var o=r+n,i=r;e[i]&&!(i>=o);)++i;if(i-r>16&&e.subarray&&tr)return tr.decode(e.subarray(r,i));for(var a="";r<i;){var s=e[r++];if(!(s&128)){a+=String.fromCharCode(s);continue}var u=e[r++]&63;if((s&224)==192){a+=String.fromCharCode((s&31)<<6|u);continue}var d=e[r++]&63;if((s&240)==224?s=(s&15)<<12|u<<6|d:s=(s&7)<<18|u<<12|d<<6|e[r++]&63,s<65536)a+=String.fromCharCode(s);else{var v=s-65536;a+=String.fromCharCode(55296|v>>10,56320|v&1023)}}return a}function j(e,r){return e?oe(G,e,r):""}function Ne(e,r,n,o){if(!(o>0))return 0;for(var i=n,a=n+o-1,s=0;s<e.length;++s){var u=e.charCodeAt(s);if(u>=55296&&u<=57343){var d=e.charCodeAt(++s);u=65536+((u&1023)<<10)|d&1023}if(u<=127){if(n>=a)break;r[n++]=u}else if(u<=2047){if(n+1>=a)break;r[n++]=192|u>>6,r[n++]=128|u&63}else if(u<=65535){if(n+2>=a)break;r[n++]=224|u>>12,r[n++]=128|u>>6&63,r[n++]=128|u&63}else{if(n+3>=a)break;r[n++]=240|u>>18,r[n++]=128|u>>12&63,r[n++]=128|u>>6&63,r[n++]=128|u&63}}return r[n]=0,n-i}function or(e,r,n){return Ne(e,G,r,n)}function Pe(e){for(var r=0,n=0;n<e.length;++n){var o=e.charCodeAt(n);o>=55296&&o<=57343&&(o=65536+((o&1023)<<10)|e.charCodeAt(++n)&1023),o<=127?++r:o<=2047?r+=2:o<=65535?r+=3:r+=4}return r}var Vn=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0;function ir(e){var r=Pe(e)+1,n=Ve(r);return Ne(e,O,n,r),n}function Ur(e,r){O.set(e,r)}function Cr(e,r,n){for(var o=0;o<e.length;++o)O[r++>>0]=e.charCodeAt(o);n||(O[r>>0]=0)}var Lr=65536;function ar(e,r){return e%r>0&&(e+=r-e%r),e}var me,O,G,Ye,Hr,l,Yr,sr,ur;function fr(e){me=e,c.HEAP8=O=new Int8Array(e),c.HEAP16=Ye=new Int16Array(e),c.HEAP32=l=new Int32Array(e),c.HEAPU8=G=new Uint8Array(e),c.HEAPU16=Hr=new Uint16Array(e),c.HEAPU32=Yr=new Uint32Array(e),c.HEAPF32=sr=new Float32Array(e),c.HEAPF64=ur=new Float64Array(e)}var Wr=5575456,We=332416,cr=c.TOTAL_MEMORY||16777216;c.wasmMemory?$=c.wasmMemory:$=new WebAssembly.Memory({initial:cr/Lr}),$&&(me=$.buffer),cr=me.byteLength,fr(me),l[We>>2]=Wr;function xe(e){for(;e.length>0;){var r=e.shift();if(typeof r=="function"){r();continue}var n=r.func;typeof n=="number"?r.arg===void 0?c.dynCall_v(n):c.dynCall_vi(n,r.arg):n(r.arg===void 0?null:r.arg)}}var lr=[],dr=[],jr=[],vr=[],Gr=!1,Vr=!1;function Xr(){if(c.preRun)for(typeof c.preRun=="function"&&(c.preRun=[c.preRun]);c.preRun.length;)$r(c.preRun.shift());xe(lr)}function qr(){Gr=!0,!c.noFSInit&&!t.init.initialized&&t.init(),X.init(),xe(dr)}function Jr(){t.ignorePermissions=!1,xe(jr)}function Kr(){Vr=!0}function Zr(){if(c.postRun)for(typeof c.postRun=="function"&&(c.postRun=[c.postRun]);c.postRun.length;)Qr(c.postRun.shift());xe(vr)}function $r(e){lr.unshift(e)}function Qr(e){vr.unshift(e)}var ze=Math.abs,he=Math.ceil,ge=Math.floor,Be=Math.min,Q=0,je=null,pe=null;function Xn(e){return e}function mr(e){Q++,c.monitorRunDependencies&&c.monitorRunDependencies(Q)}function Ge(e){if(Q--,c.monitorRunDependencies&&c.monitorRunDependencies(Q),Q==0&&(je!==null&&(clearInterval(je),je=null),pe)){var r=pe;pe=null,r()}}c.preloadedImages={},c.preloadedAudios={};function F(e){throw c.onAbort&&c.onAbort(e),e+="",Le(e),C(e),He=!0,er=1,e="abort("+e+"). Build with -s ASSERTIONS=1 for more info.",new WebAssembly.RuntimeError(e)}var hr="data:application/octet-stream;base64,";function gr(e){return String.prototype.startsWith?e.startsWith(hr):e.indexOf(hr)===0}var V="jq.wasm.wasm";gr(V)||(V=Rr(V));function pr(){try{if(de)return new Uint8Array(de);if(le)return le(V);throw"both async and sync fetching of the wasm failed"}catch(e){F(e)}}function en(){return!de&&(fe||W)&&typeof global!="object"&&typeof fetch=="function"?fetch(V,{credentials:"same-origin"}).then(function(e){if(!e.ok)throw"failed to load wasm binary file at '"+V+"'";return e.arrayBuffer()}).catch(function(){return pr()}):new Promise(function(e,r){e(pr())})}function rn(){var e={env:_r,wasi_unstable:_r};function r(s,u){var d=s.exports;c.asm=d,Ge("wasm-instantiate")}mr("wasm-instantiate");function n(s){r(s.instance)}function o(s){return en().then(function(u){return WebAssembly.instantiate(u,e)}).then(s,function(u){C("failed to asynchronously prepare wasm: "+u),F(u)})}function i(){if(!de&&typeof WebAssembly.instantiateStreaming=="function"&&!gr(V)&&typeof global!="object"&&typeof fetch=="function")fetch(V,{credentials:"same-origin"}).then(function(s){var u=WebAssembly.instantiateStreaming(s,e);return u.then(n,function(d){C("wasm streaming compile failed: "+d),C("falling back to ArrayBuffer instantiation"),o(n)})});else return o(n)}if(c.instantiateWasm)try{var a=c.instantiateWasm(e,r);return a}catch(s){return C("Module.instantiateWasm callback failed with error: "+s),!1}return i(),{}}var T,P;dr.push({func:function(){Ln()}});function qn(e){return e}function nn(e){var r=/\b_Z[\w\d_]+/g;return e.replace(r,function(n){var o=n;return n===o?n:o+" ["+n+"]"})}function tn(){var e=new Error;if(!e.stack){try{throw new Error(0)}catch(r){e=r}if(!e.stack)return"(no stack trace available)"}return e.stack.toString()}function on(){var e=tn();return c.extraStackTrace&&(e+=` `+c.extraStackTrace()),nn(e)}function an(e,r,n,o){F("Assertion failed: "+j(e)+", at: "+[r?j(r):"unknown filename",n,o?j(o):"unknown function"])}function sn(){}var S={splitPath:function(e){var r=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return r.exec(e).slice(1)},normalizeArray:function(e,r){for(var n=0,o=e.length-1;o>=0;o--){var i=e[o];i==="."?e.splice(o,1):i===".."?(e.splice(o,1),n++):n&&(e.splice(o,1),n--)}if(r)for(;n;n--)e.unshift("..");return e},normalize:function(e){var r=e.charAt(0)==="/",n=e.substr(-1)==="/";return e=S.normalizeArray(e.split("/").filter(function(o){return!!o}),!r).join("/"),!e&&!r&&(e="."),e&&n&&(e+="/"),(r?"/":"")+e},dirname:function(e){var r=S.splitPath(e),n=r[0],o=r[1];return!n&&!o?".":(o&&(o=o.substr(0,o.length-1)),n+o)},basename:function(e){if(e==="/")return"/";var r=e.lastIndexOf("/");return r===-1?e:e.substr(r+1)},extname:function(e){return S.splitPath(e)[3]},join:function(){var e=Array.prototype.slice.call(arguments,0);return S.normalize(e.join("/"))},join2:function(e,r){return S.normalize(e+"/"+r)}};function we(e){return c.___errno_location&&(l[c.___errno_location()>>2]=e),e}var I={resolve:function(){for(var e="",r=!1,n=arguments.length-1;n>=-1&&!r;n--){var o=n>=0?arguments[n]:t.cwd();if(typeof o!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!o)return"";e=o+"/"+e,r=o.charAt(0)==="/"}return e=S.normalizeArray(e.split("/").filter(function(i){return!!i}),!r).join("/"),(r?"/":"")+e||"."},relative:function(e,r){e=I.resolve(e).substr(1),r=I.resolve(r).substr(1);function n(v){for(var g=0;g<v.length&&v[g]==="";g++);for(var w=v.length-1;w>=0&&v[w]==="";w--);return g>w?[]:v.slice(g,w-g+1)}for(var o=n(e.split("/")),i=n(r.split("/")),a=Math.min(o.length,i.length),s=a,u=0;u<a;u++)if(o[u]!==i[u]){s=u;break}for(var d=[],u=s;u<o.length;u++)d.push("..");return d=d.concat(i.slice(s)),d.join("/")}},X={ttys:[],init:function(){},shutdown:function(){},register:function(e,r){X.ttys[e]={input:[],output:[],ops:r},t.registerDevice(e,X.stream_ops)},stream_ops:{open:function(e){var r=X.ttys[e.node.rdev];if(!r)throw new t.ErrnoError(43);e.tty=r,e.seekable=!1},close:function(e){e.tty.ops.flush(e.tty)},flush:function(e){e.tty.ops.flush(e.tty)},read:function(e,r,n,o,i){if(!e.tty||!e.tty.ops.get_char)throw new t.ErrnoError(60);for(var a=0,s=0;s<o;s++){var u;try{u=e.tty.ops.get_char(e.tty)}catch{throw new t.ErrnoError(29)}if(u===void 0&&a===0)throw new t.ErrnoError(6);if(u==null)break;a++,r[n+s]=u}return a&&(e.node.timestamp=Date.now()),a},write:function(e,r,n,o,i){if(!e.tty||!e.tty.ops.put_char)throw new t.ErrnoError(60);try{for(var a=0;a<o;a++)e.tty.ops.put_char(e.tty,r[n+a])}catch{throw new t.ErrnoError(29)}return o&&(e.node.timestamp=Date.now()),a}},default_tty_ops:{get_char:function(e){if(!e.input.length){var r=null;if(ce){var n=256,o=Buffer.alloc?Buffer.alloc(n):new Buffer(n),i=0;try{i=Re.readSync(process.stdin.fd,o,0,n,null)}catch(a){if(a.toString().indexOf("EOF")!=-1)i=0;else throw a}i>0?r=o.slice(0,i).toString("utf-8"):r=null}else typeof window<"u"&&typeof window.prompt=="function"?(r=window.prompt("Input: "),r!==null&&(r+=` `)):typeof readline=="function"&&(r=readline(),r!==null&&(r+=` `));if(!r)return null;e.input=ne(r,!0)}return e.input.shift()},put_char:function(e,r){r===null||r===10?(Le(oe(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},flush:function(e){e.output&&e.output.length>0&&(Le(oe(e.output,0)),e.output=[])}},default_tty1_ops:{put_char:function(e,r){r===null||r===10?(C(oe(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},flush:function(e){e.output&&e.output.length>0&&(C(oe(e.output,0)),e.output=[])}}},_={ops_table:null,mount:function(e){return _.createNode(null,"/",16895,0)},createNode:function(e,r,n,o){if(t.isBlkdev(n)||t.isFIFO(n))throw new t.ErrnoError(63);_.ops_table||(_.ops_table={dir:{node:{getattr:_.node_ops.getattr,setattr:_.node_ops.setattr,lookup:_.node_ops.lookup,mknod:_.node_ops.mknod,rename:_.node_ops.rename,unlink:_.node_ops.unlink,rmdir:_.node_ops.rmdir,readdir:_.node_ops.readdir,symlink:_.node_ops.symlink},stream:{llseek:_.stream_ops.llseek}},file:{node:{getattr:_.node_ops.getattr,setattr:_.node_ops.setattr},stream:{llseek:_.stream_ops.llseek,read:_.stream_ops.read,write:_.stream_ops.write,allocate:_.stream_ops.allocate,mmap:_.stream_ops.mmap,msync:_.stream_ops.msync}},link:{node:{getattr:_.node_ops.getattr,setattr:_.node_ops.setattr,readlink:_.node_ops.readlink},stream:{}},chrdev:{node:{getattr:_.node_ops.getattr,setattr:_.node_ops.setattr},stream:t.chrdev_stream_ops}});var i=t.createNode(e,r,n,o);return t.isDir(i.mode)?(i.node_ops=_.ops_table.dir.node,i.stream_ops=_.ops_table.dir.stream,i.contents={}):t.isFile(i.mode)?(i.node_ops=_.ops_table.file.node,i.stream_ops=_.ops_table.file.stream,i.usedBytes=0,i.contents=null):t.isLink(i.mode)?(i.node_ops=_.ops_table.link.node,i.stream_ops=_.ops_table.link.stream):t.isChrdev(i.mode)&&(i.node_ops=_.ops_table.chrdev.node,i.stream_ops=_.ops_table.chrdev.stream),i.timestamp=Date.now(),e&&(e.contents[r]=i),i},getFileDataAsRegularArray:function(e){if(e.contents&&e.contents.subarray){for(var r=[],n=0;n<e.usedBytes;++n)r.push(e.contents[n]);return r}return e.contents},getFileDataAsTypedArray:function(e){return e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array},expandFileStorage:function(e,r){var n=e.contents?e.contents.length:0;if(!(n>=r)){var o=1024*1024;r=Math.max(r,n*(n<o?2:1.125)|0),n!=0&&(r=Math.max(r,256));var i=e.contents;e.contents=new Uint8Array(r),e.usedBytes>0&&e.contents.set(i.subarray(0,e.usedBytes),0)}},resizeFileStorage:function(e,r){if(e.usedBytes!=r){if(r==0){e.contents=null,e.usedBytes=0;return}if(!e.contents||e.contents.subarray){var n=e.contents;e.contents=new Uint8Array(new ArrayBuffer(r)),n&&e.contents.set(n.subarray(0,Math.min(r,e.usedBytes))),e.usedBytes=r;return}if(e.contents||(e.contents=[]),e.contents.length>r)e.contents.length=r;else for(;e.contents.length<r;)e.contents.push(0);e.usedBytes=r}},node_ops:{getattr:function(e){var r={};return r.dev=t.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,t.isDir(e.mode)?r.size=4096:t.isFile(e.mode)?r.size=e.usedBytes:t.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:function(e,r){r.mode!==void 0&&(e.mode=r.mode),r.timestamp!==void 0&&(e.timestamp=r.timestamp),r.size!==void 0&&_.resizeFileStorage(e,r.size)},lookup:function(e,r){throw t.genericErrors[44]},mknod:function(e,r,n,o){return _.createNode(e,r,n,o)},rename:function(e,r,n){if(t.isDir(e.mode)){var o;try{o=t.lookupNode(r,n)}catch{}if(o)for(var i in o.contents)throw new t.ErrnoError(55)}delete e.parent.contents[e.name],e.name=n,r.contents[n]=e,e.parent=r},unlink:function(e,r){delete e.contents[r]},rmdir:function(e,r){var n=t.lookupNode(e,r);for(var o in n.contents)throw new t.ErrnoError(55);delete e.contents[r]},readdir:function(e){var r=[".",".."];for(var n in e.contents)e.contents.hasOwnProperty(n)&&r.push(n);return r},symlink:function(e,r,n){var o=_.createNode(e,r,41471,0);return o.link=n,o},readlink:function(e){if(!t.isLink(e.mode))throw new t.ErrnoError(28);return e.link}},stream_ops:{read:function(e,r,n,o,i){var a=e.node.contents;if(i>=e.node.usedBytes)return 0;var s=Math.min(e.node.usedBytes-i,o);if(s>8&&a.subarray)r.set(a.subarray(i,i+s),n);else for(var u=0;u<s;u++)r[n+u]=a[i+u];return s},write:function(e,r,n,o,i,a){if(a=!1,!o)return 0;var s=e.node;if(s.timestamp=Date.now(),r.subarray&&(!s.contents||s.contents.subarray)){if(a)return s.contents=r.subarray(n,n+o),s.usedBytes=o,o;if(s.usedBytes===0&&i===0)return s.contents=new Uint8Array(r.subarray(n,n+o)),s.usedBytes=o,o;if(i+o<=s.usedBytes)return s.contents.set(r.subarray(n,n+o),i),o}if(_.expandFileStorage(s,i+o),s.contents.subarray&&r.subarray)s.contents.set(r.subarray(n,n+o),i);else for(var u=0;u<o;u++)s.contents[i+u]=r[n+u];return s.usedBytes=Math.max(s.usedBytes,i+o),o},llseek:function(e,r,n){var o=r;if(n===1?o+=e.position:n===2&&t.isFile(e.node.mode)&&(o+=e.node.usedBytes),o<0)throw new t.ErrnoError(28);return o},allocate:function(e,r,n){_.expandFileStorage(e.node,r+n),e.node.usedBytes=Math.max(e.node.usedBytes,r+n)},mmap:function(e,r,n,o,i,a,s){if(!t.isFile(e.node.mode))throw new t.ErrnoError(43);var u,d,v=e.node.contents;if(!(s&2)&&(v.buffer===r||v.buffer===r.buffer))d=!1,u=v.byteOffset;else{(i>0||i+o<e.node.usedBytes)&&(v.subarray?v=v.subarray(i,i+o):v=Array.prototype.slice.call(v,i,i+o)),d=!0;var g=r.buffer==O.buffer;if(u=kr(o),!u)throw new t.ErrnoError(48);(g?O:r).set(v,u)}return{ptr:u,allocated:d}},msync:function(e,r,n,o,i){if(!t.isFile(e.node.mode))throw new t.ErrnoError(43);if(i&2)return 0;var a=_.stream_ops.write(e,r,0,o,n,!1);return 0}}},t={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,trackingDelegate:{},tracking:{openFlags:{READ:1,WRITE:2}},ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,handleFSError:function(e){if(!(e instanceof t.ErrnoError))throw e+" : "+on();return we(e.errno)},lookupPath:function(e,r){if(e=I.resolve(t.cwd(),e),r=r||{},!e)return{path:"",node:null};var n={follow_mount:!0,recurse_count:0};for(var o in n)r[o]===void 0&&(r[o]=n[o]);if(r.recurse_count>8)throw new t.ErrnoError(32);for(var i=S.normalizeArray(e.split("/").filter(function(h){return!!h}),!1),a=t.root,s="/",u=0;u<i.length;u++){var d=u===i.length-1;if(d&&r.parent)break;if(a=t.lookupNode(a,i[u]),s=S.join2(s,i[u]),t.isMountpoint(a)&&(!d||d&&r.follow_mount)&&(a=a.mounted.root),!d||r.follow)for(var v=0;t.isLink(a.mode);){var g=t.readlink(s);s=I.resolve(S.dirname(s),g);var w=t.lookupPath(s,{recurse_count:r.recurse_count});if(a=w.node,v++>40)throw new t.ErrnoError(32)}}return{path:s,node:a}},getPath:function(e){for(var r;;){if(t.isRoot(e)){var n=e.mount.mountpoint;return r?n[n.length-1]!=="/"?n+"/"+r:n+r:n}r=r?e.name+"/"+r:e.name,e=e.parent}},hashName:function(e,r){for(var n=0,o=0;o<r.length;o++)n=(n<<5)-n+r.charCodeAt(o)|0;return(e+n>>>0)%t.nameTable.length},hashAddNode:function(e){var r=t.hashName(e.parent.id,e.name);e.name_next=t.nameTable[r],t.nameTable[r]=e},hashRemoveNode:function(e){var r=t.hashName(e.parent.id,e.name);if(t.nameTable[r]===e)t.nameTable[r]=e.name_next;else for(var n=t.nameTable[r];n;){if(n.name_next===e){n.name_next=e.name_next;break}n=n.name_next}},lookupNode:function(e,r){var n=t.mayLookup(e);if(n)throw new t.ErrnoError(n,e);for(var o=t.hashName(e.id,r),i=t.nameTable[o];i;i=i.name_next){var a=i.name;if(i.parent.id===e.id&&a===r)return i}return t.lookup(e,r)},createNode:function(e,r,n,o){if(!t.FSNode){t.FSNode=function(u,d,v,g){u||(u=this),this.parent=u,this.mount=u.mount,this.mounted=null,this.id=t.nextInode++,this.name=d,this.mode=v,this.node_ops={},this.stream_ops={},this.rdev=g},t.FSNode.prototype={};var i=365,a=146;Object.defineProperties(t.FSNode.prototype,{read:{get:function(){return(this.mode&i)===i},set:function(u){u?this.mode|=i:this.mode&=~i}},write:{get:function(){return(this.mode&a)===a},set:function(u){u?this.mode|=a:this.mode&=~a}},isFolder:{get:function(){return t.isDir(this.mode)}},isDevice:{get:function(){return t.isChrdev(this.mode)}}})}var s=new t.FSNode(e,r,n,o);return t.hashAddNode(s),s},destroyNode:function(e){t.hashRemoveNode(e)},isRoot:function(e){return e===e.parent},isMountpoint:function(e){return!!e.mounted},isFile:function(e){return(e&61440)===32768},isDir:function(e){return(e&61440)===16384},isLink:function(e){return(e&61440)===40960},isChrdev:function(e){return(e&61440)===8192},isBlkdev:function(e){return(e&61440)===24576},isFIFO:function(e){return(e&61440)===4096},isSocket:function(e){return(e&49152)===49152},flagModes:{r:0,rs:1052672,"r+":2,w:577,wx:705,xw:705,"w+":578,"wx+":706,"xw+":706,a:1089,ax:1217,xa:1217,"a+":1090,"ax+":1218,"xa+":1218},modeStringToFlags:function(e){var r=t.flagModes[e];if(typeof r>"u")throw new Error("Unknown file open mode: "+e);return r},flagsToPermissionString:function(e){var r=["r","w","rw"][e&3];return e&512&&(r+="w"),r},nodePermissions:function(e,r){return t.ignorePermissions?0:r.indexOf("r")!==-1&&!(e.mode&292)||r.indexOf("w")!==-1&&!(e.mode&146)||r.indexOf("x")!==-1&&!(e.mode&73)?2:0},mayLookup:function(e){var r=t.nodePermissions(e,"x");return r||(e.node_ops.lookup?0:2)},mayCreate:function(e,r){try{var n=t.lookupNode(e,r);return 20}catch{}return t.nodePermissions(e,"wx")},mayDelete:function(e,r,n){var o;try{o=t.lookupNode(e,r)}catch(a){return a.errno}var i=t.nodePermissions(e,"wx");if(i)return i;if(n){if(!t.isDir(o.mode))return 54;if(t.isRoot(o)||t.getPath(o)===t.cwd())return 10}else if(t.isDir(o.mode))return 31;return 0},mayOpen:function(e,r){return e?t.isLink(e.mode)?32:t.isDir(e.mode)&&(t.flagsToPermissionString(r)!=="r"||r&512)?31:t.nodePermissions(e,t.flagsToPermissionString(r)):44},MAX_OPEN_FDS:4096,nextfd:function(e,r){e=e||0,r=r||t.MAX_OPEN_FDS;for(var n=e;n<=r;n++)if(!t.streams[n])return n;throw new t.ErrnoError(33)},getStream:function(e){return t.streams[e]},createStream:function(e,r,n){t.FSStream||(t.FSStream=function(){},t.FSStream.prototype={},Object.defineProperties(t.FSStream.prototype,{object:{get:function(){return this.node},set:function(s){this.node=s}},isRead:{get:function(){return(this.flags&2097155)!==1}},isWrite:{get:function(){return(this.flags&2097155)!==0}},isAppend:{get:function(){return this.flags&1024}}}));var o=new t.FSStream;for(var i in e)o[i]=e[i];e=o;var a=t.nextfd(r,n);return e.fd=a,t.streams[a]=e,e},closeStream:function(e){t.streams[e]=null},chrdev_stream_ops:{open:function(e){var r=t.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:function(){throw new t.ErrnoError(70)}},major:function(e){return e>>8},minor:function(e){return e&255},makedev:function(e,r){return e<<8|r},registerDevice:function(e,r){t.devices[e]={stream_ops:r}},getDevice:function(e){return t.devices[e]},getMounts:function(e){for(var r=[],n=[e];n.length;){var o=n.pop();r.push(o),n.push.apply(n,o.mounts)}return r},syncfs:function(e,r){typeof e=="function"&&(r=e,e=!1),t.syncFSRequests++,t.syncFSRequests>1&&console.log("warning: "+t.syncFSRequests+" FS.syncfs operations in flight at once, probably just doing extra work");var n=t.getMounts(t.root.mount),o=0;function i(s){return t.syncFSRequests--,r(s)}function a(s){if(s)return a.errored?void 0:(a.errored=!0,i(s));++o>=n.length&&i(null)}n.forEach(function(s){if(!s.type.syncfs)return a(null);s.type.syncfs(s,e,a)})},mount:function(e,r,n){var o=n==="/",i=!n,a;if(o&&t.root)throw new t.ErrnoError(10);if(!o&&!i){var s=t.lookupPath(n,{follow_mount:!1});if(n=s.path,a=s.node,t.isMountpoint(a))throw new t.ErrnoError(10);if(!t.isDir(a.mode))throw new t.ErrnoError(54)}var u={type:e,opts:r,mountpoint:n,mounts:[]},d=e.mount(u);return d.mount=u,u.root=d,o?t.root=d:a&&(a.mounted=u,a.mount&&a.mount.mounts.push(u)),d},unmount:function(e){var r=t.lookupPath(e,{follow_mount:!1});if(!t.isMountpoint(r.node))throw new t.ErrnoError(28);var n=r.node,o=n.mounted,i=t.getMounts(o);Object.keys(t.nameTable).forEach(function(s){for(var u=t.nameTable[s];u;){var d=u.name_next;i.indexOf(u.mount)!==-1&&t.destroyNode(u),u=d}}),n.mounted=null;var a=n.mount.mounts.indexOf(o);n.mount.mounts.splice(a,1)},lookup:function(e,r){return e.node_ops.lookup(e,r)},mknod:function(e,r,n){var o=t.lookupPath(e,{parent:!0}),i=o.node,a=S.basename(e);if(!a||a==="."||a==="..")throw new t.ErrnoError(28);var s=t.mayCreate(i,a);if(s)throw new t.ErrnoError(s);if(!i.node_ops.mknod)throw new t.ErrnoError(63);return i.node_ops.mknod(i,a,r,n)},create:function(e,r){return r=r!==void 0?r:438,r&=4095,r|=32768,t.mknod(e,r,0)},mkdir:function(e,r){return r=r!==void 0?r:511,r&=1023,r|=16384,t.mknod(e,r,0)},mkdirTree:function(e,r){for(var n=e.split("/"),o="",i=0;i<n.length;++i)if(n[i]){o+="/"+n[i];try{t.mkdir(o,r)}catch(a){if(a.errno!=20)throw a}}},mkdev:function(e,r,n){return typeof n>"u"&&(n=r,r=438),r|=8192,t.mknod(e,r,n)},symlink:function(e,r){if(!I.resolve(e))throw new t.ErrnoError(44);var n=t.lookupPath(r,{parent:!0}),o=n.node;if(!o)throw new t.ErrnoError(44);var i=S.basename(r),a=t.mayCreate(o,i);if(a)throw new t.ErrnoError(a);if(!o.node_ops.symlink)throw new t.ErrnoError(63);return o.node_ops.symlink(o,i,e)},rename:function(e,r){var n=S.dirname(e),o=S.dirname(r),i=S.basename(e),a=S.basename(r),s,u,d;try{s=t.lookupPath(e,{parent:!0}),u=s.node,s=t.lookupPath(r,{parent:!0}),d=s.node}catch{throw new t.ErrnoError(10)}if(!u||!d)throw new t.ErrnoError(44);if(u.mount!==d.mount)throw new t.ErrnoError(75);var v=t.lookupNode(u,i),g=I.relative(e,o);if(g.charAt(0)!==".")throw new t.ErrnoError(28);if(g=I.relative(r,n),g.charAt(0)!==".")throw new t.ErrnoError(55);var w;try{w=t.lookupNode(d,a)}catch{}if(v!==w){var h=t.isDir(v.mode),p=t.mayDelete(u,i,h);if(p)throw new t.ErrnoError(p);if(p=w?t.mayDelete(d,a,h):t.mayCreate(d,a),p)throw new t.ErrnoError(p);if(!u.node_ops.rename)throw new t.ErrnoError(63);if(t.isMountpoint(v)||w&&t.isMountpoint(w))throw new t.ErrnoError(10);if(d!==u&&(p=t.nodePermissions(u,"w"),p))throw new t.ErrnoError(p);try{t.trackingDelegate.willMovePath&&t.trackingDelegate.willMovePath(e,r)}catch(E){console.log("FS.trackingDelegate['willMovePath']('"+e+"', '"+r+"') threw an exception: "+E.message)}t.hashRemoveNode(v);try{u.node_ops.rename(v,d,a)}catch(E){throw E}finally{t.hashAddNode(v)}try{t.trackingDelegate.onMovePath&&t.trackingDelegate.onMovePath(e,r)}catch(E){console.log("FS.trackingDelegate['onMovePath']('"+e+"', '"+r+"') threw an exception: "+E.message)}}},rmdir:function(e){var r=t.lookupPath(e,{parent:!0}),n=r.node,o=S.basename(e),i=t.lookupNode(n,o),a=t.mayDelete(n,o,!0);if(a)throw new t.ErrnoError(a);if(!n.node_ops.rmdir)throw new t.ErrnoError(63);if(t.isMountpoint(i))throw new t.ErrnoError(10);try{t.trackingDelegate.willDeletePath&&t.trackingDelegate.willDeletePath(e)}catch(s){console.log("FS.trackingDelegate['willDeletePath']('"+e+"') threw an exception: "+s.message)}n.node_ops.rmdir(n,o),t.destroyNode(i);try{t.trackingDelegate.onDeletePath&&t.trackingDelegate.onDeletePath(e)}catch(s){console.log("FS.trackingDelegate['onDeletePath']('"+e+"') threw an exception: "+s.message)}},readdir:function(e){var r=t.lookupPath(e,{follow:!0}),n=r.node;if(!n.node_ops.readdir)throw new t.ErrnoError(54);return n.node_ops.readdir(n)},unlink:function(e){var r=t.lookupPath(e,{parent:!0}),n=r.node,o=S.basename(e),i=t.lookupNode(n,o),a=t.mayDelete(n,o,!1);if(a)throw new t.ErrnoError(a);if(!n.node_ops.unlink)throw new t.ErrnoError(63);if(t.isMountpoint(i))throw new t.ErrnoError(10);try{t.trackingDelegate.willDeletePath&&t.trackingDelegate.willDeletePath(e)}catch(s){console.log("FS.trackingDelegate['willDeletePath']('"+e+"') threw an exception: "+s.message)}n.node_ops.unlink(n,o),t.destroyNode(i);try{t.trackingDelegate.onDeletePath&&t.trackingDelegate.onDeletePath(e)}catch(s){console.log("FS.trackingDelegate['onDeletePath']('"+e+"') threw an exception: "+s.message)}},readlink:function(e){var r=t.lookupPath(e),n=r.node;if(!n)throw new t.ErrnoError(44);if(!n.node_ops.readlink)throw new t.ErrnoError(28);return I.resolve(t.getPath(n.parent),n.node_ops.readlink(n))},stat:function(e,r){var n=t.lookupPath(e,{follow:!r}),o=n.node;if(!o)throw new t.ErrnoError(44);if(!o.node_ops.getattr)throw new t.ErrnoError(63);return o.node_ops.getattr(o)},lstat:function(e){return t.stat(e,!0)},chmod:function(e,r,n){var o;if(typeof e=="string"){var i=t.lookupPath(e,{follow:!n});o=i.node}else o=e;if(!o.node_ops.setattr)throw new t.ErrnoError(63);o.node_ops.setattr(o,{mode:r&4095|o.mode&-4096,timestamp:Date.now()})},lchmod:function(e,r){t.chmod(e,r,!0)},fchmod:function(e,r){var n=t.getStream(e);if(!n)throw new t.ErrnoError(8);t.chmod(n.node,r)},chown:function(e,r,n,o){var i;if(typeof e=="string"){var a=t.lookupPath(e,{follow:!o});i=a.node}else i=e;if(!i.node_ops.setattr)throw new t.ErrnoError(63);i.node_ops.setattr(i,{timestamp:Date.now()})},lchown:function(e,r,n){t.chown(e,r,n,!0)},fchown:function(e,r,n){var o=t.getStream(e);if(!o)throw new t.ErrnoError(8);t.chown(o.node,r,n)},truncate:function(e,r){if(r<0)throw new t.ErrnoError(28);var n;if(typeof e=="string"){var o=t.lookupPath(e,{follow:!0});n=o.node}else n=e;if(!n.node_ops.setattr)throw new t.ErrnoError(63);if(t.isDir(n.mode))throw new t.ErrnoError(31);if(!t.isFile(n.mode))throw new t.ErrnoError(28);var i=t.nodePermissions(n,"w");if(i)throw new t.ErrnoError(i);n.node_ops.setattr(n,{size:r,timestamp:Date.now()})},ftruncate:function(e,r){var n=t.getStream(e);if(!n)throw new t.ErrnoError(8);if(!(n.flags&2097155))throw new t.ErrnoError(28);t.truncate(n.node,r)},utime:function(e,r,n){var o=t.lookupPath(e,{follow:!0}),i=o.node;i.node_ops.setattr(i,{timestamp:Math.max(r,n)})},open:function(e,r,n,o,i){if(e==="")throw new t.ErrnoError(44);r=typeof r=="string"?t.modeStringToFlags(r):r,n=typeof n>"u"?438:n,r&64?n=n&4095|32768:n=0;var a;if(typeof e=="object")a=e;else{e=S.normalize(e);try{var s=t.lookupPath(e,{follow:!(r&131072)});a=s.node}catch{}}var u=!1;if(r&64)if(a){if(r&128)throw new t.ErrnoError(20)}else a=t.mknod(e,n,0),u=!0;if(!a)throw new t.ErrnoError(44);if(t.isChrdev(a.mode)&&(r&=-513),r&65536&&!t.isDir(a.mode))throw new t.ErrnoError(54);if(!u){var d=t.mayOpen(a,r);if(d)throw new t.ErrnoError(d)}r&512&&t.truncate(a,0),r&=-641;var v=t.createStream({node:a,path:t.getPath(a),flags:r,seekable:!0,position:0,stream_ops:a.stream_ops,ungotten:[],error:!1},o,i);v.stream_ops.open&&v.stream_ops.open(v),c.logReadFiles&&!(r&1)&&(t.readFiles||(t.readFiles={}),e in t.readFiles||(t.readFiles[e]=1,console.log("FS.trackingDelegate error on read file: "+e)));try{if(t.trackingDelegate.onOpenFile){var g=0;(r&2097155)!==1&&(g|=t.tracking.openFlags.READ),r&2097155&&(g|=t.tracking.openFlags.WRITE),t.trackingDelegate.onOpenFile(e,g)}}catch(w){console.log("FS.trackingDelegate['onOpenFile']('"+e+"', flags) threw an exception: "+w.message)}return v},close:function(e){if(t.isClosed(e))throw new t.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(r){throw r}finally{t.closeStream(e.fd)}e.fd=null},isClosed:function(e){return e.fd===null},llseek:function(e,r,n){if(t.isClosed(e))throw new t.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new t.ErrnoError(70);if(n!=0&&n!=1&&n!=2)throw new t.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,n),e.ungotten=[],e.position},read:function(e,r,n,o,i){if(o<0||i<0)throw new t.ErrnoError(28);if(t.isClosed(e))throw new t.ErrnoError(8);if((e.flags&2097155)===1)throw new t.ErrnoError(8);if(t.isDir(e.node.mode))throw new t.ErrnoError(31);if(!e.stream_ops.read)throw new t.ErrnoError(28);var a=typeof i<"u";if(!a)i=e.position;else if(!e.seekable)throw new t.ErrnoError(70);var s=e.stream_ops.read(e,r,n,o,i);return a||(e.position+=s),s},write:function(e,r,n,o,i,a){if(o<0||i<0)throw new t.ErrnoError(28);if(t.isClosed(e))throw new t.ErrnoError(8);if(!(e.flags&2097155))throw new t.ErrnoError(8);if(t.isDir(e.node.mode))throw new t.ErrnoError(31);if(!e.stream_ops.write)throw new t.ErrnoError(28);e.flags&1024&&t.llseek(e,0,2);var s=typeof i<"u";if(!s)i=e.position;else if(!e.seekable)throw new t.ErrnoError(70);var u=e.stream_ops.write(e,r,n,o,i,a);s||(e.position+=u);try{e.path&&t.trackingDelegate.onWriteToFile&&t.trackingDelegate.onWriteToFile(e.path)}catch(d){console.log("FS.trackingDelegate['onWriteToFile']('"+e.path+"') threw an exception: "+d.message)}return u},allocate:function(e,r,n){if(t.isClosed(e))throw new t.ErrnoError(8);if(r<0||n<=0)throw new t.ErrnoError(28);if(!(e.flags&2097155))throw new t.ErrnoError(8);if(!t.isFile(e.node.mode)&&!t.isDir(e.node.mode))throw new t.ErrnoError(43);if(!e.stream_ops.allocate)throw new t.ErrnoError(138);e.stream_ops.allocate(e,r,n)},mmap:function(e,r,n,o,i,a,s){if(a&2&&!(s&2)&&(e.flags&2097155)!==2)throw new t.ErrnoError(2);if((e.flags&2097155)===1)throw new t.ErrnoError(2);if(!e.stream_ops.mmap)throw new t.ErrnoError(43);return e.stream_ops.mmap(e,r,n,o,i,a,s)},msync:function(e,r,n,o,i){return!e||!e.stream_ops.msync?0:e.stream_ops.msync(e,r,n,o,i)},munmap:function(e){return 0},ioctl:function(e,r,n){if(!e.stream_ops.ioctl)throw new t.ErrnoError(59);return e.stream_ops.ioctl(e,r,n)},readFile:function(e,r){if(r=r||{},r.flags=r.flags||"r",r.encoding=r.encoding||"binary",r.encoding!=="utf8"&&r.encoding!=="binary")throw new Error('Invalid encoding type "'+r.encoding+'"');var n,o=t.open(e,r.flags),i=t.stat(e),a=i.size,s=new Uint8Array(a);return t.read(o,s,0,a,0),r.encoding==="utf8"?n=oe(s,0):r.encoding==="binary"&&(n=s),t.close(o),n},writeFile:function(e,r,n){n=n||{},n.flags=n.flags||"w";var o=t.open(e,n.flags,n.mode);if(typeof r=="string"){var i=new Uint8Array(Pe(r)+1),a=Ne(r,i,0,i.length);t.write(o,i,0,a,void 0,n.canOwn)}else if(ArrayBuffer.isView(r))t.write(o,r,0,r.byteLength,void 0,n.canOwn);else throw new Error("Unsupported data type");t.close(o)},cwd:function(){return t.currentPath},chdir:function(e){var r=t.lookupPath(e,{follow:!0});if(r.node===null)throw new t.ErrnoError(44);if(!t.isDir(r.node.mode))throw new t.ErrnoError(54);var n=t.nodePermissions(r.node,"x");if(n)throw new t.ErrnoError(n);t.currentPath=r.path},createDefaultDirectories:function(){t.mkdir("/tmp"),t.mkdir("/home"),t.mkdir("/home/web_user")},createDefaultDevices:function(){t.mkdir("/dev"),t.registerDevice(t.makedev(1,3),{read:function(){return 0},write:function(o,i,a,s,u){return s}}),t.mkdev("/dev/null",t.makedev(1,3)),X.register(t.makedev(5,0),X.default_tty_ops),X.register(t.makedev(6,0),X.default_tty1_ops),t.mkdev("/dev/tty",t.makedev(5,0)),t.mkdev("/dev/tty1",t.makedev(6,0));var e;if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var r=new Uint8Array(1);e=function(){return crypto.getRandomValues(r),r[0]}}else if(ce)try{var n=require("crypto");e=function(){return n.randomBytes(1)[0]}}catch{}e||(e=function(){F("random_device")}),t.createDevice("/dev","random",e),t.createDevice("/dev","urandom",e),t.mkdir("/dev/shm"),t.mkdir("/dev/shm/tmp")},createSpecialDirectories:function(){t.mkdir("/proc"),t.mkdir("/proc/self"),t.mkdir("/proc/self/fd"),t.mount({mount:function(){var e=t.createNode("/proc/self","fd",16895,73);return e.node_ops={lookup:function(r,n){var o=+n,i=t.getStream(o);if(!i)throw new t.ErrnoError(8);var a={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:function(){return i.path}}};return a.parent=a,a}},e}},{},"/proc/self/fd")},createStandardStreams:function(){c.stdin?t.createDevice("/dev","stdin",c.stdin):t.symlink("/dev/tty","/dev/stdin"),c.stdout?t.createDevice("/dev","stdout",null,c.stdout):t.symlink("/dev/tty","/dev/stdout"),c.stderr?t.createDevice("/dev","stderr",null,c.stderr):t.symlink("/dev/tty1","/dev/stderr");var e=t.open("/dev/stdin","r"),r=t.open("/dev/stdout","w"),n=t.open("/dev/stderr","w")},ensureErrnoError:function(){t.ErrnoError||(t.ErrnoError=function(r,n){this.node=n,this.setErrno=function(o){this.errno=o},this.setErrno(r),this.message="FS error"},t.ErrnoError.prototype=new Error,t.ErrnoError.prototype.constructor=t.ErrnoError,[44].forEach(function(e){t.genericErrors[e]=new t.ErrnoError(e),t.genericErrors[e].stack="<generic error, no stack>"}))},staticInit:function(){t.ensureErrnoError(),t.nameTable=new Array(4096),t.mount(_,{},"/"),t.createDefaultDirectories(),t.createDefaultDevices(),t.createSpecialDirectories(),t.filesystems={MEMFS:_}},init:function(e,r,n){t.init.initialized=!0,t.ensureErrnoError(),c.stdin=e||c.stdin,c.stdout=r||c.stdout,c.stderr=n||c.stderr,t.createStandardStreams()},quit:function(){t.init.initialized=!1;var e=c._fflush;e&&e(0);for(var r=0;r<t.streams.length;r++){var n=t.streams[r];n&&t.close(n)}},getMode:function(e,r){var n=0;return e&&(n|=365),r&&(n|=146),n},joinPath:function(e,r){var n=S.join.apply(null,e);return r&&n[0]=="/"&&(n=n.substr(1)),n},absolutePath:function(e,r){return I.resolve(r,e)},standardizePath:function(e){return S.normalize(e)},findObject:function(e,r){var n=t.analyzePath(e,r);return n.exists?n.object:(we(n.error),null)},analyzePath:function(e,r){try{var n=t.lookupPath(e,{follow:!r});e=n.path}catch{}var o={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var n=t.lookupPath(e,{parent:!0});o.parentExists=!0,o.parentPath=n.path,o.parentObject=n.node,o.name=S.basename(e),n=t.lookupPath(e,{follow:!r}),o.exists=!0,o.path=n.path,o.object=n.node,o.name=n.node.name,o.isRoot=n.path==="/"}catch(i){o.error=i.errno}return o},createFolder:function(e,r,n,o){var i=S.join2(typeof e=="string"?e:t.getPath(e),r),a=t.getMode(n,o);return t.mkdir(i,a)},createPath:function(e,r,n,o){e=typeof e=="string"?e:t.getPath(e);for(var i=r.split("/").reverse();i.length;){var a=i.pop();if(a){var s=S.join2(e,a);try{t.mkdir(s)}catch{}e=s}}return s},createFile:function(e,r,n,o,i){var a=S.join2(typeof e=="string"?e:t.getPath(e),r),s=t.getMode(o,i);return t.create(a,s)},createDataFile:function(e,r,n,o,i,a){var s=r?S.join2(typeof e=="string"?e:t.getPath(e),r):e,u=t.getMode(o,i),d=t.create(s,u);if(n){if(typeof n=="string"){for(var v=new Array(n.length),g=0,w=n.length;g<w;++g)v[g]=n.charCodeAt(g);n=v}t.chmod(d,u|146);var h=t.open(d,"w");t.write(h,n,0,n.length,0,a),t.close(h),t.chmod(d,u)}return d},createDevice:function(e,r,n,o){var i=S.join2(typeof e=="string"?e:t.getPath(e),r),a=t.getMode(!!n,!!o);t.createDevice.major||(t.createDevice.major=64);var s=t.makedev(t.createDevice.major++,0);return t.registerDevice(s,{open:function(u){u.seekable=!1},close:function(u){o&&o.buffer&&o.buffer.length&&o(10)},read:function(u,d,v,g,w){for(var h=0,p=0;p<g;p++){var E;try{E=n()}catch{throw new t.ErrnoError(29)}if(E===void 0&&h===0)throw new t.ErrnoError(6);if(E==null)break;h++,d[v+p]=E}return h&&(u.node.timestamp=Date.now()),h},write:function(u,d,v,g,w){for(var h=0;h<g;h++)try{o(d[v+h])}catch{throw new t.ErrnoError(29)}return g&&(u.node.timestamp=Date.now()),h}}),t.mkdev(i,a,s)},createLink:function(e,r,n,o,i){var a=S.join2(typeof e=="string"?e:t.getPath(e),r);return t.symlink(n,a)},forceLoadFile:function(e){if(e.isDevice||e.isFolder||e.link||e.contents)return!0;var r=!0;if(typeof XMLHttpRequest<"u")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=ne(te(e.url),!0),e.usedBytes=e.contents.length}catch{r=!1}else throw new Error("Cannot load without read() or XMLHttpRequest.");return r||we(29),r},createLazyFile:function(e,r,n,o,i){function a(){this.lengthKnown=!1,this.chunks=[]}if(a.prototype.get=function(h){if(!(h>this.length-1||h<0)){var p=h%this.chunkSize,E=h/this.chunkSize|0;return this.getter(E)[p]}},a.prototype.setDataGetter=function(h){this.getter=h},a.prototype.cacheLength=function(){var h=new XMLHttpRequest;if(h.open("HEAD",n,!1),h.send(null),!(h.status>=200&&h.status<300||h.status===304))throw new Error("Couldn't load "+n+". Status: "+h.status);var p=Number(h.getResponseHeader("Content-length")),E,M=(E=h.getResponseHeader("Accept-Ranges"))&&E==="bytes",N=(E=h.getResponseHeader("Content-Encoding"))&&E==="gzip",k=1024*1024;M||(k=p);var f=function(b,D){if(b>D)throw new Error("invalid range ("+b+", "+D+") or no bytes requested!");if(D>p-1)throw new Error("only "+p+" bytes available! programmer error!");var A=new XMLHttpRequest;if(A.open("GET",n,!1),p!==k&&A.setRequestHeader("Range","bytes="+b+"-"+D),typeof Uint8Array<"u"&&(A.responseType="arraybuffer"),A.overrideMimeType&&A.overrideMimeType("text/plain; charset=x-user-defined"),A.send(null),!(A.status>=200&&A.status<300||A.status===304))throw new Error("Couldn't load "+n+". Status: "+A.status);return A.response!==void 0?new Uint8Array(A.response||[]):ne(A.responseText||"",!0)},m=this;m.setDataGetter(function(b){var D=b*k,A=(b+1)*k-1;if(A=Math.min(A,p-1),typeof m.chunks[b]>"u"&&(m.chunks[b]=f(D,A)),typeof m.chunks[b]>"u")throw new Error("doXHR failed!");return m.chunks[b]}),(N||!p)&&(k=p=1,p=this.getter(0).length,k=p,console.log("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=p,this._chunkSize=k,this.lengthKnown=!0},typeof XMLHttpRequest<"u"){if(!W)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var s=new a;Object.defineProperties(s,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var u={isDevice:!1,contents:s}}else var u={isDevice:!1,url:n};var d=t.createFile(e,r,u,o,i);u.contents?d.contents=u.contents:u.url&&(d.contents=null,d.url=u.url),Object.defineProperties(d,{usedBytes:{get:function(){return this.contents.length}}});var v={},g=Object.keys(d.stream_ops);return g.forEach(function(w){var h=d.stream_ops[w];v[w]=function(){if(!t.forceLoadFile(d))throw new t.ErrnoError(29);return h.apply(null,arguments)}}),v.read=function(h,p,E,M,N){if(!t.forceLoadFile(d))throw new t.ErrnoError(29);var k=h.node.contents;if(N>=k.length)return 0;var f=Math.min(k.length-N,M);if(k.slice)for(var m=0;m<f;m++)p[E+m]=k[N+m];else for(var m=0;m<f;m++)p[E+m]=k.get(N+m);return f},d.stream_ops=v,d},createPreloadedFile:function(e,r,n,o,i,a,s,u,d,v){Browser.init();var g=r?I.resolve(S.join2(e,r)):e,w="cp "+g;function h(p){function E(N){v&&v(),u||t.createDataFile(e,r,N,o,i,d),a&&a(),Ge(w)}var M=!1;c.preloadPlugins.forEach(function(N){M||N.canHandle(g)&&(N.handle(p,g,E,function(){s&&s(),Ge(w)}),M=!0)}),M||E(p)}mr(w),typeof n=="string"?Browser.asyncLoad(n,function(p){h(p)},s):h(n)},indexedDB:function(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},DB_NAME:function(){return"EM_FS_"+window.location.pathname},DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:function(e,r,n){r=r||function(){},n=n||function(){};var o=t.indexedDB();try{var i=o.open(t.DB_NAME(),t.DB_VERSION)}catch(a){return n(a)}i.onupgradeneeded=function(){console.log("creating db");var s=i.result;s.createObjectStore(t.DB_STORE_NAME)},i.onsuccess=function(){var s=i.result,u=s.transaction([t.DB_STORE_NAME],"readwrite"),d=u.objectStore(t.DB_STORE_NAME),v=0,g=0,w=e.length;function h(){g==0?r():n()}e.forEach(function(p){var E=d.put(t.analyzePath(p).object.contents,p);E.onsuccess=function(){v++,v+g==w&&h()},E.onerror=function(){g++,v+g==w&&h()}}),u.onerror=n},i.onerror=n},loadFilesFromDB:function(e,r,n){r=r||function(){},n=n||function(){};var o=t.indexedDB();try{var i=o.open(t.DB_NAME(),t.DB_VERSION)}catch(a){return n(a)}i.onupgradeneeded=n,i.onsuccess=function(){var s=i.result;try{var u=s.transaction([t.DB_STORE_NAME],"readonly")}catch(p){n(p);return}var d=u.objectStore(t.DB_STORE_NAME),v=0,g=0,w=e.length;function h(){g==0?r():n()}e.forEach(function(p){var E=d.get(p);E.onsuccess=function(){t.analyzePath(p).exists&&t.unlink(p),t.createDataFile(S.dirname(p),S.basename(p),E.result,!0,!0,!0),v++,v+g==w&&h()},E.onerror=function(){g++,v+g==w&&h()}}),u.onerror=n},i.onerror=n}},y={DEFAULT_POLLMASK:5,mappings:{},umask:511,calculateAt:function(e,r){if(r[0]!=="/"){var n;if(e===-100)n=t.cwd();else{var o=t.getStream(e);if(!o)throw new t.ErrnoError(8);n=o.path}r=S.join2(n,r)}return r},doStat:function(e,r,n){try{var o=e(r)}catch(i){if(i&&i.node&&S.normalize(r)!==S.normalize(t.getPath(i.node)))return-54;throw i}return l[n>>2]=o.dev,l[n+4>>2]=0,l[n+8>>2]=o.ino,l[n+12>>2]=o.mode,l[n+16>>2]=o.nlink,l[n+20>>2]=o.uid,l[n+24>>2]=o.gid,l[n+28>>2]=o.rdev,l[n+32>>2]=0,P=[o.size>>>0,(T=o.size,+ze(T)>=1?T>0?(Be(+ge(T/4294967296),4294967295)|0)>>>0:~~+he((T-+(~~T>>>0))/4294967296)>>>0:0)],l[n+40>>2]=P[0],l[n+44>>2]=P[1],l[n+48>>2]=4096,l[n+52>>2]=o.blocks,l[n+56>>2]=o.atime.getTime()/1e3|0,l[n+60>>2]=0,l[n+64>>2]=o.mtime.getTime()/1e3|0,l[n+68>>2]=0,l[n+72>>2]=o.ctime.getTime()/1e3|0,l[n+76>>2]=0,P=[o.ino>>>0,(T=o.ino,+ze(T)>=1?T>0?(Be(+ge(T/4294967296),4294967295)|0)>>>0:~~+he((T-+(~~T>>>0))/4294967296)>>>0:0)],l[n+80>>2]=P[0],l[n+84>>2]=P[1],0},doMsync:function(e,r,n,o){var i=new Uint8Array(G.subarray(e,e+n));t.msync(r,i,0,n,o)},doMkdir:function(e,r){return e=S.normalize(e),e[e.length-1]==="/"&&(e=e.substr(0,e.length-1)),t.mkdir(e,r,0),0},doMknod:function(e,r,n){switch(r&61440){case 32768:case 8192:case 24576:case 4096:case 49152:break;default:return-28}return t.mknod(e,r,n),0},doReadlink:function(e,r,n){if(n<=0)return-28;var o=t.readlink(e),i=Math.min(n,Pe(o)),a=O[r+i];return or(o,r,n+1),O[r+i]=a,i},doAccess:function(e,r){if(r&-8)return-28;var n,o=t.lookupPath(e,{follow:!0});if(n=o.node,!n)return-44;var i="";return r&4&&(i+="r"),r&2&&(i+="w"),r&1&&(i+="x"),i&&t.nodePermissions(n,i)?-2:0},doDup:function(e,r,n){var o=t.getStream(n);return o&&t.close(o),t.open(e,r,0,n,n).fd},doReadv:function(e,r,n,o){for(var i=0,a=0;a<n;a++){var s=l[r+a*8>>2],u=l[r+(a*8+4)>>2],d=t.read(e,O,s,u,o);if(d<0)return-1;if(i+=d,d<u)break}return i},doWritev:function(e,r,n,o){for(var i=0,a=0;a<n;a++){var s=l[r+a*8>>2],u=l[r+(a*8+4)>>2],d=t.write(e,O,s,u,o);if(d<0)return-1;i+=d}return i},varargs:0,get:function(e){y.varargs+=4;var r=l[y.varargs-4>>2];return r},getStr:function(){var e=j(y.get());return e},getStreamFromFD:function(e){e===void 0&&(e=y.get());var r=t.getStream(e);if(!r)throw new t.ErrnoError(8);return r},get64:function(){var e=y.get(),r=y.get();return e},getZero:function(){y.get()}};function un(e,r){y.varargs=r;try{var n=y.getStr(),o=y.get();return y.doStat(t.stat,n,o)}catch(i){return(typeof t>"u"||!(i instanceof t.ErrnoError))&&F(i),-i.errno}}function fn(e,r){y.varargs=r;try{var n=y.getStreamFromFD(),o=y.get();return y.doStat(t.stat,n.path,o)}catch(i){return(typeof t>"u"||!(i instanceof t.ErrnoError))&&F(i),-i.errno}}function cn(e,r){y.varargs=r;try{return 0}catch(n){return(typeof t>"u"||!(n instanceof t.ErrnoError))&&F(n),-n.errno}}function ln(e,r){return cn(e,r)}function dn(e,r){y.varargs=r;try{var n=y.getStreamFromFD(),o=y.get();switch(o){case 0:{var i=y.get();if(i<0)return-28;var a;return a=t.open(n.path,n.flags,0,i),a.fd}case 1:case 2:return 0;case 3:return n.flags;case 4:{var i=y.get();return n.flags|=i,0}case 12:{var i=y.get(),s=0;return Ye[i+s>>1]=2,0}case 13:case 14:return 0;case 16:case 8:return-28;case 9:return we(28),-1;default:return-28}}catch(u){return(typeof t>"u"||!(u instanceof t.ErrnoError))&&F(u),-u.errno}}function vn(e,r){y.varargs=r;try{var n=y.getStr(),o=y.get(),i=y.get(),a=t.open(n,o,i);return a.fd}catch(s){return(typeof t>"u"||!(s instanceof t.ErrnoError))&&F(s),-s.errno}}function mn(e,r){y.varargs=r;try{var n=y.getStreamFromFD(),o=y.get();switch(o){case 21509:case 21505:return n.tty?0:-59;case 21510:case 21511:case 21512:case 21506:case 21507:case 21508:return n.tty?0:-59;case 21519:{if(!n.tty)return-59;var i=y.get();return l[i>>2]=0,0}case 21520:return n.tty?-28:-59;case 21531:{var i=y.get();return t.ioctl(n,o,i)}case 21523:return n.tty?0:-59;case 21524:return n.tty?0:-59;default:F("bad ioctl syscall "+o)}}catch(a){return(typeof t>"u"||!(a instanceof t.ErrnoError))&&F(a),-a.errno}}function hn(e,r){y.varargs=r;try{var n=y.getStr(),o=y.get(),i=y.get();return y.doReadlink(n,o,i)}catch(a){return(typeof t>"u"||!(a instanceof t.ErrnoError))&&F(a),-a.errno}}function gn(){}function pn(){F()}function wr(){return O.length}function wn(e,r,n){G.set(G.subarray(r,r+n),e)}function yn(e){try{return $.grow(e-me.byteLength+65535>>16),fr($.buffer),1}catch{}}function _n(e){var r=wr(),n=65536,o=2147483648-n;if(e>o)return!1;for(var i=16777216,a=Math.max(r,i);a<e;)a<=536870912?a=ar(2*a,n):a=Math.min(ar((3*a+2147483648)/4,n),o);var s=yn(a);return!!s}var yr={};function ye(){if(!ye.strings){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:Me};for(var r in yr)e[r]=yr[r];var n=[];for(var r in e)n.push(r+"="+e[r]);ye.strings=n}return ye.strings}function En(e,r){var n=ye(),o=0;return n.forEach(function(i,a){var s=r+o;l[e+a*4>>2]=s,Cr(i,s),o+=i.length+1}),0}function kn(e,r){var n=ye();l[e>>2]=n.length;var o=0;return n.forEach(function(i){o+=i.length+1}),l[r>>2]=o,0}function Dn(e){}function Sn(e){try{var r=y.getStreamFromFD(e);return t.close(r),0}catch(n){return(typeof t>"u"||!(n instanceof t.ErrnoError))&&F(n),n.errno}}function bn(e,r){try{var n=y.getStreamFromFD(e),o=n.t