diff --git a/ui/decoder-simd.js b/ui/decoder-simd.js new file mode 100644 index 0000000..a7e993b --- /dev/null +++ b/ui/decoder-simd.js @@ -0,0 +1 @@ +!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 _r=n(e),br=n(t),Pr=n(r),g=function(C){var e,k=C={exports:{}},g=void 0!==g?g:{},j={};for(e in g={print:function(e){console.log("Jessibuca: [worker]:",e)},printErr:function(e){console.warn("Jessibuca: [worker]:",e),postMessage({cmd:"wasmError",message:e})}})g.hasOwnProperty(e)&&(j[e]=g[e]);var H="./this.program",X="object"==typeof window,d="function"==typeof importScripts,Q="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,t=!X&&!Q&&!d;if(g.ENVIRONMENT)throw new Error("Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -s ENVIRONMENT=web or -s ENVIRONMENT=node)");var L,B,W,o,G,r="";if(Q){if("object"!=typeof process)throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");r=d?_r.default.dirname(r)+"/":__dirname+"/",L=function(e,t){return o=o||br.default,e=(G=G||_r.default).normalize(e),o.readFileSync(e,t?null:"utf8")},W=function(e){e=L(e,!0);return A((e=e.buffer?e:new Uint8Array(e)).buffer),e},B=function(e,r,n){o=o||br.default,e=(G=G||_r.default).normalize(e),o.readFile(e,function(e,t){e?n(e):r(t.buffer)})},1>10,56320|1023&s))):i+=String.fromCharCode((31&c)<<6|a)):i+=String.fromCharCode(c)}return i}function K(e,t){return e?i(I,e,t):""}function J(e,t,r,n){if(!(0>6,t[r++]=128|63&s}else if(s<=65535){if(i<=r+2)break;t[r++]=224|s>>12,t[r++]=128|s>>6&63,t[r++]=128|63&s}else{if(i<=r+3)break;1114111>18,t[r++]=128|s>>12&63,t[r++]=128|s>>6&63,t[r++]=128|63&s}}return t[r]=0,r-o}function Z(e,t,r){A("number"==typeof r,"stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"),J(e,I,t,r)}function ee(e){for(var t=0,r=0;r>1,o=n+t/2;!(o<=n)&&re[n];)++n;if(32<(r=n<<1)-e&&ie)return ie.decode(I.subarray(e,r));for(var i="",a=0;!(t/2<=a);++a){var s=c[e+2*a>>1];if(0==s)break;i+=String.fromCharCode(s)}return i}function se(e,t,r){if(A(t%2==0,"Pointer passed to stringToUTF16 must be aligned to two bytes!"),A("number"==typeof r,"stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"),(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>1]=a,t+=2}return c[t>>1]=0,t-n}function ce(e){return 2*e.length}function de(e,t){A(e%4==0,"Pointer passed to UTF32ToString must be aligned to four bytes!");for(var r=0,n="";!(t/4<=r);){var o,i=N[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 ue(e,t,r){if(A(t%4==0,"Pointer passed to stringToUTF32 must be aligned to four bytes!"),A("number"==typeof r,"stringToUTF32(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"),(r=void 0===r?2147483647:r)<4)return 0;for(var n=t,o=n+r-4,i=0;i>2]=a,(t+=4)+4>o)break}return N[t>>2]=0,t-n}function le(e){for(var t=0,r=0;r>2)]=34821223,p[2+(e>>2)]=2310721022,N[0]=1668509029}function Te(){var e,t;Y||(t=Er(),e=p[1+(t>>2)],t=p[2+(t>>2)],34821223==e&&2310721022==t||E("Stack overflow! Stack cookie has been overwritten, expected hex dwords 0x89BACDFE and 0x2135467, but received 0x"+t.toString(16)+" "+e.toString(16)),1668509029!==N[0]&&E("Runtime error: The application has corrupted its heap memory area (address zero)!"))}Object.getOwnPropertyDescriptor(g,"INITIAL_MEMORY")||Object.defineProperty(g,"INITIAL_MEMORY",{configurable:!0,get:function(){E("Module.INITIAL_MEMORY has been replaced with plain INITIAL_MEMORY (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)")}}),A(t<=he,"INITIAL_MEMORY should be larger than TOTAL_STACK, was "+he+"! (TOTAL_STACK=5242880)"),A("undefined"!=typeof Int32Array&&"undefined"!=typeof Float64Array&&void 0!==Int32Array.prototype.subarray&&void 0!==Int32Array.prototype.set,"JS engine does not provide full typed array support"),A(!g.wasmMemory,"Use of `wasmMemory` detected. Use -s IMPORTED_MEMORY to define wasmMemory externally"),A(67108864==he,"Detected runtime INITIAL_MEMORY setting. Use -s IMPORTED_MEMORY to define wasmMemory dynamically");t=new Int16Array(1),he=new Int8Array(t.buffer);if(t[0]=25459,115!==he[0]||99!==he[1])throw"Runtime error: expected the system to be little-endian! (Run with -s SUPPORT_BIG_ENDIAN=1 to bypass)";var a,u,l,Oe=[],me=[],we=[],ye=!1,n=(A(Math.imul,"This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),A(Math.fround,"This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),A(Math.clz32,"This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),A(Math.trunc,"This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),0),f=null,De=null,_e={};function be(e){for(var t=e;;){if(!_e[e])return e;e=t+Math.random()}}function Pe(e){n++,g.monitorRunDependencies&&g.monitorRunDependencies(n),e?(A(!_e[e]),_e[e]=1,null===f&&"undefined"!=typeof setInterval&&(f=setInterval(function(){if(Y)return clearInterval(f),void(f=null);var e,t=!1;for(e in _e)t||(t=!0,s("still waiting on run dependencies:")),s("dependency: "+e);t&&s("(end of list)")},1e4))):s("warning: run dependency added without ID")}function ve(e){n--,g.monitorRunDependencies&&g.monitorRunDependencies(n),e?(A(_e[e]),delete _e[e]):s("warning: run dependency removed without ID"),0==n&&(null!==f&&(clearInterval(f),f=null),De)&&(e=De,De=null,e())}function E(e){throw g.onAbort&&g.onAbort(e),s(e+=""),Y=!0,e="abort("+e+") at "+(t=Ie(),g.extraStackTrace&&(t+="\n"+g.extraStackTrace()),Fe(t)),new WebAssembly.RuntimeError(e);var t}function Re(e){return e.startsWith("data:application/octet-stream;base64,")}function Me(e){return e.startsWith("file://")}function h(r,n){return function(){var e=r,t=n;return n||(t=g.asm),A(ye,"native function `"+e+"` called before runtime initialization"),A(!0,"native function `"+e+"` called after runtime exit (use NO_EXIT_RUNTIME to keep it alive after main() exits)"),t[r]||A(t[r],"exported native function `"+e+"` not found"),t[r].apply(null,arguments)}}function Se(e){try{if(e==a&&$)return new Uint8Array($);if(W)return W(e);throw"both async and sync fetching of the wasm failed"}catch(e){E(e)}}function Ae(e){for(;0>>0),0!=r&&(t=Math.max(t,256)),r=e.contents,e.contents=new Uint8Array(t),0=e.node.usedBytes)return 0;var a=Math.min(e.node.usedBytes-o,n);if(A(0<=a),8>>0)%D.nameTable.length},hashAddNode:function(e){var t=D.hashName(e.parent.id,e.name);e.name_next=D.nameTable[t],D.nameTable[t]=e},hashRemoveNode:function(e){var t=D.hashName(e.parent.id,e.name);if(D.nameTable[t]===e)D.nameTable[t]=e.name_next;else for(var r=D.nameTable[t];r;){if(r.name_next===e){r.name_next=e.name_next;break}r=r.name_next}},lookupNode:function(e,t){var r=D.mayLookup(e);if(r)throw new D.ErrnoError(r,e);for(var r=D.hashName(e.id,t),n=D.nameTable[r];n;n=n.name_next){var o=n.name;if(n.parent.id===e.id&&o===t)return n}return D.lookup(e,t)},createNode:function(e,t,r,n){A("object"==typeof e);e=new D.FSNode(e,t,r,n);return D.hashAddNode(e),e},destroyNode:function(e){D.hashRemoveNode(e)},isRoot:function(e){return e===e.parent},isMountpoint:function(e){return!!e.mounted},isFile:function(e){return 32768==(61440&e)},isDir:function(e){return 16384==(61440&e)},isLink:function(e){return 40960==(61440&e)},isChrdev:function(e){return 8192==(61440&e)},isBlkdev:function(e){return 24576==(61440&e)},isFIFO:function(e){return 4096==(61440&e)},isSocket:function(e){return 49152==(49152&e)},flagModes:{r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},modeStringToFlags:function(e){var t=D.flagModes[e];if(void 0===t)throw new Error("Unknown file open mode: "+e);return t},flagsToPermissionString:function(e){var t=["r","w","rw"][3&e];return 512&e&&(t+="w"),t},nodePermissions:function(e,t){return D.ignorePermissions||(!t.includes("r")||292&e.mode)&&(!t.includes("w")||146&e.mode)&&(!t.includes("x")||73&e.mode)?0:2},mayLookup:function(e){return D.nodePermissions(e,"x")||(e.node_ops.lookup?0:2)},mayCreate:function(e,t){try{return D.lookupNode(e,t),20}catch(e){}return D.nodePermissions(e,"wx")},mayDelete:function(e,t,r){var n;try{n=D.lookupNode(e,t)}catch(e){return e.errno}t=D.nodePermissions(e,"wx");if(t)return t;if(r){if(!D.isDir(n.mode))return 54;if(D.isRoot(n)||D.getPath(n)===D.cwd())return 10}else if(D.isDir(n.mode))return 31;return 0},mayOpen:function(e,t){return e?D.isLink(e.mode)?32:D.isDir(e.mode)&&("r"!==D.flagsToPermissionString(t)||512&t)?31:D.nodePermissions(e,D.flagsToPermissionString(t)):44},MAX_OPEN_FDS:4096,nextfd:function(e,t){t=t||D.MAX_OPEN_FDS;for(var r=e=e||0;r<=t;r++)if(!D.streams[r])return r;throw new D.ErrnoError(33)},getStream:function(e){return D.streams[e]},createStream:function(e,t,r){D.FSStream||(D.FSStream=function(){},D.FSStream.prototype={object:{get:function(){return this.node},set:function(e){this.node=e}},isRead:{get:function(){return 1!=(2097155&this.flags)}},isWrite:{get:function(){return 0!=(2097155&this.flags)}},isAppend:{get:function(){return 1024&this.flags}}});var n,o=new D.FSStream;for(n in e)o[n]=e[n];e=o;t=D.nextfd(t,r);return e.fd=t,D.streams[t]=e},closeStream:function(e){D.streams[e]=null},chrdev_stream_ops:{open:function(e){var t=D.getDevice(e.node.rdev);e.stream_ops=t.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:function(){throw new D.ErrnoError(70)}},major:function(e){return e>>8},minor:function(e){return 255&e},makedev:function(e,t){return e<<8|t},registerDevice:function(e,t){D.devices[e]={stream_ops:t}},getDevice:function(e){return D.devices[e]},getMounts:function(e){for(var t=[],r=[e];r.length;){var n=r.pop();t.push(n),r.push.apply(r,n.mounts)}return t},syncfs:function(t,r){"function"==typeof t&&(r=t,t=!1),D.syncFSRequests++,1=n.length&&i(null)}n.forEach(function(e){if(!e.type.syncfs)return a(null);e.type.syncfs(e,t,a)})},mount:function(e,t,r){if("string"==typeof e)throw e;var n,o="/"===r,i=!r;if(o&&D.root)throw new D.ErrnoError(10);if(!o&&!i){i=D.lookupPath(r,{follow_mount:!1});if(r=i.path,n=i.node,D.isMountpoint(n))throw new D.ErrnoError(10);if(!D.isDir(n.mode))throw new D.ErrnoError(54)}i={type:e,opts:t,mountpoint:r,mounts:[]},t=e.mount(i);return(t.mount=i).root=t,o?D.root=t:n&&(n.mounted=i,n.mount&&n.mount.mounts.push(i)),t},unmount:function(e){e=D.lookupPath(e,{follow_mount:!1});if(!D.isMountpoint(e.node))throw new D.ErrnoError(28);var e=e.node,t=e.mounted,n=D.getMounts(t),t=(Object.keys(D.nameTable).forEach(function(e){for(var t=D.nameTable[e];t;){var r=t.name_next;n.includes(t.mount)&&D.destroyNode(t),t=r}}),e.mounted=null,e.mount.mounts.indexOf(t));A(-1!==t),e.mount.mounts.splice(t,1)},lookup:function(e,t){return e.node_ops.lookup(e,t)},mknod:function(e,t,r){var n=D.lookupPath(e,{parent:!0}).node,e=O.basename(e);if(!e||"."===e||".."===e)throw new D.ErrnoError(28);var o=D.mayCreate(n,e);if(o)throw new D.ErrnoError(o);if(n.node_ops.mknod)return n.node_ops.mknod(n,e,t,r);throw new D.ErrnoError(63)},create:function(e,t){return D.mknod(e,t=(t=void 0!==t?t:438)&4095|32768,0)},mkdir:function(e,t){return D.mknod(e,t=(t=void 0!==t?t:511)&1023|16384,0)},mkdirTree:function(e,t){for(var r=e.split("/"),n="",o=0;othis.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",a,!1),e.send(null),!(200<=e.status&&e.status<300||304===e.status))throw new Error("Couldn't load "+a+". 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(function(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]=function(e,t){if(t=i.length)return 0;var a=Math.min(i.length-o,n);if(A(0<=a),i.slice)for(var s=0;s>2]=n.dev,N[r+4>>2]=0,N[r+8>>2]=n.ino,N[r+12>>2]=n.mode,N[r+16>>2]=n.nlink,N[r+20>>2]=n.uid,N[r+24>>2]=n.gid,N[r+28>>2]=n.rdev,N[r+32>>2]=0,l=[n.size>>>0,(u=n.size,1<=+Math.abs(u)?0>>0:~~+Math.ceil((u-(~~u>>>0))/4294967296)>>>0:0)],N[r+40>>2]=l[0],N[r+44>>2]=l[1],N[r+48>>2]=4096,N[r+52>>2]=n.blocks,N[r+56>>2]=n.atime.getTime()/1e3|0,N[r+60>>2]=0,N[r+64>>2]=n.mtime.getTime()/1e3|0,N[r+68>>2]=0,N[r+72>>2]=n.ctime.getTime()/1e3|0,N[r+76>>2]=0,l=[n.ino>>>0,(u=n.ino,1<=+Math.abs(u)?0>>0:~~+Math.ceil((u-(~~u>>>0))/4294967296)>>>0:0)],N[r+80>>2]=l[0],N[r+84>>2]=l[1],0},doMsync:function(e,t,r,n,o){e=I.slice(e,e+r);D.msync(t,e,o,r,n)},doMkdir:function(e,t){return"/"===(e=O.normalize(e))[e.length-1]&&(e=e.substr(0,e.length-1)),D.mkdir(e,t,0),0},doMknod:function(e,t,r){switch(61440&t){case 32768:case 8192:case 24576:case 4096:case 49152:break;default:return-28}return D.mknod(e,t,r),0},doReadlink:function(e,t,r){if(r<=0)return-28;var e=D.readlink(e),n=Math.min(r,ee(e)),o=F[t+n];return Z(e,t,r+1),F[t+n]=o,n},doAccess:function(e,t){if(-8&t)return-28;if(!(e=D.lookupPath(e,{follow:!0}).node))return-44;var r="";return 4&t&&(r+="r"),2&t&&(r+="w"),1&t&&(r+="x"),r&&D.nodePermissions(e,r)?-2:0},doDup:function(e,t,r){var n=D.getStream(r);return n&&D.close(n),D.open(e,t,0,r,r).fd},doReadv:function(e,t,r,n){for(var o=0,i=0;i>2],s=N[t+(8*i+4)>>2],a=D.read(e,F,a,s,n);if(a<0)return-1;if(o+=a,a>2],s=N[t+(8*i+4)>>2],a=D.write(e,F,a,s,n);if(a<0)return-1;o+=a}return o},varargs:void 0,get:function(){return A(null!=_.varargs),_.varargs+=4,N[_.varargs-4>>2]},getStr:function(e){return K(e)},getStreamFromFD:function(e){e=D.getStream(e);if(e)return e;throw new D.ErrnoError(8)},get64:function(e,t){return A(0<=e?0===t:-1===t),e}};function Ce(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 ke=void 0;function b(e){for(var t="",r=e;I[r];)t+=ke[I[r++]];return t}var je={},He={},Xe={};function Qe(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 Le(e,t){return e=Qe(e),new Function("body","return function "+e+'() {\n "use strict"; return body.apply(this, arguments);\n};\n')(t)}function Be(e,t){var r=Le(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 We=void 0;function P(e){throw new We(e)}var Ge=void 0;function $e(e){throw new Ge(e)}function ze(n,t,o){function r(e){var t=o(e);t.length!==n.length&&$e("Mismatched type converter count");for(var r=0;r>2])}function ht(e){return e=this.rawGetPointee?this.rawGetPointee(e):e}function gt(e){this.rawDestructor&&this.rawDestructor(e)}function Tt(e){null!==e&&e.delete()}function Ot(e,t,r){if(t===r)return e;if(void 0===r.baseClass)return null;e=Ot(e,t,r.baseClass);return null===e?null:r.downcast(e)}function mt(){return Object.keys(Dt).length}function wt(){var e,t=[];for(e in Dt)Dt.hasOwnProperty(e)&&t.push(Dt[e]);return t}function yt(e){nt=e,ot.length&&nt&&nt(it)}var Dt={};function _t(e,t){return t=function(e,t){for(void 0===t&&P("ptr should not be undefined");e.baseClass;)t=e.upcast(t),e=e.baseClass;return t}(e,t),Dt[t]}function bt(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},Ze(Object.create(e,{$$:{value:t}}))}function Pt(e){var t=this.getPointee(e);if(!t)return this.destructor(e),null;var r=_t(this.registeredClass,t);if(void 0!==r){if(0===r.$$.count.value)return r.$$.ptr=t,r.$$.smartPtr=e,r.clone();r=r.clone();return this.destructor(e),r}function n(){return this.isSmartPointer?bt(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:t,smartPtrType:this,smartPtr:e}):bt(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}r=this.registeredClass.getActualType(t),r=st[r];if(!r)return n.call(this);var r=this.isConst?r.constPointerType:r.pointerType,o=Ot(t,this.registeredClass,r.registeredClass);return null===o?n.call(this):this.isSmartPointer?bt(r.registeredClass.instancePrototype,{ptrType:r,ptr:o,smartPtrType:this,smartPtr:e}):bt(r.registeredClass.instancePrototype,{ptrType:r,ptr:o})}function M(e,t,r,n,o,i,a,s,c,d,u){this.name=e,this.registeredClass=t,this.isReference=r,this.isConst=n,this.isSmartPointer=o,this.pointeeType=i,this.sharingPolicy=a,this.rawGetPointee=s,this.rawConstructor=c,this.rawShare=d,this.rawDestructor=u,o||void 0!==t.baseClass?this.toWireType=pt:(this.toWireType=n?lt:ft,this.destructorFunction=null)}function vt(e,t,r){var n,o;return e.includes("j")?(n=t,o=r,A("dynCall_"+e in g,"bad function pointer type - no table for sig '"+e+"'"),o&&o.length?A(o.length===e.substring(1).replace(/j/g,"--").length):A(1==e.length),e=g["dynCall_"+e],o&&o.length?e.apply(null,[n].concat(o)):e.call(null,n)):(A(Ee.get(t),"missing table entry in dynCall: "+t),Ee.get(t).apply(null,r))}function S(e,t){var r,n,o,i=(e=b(e)).includes("j")?(n=t,A((r=e).includes("j"),"getDynCaller should only be called with i64 sigs"),o=[],function(){o.length=arguments.length;for(var e=0;e>2)+n]);return r}function Ft(e){for(;e.length;){var t=e.pop();e.pop()(t)}}function It(e,t){if(!(e instanceof Function))throw new TypeError("new_ called with constructor type "+typeof e+" which is not a function");var r=Le(e.name||"unknownFunctionName",function(){}),r=(r.prototype=e.prototype,new r),e=e.apply(r,t);return e instanceof Object?e:r}function Nt(e,t,r,n,o){var i=t.length;i<2&&P("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var r=null!==t[1]&&null!==r,a=!1,s=1;s>2])};case 3:return function(e){return this.fromWireType(oe[e>>3])};default:throw new TypeError("Unknown float type: "+e)}}function Lt(e,t,r){switch(t){case 0:return r?function(e){return F[e]}:function(e){return I[e]};case 1:return r?function(e){return c[e>>1]}:function(e){return re[e>>1]};case 2:return r?function(e){return N[e>>2]}:function(e){return p[e>>2]};default:throw new TypeError("Unknown integer type: "+e)}}function Bt(e){return e||P("Cannot use deleted val. handle = "+e),U[e].value}function Wt(e,t){var r=He[e];return void 0===r&&P(t+" has unknown type "+Mt(e)),r}var Gt={},$t=[];function zt(e,t){return A(t===(0|t)),(e>>>0)+4294967296*t}function Vt(e,t){if(e<=0)return e;var r=t<=32?Math.abs(1<>3],n+=8):"i64"==e?(t=[N[n>>2],N[n+4>>2]],n+=8):(A(0==(3&n)),e="i32",t=N[n>>2],n+=4),t}for(var i,a,s=[];;){var c=r;if(0===(i=F[r>>0]))break;if(a=F[r+1>>0],37==i){var d=!1,u=!1,l=!1,p=!1,f=!1;e:for(;;){switch(a){case 43:d=!0;break;case 45:u=!0;break;case 35:l=!0;break;case 48:if(p)break e;p=!0;break;case 32:f=!0;break;default:break e}a=F[++r+1>>0]}var E=0;if(42==a)E=o("i32"),a=F[++r+1>>0];else for(;48<=a&&a<=57;)E=10*E+(a-48),a=F[++r+1>>0];var h,g=!1,T=-1;if(46==a){if(g=!(T=0),42==(a=F[++r+1>>0]))T=o("i32"),r++;else for(;;){var O=F[r+1>>0];if(O<48||57>0]}switch(T<0&&(g=!(T=6)),String.fromCharCode(a)){case"h":h=104==F[r+2>>0]?(r++,1):2;break;case"l":h=108==F[r+2>>0]?(r++,8):4;break;case"L":case"q":case"j":h=8;break;case"z":case"t":case"I":h=4;break;default:h=null}switch(h&&r++,a=F[r+1>>0],String.fromCharCode(a)){case"d":case"i":case"u":case"o":case"x":case"X":case"p":var m=100==a||105==a,m=(y=o("i"+8*(h=h||4)),8==h&&(y=117==a?(y[0]>>>0)+4294967296*(y[1]>>>0):zt(y[0],y[1])),h<=4&&(y=(m?Vt:Yt)(y&Math.pow(256,h)-1,8*h)),Math.abs(y)),w="";if(100==a||105==a)D=Vt(y,8*h).toString(10);else if(117==a)D=Yt(y,8*h).toString(10),y=Math.abs(y);else if(111==a)D=(l?"0":"")+m.toString(8);else if(120==a||88==a){if(w=l&&0!=y?"0x":"",y<0){for(var y=-y,D=(m-1).toString(16),_=[],b=0;bP++;)v[0]+="0";D=v[0]+(1>0]);else s=s.concat(ar("(null)".substr(0,M),!0));if(u)for(;M>2]=s.length;break;case"%":s.push(i);break;default:for(b=c;b>0])}r+=2}else s.push(i),r+=1}return s}function Kt(e){if(!e||!e.callee||!e.callee.name)return[null,"",""];e.callee.toString();var t,r=e.callee.name,n="(",o=!0;for(t in e){var i=e[t];o||(n+=", "),o=!1,n+="number"==typeof i||"string"==typeof i?i:"("+typeof i+")"}n+=")";var a=e.callee.caller;return[e=a?a.arguments:[],r,n=o?"":n]}function Jt(e,t){24&e&&(t=t.replace(/\s+$/,""),t+=(0>>16),fe(z.buffer),1}catch(e){s("emscripten_realloc_buffer: Attempted to grow heap from "+te.byteLength+" bytes to "+t+" bytes, but got error: "+e)}}var er={};function tr(){if(!tr.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",_:H||"./this.program"};for(t in er)void 0===er[t]?delete e[t]:e[t]=er[t];var t,r=[];for(t in e)r.push(t+"="+e[t]);tr.strings=r}return tr.strings}function rr(){function e(e){e=e.toTimeString().match(/\(([A-Za-z ]+)\)$/);return e?e[1]:"GMT"}var t,r,n,o,i;rr.called||(rr.called=!0,r=(new Date).getFullYear(),t=new Date(r,0,1),r=new Date(r,6,1),n=t.getTimezoneOffset(),o=r.getTimezoneOffset(),i=Math.max(n,o),N[Tr()>>2]=60*i,N[gr()>>2]=Number(n!=o),i=e(t),t=e(r),r=pe(i),i=pe(t),o>2]=r,N[hr()+4>>2]=i):(N[hr()>>2]=i,N[hr()+4>>2]=r))}function nr(e,t,r,n){e=e||this,this.parent=e,this.mount=e.mount,this.mounted=null,this.id=D.nextInode++,this.name=t,this.mode=r,this.node_ops={},this.stream_ops={},this.rdev=n}var or=365,ir=146;function ar(e,t,r){r=0>1]=2,0;case 16:case 8:default:return-28;case 9:return N[pr()>>2]=28,-1}}catch(e){return void 0!==D&&e instanceof D.ErrnoError||E(e),-e.errno}},__sys_open:function(e,t,r){_.varargs=r;try{var n=_.getStr(e),o=r?_.get():0;return D.open(n,t,o).fd}catch(e){return void 0!==D&&e instanceof D.ErrnoError||E(e),-e.errno}},_embind_register_bigint:function(e,t,r,n,o){},_embind_register_bool:function(e,r,n,o,i){var a=Ce(n);v(e,{name:r=b(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=F;else if(2===n)t=c;else{if(4!==n)throw new TypeError("Unknown boolean type size: "+r);t=N}return this.fromWireType(t[e>>a])},destructorFunction:null})},_embind_register_class:function(c,e,t,d,r,u,n,l,o,p,f,i,E){f=b(f),u=S(r,u),l=l&&S(n,l),p=p&&S(o,p),E=S(i,E);var a,h=Qe(f);r=h,n=function(){St("Cannot construct "+f+" due to unbound types",[d])},g.hasOwnProperty(r)?(P("Cannot register public name '"+r+"' twice"),ct(g,r,r),g.hasOwnProperty(a)&&P("Cannot register multiple overloads of a function with the same number of arguments ("+a+")!"),g[r].overloadTable[a]=n):g[r]=n,ze([c,e,t],d?[d]:[],function(e){e=e[0],e=d?(a=e.registeredClass).instancePrototype:R.prototype;var t,r,n=Le(h,function(){if(Object.getPrototypeOf(this)!==o)throw new We("Use 'new' to construct "+f);if(void 0===i.constructor_body)throw new We(f+" has no accessible constructor");var e=i.constructor_body[arguments.length];if(void 0===e)throw new We("Tried to invoke ctor of "+f+" 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 dt(f,n,o,E,a,u,l,p)),e=new M(f,i,!0,!1,!1),a=new M(f+"*",i,!1,!1,!1),s=new M(f+" const*",i,!1,!0,!1);return st[c]={pointerType:a,constPointerType:s},t=h,n=n,g.hasOwnProperty(t)||$e("Replacing nonexistant public symbol"),g[t].overloadTable,g[t]=n,g[t].argCount=r,[e,a,s]})},_embind_register_class_constructor:function(e,n,t,r,o,i){A(0>>i}),r.includes("unsigned"));v(e,{name:r,fromWireType:s,toWireType:function(e,t){if("number"!=typeof t&&"boolean"!=typeof t)throw new TypeError('Cannot convert "'+Xt(t)+'" to '+this.name);if(t>>0:0|t},argPackAdvance:8,readValueFromPointer:Lt(r,a,0!==n),destructorFunction:null})},_embind_register_memory_view: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(te,t,r)}v(e,{name:r=b(r),fromWireType:o,argPackAdvance:8,readValueFromPointer:o},{ignoreDuplicateRegistrations:!0})},_embind_register_std_string:function(e,t){var c="std::string"===(t=b(t));v(e,{name:t,fromWireType:function(e){var t,r=p[e>>2];if(c)for(var n=e+4,o=0;o<=r;++o){var i,a=e+4+o;o!=r&&0!=I[a]||(i=K(n,a-n),void 0===t?t=i:t=t+String.fromCharCode(0)+i,n=a+1)}else{for(var s=new Array(r),o=0;o>2]=n,c&&r)Z(t,o+4,n+1);else if(r)for(var i=0;i>2],n=u(),o=e+4,i=0;i<=r;++i){var a,s=e+4+i*c;i!=r&&0!=n[s>>l]||(a=d(o,s-o),void 0===t?t=a:t=t+String.fromCharCode(0)+a,o=s+c)}return x(e),t},toWireType:function(e,t){"string"!=typeof t&&P("Cannot pass non-string to C++ string type "+o);var r=a(t),n=ur(4+r+c);return p[n>>2]=r>>l,i(t,n+4,r+c),null!==e&&e.push(x,n),n},argPackAdvance:8,readValueFromPointer:Et,destructorFunction:function(e){x(e)}})},_embind_register_void:function(e,t){v(e,{isVoid:!0,name:t=b(t),argPackAdvance:0,fromWireType:function(){},toWireType:function(e,t){}})},_emval_as:function(e,t,r){e=Bt(e),t=Wt(t,"emval::as");var n=[],o=Ht(n);return N[r>>2]=o,t.toWireType(n,e)},_emval_call_void_method:function(e,t,r,n){(e=$t[e])(t=Bt(t),r=void 0===(t=Gt[e=r])?b(e):t,null,n)},_emval_decref:Ct,_emval_get_method_caller:function(e,t){for(var r=function(e,t){for(var r=new Array(e),n=0;n>2)+n],"parameter "+n);return r}(e,t),t=r[0],n=t.name+"_$"+r.slice(1).map(function(e){return e.name}).join("_")+"$",o=["retType"],i=[t],a="",s=0;s>>=0)>t);var r=2147483648;if(r>2]=r,e),o=r,i=0;i>0]=n.charCodeAt(i);F[o>>0]=0,c+=e.length+1}),0},environ_sizes_get:function(e,t){var r=tr(),n=(N[e>>2]=r.length,0);return r.forEach(function(e){n+=e.length+1}),N[t>>2]=n,0},fd_close:function(e){try{var t=_.getStreamFromFD(e);return D.close(t),0}catch(e){return void 0!==D&&e instanceof D.ErrnoError||E(e),e.errno}},fd_fdstat_get:function(e,t){try{var r=_.getStreamFromFD(e),n=r.tty?2:D.isDir(r.mode)?3:D.isLink(r.mode)?7:4;return F[t>>0]=n,0}catch(e){return void 0!==D&&e instanceof D.ErrnoError||E(e),e.errno}},fd_read:function(e,t,r,n){try{var o=_.getStreamFromFD(e),i=_.doReadv(o,t,r);return N[n>>2]=i,0}catch(e){return void 0!==D&&e instanceof D.ErrnoError||E(e),e.errno}},fd_seek:function(e,t,r,n,o){try{var i=_.getStreamFromFD(e),a=4294967296*r+(t>>>0),s=9007199254740992;return a<=-s||s<=a?-61:(D.llseek(i,a,n),l=[i.position>>>0,(u=i.position,1<=+Math.abs(u)?0>>0:~~+Math.ceil((u-(~~u>>>0))/4294967296)>>>0:0)],N[o>>2]=l[0],N[o+4>>2]=l[1],i.getdents&&0==a&&0===n&&(i.getdents=null),0)}catch(e){return void 0!==D&&e instanceof D.ErrnoError||E(e),e.errno}},fd_write:function(e,t,r,n){try{var o=_.getStreamFromFD(e),i=_.doWritev(o,t,r);return N[n>>2]=i,0}catch(e){return void 0!==D&&e instanceof D.ErrnoError||E(e),e.errno}},gettimeofday:function(e){var t=Date.now();return N[e>>2]=t/1e3|0,N[e+4>>2]=t%1e3*1e3|0,0},gmtime_r:function e(t,r){var t=new Date(1e3*N[t>>2]),n=(N[r>>2]=t.getUTCSeconds(),N[r+4>>2]=t.getUTCMinutes(),N[r+8>>2]=t.getUTCHours(),N[r+12>>2]=t.getUTCDate(),N[r+16>>2]=t.getUTCMonth(),N[r+20>>2]=t.getUTCFullYear()-1900,N[r+24>>2]=t.getUTCDay(),N[r+36>>2]=0,N[r+32>>2]=0,Date.UTC(t.getUTCFullYear(),0,1,0,0,0,0)),t=(t.getTime()-n)/864e5|0;return N[r+28>>2]=t,e.GMTString||(e.GMTString=pe("GMT")),N[r+40>>2]=e.GMTString,r},localtime_r:function(e,t){rr();var e=new Date(1e3*N[e>>2]),r=(N[t>>2]=e.getSeconds(),N[t+4>>2]=e.getMinutes(),N[t+8>>2]=e.getHours(),N[t+12>>2]=e.getDate(),N[t+16>>2]=e.getMonth(),N[t+20>>2]=e.getFullYear()-1900,N[t+24>>2]=e.getDay(),new Date(e.getFullYear(),0,1)),n=(e.getTime()-r.getTime())/864e5|0,n=(N[t+28>>2]=n,N[t+36>>2]=-60*e.getTimezoneOffset(),new Date(e.getFullYear(),6,1).getTimezoneOffset()),r=r.getTimezoneOffset(),e=0|(n!=r&&e.getTimezoneOffset()==Math.min(r,n)),r=(N[t+32>>2]=e,N[hr()+(e?4:0)>>2]);return N[t+40>>2]=r,t},mktime:function(e){rr();var t=new Date(N[e+20>>2]+1900,N[e+16>>2],N[e+12>>2],N[e+8>>2],N[e+4>>2],N[e>>2],0),r=N[e+32>>2],n=t.getTimezoneOffset(),o=new Date(t.getFullYear(),0,1),i=new Date(t.getFullYear(),6,1).getTimezoneOffset(),a=o.getTimezoneOffset(),s=Math.min(a,i),r=(r<0?N[e+32>>2]=Number(i!=a&&s==n):0>2]=t.getDay(),(t.getTime()-o.getTime())/864e5|0);return N[e+28>>2]=r,N[e>>2]=t.getSeconds(),N[e+4>>2]=t.getMinutes(),N[e+8>>2]=t.getHours(),N[e+12>>2]=t.getDate(),N[e+16>>2]=t.getMonth(),t.getTime()/1e3|0},setTempRet0:function(e){}},x=(function(){var t={env:dr,wasi_snapshot_preview1:dr};function r(e,t){var e=e.exports;g.asm=e,A(z=g.asm.memory,"memory not found in wasm exports"),fe(z.buffer),A(Ee=g.asm.__indirect_function_table,"table not found in wasm exports"),e=g.asm.__wasm_call_ctors,me.unshift(e),ve("wasm-instantiate")}Pe("wasm-instantiate");var n=g;function o(e){A(g===n,"the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?"),n=null,r(e.instance)}function i(e){return function(){if(!$&&(X||d)){if("function"==typeof fetch&&!Me(a))return fetch(a,{credentials:"same-origin"}).then(function(e){if(e.ok)return e.arrayBuffer();throw"failed to load wasm binary file at '"+a+"'"}).catch(function(){return Se(a)});if(B)return new Promise(function(t,e){B(a,function(e){t(new Uint8Array(e))},e)})}return Promise.resolve().then(function(){return Se(a)})}().then(function(e){return WebAssembly.instantiate(e,t)}).then(function(e){return e}).then(e,function(e){s("failed to asynchronously prepare wasm: "+e),Me(a)&&s("warning: Loading from a file URI ("+a+") is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing"),E(e)})}if(g.instantiateWasm)try{return g.instantiateWasm(t,r)}catch(t){return s("Module.instantiateWasm callback failed with error: "+t)}$||"function"!=typeof WebAssembly.instantiateStreaming||Re(a)||Me(a)||"function"!=typeof fetch?i(o):fetch(a,{credentials:"same-origin"}).then(function(e){return WebAssembly.instantiateStreaming(e,t).then(o,function(e){return s("wasm streaming compile failed: "+e),s("falling back to ArrayBuffer instantiation"),i(o)})})}(),g.___wasm_call_ctors=h("__wasm_call_ctors"),g._free=h("free")),ur=g._malloc=h("malloc"),lr=g._strlen=h("strlen"),pr=g.___errno_location=h("__errno_location"),fr=g.___getTypeName=h("__getTypeName"),Er=(g.___embind_register_native_and_builtin_types=h("__embind_register_native_and_builtin_types"),g._emscripten_stack_get_end=function(){return(Er=g._emscripten_stack_get_end=g.asm.emscripten_stack_get_end).apply(null,arguments)}),hr=(g._fflush=h("fflush"),g.__get_tzname=h("_get_tzname")),gr=g.__get_daylight=h("_get_daylight"),Tr=g.__get_timezone=h("_get_timezone"),Or=(g.stackSave=h("stackSave"),g.stackRestore=h("stackRestore"),g.stackAlloc=h("stackAlloc"),g._emscripten_stack_init=function(){return(Or=g._emscripten_stack_init=g.asm.emscripten_stack_init).apply(null,arguments)});g._emscripten_stack_get_free=function(){return(g._emscripten_stack_get_free=g.asm.emscripten_stack_get_free).apply(null,arguments)};var mr,wr=g._memalign=h("memalign");function yr(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function Dr(e){function t(){if(!mr&&(mr=!0,g.calledRun=!0,!Y)){if(Te(),A(!ye),ye=!0,g.noFSInit||D.init.initialized||D.init(),D.ignorePermissions=!1,Ae(me),g.onRuntimeInitialized&&g.onRuntimeInitialized(),A(!g._main,'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'),Te(),g.postRun)for("function"==typeof g.postRun&&(g.postRun=[g.postRun]);g.postRun.length;)e=g.postRun.shift(),we.unshift(e);var e;Ae(we)}}if(!(0e.forEach(e=>d.set(e,t)));class P{constructor(e){this.g=e,this.consumed=0,e&&(this.need=e.next().value)}fillFromReader(r){return e=this,c=function*(){var{done:e,value:t}=yield r.read();return e?void this.close():(this.write(t),this.fillFromReader(r))},new(s=(s=a=void 0)||Promise)(function(r,t){function n(e){try{i(c.next(e))}catch(e){t(e)}}function o(e){try{i(c.throw(e))}catch(e){t(e)}}function i(e){var t;e.done?r(e.value):((t=e.value)instanceof s?t:new s(function(e){e(t)})).then(n,o)}i((c=c.apply(e,a||[])).next())});var e,a,s,c}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(a)}readU16(){return this.read(s)}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===a){if(r(4))return;e=n[0]<<24|n[1]<<16|n[2]<<8|n[3]}else if(this.need===s){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<>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}}P.U32=a,P.U16=s,P.U8=c,Date.now||(Date.now=function(){return(new Date).getTime()}),g.postRun=function(){function r(){i&&(i.abort(),i=null)}var n=[],l=[],o={},i=new AbortController,a=null,s=null,c=null,h=("VideoEncoder"in self&&(o={hasInit:!1,isEmitInfo:!1,offscreenCanvas:null,offscreenCanvasCtx:null,decoder:new VideoDecoder({output:function(e){o.isEmitInfo||(h.opt.debug&&console.log("Jessibuca: [worker] Webcodecs Video Decoder initSize"),postMessage({cmd:T,w:e.codedWidth,h:e.codedHeight}),o.isEmitInfo=!0,o.offscreenCanvas=new OffscreenCanvas(e.codedWidth,e.codedHeight),o.offscreenCanvasCtx=o.offscreenCanvas.getContext("2d")),o.offscreenCanvasCtx.drawImage(e,0,0,e.codedWidth,e.codedHeight);var t=o.offscreenCanvas.transferToImageBitmap();postMessage({cmd:O,buffer:t,delay:h.delay,ts:0},[t]),setTimeout(function(){e.close?e.close():e.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=(h.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:E.debug,forceNoOffscreen:E.forceNoOffscreen,useWCS:E.useWCS,videoBuffer:E.videoBuffer,openWebglAlignment:E.openWebglAlignment,playType:E.playType,hasAudio:E.hasAudio,isFlv:E.isFlv},useOffscreen:function(){return!h.opt.forceNoOffscreen&&"undefined"!=typeof OffscreenCanvas},initAudioPlanar:function(c,e){postMessage({cmd:"initAudio",sampleRate:e,channels:c});var d=[],u=0;this.playAudioPlanar=function(e,t,r){for(var n=t,o=[],i=0,a=0;a<2;a++){var s=g.HEAPU32[(e>>2)+a]>>2;o[a]=g.HEAPF32.subarray(s,s+n)}if(u){if(!(n>=(t=1024-u)))return u+=n,l[0]=Float32Array.of(...l[0],...o[0]),void(2==c&&(l[1]=Float32Array.of(...l[1],...o[1])));d[0]=Float32Array.of(...l[0],...o[0].subarray(0,t)),2==c&&(d[1]=Float32Array.of(...l[1],...o[1].subarray(0,t))),postMessage({cmd:m,buffer:d,ts:r},d.map(e=>e.buffer)),n-=i=t}for(u=n;1024<=u;u-=1024)d[0]=o[0].slice(i,i+=1024),2==c&&(d[1]=o[1].slice(i-1024,i)),postMessage({cmd:m,buffer:d,ts:r},d.map(e=>e.buffer));u&&(l[0]=o[0].slice(i),2==c&&(l[1]=o[1].slice(i)))}},setVideoCodec:function(e){postMessage({cmd:"videoCode",code:e})},setAudioCodec:function(e){postMessage({cmd:"audioCode",code:e})},setVideoSize:function(o,i){postMessage({cmd:T,w:o,h:i});var a,e,t,r,n,s,c,d,u,l,p=o*i,f=p>>2;function E(e,t){var r=a.createTexture();return a.bindTexture(a.TEXTURE_2D,r),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.bindTexture(a.TEXTURE_2D,null),a.uniform1i(a.getUniformLocation(n,e),t),r}h.useOffscreen()?(this.offscreenCanvas=new OffscreenCanvas(o,i),this.offscreenCanvasGL=this.offscreenCanvas.getContext("webgl"),this.webglObj=(a=this.offscreenCanvasGL,e=h.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&&a.pixelStorei(a.UNPACK_ALIGNMENT,1),e=a.createShader(a.VERTEX_SHADER),a.shaderSource(e,t),a.compileShader(e),a.getShaderParameter(e,a.COMPILE_STATUS)||console.log("Vertex shader failed to compile: "+a.getShaderInfoLog(e)),t=a.createShader(a.FRAGMENT_SHADER),a.shaderSource(t,r),a.compileShader(t),a.getShaderParameter(t,a.COMPILE_STATUS)||console.log("Fragment shader failed to compile: "+a.getShaderInfoLog(t)),n=a.createProgram(),a.attachShader(n,e),a.attachShader(n,t),a.linkProgram(n),a.getProgramParameter(n,a.LINK_STATUS)||console.log("Program failed to compile: "+a.getProgramInfoLog(n)),a.useProgram(n),s=a.createBuffer(),a.bindBuffer(a.ARRAY_BUFFER,s),a.bufferData(a.ARRAY_BUFFER,new Float32Array([1,1,-1,1,1,-1,-1,-1]),a.STATIC_DRAW),r=a.getAttribLocation(n,"vertexPos"),a.enableVertexAttribArray(r),a.vertexAttribPointer(r,2,a.FLOAT,!1,0,0),c=a.createBuffer(),a.bindBuffer(a.ARRAY_BUFFER,c),a.bufferData(a.ARRAY_BUFFER,new Float32Array([1,0,0,0,1,1,0,1]),a.STATIC_DRAW),e=a.getAttribLocation(n,"texturePos"),a.enableVertexAttribArray(e),a.vertexAttribPointer(e,2,a.FLOAT,!1,0,0),d=E("ySampler",0),u=E("uSampler",1),l=E("vSampler",2),{render:function(e,t,r,n,o){a.viewport(0,0,e,t),a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,d),a.texImage2D(a.TEXTURE_2D,0,a.LUMINANCE,e,t,0,a.LUMINANCE,a.UNSIGNED_BYTE,r),a.activeTexture(a.TEXTURE1),a.bindTexture(a.TEXTURE_2D,u),a.texImage2D(a.TEXTURE_2D,0,a.LUMINANCE,e/2,t/2,0,a.LUMINANCE,a.UNSIGNED_BYTE,n),a.activeTexture(a.TEXTURE2),a.bindTexture(a.TEXTURE_2D,l),a.texImage2D(a.TEXTURE_2D,0,a.LUMINANCE,e/2,t/2,0,a.LUMINANCE,a.UNSIGNED_BYTE,o),a.drawArrays(a.TRIANGLE_STRIP,0,4)},destroy:function(){try{a.deleteProgram(n),a.deleteBuffer(s),a.deleteBuffer(c),a.deleteTexture(d),a.deleteTexture(u),a.deleteBuffer(l)}catch(e){}}}),this.draw=function(e,t,r,n){this.webglObj.render(o,i,g.HEAPU8.subarray(t,t+p),g.HEAPU8.subarray(r,r+f),g.HEAPU8.subarray(n,n+f));t=this.offscreenCanvas.transferToImageBitmap();postMessage({cmd:O,buffer:t,delay:this.delay,ts:e},[t])}):this.draw=function(e,t,r,n){t=[g.HEAPU8.subarray(t,t+p),g.HEAPU8.subarray(r,r+f),g.HEAPU8.subarray(n,n+f)].map(e=>Uint8Array.from(e));postMessage({cmd:O,output:t,delay:this.delay,ts:e},t.map(e=>e.buffer))}},getDelay:function(e){return e?(this.firstTimestamp?e&&(this.delay=Date.now()-this.startTimestamp-(e-this.firstTimestamp)):(this.firstTimestamp=e,this.startTimestamp=Date.now(),this.delay=-1),this.delay):-1},resetDelay:function(){this.firstTimestamp=null,this.startTimestamp=null,this.delay=-1},init:function(){h.opt.debug&&console.log("Jessibuca: [worker] init");const t=e=>{(h.opt.useWCS&&h.useOffscreen()&&2===e.type&&o.decode?o:e.decoder).decode(e.payload,e.ts)};this.stopId=setInterval(()=>{if(n.length)if(this.dropping){for(h.opt.debug&&console.log("Jessibuca: [worker]: loop is dropping"),1===(e=n.shift()).type&&0===e.payload[1]&&t(e);!e.isIFrame&&n.length;)h.opt.debug&&console.log("Jessibuca: [worker]: loop is dropping = true, isIFrame is",e.isIFrame),1===(e=n.shift()).type&&0===e.payload[1]&&t(e);e.isIFrame&&(this.dropping=!1,t(e))}else{var e=n[0];if(-1===this.getDelay(e.ts))h.opt.debug&&console.log("Jessibuca: [worker]: common dumex delay is -1"),n.shift(),t(e);else if(this.delay>h.opt.videoBuffer+1e3)h.opt.debug&&console.log("Jessibuca: [worker]:",`delay is ${this.delay}, set dropping is true`),this.resetDelay(),this.dropping=!0;else for(;n.length&&(e=n[0],this.getDelay(e.ts)>h.opt.videoBuffer);)n.shift(),t(e)}},10)},close:function(){h.opt.debug&&console.log("Jessibuca: [worker]: close"),clearInterval(this.stopId),this.stopId=null,d.clear(),u.clear(),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=[],l=[],i=null,a&&(a.close(),a=null),delete this.playAudioPlanar,delete this.draw},pushBuffer:function(e,t){1===t.type?n.push({ts:t.ts,payload:e,decoder:d,type:1}):2===t.type&&n.push({ts:t.ts,payload:e,decoder:u,type:2,isIFrame:t.isIFrame})},fetchStream:function(e,t){h.opt.debug&&console.log("Jessibuca: [worker]: fetchStream, url is "+e,"options:",t),s=function(){let r=0,n=b();return e=>{r+=e;var e=b(),t=e-n;1e3<=t&&(t=r/t*1e3,postMessage({cmd:w,type:"streamRate",value:t}),n=e,r=0)}}(),2===t.protocol?(c=new P(h.demuxFlv()),fetch(e,{signal:i.signal}).then(e=>{postMessage({cmd:w,type:D}),e.body.pipeTo(new WritableStream({write:e=>(s(e.byteLength),c.write(e)),close:()=>{c=null},abort:e=>{c=null,postMessage({cmd:w,type:_,value:e.toString()}),r()}}))}).catch(e=>{postMessage({cmd:w,type:_,value:e.toString()}),r()})):1===t.protocol&&(h.opt.isFlv&&(c=new P(h.demuxFlv())),(a=new WebSocket(e)).binaryType="arraybuffer",a.onopen=()=>{h.opt.debug&&console.log("Jessibuca: [worker]: fetchStream, WebsocketStream socket open"),postMessage({cmd:w,type:D})},a.onclose=()=>{h.opt.debug&&console.log("Jessibuca: [worker]: fetchStream, WebsocketStream socket close"),h.opt.isFlv&&(c=null),postMessage({cmd:w,type:"streamEnd"})},a.onerror=e=>{h.opt.debug&&console.log("Jessibuca: [worker]: fetchStream, WebsocketStream socket error"),h.opt.isFlv&&(c=null),postMessage({cmd:w,type:"websocketError",value:e.toString()})},a.onmessage=e=>{if(s(e.data.byteLength),h.opt.isFlv)c.write(e.data);else{const n=new DataView(e.data),o=(n.getUint8(0),n.getUint32(1,!1));switch(i){case 1:const i=new Uint8Array(e.data,5);h.decode(i,{type:1,ts:o});break;case 2:var t,r;5>4==1,h.decode(t,{type:2,ts:o,isIFrame:r}))}}})},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,a=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(a){case 8:h.decode(i,{type:1,ts:e});break;case 9:const t=i[0]>>4==1;0