@pixiebrix/jq-web
Version:
a hack that makes jq run in the browser with emscripten.
1 lines • 61.9 kB
JavaScript
var jq=function(e){var r=void 0!==(e=e||{})?e:{},t=!1,n=[],o="",a=[],i=[],s=[];function u(e){for(var r=new Uint8Array(e),t="",n=0;n<r.length;++n)t+=String.fromCharCode(r[n]);return decodeURIComponent(escape(t))}r=Object.assign({noInitialRun:!0,noExitRuntime:!0,onRuntimeInitialized:function(){t=!0,n.forEach(function(e){e()})},preRun:function(){ke.init(function(){return a.length?a.pop():o?(a=function(e){for(var r=[],t=unescape(encodeURIComponent(e)),n=0;n<t.length;n++)r.push(t.charCodeAt(n));return r}(o),o="",a.push(null),a.reverse(),a.pop()):null},function(e){e&&i.push(e)},function(e){e&&s.push(e)})}},r);var c,f={};for(c in r)r.hasOwnProperty(c)&&(f[c]=r[c]);var l,d,m=[],p="./this.program",h=function(e,r){throw r},g=!1,w=!1;g="object"==typeof window,w="function"==typeof importScripts,l="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,d=!g&&!l&&!w;var v,y,E,_,k="";l?(k=w?require("path").dirname(k)+"/":__dirname+"/",v=function(e,r){return E||(E=require("fs")),_||(_=require("path")),e=_.normalize(e),E.readFileSync(e,r?null:"utf8")},y=function(e){var r=v(e,!0);return r.buffer||(r=new Uint8Array(r)),P(r.buffer),r},process.argv.length>1&&(p=process.argv[1].replace(/\\/g,"/")),m=process.argv.slice(2),process.on("uncaughtException",function(e){if(!(e instanceof Ge))throw e}),process.on("unhandledRejection",ae),h=function(e){process.exit(e)},r.inspect=function(){return"[Emscripten Module object]"}):d?("undefined"!=typeof read&&(v=function(e){return read(e)}),y=function(e){var r;return"function"==typeof readbuffer?new Uint8Array(readbuffer(e)):(P("object"==typeof(r=read(e,"binary"))),r)},"undefined"!=typeof scriptArgs?m=scriptArgs:void 0!==arguments&&(m=arguments),"function"==typeof quit&&(h=function(e){quit(e)}),"undefined"!=typeof print&&("undefined"==typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!=typeof printErr?printErr:print)):(g||w)&&(w?k=self.location.href:document.currentScript&&(k=document.currentScript.src),k=0!==k.indexOf("blob:")?k.substr(0,k.lastIndexOf("/")+1):"",v=function(e){var r=new XMLHttpRequest;return r.open("GET",e,!1),r.send(null),r.responseText},w&&(y=function(e){var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),function(e,r,t){var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=function(){200==n.status||0==n.status&&n.response?r(n.response):t()},n.onerror=t,n.send(null)});var D,b,S=r.print||console.log.bind(console),F=r.printErr||console.warn.bind(console);for(c in f)f.hasOwnProperty(c)&&(r[c]=f[c]);f=null,r.arguments&&(m=r.arguments),r.thisProgram&&(p=r.thisProgram),r.quit&&(h=r.quit),r.wasmBinary&&(D=r.wasmBinary),r.noExitRuntime&&r.noExitRuntime,"object"!=typeof WebAssembly&&F("no native wasm support detected");var M=new WebAssembly.Table({initial:177,maximum:177,element:"anyfunc"}),A=!1;function P(e,r){e||ae("Assertion failed: "+r)}var x="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function T(e,r,t){for(var n=r+t,o=r;e[o]&&!(o>=n);)++o;if(o-r>16&&e.subarray&&x)return x.decode(e.subarray(r,o));for(var a="";r<o;){var i=e[r++];if(128&i){var s=63&e[r++];if(192!=(224&i)){var u=63&e[r++];if((i=224==(240&i)?(15&i)<<12|s<<6|u:(7&i)<<18|s<<12|u<<6|63&e[r++])<65536)a+=String.fromCharCode(i);else{var c=i-65536;a+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else a+=String.fromCharCode((31&i)<<6|s)}else a+=String.fromCharCode(i)}return a}function R(e,r){return e?T(U,e,r):""}function O(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);if(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 z(e,r,t){return O(e,U,r,t)}function j(e){for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n>=55296&&n<=57343&&(n=65536+((1023&n)<<10)|1023&e.charCodeAt(++t)),n<=127?++r:r+=n<=2047?2:n<=65535?3:4}return r}function N(e){var r=j(e)+1,t=Le(r);return t&&O(e,I,t,r),t}function C(e){var r=j(e)+1,t=Xe(r);return O(e,I,t,r),t}var B,I,U,H,L;function Y(e){B=e,r.HEAP8=I=new Int8Array(e),r.HEAP16=H=new Int16Array(e),r.HEAP32=L=new Int32Array(e),r.HEAPU8=U=new Uint8Array(e),r.HEAPU16=new Uint16Array(e),r.HEAPU32=new Uint32Array(e),r.HEAPF32=new Float32Array(e),r.HEAPF64=new Float64Array(e)}var q=r.INITIAL_MEMORY||16777216;function W(e){for(;e.length>0;){var t=e.shift();if("function"!=typeof t){var n=t.func;"number"==typeof n?void 0===t.arg?r.dynCall_v(n):r.dynCall_vi(n,t.arg):n(void 0===t.arg?null:t.arg)}else t(r)}}(b=r.wasmMemory?r.wasmMemory:new WebAssembly.Memory({initial:q/65536,maximum:32768}))&&(B=b.buffer),q=B.byteLength,Y(B),L[83100]=5575440;var X=[],G=[],J=[],V=[];var K=Math.abs,Z=Math.ceil,$=Math.floor,Q=Math.min,ee=0,re=null,te=null;function ne(e){ee++,r.monitorRunDependencies&&r.monitorRunDependencies(ee)}function oe(e){if(ee--,r.monitorRunDependencies&&r.monitorRunDependencies(ee),0==ee&&(null!==re&&(clearInterval(re),re=null),te)){var t=te;te=null,t()}}function ae(e){throw r.onAbort&&r.onAbort(e),S(e+=""),F(e),A=!0,1,e="abort("+e+"). Build with -s ASSERTIONS=1 for more info.",new WebAssembly.RuntimeError(e)}function ie(e,r){return String.prototype.startsWith?e.startsWith(r):0===e.indexOf(r)}r.preloadedImages={},r.preloadedAudios={};var se="data:application/octet-stream;base64,";function ue(e){return ie(e,se)}var ce="file://";function fe(e){return ie(e,ce)}var le,de,me,pe="jq.wasm.wasm";function he(){try{if(D)return new Uint8Array(D);if(y)return y(pe);throw"both async and sync fetching of the wasm failed"}catch(e){ae(e)}}function ge(){var e=function(){var e=new Error;if(!e.stack){try{throw new Error}catch(r){e=r}if(!e.stack)return"(no stack trace available)"}return e.stack.toString()}();return r.extraStackTrace&&(e+="\n"+r.extraStackTrace()),e.replace(/\b_Z[\w\d_]+/g,function(e){var r=e;return e===r?e:r+" ["+e+"]"})}function we(e){return L[He()>>2]=e,e}ue(pe)||(le=pe,pe=r.locateFile?r.locateFile(le,k):k+le),G.push({func:function(){Ue()}});var ve={splitPath:function(e){return/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1)},normalizeArray:function(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:function(e){var r="/"===e.charAt(0),t="/"===e.substr(-1);return(e=ve.normalizeArray(e.split("/").filter(function(e){return!!e}),!r).join("/"))||r||(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:function(e){var r=ve.splitPath(e),t=r[0],n=r[1];return t||n?(n&&(n=n.substr(0,n.length-1)),t+n):"."},basename:function(e){if("/"===e)return"/";var r=e.lastIndexOf("/");return-1===r?e:e.substr(r+1)},extname:function(e){return ve.splitPath(e)[3]},join:function(){var e=Array.prototype.slice.call(arguments,0);return ve.normalize(e.join("/"))},join2:function(e,r){return ve.normalize(e+"/"+r)}},ye={resolve:function(){for(var e="",r=!1,t=arguments.length-1;t>=-1&&!r;t--){var n=t>=0?arguments[t]:ke.cwd();if("string"!=typeof n)throw new TypeError("Arguments to path.resolve must be strings");if(!n)return"";e=n+"/"+e,r="/"===n.charAt(0)}return e=ve.normalizeArray(e.split("/").filter(function(e){return!!e}),!r).join("/"),(r?"/":"")+e||"."},relative:function(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=ye.resolve(e).substr(1),r=ye.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}var u=[];for(s=i;s<n.length;s++)u.push("..");return(u=u.concat(o.slice(i))).join("/")}},Ee={ttys:[],init:function(){},shutdown:function(){},register:function(e,r){Ee.ttys[e]={input:[],output:[],ops:r},ke.registerDevice(e,Ee.stream_ops)},stream_ops:{open:function(e){var r=Ee.ttys[e.node.rdev];if(!r)throw new ke.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,t,n,o){if(!e.tty||!e.tty.ops.get_char)throw new ke.ErrnoError(60);for(var a=0,i=0;i<n;i++){var s;try{s=e.tty.ops.get_char(e.tty)}catch(e){throw new ke.ErrnoError(29)}if(void 0===s&&0===a)throw new ke.ErrnoError(6);if(null===s||void 0===s)break;a++,r[t+i]=s}return a&&(e.node.timestamp=Date.now()),a},write:function(e,r,t,n,o){if(!e.tty||!e.tty.ops.put_char)throw new ke.ErrnoError(60);try{for(var a=0;a<n;a++)e.tty.ops.put_char(e.tty,r[t+a])}catch(e){throw new ke.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),a}},default_tty_ops:{get_char:function(e){if(!e.input.length){var r=null;if(l){var t=Buffer.alloc?Buffer.alloc(256):new Buffer(256),n=0;try{n=E.readSync(process.stdin.fd,t,0,256,null)}catch(e){if(-1==e.toString().indexOf("EOF"))throw e;n=0}r=n>0?t.slice(0,n).toString("utf-8"):null}else"undefined"!=typeof window&&"function"==typeof window.prompt?null!==(r=window.prompt("Input: "))&&(r+="\n"):"function"==typeof readline&&null!==(r=readline())&&(r+="\n");if(!r)return null;e.input=Ne(r,!0)}return e.input.shift()},put_char:function(e,r){null===r||10===r?(S(T(e.output,0)),e.output=[]):0!=r&&e.output.push(r)},flush:function(e){e.output&&e.output.length>0&&(S(T(e.output,0)),e.output=[])}},default_tty1_ops:{put_char:function(e,r){null===r||10===r?(F(T(e.output,0)),e.output=[]):0!=r&&e.output.push(r)},flush:function(e){e.output&&e.output.length>0&&(F(T(e.output,0)),e.output=[])}}},_e={ops_table:null,mount:function(e){return _e.createNode(null,"/",16895,0)},createNode:function(e,r,t,n){if(ke.isBlkdev(t)||ke.isFIFO(t))throw new ke.ErrnoError(63);_e.ops_table||(_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:ke.chrdev_stream_ops}});var o=ke.createNode(e,r,t,n);return ke.isDir(o.mode)?(o.node_ops=_e.ops_table.dir.node,o.stream_ops=_e.ops_table.dir.stream,o.contents={}):ke.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):ke.isLink(o.mode)?(o.node_ops=_e.ops_table.link.node,o.stream_ops=_e.ops_table.link.stream):ke.isChrdev(o.mode)&&(o.node_ops=_e.ops_table.chrdev.node,o.stream_ops=_e.ops_table.chrdev.stream),o.timestamp=Date.now(),e&&(e.contents[r]=o),o},getFileDataAsRegularArray:function(e){if(e.contents&&e.contents.subarray){for(var r=[],t=0;t<e.usedBytes;++t)r.push(e.contents[t]);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(0)},expandFileStorage:function(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:function(e,r){if(e.usedBytes!=r){if(0==r)return e.contents=null,void(e.usedBytes=0);if(!e.contents||e.contents.subarray){var t=e.contents;return e.contents=new Uint8Array(r),t&&e.contents.set(t.subarray(0,Math.min(r,e.usedBytes))),void(e.usedBytes=r)}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=ke.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,ke.isDir(e.mode)?r.size=4096:ke.isFile(e.mode)?r.size=e.usedBytes:ke.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){void 0!==r.mode&&(e.mode=r.mode),void 0!==r.timestamp&&(e.timestamp=r.timestamp),void 0!==r.size&&_e.resizeFileStorage(e,r.size)},lookup:function(e,r){throw ke.genericErrors[44]},mknod:function(e,r,t,n){return _e.createNode(e,r,t,n)},rename:function(e,r,t){if(ke.isDir(e.mode)){var n;try{n=ke.lookupNode(r,t)}catch(e){}if(n)for(var o in n.contents)throw new ke.ErrnoError(55)}delete e.parent.contents[e.name],e.name=t,r.contents[t]=e,e.parent=r},unlink:function(e,r){delete e.contents[r]},rmdir:function(e,r){var t=ke.lookupNode(e,r);for(var n in t.contents)throw new ke.ErrnoError(55);delete e.contents[r]},readdir:function(e){var r=[".",".."];for(var t in e.contents)e.contents.hasOwnProperty(t)&&r.push(t);return r},symlink:function(e,r,t){var n=_e.createNode(e,r,41471,0);return n.link=t,n},readlink:function(e){if(!ke.isLink(e.mode))throw new ke.ErrnoError(28);return e.link}},stream_ops:{read:function(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:function(e,r,t,n,o,a){if(r.buffer===I.buffer&&(a=!1),!n)return 0;var i=e.node;if(i.timestamp=Date.now(),r.subarray&&(!i.contents||i.contents.subarray)){if(a)return i.contents=r.subarray(t,t+n),i.usedBytes=n,n;if(0===i.usedBytes&&0===o)return i.contents=r.slice(t,t+n),i.usedBytes=n,n;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:function(e,r,t){var n=r;if(1===t?n+=e.position:2===t&&ke.isFile(e.node.mode)&&(n+=e.node.usedBytes),n<0)throw new ke.ErrnoError(28);return n},allocate:function(e,r,t){_e.expandFileStorage(e.node,r+t),e.node.usedBytes=Math.max(e.node.usedBytes,r+t)},mmap:function(e,r,t,n,o,a,i){if(!ke.isFile(e.node.mode))throw new ke.ErrnoError(43);var s,u,c=e.node.contents;if(2&i||c.buffer!==r.buffer){(o>0||o+n<c.length)&&(c=c.subarray?c.subarray(o,o+n):Array.prototype.slice.call(c,o,o+n)),u=!0;var f=r.buffer==I.buffer;if(!(s=Le(n)))throw new ke.ErrnoError(48);(f?I:r).set(c,s)}else u=!1,s=c.byteOffset;return{ptr:s,allocated:u}},msync:function(e,r,t,n,o){if(!ke.isFile(e.node.mode))throw new ke.ErrnoError(43);if(2&o)return 0;_e.stream_ops.write(e,r,0,n,t,!1);return 0}}},ke={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 ke.ErrnoError))throw e+" : "+ge();return we(e.errno)},lookupPath:function(e,r){if(e=ye.resolve(ke.cwd(),e),r=r||{},!e)return{path:"",node:null};var t={follow_mount:!0,recurse_count:0};for(var n in t)void 0===r[n]&&(r[n]=t[n]);if(r.recurse_count>8)throw new ke.ErrnoError(32);for(var o=ve.normalizeArray(e.split("/").filter(function(e){return!!e}),!1),a=ke.root,i="/",s=0;s<o.length;s++){var u=s===o.length-1;if(u&&r.parent)break;if(a=ke.lookupNode(a,o[s]),i=ve.join2(i,o[s]),ke.isMountpoint(a)&&(!u||u&&r.follow_mount)&&(a=a.mounted.root),!u||r.follow)for(var c=0;ke.isLink(a.mode);){var f=ke.readlink(i);if(i=ye.resolve(ve.dirname(i),f),a=ke.lookupPath(i,{recurse_count:r.recurse_count}).node,c++>40)throw new ke.ErrnoError(32)}}return{path:i,node:a}},getPath:function(e){for(var r;;){if(ke.isRoot(e)){var t=e.mount.mountpoint;return r?"/"!==t[t.length-1]?t+"/"+r:t+r:t}r=r?e.name+"/"+r:e.name,e=e.parent}},hashName:function(e,r){for(var t=0,n=0;n<r.length;n++)t=(t<<5)-t+r.charCodeAt(n)|0;return(e+t>>>0)%ke.nameTable.length},hashAddNode:function(e){var r=ke.hashName(e.parent.id,e.name);e.name_next=ke.nameTable[r],ke.nameTable[r]=e},hashRemoveNode:function(e){var r=ke.hashName(e.parent.id,e.name);if(ke.nameTable[r]===e)ke.nameTable[r]=e.name_next;else for(var t=ke.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next}},lookupNode:function(e,r){var t=ke.mayLookup(e);if(t)throw new ke.ErrnoError(t,e);for(var n=ke.hashName(e.id,r),o=ke.nameTable[n];o;o=o.name_next){var a=o.name;if(o.parent.id===e.id&&a===r)return o}return ke.lookup(e,r)},createNode:function(e,r,t,n){var o=new ke.FSNode(e,r,t,n);return ke.hashAddNode(o),o},destroyNode:function(e){ke.hashRemoveNode(e)},isRoot:function(e){return e===e.parent},isMountpoint:function(e){return!!e.mounted},isFile:function(e){return 32768==(61440&e)},isDir:function(e){return 16384==(61440&e)},isLink:function(e){return 40960==(61440&e)},isChrdev:function(e){return 8192==(61440&e)},isBlkdev:function(e){return 24576==(61440&e)},isFIFO:function(e){return 4096==(61440&e)},isSocket:function(e){return 49152==(49152&e)},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=ke.flagModes[e];if(void 0===r)throw new Error("Unknown file open mode: "+e);return r},flagsToPermissionString:function(e){var r=["r","w","rw"][3&e];return 512&e&&(r+="w"),r},nodePermissions:function(e,r){return ke.ignorePermissions?0:(-1===r.indexOf("r")||292&e.mode)&&(-1===r.indexOf("w")||146&e.mode)&&(-1===r.indexOf("x")||73&e.mode)?0:2},mayLookup:function(e){var r=ke.nodePermissions(e,"x");return r||(e.node_ops.lookup?0:2)},mayCreate:function(e,r){try{ke.lookupNode(e,r);return 20}catch(e){}return ke.nodePermissions(e,"wx")},mayDelete:function(e,r,t){var n;try{n=ke.lookupNode(e,r)}catch(e){return e.errno}var o=ke.nodePermissions(e,"wx");if(o)return o;if(t){if(!ke.isDir(n.mode))return 54;if(ke.isRoot(n)||ke.getPath(n)===ke.cwd())return 10}else if(ke.isDir(n.mode))return 31;return 0},mayOpen:function(e,r){return e?ke.isLink(e.mode)?32:ke.isDir(e.mode)&&("r"!==ke.flagsToPermissionString(r)||512&r)?31:ke.nodePermissions(e,ke.flagsToPermissionString(r)):44},MAX_OPEN_FDS:4096,nextfd:function(e,r){e=e||0,r=r||ke.MAX_OPEN_FDS;for(var t=e;t<=r;t++)if(!ke.streams[t])return t;throw new ke.ErrnoError(33)},getStream:function(e){return ke.streams[e]},createStream:function(e,r,t){ke.FSStream||(ke.FSStream=function(){},ke.FSStream.prototype={object:{get:function(){return this.node},set:function(e){this.node=e}},isRead:{get:function(){return 1!=(2097155&this.flags)}},isWrite:{get:function(){return 0!=(2097155&this.flags)}},isAppend:{get:function(){return 1024&this.flags}}});var n=new ke.FSStream;for(var o in e)n[o]=e[o];e=n;var a=ke.nextfd(r,t);return e.fd=a,ke.streams[a]=e,e},closeStream:function(e){ke.streams[e]=null},chrdev_stream_ops:{open:function(e){var r=ke.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:function(){throw new ke.ErrnoError(70)}},major:function(e){return e>>8},minor:function(e){return 255&e},makedev:function(e,r){return e<<8|r},registerDevice:function(e,r){ke.devices[e]={stream_ops:r}},getDevice:function(e){return ke.devices[e]},getMounts:function(e){for(var r=[],t=[e];t.length;){var n=t.pop();r.push(n),t.push.apply(t,n.mounts)}return r},syncfs:function(e,r){"function"==typeof e&&(r=e,e=!1),ke.syncFSRequests++,ke.syncFSRequests>1&&F("warning: "+ke.syncFSRequests+" FS.syncfs operations in flight at once, probably just doing extra work");var t=ke.getMounts(ke.root.mount),n=0;function o(e){return ke.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(function(r){if(!r.type.syncfs)return a(null);r.type.syncfs(r,e,a)})},mount:function(e,r,t){var n,o="/"===t,a=!t;if(o&&ke.root)throw new ke.ErrnoError(10);if(!o&&!a){var i=ke.lookupPath(t,{follow_mount:!1});if(t=i.path,n=i.node,ke.isMountpoint(n))throw new ke.ErrnoError(10);if(!ke.isDir(n.mode))throw new ke.ErrnoError(54)}var s={type:e,opts:r,mountpoint:t,mounts:[]},u=e.mount(s);return u.mount=s,s.root=u,o?ke.root=u:n&&(n.mounted=s,n.mount&&n.mount.mounts.push(s)),u},unmount:function(e){var r=ke.lookupPath(e,{follow_mount:!1});if(!ke.isMountpoint(r.node))throw new ke.ErrnoError(28);var t=r.node,n=t.mounted,o=ke.getMounts(n);Object.keys(ke.nameTable).forEach(function(e){for(var r=ke.nameTable[e];r;){var t=r.name_next;-1!==o.indexOf(r.mount)&&ke.destroyNode(r),r=t}}),t.mounted=null;var a=t.mount.mounts.indexOf(n);t.mount.mounts.splice(a,1)},lookup:function(e,r){return e.node_ops.lookup(e,r)},mknod:function(e,r,t){var n=ke.lookupPath(e,{parent:!0}).node,o=ve.basename(e);if(!o||"."===o||".."===o)throw new ke.ErrnoError(28);var a=ke.mayCreate(n,o);if(a)throw new ke.ErrnoError(a);if(!n.node_ops.mknod)throw new ke.ErrnoError(63);return n.node_ops.mknod(n,o,r,t)},create:function(e,r){return r=void 0!==r?r:438,r&=4095,r|=32768,ke.mknod(e,r,0)},mkdir:function(e,r){return r=void 0!==r?r:511,r&=1023,r|=16384,ke.mknod(e,r,0)},mkdirTree:function(e,r){for(var t=e.split("/"),n="",o=0;o<t.length;++o)if(t[o]){n+="/"+t[o];try{ke.mkdir(n,r)}catch(e){if(20!=e.errno)throw e}}},mkdev:function(e,r,t){return void 0===t&&(t=r,r=438),r|=8192,ke.mknod(e,r,t)},symlink:function(e,r){if(!ye.resolve(e))throw new ke.ErrnoError(44);var t=ke.lookupPath(r,{parent:!0}).node;if(!t)throw new ke.ErrnoError(44);var n=ve.basename(r),o=ke.mayCreate(t,n);if(o)throw new ke.ErrnoError(o);if(!t.node_ops.symlink)throw new ke.ErrnoError(63);return t.node_ops.symlink(t,n,e)},rename:function(e,r){var t,n,o=ve.dirname(e),a=ve.dirname(r),i=ve.basename(e),s=ve.basename(r);try{t=ke.lookupPath(e,{parent:!0}).node,n=ke.lookupPath(r,{parent:!0}).node}catch(e){throw new ke.ErrnoError(10)}if(!t||!n)throw new ke.ErrnoError(44);if(t.mount!==n.mount)throw new ke.ErrnoError(75);var u,c=ke.lookupNode(t,i),f=ye.relative(e,a);if("."!==f.charAt(0))throw new ke.ErrnoError(28);if("."!==(f=ye.relative(r,o)).charAt(0))throw new ke.ErrnoError(55);try{u=ke.lookupNode(n,s)}catch(e){}if(c!==u){var l=ke.isDir(c.mode),d=ke.mayDelete(t,i,l);if(d)throw new ke.ErrnoError(d);if(d=u?ke.mayDelete(n,s,l):ke.mayCreate(n,s))throw new ke.ErrnoError(d);if(!t.node_ops.rename)throw new ke.ErrnoError(63);if(ke.isMountpoint(c)||u&&ke.isMountpoint(u))throw new ke.ErrnoError(10);if(n!==t&&(d=ke.nodePermissions(t,"w")))throw new ke.ErrnoError(d);try{ke.trackingDelegate.willMovePath&&ke.trackingDelegate.willMovePath(e,r)}catch(t){F("FS.trackingDelegate['willMovePath']('"+e+"', '"+r+"') threw an exception: "+t.message)}ke.hashRemoveNode(c);try{t.node_ops.rename(c,n,s)}catch(e){throw e}finally{ke.hashAddNode(c)}try{ke.trackingDelegate.onMovePath&&ke.trackingDelegate.onMovePath(e,r)}catch(t){F("FS.trackingDelegate['onMovePath']('"+e+"', '"+r+"') threw an exception: "+t.message)}}},rmdir:function(e){var r=ke.lookupPath(e,{parent:!0}).node,t=ve.basename(e),n=ke.lookupNode(r,t),o=ke.mayDelete(r,t,!0);if(o)throw new ke.ErrnoError(o);if(!r.node_ops.rmdir)throw new ke.ErrnoError(63);if(ke.isMountpoint(n))throw new ke.ErrnoError(10);try{ke.trackingDelegate.willDeletePath&&ke.trackingDelegate.willDeletePath(e)}catch(r){F("FS.trackingDelegate['willDeletePath']('"+e+"') threw an exception: "+r.message)}r.node_ops.rmdir(r,t),ke.destroyNode(n);try{ke.trackingDelegate.onDeletePath&&ke.trackingDelegate.onDeletePath(e)}catch(r){F("FS.trackingDelegate['onDeletePath']('"+e+"') threw an exception: "+r.message)}},readdir:function(e){var r=ke.lookupPath(e,{follow:!0}).node;if(!r.node_ops.readdir)throw new ke.ErrnoError(54);return r.node_ops.readdir(r)},unlink:function(e){var r=ke.lookupPath(e,{parent:!0}).node,t=ve.basename(e),n=ke.lookupNode(r,t),o=ke.mayDelete(r,t,!1);if(o)throw new ke.ErrnoError(o);if(!r.node_ops.unlink)throw new ke.ErrnoError(63);if(ke.isMountpoint(n))throw new ke.ErrnoError(10);try{ke.trackingDelegate.willDeletePath&&ke.trackingDelegate.willDeletePath(e)}catch(r){F("FS.trackingDelegate['willDeletePath']('"+e+"') threw an exception: "+r.message)}r.node_ops.unlink(r,t),ke.destroyNode(n);try{ke.trackingDelegate.onDeletePath&&ke.trackingDelegate.onDeletePath(e)}catch(r){F("FS.trackingDelegate['onDeletePath']('"+e+"') threw an exception: "+r.message)}},readlink:function(e){var r=ke.lookupPath(e).node;if(!r)throw new ke.ErrnoError(44);if(!r.node_ops.readlink)throw new ke.ErrnoError(28);return ye.resolve(ke.getPath(r.parent),r.node_ops.readlink(r))},stat:function(e,r){var t=ke.lookupPath(e,{follow:!r}).node;if(!t)throw new ke.ErrnoError(44);if(!t.node_ops.getattr)throw new ke.ErrnoError(63);return t.node_ops.getattr(t)},lstat:function(e){return ke.stat(e,!0)},chmod:function(e,r,t){var n;"string"==typeof e?n=ke.lookupPath(e,{follow:!t}).node:n=e;if(!n.node_ops.setattr)throw new ke.ErrnoError(63);n.node_ops.setattr(n,{mode:4095&r|-4096&n.mode,timestamp:Date.now()})},lchmod:function(e,r){ke.chmod(e,r,!0)},fchmod:function(e,r){var t=ke.getStream(e);if(!t)throw new ke.ErrnoError(8);ke.chmod(t.node,r)},chown:function(e,r,t,n){var o;"string"==typeof e?o=ke.lookupPath(e,{follow:!n}).node:o=e;if(!o.node_ops.setattr)throw new ke.ErrnoError(63);o.node_ops.setattr(o,{timestamp:Date.now()})},lchown:function(e,r,t){ke.chown(e,r,t,!0)},fchown:function(e,r,t){var n=ke.getStream(e);if(!n)throw new ke.ErrnoError(8);ke.chown(n.node,r,t)},truncate:function(e,r){if(r<0)throw new ke.ErrnoError(28);var t;"string"==typeof e?t=ke.lookupPath(e,{follow:!0}).node:t=e;if(!t.node_ops.setattr)throw new ke.ErrnoError(63);if(ke.isDir(t.mode))throw new ke.ErrnoError(31);if(!ke.isFile(t.mode))throw new ke.ErrnoError(28);var n=ke.nodePermissions(t,"w");if(n)throw new ke.ErrnoError(n);t.node_ops.setattr(t,{size:r,timestamp:Date.now()})},ftruncate:function(e,r){var t=ke.getStream(e);if(!t)throw new ke.ErrnoError(8);if(0==(2097155&t.flags))throw new ke.ErrnoError(28);ke.truncate(t.node,r)},utime:function(e,r,t){var n=ke.lookupPath(e,{follow:!0}).node;n.node_ops.setattr(n,{timestamp:Math.max(r,t)})},open:function(e,t,n,o,a){if(""===e)throw new ke.ErrnoError(44);var i;if(t="string"==typeof t?ke.modeStringToFlags(t):t,n=void 0===n?438:n,n=64&t?4095&n|32768:0,"object"==typeof e)i=e;else{e=ve.normalize(e);try{i=ke.lookupPath(e,{follow:!(131072&t)}).node}catch(e){}}var s=!1;if(64&t)if(i){if(128&t)throw new ke.ErrnoError(20)}else i=ke.mknod(e,n,0),s=!0;if(!i)throw new ke.ErrnoError(44);if(ke.isChrdev(i.mode)&&(t&=-513),65536&t&&!ke.isDir(i.mode))throw new ke.ErrnoError(54);if(!s){var u=ke.mayOpen(i,t);if(u)throw new ke.ErrnoError(u)}512&t&&ke.truncate(i,0),t&=-131713;var c=ke.createStream({node:i,path:ke.getPath(i),flags:t,seekable:!0,position:0,stream_ops:i.stream_ops,ungotten:[],error:!1},o,a);c.stream_ops.open&&c.stream_ops.open(c),!r.logReadFiles||1&t||(ke.readFiles||(ke.readFiles={}),e in ke.readFiles||(ke.readFiles[e]=1,F("FS.trackingDelegate error on read file: "+e)));try{if(ke.trackingDelegate.onOpenFile){var f=0;1!=(2097155&t)&&(f|=ke.tracking.openFlags.READ),0!=(2097155&t)&&(f|=ke.tracking.openFlags.WRITE),ke.trackingDelegate.onOpenFile(e,f)}}catch(r){F("FS.trackingDelegate['onOpenFile']('"+e+"', flags) threw an exception: "+r.message)}return c},close:function(e){if(ke.isClosed(e))throw new ke.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(e){throw e}finally{ke.closeStream(e.fd)}e.fd=null},isClosed:function(e){return null===e.fd},llseek:function(e,r,t){if(ke.isClosed(e))throw new ke.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new ke.ErrnoError(70);if(0!=t&&1!=t&&2!=t)throw new ke.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read:function(e,r,t,n,o){if(n<0||o<0)throw new ke.ErrnoError(28);if(ke.isClosed(e))throw new ke.ErrnoError(8);if(1==(2097155&e.flags))throw new ke.ErrnoError(8);if(ke.isDir(e.node.mode))throw new ke.ErrnoError(31);if(!e.stream_ops.read)throw new ke.ErrnoError(28);var a=void 0!==o;if(a){if(!e.seekable)throw new ke.ErrnoError(70)}else o=e.position;var i=e.stream_ops.read(e,r,t,n,o);return a||(e.position+=i),i},write:function(e,r,t,n,o,a){if(n<0||o<0)throw new ke.ErrnoError(28);if(ke.isClosed(e))throw new ke.ErrnoError(8);if(0==(2097155&e.flags))throw new ke.ErrnoError(8);if(ke.isDir(e.node.mode))throw new ke.ErrnoError(31);if(!e.stream_ops.write)throw new ke.ErrnoError(28);e.seekable&&1024&e.flags&&ke.llseek(e,0,2);var i=void 0!==o;if(i){if(!e.seekable)throw new ke.ErrnoError(70)}else o=e.position;var s=e.stream_ops.write(e,r,t,n,o,a);i||(e.position+=s);try{e.path&&ke.trackingDelegate.onWriteToFile&&ke.trackingDelegate.onWriteToFile(e.path)}catch(r){F("FS.trackingDelegate['onWriteToFile']('"+e.path+"') threw an exception: "+r.message)}return s},allocate:function(e,r,t){if(ke.isClosed(e))throw new ke.ErrnoError(8);if(r<0||t<=0)throw new ke.ErrnoError(28);if(0==(2097155&e.flags))throw new ke.ErrnoError(8);if(!ke.isFile(e.node.mode)&&!ke.isDir(e.node.mode))throw new ke.ErrnoError(43);if(!e.stream_ops.allocate)throw new ke.ErrnoError(138);e.stream_ops.allocate(e,r,t)},mmap:function(e,r,t,n,o,a,i){if(0!=(2&a)&&0==(2&i)&&2!=(2097155&e.flags))throw new ke.ErrnoError(2);if(1==(2097155&e.flags))throw new ke.ErrnoError(2);if(!e.stream_ops.mmap)throw new ke.ErrnoError(43);return e.stream_ops.mmap(e,r,t,n,o,a,i)},msync:function(e,r,t,n,o){return e&&e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,o):0},munmap:function(e){return 0},ioctl:function(e,r,t){if(!e.stream_ops.ioctl)throw new ke.ErrnoError(59);return e.stream_ops.ioctl(e,r,t)},readFile:function(e,r){if((r=r||{}).flags=r.flags||"r",r.encoding=r.encoding||"binary","utf8"!==r.encoding&&"binary"!==r.encoding)throw new Error('Invalid encoding type "'+r.encoding+'"');var t,n=ke.open(e,r.flags),o=ke.stat(e).size,a=new Uint8Array(o);return ke.read(n,a,0,o,0),"utf8"===r.encoding?t=T(a,0):"binary"===r.encoding&&(t=a),ke.close(n),t},writeFile:function(e,r,t){(t=t||{}).flags=t.flags||"w";var n=ke.open(e,t.flags,t.mode);if("string"==typeof r){var o=new Uint8Array(j(r)+1),a=O(r,o,0,o.length);ke.write(n,o,0,a,void 0,t.canOwn)}else{if(!ArrayBuffer.isView(r))throw new Error("Unsupported data type");ke.write(n,r,0,r.byteLength,void 0,t.canOwn)}ke.close(n)},cwd:function(){return ke.currentPath},chdir:function(e){var r=ke.lookupPath(e,{follow:!0});if(null===r.node)throw new ke.ErrnoError(44);if(!ke.isDir(r.node.mode))throw new ke.ErrnoError(54);var t=ke.nodePermissions(r.node,"x");if(t)throw new ke.ErrnoError(t);ke.currentPath=r.path},createDefaultDirectories:function(){ke.mkdir("/tmp"),ke.mkdir("/home"),ke.mkdir("/home/web_user")},createDefaultDevices:function(){var e;if(ke.mkdir("/dev"),ke.registerDevice(ke.makedev(1,3),{read:function(){return 0},write:function(e,r,t,n,o){return n}}),ke.mkdev("/dev/null",ke.makedev(1,3)),Ee.register(ke.makedev(5,0),Ee.default_tty_ops),Ee.register(ke.makedev(6,0),Ee.default_tty1_ops),ke.mkdev("/dev/tty",ke.makedev(5,0)),ke.mkdev("/dev/tty1",ke.makedev(6,0)),"object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var r=new Uint8Array(1);e=function(){return crypto.getRandomValues(r),r[0]}}else if(l)try{var t=require("crypto");e=function(){return t.randomBytes(1)[0]}}catch(e){}e||(e=function(){ae("random_device")}),ke.createDevice("/dev","random",e),ke.createDevice("/dev","urandom",e),ke.mkdir("/dev/shm"),ke.mkdir("/dev/shm/tmp")},createSpecialDirectories:function(){ke.mkdir("/proc"),ke.mkdir("/proc/self"),ke.mkdir("/proc/self/fd"),ke.mount({mount:function(){var e=ke.createNode("/proc/self","fd",16895,73);return e.node_ops={lookup:function(e,r){var t=+r,n=ke.getStream(t);if(!n)throw new ke.ErrnoError(8);var o={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:function(){return n.path}}};return o.parent=o,o}},e}},{},"/proc/self/fd")},createStandardStreams:function(){r.stdin?ke.createDevice("/dev","stdin",r.stdin):ke.symlink("/dev/tty","/dev/stdin"),r.stdout?ke.createDevice("/dev","stdout",null,r.stdout):ke.symlink("/dev/tty","/dev/stdout"),r.stderr?ke.createDevice("/dev","stderr",null,r.stderr):ke.symlink("/dev/tty1","/dev/stderr");ke.open("/dev/stdin","r"),ke.open("/dev/stdout","w"),ke.open("/dev/stderr","w")},ensureErrnoError:function(){ke.ErrnoError||(ke.ErrnoError=function(e,r){this.node=r,this.setErrno=function(e){this.errno=e},this.setErrno(e),this.message="FS error"},ke.ErrnoError.prototype=new Error,ke.ErrnoError.prototype.constructor=ke.ErrnoError,[44].forEach(function(e){ke.genericErrors[e]=new ke.ErrnoError(e),ke.genericErrors[e].stack="<generic error, no stack>"}))},staticInit:function(){ke.ensureErrnoError(),ke.nameTable=new Array(4096),ke.mount(_e,{},"/"),ke.createDefaultDirectories(),ke.createDefaultDevices(),ke.createSpecialDirectories(),ke.filesystems={MEMFS:_e}},init:function(e,t,n){ke.init.initialized=!0,ke.ensureErrnoError(),r.stdin=e||r.stdin,r.stdout=t||r.stdout,r.stderr=n||r.stderr,ke.createStandardStreams()},quit:function(){ke.init.initialized=!1;var e=r._fflush;e&&e(0);for(var t=0;t<ke.streams.length;t++){var n=ke.streams[t];n&&ke.close(n)}},getMode:function(e,r){var t=0;return e&&(t|=365),r&&(t|=146),t},joinPath:function(e,r){var t=ve.join.apply(null,e);return r&&"/"==t[0]&&(t=t.substr(1)),t},absolutePath:function(e,r){return ye.resolve(r,e)},standardizePath:function(e){return ve.normalize(e)},findObject:function(e,r){var t=ke.analyzePath(e,r);return t.exists?t.object:(we(t.error),null)},analyzePath:function(e,r){try{e=(n=ke.lookupPath(e,{follow:!r})).path}catch(e){}var t={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var n=ke.lookupPath(e,{parent:!0});t.parentExists=!0,t.parentPath=n.path,t.parentObject=n.node,t.name=ve.basename(e),n=ke.lookupPath(e,{follow:!r}),t.exists=!0,t.path=n.path,t.object=n.node,t.name=n.node.name,t.isRoot="/"===n.path}catch(e){t.error=e.errno}return t},createFolder:function(e,r,t,n){var o=ve.join2("string"==typeof e?e:ke.getPath(e),r),a=ke.getMode(t,n);return ke.mkdir(o,a)},createPath:function(e,r,t,n){e="string"==typeof e?e:ke.getPath(e);for(var o=r.split("/").reverse();o.length;){var a=o.pop();if(a){var i=ve.join2(e,a);try{ke.mkdir(i)}catch(e){}e=i}}return i},createFile:function(e,r,t,n,o){var a=ve.join2("string"==typeof e?e:ke.getPath(e),r),i=ke.getMode(n,o);return ke.create(a,i)},createDataFile:function(e,r,t,n,o,a){var i=r?ve.join2("string"==typeof e?e:ke.getPath(e),r):e,s=ke.getMode(n,o),u=ke.create(i,s);if(t){if("string"==typeof t){for(var c=new Array(t.length),f=0,l=t.length;f<l;++f)c[f]=t.charCodeAt(f);t=c}ke.chmod(u,146|s);var d=ke.open(u,"w");ke.write(d,t,0,t.length,0,a),ke.close(d),ke.chmod(u,s)}return u},createDevice:function(e,r,t,n){var o=ve.join2("string"==typeof e?e:ke.getPath(e),r),a=ke.getMode(!!t,!!n);ke.createDevice.major||(ke.createDevice.major=64);var i=ke.makedev(ke.createDevice.major++,0);return ke.registerDevice(i,{open:function(e){e.seekable=!1},close:function(e){n&&n.buffer&&n.buffer.length&&n(10)},read:function(e,r,n,o,a){for(var i=0,s=0;s<o;s++){var u;try{u=t()}catch(e){throw new ke.ErrnoError(29)}if(void 0===u&&0===i)throw new ke.ErrnoError(6);if(null===u||void 0===u)break;i++,r[n+s]=u}return i&&(e.node.timestamp=Date.now()),i},write:function(e,r,t,o,a){for(var i=0;i<o;i++)try{n(r[t+i])}catch(e){throw new ke.ErrnoError(29)}return o&&(e.node.timestamp=Date.now()),i}}),ke.mkdev(o,a,i)},createLink:function(e,r,t,n,o){var a=ve.join2("string"==typeof e?e:ke.getPath(e),r);return ke.symlink(t,a)},forceLoadFile:function(e){if(e.isDevice||e.isFolder||e.link||e.contents)return!0;var r=!0;if("undefined"!=typeof XMLHttpRequest)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(!v)throw new Error("Cannot load without read() or XMLHttpRequest.");try{e.contents=Ne(v(e.url),!0),e.usedBytes=e.contents.length}catch(e){r=!1}return r||we(29),r},createLazyFile:function(e,r,t,n,o){function a(){this.lengthKnown=!1,this.chunks=[]}if(a.prototype.get=function(e){if(!(e>this.length-1||e<0)){var r=e%this.chunkSize,t=e/this.chunkSize|0;return this.getter(t)[r]}},a.prototype.setDataGetter=function(e){this.getter=e},a.prototype.cacheLength=function(){var e=new XMLHttpRequest;if(e.open("HEAD",t,!1),e.send(null),!(e.status>=200&&e.status<300||304===e.status))throw new Error("Couldn't load "+t+". Status: "+e.status);var r,n=Number(e.getResponseHeader("Content-length")),o=(r=e.getResponseHeader("Accept-Ranges"))&&"bytes"===r,a=(r=e.getResponseHeader("Content-Encoding"))&&"gzip"===r,i=1048576;o||(i=n);var s=this;s.setDataGetter(function(e){var r=e*i,o=(e+1)*i-1;if(o=Math.min(o,n-1),void 0===s.chunks[e]&&(s.chunks[e]=function(e,r){if(e>r)throw new Error("invalid range ("+e+", "+r+") or no bytes requested!");if(r>n-1)throw new 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),"undefined"!=typeof Uint8Array&&(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 new Error("Couldn't load "+t+". Status: "+o.status);return void 0!==o.response?new Uint8Array(o.response||[]):Ne(o.responseText||"",!0)}(r,o)),void 0===s.chunks[e])throw new Error("doXHR failed!");return s.chunks[e]}),!a&&n||(i=n=1,n=this.getter(0).length,i=n,S("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=n,this._chunkSize=i,this.lengthKnown=!0},"undefined"!=typeof XMLHttpRequest){if(!w)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var i=new a;Object.defineProperties(i,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var s={isDevice:!1,contents:i}}else s={isDevice:!1,url:t};var u=ke.createFile(e,r,s,n,o);s.contents?u.contents=s.contents:s.url&&(u.contents=null,u.url=s.url),Object.defineProperties(u,{usedBytes:{get:function(){return this.contents.length}}});var c={};return Object.keys(u.stream_ops).forEach(function(e){var r=u.stream_ops[e];c[e]=function(){if(!ke.forceLoadFile(u))throw new ke.ErrnoError(29);return r.apply(null,arguments)}}),c.read=function(e,r,t,n,o){if(!ke.forceLoadFile(u))throw new ke.ErrnoError(29);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(s=0;s<i;s++)r[t+s]=a.get(o+s);return i},u.stream_ops=c,u},createPreloadedFile:function(e,t,n,o,a,i,s,u,c,f){Browser.init();var l=t?ye.resolve(ve.join2(e,t)):e;function d(n){function d(r){f&&f(),u||ke.createDataFile(e,t,r,o,a,c),i&&i(),oe()}var m=!1;r.preloadPlugins.forEach(function(e){m||e.canHandle(l)&&(e.handle(n,l,d,function(){s&&s(),oe()}),m=!0)}),m||d(n)}ne(),"string"==typeof n?Browser.asyncLoad(n,function(e){d(e)},s):d(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,t){r=r||function(){},t=t||function(){};var n=ke.indexedDB();try{var o=n.open(ke.DB_NAME(),ke.DB_VERSION)}catch(e){return t(e)}o.onupgradeneeded=function(){S("creating db"),o.result.createObjectStore(ke.DB_STORE_NAME)},o.onsuccess=function(){var n=o.result.transaction([ke.DB_STORE_NAME],"readwrite"),a=n.objectStore(ke.DB_STORE_NAME),i=0,s=0,u=e.length;function c(){0==s?r():t()}e.forEach(function(e){var r=a.put(ke.analyzePath(e).object.contents,e);r.onsuccess=function(){++i+s==u&&c()},r.onerror=function(){i+ ++s==u&&c()}}),n.onerror=t},o.onerror=t},loadFilesFromDB:function(e,r,t){r=r||function(){},t=t||function(){};var n=ke.indexedDB();try{var o=n.open(ke.DB_NAME(),ke.DB_VERSION)}catch(e){return t(e)}o.onupgradeneeded=t,o.onsuccess=function(){var n=o.result;try{var a=n.transaction([ke.DB_STORE_NAME],"readonly")}catch(e){return void t(e)}var i=a.objectStore(ke.DB_STORE_NAME),s=0,u=0,c=e.length;function f(){0==u?r():t()}e.forEach(function(e){var r=i.get(e);r.onsuccess=function(){ke.analyzePath(e).exists&&ke.unlink(e),ke.createDataFile(ve.dirname(e),ve.basename(e),r.result,!0,!0,!0),++s+u==c&&f()},r.onerror=function(){s+ ++u==c&&f()}}),a.onerror=t},o.onerror=t}},De={mappings:{},DEFAULT_POLLMASK:5,umask:511,calculateAt:function(e,r){if("/"!==r[0]){var t;if(-100===e)t=ke.cwd();else{var n=ke.getStream(e);if(!n)throw new ke.ErrnoError(8);t=n.path}r=ve.join2(t,r)}return r},doStat:function(e,r,t){try{var n=e(r)}catch(e){if(e&&e.node&&ve.normalize(r)!==ve.normalize(ke.getPath(e.node)))return-54;throw e}return L[t>>2]=n.dev,L[t+4>>2]=0,L[t+8>>2]=n.ino,L[t+12>>2]=n.mode,L[t+16>>2]=n.nlink,L[t+20>>2]=n.uid,L[t+24>>2]=n.gid,L[t+28>>2]=n.rdev,L[t+32>>2]=0,me=[n.size>>>0,(de=n.size,+K(de)>=1?de>0?(0|Q(+$(de/4294967296),4294967295))>>>0:~~+Z((de-+(~~de>>>0))/4294967296)>>>0:0)],L[t+40>>2]=me[0],L[t+44>>2]=me[1],L[t+48>>2]=4096,L[t+52>>2]=n.blocks,L[t+56>>2]=n.atime.getTime()/1e3|0,L[t+60>>2]=0,L[t+64>>2]=n.mtime.getTime()/1e3|0,L[t+68>>2]=0,L[t+72>>2]=n.ctime.getTime()/1e3|0,L[t+76>>2]=0,me=[n.ino>>>0,(de=n.ino,+K(de)>=1?de>0?(0|Q(+$(de/4294967296),4294967295))>>>0:~~+Z((de-+(~~de>>>0))/4294967296)>>>0:0)],L[t+80>>2]=me[0],L[t+84>>2]=me[1],0},doMsync:function(e,r,t,n,o){var a=U.slice(e,e+t);ke.msync(r,a,o,t,n)},doMkdir:function(e,r){return"/"===(e=ve.normalize(e))[e.length-1]&&(e=e.substr(0,e.length-1)),ke.mkdir(e,r,0),0},doMknod:function(e,r,t){switch(61440&r){case 32768:case 8192:case 24576:case 4096:case 49152:break;default:return-28}return ke.mknod(e,r,t),0},doReadlink:function(e,r,t){if(t<=0)return-28;var n=ke.readlink(e),o=Math.min(t,j(n)),a=I[r+o];return z(n,r,t+1),I[r+o]=a,o},doAccess:function(e,r){if(-8&r)return-28;var t;if(!(t=ke.lookupPath(e,{follow:!0}).node))return-44;var n="";return 4&r&&(n+="r"),2&r&&(n+="w"),1&r&&(n+="x"),n&&ke.nodePermissions(t,n)?-2:0},doDup:function(e,r,t){var n=ke.getStream(t);return n&&ke.close(n),ke.open(e,r,0,t,t).fd},doReadv:function(e,r,t,n){for(var o=0,a=0;a<t;a++){var i=L[r+8*a>>2],s=L[r+(8*a+4)>>2],u=ke.read(e,I,i,s,n);if(u<0)return-1;if(o+=u,u<s)break}return o},doWritev:function(e,r,t,n){for(var o=0,a=0;a<t;a++){var i=L[r+8*a>>2],s=L[r+(8*a+4)>>2],u=ke.write(e,I,i,s,n);if(u<0)return-1;o+=u}return o},varargs:void 0,get:function(){return De.varargs+=4,L[De.varargs-4>>2]},getStr:function(e){return R(e)},getStreamFromFD:function(e){var r=ke.getStream(e);if(!r)throw new ke.ErrnoError(8);return r},get64:function(e,r){return e}};function be(e){try{return b.grow(e-B.byteLength+65535>>>16),Y(b.buffer),1}catch(e){}}var Se={};function Fe(){if(!Fe.strings){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:p||"./this.program"};for(var r in Se)e[r]=Se[r];var t=[];for(var r in e)t.push(r+"="+e[r]);Fe.strings=t}return Fe.strings}var Me=(z("GMT",332464,4),332464);function Ae(){if(!Ae.called){Ae.called=!0,L[We()>>2]=60*(new Date).getTimezoneOffset();var e=(new Date).getFullYear(),r=new Date(e,0,1),t=new Date(e,6,1);L[qe()>>2]=Number(r.getTimezoneOffset()!=t.getTimezoneOffset());var n=s(r),o=s(t),a=N(n),i=N(o);t.getTimezoneOffset()<r.getTimezoneOffset()?(L[Ye()>>2]=a,L[Ye()+4>>2]=i):(L[Ye()>>2]=i,L[Ye()+4>>2]=a)}function s(e){var r=e.toTimeString().match(/\(([A-Za-z ]+)\)$/);return r?r[1]:"GMT"}}function Pe(e){return e%4==0&&(e%100!=0||e%400==0)}function xe(e,r){for(var t=0,n=0;n<=r;t+=e[n++]);return t}var Te=[31,29,31,30,31,30,31,31,30,31,30,31],Re=[31,28,31,30,31,30,31,31,30,31,30,31];function Oe(e,r){for(var t=new Date(e.getTime());r>0;){var n=Pe(t.getFullYear()),o=t.getMonth(),a=(n?Te:Re)[o];if(!(r>a-t.getDate()))return t.setDate(t.getDate()+r),t;r-=a-t.getDate()+1,t.setDate(1),o<11?t.setMonth(o+1):(t.setMonth(0),t.setFullYear(t.getFullYear()+1))}return t}function ze(e){return parseInt(e)}var je=function(e,r,t,n){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=ke.nextInode++,this.name=r,this.mode=t,this.node_ops={},this.stream_ops={},this.rdev=n};function Ne(e,r,t){var n=t>0?t:j(e)+1,o=new Array(n),a=O(e,o,0,o.length);return r&&(o.length=a),o}Object.defineProperties(je.prototype,{read:{get:function(){return 365==(365&this.mode)},set:function(e){e?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146==(146&this.mode)},set:function(e){e?this.mode|=146:this.mode&=-147}},isFolder:{get:function(){return ke.isDir(this.mode)}},isDevice:{get:function(){return ke.isChrdev(this.mode)}}}),ke.FSNode=je,ke.staticInit();var Ce={a:function(e,r,t,n){ae("Assertion failed: "+R(e)+", at: "+[r?R(r):"unknown filename",t,n?R(n):"unknown function"])},g:function(e,r,t){De.varargs=t;try{var n=De.getStreamFromFD(e);switch(r){case 0:return(o=De.get())<0?-28:ke.open(n.path,n.flags,0,o).fd;case 1:case 2:return 0;case 3:return n.flags;case 4:var o=De.get();return n.flags|=o,0;case 12:return o=De.get(),H[o+0>>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(e){return void 0!==ke&&e instanceof ke.ErrnoError||ae(e),-e.errno}},y:function(e,r){try{var t=De.getStreamFromFD(e);return De.doStat(ke.stat,t.path,r)}catch(e){return void 0!==ke&&e instanceof ke.ErrnoError||ae(e),-e.errno}},z:function(){return 0},x:function(e,r,t){De.varargs=t;try{var n=De.getStreamFromFD(e);switch(r){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 o=De.get();return L[o>>2]=0,0;case 21520:return n.tty?-28:-59;case 21531:return o=De.get(),ke.ioctl(n,r,o);case 21523:case 21524:return n.tty?0:-59;default:ae("bad ioctl syscall "+r)}}catch(e){return void 0!==ke&&e instanceof ke.ErrnoError||ae(e),-e.errno}},d:function(e,r,t){De.varargs=t;try{var n=De.getStr(e),o=De.get();return ke.open(n,r,o).fd}catch(e){return void 0!==ke&&e instanceof ke.ErrnoError||ae(e),-e.errno}},u:function(e,r,t){try{return e=De.getStr(e),De.doReadlink(e,r,t)}catch(e){return void 0!==ke&&e instanceof ke.ErrnoError||ae(e),-e.errno}},h:function(e,r){try{return e=De.getStr(e),De.doStat(ke.stat,e,r)}catch(e){return void 0!==ke&&e instanceof ke.ErrnoError||ae(e),-e.errno}},j:function(){ae()},q:function(e,r,t){U.copyWithin(e,r,r+t)},r:function(e){e>>>=0;var r=U.length;if(e>2147483648)return!1;for(var t,n,o=1;o<=4;o*=2){var a=r*(1+.2/o);if(a=Math.min(a,e+100663296),be(Math.min(2147483648,((t=Math.max(16777216,e,a))%(n=65536)>0&&(t+=n-t%n),t))))return!0}return!1},s:function(e,r){var t=0;return Fe().forEach(function(n,o){var a=r+t;L[e+4*o>>2]=a,function(e,r,t){for(var n=0;n<e.length;++n)I[r++>>0]=e.charCodeAt(n);t||(I[r>>0]=0)}(n,a),t+=n.length+1}),0},t:function(e,r){var t=Fe();L[e>>2]=t.length;var n=0;return t.forEach(function(e){n+=e.length+1}),L[r>>2]=n,0},b:function(e){},c:function(e){try{var r=De.getStreamFromFD(e);return ke.close(r),0}catch(e){return void 0!==ke&&e instanceof ke.ErrnoError||ae(e),e.errno}},i:function(e,r){try{var t=De.getStreamFromFD(e),n=t.tty?2:ke.isDir(t.mode)?3:ke.isLink(t.mode)?7:4;return I[r>>0]=n,0}catch(e){return void 0!==ke&&e instanceof ke.ErrnoError||ae(e),e.errno}},v:function(e,r,t,n){try{var o=De.getStreamFromFD(e),a=De.doReadv(o,r,t);return L[n>>2]=a,0}catch(e){return void 0!==ke&&e instanceof ke.ErrnoError||ae(e),e.errno}},p:function(e,r,t,n,o){try{var a=De.getStreamFromFD(e),i=4294967296*t+(r>>>0);return i<=-9007199254740992||i>=9007199254740992?-61:(ke.llseek(a,i,n),me=[a.position>>>0,(de=a.position,+K(de)>=1?de>0?(0|Q(+$(de/4294967296),4294967295))>>>0:~~+Z((de-+(~~de>>>0))/4294967296)>>>0:0)],L[o>>2]=me[0],L[o+4>>2]=me[1],a.getdents&&0===i&&0===n&&(a.getdents=null),0)}catch(e){return void 0!==ke&&e instanceof ke.ErrnoError||ae(e),e.errno}},f:function(e,r,t,n){try{var o=De.getStreamFromFD(e),a=De.doWritev(o,r,t);return L[n>>2]=a,0}catch(e){return void 0!==ke&&e instanceof ke.ErrnoError||ae(e),e.errno}},B:function(){throw"getpwuid: TODO"},m:function(e,r){var t=new Date(1e3*L[e>>2]);L[r>>2]=t.getUTCSeconds(),L[r+4>>2]=t.getUTCMinutes(),L[r+8>>2]=t.getUTCHours(),L[r+12>>2]=t.getUTCDate(),L[r+16>>2]=t.getUTCMonth(),L[r+20>>2]=t.getUTCFullYear()-1900,L[r+24>>2]=t.getUTCDay(),L[r+36>>2]=0,L[r+32>>2]=0;var n=Date.UTC(t.getUTCFullYear(),0,1,0,0,0,0),o=(t.getTime()-n)/864e5|0;return L[r+28>>2]=o,L[r+40>>2]=Me,r},l:function(e,r){Ae();var t=new Date(1e3*L[e>>2]);L[r>>2]=t.getSeconds(),L[r+4>>2]=t.getMinutes(),L[r+8>>2]=t.getHours(),L[r+12>>2]=t.getDate(),L[r+16>>2]=t.getMonth(),L[r+20>>2]=t.getFullYear()-1900,L[r+24>>2]=t.getDay();var n=new Date(t.getFullYear(),0,1),o=(t.getTime()-n.getTime())/864e5|0;L[r+28>>2]=o,L[r+36>>2]=-60*t.getTimezoneOffset();var a=new Date(t.getFullYear(),6,1).getTimezoneOffset(),i=n.getTimezoneOffset(),s=0|(a!=i&&t.getTimezoneOffset()==Math.min(i,a));L[r+32>>2]=s;var u=L[Ye()+(s?4:0)>>2];return L[r+40>>2]=u,r},memory:b,n:function(e){Ae();var r=new Date(L[e+20>>2]+1900,L[e+16>>2],L[e+12>>2],L[e+8>>2],L[e+4>>2],L[e>>2],0),t=L[e+32>>2],n=r.getTimezoneOffset(),o=new Date(r.getFullYear(),0,1),a=new Date(r.getFullYear(),6,1).getTimezoneOffset(),i=o.getTimezoneOffset(),s=Math.min(i,a);if(t<0)L[e+32>>2]=Number(a!=i&&s==n);else if(t>0!=(s==n)){var u=Math.max(i,a),c=t>0?s:u;r.setTime(r.getTime()+6e4*(c-n))}L[e+24>>2]=r.getDay();var f=(r.getTime()-o.getTime())/864e5|0;return L[e+28>>2]=f,r.getTime()/1e3|0},A:function(e,r){return function(e,r){switch(r){case 0:return 32e3;case 1:case 2:case 3:return 255;case 4:ca