forked from apps/plugin-preview
2 lines
84 KiB
JavaScript
2 lines
84 KiB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("path"),require("fs"),require("crypto")):"function"==typeof define&&define.amd?define(["path","fs","crypto"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).path,e.fs,e.crypto$1)}(this,function(e,t,r){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var kt=n(e),At=n(t),Dt=n(r);function o(e,t){return e(t={exports:{}},t.exports),t.exports}var i=o(function($){var t,m,B,N,O,j,i,y=void 0!==y?y:{},L=Object.assign({},y),W="./this.program",z="object"==typeof window,c="function"==typeof importScripts,V="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,e="",H=(V?(e=c?kt.default.dirname(e)+"/":__dirname+"/",j=()=>{O||(N=At.default,O=kt.default)},t=function(e,t){return j(),e=O.normalize(e),N.readFileSync(e,t?void 0:"utf8")},B=e=>{e=t(e,!0);return e=e.buffer?e:new Uint8Array(e)},m=(e,r,n)=>{j(),e=O.normalize(e),N.readFile(e,function(e,t){e?n(e):r(t.buffer)})},1<process.argv.length&&(W=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),$.exports=y,process.on("uncaughtException",function(e){if(!(e instanceof function(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}))throw e}),process.on("unhandledRejection",function(e){throw e}),y.inspect=function(){return"[Emscripten Module object]"}):(z||c)&&(c?e=self.location.href:"undefined"!=typeof document&&document.currentScript&&(e=document.currentScript.src),e=0!==e.indexOf("blob:")?e.substr(0,e.replace(/[?#].*/,"").lastIndexOf("/")+1):"",t=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},c&&(B=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),m=(e,t,r)=>{var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=()=>{200==n.status||0==n.status&&n.response?t(n.response):r()},n.onerror=r,n.send(null)}),y.print||console.log.bind(console)),a=y.printErr||console.warn.bind(console),X=(Object.assign(y,L),y.arguments&&y.arguments,y.thisProgram&&(W=y.thisProgram),y.quit&&y.quit,y.wasmBinary&&(i=y.wasmBinary),y.noExitRuntime,"object"!=typeof WebAssembly&&w("no native wasm support detected"),!1);function q(e,t){e||w(t)}var G,d,f,u,J,l,p,Y,K,Q,Z="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function s(e,t,r){for(var n=t+r,o=t;e[o]&&!(n<=o);)++o;if(16<o-t&&e.buffer&&Z)return Z.decode(e.subarray(t,o));for(var i="";t<o;){var s,a,u=e[t++];128&u?(s=63&e[t++],192!=(224&u)?(a=63&e[t++],(u=224==(240&u)?(15&u)<<12|s<<6|a:(7&u)<<18|s<<12|a<<6|63&e[t++])<65536?i+=String.fromCharCode(u):(a=u-65536,i+=String.fromCharCode(55296|a>>10,56320|1023&a))):i+=String.fromCharCode((31&u)<<6|s)):i+=String.fromCharCode(u)}return i}function ee(e,t){return e?s(f,e,t):""}function te(e,t,r,n){if(!(0<n))return 0;for(var o=r,i=r+n-1,s=0;s<e.length;++s){var a=e.charCodeAt(s);if((a=55296<=a&&a<=57343?65536+((1023&a)<<10)|1023&e.charCodeAt(++s):a)<=127){if(i<=r)break;t[r++]=a}else if(a<=2047){if(i<=r+1)break;t[r++]=192|a>>6,t[r++]=128|63&a}else if(a<=65535){if(i<=r+2)break;t[r++]=224|a>>12,t[r++]=128|a>>6&63,t[r++]=128|63&a}else{if(i<=r+3)break;t[r++]=240|a>>18,t[r++]=128|a>>12&63,t[r++]=128|a>>6&63,t[r++]=128|63&a}}return t[r]=0,r-o}function re(e){for(var t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);n<=127?t++:n<=2047?t+=2:55296<=n&&n<=57343?(t+=4,++r):t+=3}return t}y.INITIAL_MEMORY;var h,g,v,ne=[],oe=[],ie=[],r=0,n=null;function se(){r++,y.monitorRunDependencies&&y.monitorRunDependencies(r)}function ae(){var e;r--,y.monitorRunDependencies&&y.monitorRunDependencies(r),0==r&&n&&(e=n,n=null,e())}function w(e){throw y.onAbort&&y.onAbort(e),a(e="Aborted("+e+")"),X=!0,e+=". Build with -sASSERTIONS for more info.",new WebAssembly.RuntimeError(e)}function ue(e){return e.startsWith("data:application/octet-stream;base64,")}function le(e){return e.startsWith("file://")}function ce(e){try{if(e==h&&i)return new Uint8Array(i);if(B)return B(e);throw"both async and sync fetching of the wasm failed"}catch(e){w(e)}}function de(e){for(;0<e.length;)e.shift()(y)}function fe(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(e){p[this.ptr+4>>2]=e},this.get_type=function(){return p[this.ptr+4>>2]},this.set_destructor=function(e){p[this.ptr+8>>2]=e},this.get_destructor=function(){return p[this.ptr+8>>2]},this.set_refcount=function(e){l[this.ptr>>2]=e},this.set_caught=function(e){d[this.ptr+12>>0]=e=e?1:0},this.get_caught=function(){return 0!=d[this.ptr+12>>0]},this.set_rethrown=function(e){d[this.ptr+13>>0]=e=e?1:0},this.get_rethrown=function(){return 0!=d[this.ptr+13>>0]},this.init=function(e,t){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(t),this.set_refcount(0),this.set_caught(!1),this.set_rethrown(!1)},this.add_ref=function(){var e=l[this.ptr>>2];l[this.ptr>>2]=e+1},this.release_ref=function(){var e=l[this.ptr>>2];return l[this.ptr>>2]=e-1,1===e},this.set_adjusted_ptr=function(e){p[this.ptr+16>>2]=e},this.get_adjusted_ptr=function(){return p[this.ptr+16>>2]},this.get_exception_ptr=function(){if(_t(this.get_type()))return p[this.excPtr>>2];var e=this.get_adjusted_ptr();return 0!==e?e:this.excPtr}}ue(h="decoder-pro-simd.wasm")||(L=h,h=y.locateFile?y.locateFile(L,e):e+L);var b={isAbs:e=>"/"===e.charAt(0),splitPath:e=>/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1),normalizeArray:(e,t)=>{for(var r=0,n=e.length-1;0<=n;n--){var o=e[n];"."===o?e.splice(n,1):".."===o?(e.splice(n,1),r++):r&&(e.splice(n,1),r--)}if(t)for(;r;r--)e.unshift("..");return e},normalize:e=>{var t=b.isAbs(e),r="/"===e.substr(-1);return(e=(e=b.normalizeArray(e.split("/").filter(e=>!!e),!t).join("/"))||t?e:".")&&r&&(e+="/"),(t?"/":"")+e},dirname:e=>{var e=b.splitPath(e),t=e[0],e=e[1];return t||e?t+(e=e&&e.substr(0,e.length-1)):"."},basename:e=>{if("/"===e)return"/";var t=(e=(e=b.normalize(e)).replace(/\/$/,"")).lastIndexOf("/");return-1===t?e:e.substr(t+1)},join:function(){var e=Array.prototype.slice.call(arguments,0);return b.normalize(e.join("/"))},join2:(e,t)=>b.normalize(e+"/"+t)},E={resolve:function(){for(var e="",t=!1,r=arguments.length-1;-1<=r&&!t;r--){var n=0<=r?arguments[r]:T.cwd();if("string"!=typeof n)throw new TypeError("Arguments to path.resolve must be strings");if(!n)return"";e=n+"/"+e,t=b.isAbs(n)}return(t?"/":"")+b.normalizeArray(e.split("/").filter(e=>!!e),!t).join("/")||"."},relative:(e,t)=>{function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var r=e.length-1;0<=r&&""===e[r];r--);return r<t?[]:e.slice(t,r-t+1)}e=E.resolve(e).substr(1),t=E.resolve(t).substr(1);for(var n=r(e.split("/")),o=r(t.split("/")),i=Math.min(n.length,o.length),s=i,a=0;a<i;a++)if(n[a]!==o[a]){s=a;break}for(var u=[],a=s;a<n.length;a++)u.push("..");return(u=u.concat(o.slice(s))).join("/")}};function pe(e,t,r){r=0<r?r:re(e)+1,r=new Array(r),e=te(e,r,0,r.length);return t&&(r.length=e),r}var o={ttys:[],init:function(){},shutdown:function(){},register:function(e,t){o.ttys[e]={input:[],output:[],ops:t},T.registerDevice(e,o.stream_ops)},stream_ops:{open:function(e){var t=o.ttys[e.node.rdev];if(!t)throw new T.ErrnoError(43);e.tty=t,e.seekable=!1},close:function(e){e.tty.ops.flush(e.tty)},flush:function(e){e.tty.ops.flush(e.tty)},read:function(e,t,r,n,o){if(!e.tty||!e.tty.ops.get_char)throw new T.ErrnoError(60);for(var i,s=0,a=0;a<n;a++){try{i=e.tty.ops.get_char(e.tty)}catch(e){throw new T.ErrnoError(29)}if(void 0===i&&0===s)throw new T.ErrnoError(6);if(null==i)break;s++,t[r+a]=i}return s&&(e.node.timestamp=Date.now()),s},write:function(e,t,r,n,o){if(!e.tty||!e.tty.ops.put_char)throw new T.ErrnoError(60);try{for(var i=0;i<n;i++)e.tty.ops.put_char(e.tty,t[r+i])}catch(e){throw new T.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),i}},default_tty_ops:{get_char:function(e){if(!e.input.length){var t=null;if(V){var r=Buffer.alloc(256),n=0;try{n=N.readSync(process.stdin.fd,r,0,256,-1)}catch(e){if(!e.toString().includes("EOF"))throw e;n=0}t=0<n?r.slice(0,n).toString("utf-8"):null}else"undefined"!=typeof window&&"function"==typeof window.prompt?null!==(t=window.prompt("Input: "))&&(t+="\n"):"function"==typeof readline&&null!==(t=readline())&&(t+="\n");if(!t)return null;e.input=pe(t,!0)}return e.input.shift()},put_char:function(e,t){null===t||10===t?(H(s(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},flush:function(e){e.output&&0<e.output.length&&(H(s(e.output,0)),e.output=[])}},default_tty1_ops:{put_char:function(e,t){null===t||10===t?(a(s(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},flush:function(e){e.output&&0<e.output.length&&(a(s(e.output,0)),e.output=[])}}};function he(e){t=e,e=65536*Math.ceil(t/65536);var t=Et(65536,e);return t?(e=e,f.fill(0,t,t+e),t):0}var _={ops_table:null,mount:function(e){return _.createNode(null,"/",16895,0)},createNode:function(e,t,r,n){if(T.isBlkdev(r)||T.isFIFO(r))throw new T.ErrnoError(63);_.ops_table||(_.ops_table={dir:{node:{getattr:_.node_ops.getattr,setattr:_.node_ops.setattr,lookup:_.node_ops.lookup,mknod:_.node_ops.mknod,rename:_.node_ops.rename,unlink:_.node_ops.unlink,rmdir:_.node_ops.rmdir,readdir:_.node_ops.readdir,symlink:_.node_ops.symlink},stream:{llseek:_.stream_ops.llseek}},file:{node:{getattr:_.node_ops.getattr,setattr:_.node_ops.setattr},stream:{llseek:_.stream_ops.llseek,read:_.stream_ops.read,write:_.stream_ops.write,allocate:_.stream_ops.allocate,mmap:_.stream_ops.mmap,msync:_.stream_ops.msync}},link:{node:{getattr:_.node_ops.getattr,setattr:_.node_ops.setattr,readlink:_.node_ops.readlink},stream:{}},chrdev:{node:{getattr:_.node_ops.getattr,setattr:_.node_ops.setattr},stream:T.chrdev_stream_ops}});r=T.createNode(e,t,r,n);return T.isDir(r.mode)?(r.node_ops=_.ops_table.dir.node,r.stream_ops=_.ops_table.dir.stream,r.contents={}):T.isFile(r.mode)?(r.node_ops=_.ops_table.file.node,r.stream_ops=_.ops_table.file.stream,r.usedBytes=0,r.contents=null):T.isLink(r.mode)?(r.node_ops=_.ops_table.link.node,r.stream_ops=_.ops_table.link.stream):T.isChrdev(r.mode)&&(r.node_ops=_.ops_table.chrdev.node,r.stream_ops=_.ops_table.chrdev.stream),r.timestamp=Date.now(),e&&(e.contents[t]=r,e.timestamp=r.timestamp),r},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,t){var r=e.contents?e.contents.length:0;t<=r||(t=Math.max(t,r*(r<1048576?2:1.125)>>>0),0!=r&&(t=Math.max(t,256)),r=e.contents,e.contents=new Uint8Array(t),0<e.usedBytes&&e.contents.set(r.subarray(0,e.usedBytes),0))},resizeFileStorage:function(e,t){var r;e.usedBytes!=t&&(0==t?(e.contents=null,e.usedBytes=0):(r=e.contents,e.contents=new Uint8Array(t),r&&e.contents.set(r.subarray(0,Math.min(t,e.usedBytes))),e.usedBytes=t))},node_ops:{getattr:function(e){var t={};return t.dev=T.isChrdev(e.mode)?e.id:1,t.ino=e.id,t.mode=e.mode,t.nlink=1,t.uid=0,t.gid=0,t.rdev=e.rdev,T.isDir(e.mode)?t.size=4096:T.isFile(e.mode)?t.size=e.usedBytes:T.isLink(e.mode)?t.size=e.link.length:t.size=0,t.atime=new Date(e.timestamp),t.mtime=new Date(e.timestamp),t.ctime=new Date(e.timestamp),t.blksize=4096,t.blocks=Math.ceil(t.size/t.blksize),t},setattr:function(e,t){void 0!==t.mode&&(e.mode=t.mode),void 0!==t.timestamp&&(e.timestamp=t.timestamp),void 0!==t.size&&_.resizeFileStorage(e,t.size)},lookup:function(e,t){throw T.genericErrors[44]},mknod:function(e,t,r,n){return _.createNode(e,t,r,n)},rename:function(e,t,r){if(T.isDir(e.mode)){var n;try{n=T.lookupNode(t,r)}catch(e){}if(n)for(var o in n.contents)throw new T.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=r,t.contents[r]=e,t.timestamp=e.parent.timestamp,e.parent=t},unlink:function(e,t){delete e.contents[t],e.timestamp=Date.now()},rmdir:function(e,t){for(var r in T.lookupNode(e,t).contents)throw new T.ErrnoError(55);delete e.contents[t],e.timestamp=Date.now()},readdir:function(e){var t,r=[".",".."];for(t in e.contents)e.contents.hasOwnProperty(t)&&r.push(t);return r},symlink:function(e,t,r){e=_.createNode(e,t,41471,0);return e.link=r,e},readlink:function(e){if(T.isLink(e.mode))return e.link;throw new T.ErrnoError(28)}},stream_ops:{read:function(e,t,r,n,o){var i=e.node.contents;if(o>=e.node.usedBytes)return 0;var s=Math.min(e.node.usedBytes-o,n);if(8<s&&i.subarray)t.set(i.subarray(o,o+s),r);else for(var a=0;a<s;a++)t[r+a]=i[o+a];return s},write:function(e,t,r,n,o,i){if(!n)return 0;var s=e.node;if(s.timestamp=Date.now(),t.subarray&&(!s.contents||s.contents.subarray)){if(i)return s.contents=t.subarray(r,r+n),s.usedBytes=n;if(0===s.usedBytes&&0===o)return s.contents=t.slice(r,r+n),s.usedBytes=n;if(o+n<=s.usedBytes)return s.contents.set(t.subarray(r,r+n),o),n}if(_.expandFileStorage(s,o+n),s.contents.subarray&&t.subarray)s.contents.set(t.subarray(r,r+n),o);else for(var a=0;a<n;a++)s.contents[o+a]=t[r+a];return s.usedBytes=Math.max(s.usedBytes,o+n),n},llseek:function(e,t,r){if(1===r?t+=e.position:2===r&&T.isFile(e.node.mode)&&(t+=e.node.usedBytes),t<0)throw new T.ErrnoError(28);return t},allocate:function(e,t,r){_.expandFileStorage(e.node,t+r),e.node.usedBytes=Math.max(e.node.usedBytes,t+r)},mmap:function(e,t,r,n,o){if(!T.isFile(e.node.mode))throw new T.ErrnoError(43);var i,s,e=e.node.contents;if(2&o||e.buffer!==G){if((0<r||r+t<e.length)&&(e=e.subarray?e.subarray(r,r+t):Array.prototype.slice.call(e,r,r+t)),s=!0,!(i=he(t)))throw new T.ErrnoError(48);d.set(e,i)}else s=!1,i=e.byteOffset;return{ptr:i,allocated:s}},msync:function(e,t,r,n,o){if(T.isFile(e.node.mode))return 2&o||_.stream_ops.write(e,t,0,n,r,!1),0;throw new T.ErrnoError(43)}}},T={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(!(e=E.resolve(T.cwd(),e)))return{path:"",node:null};if(8<(t=Object.assign({follow_mount:!0,recurse_count:0},t)).recurse_count)throw new T.ErrnoError(32);for(var r=b.normalizeArray(e.split("/").filter(e=>!!e),!1),n=T.root,o="/",i=0;i<r.length;i++){var s=i===r.length-1;if(s&&t.parent)break;if(n=T.lookupNode(n,r[i]),o=b.join2(o,r[i]),!T.isMountpoint(n)||s&&!t.follow_mount||(n=n.mounted.root),!s||t.follow)for(var a=0;T.isLink(n.mode);){var u=T.readlink(o),o=E.resolve(b.dirname(o),u),n=T.lookupPath(o,{recurse_count:t.recurse_count+1}).node;if(40<a++)throw new T.ErrnoError(32)}}return{path:o,node:n}},getPath:e=>{for(var t,r;;){if(T.isRoot(e))return r=e.mount.mountpoint,t?"/"!==r[r.length-1]?r+"/"+t:r+t:r;t=t?e.name+"/"+t:e.name,e=e.parent}},hashName:(e,t)=>{for(var r=0,n=0;n<t.length;n++)r=(r<<5)-r+t.charCodeAt(n)|0;return(e+r>>>0)%T.nameTable.length},hashAddNode:e=>{var t=T.hashName(e.parent.id,e.name);e.name_next=T.nameTable[t],T.nameTable[t]=e},hashRemoveNode:e=>{var t=T.hashName(e.parent.id,e.name);if(T.nameTable[t]===e)T.nameTable[t]=e.name_next;else for(var r=T.nameTable[t];r;){if(r.name_next===e){r.name_next=e.name_next;break}r=r.name_next}},lookupNode:(e,t)=>{var r=T.mayLookup(e);if(r)throw new T.ErrnoError(r,e);for(var r=T.hashName(e.id,t),n=T.nameTable[r];n;n=n.name_next){var o=n.name;if(n.parent.id===e.id&&o===t)return n}return T.lookup(e,t)},createNode:(e,t,r,n)=>{e=new T.FSNode(e,t,r,n);return T.hashAddNode(e),e},destroyNode:e=>{T.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 t=T.flagModes[e];if(void 0===t)throw new Error("Unknown file open mode: "+e);return t},flagsToPermissionString:e=>{var t=["r","w","rw"][3&e];return 512&e&&(t+="w"),t},nodePermissions:(e,t)=>T.ignorePermissions||(!t.includes("r")||292&e.mode)&&(!t.includes("w")||146&e.mode)&&(!t.includes("x")||73&e.mode)?0:2,mayLookup:e=>{return T.nodePermissions(e,"x")||(e.node_ops.lookup?0:2)},mayCreate:(e,t)=>{try{return T.lookupNode(e,t),20}catch(e){}return T.nodePermissions(e,"wx")},mayDelete:(e,t,r)=>{var n;try{n=T.lookupNode(e,t)}catch(e){return e.errno}t=T.nodePermissions(e,"wx");if(t)return t;if(r){if(!T.isDir(n.mode))return 54;if(T.isRoot(n)||T.getPath(n)===T.cwd())return 10}else if(T.isDir(n.mode))return 31;return 0},mayOpen:(e,t)=>e?T.isLink(e.mode)?32:T.isDir(e.mode)&&("r"!==T.flagsToPermissionString(t)||512&t)?31:T.nodePermissions(e,T.flagsToPermissionString(t)):44,MAX_OPEN_FDS:4096,nextfd:function(){for(var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:T.MAX_OPEN_FDS,r=e;r<=t;r++)if(!T.streams[r])return r;throw new T.ErrnoError(33)},getStream:e=>T.streams[e],createStream:(e,t,r)=>{T.FSStream||(T.FSStream=function(){this.shared={}},T.FSStream.prototype={},Object.defineProperties(T.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}},flags:{get:function(){return this.shared.flags},set:function(e){this.shared.flags=e}},position:{get:function(){return this.shared.position},set:function(e){this.shared.position=e}}})),e=Object.assign(new T.FSStream,e);t=T.nextfd(t,r);return e.fd=t,T.streams[t]=e},closeStream:e=>{T.streams[e]=null},chrdev_stream_ops:{open:e=>{var t=T.getDevice(e.node.rdev);e.stream_ops=t.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:()=>{throw new T.ErrnoError(70)}},major:e=>e>>8,minor:e=>255&e,makedev:(e,t)=>e<<8|t,registerDevice:(e,t)=>{T.devices[e]={stream_ops:t}},getDevice:e=>T.devices[e],getMounts:e=>{for(var t=[],r=[e];r.length;){var n=r.pop();t.push(n),r.push.apply(r,n.mounts)}return t},syncfs:(t,r)=>{"function"==typeof t&&(r=t,t=!1),T.syncFSRequests++,1<T.syncFSRequests&&a("warning: "+T.syncFSRequests+" FS.syncfs operations in flight at once, probably just doing extra work");var n=T.getMounts(T.root.mount),o=0;function i(e){return T.syncFSRequests--,r(e)}function s(e){if(e)return s.errored?void 0:(s.errored=!0,i(e));++o>=n.length&&i(null)}n.forEach(e=>{if(!e.type.syncfs)return s(null);e.type.syncfs(e,t,s)})},mount:(e,t,r)=>{var n,o="/"===r,i=!r;if(o&&T.root)throw new T.ErrnoError(10);if(!o&&!i){i=T.lookupPath(r,{follow_mount:!1});if(r=i.path,n=i.node,T.isMountpoint(n))throw new T.ErrnoError(10);if(!T.isDir(n.mode))throw new T.ErrnoError(54)}i={type:e,opts:t,mountpoint:r,mounts:[]},t=e.mount(i);return(t.mount=i).root=t,o?T.root=t:n&&(n.mounted=i,n.mount&&n.mount.mounts.push(i)),t},unmount:e=>{e=T.lookupPath(e,{follow_mount:!1});if(!T.isMountpoint(e.node))throw new T.ErrnoError(28);var e=e.node,t=e.mounted,n=T.getMounts(t),t=(Object.keys(T.nameTable).forEach(e=>{for(var t=T.nameTable[e];t;){var r=t.name_next;n.includes(t.mount)&&T.destroyNode(t),t=r}}),e.mounted=null,e.mount.mounts.indexOf(t));e.mount.mounts.splice(t,1)},lookup:(e,t)=>e.node_ops.lookup(e,t),mknod:(e,t,r)=>{var n=T.lookupPath(e,{parent:!0}).node,e=b.basename(e);if(!e||"."===e||".."===e)throw new T.ErrnoError(28);var o=T.mayCreate(n,e);if(o)throw new T.ErrnoError(o);if(n.node_ops.mknod)return n.node_ops.mknod(n,e,t,r);throw new T.ErrnoError(63)},create:(e,t)=>T.mknod(e,t=(t=void 0!==t?t:438)&4095|32768,0),mkdir:(e,t)=>T.mknod(e,t=(t=void 0!==t?t:511)&1023|16384,0),mkdirTree:(e,t)=>{for(var r=e.split("/"),n="",o=0;o<r.length;++o)if(r[o]){n+="/"+r[o];try{T.mkdir(n,t)}catch(e){if(20!=e.errno)throw e}}},mkdev:(e,t,r)=>(void 0===r&&(r=t,t=438),T.mknod(e,t|=8192,r)),symlink:(e,t)=>{if(!E.resolve(e))throw new T.ErrnoError(44);var r=T.lookupPath(t,{parent:!0}).node;if(!r)throw new T.ErrnoError(44);var t=b.basename(t),n=T.mayCreate(r,t);if(n)throw new T.ErrnoError(n);if(r.node_ops.symlink)return r.node_ops.symlink(r,t,e);throw new T.ErrnoError(63)},rename:(e,t)=>{var r=b.dirname(e),n=b.dirname(t),o=b.basename(e),i=b.basename(t),s=T.lookupPath(e,{parent:!0}).node,a=T.lookupPath(t,{parent:!0}).node;if(!s||!a)throw new T.ErrnoError(44);if(s.mount!==a.mount)throw new T.ErrnoError(75);var u,l=T.lookupNode(s,o);if("."!==E.relative(e,n).charAt(0))throw new T.ErrnoError(28);if("."!==E.relative(t,r).charAt(0))throw new T.ErrnoError(55);try{u=T.lookupNode(a,i)}catch(e){}if(l!==u){n=T.isDir(l.mode),t=T.mayDelete(s,o,n);if(t)throw new T.ErrnoError(t);if(t=u?T.mayDelete(a,i,n):T.mayCreate(a,i))throw new T.ErrnoError(t);if(!s.node_ops.rename)throw new T.ErrnoError(63);if(T.isMountpoint(l)||u&&T.isMountpoint(u))throw new T.ErrnoError(10);if(a!==s&&(t=T.nodePermissions(s,"w")))throw new T.ErrnoError(t);T.hashRemoveNode(l);try{s.node_ops.rename(l,a,i)}catch(e){throw e}finally{T.hashAddNode(l)}}},rmdir:e=>{var t=T.lookupPath(e,{parent:!0}).node,e=b.basename(e),r=T.lookupNode(t,e),n=T.mayDelete(t,e,!0);if(n)throw new T.ErrnoError(n);if(!t.node_ops.rmdir)throw new T.ErrnoError(63);if(T.isMountpoint(r))throw new T.ErrnoError(10);t.node_ops.rmdir(t,e),T.destroyNode(r)},readdir:e=>{e=T.lookupPath(e,{follow:!0}).node;if(e.node_ops.readdir)return e.node_ops.readdir(e);throw new T.ErrnoError(54)},unlink:e=>{var t=T.lookupPath(e,{parent:!0}).node;if(!t)throw new T.ErrnoError(44);var e=b.basename(e),r=T.lookupNode(t,e),n=T.mayDelete(t,e,!1);if(n)throw new T.ErrnoError(n);if(!t.node_ops.unlink)throw new T.ErrnoError(63);if(T.isMountpoint(r))throw new T.ErrnoError(10);t.node_ops.unlink(t,e),T.destroyNode(r)},readlink:e=>{e=T.lookupPath(e).node;if(!e)throw new T.ErrnoError(44);if(e.node_ops.readlink)return E.resolve(T.getPath(e.parent),e.node_ops.readlink(e));throw new T.ErrnoError(28)},stat:(e,t)=>{e=T.lookupPath(e,{follow:!t}).node;if(!e)throw new T.ErrnoError(44);if(e.node_ops.getattr)return e.node_ops.getattr(e);throw new T.ErrnoError(63)},lstat:e=>T.stat(e,!0),chmod:(e,t,r)=>{r="string"==typeof e?T.lookupPath(e,{follow:!r}).node:e;if(!r.node_ops.setattr)throw new T.ErrnoError(63);r.node_ops.setattr(r,{mode:4095&t|-4096&r.mode,timestamp:Date.now()})},lchmod:(e,t)=>{T.chmod(e,t,!0)},fchmod:(e,t)=>{e=T.getStream(e);if(!e)throw new T.ErrnoError(8);T.chmod(e.node,t)},chown:(e,t,r,n)=>{n="string"==typeof e?T.lookupPath(e,{follow:!n}).node:e;if(!n.node_ops.setattr)throw new T.ErrnoError(63);n.node_ops.setattr(n,{timestamp:Date.now()})},lchown:(e,t,r)=>{T.chown(e,t,r,!0)},fchown:(e,t,r)=>{e=T.getStream(e);if(!e)throw new T.ErrnoError(8);T.chown(e.node,t,r)},truncate:(e,t)=>{if(t<0)throw new T.ErrnoError(28);e="string"==typeof e?T.lookupPath(e,{follow:!0}).node:e;if(!e.node_ops.setattr)throw new T.ErrnoError(63);if(T.isDir(e.mode))throw new T.ErrnoError(31);if(!T.isFile(e.mode))throw new T.ErrnoError(28);var r=T.nodePermissions(e,"w");if(r)throw new T.ErrnoError(r);e.node_ops.setattr(e,{size:t,timestamp:Date.now()})},ftruncate:(e,t)=>{e=T.getStream(e);if(!e)throw new T.ErrnoError(8);if(0==(2097155&e.flags))throw new T.ErrnoError(28);T.truncate(e.node,t)},utime:(e,t,r)=>{e=T.lookupPath(e,{follow:!0}).node;e.node_ops.setattr(e,{timestamp:Math.max(t,r)})},open:(e,t,r)=>{if(""===e)throw new T.ErrnoError(44);var n;if(r=void 0===r?438:r,r=64&(t="string"==typeof t?T.modeStringToFlags(t):t)?4095&r|32768:0,"object"==typeof e)n=e;else{e=b.normalize(e);try{n=T.lookupPath(e,{follow:!(131072&t)}).node}catch(e){}}var o=!1;if(64&t)if(n){if(128&t)throw new T.ErrnoError(20)}else n=T.mknod(e,r,0),o=!0;if(!n)throw new T.ErrnoError(44);if(T.isChrdev(n.mode)&&(t&=-513),65536&t&&!T.isDir(n.mode))throw new T.ErrnoError(54);if(!o){r=T.mayOpen(n,t);if(r)throw new T.ErrnoError(r)}512&t&&!o&&T.truncate(n,0),t&=-131713;r=T.createStream({node:n,path:T.getPath(n),flags:t,seekable:!0,position:0,stream_ops:n.stream_ops,ungotten:[],error:!1});return r.stream_ops.open&&r.stream_ops.open(r),!y.logReadFiles||1&t||(T.readFiles||(T.readFiles={}),e in T.readFiles||(T.readFiles[e]=1)),r},close:e=>{if(T.isClosed(e))throw new T.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(e){throw e}finally{T.closeStream(e.fd)}e.fd=null},isClosed:e=>null===e.fd,llseek:(e,t,r)=>{if(T.isClosed(e))throw new T.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new T.ErrnoError(70);if(0!=r&&1!=r&&2!=r)throw new T.ErrnoError(28);return e.position=e.stream_ops.llseek(e,t,r),e.ungotten=[],e.position},read:(e,t,r,n,o)=>{if(n<0||o<0)throw new T.ErrnoError(28);if(T.isClosed(e))throw new T.ErrnoError(8);if(1==(2097155&e.flags))throw new T.ErrnoError(8);if(T.isDir(e.node.mode))throw new T.ErrnoError(31);if(!e.stream_ops.read)throw new T.ErrnoError(28);var i=void 0!==o;if(i){if(!e.seekable)throw new T.ErrnoError(70)}else o=e.position;t=e.stream_ops.read(e,t,r,n,o);return i||(e.position+=t),t},write:(e,t,r,n,o,i)=>{if(n<0||o<0)throw new T.ErrnoError(28);if(T.isClosed(e))throw new T.ErrnoError(8);if(0==(2097155&e.flags))throw new T.ErrnoError(8);if(T.isDir(e.node.mode))throw new T.ErrnoError(31);if(!e.stream_ops.write)throw new T.ErrnoError(28);e.seekable&&1024&e.flags&&T.llseek(e,0,2);var s=void 0!==o;if(s){if(!e.seekable)throw new T.ErrnoError(70)}else o=e.position;t=e.stream_ops.write(e,t,r,n,o,i);return s||(e.position+=t),t},allocate:(e,t,r)=>{if(T.isClosed(e))throw new T.ErrnoError(8);if(t<0||r<=0)throw new T.ErrnoError(28);if(0==(2097155&e.flags))throw new T.ErrnoError(8);if(!T.isFile(e.node.mode)&&!T.isDir(e.node.mode))throw new T.ErrnoError(43);if(!e.stream_ops.allocate)throw new T.ErrnoError(138);e.stream_ops.allocate(e,t,r)},mmap:(e,t,r,n,o)=>{if(0!=(2&n)&&0==(2&o)&&2!=(2097155&e.flags))throw new T.ErrnoError(2);if(1==(2097155&e.flags))throw new T.ErrnoError(2);if(e.stream_ops.mmap)return e.stream_ops.mmap(e,t,r,n,o);throw new T.ErrnoError(43)},msync:(e,t,r,n,o)=>e&&e.stream_ops.msync?e.stream_ops.msync(e,t,r,n,o):0,munmap:e=>0,ioctl:(e,t,r)=>{if(e.stream_ops.ioctl)return e.stream_ops.ioctl(e,t,r);throw new T.ErrnoError(59)},readFile:function(e){let t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(t.flags=t.flags||0,t.encoding=t.encoding||"binary","utf8"!==t.encoding&&"binary"!==t.encoding)throw new Error('Invalid encoding type "'+t.encoding+'"');var r,n=T.open(e,t.flags),e=T.stat(e).size,o=new Uint8Array(e);return T.read(n,o,0,e,0),"utf8"===t.encoding?r=s(o,0):"binary"===t.encoding&&(r=o),T.close(n),r},writeFile:function(e,t){let r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};r.flags=r.flags||577;e=T.open(e,r.flags,r.mode);if("string"==typeof t){var n=new Uint8Array(re(t)+1),o=te(t,n,0,n.length);T.write(e,n,0,o,void 0,r.canOwn)}else{if(!ArrayBuffer.isView(t))throw new Error("Unsupported data type");T.write(e,t,0,t.byteLength,void 0,r.canOwn)}T.close(e)},cwd:()=>T.currentPath,chdir:e=>{e=T.lookupPath(e,{follow:!0});if(null===e.node)throw new T.ErrnoError(44);if(!T.isDir(e.node.mode))throw new T.ErrnoError(54);var t=T.nodePermissions(e.node,"x");if(t)throw new T.ErrnoError(t);T.currentPath=e.path},createDefaultDirectories:()=>{T.mkdir("/tmp"),T.mkdir("/home"),T.mkdir("/home/web_user")},createDefaultDevices:()=>{T.mkdir("/dev"),T.registerDevice(T.makedev(1,3),{read:()=>0,write:(e,t,r,n,o)=>n}),T.mkdev("/dev/null",T.makedev(1,3)),o.register(T.makedev(5,0),o.default_tty_ops),o.register(T.makedev(6,0),o.default_tty1_ops),T.mkdev("/dev/tty",T.makedev(5,0)),T.mkdev("/dev/tty1",T.makedev(6,0));var e=function(){var e;if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues)return e=new Uint8Array(1),()=>(crypto.getRandomValues(e),e[0]);if(V)try{var t=Dt.default;return()=>t.randomBytes(1)[0]}catch(e){}return()=>w("randomDevice")}();T.createDevice("/dev","random",e),T.createDevice("/dev","urandom",e),T.mkdir("/dev/shm"),T.mkdir("/dev/shm/tmp")},createSpecialDirectories:()=>{T.mkdir("/proc");var t=T.mkdir("/proc/self");T.mkdir("/proc/self/fd"),T.mount({mount:()=>{var e=T.createNode(t,"fd",16895,73);return e.node_ops={lookup:(e,t)=>{var r=T.getStream(+t);if(!r)throw new T.ErrnoError(8);t={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>r.path}};return t.parent=t}},e}},{},"/proc/self/fd")},createStandardStreams:()=>{y.stdin?T.createDevice("/dev","stdin",y.stdin):T.symlink("/dev/tty","/dev/stdin"),y.stdout?T.createDevice("/dev","stdout",null,y.stdout):T.symlink("/dev/tty","/dev/stdout"),y.stderr?T.createDevice("/dev","stderr",null,y.stderr):T.symlink("/dev/tty1","/dev/stderr"),T.open("/dev/stdin",0),T.open("/dev/stdout",1),T.open("/dev/stderr",1)},ensureErrnoError:()=>{T.ErrnoError||(T.ErrnoError=function(e,t){this.node=t,this.setErrno=function(e){this.errno=e},this.setErrno(e),this.message="FS error"},T.ErrnoError.prototype=new Error,T.ErrnoError.prototype.constructor=T.ErrnoError,[44].forEach(e=>{T.genericErrors[e]=new T.ErrnoError(e),T.genericErrors[e].stack="<generic error, no stack>"}))},staticInit:()=>{T.ensureErrnoError(),T.nameTable=new Array(4096),T.mount(_,{},"/"),T.createDefaultDirectories(),T.createDefaultDevices(),T.createSpecialDirectories(),T.filesystems={MEMFS:_}},init:(e,t,r)=>{T.init.initialized=!0,T.ensureErrnoError(),y.stdin=e||y.stdin,y.stdout=t||y.stdout,y.stderr=r||y.stderr,T.createStandardStreams()},quit:()=>{T.init.initialized=!1;for(var e=0;e<T.streams.length;e++){var t=T.streams[e];t&&T.close(t)}},getMode:(e,t)=>{var r=0;return e&&(r|=365),t&&(r|=146),r},findObject:(e,t)=>{e=T.analyzePath(e,t);return e.exists?e.object:null},analyzePath:(e,t)=>{try{e=(n=T.lookupPath(e,{follow:!t})).path}catch(e){}var r={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var n=T.lookupPath(e,{parent:!0});r.parentExists=!0,r.parentPath=n.path,r.parentObject=n.node,r.name=b.basename(e),n=T.lookupPath(e,{follow:!t}),r.exists=!0,r.path=n.path,r.object=n.node,r.name=n.node.name,r.isRoot="/"===n.path}catch(e){r.error=e.errno}return r},createPath:(e,t,r,n)=>{e="string"==typeof e?e:T.getPath(e);for(var o=t.split("/").reverse();o.length;){var i=o.pop();if(i){var s=b.join2(e,i);try{T.mkdir(s)}catch(e){}e=s}}return s},createFile:(e,t,r,n,o)=>{e=b.join2("string"==typeof e?e:T.getPath(e),t),t=T.getMode(n,o);return T.create(e,t)},createDataFile:(e,t,r,n,o,i)=>{var s=t,t=(e&&(e="string"==typeof e?e:T.getPath(e),s=t?b.join2(e,t):e),T.getMode(n,o)),e=T.create(s,t);if(r){if("string"==typeof r){for(var a=new Array(r.length),u=0,l=r.length;u<l;++u)a[u]=r.charCodeAt(u);r=a}T.chmod(e,146|t);n=T.open(e,577);T.write(n,r,0,r.length,0,i),T.close(n),T.chmod(e,t)}return e},createDevice:(e,t,u,s)=>{var e=b.join2("string"==typeof e?e:T.getPath(e),t),t=T.getMode(!!u,!!s),r=(T.createDevice.major||(T.createDevice.major=64),T.makedev(T.createDevice.major++,0));return T.registerDevice(r,{open:e=>{e.seekable=!1},close:e=>{s&&s.buffer&&s.buffer.length&&s(10)},read:(e,t,r,n,o)=>{for(var i,s=0,a=0;a<n;a++){try{i=u()}catch(e){throw new T.ErrnoError(29)}if(void 0===i&&0===s)throw new T.ErrnoError(6);if(null==i)break;s++,t[r+a]=i}return s&&(e.node.timestamp=Date.now()),s},write:(e,t,r,n,o)=>{for(var i=0;i<n;i++)try{s(t[r+i])}catch(e){throw new T.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),i}}),T.mkdev(e,t,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(!t)throw new Error("Cannot load without read() or XMLHttpRequest.");try{e.contents=pe(t(e.url),!0),e.usedBytes=e.contents.length}catch(e){throw new T.ErrnoError(29)}},createLazyFile:(e,t,s,r,n)=>{function o(){this.lengthKnown=!1,this.chunks=[]}if(o.prototype.get=function(e){var t;if(!(e>this.length-1||e<0))return t=e%this.chunkSize,e=e/this.chunkSize|0,this.getter(e)[t]},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 t,n=Number(e.getResponseHeader("Content-length")),r=(t=e.getResponseHeader("Accept-Ranges"))&&"bytes"===t,e=(t=e.getResponseHeader("Content-Encoding"))&&"gzip"===t,o=1048576,i=(r||(o=n),this);i.setDataGetter(e=>{var t=e*o,r=(e+1)*o-1,r=Math.min(r,n-1);if(void 0===i.chunks[e]&&(i.chunks[e]=((e,t)=>{if(t<e)throw new Error("invalid range ("+e+", "+t+") or no bytes requested!");if(n-1<t)throw new Error("only "+n+" bytes available! programmer error!");var r=new XMLHttpRequest;if(r.open("GET",s,!1),n!==o&&r.setRequestHeader("Range","bytes="+e+"-"+t),r.responseType="arraybuffer",r.overrideMimeType&&r.overrideMimeType("text/plain; charset=x-user-defined"),r.send(null),200<=r.status&&r.status<300||304===r.status)return void 0!==r.response?new Uint8Array(r.response||[]):pe(r.responseText||"",!0);throw new Error("Couldn't load "+s+". Status: "+r.status)})(t,r)),void 0===i.chunks[e])throw new Error("doXHR failed!");return i.chunks[e]}),!e&&n||(o=n=1,n=this.getter(0).length,o=n,H("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(!c)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var i=new o,i=(Object.defineProperties(i,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}}),{isDevice:!1,contents:i})}else i={isDevice:!1,url:s};var a=T.createFile(e,t,i,r,n),u=(i.contents?a.contents=i.contents:i.url&&(a.contents=null,a.url=i.url),Object.defineProperties(a,{usedBytes:{get:function(){return this.contents.length}}}),{});function l(e,t,r,n,o){var i=e.node.contents;if(o>=i.length)return 0;var s=Math.min(i.length-o,n);if(i.slice)for(var a=0;a<s;a++)t[r+a]=i[o+a];else for(a=0;a<s;a++)t[r+a]=i.get(o+a);return s}return Object.keys(a.stream_ops).forEach(e=>{var t=a.stream_ops[e];u[e]=function(){return T.forceLoadFile(a),t.apply(null,arguments)}}),u.read=(e,t,r,n,o)=>(T.forceLoadFile(a),l(e,t,r,n,o)),u.mmap=(e,t,r,n,o)=>{T.forceLoadFile(a);var i=he(t);if(i)return l(e,d,i,t,r),{ptr:i,allocated:!0};throw new T.ErrnoError(48)},a.stream_ops=u,a},createPreloadedFile:(r,n,e,o,i,s,a,u,l,c)=>{var t,d,f,p=n?E.resolve(b.join2(r,n)):r;function h(e){function t(e){c&&c(),u||T.createDataFile(r,n,e,o,i,l),s&&s(),ae()}Browser.handledByPreloadPlugin(e,p,t,()=>{a&&a(),ae()})||t(e)}se(),"string"==typeof e?(d=a,f="al "+(t=e),m(t,e=>{q(e,'Loading data file "'+t+'" failed (no arrayBuffer).'),h(new Uint8Array(e)),f&&ae()},e=>{if(!d)throw'Loading data file "'+t+'" failed.';d()}),f&&se()):h(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,a,u)=>{a=a||(()=>{}),u=u||(()=>{});var e=T.indexedDB();try{var l=e.open(T.DB_NAME(),T.DB_VERSION)}catch(s){return u(s)}l.onupgradeneeded=()=>{H("creating db"),l.result.createObjectStore(T.DB_STORE_NAME)},l.onsuccess=()=>{var e=l.result.transaction([T.DB_STORE_NAME],"readwrite"),t=e.objectStore(T.DB_STORE_NAME),r=0,n=0,o=s.length;function i(){(0==n?a:u)()}s.forEach(e=>{e=t.put(T.analyzePath(e).object.contents,e);e.onsuccess=()=>{++r+n==o&&i()},e.onerror=()=>{r+ ++n==o&&i()}}),e.onerror=u},l.onerror=u},loadFilesFromDB:(a,u,l)=>{u=u||(()=>{}),l=l||(()=>{});var e=T.indexedDB();try{var c=e.open(T.DB_NAME(),T.DB_VERSION)}catch(a){return l(a)}c.onupgradeneeded=l,c.onsuccess=()=>{var e=c.result;try{var t=e.transaction([T.DB_STORE_NAME],"readonly")}catch(e){return void l(e)}var r=t.objectStore(T.DB_STORE_NAME),n=0,o=0,i=a.length;function s(){(0==o?u:l)()}a.forEach(e=>{var t=r.get(e);t.onsuccess=()=>{T.analyzePath(e).exists&&T.unlink(e),T.createDataFile(b.dirname(e),b.basename(e),t.result,!0,!0,!0),++n+o==i&&s()},t.onerror=()=>{n+ ++o==i&&s()}}),t.onerror=l},c.onerror=l}},k={DEFAULT_POLLMASK:5,calculateAt:function(e,t,r){if(b.isAbs(t))return t;var n;if(-100===e)n=T.cwd();else{e=T.getStream(e);if(!e)throw new T.ErrnoError(8);n=e.path}if(0!=t.length)return b.join2(n,t);if(r)return n;throw new T.ErrnoError(44)},doStat:function(e,t,r){try{var n=e(t)}catch(e){if(e&&e.node&&b.normalize(t)!==b.normalize(T.getPath(e.node)))return-54;throw e}return l[r>>2]=n.dev,l[r+4>>2]=0,l[r+8>>2]=n.ino,l[r+12>>2]=n.mode,l[r+16>>2]=n.nlink,l[r+20>>2]=n.uid,l[r+24>>2]=n.gid,l[r+28>>2]=n.rdev,l[r+32>>2]=0,v=[n.size>>>0,(g=n.size,1<=+Math.abs(g)?0<g?(0|Math.min(+Math.floor(g/4294967296),4294967295))>>>0:~~+Math.ceil((g-(~~g>>>0))/4294967296)>>>0:0)],l[r+40>>2]=v[0],l[r+44>>2]=v[1],l[r+48>>2]=4096,l[r+52>>2]=n.blocks,v=[Math.floor(n.atime.getTime()/1e3)>>>0,(g=Math.floor(n.atime.getTime()/1e3),1<=+Math.abs(g)?0<g?(0|Math.min(+Math.floor(g/4294967296),4294967295))>>>0:~~+Math.ceil((g-(~~g>>>0))/4294967296)>>>0:0)],l[r+56>>2]=v[0],l[r+60>>2]=v[1],l[r+64>>2]=0,v=[Math.floor(n.mtime.getTime()/1e3)>>>0,(g=Math.floor(n.mtime.getTime()/1e3),1<=+Math.abs(g)?0<g?(0|Math.min(+Math.floor(g/4294967296),4294967295))>>>0:~~+Math.ceil((g-(~~g>>>0))/4294967296)>>>0:0)],l[r+72>>2]=v[0],l[r+76>>2]=v[1],l[r+80>>2]=0,v=[Math.floor(n.ctime.getTime()/1e3)>>>0,(g=Math.floor(n.ctime.getTime()/1e3),1<=+Math.abs(g)?0<g?(0|Math.min(+Math.floor(g/4294967296),4294967295))>>>0:~~+Math.ceil((g-(~~g>>>0))/4294967296)>>>0:0)],l[r+88>>2]=v[0],l[r+92>>2]=v[1],l[r+96>>2]=0,v=[n.ino>>>0,(g=n.ino,1<=+Math.abs(g)?0<g?(0|Math.min(+Math.floor(g/4294967296),4294967295))>>>0:~~+Math.ceil((g-(~~g>>>0))/4294967296)>>>0:0)],l[r+104>>2]=v[0],l[r+108>>2]=v[1],0},doMsync:function(e,t,r,n,o){e=f.slice(e,e+r);T.msync(t,e,o,r,n)},varargs:void 0,get:function(){return k.varargs+=4,l[k.varargs-4>>2]},getStr:function(e){return ee(e)},getStreamFromFD:function(e){e=T.getStream(e);if(e)return e;throw new T.ErrnoError(8)}};function me(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+e)}}var ye=void 0;function A(e){for(var t="",r=e;f[r];)t+=ye[f[r++]];return t}var D={},C={},ge={};function ve(e){if(void 0===e)return"_unknown";var t=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return 48<=t&&t<=57?"_"+e:e}function we(e,t){return e=ve(e),new Function("body","return function "+e+'() {\n "use strict"; return body.apply(this, arguments);\n};\n')(t)}function be(e,t){var r=we(t,function(e){this.name=t,this.message=e;e=new Error(e).stack;void 0!==e&&(this.stack=this.toString()+"\n"+e.replace(/^Error(:[^\n]*)?\n/,""))});return r.prototype=Object.create(e.prototype),(r.prototype.constructor=r).prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message},r}var F=void 0;function S(e){throw new F(e)}var Ee=void 0;function _e(e){throw new Ee(e)}function Te(n,t,o){function r(e){var t=o(e);t.length!==n.length&&_e("Mismatched type converter count");for(var r=0;r<n.length;++r)P(n[r],t[r])}n.forEach(function(e){ge[e]=t});var i=new Array(t.length),s=[],a=0;t.forEach((e,t)=>{C.hasOwnProperty(e)?i[t]=C[e]:(s.push(e),D.hasOwnProperty(e)||(D[e]=[]),D[e].push(()=>{i[t]=C[e],++a===s.length&&r(i)}))}),0===s.length&&r(i)}function P(e,t,r){r=2<arguments.length&&void 0!==r?r:{};if(!("argPackAdvance"in t))throw new TypeError("registerType registeredInstance requires argPackAdvance");var n=t.name;if(e||S('type "'+n+'" must have a positive integer typeid pointer'),C.hasOwnProperty(e)){if(r.ignoreDuplicateRegistrations)return;S("Cannot register type '"+n+"' twice")}C[e]=t,delete ge[e],D.hasOwnProperty(e)&&(r=D[e],delete D[e],r.forEach(e=>e()))}function ke(e){S(e.$$.ptrType.registeredClass.name+" instance already deleted")}var Ae=!1;function De(e){}function Ce(e){--e.count.value,0===e.count.value&&((e=e).smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr))}var Fe={};var Se=[];function Pe(){for(;Se.length;){var e=Se.pop();e.$$.deleteScheduled=!1,e.delete()}}var Re=void 0;var xe={};function Me(e,t){return t.ptrType&&t.ptr||_e("makeClassHandle requires ptr and ptrType"),!!t.smartPtrType!=!!t.smartPtr&&_e("Both smartPtrType and smartPtr must be specified"),t.count={value:1},Ie(Object.create(e,{$$:{value:t}}))}function Ie(e){return"undefined"==typeof FinalizationRegistry?(Ie=e=>e,e):(Ae=new FinalizationRegistry(e=>{Ce(e.$$)}),De=e=>Ae.unregister(e),(Ie=e=>{var t=e.$$;return t.smartPtr&&Ae.register(e,{$$:t},e),e})(e))}function R(){}function Ue(e,t,r){var n;void 0===e[t].overloadTable&&(n=e[t],e[t]=function(){return e[t].overloadTable.hasOwnProperty(arguments.length)||S("Function '"+r+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+e[t].overloadTable+")!"),e[t].overloadTable[arguments.length].apply(this,arguments)},e[t].overloadTable=[],e[t].overloadTable[n.argCount]=n)}function $e(e,t,r,n,o,i,s,a){this.name=e,this.constructor=t,this.instancePrototype=r,this.rawDestructor=n,this.baseClass=o,this.getActualType=i,this.upcast=s,this.downcast=a,this.pureVirtualFunctions=[]}function Be(e,t,r){for(;t!==r;)t.upcast||S("Expected null or instance of "+r.name+", got an instance of "+t.name),e=t.upcast(e),t=t.baseClass;return e}function Ne(e,t){if(null===t)return this.isReference&&S("null is not a valid "+this.name),0;t.$$||S('Cannot pass "'+et(t)+'" as a '+this.name),t.$$.ptr||S("Cannot pass deleted object as a pointer of type "+this.name);var r=t.$$.ptrType.registeredClass;return Be(t.$$.ptr,r,this.registeredClass)}function Oe(e,t){if(null===t)return this.isReference&&S("null is not a valid "+this.name),this.isSmartPointer?(n=this.rawConstructor(),null!==e&&e.push(this.rawDestructor,n),n):0;t.$$||S('Cannot pass "'+et(t)+'" as a '+this.name),t.$$.ptr||S("Cannot pass deleted object as a pointer of type "+this.name),!this.isConst&&t.$$.ptrType.isConst&&S("Cannot convert argument of type "+(t.$$.smartPtrType||t.$$.ptrType).name+" to parameter type "+this.name);var r,n,o=t.$$.ptrType.registeredClass;if(n=Be(t.$$.ptr,o,this.registeredClass),this.isSmartPointer)switch(void 0===t.$$.smartPtr&&S("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:t.$$.smartPtrType===this?n=t.$$.smartPtr:S("Cannot convert argument of type "+(t.$$.smartPtrType||t.$$.ptrType).name+" to parameter type "+this.name);break;case 1:n=t.$$.smartPtr;break;case 2:t.$$.smartPtrType===this?n=t.$$.smartPtr:(r=t.clone(),n=this.rawShare(n,Ze.toHandle(function(){r.delete()})),null!==e&&e.push(this.rawDestructor,n));break;default:S("Unsupporting sharing policy")}return n}function je(e,t){if(null===t)return this.isReference&&S("null is not a valid "+this.name),0;t.$$||S('Cannot pass "'+et(t)+'" as a '+this.name),t.$$.ptr||S("Cannot pass deleted object as a pointer of type "+this.name),t.$$.ptrType.isConst&&S("Cannot convert argument of type "+t.$$.ptrType.name+" to parameter type "+this.name);var r=t.$$.ptrType.registeredClass;return Be(t.$$.ptr,r,this.registeredClass)}function Le(e){return this.fromWireType(l[e>>2])}function x(e,t,r,n,o,i,s,a,u,l,c){this.name=e,this.registeredClass=t,this.isReference=r,this.isConst=n,this.isSmartPointer=o,this.pointeeType=i,this.sharingPolicy=s,this.rawGetPointee=a,this.rawConstructor=u,this.rawShare=l,this.rawDestructor=c,o||void 0!==t.baseClass?this.toWireType=Oe:(this.toWireType=n?Ne:je,this.destructorFunction=null)}var We=[];function ze(e){var t=We[e];return t||(e>=We.length&&(We.length=e+1),We[e]=t=Q.get(e)),t}function M(e,t){var o,i,s,r=(e=A(e)).includes("j")?(o=e,i=t,s=[],function(){return s.length=0,Object.assign(s,arguments),t=i,r=s,(e=o).includes("j")?(n=t,e=y["dynCall_"+e],r&&r.length?e.apply(null,[n].concat(r)):e.call(null,n)):ze(t).apply(null,r);var e,t,r,n}):ze(t);return"function"!=typeof r&&S("unknown function pointer with signature "+e+": "+t),r}var Ve=void 0;function He(e){var e=wt(e),t=A(e);return U(e),t}function Xe(e,t){var r=[],n={};throw t.forEach(function e(t){n[t]||C[t]||(ge[t]?ge[t].forEach(e):(r.push(t),n[t]=!0))}),new Ve(e+": "+r.map(He).join([", "]))}function qe(e,t){for(var r=[],n=0;n<e;n++)r.push(p[t+4*n>>2]);return r}function Ge(e){for(;e.length;){var t=e.pop();e.pop()(t)}}function Je(e,t){if(!(e instanceof Function))throw new TypeError("new_ called with constructor type "+typeof e+" which is not a function");var r=we(e.name||"unknownFunctionName",function(){}),r=(r.prototype=e.prototype,new r),e=e.apply(r,t);return e instanceof Object?e:r}function Ye(e,t,r,n,o){var i=t.length;i<2&&S("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var r=null!==t[1]&&null!==r,s=!1,a=1;a<t.length;++a)if(null!==t[a]&&void 0===t[a].destructorFunction){s=!0;break}for(var u="void"!==t[0].name,l="",c="",a=0;a<i-2;++a)l+=(0!==a?", ":"")+"arg"+a,c+=(0!==a?", ":"")+"arg"+a+"Wired";var d="return function "+ve(e)+"("+l+") {\nif (arguments.length !== "+(i-2)+") {\nthrowBindingError('function "+e+" called with ' + arguments.length + ' arguments, expected "+(i-2)+" args!');\n}\n",f=(s&&(d+="var destructors = [];\n"),s?"destructors":"null"),p=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],h=[S,n,o,Ge,t[0],t[1]];for(r&&(d+="var thisWired = classParam.toWireType("+f+", this);\n"),a=0;a<i-2;++a)d+="var arg"+a+"Wired = argType"+a+".toWireType("+f+", arg"+a+"); // "+t[a+2].name+"\n",p.push("argType"+a),h.push(t[a+2]);if(d+=(u?"var rv = ":"")+"invoker(fn"+(0<(c=r?"thisWired"+(0<c.length?", ":"")+c:c).length?", ":"")+c+");\n",s)d+="runDestructors(destructors);\n";else for(a=r?1:2;a<t.length;++a){var m=1===a?"thisWired":"arg"+(a-2)+"Wired";null!==t[a].destructorFunction&&(d+=m+"_dtor("+m+"); // "+t[a].name+"\n",p.push(m+"_dtor"),h.push(t[a].destructorFunction))}return u&&(d+="var ret = retType.fromWireType(rv);\nreturn ret;\n"),p.push(d+="}\n"),Je(Function,p).apply(null,h)}var Ke=[],I=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function Qe(e){4<e&&0==--I[e].refcount&&(I[e]=void 0,Ke.push(e))}var Ze={toValue:e=>(e||S("Cannot use deleted val. handle = "+e),I[e].value),toHandle:e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var t=Ke.length?Ke.pop():I.length;return I[t]={refcount:1,value:e},t}}};function et(e){if(null===e)return"null";var t=typeof e;return"object"==t||"array"==t||"function"==t?e.toString():""+e}var tt="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0;function rt(e,t){for(var r,n=e>>1,o=n+t/2;!(o<=n)&&J[n];)++n;if(32<(r=n<<1)-e&&tt)return tt.decode(f.subarray(e,r));for(var i="",s=0;!(t/2<=s);++s){var a=u[e+2*s>>1];if(0==a)break;i+=String.fromCharCode(a)}return i}function nt(e,t,r){if((r=void 0===r?2147483647:r)<2)return 0;for(var n=t,o=(r-=2)<2*e.length?r/2:e.length,i=0;i<o;++i){var s=e.charCodeAt(i);u[t>>1]=s,t+=2}return u[t>>1]=0,t-n}function ot(e){return 2*e.length}function it(e,t){for(var r=0,n="";!(t/4<=r);){var o,i=l[e+4*r>>2];if(0==i)break;++r,65536<=i?(o=i-65536,n+=String.fromCharCode(55296|o>>10,56320|1023&o)):n+=String.fromCharCode(i)}return n}function st(e,t,r){if((r=void 0===r?2147483647:r)<4)return 0;for(var n=t,o=n+r-4,i=0;i<e.length;++i){var s=e.charCodeAt(i);if(55296<=s&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++i)),l[t>>2]=s,(t+=4)+4>o)break}return l[t>>2]=0,t-n}function at(e){for(var t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);55296<=n&&n<=57343&&++r,t+=4}return t}var ut={},lt=[],ct=[],dt={};function ft(){if(!ft.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",_:W||"./this.program"};for(t in dt)void 0===dt[t]?delete e[t]:e[t]=dt[t];var t,r=[];for(t in e)r.push(t+"="+e[t]);ft.strings=r}return ft.strings}function pt(e,t,r,n){this.parent=e=e||this,this.mount=e.mount,this.mounted=null,this.id=T.nextInode++,this.name=t,this.mode=r,this.node_ops={},this.stream_ops={},this.rdev=n}Object.defineProperties(pt.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 T.isDir(this.mode)}},isDevice:{get:function(){return T.isChrdev(this.mode)}}}),T.FSNode=pt,T.staticInit();for(var ht=new Array(256),mt=0;mt<256;++mt)ht[mt]=String.fromCharCode(mt);ye=ht,F=y.BindingError=be(Error,"BindingError"),Ee=y.InternalError=be(Error,"InternalError"),R.prototype.isAliasOf=function(e){if(!(this instanceof R))return!1;if(!(e instanceof R))return!1;for(var t=this.$$.ptrType.registeredClass,r=this.$$.ptr,n=e.$$.ptrType.registeredClass,o=e.$$.ptr;t.baseClass;)r=t.upcast(r),t=t.baseClass;for(;n.baseClass;)o=n.upcast(o),n=n.baseClass;return t===n&&r===o},R.prototype.clone=function(){if(this.$$.ptr||ke(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e=Ie(Object.create(Object.getPrototypeOf(this),{$$:{value:{count:(e=this.$$).count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}}}));return e.$$.count.value+=1,e.$$.deleteScheduled=!1,e},R.prototype.delete=function(){this.$$.ptr||ke(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&S("Object already scheduled for deletion"),De(this),Ce(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},R.prototype.isDeleted=function(){return!this.$$.ptr},R.prototype.deleteLater=function(){return this.$$.ptr||ke(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&S("Object already scheduled for deletion"),Se.push(this),1===Se.length&&Re&&Re(Pe),this.$$.deleteScheduled=!0,this},y.getInheritedInstanceCount=function(){return Object.keys(xe).length},y.getLiveInheritedInstances=function(){var e,t=[];for(e in xe)xe.hasOwnProperty(e)&&t.push(xe[e]);return t},y.flushPendingDeletes=Pe,y.setDelayFunction=function(e){Re=e,Se.length&&Re&&Re(Pe)},x.prototype.getPointee=function(e){return e=this.rawGetPointee?this.rawGetPointee(e):e},x.prototype.destructor=function(e){this.rawDestructor&&this.rawDestructor(e)},x.prototype.argPackAdvance=8,x.prototype.readValueFromPointer=Le,x.prototype.deleteObject=function(e){null!==e&&e.delete()},x.prototype.fromWireType=function(e){var t=this.getPointee(e);if(!t)return this.destructor(e),null;if(n=function(e,t){for(void 0===t&&S("ptr should not be undefined");e.baseClass;)t=e.upcast(t),e=e.baseClass;return t}(n=this.registeredClass,n=t),void 0!==(n=xe[n])){if(0===n.$$.count.value)return n.$$.ptr=t,n.$$.smartPtr=e,n.clone();n=n.clone();return this.destructor(e),n}function r(){return this.isSmartPointer?Me(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:t,smartPtrType:this,smartPtr:e}):Me(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}if(n=this.registeredClass.getActualType(t),!(n=Fe[n]))return r.call(this);var n=this.isConst?n.constPointerType:n.pointerType,o=function e(t,r,n){if(r===n)return t;if(void 0===n.baseClass)return null;t=e(t,r,n.baseClass);return null===t?null:n.downcast(t)}(t,this.registeredClass,n.registeredClass);return null===o?r.call(this):this.isSmartPointer?Me(n.registeredClass.instancePrototype,{ptrType:n,ptr:o,smartPtrType:this,smartPtr:e}):Me(n.registeredClass.instancePrototype,{ptrType:n,ptr:o})},Ve=y.UnboundTypeError=be(Error,"UnboundTypeError"),y.count_emval_handles=function(){for(var e=0,t=5;t<I.length;++t)void 0!==I[t]&&++e;return e},y.get_first_emval=function(){for(var e=5;e<I.length;++e)if(void 0!==I[e])return I[e];return null};var yt={s:function(e){return gt(e+24)+24},r:function(e,t,r){throw new fe(e).init(t,r),e},C:function(e,t,r){k.varargs=r;try{var n=k.getStreamFromFD(e);switch(t){case 0:return(o=k.get())<0?-28:T.createStream(n,o).fd;case 1:case 2:case 6:case 7:return 0;case 3:return n.flags;case 4:var o=k.get();return n.flags|=o,0;case 5:return o=k.get(),u[o+0>>1]=2,0;case 16:case 8:default:return-28;case 9:return l[vt()>>2]=28,-1}}catch(e){if(void 0!==T&&e instanceof T.ErrnoError)return-e.errno;throw e}},v:function(e,t,r,n){k.varargs=n;try{t=k.getStr(t),t=k.calculateAt(e,t);var o=n?k.get():0;return T.open(t,r,o).fd}catch(e){if(void 0!==T&&e instanceof T.ErrnoError)return-e.errno;throw e}},u:function(e,t,r,n,o){},E:function(e,r,n,o,i){var s=me(n);P(e,{name:r=A(r),fromWireType:function(e){return!!e},toWireType:function(e,t){return t?o:i},argPackAdvance:8,readValueFromPointer:function(e){var t;if(1===n)t=d;else if(2===n)t=u;else{if(4!==n)throw new TypeError("Unknown boolean type size: "+r);t=l}return this.fromWireType(t[e>>s])},destructorFunction:null})},m:function(u,e,t,l,r,c,n,d,o,f,p,i,h){p=A(p),c=M(r,c),d=d&&M(n,d),f=f&&M(o,f),h=M(i,h);var s,m=ve(p);r=m,n=function(){Xe("Cannot construct "+p+" due to unbound types",[l])},y.hasOwnProperty(r)?(S("Cannot register public name '"+r+"' twice"),Ue(y,r,r),y.hasOwnProperty(s)&&S("Cannot register multiple overloads of a function with the same number of arguments ("+s+")!"),y[r].overloadTable[s]=n):y[r]=n,Te([u,e,t],l?[l]:[],function(e){e=e[0],e=l?(s=e.registeredClass).instancePrototype:R.prototype;var t,r,n=we(m,function(){if(Object.getPrototypeOf(this)!==o)throw new F("Use 'new' to construct "+p);if(void 0===i.constructor_body)throw new F(p+" has no accessible constructor");var e=i.constructor_body[arguments.length];if(void 0===e)throw new F("Tried to invoke ctor of "+p+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(i.constructor_body).toString()+") parameters instead!");return e.apply(this,arguments)}),o=Object.create(e,{constructor:{value:n}}),i=(n.prototype=o,new $e(p,n,o,h,s,c,d,f)),e=new x(p,i,!0,!1,!1),s=new x(p+"*",i,!1,!1,!1),a=new x(p+" const*",i,!1,!0,!1);return Fe[u]={pointerType:s,constPointerType:a},t=m,n=n,y.hasOwnProperty(t)||_e("Replacing nonexistant public symbol"),y[t].overloadTable,y[t]=n,y[t].argCount=r,[e,s,a]})},l:function(e,n,t,r,o,i){q(0<n);var s=qe(n,t);o=M(r,o),Te([],[e],function(t){var r="constructor "+(t=t[0]).name;if(void 0===t.registeredClass.constructor_body&&(t.registeredClass.constructor_body=[]),void 0!==t.registeredClass.constructor_body[n-1])throw new F("Cannot register multiple constructors with identical number of parameters ("+(n-1)+") for class '"+t.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return t.registeredClass.constructor_body[n-1]=()=>{Xe("Cannot construct "+t.name+" due to unbound types",s)},Te([],s,function(e){return e.splice(1,0,null),t.registeredClass.constructor_body[n-1]=Ye(r,e,null,o,i),[]}),[]})},d:function(e,i,s,t,r,a,u,l){var c=qe(s,t);i=A(i),a=M(r,a),Te([],[e],function(t){var r=(t=t[0]).name+"."+i;function e(){Xe("Cannot call "+r+" due to unbound types",c)}i.startsWith("@@")&&(i=Symbol[i.substring(2)]),l&&t.registeredClass.pureVirtualFunctions.push(i);var n=t.registeredClass.instancePrototype,o=n[i];return void 0===o||void 0===o.overloadTable&&o.className!==t.name&&o.argCount===s-2?(e.argCount=s-2,e.className=t.name,n[i]=e):(Ue(n,i,r),n[i].overloadTable[s-2]=e),Te([],c,function(e){e=Ye(r,e,t,a,u);return void 0===n[i].overloadTable?(e.argCount=s-2,n[i]=e):n[i].overloadTable[s-2]=e,[]}),[]})},D:function(e,t){P(e,{name:t=A(t),fromWireType:function(e){var t=Ze.toValue(e);return Qe(e),t},toWireType:function(e,t){return Ze.toHandle(t)},argPackAdvance:8,readValueFromPointer:Le,destructorFunction:null})},o:function(e,t,r){r=me(r);P(e,{name:t=A(t),fromWireType:function(e){return e},toWireType:function(e,t){return t},argPackAdvance:8,readValueFromPointer:function(e,t){switch(t){case 2:return function(e){return this.fromWireType(Y[e>>2])};case 3:return function(e){return this.fromWireType(K[e>>3])};default:throw new TypeError("Unknown float type: "+e)}}(t,r),destructorFunction:null})},c:function(e,t,r,n,o){t=A(t);var i,s=me(r),a=e=>e,r=(0===n&&(i=32-8*r,a=e=>e<<i>>>i),t.includes("unsigned"));P(e,{name:t,fromWireType:a,toWireType:r?function(e,t){return this.name,t>>>0}:function(e,t){return this.name,t},argPackAdvance:8,readValueFromPointer:function(e,t,r){switch(t){case 0:return r?function(e){return d[e]}:function(e){return f[e]};case 1:return r?function(e){return u[e>>1]}:function(e){return J[e>>1]};case 2:return r?function(e){return l[e>>2]}:function(e){return p[e>>2]};default:throw new TypeError("Unknown integer type: "+e)}}(t,s,0!==n),destructorFunction:null})},b:function(e,t,r){var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][t];function o(e){var t=p,r=t[e>>=2],t=t[e+1];return new n(G,t,r)}P(e,{name:r=A(r),fromWireType:o,argPackAdvance:8,readValueFromPointer:o},{ignoreDuplicateRegistrations:!0})},p:function(e,t){var l="std::string"===(t=A(t));P(e,{name:t,fromWireType:function(e){var t,r=p[e>>2],n=e+4;if(l)for(var o=n,i=0;i<=r;++i){var s,a=n+i;i!=r&&0!=f[a]||(s=ee(o,a-o),void 0===t?t=s:t=t+String.fromCharCode(0)+s,o=a+1)}else{for(var u=new Array(r),i=0;i<r;++i)u[i]=String.fromCharCode(f[n+i]);t=u.join("")}return U(e),t},toWireType:function(e,t){var r,n="string"==typeof(t=t instanceof ArrayBuffer?new Uint8Array(t):t),o=(n||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||S("Cannot pass non-string to std::string"),r=l&&n?re(t):t.length,gt(4+r+1)),i=o+4;if(p[o>>2]=r,l&&n)te(t,f,i,r+1);else if(n)for(var s=0;s<r;++s){var a=t.charCodeAt(s);255<a&&(U(i),S("String has UTF-16 code units that do not fit in 8 bits")),f[i+s]=a}else for(s=0;s<r;++s)f[i+s]=t[s];return null!==e&&e.push(U,o),o},argPackAdvance:8,readValueFromPointer:Le,destructorFunction:function(e){U(e)}})},k:function(e,u,o){var l,i,c,s,d;o=A(o),2===u?(l=rt,i=nt,s=ot,c=()=>J,d=1):4===u&&(l=it,i=st,s=at,c=()=>p,d=2),P(e,{name:o,fromWireType:function(e){for(var t,r=p[e>>2],n=c(),o=e+4,i=0;i<=r;++i){var s,a=e+4+i*u;i!=r&&0!=n[a>>d]||(s=l(o,a-o),void 0===t?t=s:t=t+String.fromCharCode(0)+s,o=a+u)}return U(e),t},toWireType:function(e,t){"string"!=typeof t&&S("Cannot pass non-string to C++ string type "+o);var r=s(t),n=gt(4+r+u);return p[n>>2]=r>>d,i(t,n+4,r+u),null!==e&&e.push(U,n),n},argPackAdvance:8,readValueFromPointer:Le,destructorFunction:function(e){U(e)}})},q:function(e,t){P(e,{isVoid:!0,name:t=A(t),argPackAdvance:0,fromWireType:function(){},toWireType:function(e,t){}})},j:function(){return Date.now()},f:function(e,t,r,n){(e=lt[e])(t=Ze.toValue(t),r=void 0===(t=ut[e=r])?A(e):t,null,n)},g:Qe,e:function(e,t){var r=function(e,t){for(var r,n,o=new Array(e),i=0;i<e;++i)o[i]=(r=p[t+4*i>>2],void 0===(n=C[r])&&S("parameter "+i+" has unknown type "+He(r)),n);return o}(e,t),t=r[0],n=t.name+"_$"+r.slice(1).map(function(e){return e.name}).join("_")+"$",o=ct[n];if(void 0!==o)return o;for(var i=["retType"],s=[t],a="",u=0;u<e-1;++u)a+=(0!==u?", ":"")+"arg"+u,i.push("argType"+u),s.push(r[1+u]);for(var l="return function "+ve("methodCaller_"+n)+"(handle, name, destructors, args) {\n",c=0,u=0;u<e-1;++u)l+=" var arg"+u+" = argType"+u+".readValueFromPointer(args"+(c?"+"+c:"")+");\n",c+=r[u+1].argPackAdvance;for(l+=" var rv = handle[name]("+a+");\n",u=0;u<e-1;++u)r[u+1].deleteObject&&(l+=" argType"+u+".deleteObject(arg"+u+");\n");t.isVoid||(l+=" return retType.toWireType(destructors, rv);\n"),i.push(l+="};\n");var t=Je(Function,i).apply(null,s),d=lt.length;return lt.push(t),ct[n]=o=d},a:function(){w("")},z:function(e,t,r){f.copyWithin(e,t,t+r)},i:function(e){f.length,w("OOM")},x:function(s,a){var u=0;return ft().forEach(function(e,t){for(var r=a+u,n=(p[s+4*t>>2]=r,e),o=r,i=0;i<n.length;++i)d[o++>>0]=n.charCodeAt(i);d[o>>0]=0,u+=e.length+1}),0},y:function(e,t){var r=ft(),n=(p[e>>2]=r.length,0);return r.forEach(function(e){n+=e.length+1}),p[t>>2]=n,0},n:function(e){try{var t=k.getStreamFromFD(e);return T.close(t),0}catch(e){if(void 0!==T&&e instanceof T.ErrnoError)return e.errno;throw e}},w:function(e,t){try{var r=k.getStreamFromFD(e),n=r.tty?2:T.isDir(r.mode)?3:T.isLink(r.mode)?7:4;return d[t>>0]=n,0}catch(e){if(void 0!==T&&e instanceof T.ErrnoError)return e.errno;throw e}},B:function(e,t,r,n){try{var o=function(e,t,r){for(var n=0,o=0;o<r;o++){var i=p[t>>2],s=p[t+4>>2],i=(t+=8,T.read(e,d,i,s,void 0));if(i<0)return-1;if(n+=i,i<s)break}return n}(k.getStreamFromFD(e),t,r);return l[n>>2]=o,0}catch(e){if(void 0!==T&&e instanceof T.ErrnoError)return e.errno;throw e}},t:function(e,t,r,n,o){try{var i=r+2097152>>>0<4194305-!!t?(t>>>0)+4294967296*r:NaN;if(isNaN(i))return 61;var s=k.getStreamFromFD(e);return T.llseek(s,i,n),v=[s.position>>>0,(g=s.position,1<=+Math.abs(g)?0<g?(0|Math.min(+Math.floor(g/4294967296),4294967295))>>>0:~~+Math.ceil((g-(~~g>>>0))/4294967296)>>>0:0)],l[o>>2]=v[0],l[o+4>>2]=v[1],s.getdents&&0===i&&0===n&&(s.getdents=null),0}catch(e){if(void 0!==T&&e instanceof T.ErrnoError)return e.errno;throw e}},A:function(e,t,r,n){try{var o=function(e,t,r){for(var n=0,o=0;o<r;o++){var i=p[t>>2],s=p[t+4>>2],i=(t+=8,T.write(e,d,i,s,void 0));if(i<0)return-1;n+=i}return n}(k.getStreamFromFD(e),t,r);return p[n>>2]=o,0}catch(e){if(void 0!==T&&e instanceof T.ErrnoError)return e.errno;throw e}},h:function(e){}},U=(!function(){var t={a:yt};function r(e,t){var e=e.exports;y.asm=e,e=y.asm.F.buffer,G=e,y.HEAP8=d=new Int8Array(e),y.HEAP16=u=new Int16Array(e),y.HEAP32=l=new Int32Array(e),y.HEAPU8=f=new Uint8Array(e),y.HEAPU16=J=new Uint16Array(e),y.HEAPU32=p=new Uint32Array(e),y.HEAPF32=Y=new Float32Array(e),y.HEAPF64=K=new Float64Array(e),Q=y.asm.J,e=y.asm.G,oe.unshift(e),ae()}function n(e){r(e.instance)}function o(e){return function(){if(!i&&(z||c)){if("function"==typeof fetch&&!le(h))return fetch(h,{credentials:"same-origin"}).then(function(e){if(e.ok)return e.arrayBuffer();throw"failed to load wasm binary file at '"+h+"'"}).catch(function(){return ce(h)});if(m)return new Promise(function(t,e){m(h,function(e){t(new Uint8Array(e))},e)})}return Promise.resolve().then(function(){return ce(h)})}().then(function(e){return WebAssembly.instantiate(e,t)}).then(function(e){return e}).then(e,function(e){a("failed to asynchronously prepare wasm: "+e),w(e)})}if(se(),y.instantiateWasm)try{return y.instantiateWasm(t,r)}catch(t){return a("Module.instantiateWasm callback failed with error: "+t)}i||"function"!=typeof WebAssembly.instantiateStreaming||ue(h)||le(h)||V||"function"!=typeof fetch?o(n):fetch(h,{credentials:"same-origin"}).then(function(e){return WebAssembly.instantiateStreaming(e,t).then(n,function(e){return a("wasm streaming compile failed: "+e),a("falling back to ArrayBuffer instantiation"),o(n)})})}(),y.___wasm_call_ctors=function(){return(y.___wasm_call_ctors=y.asm.G).apply(null,arguments)},y._free=function(){return(U=y._free=y.asm.H).apply(null,arguments)}),gt=y._malloc=function(){return(gt=y._malloc=y.asm.I).apply(null,arguments)},vt=y.___errno_location=function(){return(vt=y.___errno_location=y.asm.K).apply(null,arguments)},wt=y.___getTypeName=function(){return(wt=y.___getTypeName=y.asm.L).apply(null,arguments)};y.___embind_register_native_and_builtin_types=function(){return(y.___embind_register_native_and_builtin_types=y.asm.M).apply(null,arguments)};var bt,Et=y._emscripten_builtin_memalign=function(){return(Et=y._emscripten_builtin_memalign=y.asm.N).apply(null,arguments)},_t=y.___cxa_is_pointer_type=function(){return(_t=y.___cxa_is_pointer_type=y.asm.O).apply(null,arguments)};function Tt(){function e(){if(!bt&&(bt=!0,y.calledRun=!0,!X)){if(y.noFSInit||T.init.initialized||T.init(),T.ignorePermissions=!1,de(oe),y.onRuntimeInitialized&&y.onRuntimeInitialized(),y.postRun)for("function"==typeof y.postRun&&(y.postRun=[y.postRun]);y.postRun.length;)e=y.postRun.shift(),ie.unshift(e);var e;de(ie)}}if(!(0<r)){if(y.preRun)for("function"==typeof y.preRun&&(y.preRun=[y.preRun]);y.preRun.length;)t=y.preRun.shift(),ne.unshift(t);var t;de(ne),0<r||(y.setStatus?(y.setStatus("Running..."),setTimeout(function(){setTimeout(function(){y.setStatus("")},1),e()},1)):e())}}if(y.dynCall_viiijj=function(){return(y.dynCall_viiijj=y.asm.P).apply(null,arguments)},y.dynCall_jij=function(){return(y.dynCall_jij=y.asm.Q).apply(null,arguments)},y.dynCall_jii=function(){return(y.dynCall_jii=y.asm.R).apply(null,arguments)},y.dynCall_jiji=function(){return(y.dynCall_jiji=y.asm.S).apply(null,arguments)},y._ff_h264_cabac_tables=215484,n=function e(){bt||Tt(),bt||(n=e)},y.preInit)for("function"==typeof y.preInit&&(y.preInit=[y.preInit]);0<y.preInit.length;)y.preInit.pop()();Tt(),$.exports=y});const k="player",A="playbackTF",D={playType:k,container:"",videoBuffer:1e3,videoBufferDelay:1e3,networkDelay:5e3,isResize:!0,isFullResize:!1,isFlv:!1,isHls:!1,isWebrtc:!1,debug:!1,hotKey:!1,loadingTimeout:10,heartTimeout:10,timeout:10,loadingTimeoutReplay:!0,heartTimeoutReplay:!0,loadingTimeoutReplayTimes:3,heartTimeoutReplayTimes:3,supportDblclickFullscreen:!1,showBandwidth:!1,keepScreenOn:!1,isNotMute:!1,hasAudio:!0,hasVideo:!0,operateBtns:{fullscreen:!1,screenshot:!1,play:!1,audio:!1,record:!1,ptz:!1,quality:!1,zoom:!1,close:!1,fullscreenFn:null,fullscreenExitFn:null,screenshotFn:null,playFn:null,pauseFn:null,recordFn:null,recordStopFn:null},watermarkConfig:{},controlAutoHide:!1,hasControl:!1,loadingText:"",background:"",decoder:"decoder-pro.js",url:"",rotate:0,mirrorRotate:"none",playbackConfig:{playList:[],fps:""},qualityConfig:[],forceNoOffscreen:!0,hiddenAutoPause:!1,protocol:2,demuxType:"flv",useWasm:!1,useWCS:!1,useSIMD:!1,wcsUseVideoRender:!0,wasmUseVideoRender:!1,mseUseCanvasRender:!1,hlsUseCanvasRender:!1,useMSE:!1,useOffscreen:!1,autoWasm:!0,wasmDecodeErrorReplay:!0,openWebglAlignment:!1,wasmDecodeAudioSyncVideo:!0,playbackDelayTime:1e3,playbackFps:25,showPlaybackControl:!1,playbackForwardMaxRateDecodeIFrame:4,playbackCurrentTimeMove:!0,useVideoRender:!0,useCanvasRender:!1,networkDelayTimeoutReplay:!0},C="initVideo",F="render",S="playAudio",P="workerFetch",R="init",x="streamSuccess",M="fetchError";function I(){return(new Date).getTime()}function U(){return(performance&&"function"==typeof performance.now?performance:Date).now()}o(function(e){var s,t,a,r,n;s="undefined"!=typeof window&&void 0!==window.document?window.document:{},t=e.exports,a=function(){for(var e,t=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],r=0,n=t.length,o={};r<n;r++)if((e=t[r])&&e[1]in s){for(r=0;r<e.length;r++)o[t[0][r]]=e[r];return o}return!1}(),r={change:a.fullscreenchange,error:a.fullscreenerror},n={request:function(o,i){return new Promise(function(e,t){var r=function(){this.off("change",r),e()}.bind(this),n=(this.on("change",r),(o=o||s.documentElement)[a.requestFullscreen](i));n instanceof Promise&&n.then(r).catch(t)}.bind(this))},exit:function(){return new Promise(function(e,t){var r,n;this.isFullscreen?(r=function(){this.off("change",r),e()}.bind(this),this.on("change",r),(n=s[a.exitFullscreen]())instanceof Promise&&n.then(r).catch(t)):e()}.bind(this))},toggle:function(e,t){return this.isFullscreen?this.exit():this.request(e,t)},onchange:function(e){this.on("change",e)},onerror:function(e){this.on("error",e)},on:function(e,t){e=r[e];e&&s.addEventListener(e,t,!1)},off:function(e,t){e=r[e];e&&s.removeEventListener(e,t,!1)},raw:a},a?(Object.defineProperties(n,{isFullscreen:{get:function(){return Boolean(s[a.fullscreenElement])}},element:{enumerable:!0,get:function(){return s[a.fullscreenElement]}},isEnabled:{enumerable:!0,get:function(){return Boolean(s[a.fullscreenEnabled])}}}),t?e.exports=n:window.screenfull=n):t?e.exports={isEnabled:!1}:window.screenfull={isEnabled:!1}}).isEnabled;try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){var s=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(s instanceof WebAssembly.Module)new WebAssembly.Instance(s),WebAssembly.Instance}}catch(e){}const a=[[Uint8Array,Int8Array],[Uint16Array,Int16Array],[Uint32Array,Int32Array,Float32Array],[Float64Array]],u=Symbol(32),l=Symbol(16),c=Symbol(8),d=new Map;a.forEach((e,t)=>e.forEach(e=>d.set(e,t)));class ${constructor(e){this.g=e,this.consumed=0,e&&(this.need=e.next().value)}fillFromReader(r){return e=this,u=function*(){var{done:e,value:t}=yield r.read();return e?void this.close():(this.write(t),this.fillFromReader(r))},new(a=(a=s=void 0)||Promise)(function(r,t){function n(e){try{i(u.next(e))}catch(e){t(e)}}function o(e){try{i(u.throw(e))}catch(e){t(e)}}function i(e){var t;e.done?r(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(n,o)}i((u=u.apply(e,s||[])).next())});var e,s,a,u}consume(){this.buffer&&this.consumed&&(this.buffer.copyWithin(0,this.consumed),this.buffer=this.buffer.subarray(0,this.buffer.length-this.consumed),this.consumed=0)}demand(e,t){return t&&this.consume(),this.need=e,this.flush()}read(r){return new Promise((t,e)=>{if(this.resolve)return e("last read not complete yet");this.resolve=e=>{delete this.resolve,delete this.need,t(e)},this.demand(r,!0)})}readU32(){return this.read(u)}readU16(){return this.read(l)}readU8(){return this.read(c)}close(){this.g&&this.g.return()}flush(){if(this.buffer&&this.need){let e=null;const n=this.buffer.subarray(this.consumed);let t=0;var r=e=>n.length<(t=e);if("number"==typeof this.need){if(r(this.need))return;e=n.subarray(0,t)}else if(this.need instanceof ArrayBuffer){if(r(this.need.byteLength))return;new Uint8Array(this.need).set(n.subarray(0,t)),e=this.need}else if(this.need===u){if(r(4))return;e=n[0]<<24|n[1]<<16|n[2]<<8|n[3]}else if(this.need===l){if(r(2))return;e=n[0]<<8|n[1]}else if(this.need===c){if(r(1))return;e=n[0]}else if(d.has(this.need.constructor)){if(r(this.need.length<<d.get(this.need.constructor)))return;new Uint8Array(this.need.buffer,this.need.byteOffset).set(n.subarray(0,t)),e=this.need}else if(this.g)return void this.g.throw(new Error("Unsupported type"));return this.consumed+=t,this.g?this.demand(this.g.next(e).value,!0):this.resolve&&this.resolve(e),e}}write(e){e instanceof ArrayBuffer?this.malloc(e.byteLength).set(new Uint8Array(e)):this.malloc(e.byteLength).set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),(this.g||this.resolve)&&this.flush()}writeU32(e){this.malloc(4).set([e>>24&255,e>>16&255,e>>8&255,255&e]),this.flush()}writeU16(e){this.malloc(2).set([e>>8&255,255&e]),this.flush()}writeU8(e){this.malloc(1)[0]=e,this.flush()}malloc(e){if(this.buffer){var t=this.buffer.length,r=t+e;if(r<=this.buffer.buffer.byteLength-this.buffer.byteOffset)this.buffer=new Uint8Array(this.buffer.buffer,this.buffer.byteOffset,r);else{const e=new Uint8Array(r);e.set(this.buffer),this.buffer=e}return this.buffer.subarray(t,r)}return this.buffer=new Uint8Array(e),this.buffer}}function f(a){function r(){i&&(i.abort(),i=null)}let n=[],u=[],o={},i=new AbortController,s=null,l=null,e=null,c=null,d=null,f=null,p=!1,h=!1,m=!1,y=null,g=null,v=[],w=0,b=0,E=("VideoEncoder"in self&&(o={hasInit:!1,isEmitInfo:!1,offscreenCanvas:null,offscreenCanvasCtx:null,decoder:new VideoDecoder({output:function(t){var e;o.isEmitInfo||(E.opt.debug&&console.log("Jessibuca: [worker] Webcodecs Video Decoder initSize"),postMessage({cmd:C,w:t.codedWidth,h:t.codedHeight}),o.isEmitInfo=!0,o.offscreenCanvas=new OffscreenCanvas(t.codedWidth,t.codedHeight),o.offscreenCanvasCtx=o.offscreenCanvas.getContext("2d")),"function"==typeof t.createImageBitmap?t.createImageBitmap().then(e=>{o.offscreenCanvasCtx.drawImage(e,0,0,t.codedWidth,t.codedHeight);e=o.offscreenCanvas.transferToImageBitmap();postMessage({cmd:F,buffer:e,delay:E.delay,ts:0},[e]),setTimeout(function(){t.close?t.close():t.destroy()},100)}):(o.offscreenCanvasCtx.drawImage(t,0,0,t.codedWidth,t.codedHeight),e=o.offscreenCanvas.transferToImageBitmap(),postMessage({cmd:F,buffer:e,delay:E.delay,ts:0},[e]),setTimeout(function(){t.close?t.close():t.destroy()},100))},error:function(e){console.error(e)}}),decode:function(e,t){const r=e[0]>>4==1;if(o.hasInit){t=new EncodedVideoChunk({data:e.slice(5),timestamp:t,type:r?"key":"delta"});o.decoder.decode(t)}else if(r&&0===e[1]){const t=15&e[0],r=(E.setVideoCodec(t),function(e){let r=e.subarray(1,4),n="avc1.";for(let t=0;t<3;t++){let e=r[t].toString(16);e.length<2&&(e="0"+e),n+=e}return{codec:n,description:e}}(e.slice(5)));o.decoder.configure(r),o.hasInit=!0}},reset(){o.hasInit=!1,o.isEmitInfo=!1,o.offscreenCanvas=null,o.offscreenCanvasCtx=null}}),{opt:{debug:D.debug,useOffscreen:D.useOffscreen,useWCS:D.useWCS,videoBuffer:D.videoBuffer,videoBufferDelay:D.videoBufferDelay,openWebglAlignment:D.openWebglAlignment,playType:D.playType,hasAudio:D.hasAudio,hasVideo:D.hasVideo,playbackRate:1,playbackForwardMaxRateDecodeIFrame:D.playbackForwardMaxRateDecodeIFrame,sampleRate:0,networkDelay:D.networkDelay,visibility:!0},startStreamRateInterval:function(){E.stopStreamRateInterval(),e=setInterval(()=>{l&&l(0)},1e3)},stopStreamRateInterval:function(){e&&(clearInterval(e),e=null)},useOffscreen:function(){return E.opt.useOffscreen&&"undefined"!=typeof OffscreenCanvas},getDelay:function(e){return e?(this.firstTimestamp?e&&(t=Date.now()-this.startTimestamp,r=e-this.firstTimestamp,this.delay=r<=t?t-r:r-t):(this.firstTimestamp=e,this.startTimestamp=Date.now(),this.delay=-1),this.delay):-1;var t,r},resetDelay:function(){this.firstTimestamp=null,this.startTimestamp=null,this.delay=-1},doDecode:function(e){E.opt.useWCS&&E.useOffscreen()&&2===e.type&&o.decode?o.decode(e.payload,e.ts):e.decoder.decode(e.payload,e.ts,e.isIFrame)},init:function(){E.opt.debug&&console.log("Jessibuca: [worker] init");const t=E.opt.playType===k;this.stopId=setInterval(()=>{let e=null;if(n.length)if(this.dropping){for(E.opt.debug&&console.log("Jessibuca: [worker]: loop is dropping"),1===(e=n.shift()).type&&0===e.payload[1]&&E.doDecode(e);!e.isIFrame&&n.length;)E.opt.debug&&console.log("Jessibuca: [worker]: loop is dropping = true, isIFrame is",e.isIFrame),1===(e=n.shift()).type&&0===e.payload[1]&&E.doDecode(e);e.isIFrame&&n.length<10&&(this.dropping=!1,E.doDecode(e))}else if(e=n[0],-1===E.getDelay(e.ts))E.opt.debug&&console.log("Jessibuca: [worker]: common dumex delay is -1 ,data.ts is",e.ts),n.shift(),E.doDecode(e);else if(E.delay>E.opt.videoBuffer+E.opt.videoBufferDelay&&t)E.opt.debug&&console.log("Jessibuca: [worker]:",`delay is ${this.delay}, set dropping is true`),this.resetDelay(),this.dropping=!0;else for(;n.length;){if(e=n[0],!(E.getDelay(e.ts)>E.opt.videoBuffer)){E.delay<0&&E.opt.debug&&console.warn("Jessibuca: [worker]:",`delay is ${this.delay}, bufferList is `+n.length);break}n.shift(),E.doDecode(e)}},10)},close:function(){E.opt.debug&&console.log("Jessibuca: [worker]: close"),E.stopStreamRateInterval(),clearInterval(this.stopId),this.stopId=null,_.clear&&_.clear(),T.clear&&T.clear(),_=null,T=null,o.reset&&o.reset(),this.firstTimestamp=null,this.startTimestamp=null,this.delay=-1,this.dropping=!1,this.webglObj&&(this.webglObj.destroy(),this.offscreenCanvas=null,this.offscreenCanvasGL=null,this.offscreenCanvasCtx=null),n=[],u=[],i=null,c=null,s&&(s.close(),s=null),d=null,f=null,p=!1,h=!1,m=!1,v=[],w=0,b=0,y=null,g=null,delete E.playAudioPlanar,delete E.draw,delete E.demuxFlv},pushBuffer:function(e,t){if(E.opt.playType===k){const e=E.opt.videoBuffer+E.opt.videoBufferDelay;E.getDelay(t.ts)>e&&(E.opt.debug&&console.log(`Jessibuca: [worker]: pushBuffer, decoder.delay is ${E.delay} more than `+e),this.dropBuffer())}1===t.type?n.push({ts:t.ts,payload:e,decoder:{decode:E.decodeAudio},type:1,isIFrame:!1}):2===t.type&&n.push({ts:t.ts,payload:e,decoder:{decode:E.decodeVideo},type:2,isIFrame:t.isIFrame}),60<n.length&&E.opt.debug&&console.warn("Jessibuca: [worker]: pushBuffer bufferList length is "+n.length)},fetchStream:function(e,t){E.opt.debug&&console.log("Jessibuca: [worker]: fetchStream, url is "+e,"options:",t),l=function(r){let n=0,o=U();return e=>{var t;"[object Number]"===Object.prototype.toString.call(e)&&(n+=e,1e3<=(t=(e=U())-o)&&(r(n/t*1e3),o=e,n=0))}}(e=>{postMessage({cmd:P,type:"streamRate",value:e})}),E.startStreamRateInterval(),2===t.protocol?(c=new $(E.demuxFlv()),fetch(e,{signal:i.signal}).then(e=>{postMessage({cmd:P,type:x}),e.body.pipeTo(new WritableStream({write:e=>{l(e.byteLength),c.write(e)},close:()=>{c=null},abort:e=>{c=null,postMessage({cmd:P,type:M,value:e.toString()}),r()}}))}).catch(e=>{postMessage({cmd:P,type:M,value:e.toString()}),r()})):1===t.protocol&&(t.isFlv&&(c=new $(E.demuxFlv())),(s=new WebSocket(e)).binaryType="arraybuffer",s.onopen=()=>{E.opt.debug&&console.log("Jessibuca: [worker]: fetchStream, WebsocketStream socket open"),postMessage({cmd:P,type:x})},s.onclose=()=>{E.opt.debug&&console.log("Jessibuca: [worker]: fetchStream, WebsocketStream socket close"),c=null,postMessage({cmd:P,type:"streamEnd"})},s.onerror=e=>{E.opt.debug&&console.log("Jessibuca: [worker]: fetchStream, WebsocketStream socket error"),c=null,postMessage({cmd:P,type:"websocketError",value:e.toString()})},s.onmessage=e=>{l(e.data.byteLength),t.isFlv?c.write(e.data):E.demuxM7s(e.data)})},demuxFlv:function*(){yield 9;const t=new ArrayBuffer(4),r=new Uint8Array(t),n=new Uint32Array(t);for(;;){r[3]=0;const t=yield 15,s=t[4];r[0]=t[7],r[1]=t[6],r[2]=t[5];var o=n[0];r[0]=t[10],r[1]=t[9],r[2]=t[8];let e=n[0];16777215===e&&(r[3]=t[11],e=n[0]);var i=(yield o).slice();switch(s){case 8:E.decode(i,{type:1,ts:e});break;case 9:if(0<i.byteLength){const t=i[0]>>4==1;E.calcNetworkDelay(e),E.decode(i,{type:2,ts:e,isIFrame:t})}}}},decode:function(e,t){var r=E.opt.playType;1===t.type?E.opt.hasAudio&&(postMessage({cmd:P,type:"streamAbps",value:e.byteLength}),r===k?E.pushBuffer(e,{type:t.type,ts:t.ts}):r===A&&_.decode(e,t.ts)):2===t.type&&E.opt.hasVideo&&(postMessage({cmd:P,type:"streamVbps",value:e.byteLength}),r===k?E.pushBuffer(e,{type:t.type,ts:t.ts,isIFrame:t.isIFrame}):r===A&&(E.opt.playbackRate>=E.opt.playbackForwardMaxRateDecodeIFrame?t.isIFrame&&E.decodeVideo(e,t.ts,t.isIFrame):1===E.opt.playbackRate?E.pushBuffer(e,{type:t.type,ts:t.ts,isIFrame:t.isIFrame}):E.decodeVideo(e,t.ts,t.isIFrame)))},setCodecAudio:function(e){var t=e[0]>>4;(10==t&&0===e[1]||7==t||8==t)&&(e=10==t?e.slice(2):e.slice(1),_.setCodec(t,E.opt.sampleRate,e),h=!0)},decodeAudio:function(e,t){var r=e[0]>>4;h?_.decode(10==r?e.slice(2):e.slice(1),t):E.setCodecAudio(e)},setCodecVideo:function(e){var t=15&e[0];e[0]>>4!=1||0!==e[1]||7!=t&&12!=t||(E.opt.debug&&console.log("Jessibuca: [worker]: decodeVideo: init video codec"),p=!0,e=e.slice(5),T.setCodec(t,e))},decodeVideo:function(e,t,r){p?(m=!m&&r?!0:m)?T.decode(e.slice(5),r?1:0,t):E.opt.debug&&console.error("Jessibuca: [worker]: decodeVideo: first frame is not iframe"):E.setCodecVideo(e)},clearBuffer:function(){var e=0<arguments.length&&void 0!==arguments[0]&&arguments[0];E.opt.debug&&console.log(`Jessibuca: [worker]: clearBuffer,bufferList length is ${n.length}, need clear is `+e),e&&(n=[]),this.resetDelay(),this.dropping=!0},dropBuffer:function(){for(;0<n.length;){var e=n[0];if(1===e.type&&0===e.payload[1]&&(E.doDecode(e),n.shift()),e.isIFrame&&n.length<10){E.opt.debug&&console.log(`Jessibuca: [worker]: dropBuffer end isIFrame ${e.isIFrame} and delay is ${E.delay} and bufferlist is `+n.length);break}E.opt.debug&&console.log(`Jessibuca: [worker]: dropBuffer is dropping and isIFrame ${e.isIFrame} and delay is ${E.delay} and bufferlist is `+n.length),n.shift()}},demuxM7s:function(e){const t=new DataView(e),r=t.getUint32(1,!1),n=t.getUint8(0);switch(E.opt.debug&&console.log("Jessibuca: [worker]: demuxM7s , type is "+n),n){case 1:E.decode(new Uint8Array(e,5),{type:1,ts:r});break;case 2:if(5<t.byteLength){const n=t.getUint8(5)>>4==1;E.calcNetworkDelay(r),E.decode(new Uint8Array(e,5),{type:2,ts:r,isIFrame:n})}}},calcNetworkDelay:function(e){var t,r,n;!p||e<=0||(null===y&&(y=e,g=I()),(n=(t=e-y)<(r=I()-g)?r-t:t-r)>E.opt.networkDelay&&E.opt.debug&&console.warn("Jessibuca: [worker]: ",`demuxFlv now dts:${e}, vs start is ${t},local diff is ${r} ,delay is `+n),postMessage({cmd:P,type:"netBuf",value:n}))},videoInfo:function(e,t,r){function n(e,t){var r=i.createTexture();return i.bindTexture(i.TEXTURE_2D,r),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.bindTexture(i.TEXTURE_2D,null),i.uniform1i(i.getUniformLocation(o,e),t),r}var i,o,s,a,u,l,c;postMessage({cmd:"videoCode",code:e}),postMessage({cmd:C,w:t,h:r}),d=t,f=r,E.useOffscreen()&&(this.offscreenCanvas=new OffscreenCanvas(t,r),this.offscreenCanvasGL=this.offscreenCanvas.getContext("webgl"),this.webglObj=(i=this.offscreenCanvasGL,e=E.opt.openWebglAlignment,t=["attribute vec4 vertexPos;","attribute vec4 texturePos;","varying vec2 textureCoord;","void main()","{","gl_Position = vertexPos;","textureCoord = texturePos.xy;","}"].join("\n"),r=["precision highp float;","varying highp vec2 textureCoord;","uniform sampler2D ySampler;","uniform sampler2D uSampler;","uniform sampler2D vSampler;","const mat4 YUV2RGB = mat4","(","1.1643828125, 0, 1.59602734375, -.87078515625,","1.1643828125, -.39176171875, -.81296875, .52959375,","1.1643828125, 2.017234375, 0, -1.081390625,","0, 0, 0, 1",");","void main(void) {","highp float y = texture2D(ySampler, textureCoord).r;","highp float u = texture2D(uSampler, textureCoord).r;","highp float v = texture2D(vSampler, textureCoord).r;","gl_FragColor = vec4(y, u, v, 1) * YUV2RGB;","}"].join("\n"),e&&i.pixelStorei(i.UNPACK_ALIGNMENT,1),e=i.createShader(i.VERTEX_SHADER),i.shaderSource(e,t),i.compileShader(e),i.getShaderParameter(e,i.COMPILE_STATUS)||(console.log("Vertex shader failed to compile: "+i.getShaderInfoLog(e)),i.deleteShader(e)),t=i.createShader(i.FRAGMENT_SHADER),i.shaderSource(t,r),i.compileShader(t),i.getShaderParameter(t,i.COMPILE_STATUS)||(console.log("Fragment shader failed to compile: "+i.getShaderInfoLog(t)),i.deleteShader(t)),o=i.createProgram(),i.attachShader(o,e),i.attachShader(o,t),i.linkProgram(o),i.getProgramParameter(o,i.LINK_STATUS)||console.log("Program failed to compile: "+i.getProgramInfoLog(o)),i.useProgram(o),s=i.createBuffer(),i.bindBuffer(i.ARRAY_BUFFER,s),i.bufferData(i.ARRAY_BUFFER,new Float32Array([1,1,-1,1,1,-1,-1,-1]),i.STATIC_DRAW),r=i.getAttribLocation(o,"vertexPos"),i.enableVertexAttribArray(r),i.vertexAttribPointer(r,2,i.FLOAT,!1,0,0),a=i.createBuffer(),i.bindBuffer(i.ARRAY_BUFFER,a),i.bufferData(i.ARRAY_BUFFER,new Float32Array([1,0,0,0,1,1,0,1]),i.STATIC_DRAW),e=i.getAttribLocation(o,"texturePos"),i.enableVertexAttribArray(e),i.vertexAttribPointer(e,2,i.FLOAT,!1,0,0),u=n("ySampler",0),l=n("uSampler",1),c=n("vSampler",2),{render:function(e,t,r,n,o){i.viewport(0,0,e,t),i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,u),i.texImage2D(i.TEXTURE_2D,0,i.LUMINANCE,e,t,0,i.LUMINANCE,i.UNSIGNED_BYTE,r),i.activeTexture(i.TEXTURE1),i.bindTexture(i.TEXTURE_2D,l),i.texImage2D(i.TEXTURE_2D,0,i.LUMINANCE,e/2,t/2,0,i.LUMINANCE,i.UNSIGNED_BYTE,n),i.activeTexture(i.TEXTURE2),i.bindTexture(i.TEXTURE_2D,c),i.texImage2D(i.TEXTURE_2D,0,i.LUMINANCE,e/2,t/2,0,i.LUMINANCE,i.UNSIGNED_BYTE,o),i.drawArrays(i.TRIANGLE_STRIP,0,4)},renderYUV:function(e,t,r){var n=r.slice(0,e*t),o=r.slice(e*t,e*t*5/4),r=r.slice(e*t*5/4,e*t*3/2);i.viewport(0,0,e,t),i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,u),i.texImage2D(i.TEXTURE_2D,0,i.LUMINANCE,e,t,0,i.LUMINANCE,i.UNSIGNED_BYTE,n),i.activeTexture(i.TEXTURE1),i.bindTexture(i.TEXTURE_2D,l),i.texImage2D(i.TEXTURE_2D,0,i.LUMINANCE,e/2,t/2,0,i.LUMINANCE,i.UNSIGNED_BYTE,o),i.activeTexture(i.TEXTURE2),i.bindTexture(i.TEXTURE_2D,c),i.texImage2D(i.TEXTURE_2D,0,i.LUMINANCE,e/2,t/2,0,i.LUMINANCE,i.UNSIGNED_BYTE,r),i.drawArrays(i.TRIANGLE_STRIP,0,4)},destroy:function(){try{i.deleteProgram(o),i.deleteBuffer(s),i.deleteBuffer(a),i.deleteTexture(u),i.deleteTexture(l),i.deleteBuffer(c)}catch(e){}}}))},audioInfo:function(e,t,r){postMessage({cmd:"audioCode",code:e}),postMessage({cmd:"initAudio",sampleRate:t,channels:r}),b=r},yuvData:function(e,t){var r=d*f*3/2,e=a.HEAPU8.subarray(e,e+r),r=new Uint8Array(e);E.useOffscreen()?(this.webglObj.renderYUV(d,f,r),e=this.offscreenCanvas.transferToImageBitmap(),postMessage({cmd:F,buffer:e,delay:this.delay,ts:t},[e])):postMessage({cmd:F,output:r,delay:this.delay,ts:t},[r.buffer])},pcmData:function(t,e,r){let n=e,o=[],i=0;for(let e=0;e<2;e++){var s=a.HEAPU32[(t>>2)+e]>>2;o[e]=a.HEAPF32.subarray(s,s+n)}if(w){if(!(n>=(e=1024-w)))return w+=n,u[0]=Float32Array.of(...u[0],...o[0]),void(2==b&&(u[1]=Float32Array.of(...u[1],...o[1])));v[0]=Float32Array.of(...u[0],...o[0].subarray(0,e)),2==b&&(v[1]=Float32Array.of(...u[1],...o[1].subarray(0,e))),postMessage({cmd:S,buffer:v,ts:r},v.map(e=>e.buffer)),i=e,n-=e}for(w=n;1024<=w;w-=1024)v[0]=o[0].slice(i,i+=1024),2==b&&(v[1]=o[1].slice(i-1024,i)),postMessage({cmd:S,buffer:v,ts:r},v.map(e=>e.buffer));w&&(u[0]=o[0].slice(i),2==b&&(u[1]=o[1].slice(i)))},timeEnd:function(){postMessage({cmd:"workerEnd"})}}),_=new a.AudioDecoder(E),T=new a.VideoDecoder(E);postMessage({cmd:R}),self.onmessage=function(e){var t=e.data;switch(t.cmd){case R:try{E.opt=Object.assign(E.opt,JSON.parse(t.opt))}catch(e){}E.init();break;case"decode":E.pushBuffer(t.buffer,t.options);break;case"audioDecode":E.decodeAudio(t.buffer,t.ts);break;case"videoDecode":E.decodeVideo(t.buffer,t.ts,t.isIFrame);break;case"clearBuffer":E.clearBuffer(t.needClear);break;case"fetchStream":E.fetchStream(t.url,JSON.parse(t.opt));break;case"close":E.close();break;case"updateConfig":E.opt[t.key]=t.value}}}$.U32=u,$.U16=l,$.U8=c,Date.now||(Date.now=function(){return(new Date).getTime()}),i.postRun=function(){f(i)}});
|