-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwdosbox.js
5 lines (5 loc) · 79 KB
/
wdosbox.js
1
2
3
4
5
/**
* js-dos v7
* (c) 2023 Alexander Guryanov, https://github.com/caiiiycuk
*/
var WDOSBOX=(()=>{var mr="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0;return"undefined"!=typeof __filename&&(mr=mr||__filename),function(e){var t,a,c=void 0!==(e=e||{})?e:{};c.ready=new Promise(function(e,r){t=e,a=r});var r,y,n,o,s,i,u=Object.assign({},c),d=[],l="./this.program",f=(e,r)=>{throw r},p="object"==typeof window,m="function"==typeof importScripts,h="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,w="";h?(w=m?require("path").dirname(w)+"/":__dirname+"/",i=()=>{s||(o=require("fs"),s=require("path"))},r=function(e,r){return i(),e=s.normalize(e),o.readFileSync(e,r?void 0:"utf8")},n=e=>{e=r(e,!0);return e.buffer||(e=new Uint8Array(e)),e},y=(e,t,n)=>{i(),e=s.normalize(e),o.readFile(e,function(e,r){e?n(e):t(r.buffer)})},1<process.argv.length&&(l=process.argv[1].replace(/\\/g,"/")),d=process.argv.slice(2),process.on("uncaughtException",function(e){if(!(e instanceof cr))throw e}),process.on("unhandledRejection",function(e){throw e}),f=(e,r)=>{if($())throw process.exitCode=e,r;(r=r)instanceof cr||_("exiting due to exception: "+r),process.exit(e)},c.inspect=function(){return"[Emscripten Module object]"}):(p||m)&&(m?w=self.location.href:"undefined"!=typeof document&&document.currentScript&&(w=document.currentScript.src),mr&&(w=mr),w=0!==w.indexOf("blob:")?w.substr(0,w.replace(/[?#].*/,"").lastIndexOf("/")+1):"",r=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.send(null),r.responseText},m&&(n=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),y=(e,r,t)=>{var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=()=>{200==n.status||0==n.status&&n.response?r(n.response):t()},n.onerror=t,n.send(null)});var g,v=c.print||console.log.bind(console),_=c.printErr||console.warn.bind(console);Object.assign(c,u),c.arguments&&(d=c.arguments),c.thisProgram&&(l=c.thisProgram),c.quit&&(f=c.quit),c.wasmBinary&&(g=c.wasmBinary);var E,k=c.noExitRuntime||!1;"object"!=typeof WebAssembly&&oe("no native wasm support detected");var b,S=!1;function D(e,r){e||oe(r)}var F="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function M(e,r,t){for(var n=r+t,o=r;e[o]&&!(n<=o);)++o;if(16<o-r&&e.subarray&&F)return F.decode(e.subarray(r,o));for(var a="";r<o;){var s,i,u=e[r++];128&u?(s=63&e[r++],192!=(224&u)?(i=63&e[r++],(u=224==(240&u)?(15&u)<<12|s<<6|i:(7&u)<<18|s<<12|i<<6|63&e[r++])<65536?a+=String.fromCharCode(u):(i=u-65536,a+=String.fromCharCode(55296|i>>10,56320|1023&i))):a+=String.fromCharCode((31&u)<<6|s)):a+=String.fromCharCode(u)}return a}function A(e,r){return e?M(O,e,r):""}function P(e,r,t,n){if(!(0<n))return 0;for(var o=t,a=t+n-1,s=0;s<e.length;++s){var i=e.charCodeAt(s);if(55296<=i&&i<=57343&&(i=65536+((1023&i)<<10)|1023&e.charCodeAt(++s)),i<=127){if(a<=t)break;r[t++]=i}else if(i<=2047){if(a<=t+1)break;r[t++]=192|i>>6,r[t++]=128|63&i}else if(i<=65535){if(a<=t+2)break;r[t++]=224|i>>12,r[t++]=128|i>>6&63,r[t++]=128|63&i}else{if(a<=t+3)break;r[t++]=240|i>>18,r[t++]=128|i>>12&63,r[t++]=128|i>>6&63,r[t++]=128|63&i}}return r[t]=0,t-o}function x(e,r,t){return P(e,O,r,t)}function T(e){for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);55296<=n&&n<=57343&&(n=65536+((1023&n)<<10)|1023&e.charCodeAt(++t)),n<=127?++r:r+=n<=2047?2:n<=65535?3:4}return r}var R,z,O,C,N,B,U,I="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0;function H(e){var r=T(e)+1,t=er(r);return t&&P(e,z,t,r),t}function L(e){var r=T(e)+1,t=sr(r);return P(e,z,t,r),t}function j(e){R=e,c.HEAP8=z=new Int8Array(e),c.HEAP16=C=new Int16Array(e),c.HEAP32=B=new Int32Array(e),c.HEAPU8=O=new Uint8Array(e),c.HEAPU16=N=new Uint16Array(e),c.HEAPU32=new Uint32Array(e),c.HEAPF32=new Float32Array(e),c.HEAPF64=U=new Float64Array(e)}c.INITIAL_MEMORY;var q=[],W=[],Y=[],X=[],G=[],V=!1,K=0;function $(){return k||0<K}function Z(){if(c.preRun)for("function"==typeof c.preRun&&(c.preRun=[c.preRun]);c.preRun.length;)e=c.preRun.shift(),q.unshift(e);var e;me(q)}function J(){if(c.postRun)for("function"==typeof c.postRun&&(c.postRun=[c.postRun]);c.postRun.length;)e=c.postRun.shift(),G.unshift(e);var e;me(G)}var Q=0,ee=null,re=null;function te(e){Q++,c.monitorRunDependencies&&c.monitorRunDependencies(Q)}function ne(e){var r;Q--,c.monitorRunDependencies&&c.monitorRunDependencies(Q),0==Q&&(null!==ee&&(clearInterval(ee),ee=null),re&&(r=re,re=null,r()))}function oe(e){c.onAbort&&c.onAbort(e),_(e="Aborted("+e+")"),S=!0,b=1,e+=". Build with -s ASSERTIONS=1 for more info.";e=new WebAssembly.RuntimeError(e);throw a(e),e}c.preloadedImages={},c.preloadedAudios={};var ae,se,ie,ue,ce="data:application/octet-stream;base64,";function de(e){return e.startsWith(ce)}function le(e){return e.startsWith("file://")}function fe(e){try{if(e==ae&&g)return new Uint8Array(g);if(n)return n(e);throw"both async and sync fetching of the wasm failed"}catch(e){oe(e)}}de(ae="wdosbox.wasm")||(se=ae,ae=c.locateFile?c.locateFile(se,w):w+se);var pe={277716:function(){c.paused=!0},277744:function(){c.paused=!1},277773:function(){c.performance=c.performance||("object"==typeof performance?performance:Date)},277878:function(){c.screenIsReadOnly=!0},277913:function(e,r){c.websocket.url=A(e)+":"+r}};function me(e){for(;0<e.length;){var r,t=e.shift();"function"!=typeof t?"number"==typeof(r=t.func)?void 0===t.arg?ur.call(null,r):(n=t.arg,ir.apply(null,[r,n])):r(void 0===t.arg?null:t.arg):t(c)}var n}function he(e){if(e instanceof cr||"unwind"==e)return b;f(1,e)}var we={splitPath:function(e){return/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1)},normalizeArray:function(e,r){for(var t=0,n=e.length-1;0<=n;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=we.normalizeArray(e.split("/").filter(function(e){return!!e}),!r).join("/"))||r||(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:function(e){var r=we.splitPath(e),e=r[0],r=r[1];return e||r?e+(r=r&&r.substr(0,r.length-1)):"."},basename:function(e){if("/"===e)return"/";var r=(e=(e=we.normalize(e)).replace(/\/$/,"")).lastIndexOf("/");return-1===r?e:e.substr(r+1)},extname:function(e){return we.splitPath(e)[3]},join:function(){var e=Array.prototype.slice.call(arguments,0);return we.normalize(e.join("/"))},join2:function(e,r){return we.normalize(e+"/"+r)}},ye={resolve:function(){for(var e="",r=!1,t=arguments.length-1;-1<=t&&!r;t--){var n=0<=t?arguments[t]:Ee.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(r?"/":"")+(e=we.normalizeArray(e.split("/").filter(function(e){return!!e}),!r).join("/"))||"."},relative:function(e,r){function t(e){for(var r=0;r<e.length&&""===e[r];r++);for(var t=e.length-1;0<=t&&""===e[t];t--);return t<r?[]: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),s=a,i=0;i<a;i++)if(n[i]!==o[i]){s=i;break}for(var u=[],i=s;i<n.length;i++)u.push("..");return(u=u.concat(o.slice(s))).join("/")}},ge={ttys:[],init:function(){},shutdown:function(){},register:function(e,r){ge.ttys[e]={input:[],output:[],ops:r},Ee.registerDevice(e,ge.stream_ops)},stream_ops:{open:function(e){var r=ge.ttys[e.node.rdev];if(!r)throw new Ee.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 Ee.ErrnoError(60);for(var a,s=0,i=0;i<n;i++){try{a=e.tty.ops.get_char(e.tty)}catch(e){throw new Ee.ErrnoError(29)}if(void 0===a&&0===s)throw new Ee.ErrnoError(6);if(null==a)break;s++,r[t+i]=a}return s&&(e.node.timestamp=Date.now()),s},write:function(e,r,t,n,o){if(!e.tty||!e.tty.ops.put_char)throw new Ee.ErrnoError(60);try{for(var a=0;a<n;a++)e.tty.ops.put_char(e.tty,r[t+a])}catch(e){throw new Ee.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(h){var t=Buffer.alloc(256),n=0;try{n=o.readSync(process.stdin.fd,t,0,256,-1)}catch(e){if(!e.toString().includes("EOF"))throw e;n=0}r=0<n?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=$e(r,!0)}return e.input.shift()},put_char:function(e,r){null===r||10===r?(v(M(e.output,0)),e.output=[]):0!=r&&e.output.push(r)},flush:function(e){e.output&&0<e.output.length&&(v(M(e.output,0)),e.output=[])}},default_tty1_ops:{put_char:function(e,r){null===r||10===r?(_(M(e.output,0)),e.output=[]):0!=r&&e.output.push(r)},flush:function(e){e.output&&0<e.output.length&&(_(M(e.output,0)),e.output=[])}}};function ve(e,r){O.fill(0,e,e+r)}var _e={ops_table:null,mount:function(e){return _e.createNode(null,"/",16895,0)},createNode:function(e,r,t,n){if(Ee.isBlkdev(t)||Ee.isFIFO(t))throw new Ee.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:Ee.chrdev_stream_ops}});n=Ee.createNode(e,r,t,n);return Ee.isDir(n.mode)?(n.node_ops=_e.ops_table.dir.node,n.stream_ops=_e.ops_table.dir.stream,n.contents={}):Ee.isFile(n.mode)?(n.node_ops=_e.ops_table.file.node,n.stream_ops=_e.ops_table.file.stream,n.usedBytes=0,n.contents=null):Ee.isLink(n.mode)?(n.node_ops=_e.ops_table.link.node,n.stream_ops=_e.ops_table.link.stream):Ee.isChrdev(n.mode)&&(n.node_ops=_e.ops_table.chrdev.node,n.stream_ops=_e.ops_table.chrdev.stream),n.timestamp=Date.now(),e&&(e.contents[r]=n,e.timestamp=n.timestamp),n},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;r<=t||(r=Math.max(r,t*(t<1048576?2:1.125)>>>0),0!=t&&(r=Math.max(r,256)),t=e.contents,e.contents=new Uint8Array(r),0<e.usedBytes&&e.contents.set(t.subarray(0,e.usedBytes),0))},resizeFileStorage:function(e,r){var t;e.usedBytes!=r&&(0==r?(e.contents=null,e.usedBytes=0):(t=e.contents,e.contents=new Uint8Array(r),t&&e.contents.set(t.subarray(0,Math.min(r,e.usedBytes))),e.usedBytes=r))},node_ops:{getattr:function(e){var r={};return r.dev=Ee.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,Ee.isDir(e.mode)?r.size=4096:Ee.isFile(e.mode)?r.size=e.usedBytes:Ee.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 Ee.genericErrors[44]},mknod:function(e,r,t,n){return _e.createNode(e,r,t,n)},rename:function(e,r,t){if(Ee.isDir(e.mode)){var n;try{n=Ee.lookupNode(r,t)}catch(e){}if(n)for(var o in n.contents)throw new Ee.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=t,r.contents[t]=e,r.timestamp=e.parent.timestamp,e.parent=r},unlink:function(e,r){delete e.contents[r],e.timestamp=Date.now()},rmdir:function(e,r){for(var t in Ee.lookupNode(e,r).contents)throw new Ee.ErrnoError(55);delete e.contents[r],e.timestamp=Date.now()},readdir:function(e){var r,t=[".",".."];for(r in e.contents)e.contents.hasOwnProperty(r)&&t.push(r);return t},symlink:function(e,r,t){r=_e.createNode(e,r,41471,0);return r.link=t,r},readlink:function(e){if(!Ee.isLink(e.mode))throw new Ee.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 s=Math.min(e.node.usedBytes-o,n);if(8<s&&a.subarray)r.set(a.subarray(o,o+s),t);else for(var i=0;i<s;i++)r[t+i]=a[o+i];return s},write:function(e,r,t,n,o,a){if(r.buffer===z.buffer&&(a=!1),!n)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(t,t+n),s.usedBytes=n;if(0===s.usedBytes&&0===o)return s.contents=r.slice(t,t+n),s.usedBytes=n;if(o+n<=s.usedBytes)return s.contents.set(r.subarray(t,t+n),o),n}if(_e.expandFileStorage(s,o+n),s.contents.subarray&&r.subarray)s.contents.set(r.subarray(t,t+n),o);else for(var i=0;i<n;i++)s.contents[o+i]=r[t+i];return s.usedBytes=Math.max(s.usedBytes,o+n),n},llseek:function(e,r,t){if(1===t?r+=e.position:2===t&&Ee.isFile(e.node.mode)&&(r+=e.node.usedBytes),r<0)throw new Ee.ErrnoError(28);return r},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){if(0!==r)throw new Ee.ErrnoError(28);if(!Ee.isFile(e.node.mode))throw new Ee.ErrnoError(43);var s,i,e=e.node.contents;if(2&a||e.buffer!==R){if((0<n||n+t<e.length)&&(e=e.subarray?e.subarray(n,n+t):Array.prototype.slice.call(e,n,n+t)),i=!0,!(s=void oe()))throw new Ee.ErrnoError(48);z.set(e,s)}else i=!1,s=e.byteOffset;return{ptr:s,allocated:i}},msync:function(e,r,t,n,o){if(!Ee.isFile(e.node.mode))throw new Ee.ErrnoError(43);if(2&o)return 0;_e.stream_ops.write(e,r,0,n,t,!1);return 0}}};var Ee={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath:(e,r={})=>{if(!(e=ye.resolve(Ee.cwd(),e)))return{path:"",node:null};if(8<(r=Object.assign({follow_mount:!0,recurse_count:0},r)).recurse_count)throw new Ee.ErrnoError(32);for(var t=we.normalizeArray(e.split("/").filter(e=>!!e),!1),n=Ee.root,o="/",a=0;a<t.length;a++){var s=a===t.length-1;if(s&&r.parent)break;if(n=Ee.lookupNode(n,t[a]),o=we.join2(o,t[a]),Ee.isMountpoint(n)&&(!s||s&&r.follow_mount)&&(n=n.mounted.root),!s||r.follow)for(var i=0;Ee.isLink(n.mode);){var u=Ee.readlink(o),o=ye.resolve(we.dirname(o),u),n=Ee.lookupPath(o,{recurse_count:r.recurse_count+1}).node;if(40<i++)throw new Ee.ErrnoError(32)}}return{path:o,node:n}},getPath:e=>{for(var r;;){if(Ee.isRoot(e)){var t=e.mount.mountpoint;return r?"/"!==t[t.length-1]?t+"/"+r:t+r:t}r=r?e.name+"/"+r:e.name,e=e.parent}},hashName:(e,r)=>{for(var t=0,n=0;n<r.length;n++)t=(t<<5)-t+r.charCodeAt(n)|0;return(e+t>>>0)%Ee.nameTable.length},hashAddNode:e=>{var r=Ee.hashName(e.parent.id,e.name);e.name_next=Ee.nameTable[r],Ee.nameTable[r]=e},hashRemoveNode:e=>{var r=Ee.hashName(e.parent.id,e.name);if(Ee.nameTable[r]===e)Ee.nameTable[r]=e.name_next;else for(var t=Ee.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next}},lookupNode:(e,r)=>{var t=Ee.mayLookup(e);if(t)throw new Ee.ErrnoError(t,e);for(var t=Ee.hashName(e.id,r),n=Ee.nameTable[t];n;n=n.name_next){var o=n.name;if(n.parent.id===e.id&&o===r)return n}return Ee.lookup(e,r)},createNode:(e,r,t,n)=>{n=new Ee.FSNode(e,r,t,n);return Ee.hashAddNode(n),n},destroyNode:e=>{Ee.hashRemoveNode(e)},isRoot:e=>e===e.parent,isMountpoint:e=>!!e.mounted,isFile:e=>32768==(61440&e),isDir:e=>16384==(61440&e),isLink:e=>40960==(61440&e),isChrdev:e=>8192==(61440&e),isBlkdev:e=>24576==(61440&e),isFIFO:e=>4096==(61440&e),isSocket:e=>49152==(49152&e),flagModes:{r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},modeStringToFlags:e=>{var r=Ee.flagModes[e];if(void 0===r)throw new Error("Unknown file open mode: "+e);return r},flagsToPermissionString:e=>{var r=["r","w","rw"][3&e];return 512&e&&(r+="w"),r},nodePermissions:(e,r)=>Ee.ignorePermissions||(!r.includes("r")||292&e.mode)&&(!r.includes("w")||146&e.mode)&&(!r.includes("x")||73&e.mode)?0:2,mayLookup:e=>{var r=Ee.nodePermissions(e,"x");return r||(e.node_ops.lookup?0:2)},mayCreate:(e,r)=>{try{Ee.lookupNode(e,r);return 20}catch(e){}return Ee.nodePermissions(e,"wx")},mayDelete:(e,r,t)=>{var n;try{n=Ee.lookupNode(e,r)}catch(e){return e.errno}var o=Ee.nodePermissions(e,"wx");if(o)return o;if(t){if(!Ee.isDir(n.mode))return 54;if(Ee.isRoot(n)||Ee.getPath(n)===Ee.cwd())return 10}else if(Ee.isDir(n.mode))return 31;return 0},mayOpen:(e,r)=>e?Ee.isLink(e.mode)?32:Ee.isDir(e.mode)&&("r"!==Ee.flagsToPermissionString(r)||512&r)?31:Ee.nodePermissions(e,Ee.flagsToPermissionString(r)):44,MAX_OPEN_FDS:4096,nextfd:(e=0,r=Ee.MAX_OPEN_FDS)=>{for(var t=e;t<=r;t++)if(!Ee.streams[t])return t;throw new Ee.ErrnoError(33)},getStream:e=>Ee.streams[e],createStream:(e,r,t)=>{Ee.FSStream||(Ee.FSStream=function(){},Ee.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}}}),e=Object.assign(new Ee.FSStream,e);t=Ee.nextfd(r,t);return e.fd=t,Ee.streams[t]=e},closeStream:e=>{Ee.streams[e]=null},chrdev_stream_ops:{open:e=>{var r=Ee.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:()=>{throw new Ee.ErrnoError(70)}},major:e=>e>>8,minor:e=>255&e,makedev:(e,r)=>e<<8|r,registerDevice:(e,r)=>{Ee.devices[e]={stream_ops:r}},getDevice:e=>Ee.devices[e],getMounts:e=>{for(var r=[],t=[e];t.length;){var n=t.pop();r.push(n),t.push.apply(t,n.mounts)}return r},syncfs:(r,t)=>{"function"==typeof r&&(t=r,r=!1),Ee.syncFSRequests++,1<Ee.syncFSRequests&&_("warning: "+Ee.syncFSRequests+" FS.syncfs operations in flight at once, probably just doing extra work");var n=Ee.getMounts(Ee.root.mount),o=0;function a(e){return Ee.syncFSRequests--,t(e)}function s(e){if(e)return s.errored?void 0:(s.errored=!0,a(e));++o>=n.length&&a(null)}n.forEach(e=>e.type.syncfs?void e.type.syncfs(e,r,s):s(null))},mount:(e,r,t)=>{var n="/"===t,o=!t;if(n&&Ee.root)throw new Ee.ErrnoError(10);if(!n&&!o){var a=Ee.lookupPath(t,{follow_mount:!1});if(t=a.path,a=a.node,Ee.isMountpoint(a))throw new Ee.ErrnoError(10);if(!Ee.isDir(a.mode))throw new Ee.ErrnoError(54)}t={type:e,opts:r,mountpoint:t,mounts:[]},e=e.mount(t);return(e.mount=t).root=e,n?Ee.root=e:a&&(a.mounted=t,a.mount&&a.mount.mounts.push(t)),e},unmount:e=>{var r=Ee.lookupPath(e,{follow_mount:!1});if(!Ee.isMountpoint(r.node))throw new Ee.ErrnoError(28);var e=r.node,r=e.mounted,n=Ee.getMounts(r);Object.keys(Ee.nameTable).forEach(e=>{for(var r=Ee.nameTable[e];r;){var t=r.name_next;n.includes(r.mount)&&Ee.destroyNode(r),r=t}}),e.mounted=null;r=e.mount.mounts.indexOf(r);e.mount.mounts.splice(r,1)},lookup:(e,r)=>e.node_ops.lookup(e,r),mknod:(e,r,t)=>{var n=Ee.lookupPath(e,{parent:!0}).node,o=we.basename(e);if(!o||"."===o||".."===o)throw new Ee.ErrnoError(28);e=Ee.mayCreate(n,o);if(e)throw new Ee.ErrnoError(e);if(!n.node_ops.mknod)throw new Ee.ErrnoError(63);return n.node_ops.mknod(n,o,r,t)},create:(e,r)=>(r=void 0!==r?r:438,r&=4095,r|=32768,Ee.mknod(e,r,0)),mkdir:(e,r)=>(r=void 0!==r?r:511,r&=1023,r|=16384,Ee.mknod(e,r,0)),mkdirTree:(e,r)=>{for(var t=e.split("/"),n="",o=0;o<t.length;++o)if(t[o]){n+="/"+t[o];try{Ee.mkdir(n,r)}catch(e){if(20!=e.errno)throw e}}},mkdev:(e,r,t)=>(void 0===t&&(t=r,r=438),r|=8192,Ee.mknod(e,r,t)),symlink:(e,r)=>{if(!ye.resolve(e))throw new Ee.ErrnoError(44);var t=Ee.lookupPath(r,{parent:!0}).node;if(!t)throw new Ee.ErrnoError(44);var n=we.basename(r),r=Ee.mayCreate(t,n);if(r)throw new Ee.ErrnoError(r);if(!t.node_ops.symlink)throw new Ee.ErrnoError(63);return t.node_ops.symlink(t,n,e)},rename:(e,r)=>{var t=we.dirname(e),n=we.dirname(r),o=we.basename(e),a=we.basename(r),s=Ee.lookupPath(e,{parent:!0}),i=s.node,u=Ee.lookupPath(r,{parent:!0}).node;if(!i||!u)throw new Ee.ErrnoError(44);if(i.mount!==u.mount)throw new Ee.ErrnoError(75);var c,d=Ee.lookupNode(i,o),n=ye.relative(e,n);if("."!==n.charAt(0))throw new Ee.ErrnoError(28);if("."!==(n=ye.relative(r,t)).charAt(0))throw new Ee.ErrnoError(55);try{c=Ee.lookupNode(u,a)}catch(e){}if(d!==c){n=Ee.isDir(d.mode),o=Ee.mayDelete(i,o,n);if(o)throw new Ee.ErrnoError(o);if(o=c?Ee.mayDelete(u,a,n):Ee.mayCreate(u,a))throw new Ee.ErrnoError(o);if(!i.node_ops.rename)throw new Ee.ErrnoError(63);if(Ee.isMountpoint(d)||c&&Ee.isMountpoint(c))throw new Ee.ErrnoError(10);if(u!==i&&(o=Ee.nodePermissions(i,"w")))throw new Ee.ErrnoError(o);Ee.hashRemoveNode(d);try{i.node_ops.rename(d,u,a)}catch(e){throw e}finally{Ee.hashAddNode(d)}}},rmdir:e=>{var r=Ee.lookupPath(e,{parent:!0}).node,t=we.basename(e),n=Ee.lookupNode(r,t),e=Ee.mayDelete(r,t,!0);if(e)throw new Ee.ErrnoError(e);if(!r.node_ops.rmdir)throw new Ee.ErrnoError(63);if(Ee.isMountpoint(n))throw new Ee.ErrnoError(10);r.node_ops.rmdir(r,t),Ee.destroyNode(n)},readdir:e=>{e=Ee.lookupPath(e,{follow:!0}).node;if(!e.node_ops.readdir)throw new Ee.ErrnoError(54);return e.node_ops.readdir(e)},unlink:e=>{var r=Ee.lookupPath(e,{parent:!0}).node;if(!r)throw new Ee.ErrnoError(44);var t=we.basename(e),n=Ee.lookupNode(r,t),e=Ee.mayDelete(r,t,!1);if(e)throw new Ee.ErrnoError(e);if(!r.node_ops.unlink)throw new Ee.ErrnoError(63);if(Ee.isMountpoint(n))throw new Ee.ErrnoError(10);r.node_ops.unlink(r,t),Ee.destroyNode(n)},readlink:e=>{e=Ee.lookupPath(e).node;if(!e)throw new Ee.ErrnoError(44);if(!e.node_ops.readlink)throw new Ee.ErrnoError(28);return ye.resolve(Ee.getPath(e.parent),e.node_ops.readlink(e))},stat:(e,r)=>{r=Ee.lookupPath(e,{follow:!r}).node;if(!r)throw new Ee.ErrnoError(44);if(!r.node_ops.getattr)throw new Ee.ErrnoError(63);return r.node_ops.getattr(r)},lstat:e=>Ee.stat(e,!0),chmod:(e,r,t)=>{if(!(e="string"==typeof e?Ee.lookupPath(e,{follow:!t}).node:e).node_ops.setattr)throw new Ee.ErrnoError(63);e.node_ops.setattr(e,{mode:4095&r|-4096&e.mode,timestamp:Date.now()})},lchmod:(e,r)=>{Ee.chmod(e,r,!0)},fchmod:(e,r)=>{e=Ee.getStream(e);if(!e)throw new Ee.ErrnoError(8);Ee.chmod(e.node,r)},chown:(e,r,t,n)=>{if(!(e="string"==typeof e?Ee.lookupPath(e,{follow:!n}).node:e).node_ops.setattr)throw new Ee.ErrnoError(63);e.node_ops.setattr(e,{timestamp:Date.now()})},lchown:(e,r,t)=>{Ee.chown(e,r,t,!0)},fchown:(e,r,t)=>{e=Ee.getStream(e);if(!e)throw new Ee.ErrnoError(8);Ee.chown(e.node,r,t)},truncate:(e,r)=>{if(r<0)throw new Ee.ErrnoError(28);var t;if(!(t="string"==typeof e?Ee.lookupPath(e,{follow:!0}).node:e).node_ops.setattr)throw new Ee.ErrnoError(63);if(Ee.isDir(t.mode))throw new Ee.ErrnoError(31);if(!Ee.isFile(t.mode))throw new Ee.ErrnoError(28);e=Ee.nodePermissions(t,"w");if(e)throw new Ee.ErrnoError(e);t.node_ops.setattr(t,{size:r,timestamp:Date.now()})},ftruncate:(e,r)=>{e=Ee.getStream(e);if(!e)throw new Ee.ErrnoError(8);if(0==(2097155&e.flags))throw new Ee.ErrnoError(28);Ee.truncate(e.node,r)},utime:(e,r,t)=>{e=Ee.lookupPath(e,{follow:!0}).node;e.node_ops.setattr(e,{timestamp:Math.max(r,t)})},open:(e,r,t,n,o)=>{if(""===e)throw new Ee.ErrnoError(44);if(t=void 0===t?438:t,t=64&(r="string"==typeof r?Ee.modeStringToFlags(r):r)?4095&t|32768:0,"object"==typeof e)a=e;else{e=we.normalize(e);try{var a=Ee.lookupPath(e,{follow:!(131072&r)}).node}catch(e){}}var s=!1;if(64&r)if(a){if(128&r)throw new Ee.ErrnoError(20)}else a=Ee.mknod(e,t,0),s=!0;if(!a)throw new Ee.ErrnoError(44);if(Ee.isChrdev(a.mode)&&(r&=-513),65536&r&&!Ee.isDir(a.mode))throw new Ee.ErrnoError(54);if(!s){s=Ee.mayOpen(a,r);if(s)throw new Ee.ErrnoError(s)}512&r&&Ee.truncate(a,0),r&=-131713;o=Ee.createStream({node:a,path:Ee.getPath(a),flags:r,seekable:!0,position:0,stream_ops:a.stream_ops,ungotten:[],error:!1},n,o);return o.stream_ops.open&&o.stream_ops.open(o),!c.logReadFiles||1&r||(Ee.readFiles||(Ee.readFiles={}),e in Ee.readFiles||(Ee.readFiles[e]=1)),o},close:e=>{if(Ee.isClosed(e))throw new Ee.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(e){throw e}finally{Ee.closeStream(e.fd)}e.fd=null},isClosed:e=>null===e.fd,llseek:(e,r,t)=>{if(Ee.isClosed(e))throw new Ee.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new Ee.ErrnoError(70);if(0!=t&&1!=t&&2!=t)throw new Ee.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read:(e,r,t,n,o)=>{if(n<0||o<0)throw new Ee.ErrnoError(28);if(Ee.isClosed(e))throw new Ee.ErrnoError(8);if(1==(2097155&e.flags))throw new Ee.ErrnoError(8);if(Ee.isDir(e.node.mode))throw new Ee.ErrnoError(31);if(!e.stream_ops.read)throw new Ee.ErrnoError(28);var a=void 0!==o;if(a){if(!e.seekable)throw new Ee.ErrnoError(70)}else o=e.position;o=e.stream_ops.read(e,r,t,n,o);return a||(e.position+=o),o},write:(e,r,t,n,o,a)=>{if(n<0||o<0)throw new Ee.ErrnoError(28);if(Ee.isClosed(e))throw new Ee.ErrnoError(8);if(0==(2097155&e.flags))throw new Ee.ErrnoError(8);if(Ee.isDir(e.node.mode))throw new Ee.ErrnoError(31);if(!e.stream_ops.write)throw new Ee.ErrnoError(28);e.seekable&&1024&e.flags&&Ee.llseek(e,0,2);var s=void 0!==o;if(s){if(!e.seekable)throw new Ee.ErrnoError(70)}else o=e.position;a=e.stream_ops.write(e,r,t,n,o,a);return s||(e.position+=a),a},allocate:(e,r,t)=>{if(Ee.isClosed(e))throw new Ee.ErrnoError(8);if(r<0||t<=0)throw new Ee.ErrnoError(28);if(0==(2097155&e.flags))throw new Ee.ErrnoError(8);if(!Ee.isFile(e.node.mode)&&!Ee.isDir(e.node.mode))throw new Ee.ErrnoError(43);if(!e.stream_ops.allocate)throw new Ee.ErrnoError(138);e.stream_ops.allocate(e,r,t)},mmap:(e,r,t,n,o,a)=>{if(0!=(2&o)&&0==(2&a)&&2!=(2097155&e.flags))throw new Ee.ErrnoError(2);if(1==(2097155&e.flags))throw new Ee.ErrnoError(2);if(!e.stream_ops.mmap)throw new Ee.ErrnoError(43);return e.stream_ops.mmap(e,r,t,n,o,a)},msync:(e,r,t,n,o)=>e&&e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,o):0,munmap:e=>0,ioctl:(e,r,t)=>{if(!e.stream_ops.ioctl)throw new Ee.ErrnoError(59);return e.stream_ops.ioctl(e,r,t)},readFile:(e,r={})=>{if(r.flags=r.flags||0,r.encoding=r.encoding||"binary","utf8"!==r.encoding&&"binary"!==r.encoding)throw new Error('Invalid encoding type "'+r.encoding+'"');var t,n=Ee.open(e,r.flags),o=Ee.stat(e).size,e=new Uint8Array(o);return Ee.read(n,e,0,o,0),"utf8"===r.encoding?t=M(e,0):"binary"===r.encoding&&(t=e),Ee.close(n),t},writeFile:(e,r,t={})=>{t.flags=t.flags||577;var n=Ee.open(e,t.flags,t.mode);if("string"==typeof r){var o=new Uint8Array(T(r)+1),e=P(r,o,0,o.length);Ee.write(n,o,0,e,void 0,t.canOwn)}else{if(!ArrayBuffer.isView(r))throw new Error("Unsupported data type");Ee.write(n,r,0,r.byteLength,void 0,t.canOwn)}Ee.close(n)},cwd:()=>Ee.currentPath,chdir:e=>{var r=Ee.lookupPath(e,{follow:!0});if(null===r.node)throw new Ee.ErrnoError(44);if(!Ee.isDir(r.node.mode))throw new Ee.ErrnoError(54);e=Ee.nodePermissions(r.node,"x");if(e)throw new Ee.ErrnoError(e);Ee.currentPath=r.path},createDefaultDirectories:()=>{Ee.mkdir("/tmp"),Ee.mkdir("/home"),Ee.mkdir("/home/web_user")},createDefaultDevices:()=>{Ee.mkdir("/dev"),Ee.registerDevice(Ee.makedev(1,3),{read:()=>0,write:(e,r,t,n,o)=>n}),Ee.mkdev("/dev/null",Ee.makedev(1,3)),ge.register(Ee.makedev(5,0),ge.default_tty_ops),ge.register(Ee.makedev(6,0),ge.default_tty1_ops),Ee.mkdev("/dev/tty",Ee.makedev(5,0)),Ee.mkdev("/dev/tty1",Ee.makedev(6,0));var e=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var e=new Uint8Array(1);return function(){return crypto.getRandomValues(e),e[0]}}if(h)try{var r=require("crypto");return function(){return r.randomBytes(1)[0]}}catch(e){}return function(){oe("randomDevice")}}();Ee.createDevice("/dev","random",e),Ee.createDevice("/dev","urandom",e),Ee.mkdir("/dev/shm"),Ee.mkdir("/dev/shm/tmp")},createSpecialDirectories:()=>{Ee.mkdir("/proc");var r=Ee.mkdir("/proc/self");Ee.mkdir("/proc/self/fd"),Ee.mount({mount:()=>{var e=Ee.createNode(r,"fd",16895,73);return e.node_ops={lookup:(e,r)=>{var r=+r,t=Ee.getStream(r);if(!t)throw new Ee.ErrnoError(8);r={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>t.path}};return r.parent=r}},e}},{},"/proc/self/fd")},createStandardStreams:()=>{c.stdin?Ee.createDevice("/dev","stdin",c.stdin):Ee.symlink("/dev/tty","/dev/stdin"),c.stdout?Ee.createDevice("/dev","stdout",null,c.stdout):Ee.symlink("/dev/tty","/dev/stdout"),c.stderr?Ee.createDevice("/dev","stderr",null,c.stderr):Ee.symlink("/dev/tty1","/dev/stderr");Ee.open("/dev/stdin",0),Ee.open("/dev/stdout",1),Ee.open("/dev/stderr",1)},ensureErrnoError:()=>{Ee.ErrnoError||(Ee.ErrnoError=function(e,r){this.node=r,this.setErrno=function(e){this.errno=e},this.setErrno(e),this.message="FS error"},Ee.ErrnoError.prototype=new Error,Ee.ErrnoError.prototype.constructor=Ee.ErrnoError,[44].forEach(e=>{Ee.genericErrors[e]=new Ee.ErrnoError(e),Ee.genericErrors[e].stack="<generic error, no stack>"}))},staticInit:()=>{Ee.ensureErrnoError(),Ee.nameTable=new Array(4096),Ee.mount(_e,{},"/"),Ee.createDefaultDirectories(),Ee.createDefaultDevices(),Ee.createSpecialDirectories(),Ee.filesystems={MEMFS:_e}},init:(e,r,t)=>{Ee.init.initialized=!0,Ee.ensureErrnoError(),c.stdin=e||c.stdin,c.stdout=r||c.stdout,c.stderr=t||c.stderr,Ee.createStandardStreams()},quit:()=>{Ee.init.initialized=!1,tr();for(var e=0;e<Ee.streams.length;e++){var r=Ee.streams[e];r&&Ee.close(r)}},getMode:(e,r)=>{var t=0;return e&&(t|=365),r&&(t|=146),t},findObject:(e,r)=>{r=Ee.analyzePath(e,r);return r.exists?r.object:null},analyzePath:(e,r)=>{try{e=(n=Ee.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=Ee.lookupPath(e,{parent:!0});t.parentExists=!0,t.parentPath=n.path,t.parentObject=n.node,t.name=we.basename(e),n=Ee.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},createPath:(e,r,t,n)=>{e="string"==typeof e?e:Ee.getPath(e);for(var o=r.split("/").reverse();o.length;){var a=o.pop();if(a){var s=we.join2(e,a);try{Ee.mkdir(s)}catch(e){}e=s}}return s},createFile:(e,r,t,n,o)=>{r=we.join2("string"==typeof e?e:Ee.getPath(e),r),o=Ee.getMode(n,o);return Ee.create(r,o)},createDataFile:(e,r,t,n,o,a)=>{var s=r;e&&(e="string"==typeof e?e:Ee.getPath(e),s=r?we.join2(e,r):e);n=Ee.getMode(n,o),o=Ee.create(s,n);if(t){if("string"==typeof t){for(var i=new Array(t.length),u=0,c=t.length;u<c;++u)i[u]=t.charCodeAt(u);t=i}Ee.chmod(o,146|n);s=Ee.open(o,577);Ee.write(s,t,0,t.length,0,a),Ee.close(s),Ee.chmod(o,n)}return o},createDevice:(e,r,u,s)=>{var t=we.join2("string"==typeof e?e:Ee.getPath(e),r),e=Ee.getMode(!!u,!!s);Ee.createDevice.major||(Ee.createDevice.major=64);r=Ee.makedev(Ee.createDevice.major++,0);return Ee.registerDevice(r,{open:e=>{e.seekable=!1},close:e=>{s&&s.buffer&&s.buffer.length&&s(10)},read:(e,r,t,n,o)=>{for(var a,s=0,i=0;i<n;i++){try{a=u()}catch(e){throw new Ee.ErrnoError(29)}if(void 0===a&&0===s)throw new Ee.ErrnoError(6);if(null==a)break;s++,r[t+i]=a}return s&&(e.node.timestamp=Date.now()),s},write:(e,r,t,n,o)=>{for(var a=0;a<n;a++)try{s(r[t+a])}catch(e){throw new Ee.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),a}}),Ee.mkdev(t,e,r)},forceLoadFile:e=>{if(e.isDevice||e.isFolder||e.link||e.contents)return!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(!r)throw new Error("Cannot load without read() or XMLHttpRequest.");try{e.contents=$e(r(e.url),!0),e.usedBytes=e.contents.length}catch(e){throw new Ee.ErrnoError(29)}},createLazyFile:(e,r,s,t,n)=>{function o(){this.lengthKnown=!1,this.chunks=[]}if(o.prototype.get=function(e){if(!(e>this.length-1||e<0)){var r=e%this.chunkSize,e=e/this.chunkSize|0;return this.getter(e)[r]}},o.prototype.setDataGetter=function(e){this.getter=e},o.prototype.cacheLength=function(){var e=new XMLHttpRequest;if(e.open("HEAD",s,!1),e.send(null),!(200<=e.status&&e.status<300||304===e.status))throw new Error("Couldn't load "+s+". Status: "+e.status);var n=Number(e.getResponseHeader("Content-length")),r=(t=e.getResponseHeader("Accept-Ranges"))&&"bytes"===t,t=(t=e.getResponseHeader("Content-Encoding"))&&"gzip"===t,o=1048576;r||(o=n);var a=this;a.setDataGetter(e=>{var r=e*o,t=(e+1)*o-1,t=Math.min(t,n-1);if(void 0===a.chunks[e]&&(a.chunks[e]=((e,r)=>{if(r<e)throw new Error("invalid range ("+e+", "+r+") or no bytes requested!");if(n-1<r)throw new Error("only "+n+" bytes available! programmer error!");var t=new XMLHttpRequest;if(t.open("GET",s,!1),n!==o&&t.setRequestHeader("Range","bytes="+e+"-"+r),t.responseType="arraybuffer",t.overrideMimeType&&t.overrideMimeType("text/plain; charset=x-user-defined"),t.send(null),!(200<=t.status&&t.status<300||304===t.status))throw new Error("Couldn't load "+s+". Status: "+t.status);return void 0!==t.response?new Uint8Array(t.response||[]):$e(t.responseText||"",!0)})(r,t)),void 0===a.chunks[e])throw new Error("doXHR failed!");return a.chunks[e]}),!t&&n||(o=n=1,n=this.getter(0).length,o=n,v("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=n,this._chunkSize=o,this.lengthKnown=!0},"undefined"!=typeof XMLHttpRequest){if(!m)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var a=new o;Object.defineProperties(a,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});a={isDevice:!1,contents:a}}else a={isDevice:!1,url:s};var u=Ee.createFile(e,r,a,t,n);a.contents?u.contents=a.contents:a.url&&(u.contents=null,u.url=a.url),Object.defineProperties(u,{usedBytes:{get:function(){return this.contents.length}}});var i={};return Object.keys(u.stream_ops).forEach(e=>{var r=u.stream_ops[e];i[e]=function(){return Ee.forceLoadFile(u),r.apply(null,arguments)}}),i.read=(e,r,t,n,o)=>{Ee.forceLoadFile(u);var a=e.node.contents;if(o>=a.length)return 0;var s=Math.min(a.length-o,n);if(a.slice)for(var i=0;i<s;i++)r[t+i]=a[o+i];else for(i=0;i<s;i++)r[t+i]=a.get(o+i);return s},u.stream_ops=i,u},createPreloadedFile:(t,n,e,o,a,s,i,u,c,d)=>{var r,l,f,p,m,h=n?ye.resolve(we.join2(t,n)):t;function w(e){function r(e){d&&d(),u||Ee.createDataFile(t,n,e,o,a,c),s&&s(),ne()}Browser.handledByPreloadPlugin(e,h,r,()=>{i&&i(),ne()})||r(e)}te(),"string"==typeof e?(r=e,l=e=>w(e),f=i,m=p?"":"al "+r,y(r,function(e){D(e,'Loading data file "'+r+'" failed (no arrayBuffer).'),l(new Uint8Array(e)),m&&ne()},function(e){if(!f)throw'Loading data file "'+r+'" failed.';f()}),m&&te()):w(e)},indexedDB:()=>window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB,DB_NAME:()=>"EM_FS_"+window.location.pathname,DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:(s,i,u)=>{i=i||(()=>{}),u=u||(()=>{});var e=Ee.indexedDB();try{var c=e.open(Ee.DB_NAME(),Ee.DB_VERSION)}catch(e){return u(e)}c.onupgradeneeded=()=>{v("creating db"),c.result.createObjectStore(Ee.DB_STORE_NAME)},c.onsuccess=()=>{var e=c.result.transaction([Ee.DB_STORE_NAME],"readwrite"),r=e.objectStore(Ee.DB_STORE_NAME),t=0,n=0,o=s.length;function a(){(0==n?i:u)()}s.forEach(e=>{e=r.put(Ee.analyzePath(e).object.contents,e);e.onsuccess=()=>{++t+n==o&&a()},e.onerror=()=>{t+ ++n==o&&a()}}),e.onerror=u},c.onerror=u},loadFilesFromDB:(i,u,c)=>{u=u||(()=>{}),c=c||(()=>{});var e=Ee.indexedDB();try{var d=e.open(Ee.DB_NAME(),Ee.DB_VERSION)}catch(e){return c(e)}d.onupgradeneeded=c,d.onsuccess=()=>{var e=d.result;try{var r=e.transaction([Ee.DB_STORE_NAME],"readonly")}catch(e){return void c(e)}var t=r.objectStore(Ee.DB_STORE_NAME),n=0,o=0,a=i.length;function s(){(0==o?u:c)()}i.forEach(e=>{var r=t.get(e);r.onsuccess=()=>{Ee.analyzePath(e).exists&&Ee.unlink(e),Ee.createDataFile(we.dirname(e),we.basename(e),r.result,!0,!0,!0),++n+o==a&&s()},r.onerror=()=>{n+ ++o==a&&s()}}),r.onerror=c},d.onerror=c}},ke={mount:function(e){return c.websocket=c.websocket&&"object"==typeof c.websocket?c.websocket:{},c.websocket._callbacks={},c.websocket.on=function(e,r){return"function"==typeof r&&(this._callbacks[e]=r),this},c.websocket.emit=function(e,r){"function"==typeof this._callbacks[e]&&this._callbacks[e].call(this,r)},Ee.createNode(null,"/",16895,0)},createSocket:function(e,r,t){r&=-526337,t&&D(1==r==(6==t));e={family:e,type:r,protocol:t,server:null,error:null,peers:{},pending:[],recv_queue:[],sock_ops:ke.websocket_sock_ops},r=ke.nextname(),t=Ee.createNode(ke.root,r,49152,0);t.sock=e;t=Ee.createStream({path:r,node:t,flags:2,seekable:!1,stream_ops:ke.stream_ops});return e.stream=t,e},getSocket:function(e){e=Ee.getStream(e);return e&&Ee.isSocket(e.node.mode)?e.node.sock:null},stream_ops:{poll:function(e){e=e.node.sock;return e.sock_ops.poll(e)},ioctl:function(e,r,t){e=e.node.sock;return e.sock_ops.ioctl(e,r,t)},read:function(e,r,t,n,o){e=e.node.sock,n=e.sock_ops.recvmsg(e,n);return n?(r.set(n.buffer,t),n.buffer.length):0},write:function(e,r,t,n,o){e=e.node.sock;return e.sock_ops.sendmsg(e,r,t,n)},close:function(e){e=e.node.sock;e.sock_ops.close(e)}},nextname:function(){return ke.nextname.current||(ke.nextname.current=0),"socket["+ke.nextname.current+++"]"},websocket_sock_ops:{createPeer:function(e,r,t){var n;if("object"==typeof r&&(n=r,t=r=null),n)if(n._socket)r=n._socket.remoteAddress,t=n._socket.remotePort;else{var o=/ws[s]?:\/\/([^:]+):(\d+)/.exec(n.url);if(!o)throw new Error("WebSocket URL must be in the format ws(s)://address:port");r=o[1],t=parseInt(o[2],10)}else try{var a=c.websocket&&"object"==typeof c.websocket,s="ws:#".replace("#","//");a&&"string"==typeof c.websocket.url&&(s=c.websocket.url),"ws://"!==s&&"wss://"!==s||(s=s+(u=r.split("/"))[0]+":"+t+"/"+u.slice(1).join("/"));var i="binary";a&&"string"==typeof c.websocket.subprotocol&&(i=c.websocket.subprotocol);var u=void 0;"null"!==i&&(i=i.replace(/^ +| +$/g,"").split(/ *, */),u=h?{protocol:i.toString()}:i),a&&null===c.websocket.subprotocol&&(i="null",u=void 0),(n=new(h?require("ws"):WebSocket)(s,u)).binaryType="arraybuffer"}catch(e){throw new Ee.ErrnoError(23)}o={addr:r,port:t,socket:n,dgram_send_queue:[]};return ke.websocket_sock_ops.addPeer(e,o),ke.websocket_sock_ops.handlePeerEvents(e,o),2===e.type&&void 0!==e.sport&&o.dgram_send_queue.push(new Uint8Array([255,255,255,255,"p".charCodeAt(0),"o".charCodeAt(0),"r".charCodeAt(0),"t".charCodeAt(0),(65280&e.sport)>>8,255&e.sport])),o},getPeer:function(e,r,t){return e.peers[r+":"+t]},addPeer:function(e,r){e.peers[r.addr+":"+r.port]=r},removePeer:function(e,r){delete e.peers[r.addr+":"+r.port]},handlePeerEvents:function(t,n){function e(){c.websocket.emit("open",t.stream.fd);try{for(var e=n.dgram_send_queue.shift();e;)n.socket.send(e),e=n.dgram_send_queue.shift()}catch(e){n.socket.close()}}var o=!0;function a(e){if("string"==typeof e)e=(new TextEncoder).encode(e);else{if(D(void 0!==e.byteLength),0==e.byteLength)return;e=new Uint8Array(e)}var r=o;if(o=!1,r&&10===e.length&&255===e[0]&&255===e[1]&&255===e[2]&&255===e[3]&&e[4]==="p".charCodeAt(0)&&e[5]==="o".charCodeAt(0)&&e[6]==="r".charCodeAt(0)&&e[7]==="t".charCodeAt(0)){r=e[8]<<8|e[9];return ke.websocket_sock_ops.removePeer(t,n),n.port=r,void ke.websocket_sock_ops.addPeer(t,n)}t.recv_queue.push({addr:n.addr,port:n.port,data:e}),c.websocket.emit("message",t.stream.fd)}h?(n.socket.on("open",e),n.socket.on("message",function(e,r){r.binary&&a(new Uint8Array(e).buffer)}),n.socket.on("close",function(){c.websocket.emit("close",t.stream.fd)}),n.socket.on("error",function(e){t.error=14,c.websocket.emit("error",[t.stream.fd,t.error,"ECONNREFUSED: Connection refused"])})):(n.socket.onopen=e,n.socket.onclose=function(){c.websocket.emit("close",t.stream.fd)},n.socket.onmessage=function(e){a(e.data)},n.socket.onerror=function(e){t.error=14,c.websocket.emit("error",[t.stream.fd,t.error,"ECONNREFUSED: Connection refused"])})},poll:function(e){if(1===e.type&&e.server)return e.pending.length?65:0;var r=0,t=1===e.type?ke.websocket_sock_ops.getPeer(e,e.daddr,e.dport):null;return(e.recv_queue.length||!t||t&&t.socket.readyState===t.socket.CLOSING||t&&t.socket.readyState===t.socket.CLOSED)&&(r|=65),(!t||t&&t.socket.readyState===t.socket.OPEN)&&(r|=4),(t&&t.socket.readyState===t.socket.CLOSING||t&&t.socket.readyState===t.socket.CLOSED)&&(r|=16),r},ioctl:function(e,r,t){if(21531!==r)return 28;r=0;return e.recv_queue.length&&(r=e.recv_queue[0].data.length),B[t>>2]=r,0},close:function(e){if(e.server){try{e.server.close()}catch(e){}e.server=null}for(var r=Object.keys(e.peers),t=0;t<r.length;t++){var n=e.peers[r[t]];try{n.socket.close()}catch(e){}ke.websocket_sock_ops.removePeer(e,n)}return 0},bind:function(e,r,t){if(void 0!==e.saddr||void 0!==e.sport)throw new Ee.ErrnoError(28);if(e.saddr=r,e.sport=t,2===e.type){e.server&&(e.server.close(),e.server=null);try{e.sock_ops.listen(e,0)}catch(e){if(!(e instanceof Ee.ErrnoError))throw e;if(138!==e.errno)throw e}}},connect:function(e,r,t){if(e.server)throw new Ee.ErrnoError(138);if(void 0!==e.daddr&&void 0!==e.dport){var n=ke.websocket_sock_ops.getPeer(e,e.daddr,e.dport);if(n)throw n.socket.readyState===n.socket.CONNECTING?new Ee.ErrnoError(7):new Ee.ErrnoError(30)}t=ke.websocket_sock_ops.createPeer(e,r,t);throw e.daddr=t.addr,e.dport=t.port,new Ee.ErrnoError(26)},listen:function(n,e){if(!h)throw new Ee.ErrnoError(138);if(n.server)throw new Ee.ErrnoError(28);var r=require("ws").Server,t=n.saddr;n.server=new r({host:t,port:n.sport}),c.websocket.emit("listen",n.stream.fd),n.server.on("connection",function(e){var r,t;1===n.type?(r=ke.createSocket(n.family,n.type,n.protocol),t=ke.websocket_sock_ops.createPeer(r,e),r.daddr=t.addr,r.dport=t.port,n.pending.push(r),c.websocket.emit("connection",r.stream.fd)):(ke.websocket_sock_ops.createPeer(n,e),c.websocket.emit("connection",n.stream.fd))}),n.server.on("closed",function(){c.websocket.emit("close",n.stream.fd),n.server=null}),n.server.on("error",function(e){n.error=23,c.websocket.emit("error",[n.stream.fd,n.error,"EHOSTUNREACH: Host is unreachable"])})},accept:function(e){if(!e.server)throw new Ee.ErrnoError(28);var r=e.pending.shift();return r.stream.flags=e.stream.flags,r},getname:function(e,r){var t,n;if(r){if(void 0===e.daddr||void 0===e.dport)throw new Ee.ErrnoError(53);t=e.daddr,n=e.dport}else t=e.saddr||0,n=e.sport||0;return{addr:t,port:n}},sendmsg:function(e,r,t,n,o,a){if(2===e.type){if(void 0!==o&&void 0!==a||(o=e.daddr,a=e.dport),void 0===o||void 0===a)throw new Ee.ErrnoError(17)}else o=e.daddr,a=e.dport;var s,i=ke.websocket_sock_ops.getPeer(e,o,a);if(1===e.type){if(!i||i.socket.readyState===i.socket.CLOSING||i.socket.readyState===i.socket.CLOSED)throw new Ee.ErrnoError(53);if(i.socket.readyState===i.socket.CONNECTING)throw new Ee.ErrnoError(6)}if(ArrayBuffer.isView(r)&&(t+=r.byteOffset,r=r.buffer),s=r.slice(t,t+n),2===e.type&&(!i||i.socket.readyState!==i.socket.OPEN))return i&&i.socket.readyState!==i.socket.CLOSING&&i.socket.readyState!==i.socket.CLOSED||(i=ke.websocket_sock_ops.createPeer(e,o,a)),i.dgram_send_queue.push(s),n;try{return i.socket.send(s),n}catch(e){throw new Ee.ErrnoError(28)}},recvmsg:function(e,r){if(1===e.type&&e.server)throw new Ee.ErrnoError(53);var t=e.recv_queue.shift();if(!t){if(1!==e.type)throw new Ee.ErrnoError(6);var n=ke.websocket_sock_ops.getPeer(e,e.daddr,e.dport);if(n){if(n.socket.readyState===n.socket.CLOSING||n.socket.readyState===n.socket.CLOSED)return null;throw new Ee.ErrnoError(6)}throw new Ee.ErrnoError(53)}var o=t.data.byteLength||t.data.length,a=t.data.byteOffset||0,s=t.data.buffer||t.data,n=Math.min(r,o),r={buffer:new Uint8Array(s,a,n),addr:t.addr,port:t.port};return 1===e.type&&n<o&&(o=o-n,t.data=new Uint8Array(s,a+n,o),e.recv_queue.unshift(t)),r}}};function be(e){e=ke.getSocket(e);if(!e)throw new Ee.ErrnoError(8);return e}function Se(e){return B[rr()>>2]=e}function De(e){return(255&e)+"."+(e>>8&255)+"."+(e>>16&255)+"."+(e>>24&255)}function Fe(e,r){var t,n=C[e>>1],o=ar(N[e+2>>1]);switch(n){case 2:if(16!==r)return{errno:28};t=De(t=B[e+4>>2]);break;case 10:if(28!==r)return{errno:28};t=function(e){for(var r="",t=0,n=0,o=0,a=0,s=0,i=0,u=[65535&e[0],e[0]>>16,65535&e[1],e[1]>>16,65535&e[2],e[2]>>16,65535&e[3],e[3]>>16],c=!0,e="",i=0;i<5;i++)if(0!==u[i]){c=!1;break}if(c){if(e=De(u[6]|u[7]<<16),-1===u[5])return r="::ffff:",r+=e;if(0===u[5])return r="::","0.0.0.0"===e&&(e=""),"0.0.0.1"===e&&(e="1"),r+=e}for(t=0;t<8;t++)0===u[t]&&(1<t-o&&(s=0),o=t,s++),n<s&&(a=t-(n=s)+1);for(t=0;t<8;t++)1<n&&0===u[t]&&a<=t&&t<a+n?t===a&&(r+=":",0===a&&(r+=":")):(r+=Number(ar(65535&u[t])).toString(16),r+=t<7?":":"");return r}(t=[B[e+8>>2],B[e+12>>2],B[e+16>>2],B[e+20>>2]]);break;default:return{errno:5}}return{family:n,addr:t,port:o}}function Me(e){for(var r=e.split("."),t=0;t<4;t++){var n=Number(r[t]);if(isNaN(n))return null;r[t]=n}return(r[0]|r[1]<<8|r[2]<<16|r[3]<<24)>>>0}function Ae(e){return parseInt(e)}function Pe(e){var r,t,n,o,a=[];if(!/^((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\3)::|:\b|$))|(?!\2\3)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i.test(e))return null;if("::"===e)return[0,0,0,0,0,0,0,0];for(r=0<(e=e.startsWith("::")?e.replace("::","Z:"):e.replace("::",":Z:")).indexOf(".")?((r=(e=e.replace(new RegExp("[.]","g"),":")).split(":"))[r.length-4]=Ae(r[r.length-4])+256*Ae(r[r.length-3]),r[r.length-3]=Ae(r[r.length-2])+256*Ae(r[r.length-1]),r.slice(0,r.length-2)):e.split(":"),t=o=n=0;t<r.length;t++)if("string"==typeof r[t])if("Z"===r[t]){for(o=0;o<8-r.length+1;o++)a[t+o]=0;n=o-1}else a[t+n]=or(parseInt(r[t],16));else a[t+n]=r[t];return[a[1]<<16|a[0],a[3]<<16|a[2],a[5]<<16|a[4],a[7]<<16|a[6]]}var xe={address_map:{id:1,addrs:{},names:{}},lookup_name:function(e){var r,t=Me(e);return null!==t||null!==(t=Pe(e))?e:(xe.address_map.addrs[e]?r=xe.address_map.addrs[e]:(D((t=xe.address_map.id++)<65535,"exceeded max address mappings of 65535"),r="172.29."+(255&t)+"."+(65280&t),xe.address_map.names[r]=e,xe.address_map.addrs[e]=r),r)},lookup_addr:function(e){return xe.address_map.names[e]||null}};function Te(e,r,t){if(t&&0===e)return null;r=Fe(e,r);if(r.errno)throw new Ee.ErrnoError(r.errno);return r.addr=xe.lookup_addr(r.addr)||r.addr,r}var Re,ze={DEFAULT_POLLMASK:5,calculateAt:function(e,r,t){if("/"===r[0])return r;var n;if(-100===e)n=Ee.cwd();else{e=Ee.getStream(e);if(!e)throw new Ee.ErrnoError(8);n=e.path}if(0!=r.length)return we.join2(n,r);if(!t)throw new Ee.ErrnoError(44);return n},doStat:function(e,r,t){try{var n=e(r)}catch(e){if(e&&e.node&&we.normalize(r)!==we.normalize(Ee.getPath(e.node)))return-54;throw e}return B[t>>2]=n.dev,B[t+4>>2]=0,B[t+8>>2]=n.ino,B[t+12>>2]=n.mode,B[t+16>>2]=n.nlink,B[t+20>>2]=n.uid,B[t+24>>2]=n.gid,B[t+28>>2]=n.rdev,B[t+32>>2]=0,ue=[n.size>>>0,(ie=n.size,1<=+Math.abs(ie)?0<ie?(0|Math.min(+Math.floor(ie/4294967296),4294967295))>>>0:~~+Math.ceil((ie-(~~ie>>>0))/4294967296)>>>0:0)],B[t+40>>2]=ue[0],B[t+44>>2]=ue[1],B[t+48>>2]=4096,B[t+52>>2]=n.blocks,B[t+56>>2]=n.atime.getTime()/1e3|0,B[t+60>>2]=0,B[t+64>>2]=n.mtime.getTime()/1e3|0,B[t+68>>2]=0,B[t+72>>2]=n.ctime.getTime()/1e3|0,B[t+76>>2]=0,ue=[n.ino>>>0,(ie=n.ino,1<=+Math.abs(ie)?0<ie?(0|Math.min(+Math.floor(ie/4294967296),4294967295))>>>0:~~+Math.ceil((ie-(~~ie>>>0))/4294967296)>>>0:0)],B[t+80>>2]=ue[0],B[t+84>>2]=ue[1],0},doMsync:function(e,r,t,n,o){e=O.slice(e,e+t);Ee.msync(r,e,o,t,n)},doMkdir:function(e,r){return"/"===(e=we.normalize(e))[e.length-1]&&(e=e.substr(0,e.length-1)),Ee.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 Ee.mknod(e,r,t),0},doReadlink:function(e,r,t){if(t<=0)return-28;var n=Ee.readlink(e),o=Math.min(t,T(n)),e=z[r+o];return x(n,r,t+1),z[r+o]=e,o},doAccess:function(e,r){if(-8&r)return-28;var t=Ee.lookupPath(e,{follow:!0}).node;if(!t)return-44;e="";return 4&r&&(e+="r"),2&r&&(e+="w"),1&r&&(e+="x"),e&&Ee.nodePermissions(t,e)?-2:0},doDup:function(e,r,t){var n=Ee.getStream(t);return n&&Ee.close(n),Ee.open(e,r,0,t,t).fd},doReadv:function(e,r,t,n){for(var o=0,a=0;a<t;a++){var s=B[r+8*a>>2],i=B[r+(8*a+4)>>2],s=Ee.read(e,z,s,i,n);if(s<0)return-1;if(o+=s,s<i)break}return o},doWritev:function(e,r,t,n){for(var o=0,a=0;a<t;a++){var s=B[r+8*a>>2],i=B[r+(8*a+4)>>2],i=Ee.write(e,z,s,i,n);if(i<0)return-1;o+=i}return o},varargs:void 0,get:function(){return ze.varargs+=4,B[ze.varargs-4>>2]},getStr:function(e){return A(e)},getStreamFromFD:function(e){e=Ee.getStream(e);if(!e)throw new Ee.ErrnoError(8);return e},get64:function(e,r){return e}};function Oe(e,r,t){var n,o,a,s,i;function u(e){e=e.toTimeString().match(/\(([A-Za-z ]+)\)$/);return e?e[1]:"GMT"}Oe.called||(Oe.called=!0,n=e,o=r,a=t,s=(new Date).getFullYear(),i=new Date(s,0,1),e=new Date(s,6,1),r=i.getTimezoneOffset(),t=e.getTimezoneOffset(),s=Math.max(r,t),B[n>>2]=60*s,B[o>>2]=Number(r!=t),i=u(i),e=u(e),i=H(i),e=H(e),t<r?(B[a>>2]=i,B[a+4>>2]=e):(B[a>>2]=e,B[a+4>>2]=i))}function Ce(){oe("")}c._abort=Ce,Re=h?()=>{var e=process.hrtime();return 1e3*e[0]+e[1]/1e6}:()=>performance.now();var Ne=[];function Be(){K+=1}var Ue={};function Ie(){if(!Ie.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",_:l||"./this.program"};for(r in Ue)void 0===Ue[r]?delete e[r]:e[r]=Ue[r];var r,t=[];for(r in e)t.push(r+"="+e[r]);Ie.strings=t}return Ie.strings}function He(e){fr(e)}function Le(e){return e%4==0&&(e%100!=0||e%400==0)}function je(e,r){for(var t=0,n=0;n<=r;t+=e[n++]);return t}var qe=[31,29,31,30,31,30,31,31,30,31,30,31],We=[31,28,31,30,31,30,31,31,30,31,30,31];function Ye(e,r){for(var t=new Date(e.getTime());0<r;){var n=Le(t.getFullYear()),o=t.getMonth(),n=(n?qe:We)[o];if(!(r>n-t.getDate()))return t.setDate(t.getDate()+r),t;r-=n-t.getDate()+1,t.setDate(1),o<11?t.setMonth(o+1):(t.setMonth(0),t.setFullYear(t.getFullYear()+1))}return t}function Xe(e,r,t,n){var o=B[n+40>>2],a={tm_sec:B[n>>2],tm_min:B[n+4>>2],tm_hour:B[n+8>>2],tm_mday:B[n+12>>2],tm_mon:B[n+16>>2],tm_year:B[n+20>>2],tm_wday:B[n+24>>2],tm_yday:B[n+28>>2],tm_isdst:B[n+32>>2],tm_gmtoff:B[n+36>>2],tm_zone:o?A(o):""},s=A(t),i={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(h in i)s=s.replace(new RegExp(h,"g"),i[h]);var u=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],c=["January","February","March","April","May","June","July","August","September","October","November","December"];function d(e,r,t){for(var n="number"==typeof e?e.toString():e||"";n.length<r;)n=t[0]+n;return n}function l(e,r){return d(e,r,"0")}function f(e,r){function t(e){return e<0?-1:0<e?1:0}var n;return 0===(n=t(e.getFullYear()-r.getFullYear()))&&0===(n=t(e.getMonth()-r.getMonth()))&&(n=t(e.getDate()-r.getDate())),n}function p(e){switch(e.getDay()){case 0:return new Date(e.getFullYear()-1,11,29);case 1:return e;case 2:return new Date(e.getFullYear(),0,3);case 3:return new Date(e.getFullYear(),0,2);case 4:return new Date(e.getFullYear(),0,1);case 5:return new Date(e.getFullYear()-1,11,31);case 6:return new Date(e.getFullYear()-1,11,30)}}function m(e){var r=Ye(new Date(e.tm_year+1900,0,1),e.tm_yday),t=new Date(r.getFullYear(),0,4),e=new Date(r.getFullYear()+1,0,4),t=p(t),e=p(e);return f(t,r)<=0?f(e,r)<=0?r.getFullYear()+1:r.getFullYear():r.getFullYear()-1}var h,w={"%a":function(e){return u[e.tm_wday].substring(0,3)},"%A":function(e){return u[e.tm_wday]},"%b":function(e){return c[e.tm_mon].substring(0,3)},"%B":function(e){return c[e.tm_mon]},"%C":function(e){return l((e.tm_year+1900)/100|0,2)},"%d":function(e){return l(e.tm_mday,2)},"%e":function(e){return d(e.tm_mday,2," ")},"%g":function(e){return m(e).toString().substring(2)},"%G":m,"%H":function(e){return l(e.tm_hour,2)},"%I":function(e){e=e.tm_hour;return 0==e?e=12:12<e&&(e-=12),l(e,2)},"%j":function(e){return l(e.tm_mday+je(Le(e.tm_year+1900)?qe:We,e.tm_mon-1),3)},"%m":function(e){return l(e.tm_mon+1,2)},"%M":function(e){return l(e.tm_min,2)},"%n":function(){return"\n"},"%p":function(e){return 0<=e.tm_hour&&e.tm_hour<12?"AM":"PM"},"%S":function(e){return l(e.tm_sec,2)},"%t":function(){return"\t"},"%u":function(e){return e.tm_wday||7},"%U":function(e){var r=new Date(e.tm_year+1900,0,1),t=0===r.getDay()?r:Ye(r,7-r.getDay()),n=new Date(e.tm_year+1900,e.tm_mon,e.tm_mday);if(f(t,n)<0){e=je(Le(n.getFullYear())?qe:We,n.getMonth()-1)-31,n=31-t.getDate()+e+n.getDate();return l(Math.ceil(n/7),2)}return 0===f(t,r)?"01":"00"},"%V":function(e){var r=new Date(e.tm_year+1900,0,4),t=new Date(e.tm_year+1901,0,4),n=p(r),r=p(t),t=Ye(new Date(e.tm_year+1900,0,1),e.tm_yday);return f(t,n)<0?"53":f(r,t)<=0?"01":(n=n.getFullYear()<e.tm_year+1900?e.tm_yday+32-n.getDate():e.tm_yday+1-n.getDate(),l(Math.ceil(n/7),2))},"%w":function(e){return e.tm_wday},"%W":function(e){var r=new Date(e.tm_year,0,1),t=1===r.getDay()?r:Ye(r,0===r.getDay()?1:7-r.getDay()+1),n=new Date(e.tm_year+1900,e.tm_mon,e.tm_mday);if(f(t,n)<0){e=je(Le(n.getFullYear())?qe:We,n.getMonth()-1)-31,n=31-t.getDate()+e+n.getDate();return l(Math.ceil(n/7),2)}return 0===f(t,r)?"01":"00"},"%y":function(e){return(e.tm_year+1900).toString().substring(2)},"%Y":function(e){return e.tm_year+1900},"%z":function(e){var r=e.tm_gmtoff,e=0<=r;return r=(r=Math.abs(r)/60)/60*100+r%60,(e?"+":"-")+String("0000"+r).slice(-4)},"%Z":function(e){return e.tm_zone},"%%":function(){return"%"}},s=s.replace(/%%/g,"\0\0");for(h in w)s.includes(h)&&(s=s.replace(new RegExp(h,"g"),w[h](a)));t=$e(s=s.replace(/\0\0/g,"%"),!1);return t.length>r?0:(r=t,e=e,z.set(r,e),t.length-1)}function Ge(e){try{return e()}catch(e){oe(e)}}function Ve(e,r){if(!V&&!S)if(r)e();else try{e(),function(){if(!$())try{He(b)}catch(e){he(e)}}()}catch(e){he(e)}}var Ke={State:{Normal:0,Unwinding:1,Rewinding:2,Disabled:3},state:0,StackSize:4096,currData:null,handleSleepReturnValue:0,exportCallStack:[],callStackNameToId:{},callStackIdToName:{},callStackId:0,asyncPromiseHandlers:null,sleepCallbacks:[],getCallStackId:function(e){var r=Ke.callStackNameToId[e];return void 0===r&&(r=Ke.callStackId++,Ke.callStackNameToId[e]=r,Ke.callStackIdToName[r]=e),r},instrumentWasmExports:function(t){var e,n={};for(e in t)!function(e){var r=t[e];n[e]="function"==typeof r?function(){Ke.exportCallStack.push(e);try{return r.apply(null,arguments)}finally{S||(D(Ke.exportCallStack.pop()===e),Ke.maybeStopUnwind())}}:r}(e);return n},maybeStopUnwind:function(){Ke.currData&&Ke.state===Ke.State.Unwinding&&0===Ke.exportCallStack.length&&(Be(),Ke.state=Ke.State.Normal,Ge(c._asyncify_stop_unwind),"undefined"!=typeof Fibers&&Fibers.trampoline())},whenDone:function(){return new Promise((e,r)=>{Ke.asyncPromiseHandlers={resolve:e,reject:r}})},allocateData:function(){var e=er(12+Ke.StackSize);return Ke.setDataHeader(e,e+12,Ke.StackSize),Ke.setDataRewindFunc(e),e},setDataHeader:function(e,r,t){B[e>>2]=r,B[e+4>>2]=r+t},setDataRewindFunc:function(e){var r=Ke.exportCallStack[0],r=Ke.getCallStackId(r);B[e+8>>2]=r},getDataRewindFunc:function(e){e=B[e+8>>2],e=Ke.callStackIdToName[e];return c.asm[e]},doRewind:function(e){e=Ke.getDataRewindFunc(e);return--K,e()},handleSleep:function(e){var o,a;if(!S)return Ke.state===Ke.State.Normal?(a=o=!1,e(e=>{if(!S&&(Ke.handleSleepReturnValue=e||0,o=!0,a)){Ke.state=Ke.State.Rewinding,Ge(()=>c._asyncify_start_rewind(Ke.currData)),"undefined"!=typeof Browser&&Browser.mainLoop.func&&Browser.mainLoop.resume();var r,t=!1;try{r=Ke.doRewind(Ke.currData)}catch(e){r=e,t=!0}var n=!1;if(Ke.currData||(e=Ke.asyncPromiseHandlers)&&(Ke.asyncPromiseHandlers=null,(t?e.reject:e.resolve)(r),n=!0),t&&!n)throw r}}),a=!0,o||(Ke.state=Ke.State.Unwinding,Ke.currData=Ke.allocateData(),Ge(()=>c._asyncify_start_unwind(Ke.currData)),"undefined"!=typeof Browser&&Browser.mainLoop.func&&Browser.mainLoop.pause())):Ke.state===Ke.State.Rewinding?(Ke.state=Ke.State.Normal,Ge(c._asyncify_stop_rewind),Qe(Ke.currData),Ke.currData=null,Ke.sleepCallbacks.forEach(e=>Ve(e))):oe("invalid state: "+Ke.state),Ke.handleSleepReturnValue},handleAsync:function(r){return Ke.handleSleep(e=>{r().then(e)})}},u=function(e,r,t,n){e=e||this,this.parent=e,this.mount=e.mount,this.mounted=null,this.id=Ee.nextInode++,this.name=r,this.mode=t,this.node_ops={},this.stream_ops={},this.rdev=n};function $e(e,r,t){t=0<t?t:T(e)+1,t=new Array(t),e=P(e,t,0,t.length);return r&&(t.length=e),t}Object.defineProperties(u.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 Ee.isDir(this.mode)}},isDevice:{get:function(){return Ee.isChrdev(this.mode)}}}),Ee.FSNode=u,Ee.staticInit(),c.FS_createPath=Ee.createPath,c.FS_createPreloadedFile=Ee.createPreloadedFile,c.FS_createDataFile=Ee.createDataFile,c.FS_createPath=Ee.createPath,c.FS_createDataFile=Ee.createDataFile,c.FS_createPreloadedFile=Ee.createPreloadedFile,c.FS_createLazyFile=Ee.createLazyFile,c.FS_createDevice=Ee.createDevice,c.FS_unlink=Ee.unlink;var Ze,Je={r:function(e,r,t,n){oe("Assertion failed: "+A(e)+", at: "+[r?A(r):"unknown filename",t,n?A(n):"unknown function"])},ra:function(e,r,t){try{var n=be(e),o=Te(r,t);return n.sock_ops.bind(n,o.addr,o.port),0}catch(e){if(void 0===Ee||!(e instanceof Ee.ErrnoError))throw e;return-e.errno}},qa:function(e,r){try{return e=ze.getStr(e),Ee.chmod(e,r),0}catch(e){if(void 0===Ee||!(e instanceof Ee.ErrnoError))throw e;return-e.errno}},pa:function(e,r,t){try{var n=be(e),o=Te(r,t);return n.sock_ops.connect(n,o.addr,o.port),0}catch(e){if(void 0===Ee||!(e instanceof Ee.ErrnoError))throw e;return-e.errno}},oa:function(e,r,t,n){try{return r=ze.getStr(r),r=ze.calculateAt(e,r),ze.doAccess(r,t)}catch(e){if(void 0===Ee||!(e instanceof Ee.ErrnoError))throw e;return-e.errno}},b:function(e,r,t){ze.varargs=t;try{var n=ze.getStreamFromFD(e);switch(r){case 0:return(o=ze.get())<0?-28:Ee.open(n.path,n.flags,0,o).fd;case 1:case 2:return 0;case 3:return n.flags;case 4:var o=ze.get();return n.flags|=o,0;case 5:o=ze.get();return C[o+0>>1]=2,0;case 6:case 7:return 0;case 16:case 8:return-28;case 9:return Se(28),-1;default:return-28}}catch(e){if(void 0===Ee||!(e instanceof Ee.ErrnoError))throw e;return-e.errno}},na:function(e,r){try{var t=ze.getStreamFromFD(e);return ze.doStat(Ee.stat,t.path,r)}catch(e){if(void 0===Ee||!(e instanceof Ee.ErrnoError))throw e;return-e.errno}},ma:function(e,r,t,n){try{r=ze.getStr(r);var o=256&n,a=4096&n;return n&=-4353,r=ze.calculateAt(e,r,a),ze.doStat(o?Ee.lstat:Ee.stat,r,t)}catch(e){if(void 0===Ee||!(e instanceof Ee.ErrnoError))throw e;return-e.errno}},la:function(e,r,t){try{var n=ze.get64(r,t);return Ee.ftruncate(e,n),0}catch(e){if(void 0===Ee||!(e instanceof Ee.ErrnoError))throw e;return-e.errno}},ka:function(e,r){try{if(0===r)return-28;var t=Ee.cwd();return r<T(t)+1?-68:(x(t,e,r),e)}catch(e){if(void 0===Ee||!(e instanceof Ee.ErrnoError))throw e;return-e.errno}},ja:function(e,r,t){try{var n=ze.getStreamFromFD(e);n.getdents||(n.getdents=Ee.readdir(n.path));for(var o=0,a=Ee.llseek(n,0,1),s=Math.floor(a/280);s<n.getdents.length&&o+280<=t;){var i,u,c=n.getdents[s];u="."===c?(i=n.node.id,4):".."===c?(i=Ee.lookupPath(n.path,{parent:!0}).node.id,4):(i=(u=Ee.lookupNode(n.node,c)).id,Ee.isChrdev(u.mode)?2:Ee.isDir(u.mode)?4:Ee.isLink(u.mode)?10:8),ue=[i>>>0,(ie=i,1<=+Math.abs(ie)?0<ie?(0|Math.min(+Math.floor(ie/4294967296),4294967295))>>>0:~~+Math.ceil((ie-(~~ie>>>0))/4294967296)>>>0:0)],B[r+o>>2]=ue[0],B[r+o+4>>2]=ue[1],ue=[280*(s+1)>>>0,(ie=280*(s+1),1<=+Math.abs(ie)?0<ie?(0|Math.min(+Math.floor(ie/4294967296),4294967295))>>>0:~~+Math.ceil((ie-(~~ie>>>0))/4294967296)>>>0:0)],B[r+o+8>>2]=ue[0],B[r+o+12>>2]=ue[1],C[r+o+16>>1]=280,z[r+o+18>>0]=u,x(c,r+o+19,256),o+=280,s+=1}return Ee.llseek(n,280*s,0),o}catch(e){if(void 0===Ee||!(e instanceof Ee.ErrnoError))throw e;return-e.errno}},ia:function(e,r,t){ze.varargs=t;try{var n=ze.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=ze.get();return B[o>>2]=0;case 21520:return n.tty?-28:-59;case 21531:o=ze.get();return Ee.ioctl(n,r,o);case 21523:case 21524:return n.tty?0:-59;default:oe("bad ioctl syscall "+r)}}catch(e){if(void 0===Ee||!(e instanceof Ee.ErrnoError))throw e;return-e.errno}},ha:function(e,r){try{var t=be(e);return t.sock_ops.listen(t,r),0}catch(e){if(void 0===Ee||!(e instanceof Ee.ErrnoError))throw e;return-e.errno}},ga:function(e,r){try{return e=ze.getStr(e),ze.doStat(Ee.lstat,e,r)}catch(e){if(void 0===Ee||!(e instanceof Ee.ErrnoError))throw e;return-e.errno}},fa:function(e,r){try{return e=ze.getStr(e),ze.doMkdir(e,r)}catch(e){if(void 0===Ee||!(e instanceof Ee.ErrnoError))throw e;return-e.errno}},q:function(e,r,t){ze.varargs=t;try{var n=ze.getStr(e),o=t?ze.get():0;return Ee.open(n,r,o).fd}catch(e){if(void 0===Ee||!(e instanceof Ee.ErrnoError))throw e;return-e.errno}},ea:function(e,r,t){try{return e=ze.getStr(e),ze.doReadlink(e,r,t)}catch(e){if(void 0===Ee||!(e instanceof Ee.ErrnoError))throw e;return-e.errno}},da:function(e,r,t,n,o,a){try{var s=be(e),i=s.sock_ops.recvmsg(s,t);return i?(o&&function(e,r,t,n,o){switch(r){case 2:t=Me(t),ve(e,16),o&&(B[o>>2]=16),C[e>>1]=r,B[e+4>>2]=t,C[e+2>>1]=or(n);break;case 10:t=Pe(t),ve(e,28),o&&(B[o>>2]=28),B[e>>2]=r,B[e+8>>2]=t[0],B[e+12>>2]=t[1],B[e+16>>2]=t[2],B[e+20>>2]=t[3],C[e+2>>1]=or(n);break;default:return}}(o,s.family,xe.lookup_name(i.addr),i.port,a),O.set(i.buffer,r),i.buffer.byteLength):0}catch(e){if(void 0===Ee||!(e instanceof Ee.ErrnoError))throw e;return-e.errno}},ca:function(e,r){try{return e=ze.getStr(e),r=ze.getStr(r),Ee.rename(e,r),0}catch(e){if(void 0===Ee||!(e instanceof Ee.ErrnoError))throw e;return-e.errno}},p:function(e){try{return e=ze.getStr(e),Ee.rmdir(e),0}catch(e){if(void 0===Ee||!(e instanceof Ee.ErrnoError))throw e;return-e.errno}},ba:function(e,r,t,n,o,a){try{var s=be(e),i=Te(o,a,!0);return i?s.sock_ops.sendmsg(s,z,r,t,i.addr,i.port):Ee.write(s.stream,z,r,t)}catch(e){if(void 0===Ee||!(e instanceof Ee.ErrnoError))throw e;return-e.errno}},o:function(e,r,t){try{return ke.createSocket(e,r,t).stream.fd}catch(e){if(void 0===Ee||!(e instanceof Ee.ErrnoError))throw e;return-e.errno}},aa:function(e,r){try{return e=ze.getStr(e),ze.doStat(Ee.stat,e,r)}catch(e){if(void 0===Ee||!(e instanceof Ee.ErrnoError))throw e;return-e.errno}},n:function(e){try{return e=ze.getStr(e),Ee.unlink(e),0}catch(e){if(void 0===Ee||!(e instanceof Ee.ErrnoError))throw e;return-e.errno}},Y:function(e,r){var t=new Date(1e3*B[e>>2]);B[r>>2]=t.getSeconds(),B[r+4>>2]=t.getMinutes(),B[r+8>>2]=t.getHours(),B[r+12>>2]=t.getDate(),B[r+16>>2]=t.getMonth(),B[r+20>>2]=t.getFullYear()-1900,B[r+24>>2]=t.getDay();var n=new Date(t.getFullYear(),0,1),e=(t.getTime()-n.getTime())/864e5|0;B[r+28>>2]=e,B[r+36>>2]=-60*t.getTimezoneOffset(),e=new Date(t.getFullYear(),6,1).getTimezoneOffset(),n=n.getTimezoneOffset(),e=0|(e!=n&&t.getTimezoneOffset()==Math.min(n,e)),B[r+32>>2]=e},X:function(e){var r=new Date(B[e+20>>2]+1900,B[e+16>>2],B[e+12>>2],B[e+8>>2],B[e+4>>2],B[e>>2],0),t=B[e+32>>2],n=r.getTimezoneOffset(),o=new Date(r.getFullYear(),0,1),a=new Date(r.getFullYear(),6,1).getTimezoneOffset(),s=o.getTimezoneOffset(),i=Math.min(s,a);return t<0?B[e+32>>2]=Number(a!=s&&i==n):0<t!=(i==n)&&(a=Math.max(s,a),a=0<t?i:a,r.setTime(r.getTime()+6e4*(a-n))),B[e+24>>2]=r.getDay(),o=(r.getTime()-o.getTime())/864e5|0,B[e+28>>2]=o,B[e>>2]=r.getSeconds(),B[e+4>>2]=r.getMinutes(),B[e+8>>2]=r.getHours(),B[e+12>>2]=r.getDate(),B[e+16>>2]=r.getMonth(),r.getTime()/1e3|0},W:Oe,a:Ce,V:function(e,r){var t;if(0===e)t=Date.now();else{if(1!==e&&4!==e)return Se(28),-1;t=Re()}return B[r>>2]=t/1e3|0,B[r+4>>2]=t%1e3*1e3*1e3|0,0},U:function(e){(e?self:window).removeEventListener("message",c.receive),c.alive=!1,delete c.sync_sleep},T:function(){c.alive=!1,delete c.sync_sleep},S:function(e,r,t){for(var n=new Uint8Array(t/4*3),o=c.HEAPU8,a=0,s=r;a<n.length;)n[a++]=o[s++],n[a++]=o[s++],n[a++]=o[s++],s++;c.frame_update_lines.push({start:e,heapu8:n}),c.frame_update_lines_transferable.push(n.buffer)},R:function(e,r,t,n,o,a,s,i){registerNames=["al","ah","ax","eax","bl","bh","bx","ebx","cl","ch","cx","ecx","dl","dh","dx","edx","si","esi","di","edi","sp","esp","bp","ebp","ip","eip"],registers=Object.fromEntries(registerNames.map((e,r)=>[e,c.HEAPU32[(n>>2)+r]])),c.memoryContents={memBase:e,ip:r,flags:t,registers:registers,segments_values:{es:c.HEAPU16[o>>1],cs:c.HEAPU16[1+(o>>1)],ss:c.HEAPU16[2+(o>>1)],ds:c.HEAPU16[3+(o>>1)],fs:c.HEAPU16[4+(o>>1)],gs:c.HEAPU16[5+(o>>1)]},segments_physical:{es:c.HEAPU32[a>>2],cs:c.HEAPU32[1+(a>>2)],ss:c.HEAPU32[2+(a>>2)],ds:c.HEAPU32[3+(a>>2)],fs:c.HEAPU32[4+(a>>2)],gs:c.HEAPU32[5+(a>>2)]},numPages:s,memoryCopy:void 0},i&&(c.memoryContents.memoryCopy=c.HEAPU8.slice(e,e+s/4096*1024*1024))},Q:function(){0<c.frame_update_lines.length&&c.sendMessage("ws-update-lines",{lines:c.frame_update_lines},c.frame_update_lines_transferable),delete c.frame_update_lines,delete c.frame_update_lines_transferable},m:function(){var e;c.exit?(c.exit(),c.cleanup()):(e="ERR! exitRuntime called without request, asyncify state: "+Ke.state,c.err(e))},P:function(){c.FS.chdir("/home/web_user");let n;for(c.libzip_progress=function(e,r,t){c.sendMessage("ws-extract-progress",{index:n,file:e,extracted:r,count:t})},n=0;n<c.bundles.length;++n){var e=c.bundles[n],r=c._malloc(e.length);c.HEAPU8.set(e,r);e=c._zip_to_fs(r,e.length);if(c._free(r),0!==e)return void c.err("Unable to extract bundle archive\n");if(0===n){try{c.FS.readFile("/home/web_user/.jsdos/dosbox.conf")}catch(e){return void c.err("Broken bundle, .jsdos/dosbox.conf not found")}c.fsCreatedAt=c._get_changes_mtime_ms()}}var t=c._getConfigContent(),o=c.UTF8ToString(t);c._free(t),c.sendMessage("ws-config",{content:o}),delete c.libzip_progress,delete c.bundles},l:function(e){return Ee.lookupPath(A(e)).node.timestamp},O:function(){c.FS.chdir("/home/web_user");var e=c._zip_from_fs(c.fsCreatedAt);if(0===e)return c.err("Can't create zip, see more info in logs"),void c._abort();var r=c.HEAPU32[e/4];const t=c.HEAPU8;r=t.slice(e+4,e+4+r),c._free(e),c.persist(r)},N:function(e,r,t){void 0!==c.libzip_progress&&c.libzip_progress(A(e),r,t)},M:function(e){return void 0!==c.sharedMemory?(c.sendMessage("ws-update-lines",{rgba:e}),!1):(c.frame_update_lines=[],c.frame_update_lines_transferable=[],!0)},L:function(e,r){c.sendMessage("ws-frame-set-size",{width:e,height:r})},K:function(e){if(void 0!==c.directSound){for(var r={ringSize:c.directSound.ringSize,bufferSize:c.directSound.bufferSize,buffer:[]},t=0;t<r.ringSize;++t)r.buffer.push(c.directSound.buffer[t].buffer);c.sendMessage("ws-sound-init",{freq:e,directSound:r})}else c.sendMessage("ws-sound-init",{freq:e})},J:function(e,r){var t;r<=0||(void 0!==c.directSound?((t=c.directSound.buffer[c.directSound.active])[t.length-1]=r,t.set(c.HEAPF32.subarray(e/4,e/4+r),0),c.directSound.active=(c.directSound.active+1)%c.directSound.ringSize):(r=c.HEAPF32.slice(e/4,e/4+r),c.sendMessage("ws-sound-push",{samples:r},[r.buffer])))},I:function(){c.exit=function(){c.sendMessage("ws-exit")}},d:function(e,r,t){return t=function(e,r){for(Ne.length=0,r>>=2;t=O[e++];){var t=t<105;t&&1&r&&r++,Ne.push(t?U[r++>>1]:B[r]),++r}return Ne}(r,t),pe[e].apply(null,t)},H:function(){throw Be(),"unwind"},G:function(e){k=!1,K=0,fr(e)},F:function(e){var r=O.length,t=2147483648;if(t<(e>>>=0))return!1;for(var n,o=1;o<=4;o*=2){var a=r*(1+.2/o),a=Math.min(a,e+100663296);if(function(e){try{return E.grow(e-R.byteLength+65535>>>16),j(E.buffer),1}catch(e){}}(Math.min(t,(n=Math.max(e,a))+((a=65536)-n%a)%a)))return!0}return!1},$:function(n,o){var a=0;return Ie().forEach(function(e,r){var t=o+a;(function(e,r,t){for(var n=0;n<e.length;++n)z[r++>>0]=e.charCodeAt(n);t||(z[r>>0]=0)})(e,B[n+4*r>>2]=t),a+=e.length+1}),0},_:function(e,r){var t=Ie();B[e>>2]=t.length;var n=0;return t.forEach(function(e){n+=e.length+1}),B[r>>2]=n,0},g:He,e:function(e){try{var r=ze.getStreamFromFD(e);return Ee.close(r),0}catch(e){if(void 0===Ee||!(e instanceof Ee.ErrnoError))throw e;return e.errno}},Z:function(e,r,t,n){try{var o=ze.getStreamFromFD(e),o=ze.doReadv(o,r,t);return B[n>>2]=o,0}catch(e){if(void 0===Ee||!(e instanceof Ee.ErrnoError))throw e;return e.errno}},A:function(e,r,t,n,o){try{var a=ze.getStreamFromFD(e),s=4294967296*t+(r>>>0),i=9007199254740992;return s<=-i||i<=s?-61:(Ee.llseek(a,s,n),ue=[a.position>>>0,(ie=a.position,1<=+Math.abs(ie)?0<ie?(0|Math.min(+Math.floor(ie/4294967296),4294967295))>>>0:~~+Math.ceil((ie-(~~ie>>>0))/4294967296)>>>0:0)],B[o>>2]=ue[0],B[o+4>>2]=ue[1],a.getdents&&0==s&&0===n&&(a.getdents=null),0)}catch(e){if(void 0===Ee||!(e instanceof Ee.ErrnoError))throw e;return e.errno}},h:function(e,r,t,n){try{var o=ze.getStreamFromFD(e),o=ze.doWritev(o,r,t);return B[n>>2]=o,0}catch(e){if(void 0===Ee||!(e instanceof Ee.ErrnoError))throw e;return e.errno}},E:function(e){return r=A(e),t=er(20),e=er(r.length+1),x(r,e,r.length+1),B[t>>2]=e,e=er(4),B[e>>2]=0,B[t+4>>2]=e,B[t+8>>2]=2,B[t+12>>2]=4,e=er(12),B[e>>2]=e+8,B[e+4>>2]=0,B[e+8>>2]=Me(xe.lookup_name(r)),B[t+16>>2]=e,t;var r,t},D:function(n){return c.alive=!0,c.sync_sleep=function(e){if(c.sync_wakeUp)throw new Error("Trying to sleep in sleeping state!");function r(){n?postMessage({name:"ws-sync-sleep",props:{sessionId:c.sessionId}}):window.postMessage({name:"ws-sync-sleep",props:{sessionId:c.sessionId}},"*")}var t;c.sync_wakeUp=e,!0===c.paused?t=setInterval(function(){!1===c.paused&&(clearInterval(t),r())},16):r()},c.receive=function(e){e.data;"wc-sync-sleep"===e.data.name&&c.sessionId===e.data.props.sessionId&&(e=c.sync_wakeUp,delete c.sync_wakeUp,c.alive&&e())},(n?self:window).addEventListener("message",c.receive,{passive:!0}),!0},C:function(){return c.alive=!0,c.sync_sleep=function(r){setTimeout(function(){var e;c.alive&&(!0===c.paused?e=setInterval(function(){!1===c.paused&&(clearInterval(e),r())},16):r())})},!0},k:function(){return"object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node},B:function(){return 0===Ke.state?1:0},j:function(){return"function"==typeof importScripts},i:function(){return c.performance.now()},z:Xe,y:function(){if(!c.sync_sleep)throw new Error("Async environment does not exists");return Ke.handleSleep(function(e){c.sync_sleep(e)})},c:function(e){var r=Date.now()/1e3|0;return e&&(B[e>>2]=r),r},x:function(e,r){c.sendMessage("ws-err",{tag:A(e),message:A(r)})},w:function(e,r){c.sendMessage("ws-log",{tag:A(e),message:A(r)})},v:function(e,r,t){c.sendMessage("ws-connected",{networkType:e,address:A(r),port:t})},f:function(e){c.sendMessage("ws-disconnected",{networkType:e})},u:function(e,r){c.sendMessage("ws-stdout",{message:A(e,r)})},t:function(e,r){c.sendMessage("ws-warn",{tag:A(e),message:A(r)})},s:function(e){var n="function"==typeof importScripts;function t(e,r,t){(r=r||{}).sessionId=c.sessionId,c.postMessage?c.postMessage(e,r,t):n?postMessage({name:e,props:r},t):window.postMessage({name:e,props:r},"*",t)}function r(e){e=e.data;void 0===e.name||e.name.length<3||"w"!==e.name[0]||"c"!==e.name[1]||"-"!==e.name[2]||e.props.sessionId===c.sessionId&&function(e){switch(e.name){case"wc-run":c.bundles=e.props.bundles,c._extractBundleToFs(),c._runRuntime(),t("ws-server-ready");break;case"wc-pause":c._requestPause();break;case"wc-resume":c._requestResume();break;case"wc-mute":c._requestMute();break;case"wc-unmute":c._requestUnmute();break;case"wc-exit":try{c._requestExit()}catch(e){if(c.err(e.message),"ExitStatus"!==e.name)throw e}break;case"wc-pack-fs-to-bundle":try{c.persist=function(e){t("ws-persist",{bundle:e},[e.buffer])},c._packFsToBundle(),delete c.persist}catch(e){c.err(e.message)}break;case"wc-add-key":c._addKey(e.props.key,e.props.pressed,e.props.timeMs);break;case"wc-mouse-move":c._mouseMove(e.props.x,e.props.y,e.props.relative,e.props.timeMs);break;case"wc-mouse-button":c._mouseButton(e.props.button,e.props.pressed,e.props.timeMs);break;case"wc-mouse-sync":c._mouseSync(e.props.timeMs);break;case"wc-sync-sleep":break;case"wc-connect":var r=c.mallocString(e.props.address);c._networkConnect(e.props.networkType,r,e.props.port),c._free(r);break;case"wc-disconnect":c._networkDisconnect(e.props.networkType);break;default:console.log("Unknown client message (wc): "+JSON.stringify(e))}}(e)}if(c.sessionId=A(e),c.sendMessage=t,c.ping=function(e){},c.log=function(e){t("ws-log",{tag:"worker",message:e})},c.warn=function(e){t("ws-warn",{tag:"worker",message:e})},c.err=function(e){t("ws-err",{tag:"panic",message:e})},c.print=c.log,c.printErr=c.err,c.mallocString=function(e){var r=c.lengthBytesUTF8(e)+1,t=c._malloc(r);return c.stringToUTF8(e,t,r),t},c.postMessage?(c.messageHandler=r,c.cleanup=function(){}):n?(onmessage=r,c.cleanup=function(){}):(window.addEventListener("message",r,{passive:!0}),c.cleanup=function(){window.removeEventListener("message",r)}),n){if("undefined"!=typeof SharedArrayBuffer&&c.HEAPU8.buffer instanceof SharedArrayBuffer){c.sharedMemory=c.HEAPU8.buffer,c.directSound={ringSize:32,bufferSize:2049,buffer:[],active:0};for(var o=0;o<c.directSound.ringSize;++o){var a=new SharedArrayBuffer(4*c.directSound.bufferSize);c.directSound.buffer.push(new Float32Array(a))}}}else{c.sharedMemory=c.HEAPU8.buffer,c.directSound={ringSize:32,bufferSize:2049,buffer:[],active:0};for(o=0;o<c.directSound.ringSize;++o)c.directSound.buffer.push(new Float32Array(c.directSound.bufferSize))}t("ws-ready",{sharedMemory:c.sharedMemory})}},Qe=(function(){var r={a:Je};function t(e,r){e=e.exports,e=Ke.instrumentWasmExports(e);c.asm=e,j((E=c.asm.sa).buffer),c.asm.Ya,e=c.asm.ta,W.unshift(e),ne()}function n(e){t(e.instance)}function o(e){return function(){if(!g&&(p||m)){if("function"==typeof fetch&&!le(ae))return fetch(ae,{credentials:"same-origin"}).then(function(e){if(!e.ok)throw"failed to load wasm binary file at '"+ae+"'";return e.arrayBuffer()}).catch(function(){return fe(ae)});if(y)return new Promise(function(r,e){y(ae,function(e){r(new Uint8Array(e))},e)})}return Promise.resolve().then(function(){return fe(ae)})}().then(function(e){return WebAssembly.instantiate(e,r)}).then(function(e){return e}).then(e,function(e){_("failed to asynchronously prepare wasm: "+e),oe(e)})}if(te(),c.instantiateWasm)try{var e=c.instantiateWasm(r,t);return e=Ke.instrumentWasmExports(e)}catch(e){return _("Module.instantiateWasm callback failed with error: "+e)}(g||"function"!=typeof WebAssembly.instantiateStreaming||de(ae)||le(ae)||"function"!=typeof fetch?o(n):fetch(ae,{credentials:"same-origin"}).then(function(e){return WebAssembly.instantiateStreaming(e,r).then(n,function(e){return _("wasm streaming compile failed: "+e),_("falling back to ArrayBuffer instantiation"),o(n)})})).catch(a)}(),c.___wasm_call_ctors=function(){return(c.___wasm_call_ctors=c.asm.ta).apply(null,arguments)},c._free=function(){return(Qe=c._free=c.asm.ua).apply(null,arguments)}),er=c._malloc=function(){return(er=c._malloc=c.asm.va).apply(null,arguments)},rr=c.___errno_location=function(){return(rr=c.___errno_location=c.asm.wa).apply(null,arguments)},tr=(c._get_changes_mtime_ms=function(){return(c._get_changes_mtime_ms=c.asm.xa).apply(null,arguments)},c._zip_from_fs=function(){return(c._zip_from_fs=c.asm.ya).apply(null,arguments)},c._zip_to_fs=function(){return(c._zip_to_fs=c.asm.za).apply(null,arguments)},c._zipfile_to_fs=function(){return(c._zipfile_to_fs=c.asm.Aa).apply(null,arguments)},c._libzip_destroy=function(){return(c._libzip_destroy=c.asm.Ba).apply(null,arguments)},c._networkConnect=function(){return(c._networkConnect=c.asm.Ca).apply(null,arguments)},c._networkDisconnect=function(){return(c._networkDisconnect=c.asm.Da).apply(null,arguments)},c._extractBundleToFs=function(){return(c._extractBundleToFs=c.asm.Ea).apply(null,arguments)},c._packFsToBundle=function(){return(c._packFsToBundle=c.asm.Fa).apply(null,arguments)},c._addKey=function(){return(c._addKey=c.asm.Ga).apply(null,arguments)},c._mouseMove=function(){return(c._mouseMove=c.asm.Ha).apply(null,arguments)},c._mouseButton=function(){return(c._mouseButton=c.asm.Ia).apply(null,arguments)},c._mouseSync=function(){return(c._mouseSync=c.asm.Ja).apply(null,arguments)},c._exitRuntime=function(){return(c._exitRuntime=c.asm.Ka).apply(null,arguments)},c._runRuntime=function(){return(c._runRuntime=c.asm.La).apply(null,arguments)},c._requestPause=function(){return(c._requestPause=c.asm.Ma).apply(null,arguments)},c._requestResume=function(){return(c._requestResume=c.asm.Na).apply(null,arguments)},c._requestMute=function(){return(c._requestMute=c.asm.Oa).apply(null,arguments)},c._requestUnmute=function(){return(c._requestUnmute=c.asm.Pa).apply(null,arguments)},c._requestExit=function(){return(c._requestExit=c.asm.Qa).apply(null,arguments)},c._getConfigContent=function(){return(c._getConfigContent=c.asm.Ra).apply(null,arguments)},c._main=function(){return(c._main=c.asm.Sa).apply(null,arguments)},c._dumpMemory=function(){return(c._dumpMemory=c.asm.Ta).apply(null,arguments)},c._rescanFilesystem=function(){return(c._rescanFilesystem=c.asm.Ua).apply(null,arguments)},c._pauseExecution=function(){return(c._pauseExecution=c.asm.Va).apply(null,arguments)},c.___stdio_exit=function(){return(tr=c.___stdio_exit=c.asm.Wa).apply(null,arguments)}),nr=c.___funcs_on_exit=function(){return(nr=c.___funcs_on_exit=c.asm.Xa).apply(null,arguments)},or=c._htons=function(){return(or=c._htons=c.asm.Za).apply(null,arguments)},ar=c._ntohs=function(){return(ar=c._ntohs=c.asm._a).apply(null,arguments)},sr=c.stackAlloc=function(){return(sr=c.stackAlloc=c.asm.$a).apply(null,arguments)},ir=c.dynCall_vi=function(){return(ir=c.dynCall_vi=c.asm.ab).apply(null,arguments)},ur=c.dynCall_v=function(){return(ur=c.dynCall_v=c.asm.bb).apply(null,arguments)};c._asyncify_start_unwind=function(){return(c._asyncify_start_unwind=c.asm.cb).apply(null,arguments)},c._asyncify_stop_unwind=function(){return(c._asyncify_stop_unwind=c.asm.db).apply(null,arguments)},c._asyncify_start_rewind=function(){return(c._asyncify_start_rewind=c.asm.eb).apply(null,arguments)},c._asyncify_stop_rewind=function(){return(c._asyncify_stop_rewind=c.asm.fb).apply(null,arguments)};function cr(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}c.UTF8ToString=A,c.stringToUTF8=x,c.lengthBytesUTF8=T,c.addRunDependency=te,c.removeRunDependency=ne,c.FS_createPath=Ee.createPath,c.FS_createDataFile=Ee.createDataFile,c.FS_createPreloadedFile=Ee.createPreloadedFile,c.FS_createLazyFile=Ee.createLazyFile,c.FS_createDevice=Ee.createDevice,c.FS_unlink=Ee.unlink,c.callMain=dr,c.FS=Ee;c.UTF16ToString=function(e,r){for(var t=e,n=t>>1,o=n+r/2;!(o<=n)&&N[n];)++n;if(32<(t=n<<1)-e&&I)return I.decode(O.subarray(e,t));for(var a="",s=0;!(r/2<=s);++s){var i=C[e+2*s>>1];if(0==i)break;a+=String.fromCharCode(i)}return a};function dr(e){var r=c._main,t=(e=e||[]).length+1,n=sr(4*(t+1));B[n>>2]=L(l);for(var o=1;o<t;o++)B[(n>>2)+o]=L(e[o-1]);B[(n>>2)+t]=0;try{var a=r(t,n);return fr(a),a}catch(e){return he(e)}finally{0}}function lr(e){function r(){Ze||(Ze=!0,c.calledRun=!0,S||(ke.root=Ee.mount(ke,{},null),c.noFSInit||Ee.init.initialized||Ee.init(),Ee.ignorePermissions=!1,ge.init(),me(W),me(Y),t(c),c.onRuntimeInitialized&&c.onRuntimeInitialized(),pr&&dr(e),J()))}e=e||d,0<Q||(Z(),0<Q||(c.setStatus?(c.setStatus("Running..."),setTimeout(function(){setTimeout(function(){c.setStatus("")},1),r()},1)):r()))}function fr(e){b=e,$()||(nr(),me(X),Ee.quit(),ge.shutdown(),V=!0),b=e=e,$()||(c.onExit&&c.onExit(e),S=!0),f(e,new cr(e))}if(re=function e(){Ze||lr(),Ze||(re=e)},c.run=lr,c.preInit)for("function"==typeof c.preInit&&(c.preInit=[c.preInit]);0<c.preInit.length;)c.preInit.pop()();var pr=!1;return c.noInitialRun&&(pr=!1),lr(),e.ready}})();"object"==typeof exports&&"object"==typeof module?module.exports=WDOSBOX:"function"==typeof define&&define.amd?define([],function(){return WDOSBOX}):"object"==typeof exports&&(exports.WDOSBOX=WDOSBOX);var worker="function"==typeof importScripts;worker&&(onmessage=e=>{e=e.data;if(void 0!==e&&"wc-install"===e.name){var t,r=e.props.sessionId;const n={};void 0!==e.props.module&&(t=e.props.module,n.instantiateWasm=(e,r)=>{e.env=e.env||{},WebAssembly.instantiate(t,e).then(e=>r(e,t))}),n.onRuntimeInitialized=()=>{n.callMain([r])},new WDOSBOX(n)}});