canvas-2aaf4e1d.js 200 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. var ft=(p=>(p.VideoCodecInfo="videoCodecInfo",p.VideoFrame="videoFrame",p.Error="error",p))(ft||{}),Gt=(p=>(p.AudioCodecInfo="audioCodecInfo",p.AudioFrame="audioFrame",p.Error="error",p))(Gt||{}),qt={},Ui={get exports(){return qt},set exports(p){qt=p}};(function(p){var a=Object.prototype.hasOwnProperty,o="~";function h(){}Object.create&&(h.prototype=Object.create(null),new h().__proto__||(o=!1));function y(S,w,C){this.fn=S,this.context=w,this.once=C||!1}function _(S,w,C,F,H){if(typeof C!="function")throw new TypeError("The listener must be a function");var te=new y(C,F||S,H),Z=o?o+w:w;return S._events[Z]?S._events[Z].fn?S._events[Z]=[S._events[Z],te]:S._events[Z].push(te):(S._events[Z]=te,S._eventsCount++),S}function b(S,w){--S._eventsCount===0?S._events=new h:delete S._events[w]}function D(){this._events=new h,this._eventsCount=0}D.prototype.eventNames=function(){var w=[],C,F;if(this._eventsCount===0)return w;for(F in C=this._events)a.call(C,F)&&w.push(o?F.slice(1):F);return Object.getOwnPropertySymbols?w.concat(Object.getOwnPropertySymbols(C)):w},D.prototype.listeners=function(w){var C=o?o+w:w,F=this._events[C];if(!F)return[];if(F.fn)return[F.fn];for(var H=0,te=F.length,Z=new Array(te);H<te;H++)Z[H]=F[H].fn;return Z},D.prototype.listenerCount=function(w){var C=o?o+w:w,F=this._events[C];return F?F.fn?1:F.length:0},D.prototype.emit=function(w,C,F,H,te,Z){var N=o?o+w:w;if(!this._events[N])return!1;var B=this._events[N],ce=arguments.length,X,ie;if(B.fn){switch(B.once&&this.removeListener(w,B.fn,void 0,!0),ce){case 1:return B.fn.call(B.context),!0;case 2:return B.fn.call(B.context,C),!0;case 3:return B.fn.call(B.context,C,F),!0;case 4:return B.fn.call(B.context,C,F,H),!0;case 5:return B.fn.call(B.context,C,F,H,te),!0;case 6:return B.fn.call(B.context,C,F,H,te,Z),!0}for(ie=1,X=new Array(ce-1);ie<ce;ie++)X[ie-1]=arguments[ie];B.fn.apply(B.context,X)}else{var Oe=B.length,ee;for(ie=0;ie<Oe;ie++)switch(B[ie].once&&this.removeListener(w,B[ie].fn,void 0,!0),ce){case 1:B[ie].fn.call(B[ie].context);break;case 2:B[ie].fn.call(B[ie].context,C);break;case 3:B[ie].fn.call(B[ie].context,C,F);break;case 4:B[ie].fn.call(B[ie].context,C,F,H);break;default:if(!X)for(ee=1,X=new Array(ce-1);ee<ce;ee++)X[ee-1]=arguments[ee];B[ie].fn.apply(B[ie].context,X)}}return!0},D.prototype.on=function(w,C,F){return _(this,w,C,F,!1)},D.prototype.once=function(w,C,F){return _(this,w,C,F,!0)},D.prototype.removeListener=function(w,C,F,H){var te=o?o+w:w;if(!this._events[te])return this;if(!C)return b(this,te),this;var Z=this._events[te];if(Z.fn)Z.fn===C&&(!H||Z.once)&&(!F||Z.context===F)&&b(this,te);else{for(var N=0,B=[],ce=Z.length;N<ce;N++)(Z[N].fn!==C||H&&!Z[N].once||F&&Z[N].context!==F)&&B.push(Z[N]);B.length?this._events[te]=B.length===1?B[0]:B:b(this,te)}return this},D.prototype.removeAllListeners=function(w){var C;return w?(C=o?o+w:w,this._events[C]&&b(this,C)):(this._events=new h,this._eventsCount=0),this},D.prototype.off=D.prototype.removeListener,D.prototype.addListener=D.prototype.on,D.prefixed=o,D.EventEmitter=D,p.exports=D})(Ui);const Si=Symbol("instance"),wi=Symbol("cacheResult");let _i=class{constructor(a,o,h){this.oldState=a,this.newState=o,this.action=h,this.aborted=!1}abort(a){this.aborted=!0,Nn.call(a,this.oldState,new Error(`action '${this.action}' aborted`))}toString(){return`${this.action}ing`}},ni=class extends Error{constructor(a,o,h){super(o),this.state=a,this.message=o,this.cause=h}};function Mi(p){return typeof p=="object"&&p&&"then"in p}const zn=new Map;function ii(p,a,o={}){return(h,y,_)=>{const b=o.action||y;if(!o.context){const S=zn.get(h)||[];zn.has(h)||zn.set(h,S),S.push({from:p,to:a,action:b})}const D=_.value;_.value=function(...S){let w=this;if(o.context&&(w=cr.get(typeof o.context=="function"?o.context.call(this,...S):o.context)),w.state===a)return w[wi];w.state instanceof _i&&w.state.action==o.abortAction&&w.state.abort(w);let C=null;if(Array.isArray(p)?p.length==0?w.state instanceof _i&&w.state.abort(w):(typeof w.state!="string"||!p.includes(w.state))&&(C=new ni(w._state,`${w.name} ${b} to ${a} failed: current state ${w._state} not in from config`)):p!==w.state&&(C=new ni(w._state,`${w.name} ${b} to ${a} failed: current state ${w._state} not from ${p}`)),C)if(o.fail)o.fail.call(this,C);else{if(o.ignoreError)return C;throw C}const F=w.state,H=new _i(F,a,b);Nn.call(w,H);const te=N=>{var B;return w[wi]=N,H.aborted||(Nn.call(w,a),(B=o.success)===null||B===void 0||B.call(this,w[wi])),N},Z=N=>{const B=N instanceof Error?N.message:String(N);if(Nn.call(w,F,N),o.fail)o.fail.call(this,new ni(w._state,`action '${b}' failed :${B}`,N instanceof Error?N:new Error(B)));else{if(o.ignoreError)return N;throw N}};try{const N=D.apply(this,S);return Mi(N)?N.then(te).catch(Z):te(N)}catch(N){Z(N)}}}}function xi(...p){return(a,o,h)=>{const y=h.value,_=o;h.value=function(...b){if(!p.includes(this.state.toString()))throw new ni(this.state,`${this.name} ${_} failed: current state ${this.state} not in ${p}`);return y.apply(this,b)}}}const Ii=(()=>typeof window<"u"&&window.__AFSM__?(o,h)=>{window.dispatchEvent(new CustomEvent(o,{detail:h}))}:typeof importScripts<"u"?(o,h)=>{postMessage({type:o,payload:h})}:()=>{})();function Nn(p,a){const o=this._state;this._state=p;const h=p.toString();p&&this.emit(h,o),this.emit(cr.STATECHANGED,p,o,a),this.updateDevTools({value:p,old:o,err:a instanceof Error?a.message:String(a)})}let cr=class lr extends qt{constructor(a,o,h){super(),this.name=a,this.groupName=o,this._state=lr.INIT,a||(a=Date.now().toString(36)),h?Object.setPrototypeOf(this,h):h=Object.getPrototypeOf(this),o||(this.groupName=this.constructor.name);const y=h[Si];y?this.name=y.name+"-"+y.count++:h[Si]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){const a=Object.getPrototypeOf(this),o=zn.get(a)||[];let h=new Set,y=[],_=[];const b=new Set,D=Object.getPrototypeOf(a);zn.has(D)&&(D.stateDiagram.forEach(w=>h.add(w)),D.allStates.forEach(w=>b.add(w))),o.forEach(({from:w,to:C,action:F})=>{typeof w=="string"?y.push({from:w,to:C,action:F}):w.length?w.forEach(H=>{y.push({from:H,to:C,action:F})}):_.push({to:C,action:F})}),y.forEach(({from:w,to:C,action:F})=>{b.add(w),b.add(C),b.add(F+"ing"),h.add(`${w} --> ${F}ing : ${F}`),h.add(`${F}ing --> ${C} : ${F} 🟢`),h.add(`${F}ing --> ${w} : ${F} 🔴`)}),_.forEach(({to:w,action:C})=>{h.add(`${C}ing --> ${w} : ${C} 🟢`),b.forEach(F=>{F!==w&&h.add(`${F} --> ${C}ing : ${C}`)})});const S=[...h];return Object.defineProperties(a,{stateDiagram:{value:S},allStates:{value:b}}),S}static get(a){let o;return typeof a=="string"?(o=lr.instances.get(a),o||lr.instances.set(a,o=new lr(a,void 0,Object.create(lr.prototype)))):(o=lr.instances2.get(a),o||lr.instances2.set(a,o=new lr(a.constructor.name,void 0,Object.create(lr.prototype)))),o}static getState(a){var o;return(o=lr.get(a))===null||o===void 0?void 0:o.state}updateDevTools(a={}){Ii(lr.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},a))}get state(){return this._state}set state(a){Nn.call(this,a)}};cr.STATECHANGED="stateChanged";cr.UPDATEAFSM="updateAFSM";cr.INIT="[*]";cr.ON="on";cr.OFF="off";cr.instances=new Map;cr.instances2=new WeakMap;var lt=(p=>(p.CONNECTED="connected",p.DISCONNECTED="disconnected",p.RECONNECTED="reconnected",p))(lt||{}),ji=globalThis&&globalThis.__awaiter||function(p,a,o,h){function y(_){return _ instanceof o?_:new o(function(b){b(_)})}return new(o||(o=Promise))(function(_,b){function D(C){try{w(h.next(C))}catch(F){b(F)}}function S(C){try{w(h.throw(C))}catch(F){b(F)}}function w(C){C.done?_(C.value):y(C.value).then(D,S)}w((h=h.apply(p,a||[])).next())})};const Ei=Symbol(32),Pi=Symbol(16),Ci=Symbol(8);class qn{constructor(a){this.g=a,this.consumed=0,a&&(this.need=a.next().value)}setG(a){this.g=a,this.demand(a.next().value,!0)}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(a,o){return o&&this.consume(),this.need=a,this.flush()}read(a){return ji(this,void 0,void 0,function*(){return this.lastReadPromise&&(yield this.lastReadPromise),this.lastReadPromise=new Promise((o,h)=>{var y;this.reject=h,this.resolve=b=>{delete this.lastReadPromise,delete this.resolve,delete this.need,o(b)},this.demand(a,!0)||(y=this.pull)===null||y===void 0||y.call(this,a)})})}readU32(){return this.read(Ei)}readU16(){return this.read(Pi)}readU8(){return this.read(Ci)}close(){var a;this.g&&this.g.return(),this.buffer&&this.buffer.subarray(0,0),(a=this.reject)===null||a===void 0||a.call(this,new Error("EOF")),delete this.lastReadPromise}flush(){if(!this.buffer||!this.need)return;let a=null;const o=this.buffer.subarray(this.consumed);let h=0;const y=_=>o.length<(h=_);if(typeof this.need=="number"){if(y(this.need))return;a=o.subarray(0,h)}else if(this.need===Ei){if(y(4))return;a=o[0]<<24|o[1]<<16|o[2]<<8|o[3]}else if(this.need===Pi){if(y(2))return;a=o[0]<<8|o[1]}else if(this.need===Ci){if(y(1))return;a=o[0]}else if("buffer"in this.need){if("byteOffset"in this.need){if(y(this.need.byteLength-this.need.byteOffset))return;new Uint8Array(this.need.buffer,this.need.byteOffset).set(o.subarray(0,h)),a=this.need}else if(this.g){this.g.throw(new Error("Unsupported type"));return}}else{if(y(this.need.byteLength))return;new Uint8Array(this.need).set(o.subarray(0,h)),a=this.need}return this.consumed+=h,this.g?this.demand(this.g.next(a).value,!0):this.resolve&&this.resolve(a),a}write(a){if(a instanceof Uint8Array?this.malloc(a.length).set(a):"buffer"in a?this.malloc(a.byteLength).set(new Uint8Array(a.buffer,a.byteOffset,a.byteLength)):this.malloc(a.byteLength).set(new Uint8Array(a)),this.g||this.resolve)this.flush();else return new Promise(o=>this.pull=o)}writeU32(a){this.malloc(4).set([a>>24&255,a>>16&255,a>>8&255,a&255]),this.flush()}writeU16(a){this.malloc(2).set([a>>8&255,a&255]),this.flush()}writeU8(a){this.malloc(1)[0]=a,this.flush()}malloc(a){if(this.buffer){const o=this.buffer.length,h=o+a;if(h<=this.buffer.buffer.byteLength-this.buffer.byteOffset)this.buffer=new Uint8Array(this.buffer.buffer,this.buffer.byteOffset,h);else{const y=new Uint8Array(h);y.set(this.buffer),this.buffer=y}return this.buffer.subarray(o,h)}else return this.buffer=new Uint8Array(a),this.buffer}}qn.U32=Ei;qn.U16=Pi;qn.U8=Ci;var Li=Object.defineProperty,Bi=Object.getOwnPropertyDescriptor,Xn=(p,a,o,h)=>{for(var y=h>1?void 0:h?Bi(a,o):a,_=p.length-1,b;_>=0;_--)(b=p[_])&&(y=(h?b(a,o,y):b(y))||y);return h&&y&&Li(a,o,y),y};function Ri(p,a=1,o=1){return p<=1?o:Ri(p-1,o,a+o)}function Hi(p){const a=Math.round(p/2)+1;return a>6?13*1e3:Ri(a)*1e3}class ki{constructor(){this.total=0,this._buffer=0,this.lastTime=0,this._bps=0}add(a){const o=Date.now();this._buffer+=a,this.lastTime===0?this.lastTime=o:o-this.lastTime>1e3&&(this._bps=this._buffer*1e3/(o-this.lastTime)>>0,this._buffer=0,this.lastTime=o),this.total+=a}get bps(){return Date.now()-this.lastTime>5e3?0:this._bps}}class At extends cr{constructor(a,o={}){super(a||"conn","Connection"),this.url=a,this.options=o,this.up=new ki,this.down=new ki,this.underlyingSink={write:async h=>(this.down.add(h.length||h.byteLength),this.oput?.write(h))},this.options.reconnectTimeout||(this.options.reconnectTimeout=Hi)}read(a){return Promise.reject("not connected")}async connect(){this.abortCtrl=new AbortController,`${this.url}`,console.time(this.url),this.onConnected(await this._connect())}_close(){}_send(a){}async reconnect(){`${this.url}`,console.time(this.url),this.abortCtrl=new AbortController,this.onConnected(await this._connect())}onConnected(a){if(console.timeEnd(this.url),!!a)return this.oput||(this.oput=new qn),this.read=this.oput.read.bind(this.oput),a.pipeTo(new WritableStream(this.underlyingSink),this.abortCtrl).catch(o=>{this.abortCtrl.signal.aborted||this.disconnect(o)})}disconnect(a){console.warn(`disconnect: ${this.url}`,a),this.options.reconnectCount&&this.reconnectAfter()}reconnectAfter(a=1e3,o=0){setTimeout(()=>{this.reconnect().catch(h=>{`${this.url}`,o<this.options.reconnectCount&&this.reconnectAfter(this.options.reconnectTimeout(o),o+1)})},a)}close(){this.abortCtrl?.abort(),this._close()}send(a){this.up.add(a.byteLength-("byteOffset"in a?a.byteOffset:0)),this._send(a)}}Xn([xi(lt.CONNECTED)],At.prototype,"read",1);Xn([ii([lt.DISCONNECTED,cr.INIT],lt.CONNECTED)],At.prototype,"connect",1);Xn([ii(lt.DISCONNECTED,lt.RECONNECTED)],At.prototype,"reconnect",1);Xn([ii(lt.CONNECTED,lt.DISCONNECTED)],At.prototype,"disconnect",1);Xn([ii([],cr.INIT)],At.prototype,"close",1);class ho extends At{async _connect(){const a=new WebSocket(this.url);return this.ws=a,a.binaryType="arraybuffer",new Promise((o,h)=>{a.onerror=h,a.onopen=()=>{o(new ReadableStream({start:y=>{a.onclose=_=>y.error(_),a.onmessage=_=>y.enqueue(_.data)}}))}})}_close(){this.ws?.close(1e3,"close")}_send(a){this.ws?.send(a)}}class po extends At{constructor(a){super(a.label),this.dc=a}async _connect(){return new ReadableStream({start:a=>{this.dc.onclose=()=>{a.close()},this.dc.onerror=o=>{a.error(o)},this.dc.onmessage=o=>{a.enqueue(o.data)}}})}_close(){this.dc.close()}_send(a){this.dc.send(a)}}class vo extends qt.EventEmitter{constructor(a,o="recvonly"){super(),this.id=a,this.direction=o}get mediaStream(){return this._mediaStream}set mediaStream(a){this._mediaStream=a,a&&this.emit("change",a)}set audioTrack(a){if(this._audioTrack=a,this._mediaStream){const o=this._mediaStream.getAudioTracks()[0];o&&this._mediaStream.removeTrack(o)}a&&(this._mediaStream?this._mediaStream.addTrack(a):this._mediaStream=new MediaStream([a])),this._mediaStream&&this.emit("change",this._mediaStream)}get audioTrack(){return this._audioTrack||this._mediaStream?.getAudioTracks()[0]}set videoTrack(a){if(this._videoTrack=a,this._mediaStream){const o=this._mediaStream.getVideoTracks()[0];o&&this._mediaStream.removeTrack(o)}a&&(this._mediaStream?this._mediaStream.addTrack(a):this._mediaStream=new MediaStream([a])),this._mediaStream&&this.emit("change",this._mediaStream)}get videoTrack(){return this._videoTrack||this._mediaStream?.getVideoTracks()[0]}close(){this.emit("close")}}const Ai=Symbol("instance"),ti=Symbol("cacheResult");class bi{constructor(a,o,h){this.oldState=a,this.newState=o,this.action=h,this.aborted=!1}abort(a){this.aborted=!0,Gn.call(a,this.oldState,new Error(`action '${this.action}' aborted`))}toString(){return`${this.action}ing`}}class $i extends Error{constructor(a,o,h){super(o),this.state=a,this.message=o,this.cause=h}}function Wi(p){return typeof p=="object"&&p&&"then"in p}const Vn=new Map;function ke(p,a,o={}){return(h,y,_)=>{const b=o.action||y;if(!o.context){const S=Vn.get(h)||[];Vn.has(h)||Vn.set(h,S),S.push({from:p,to:a,action:b})}const D=_.value;_.value=function(...S){let w=this;if(o.context&&(w=de.get(typeof o.context=="function"?o.context.call(this,...S):o.context)),w.state===a)return o.sync?w[ti]:Promise.resolve(w[ti]);w.state instanceof bi&&w.state.action==o.abortAction&&w.state.abort(w);let C=null;Array.isArray(p)?p.length==0?w.state instanceof bi&&w.state.abort(w):(typeof w.state!="string"||!p.includes(w.state))&&(C=new $i(w._state,`${w.name} ${b} to ${a} failed: current state ${w._state} not from ${p.join("|")}`)):p!==w.state&&(C=new $i(w._state,`${w.name} ${b} to ${a} failed: current state ${w._state} not from ${p}`));const F=B=>{if(o.fail&&o.fail.call(this,B),o.sync){if(o.ignoreError)return B;throw B}else return o.ignoreError?Promise.resolve(B):Promise.reject(B)};if(C)return F(C);const H=w.state,te=new bi(H,a,b);Gn.call(w,te);const Z=B=>{var ce;return w[ti]=B,te.aborted||(Gn.call(w,a),(ce=o.success)===null||ce===void 0||ce.call(this,w[ti])),B},N=B=>(Gn.call(w,H,B),F(B));try{const B=D.apply(this,S);return Wi(B)?B.then(Z).catch(N):o.sync?Z(B):Promise.resolve(Z(B))}catch(B){return N(B)}}}}function Ti(...p){return(a,o,h)=>{const y=h.value,_=o;h.value=function(...b){if(!p.includes(this.state.toString()))throw new $i(this.state,`${this.name} ${_} failed: current state ${this.state} not in ${p}`);return y.apply(this,b)}}}const zi=(()=>typeof window<"u"&&window.__AFSM__?(o,h)=>{window.dispatchEvent(new CustomEvent(o,{detail:h}))}:typeof importScripts<"u"?(o,h)=>{postMessage({type:o,payload:h})}:()=>{})();function Gn(p,a){const o=this._state;this._state=p;const h=p.toString();p&&this.emit(h,o),this.emit(de.STATECHANGED,p,o,a),this.updateDevTools({value:p,old:o,err:a instanceof Error?a.message:String(a)})}class de extends qt{constructor(a,o,h){super(),this.name=a,this.groupName=o,this._state=de.INIT,a||(a=Date.now().toString(36)),h?Object.setPrototypeOf(this,h):h=Object.getPrototypeOf(this),o||(this.groupName=this.constructor.name);const y=h[Ai];y?this.name=y.name+"-"+y.count++:h[Ai]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){const a=Object.getPrototypeOf(this),o=Vn.get(a)||[];let h=new Set,y=[],_=[];const b=new Set,D=Object.getPrototypeOf(a);Vn.has(D)&&(D.stateDiagram.forEach(w=>h.add(w)),D.allStates.forEach(w=>b.add(w))),o.forEach(({from:w,to:C,action:F})=>{typeof w=="string"?y.push({from:w,to:C,action:F}):w.length?w.forEach(H=>{y.push({from:H,to:C,action:F})}):_.push({to:C,action:F})}),y.forEach(({from:w,to:C,action:F})=>{b.add(w),b.add(C),b.add(F+"ing"),h.add(`${w} --> ${F}ing : ${F}`),h.add(`${F}ing --> ${C} : ${F} 🟢`),h.add(`${F}ing --> ${w} : ${F} 🔴`)}),_.forEach(({to:w,action:C})=>{h.add(`${C}ing --> ${w} : ${C} 🟢`),b.forEach(F=>{F!==w&&h.add(`${F} --> ${C}ing : ${C}`)})});const S=[...h];return Object.defineProperties(a,{stateDiagram:{value:S},allStates:{value:b}}),S}static get(a){let o;return typeof a=="string"?(o=de.instances.get(a),o||de.instances.set(a,o=new de(a,void 0,Object.create(de.prototype)))):(o=de.instances2.get(a),o||de.instances2.set(a,o=new de(a.constructor.name,void 0,Object.create(de.prototype)))),o}static getState(a){var o;return(o=de.get(a))===null||o===void 0?void 0:o.state}updateDevTools(a={}){zi(de.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},a))}get state(){return this._state}set state(a){Gn.call(this,a)}}de.STATECHANGED="stateChanged";de.UPDATEAFSM="updateAFSM";de.INIT="[*]";de.ON="on";de.OFF="off";de.instances=new Map;de.instances2=new WeakMap;var Ni=Object.defineProperty,Vi=Object.getOwnPropertyDescriptor,oi=(p,a,o,h)=>{for(var y=h>1?void 0:h?Vi(a,o):a,_=p.length-1,b;_>=0;_--)(b=p[_])&&(y=(h?b(a,o,y):b(y))||y);return h&&y&&Ni(a,o,y),y};function Gi(){var p;self.onmessage=a=>{if(a.data.type==="init"){const{canvas:o,wasmScript:h,wasmBinary:y}=a.data,_=o?.getContext("2d");let b=0,D=0;const S={wasmBinary:y,postRun:()=>{p=new S.VideoDecoder({videoInfo(w,C){b=w,D=C},yuvData(w,C){const F=b*D,H=F>>2;let te=S.HEAPU32[w>>2],Z=S.HEAPU32[(w>>2)+1],N=S.HEAPU32[(w>>2)+2],B=S.HEAPU8.subarray(te,te+F),ce=S.HEAPU8.subarray(Z,Z+H),X=S.HEAPU8.subarray(N,N+H);const ie=new Uint8Array(F+H+H);ie.set(B),ie.set(ce,F),ie.set(X,F+H);const Oe=new VideoFrame(ie,{codedWidth:b,codedHeight:D,format:"I420",timestamp:C});o?(_?.drawImage(Oe,0,0,o.width,o.height),_?.commit()):self.postMessage({type:"yuvData",videoFrame:Oe},[Oe])}}),self.postMessage({type:"ready"})}};Function("var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;return "+h)()(S)}else if(a.data.type==="decode"){const{packet:o}=a.data;p?.decode(o.data,o.type=="key",o.timestamp)}else if(a.data.type==="setCodec"){const{codec:o,format:h,description:y}=a.data;p?.setCodec(o,h,y??"")}}}class Xt extends de{constructor(a,o,h=!1,y,_=!1){super(),this.createModule=a,this.wasmBinary=o,this.workerMode=h,this.canvas=y,this.yuvMode=_,this.module={},this.width=0,this.height=0}async initialize(a){if(this.workerMode){const h=/\{(.+)\}/s.exec(Gi.toString())[1];this.worker=new Worker(URL.createObjectURL(new Blob([h],{type:"text/javascript"})));const y=this.canvas?.transferControlToOffscreen(),_=await this.wasmBinary;return console.warn("worker mode",_),this.worker.postMessage({type:"init",canvas:y,wasmScript:this.createModule.toString(),wasmBinary:_},y?[y,_]:[_]),new Promise(b=>{this.worker.onmessage=D=>{if(D.data.type==="ready")delete this.wasmBinary,b(),console.warn("worker mode initialize success");else if(D.data.type==="yuvData"){const{videoFrame:S}=D.data;this.emit(ft.VideoFrame,S)}}})}const o=this.module;return this.wasmBinary&&(o.wasmBinary=await this.wasmBinary),o.print=h=>console.log(h),o.printErr=h=>console.log(`[JS] ERROR: ${h}`),o.onAbort=()=>console.log("[JS] FATAL: WASM ABORTED"),new Promise(h=>{o.postRun=y=>{this.decoder=new this.module.VideoDecoder(this),h()},a&&Object.assign(o,a),this.createModule(o)})}configure(a){this.config=a;const o=this.config.codec.startsWith("avc")?"avc":"hevc",h=this.config.description?o=="avc"?"avcc":"hvcc":"annexb";this.decoder?.setCodec(o,h,this.config.description??""),this.worker?.postMessage({type:"setCodec",codec:o,format:h,description:this.config.description})}decode(a){this.decoder?.decode(a.data,a.type=="key",a.timestamp),this.state==="configured"&&this.worker?.postMessage({type:"decode",packet:a})}flush(){}reset(){this.config=void 0,this.decoder&&this.decoder.clear()}close(){this.removeAllListeners(),this.decoder&&(this.decoder.clear(),this.decoder.delete())}videoInfo(a,o){this.width=a,this.height=o;let h={width:a,height:o};this.emit(ft.VideoCodecInfo,h)}yuvData(a,o){if(!this.module)return;const h=this.width*this.height,y=h>>2;let _=this.module.HEAPU32[a>>2],b=this.module.HEAPU32[(a>>2)+1],D=this.module.HEAPU32[(a>>2)+2],S=this.module.HEAPU8.subarray(_,_+h),w=this.module.HEAPU8.subarray(b,b+y),C=this.module.HEAPU8.subarray(D,D+y);if(this.yuvMode){this.emit(ft.VideoFrame,{y:S,u:w,v:C,timestamp:o});return}const F=new Uint8Array(h+y+y);F.set(S),F.set(w,h),F.set(C,h+y),this.emit(ft.VideoFrame,new VideoFrame(F,{codedWidth:this.width,codedHeight:this.height,format:"I420",timestamp:o}))}errorInfo(a){let o={errMsg:a};this.emit(ft.Error,o)}}oi([ke([de.INIT,"closed"],"initialized")],Xt.prototype,"initialize",1);oi([ke("initialized","configured",{sync:!0})],Xt.prototype,"configure",1);oi([ke([],de.INIT,{sync:!0})],Xt.prototype,"reset",1);oi([ke([],"closed",{sync:!0})],Xt.prototype,"close",1);var qi=(()=>{var p=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(a={}){var o=a,h,y;o.ready=new Promise((e,r)=>{h=e,y=r});var _=Object.assign({},o),b="./this.program",D=typeof window=="object",S=typeof importScripts=="function";typeof process=="object"&&typeof process.versions=="object"&&process.versions.node;var w="";function C(e){return o.locateFile?o.locateFile(e,w):w+e}var F,H,te;(D||S)&&(S?w=self.location.href:typeof document<"u"&&document.currentScript&&(w=document.currentScript.src),p&&(w=p),w.indexOf("blob:")!==0?w=w.substr(0,w.replace(/[?#].*/,"").lastIndexOf("/")+1):w="",F=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.send(null),r.responseText},S&&(te=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),H=(e,r,t)=>{var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=()=>{if(n.status==200||n.status==0&&n.response){r(n.response);return}t()},n.onerror=t,n.send(null)});var Z=o.print||console.log.bind(console),N=o.printErr||console.error.bind(console);Object.assign(o,_),_=null,o.arguments&&o.arguments,o.thisProgram&&(b=o.thisProgram),o.quit&&o.quit;var B;o.wasmBinary&&(B=o.wasmBinary),o.noExitRuntime,typeof WebAssembly!="object"&&Ue("no native wasm support detected");var ce,X,ie=!1;function Oe(e,r){e||Ue(r)}var ee,K,we,Je,W,z,dr,hr;function Sr(){var e=ce.buffer;o.HEAP8=ee=new Int8Array(e),o.HEAP16=we=new Int16Array(e),o.HEAP32=W=new Int32Array(e),o.HEAPU8=K=new Uint8Array(e),o.HEAPU16=Je=new Uint16Array(e),o.HEAPU32=z=new Uint32Array(e),o.HEAPF32=dr=new Float32Array(e),o.HEAPF64=hr=new Float64Array(e)}var pr,Zr=[],kr=[],vr=[];function Mr(){if(o.preRun)for(typeof o.preRun=="function"&&(o.preRun=[o.preRun]);o.preRun.length;)mr(o.preRun.shift());Ar(Zr)}function xr(){!o.noFSInit&&!i.init.initialized&&i.init(),i.ignorePermissions=!1,Ar(kr)}function He(){if(o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;)be(o.postRun.shift());Ar(vr)}function mr(e){Zr.unshift(e)}function _e(e){kr.unshift(e)}function be(e){vr.unshift(e)}var Pe=0,er=null;function ri(e){return e}function Ke(e){Pe++,o.monitorRunDependencies&&o.monitorRunDependencies(Pe)}function sr(e){if(Pe--,o.monitorRunDependencies&&o.monitorRunDependencies(Pe),Pe==0&&er){var r=er;er=null,r()}}function Ue(e){o.onAbort&&o.onAbort(e),e="Aborted("+e+")",N(e),ie=!0,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw y(r),r}var Ft="data:application/octet-stream;base64,";function ct(e){return e.startsWith(Ft)}var We;We="videodec.wasm",ct(We)||(We=C(We));function Ir(e){if(e==We&&B)return new Uint8Array(B);if(te)return te(e);throw"both async and sync fetching of the wasm failed"}function Kt(e){return!B&&(D||S)&&typeof fetch=="function"?fetch(e,{credentials:"same-origin"}).then(r=>{if(!r.ok)throw"failed to load wasm binary file at '"+e+"'";return r.arrayBuffer()}).catch(()=>Ir(e)):Promise.resolve().then(()=>Ir(e))}function Jr(e,r,t){return Kt(e).then(n=>WebAssembly.instantiate(n,r)).then(n=>n).then(t,n=>{N("failed to asynchronously prepare wasm: "+n),Ue(n)})}function Qt(e,r,t,n){return!e&&typeof WebAssembly.instantiateStreaming=="function"&&!ct(r)&&typeof fetch=="function"?fetch(r,{credentials:"same-origin"}).then(s=>{var u=WebAssembly.instantiateStreaming(s,t);return u.then(n,function(l){return N("wasm streaming compile failed: "+l),N("falling back to ArrayBuffer instantiation"),Jr(r,t,n)})}):Jr(r,t,n)}function Yt(){var e={a:yi};function r(n,s){var u=n.exports;return X=u,ce=X.E,Sr(),pr=X.H,_e(X.F),sr(),u}Ke();function t(n){r(n.instance)}if(o.instantiateWasm)try{return o.instantiateWasm(e,r)}catch(n){N("Module.instantiateWasm callback failed with error: "+n),y(n)}return Qt(B,We,e,t).catch(y),{}}var U,Q,Ar=e=>{for(;e.length>0;)e.shift()(o)};function Me(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(r){z[this.ptr+4>>2]=r},this.get_type=function(){return z[this.ptr+4>>2]},this.set_destructor=function(r){z[this.ptr+8>>2]=r},this.get_destructor=function(){return z[this.ptr+8>>2]},this.set_caught=function(r){r=r?1:0,ee[this.ptr+12>>0]=r},this.get_caught=function(){return ee[this.ptr+12>>0]!=0},this.set_rethrown=function(r){r=r?1:0,ee[this.ptr+13>>0]=r},this.get_rethrown=function(){return ee[this.ptr+13>>0]!=0},this.init=function(r,t){this.set_adjusted_ptr(0),this.set_type(r),this.set_destructor(t)},this.set_adjusted_ptr=function(r){z[this.ptr+16>>2]=r},this.get_adjusted_ptr=function(){return z[this.ptr+16>>2]},this.get_exception_ptr=function(){var r=Ln(this.get_type());if(r)return z[this.excPtr>>2];var t=this.get_adjusted_ptr();return t!==0?t:this.excPtr}}var ar=0;function gr(e,r,t){var n=new Me(e);throw n.init(r,t),ar=e,ar}var et=e=>(W[In()>>2]=e,e),q={isAbs:e=>e.charAt(0)==="/",splitPath:e=>{var r=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return r.exec(e).slice(1)},normalizeArray:(e,r)=>{for(var t=0,n=e.length-1;n>=0;n--){var s=e[n];s==="."?e.splice(n,1):s===".."?(e.splice(n,1),t++):t&&(e.splice(n,1),t--)}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=q.isAbs(e),t=e.substr(-1)==="/";return e=q.normalizeArray(e.split("/").filter(n=>!!n),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=q.splitPath(e),t=r[0],n=r[1];return!t&&!n?".":(n&&(n=n.substr(0,n.length-1)),t+n)},basename:e=>{if(e==="/")return"/";e=q.normalize(e),e=e.replace(/\/$/,"");var r=e.lastIndexOf("/");return r===-1?e:e.substr(r+1)},join:function(){var e=Array.prototype.slice.call(arguments);return q.normalize(e.join("/"))},join2:(e,r)=>q.normalize(e+"/"+r)},le=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return e=>crypto.getRandomValues(e);Ue("initRandomDevice")},rt=e=>(rt=le())(e),ye={resolve:function(){for(var e="",r=!1,t=arguments.length-1;t>=-1&&!r;t--){var n=t>=0?arguments[t]:i.cwd();if(typeof n!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!n)return"";e=n+"/"+e,r=q.isAbs(n)}return e=q.normalizeArray(e.split("/").filter(s=>!!s),!r).join("/"),(r?"/":"")+e||"."},relative:(e,r)=>{e=ye.resolve(e).substr(1),r=ye.resolve(r).substr(1);function t(m){for(var $=0;$<m.length&&m[$]==="";$++);for(var k=m.length-1;k>=0&&m[k]==="";k--);return $>k?[]:m.slice($,k-$+1)}for(var n=t(e.split("/")),s=t(r.split("/")),u=Math.min(n.length,s.length),l=u,f=0;f<u;f++)if(n[f]!==s[f]){l=f;break}for(var g=[],f=l;f<n.length;f++)g.push("..");return g=g.concat(s.slice(l)),g.join("/")}},yr=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,ze=(e,r,t)=>{for(var n=r+t,s=r;e[s]&&!(s>=n);)++s;if(s-r>16&&e.buffer&&yr)return yr.decode(e.subarray(r,s));for(var u="";r<s;){var l=e[r++];if(!(l&128)){u+=String.fromCharCode(l);continue}var f=e[r++]&63;if((l&224)==192){u+=String.fromCharCode((l&31)<<6|f);continue}var g=e[r++]&63;if((l&240)==224?l=(l&15)<<12|f<<6|g:l=(l&7)<<18|f<<12|g<<6|e[r++]&63,l<65536)u+=String.fromCharCode(l);else{var m=l-65536;u+=String.fromCharCode(55296|m>>10,56320|m&1023)}}return u},xe=[],jr=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n<=127?r++:n<=2047?r+=2:n>=55296&&n<=57343?(r+=4,++t):r+=3}return r},Lr=(e,r,t,n)=>{if(!(n>0))return 0;for(var s=t,u=t+n-1,l=0;l<e.length;++l){var f=e.charCodeAt(l);if(f>=55296&&f<=57343){var g=e.charCodeAt(++l);f=65536+((f&1023)<<10)|g&1023}if(f<=127){if(t>=u)break;r[t++]=f}else if(f<=2047){if(t+1>=u)break;r[t++]=192|f>>6,r[t++]=128|f&63}else if(f<=65535){if(t+2>=u)break;r[t++]=224|f>>12,r[t++]=128|f>>6&63,r[t++]=128|f&63}else{if(t+3>=u)break;r[t++]=240|f>>18,r[t++]=128|f>>12&63,r[t++]=128|f>>6&63,r[t++]=128|f&63}}return r[t]=0,t-s};function Br(e,r,t){var n=t>0?t:jr(e)+1,s=new Array(n),u=Lr(e,s,0,s.length);return r&&(s.length=u),s}var dt=()=>{if(!xe.length){var e=null;if(typeof window<"u"&&typeof window.prompt=="function"?(e=window.prompt("Input: "),e!==null&&(e+=`
  2. `)):typeof readline=="function"&&(e=readline(),e!==null&&(e+=`
  3. `)),!e)return null;xe=Br(e,!0)}return xe.shift()},Ae={ttys:[],init:function(){},shutdown:function(){},register:function(e,r){Ae.ttys[e]={input:[],output:[],ops:r},i.registerDevice(e,Ae.stream_ops)},stream_ops:{open:function(e){var r=Ae.ttys[e.node.rdev];if(!r)throw new i.ErrnoError(43);e.tty=r,e.seekable=!1},close:function(e){e.tty.ops.fsync(e.tty)},fsync:function(e){e.tty.ops.fsync(e.tty)},read:function(e,r,t,n,s){if(!e.tty||!e.tty.ops.get_char)throw new i.ErrnoError(60);for(var u=0,l=0;l<n;l++){var f;try{f=e.tty.ops.get_char(e.tty)}catch{throw new i.ErrnoError(29)}if(f===void 0&&u===0)throw new i.ErrnoError(6);if(f==null)break;u++,r[t+l]=f}return u&&(e.node.timestamp=Date.now()),u},write:function(e,r,t,n,s){if(!e.tty||!e.tty.ops.put_char)throw new i.ErrnoError(60);try{for(var u=0;u<n;u++)e.tty.ops.put_char(e.tty,r[t+u])}catch{throw new i.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),u}},default_tty_ops:{get_char:function(e){return dt()},put_char:function(e,r){r===null||r===10?(Z(ze(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},fsync:function(e){e.output&&e.output.length>0&&(Z(ze(e.output,0)),e.output=[])},ioctl_tcgets:function(e){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets:function(e,r,t){return 0},ioctl_tiocgwinsz:function(e){return[24,80]}},default_tty1_ops:{put_char:function(e,r){r===null||r===10?(N(ze(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},fsync:function(e){e.output&&e.output.length>0&&(N(ze(e.output,0)),e.output=[])}}},tt=e=>{Ue()},L={ops_table:null,mount(e){return L.createNode(null,"/",16895,0)},createNode(e,r,t,n){if(i.isBlkdev(t)||i.isFIFO(t))throw new i.ErrnoError(63);L.ops_table||(L.ops_table={dir:{node:{getattr:L.node_ops.getattr,setattr:L.node_ops.setattr,lookup:L.node_ops.lookup,mknod:L.node_ops.mknod,rename:L.node_ops.rename,unlink:L.node_ops.unlink,rmdir:L.node_ops.rmdir,readdir:L.node_ops.readdir,symlink:L.node_ops.symlink},stream:{llseek:L.stream_ops.llseek}},file:{node:{getattr:L.node_ops.getattr,setattr:L.node_ops.setattr},stream:{llseek:L.stream_ops.llseek,read:L.stream_ops.read,write:L.stream_ops.write,allocate:L.stream_ops.allocate,mmap:L.stream_ops.mmap,msync:L.stream_ops.msync}},link:{node:{getattr:L.node_ops.getattr,setattr:L.node_ops.setattr,readlink:L.node_ops.readlink},stream:{}},chrdev:{node:{getattr:L.node_ops.getattr,setattr:L.node_ops.setattr},stream:i.chrdev_stream_ops}});var s=i.createNode(e,r,t,n);return i.isDir(s.mode)?(s.node_ops=L.ops_table.dir.node,s.stream_ops=L.ops_table.dir.stream,s.contents={}):i.isFile(s.mode)?(s.node_ops=L.ops_table.file.node,s.stream_ops=L.ops_table.file.stream,s.usedBytes=0,s.contents=null):i.isLink(s.mode)?(s.node_ops=L.ops_table.link.node,s.stream_ops=L.ops_table.link.stream):i.isChrdev(s.mode)&&(s.node_ops=L.ops_table.chrdev.node,s.stream_ops=L.ops_table.chrdev.stream),s.timestamp=Date.now(),e&&(e.contents[r]=s,e.timestamp=s.timestamp),s},getFileDataAsTypedArray(e){return e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0)},expandFileStorage(e,r){var t=e.contents?e.contents.length:0;if(!(t>=r)){var n=1024*1024;r=Math.max(r,t*(t<n?2:1.125)>>>0),t!=0&&(r=Math.max(r,256));var s=e.contents;e.contents=new Uint8Array(r),e.usedBytes>0&&e.contents.set(s.subarray(0,e.usedBytes),0)}},resizeFileStorage(e,r){if(e.usedBytes!=r)if(r==0)e.contents=null,e.usedBytes=0;else{var t=e.contents;e.contents=new Uint8Array(r),t&&e.contents.set(t.subarray(0,Math.min(r,e.usedBytes))),e.usedBytes=r}},node_ops:{getattr(e){var r={};return r.dev=i.isChrdev(e.mode)?e.id:1,r.ino=e.id,r.mode=e.mode,r.nlink=1,r.uid=0,r.gid=0,r.rdev=e.rdev,i.isDir(e.mode)?r.size=4096:i.isFile(e.mode)?r.size=e.usedBytes:i.isLink(e.mode)?r.size=e.link.length:r.size=0,r.atime=new Date(e.timestamp),r.mtime=new Date(e.timestamp),r.ctime=new Date(e.timestamp),r.blksize=4096,r.blocks=Math.ceil(r.size/r.blksize),r},setattr(e,r){r.mode!==void 0&&(e.mode=r.mode),r.timestamp!==void 0&&(e.timestamp=r.timestamp),r.size!==void 0&&L.resizeFileStorage(e,r.size)},lookup(e,r){throw i.genericErrors[44]},mknod(e,r,t,n){return L.createNode(e,r,t,n)},rename(e,r,t){if(i.isDir(e.mode)){var n;try{n=i.lookupNode(r,t)}catch{}if(n)for(var s in n.contents)throw new i.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=t,r.contents[t]=e,r.timestamp=e.parent.timestamp,e.parent=r},unlink(e,r){delete e.contents[r],e.timestamp=Date.now()},rmdir(e,r){var t=i.lookupNode(e,r);for(var n in t.contents)throw new i.ErrnoError(55);delete e.contents[r],e.timestamp=Date.now()},readdir(e){var r=[".",".."];for(var t in e.contents)e.contents.hasOwnProperty(t)&&r.push(t);return r},symlink(e,r,t){var n=L.createNode(e,r,41471,0);return n.link=t,n},readlink(e){if(!i.isLink(e.mode))throw new i.ErrnoError(28);return e.link}},stream_ops:{read(e,r,t,n,s){var u=e.node.contents;if(s>=e.node.usedBytes)return 0;var l=Math.min(e.node.usedBytes-s,n);if(l>8&&u.subarray)r.set(u.subarray(s,s+l),t);else for(var f=0;f<l;f++)r[t+f]=u[s+f];return l},write(e,r,t,n,s,u){if(!n)return 0;var l=e.node;if(l.timestamp=Date.now(),r.subarray&&(!l.contents||l.contents.subarray)){if(u)return l.contents=r.subarray(t,t+n),l.usedBytes=n,n;if(l.usedBytes===0&&s===0)return l.contents=r.slice(t,t+n),l.usedBytes=n,n;if(s+n<=l.usedBytes)return l.contents.set(r.subarray(t,t+n),s),n}if(L.expandFileStorage(l,s+n),l.contents.subarray&&r.subarray)l.contents.set(r.subarray(t,t+n),s);else for(var f=0;f<n;f++)l.contents[s+f]=r[t+f];return l.usedBytes=Math.max(l.usedBytes,s+n),n},llseek(e,r,t){var n=r;if(t===1?n+=e.position:t===2&&i.isFile(e.node.mode)&&(n+=e.node.usedBytes),n<0)throw new i.ErrnoError(28);return n},allocate(e,r,t){L.expandFileStorage(e.node,r+t),e.node.usedBytes=Math.max(e.node.usedBytes,r+t)},mmap(e,r,t,n,s){if(!i.isFile(e.node.mode))throw new i.ErrnoError(43);var u,l,f=e.node.contents;if(!(s&2)&&f.buffer===ee.buffer)l=!1,u=f.byteOffset;else{if((t>0||t+r<f.length)&&(f.subarray?f=f.subarray(t,t+r):f=Array.prototype.slice.call(f,t,t+r)),l=!0,u=tt(),!u)throw new i.ErrnoError(48);ee.set(f,u)}return{ptr:u,allocated:l}},msync(e,r,t,n,s){return L.stream_ops.write(e,r,0,n,t,!1),0}}},Dt=(e,r,t,n)=>{var s=n?"":`al ${e}`;H(e,u=>{Oe(u,`Loading data file "${e}" failed (no arrayBuffer).`),r(new Uint8Array(u)),s&&sr()},u=>{if(t)t();else throw`Loading data file "${e}" failed.`}),s&&Ke()},Rt=o.preloadPlugins||[];function Ot(e,r,t,n){typeof Browser<"u"&&Browser.init();var s=!1;return Rt.forEach(function(u){s||u.canHandle(r)&&(u.handle(e,r,t,n),s=!0)}),s}function Zt(e,r,t,n,s,u,l,f,g,m){var $=r?ye.resolve(q.join2(e,r)):e;function k(T){function P(x){m&&m(),f||i.createDataFile(e,r,x,n,s,g),u&&u(),sr()}Ot(T,$,P,()=>{l&&l(),sr()})||P(T)}Ke(),typeof t=="string"?Dt(t,T=>k(T),l):k(t)}function Jt(e){var r={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},t=r[e];if(typeof t>"u")throw new Error(`Unknown file open mode: ${e}`);return t}function rr(e,r){var t=0;return e&&(t|=365),r&&(t|=146),t}var i={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath:(e,r={})=>{if(e=ye.resolve(e),!e)return{path:"",node:null};var t={follow_mount:!0,recurse_count:0};if(r=Object.assign(t,r),r.recurse_count>8)throw new i.ErrnoError(32);for(var n=e.split("/").filter(k=>!!k),s=i.root,u="/",l=0;l<n.length;l++){var f=l===n.length-1;if(f&&r.parent)break;if(s=i.lookupNode(s,n[l]),u=q.join2(u,n[l]),i.isMountpoint(s)&&(!f||f&&r.follow_mount)&&(s=s.mounted.root),!f||r.follow)for(var g=0;i.isLink(s.mode);){var m=i.readlink(u);u=ye.resolve(q.dirname(u),m);var $=i.lookupPath(u,{recurse_count:r.recurse_count+1});if(s=$.node,g++>40)throw new i.ErrnoError(32)}}return{path:u,node:s}},getPath:e=>{for(var r;;){if(i.isRoot(e)){var t=e.mount.mountpoint;return r?t[t.length-1]!=="/"?`${t}/${r}`:t+r:t}r=r?`${e.name}/${r}`:e.name,e=e.parent}},hashName:(e,r)=>{for(var t=0,n=0;n<r.length;n++)t=(t<<5)-t+r.charCodeAt(n)|0;return(e+t>>>0)%i.nameTable.length},hashAddNode:e=>{var r=i.hashName(e.parent.id,e.name);e.name_next=i.nameTable[r],i.nameTable[r]=e},hashRemoveNode:e=>{var r=i.hashName(e.parent.id,e.name);if(i.nameTable[r]===e)i.nameTable[r]=e.name_next;else for(var t=i.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next}},lookupNode:(e,r)=>{var t=i.mayLookup(e);if(t)throw new i.ErrnoError(t,e);for(var n=i.hashName(e.id,r),s=i.nameTable[n];s;s=s.name_next){var u=s.name;if(s.parent.id===e.id&&u===r)return s}return i.lookup(e,r)},createNode:(e,r,t,n)=>{var s=new i.FSNode(e,r,t,n);return i.hashAddNode(s),s},destroyNode:e=>{i.hashRemoveNode(e)},isRoot:e=>e===e.parent,isMountpoint:e=>!!e.mounted,isFile:e=>(e&61440)===32768,isDir:e=>(e&61440)===16384,isLink:e=>(e&61440)===40960,isChrdev:e=>(e&61440)===8192,isBlkdev:e=>(e&61440)===24576,isFIFO:e=>(e&61440)===4096,isSocket:e=>(e&49152)===49152,flagsToPermissionString:e=>{var r=["r","w","rw"][e&3];return e&512&&(r+="w"),r},nodePermissions:(e,r)=>i.ignorePermissions?0:r.includes("r")&&!(e.mode&292)||r.includes("w")&&!(e.mode&146)||r.includes("x")&&!(e.mode&73)?2:0,mayLookup:e=>{var r=i.nodePermissions(e,"x");return r||(e.node_ops.lookup?0:2)},mayCreate:(e,r)=>{try{var t=i.lookupNode(e,r);return 20}catch{}return i.nodePermissions(e,"wx")},mayDelete:(e,r,t)=>{var n;try{n=i.lookupNode(e,r)}catch(u){return u.errno}var s=i.nodePermissions(e,"wx");if(s)return s;if(t){if(!i.isDir(n.mode))return 54;if(i.isRoot(n)||i.getPath(n)===i.cwd())return 10}else if(i.isDir(n.mode))return 31;return 0},mayOpen:(e,r)=>e?i.isLink(e.mode)?32:i.isDir(e.mode)&&(i.flagsToPermissionString(r)!=="r"||r&512)?31:i.nodePermissions(e,i.flagsToPermissionString(r)):44,MAX_OPEN_FDS:4096,nextfd:()=>{for(var e=0;e<=i.MAX_OPEN_FDS;e++)if(!i.streams[e])return e;throw new i.ErrnoError(33)},getStreamChecked:e=>{var r=i.getStream(e);if(!r)throw new i.ErrnoError(8);return r},getStream:e=>i.streams[e],createStream:(e,r=-1)=>(i.FSStream||(i.FSStream=function(){this.shared={}},i.FSStream.prototype={},Object.defineProperties(i.FSStream.prototype,{object:{get(){return this.node},set(t){this.node=t}},isRead:{get(){return(this.flags&2097155)!==1}},isWrite:{get(){return(this.flags&2097155)!==0}},isAppend:{get(){return this.flags&1024}},flags:{get(){return this.shared.flags},set(t){this.shared.flags=t}},position:{get(){return this.shared.position},set(t){this.shared.position=t}}})),e=Object.assign(new i.FSStream,e),r==-1&&(r=i.nextfd()),e.fd=r,i.streams[r]=e,e),closeStream:e=>{i.streams[e]=null},chrdev_stream_ops:{open:e=>{var r=i.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:()=>{throw new i.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,r)=>e<<8|r,registerDevice:(e,r)=>{i.devices[e]={stream_ops:r}},getDevice:e=>i.devices[e],getMounts:e=>{for(var r=[],t=[e];t.length;){var n=t.pop();r.push(n),t.push.apply(t,n.mounts)}return r},syncfs:(e,r)=>{typeof e=="function"&&(r=e,e=!1),i.syncFSRequests++,i.syncFSRequests>1&&N(`warning: ${i.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var t=i.getMounts(i.root.mount),n=0;function s(l){return i.syncFSRequests--,r(l)}function u(l){if(l)return u.errored?void 0:(u.errored=!0,s(l));++n>=t.length&&s(null)}t.forEach(l=>{if(!l.type.syncfs)return u(null);l.type.syncfs(l,e,u)})},mount:(e,r,t)=>{var n=t==="/",s=!t,u;if(n&&i.root)throw new i.ErrnoError(10);if(!n&&!s){var l=i.lookupPath(t,{follow_mount:!1});if(t=l.path,u=l.node,i.isMountpoint(u))throw new i.ErrnoError(10);if(!i.isDir(u.mode))throw new i.ErrnoError(54)}var f={type:e,opts:r,mountpoint:t,mounts:[]},g=e.mount(f);return g.mount=f,f.root=g,n?i.root=g:u&&(u.mounted=f,u.mount&&u.mount.mounts.push(f)),g},unmount:e=>{var r=i.lookupPath(e,{follow_mount:!1});if(!i.isMountpoint(r.node))throw new i.ErrnoError(28);var t=r.node,n=t.mounted,s=i.getMounts(n);Object.keys(i.nameTable).forEach(l=>{for(var f=i.nameTable[l];f;){var g=f.name_next;s.includes(f.mount)&&i.destroyNode(f),f=g}}),t.mounted=null;var u=t.mount.mounts.indexOf(n);t.mount.mounts.splice(u,1)},lookup:(e,r)=>e.node_ops.lookup(e,r),mknod:(e,r,t)=>{var n=i.lookupPath(e,{parent:!0}),s=n.node,u=q.basename(e);if(!u||u==="."||u==="..")throw new i.ErrnoError(28);var l=i.mayCreate(s,u);if(l)throw new i.ErrnoError(l);if(!s.node_ops.mknod)throw new i.ErrnoError(63);return s.node_ops.mknod(s,u,r,t)},create:(e,r)=>(r=r!==void 0?r:438,r&=4095,r|=32768,i.mknod(e,r,0)),mkdir:(e,r)=>(r=r!==void 0?r:511,r&=1023,r|=16384,i.mknod(e,r,0)),mkdirTree:(e,r)=>{for(var t=e.split("/"),n="",s=0;s<t.length;++s)if(t[s]){n+="/"+t[s];try{i.mkdir(n,r)}catch(u){if(u.errno!=20)throw u}}},mkdev:(e,r,t)=>(typeof t>"u"&&(t=r,r=438),r|=8192,i.mknod(e,r,t)),symlink:(e,r)=>{if(!ye.resolve(e))throw new i.ErrnoError(44);var t=i.lookupPath(r,{parent:!0}),n=t.node;if(!n)throw new i.ErrnoError(44);var s=q.basename(r),u=i.mayCreate(n,s);if(u)throw new i.ErrnoError(u);if(!n.node_ops.symlink)throw new i.ErrnoError(63);return n.node_ops.symlink(n,s,e)},rename:(e,r)=>{var t=q.dirname(e),n=q.dirname(r),s=q.basename(e),u=q.basename(r),l,f,g;if(l=i.lookupPath(e,{parent:!0}),f=l.node,l=i.lookupPath(r,{parent:!0}),g=l.node,!f||!g)throw new i.ErrnoError(44);if(f.mount!==g.mount)throw new i.ErrnoError(75);var m=i.lookupNode(f,s),$=ye.relative(e,n);if($.charAt(0)!==".")throw new i.ErrnoError(28);if($=ye.relative(r,t),$.charAt(0)!==".")throw new i.ErrnoError(55);var k;try{k=i.lookupNode(g,u)}catch{}if(m!==k){var T=i.isDir(m.mode),P=i.mayDelete(f,s,T);if(P)throw new i.ErrnoError(P);if(P=k?i.mayDelete(g,u,T):i.mayCreate(g,u),P)throw new i.ErrnoError(P);if(!f.node_ops.rename)throw new i.ErrnoError(63);if(i.isMountpoint(m)||k&&i.isMountpoint(k))throw new i.ErrnoError(10);if(g!==f&&(P=i.nodePermissions(f,"w"),P))throw new i.ErrnoError(P);i.hashRemoveNode(m);try{f.node_ops.rename(m,g,u)}catch(x){throw x}finally{i.hashAddNode(m)}}},rmdir:e=>{var r=i.lookupPath(e,{parent:!0}),t=r.node,n=q.basename(e),s=i.lookupNode(t,n),u=i.mayDelete(t,n,!0);if(u)throw new i.ErrnoError(u);if(!t.node_ops.rmdir)throw new i.ErrnoError(63);if(i.isMountpoint(s))throw new i.ErrnoError(10);t.node_ops.rmdir(t,n),i.destroyNode(s)},readdir:e=>{var r=i.lookupPath(e,{follow:!0}),t=r.node;if(!t.node_ops.readdir)throw new i.ErrnoError(54);return t.node_ops.readdir(t)},unlink:e=>{var r=i.lookupPath(e,{parent:!0}),t=r.node;if(!t)throw new i.ErrnoError(44);var n=q.basename(e),s=i.lookupNode(t,n),u=i.mayDelete(t,n,!1);if(u)throw new i.ErrnoError(u);if(!t.node_ops.unlink)throw new i.ErrnoError(63);if(i.isMountpoint(s))throw new i.ErrnoError(10);t.node_ops.unlink(t,n),i.destroyNode(s)},readlink:e=>{var r=i.lookupPath(e),t=r.node;if(!t)throw new i.ErrnoError(44);if(!t.node_ops.readlink)throw new i.ErrnoError(28);return ye.resolve(i.getPath(t.parent),t.node_ops.readlink(t))},stat:(e,r)=>{var t=i.lookupPath(e,{follow:!r}),n=t.node;if(!n)throw new i.ErrnoError(44);if(!n.node_ops.getattr)throw new i.ErrnoError(63);return n.node_ops.getattr(n)},lstat:e=>i.stat(e,!0),chmod:(e,r,t)=>{var n;if(typeof e=="string"){var s=i.lookupPath(e,{follow:!t});n=s.node}else n=e;if(!n.node_ops.setattr)throw new i.ErrnoError(63);n.node_ops.setattr(n,{mode:r&4095|n.mode&-4096,timestamp:Date.now()})},lchmod:(e,r)=>{i.chmod(e,r,!0)},fchmod:(e,r)=>{var t=i.getStreamChecked(e);i.chmod(t.node,r)},chown:(e,r,t,n)=>{var s;if(typeof e=="string"){var u=i.lookupPath(e,{follow:!n});s=u.node}else s=e;if(!s.node_ops.setattr)throw new i.ErrnoError(63);s.node_ops.setattr(s,{timestamp:Date.now()})},lchown:(e,r,t)=>{i.chown(e,r,t,!0)},fchown:(e,r,t)=>{var n=i.getStreamChecked(e);i.chown(n.node,r,t)},truncate:(e,r)=>{if(r<0)throw new i.ErrnoError(28);var t;if(typeof e=="string"){var n=i.lookupPath(e,{follow:!0});t=n.node}else t=e;if(!t.node_ops.setattr)throw new i.ErrnoError(63);if(i.isDir(t.mode))throw new i.ErrnoError(31);if(!i.isFile(t.mode))throw new i.ErrnoError(28);var s=i.nodePermissions(t,"w");if(s)throw new i.ErrnoError(s);t.node_ops.setattr(t,{size:r,timestamp:Date.now()})},ftruncate:(e,r)=>{var t=i.getStreamChecked(e);if(!(t.flags&2097155))throw new i.ErrnoError(28);i.truncate(t.node,r)},utime:(e,r,t)=>{var n=i.lookupPath(e,{follow:!0}),s=n.node;s.node_ops.setattr(s,{timestamp:Math.max(r,t)})},open:(e,r,t)=>{if(e==="")throw new i.ErrnoError(44);r=typeof r=="string"?Jt(r):r,t=typeof t>"u"?438:t,r&64?t=t&4095|32768:t=0;var n;if(typeof e=="object")n=e;else{e=q.normalize(e);try{var s=i.lookupPath(e,{follow:!(r&131072)});n=s.node}catch{}}var u=!1;if(r&64)if(n){if(r&128)throw new i.ErrnoError(20)}else n=i.mknod(e,t,0),u=!0;if(!n)throw new i.ErrnoError(44);if(i.isChrdev(n.mode)&&(r&=-513),r&65536&&!i.isDir(n.mode))throw new i.ErrnoError(54);if(!u){var l=i.mayOpen(n,r);if(l)throw new i.ErrnoError(l)}r&512&&!u&&i.truncate(n,0),r&=-131713;var f=i.createStream({node:n,path:i.getPath(n),flags:r,seekable:!0,position:0,stream_ops:n.stream_ops,ungotten:[],error:!1});return f.stream_ops.open&&f.stream_ops.open(f),o.logReadFiles&&!(r&1)&&(i.readFiles||(i.readFiles={}),e in i.readFiles||(i.readFiles[e]=1)),f},close:e=>{if(i.isClosed(e))throw new i.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(r){throw r}finally{i.closeStream(e.fd)}e.fd=null},isClosed:e=>e.fd===null,llseek:(e,r,t)=>{if(i.isClosed(e))throw new i.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new i.ErrnoError(70);if(t!=0&&t!=1&&t!=2)throw new i.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read:(e,r,t,n,s)=>{if(n<0||s<0)throw new i.ErrnoError(28);if(i.isClosed(e))throw new i.ErrnoError(8);if((e.flags&2097155)===1)throw new i.ErrnoError(8);if(i.isDir(e.node.mode))throw new i.ErrnoError(31);if(!e.stream_ops.read)throw new i.ErrnoError(28);var u=typeof s<"u";if(!u)s=e.position;else if(!e.seekable)throw new i.ErrnoError(70);var l=e.stream_ops.read(e,r,t,n,s);return u||(e.position+=l),l},write:(e,r,t,n,s,u)=>{if(n<0||s<0)throw new i.ErrnoError(28);if(i.isClosed(e))throw new i.ErrnoError(8);if(!(e.flags&2097155))throw new i.ErrnoError(8);if(i.isDir(e.node.mode))throw new i.ErrnoError(31);if(!e.stream_ops.write)throw new i.ErrnoError(28);e.seekable&&e.flags&1024&&i.llseek(e,0,2);var l=typeof s<"u";if(!l)s=e.position;else if(!e.seekable)throw new i.ErrnoError(70);var f=e.stream_ops.write(e,r,t,n,s,u);return l||(e.position+=f),f},allocate:(e,r,t)=>{if(i.isClosed(e))throw new i.ErrnoError(8);if(r<0||t<=0)throw new i.ErrnoError(28);if(!(e.flags&2097155))throw new i.ErrnoError(8);if(!i.isFile(e.node.mode)&&!i.isDir(e.node.mode))throw new i.ErrnoError(43);if(!e.stream_ops.allocate)throw new i.ErrnoError(138);e.stream_ops.allocate(e,r,t)},mmap:(e,r,t,n,s)=>{if(n&2&&!(s&2)&&(e.flags&2097155)!==2)throw new i.ErrnoError(2);if((e.flags&2097155)===1)throw new i.ErrnoError(2);if(!e.stream_ops.mmap)throw new i.ErrnoError(43);return e.stream_ops.mmap(e,r,t,n,s)},msync:(e,r,t,n,s)=>e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,s):0,munmap:e=>0,ioctl:(e,r,t)=>{if(!e.stream_ops.ioctl)throw new i.ErrnoError(59);return e.stream_ops.ioctl(e,r,t)},readFile:(e,r={})=>{if(r.flags=r.flags||0,r.encoding=r.encoding||"binary",r.encoding!=="utf8"&&r.encoding!=="binary")throw new Error(`Invalid encoding type "${r.encoding}"`);var t,n=i.open(e,r.flags),s=i.stat(e),u=s.size,l=new Uint8Array(u);return i.read(n,l,0,u,0),r.encoding==="utf8"?t=ze(l,0):r.encoding==="binary"&&(t=l),i.close(n),t},writeFile:(e,r,t={})=>{t.flags=t.flags||577;var n=i.open(e,t.flags,t.mode);if(typeof r=="string"){var s=new Uint8Array(jr(r)+1),u=Lr(r,s,0,s.length);i.write(n,s,0,u,void 0,t.canOwn)}else if(ArrayBuffer.isView(r))i.write(n,r,0,r.byteLength,void 0,t.canOwn);else throw new Error("Unsupported data type");i.close(n)},cwd:()=>i.currentPath,chdir:e=>{var r=i.lookupPath(e,{follow:!0});if(r.node===null)throw new i.ErrnoError(44);if(!i.isDir(r.node.mode))throw new i.ErrnoError(54);var t=i.nodePermissions(r.node,"x");if(t)throw new i.ErrnoError(t);i.currentPath=r.path},createDefaultDirectories:()=>{i.mkdir("/tmp"),i.mkdir("/home"),i.mkdir("/home/web_user")},createDefaultDevices:()=>{i.mkdir("/dev"),i.registerDevice(i.makedev(1,3),{read:()=>0,write:(n,s,u,l,f)=>l}),i.mkdev("/dev/null",i.makedev(1,3)),Ae.register(i.makedev(5,0),Ae.default_tty_ops),Ae.register(i.makedev(6,0),Ae.default_tty1_ops),i.mkdev("/dev/tty",i.makedev(5,0)),i.mkdev("/dev/tty1",i.makedev(6,0));var e=new Uint8Array(1024),r=0,t=()=>(r===0&&(r=rt(e).byteLength),e[--r]);i.createDevice("/dev","random",t),i.createDevice("/dev","urandom",t),i.mkdir("/dev/shm"),i.mkdir("/dev/shm/tmp")},createSpecialDirectories:()=>{i.mkdir("/proc");var e=i.mkdir("/proc/self");i.mkdir("/proc/self/fd"),i.mount({mount:()=>{var r=i.createNode(e,"fd",16895,73);return r.node_ops={lookup:(t,n)=>{var s=+n,u=i.getStreamChecked(s),l={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>u.path}};return l.parent=l,l}},r}},{},"/proc/self/fd")},createStandardStreams:()=>{o.stdin?i.createDevice("/dev","stdin",o.stdin):i.symlink("/dev/tty","/dev/stdin"),o.stdout?i.createDevice("/dev","stdout",null,o.stdout):i.symlink("/dev/tty","/dev/stdout"),o.stderr?i.createDevice("/dev","stderr",null,o.stderr):i.symlink("/dev/tty1","/dev/stderr"),i.open("/dev/stdin",0),i.open("/dev/stdout",1),i.open("/dev/stderr",1)},ensureErrnoError:()=>{i.ErrnoError||(i.ErrnoError=function(r,t){this.name="ErrnoError",this.node=t,this.setErrno=function(n){this.errno=n},this.setErrno(r),this.message="FS error"},i.ErrnoError.prototype=new Error,i.ErrnoError.prototype.constructor=i.ErrnoError,[44].forEach(e=>{i.genericErrors[e]=new i.ErrnoError(e),i.genericErrors[e].stack="<generic error, no stack>"}))},staticInit:()=>{i.ensureErrnoError(),i.nameTable=new Array(4096),i.mount(L,{},"/"),i.createDefaultDirectories(),i.createDefaultDevices(),i.createSpecialDirectories(),i.filesystems={MEMFS:L}},init:(e,r,t)=>{i.init.initialized=!0,i.ensureErrnoError(),o.stdin=e||o.stdin,o.stdout=r||o.stdout,o.stderr=t||o.stderr,i.createStandardStreams()},quit:()=>{i.init.initialized=!1;for(var e=0;e<i.streams.length;e++){var r=i.streams[e];r&&i.close(r)}},findObject:(e,r)=>{var t=i.analyzePath(e,r);return t.exists?t.object:null},analyzePath:(e,r)=>{try{var t=i.lookupPath(e,{follow:!r});e=t.path}catch{}var n={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var t=i.lookupPath(e,{parent:!0});n.parentExists=!0,n.parentPath=t.path,n.parentObject=t.node,n.name=q.basename(e),t=i.lookupPath(e,{follow:!r}),n.exists=!0,n.path=t.path,n.object=t.node,n.name=t.node.name,n.isRoot=t.path==="/"}catch(s){n.error=s.errno}return n},createPath:(e,r,t,n)=>{e=typeof e=="string"?e:i.getPath(e);for(var s=r.split("/").reverse();s.length;){var u=s.pop();if(u){var l=q.join2(e,u);try{i.mkdir(l)}catch{}e=l}}return l},createFile:(e,r,t,n,s)=>{var u=q.join2(typeof e=="string"?e:i.getPath(e),r),l=rr(n,s);return i.create(u,l)},createDataFile:(e,r,t,n,s,u)=>{var l=r;e&&(e=typeof e=="string"?e:i.getPath(e),l=r?q.join2(e,r):e);var f=rr(n,s),g=i.create(l,f);if(t){if(typeof t=="string"){for(var m=new Array(t.length),$=0,k=t.length;$<k;++$)m[$]=t.charCodeAt($);t=m}i.chmod(g,f|146);var T=i.open(g,577);i.write(T,t,0,t.length,0,u),i.close(T),i.chmod(g,f)}return g},createDevice:(e,r,t,n)=>{var s=q.join2(typeof e=="string"?e:i.getPath(e),r),u=rr(!!t,!!n);i.createDevice.major||(i.createDevice.major=64);var l=i.makedev(i.createDevice.major++,0);return i.registerDevice(l,{open:f=>{f.seekable=!1},close:f=>{n&&n.buffer&&n.buffer.length&&n(10)},read:(f,g,m,$,k)=>{for(var T=0,P=0;P<$;P++){var x;try{x=t()}catch{throw new i.ErrnoError(29)}if(x===void 0&&T===0)throw new i.ErrnoError(6);if(x==null)break;T++,g[m+P]=x}return T&&(f.node.timestamp=Date.now()),T},write:(f,g,m,$,k)=>{for(var T=0;T<$;T++)try{n(g[m+T])}catch{throw new i.ErrnoError(29)}return $&&(f.node.timestamp=Date.now()),T}}),i.mkdev(s,u,l)},forceLoadFile:e=>{if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if(typeof XMLHttpRequest<"u")throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");if(F)try{e.contents=Br(F(e.url),!0),e.usedBytes=e.contents.length}catch{throw new i.ErrnoError(29)}else throw new Error("Cannot load without read() or XMLHttpRequest.")},createLazyFile:(e,r,t,n,s)=>{function u(){this.lengthKnown=!1,this.chunks=[]}if(u.prototype.get=function(P){if(!(P>this.length-1||P<0)){var x=P%this.chunkSize,Y=P/this.chunkSize|0;return this.getter(Y)[x]}},u.prototype.setDataGetter=function(P){this.getter=P},u.prototype.cacheLength=function(){var P=new XMLHttpRequest;if(P.open("HEAD",t,!1),P.send(null),!(P.status>=200&&P.status<300||P.status===304))throw new Error("Couldn't load "+t+". Status: "+P.status);var x=Number(P.getResponseHeader("Content-length")),Y,J=(Y=P.getResponseHeader("Accept-Ranges"))&&Y==="bytes",se=(Y=P.getResponseHeader("Content-Encoding"))&&Y==="gzip",ve=1024*1024;J||(ve=x);var re=(me,De)=>{if(me>De)throw new Error("invalid range ("+me+", "+De+") or no bytes requested!");if(De>x-1)throw new Error("only "+x+" bytes available! programmer error!");var ae=new XMLHttpRequest;if(ae.open("GET",t,!1),x!==ve&&ae.setRequestHeader("Range","bytes="+me+"-"+De),ae.responseType="arraybuffer",ae.overrideMimeType&&ae.overrideMimeType("text/plain; charset=x-user-defined"),ae.send(null),!(ae.status>=200&&ae.status<300||ae.status===304))throw new Error("Couldn't load "+t+". Status: "+ae.status);return ae.response!==void 0?new Uint8Array(ae.response||[]):Br(ae.responseText||"",!0)},qe=this;qe.setDataGetter(me=>{var De=me*ve,ae=(me+1)*ve-1;if(ae=Math.min(ae,x-1),typeof qe.chunks[me]>"u"&&(qe.chunks[me]=re(De,ae)),typeof qe.chunks[me]>"u")throw new Error("doXHR failed!");return qe.chunks[me]}),(se||!x)&&(ve=x=1,x=this.getter(0).length,ve=x,Z("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=x,this._chunkSize=ve,this.lengthKnown=!0},typeof XMLHttpRequest<"u"){if(!S)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var l=new u;Object.defineProperties(l,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var f={isDevice:!1,contents:l}}else var f={isDevice:!1,url:t};var g=i.createFile(e,r,f,n,s);f.contents?g.contents=f.contents:f.url&&(g.contents=null,g.url=f.url),Object.defineProperties(g,{usedBytes:{get:function(){return this.contents.length}}});var m={},$=Object.keys(g.stream_ops);$.forEach(T=>{var P=g.stream_ops[T];m[T]=function(){return i.forceLoadFile(g),P.apply(null,arguments)}});function k(T,P,x,Y,J){var se=T.node.contents;if(J>=se.length)return 0;var ve=Math.min(se.length-J,Y);if(se.slice)for(var re=0;re<ve;re++)P[x+re]=se[J+re];else for(var re=0;re<ve;re++)P[x+re]=se.get(J+re);return ve}return m.read=(T,P,x,Y,J)=>(i.forceLoadFile(g),k(T,P,x,Y,J)),m.mmap=(T,P,x,Y,J)=>{i.forceLoadFile(g);var se=tt();if(!se)throw new i.ErrnoError(48);return k(T,ee,se,P,x),{ptr:se,allocated:!0}},g.stream_ops=m,g}},wr=(e,r)=>e?ze(K,e,r):"",ue={DEFAULT_POLLMASK:5,calculateAt:function(e,r,t){if(q.isAbs(r))return r;var n;if(e===-100)n=i.cwd();else{var s=ue.getStreamFromFD(e);n=s.path}if(r.length==0){if(!t)throw new i.ErrnoError(44);return n}return q.join2(n,r)},doStat:function(e,r,t){try{var n=e(r)}catch(f){if(f&&f.node&&q.normalize(r)!==q.normalize(i.getPath(f.node)))return-54;throw f}W[t>>2]=n.dev,W[t+4>>2]=n.mode,z[t+8>>2]=n.nlink,W[t+12>>2]=n.uid,W[t+16>>2]=n.gid,W[t+20>>2]=n.rdev,Q=[n.size>>>0,(U=n.size,+Math.abs(U)>=1?U>0?+Math.floor(U/4294967296)>>>0:~~+Math.ceil((U-+(~~U>>>0))/4294967296)>>>0:0)],W[t+24>>2]=Q[0],W[t+28>>2]=Q[1],W[t+32>>2]=4096,W[t+36>>2]=n.blocks;var s=n.atime.getTime(),u=n.mtime.getTime(),l=n.ctime.getTime();return Q=[Math.floor(s/1e3)>>>0,(U=Math.floor(s/1e3),+Math.abs(U)>=1?U>0?+Math.floor(U/4294967296)>>>0:~~+Math.ceil((U-+(~~U>>>0))/4294967296)>>>0:0)],W[t+40>>2]=Q[0],W[t+44>>2]=Q[1],z[t+48>>2]=s%1e3*1e3,Q=[Math.floor(u/1e3)>>>0,(U=Math.floor(u/1e3),+Math.abs(U)>=1?U>0?+Math.floor(U/4294967296)>>>0:~~+Math.ceil((U-+(~~U>>>0))/4294967296)>>>0:0)],W[t+56>>2]=Q[0],W[t+60>>2]=Q[1],z[t+64>>2]=u%1e3*1e3,Q=[Math.floor(l/1e3)>>>0,(U=Math.floor(l/1e3),+Math.abs(U)>=1?U>0?+Math.floor(U/4294967296)>>>0:~~+Math.ceil((U-+(~~U>>>0))/4294967296)>>>0:0)],W[t+72>>2]=Q[0],W[t+76>>2]=Q[1],z[t+80>>2]=l%1e3*1e3,Q=[n.ino>>>0,(U=n.ino,+Math.abs(U)>=1?U>0?+Math.floor(U/4294967296)>>>0:~~+Math.ceil((U-+(~~U>>>0))/4294967296)>>>0:0)],W[t+88>>2]=Q[0],W[t+92>>2]=Q[1],0},doMsync:function(e,r,t,n,s){if(!i.isFile(r.node.mode))throw new i.ErrnoError(43);if(n&2)return 0;var u=K.slice(e,e+t);i.msync(r,u,s,t,n)},varargs:void 0,get(){ue.varargs+=4;var e=W[ue.varargs-4>>2];return e},getStr(e){var r=wr(e);return r},getStreamFromFD:function(e){var r=i.getStreamChecked(e);return r}};function en(e,r,t){ue.varargs=t;try{var n=ue.getStreamFromFD(e);switch(r){case 0:{var s=ue.get();if(s<0)return-28;var u;return u=i.createStream(n,s),u.fd}case 1:case 2:return 0;case 3:return n.flags;case 4:{var s=ue.get();return n.flags|=s,0}case 5:{var s=ue.get(),l=0;return we[s+l>>1]=2,0}case 6:case 7:return 0;case 16:case 8:return-28;case 9:return et(28),-1;default:return-28}}catch(f){if(typeof i>"u"||f.name!=="ErrnoError")throw f;return-f.errno}}function Hr(e,r,t,n){ue.varargs=n;try{r=ue.getStr(r),r=ue.calculateAt(e,r);var s=n?ue.get():0;return i.open(r,t,s).fd}catch(u){if(typeof i>"u"||u.name!=="ErrnoError")throw u;return-u.errno}}function rn(e,r,t,n,s){}function Wr(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}`)}}function nt(){for(var e=new Array(256),r=0;r<256;++r)e[r]=String.fromCharCode(r);ht=e}var ht=void 0;function he(e){for(var r="",t=e;K[t];)r+=ht[K[t++]];return r}var Ne={},Ie={},_r={},Ve=void 0;function V(e){throw new Ve(e)}var Qe=void 0;function br(e){throw new Qe(e)}function tr(e,r,t){e.forEach(function(f){_r[f]=r});function n(f){var g=t(f);g.length!==e.length&&br("Mismatched type converter count");for(var m=0;m<e.length;++m)Ee(e[m],g[m])}var s=new Array(r.length),u=[],l=0;r.forEach((f,g)=>{Ie.hasOwnProperty(f)?s[g]=Ie[f]:(u.push(f),Ne.hasOwnProperty(f)||(Ne[f]=[]),Ne[f].push(()=>{s[g]=Ie[f],++l,l===u.length&&n(s)}))}),u.length===0&&n(s)}function it(e,r,t={}){var n=r.name;if(e||V(`type "${n}" must have a positive integer typeid pointer`),Ie.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;V(`Cannot register type '${n}' twice`)}if(Ie[e]=r,delete _r[e],Ne.hasOwnProperty(e)){var s=Ne[e];delete Ne[e],s.forEach(u=>u())}}function Ee(e,r,t={}){if(!("argPackAdvance"in r))throw new TypeError("registerType registeredInstance requires argPackAdvance");return it(e,r,t)}function Ut(e,r,t,n,s){var u=Wr(t);r=he(r),Ee(e,{name:r,fromWireType:function(l){return!!l},toWireType:function(l,f){return f?n:s},argPackAdvance:8,readValueFromPointer:function(l){var f;if(t===1)f=ee;else if(t===2)f=we;else if(t===4)f=W;else throw new TypeError("Unknown boolean type size: "+r);return this.fromWireType(f[l>>u])},destructorFunction:null})}function tn(e){if(!(this instanceof Se)||!(e instanceof Se))return!1;for(var r=this.$$.ptrType.registeredClass,t=this.$$.ptr,n=e.$$.ptrType.registeredClass,s=e.$$.ptr;r.baseClass;)t=r.upcast(t),r=r.baseClass;for(;n.baseClass;)s=n.upcast(s),n=n.baseClass;return r===n&&t===s}function nn(e){return{count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}}function Er(e){function r(t){return t.$$.ptrType.registeredClass.name}V(r(e)+" instance already deleted")}var zr=!1;function pt(e){}function on(e){e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)}function Fr(e){e.count.value-=1;var r=e.count.value===0;r&&on(e)}function vt(e,r,t){if(r===t)return e;if(t.baseClass===void 0)return null;var n=vt(e,r,t.baseClass);return n===null?null:t.downcast(n)}var mt={};function sn(){return Object.keys(ir).length}function an(){var e=[];for(var r in ir)ir.hasOwnProperty(r)&&e.push(ir[r]);return e}var Ce=[];function Nr(){for(;Ce.length;){var e=Ce.pop();e.$$.deleteScheduled=!1,e.delete()}}var nr=void 0;function ot(e){nr=e,Ce.length&&nr&&nr(Nr)}function Mt(){o.getInheritedInstanceCount=sn,o.getLiveInheritedInstances=an,o.flushPendingDeletes=Nr,o.setDelayFunction=ot}var ir={};function un(e,r){for(r===void 0&&V("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r}function Dr(e,r){return r=un(e,r),ir[r]}function Pr(e,r){(!r.ptrType||!r.ptr)&&br("makeClassHandle requires ptr and ptrType");var t=!!r.smartPtrType,n=!!r.smartPtr;return t!==n&&br("Both smartPtrType and smartPtr must be specified"),r.count={value:1},Ye(Object.create(e,{$$:{value:r}}))}function xt(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=Dr(this.registeredClass,r);if(t!==void 0){if(t.$$.count.value===0)return t.$$.ptr=r,t.$$.smartPtr=e,t.clone();var n=t.clone();return this.destructor(e),n}function s(){return this.isSmartPointer?Pr(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):Pr(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var u=this.registeredClass.getActualType(r),l=mt[u];if(!l)return s.call(this);var f;this.isConst?f=l.constPointerType:f=l.pointerType;var g=vt(r,this.registeredClass,f.registeredClass);return g===null?s.call(this):this.isSmartPointer?Pr(f.registeredClass.instancePrototype,{ptrType:f,ptr:g,smartPtrType:this,smartPtr:e}):Pr(f.registeredClass.instancePrototype,{ptrType:f,ptr:g})}var Ye=function(e){return typeof FinalizationRegistry>"u"?(Ye=r=>r,e):(zr=new FinalizationRegistry(r=>{Fr(r.$$)}),Ye=r=>{var t=r.$$,n=!!t.smartPtr;if(n){var s={$$:t};zr.register(r,s,r)}return r},pt=r=>zr.unregister(r),Ye(e))};function gt(){if(this.$$.ptr||Er(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e=Ye(Object.create(Object.getPrototypeOf(this),{$$:{value:nn(this.$$)}}));return e.$$.count.value+=1,e.$$.deleteScheduled=!1,e}function fn(){this.$$.ptr||Er(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&V("Object already scheduled for deletion"),pt(this),Fr(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function It(){return!this.$$.ptr}function ln(){return this.$$.ptr||Er(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&V("Object already scheduled for deletion"),Ce.push(this),Ce.length===1&&nr&&nr(Nr),this.$$.deleteScheduled=!0,this}function jt(){Se.prototype.isAliasOf=tn,Se.prototype.clone=gt,Se.prototype.delete=fn,Se.prototype.isDeleted=It,Se.prototype.deleteLater=ln}function Se(){}var cn=48,dn=57;function Cr(e){if(e===void 0)return"_unknown";e=e.replace(/[^a-zA-Z0-9_]/g,"$");var r=e.charCodeAt(0);return r>=cn&&r<=dn?`_${e}`:e}function Rr(e,r){return e=Cr(e),{[e]:function(){return r.apply(this,arguments)}}[e]}function je(e,r,t){if(e[r].overloadTable===void 0){var n=e[r];e[r]=function(){return e[r].overloadTable.hasOwnProperty(arguments.length)||V(`Function '${t}' called with an invalid number of arguments (${arguments.length}) - expects one of (${e[r].overloadTable})!`),e[r].overloadTable[arguments.length].apply(this,arguments)},e[r].overloadTable=[],e[r].overloadTable[n.argCount]=n}}function Lt(e,r,t){o.hasOwnProperty(e)?((t===void 0||o[e].overloadTable!==void 0&&o[e].overloadTable[t]!==void 0)&&V(`Cannot register public name '${e}' twice`),je(o,e,e),o.hasOwnProperty(t)&&V(`Cannot register multiple overloads of a function with the same number of arguments (${t})!`),o[e].overloadTable[t]=r):(o[e]=r,t!==void 0&&(o[e].numArguments=t))}function hn(e,r,t,n,s,u,l,f){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=s,this.getActualType=u,this.upcast=l,this.downcast=f,this.pureVirtualFunctions=[]}function Vr(e,r,t){for(;r!==t;)r.upcast||V(`Expected null or instance of ${t.name}, got an instance of ${r.name}`),e=r.upcast(e),r=r.baseClass;return e}function st(e,r){if(r===null)return this.isReference&&V(`null is not a valid ${this.name}`),0;r.$$||V(`Cannot pass "${qr(r)}" as a ${this.name}`),r.$$.ptr||V(`Cannot pass deleted object as a pointer of type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=Vr(r.$$.ptr,t,this.registeredClass);return n}function pn(e,r){var t;if(r===null)return this.isReference&&V(`null is not a valid ${this.name}`),this.isSmartPointer?(t=this.rawConstructor(),e!==null&&e.push(this.rawDestructor,t),t):0;r.$$||V(`Cannot pass "${qr(r)}" as a ${this.name}`),r.$$.ptr||V(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&r.$$.ptrType.isConst&&V(`Cannot convert argument of type ${r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name} to parameter type ${this.name}`);var n=r.$$.ptrType.registeredClass;if(t=Vr(r.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(r.$$.smartPtr===void 0&&V("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:V(`Cannot convert argument of type ${r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:t=r.$$.smartPtr;break;case 2:if(r.$$.smartPtrType===this)t=r.$$.smartPtr;else{var s=r.clone();t=this.rawShare(t,Tr.toHandle(function(){s.delete()})),e!==null&&e.push(this.rawDestructor,t)}break;default:V("Unsupporting sharing policy")}return t}function yt(e,r){if(r===null)return this.isReference&&V(`null is not a valid ${this.name}`),0;r.$$||V(`Cannot pass "${qr(r)}" as a ${this.name}`),r.$$.ptr||V(`Cannot pass deleted object as a pointer of type ${this.name}`),r.$$.ptrType.isConst&&V(`Cannot convert argument of type ${r.$$.ptrType.name} to parameter type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=Vr(r.$$.ptr,t,this.registeredClass);return n}function $r(e){return this.fromWireType(W[e>>2])}function vn(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e}function mn(e){this.rawDestructor&&this.rawDestructor(e)}function gn(e){e!==null&&e.delete()}function yn(){$e.prototype.getPointee=vn,$e.prototype.destructor=mn,$e.prototype.argPackAdvance=8,$e.prototype.readValueFromPointer=$r,$e.prototype.deleteObject=gn,$e.prototype.fromWireType=xt}function $e(e,r,t,n,s,u,l,f,g,m,$){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=s,this.pointeeType=u,this.sharingPolicy=l,this.rawGetPointee=f,this.rawConstructor=g,this.rawShare=m,this.rawDestructor=$,!s&&r.baseClass===void 0?n?(this.toWireType=st,this.destructorFunction=null):(this.toWireType=yt,this.destructorFunction=null):this.toWireType=pn}function wn(e,r,t){o.hasOwnProperty(e)||br("Replacing nonexistant public symbol"),o[e].overloadTable!==void 0&&t!==void 0?o[e].overloadTable[t]=r:(o[e]=r,o[e].argCount=t)}var _n=(e,r,t)=>{var n=o["dynCall_"+e];return t&&t.length?n.apply(null,[r].concat(t)):n.call(null,r)},ur=[],at=e=>{var r=ur[e];return r||(e>=ur.length&&(ur.length=e+1),ur[e]=r=pr.get(e)),r},bn=(e,r,t)=>{if(e.includes("j"))return _n(e,r,t);var n=at(r).apply(null,t);return n},En=(e,r)=>{var t=[];return function(){return t.length=0,Object.assign(t,arguments),bn(e,r,t)}};function Le(e,r){e=he(e);function t(){return e.includes("j")?En(e,r):at(r)}var n=t();return typeof n!="function"&&V(`unknown function pointer with signature ${e}: ${r}`),n}function Pn(e,r){var t=Rr(r,function(n){this.name=r,this.message=n;var s=new Error(n).stack;s!==void 0&&(this.stack=this.toString()+`
  4. `+s.replace(/^Error(:[^\n]*)?\n/,""))});return t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},t}var wt=void 0;function _t(e){var r=jn(e),t=he(r);return Fe(r),t}function Gr(e,r){var t=[],n={};function s(u){if(!n[u]&&!Ie[u]){if(_r[u]){_r[u].forEach(s);return}t.push(u),n[u]=!0}}throw r.forEach(s),new wt(`${e}: `+t.map(_t).join([", "]))}function Cn(e,r,t,n,s,u,l,f,g,m,$,k,T){$=he($),u=Le(s,u),f&&(f=Le(l,f)),m&&(m=Le(g,m)),T=Le(k,T);var P=Cr($);Lt(P,function(){Gr(`Cannot construct ${$} due to unbound types`,[n])}),tr([e,r,t],n?[n]:[],function(x){x=x[0];var Y,J;n?(Y=x.registeredClass,J=Y.instancePrototype):J=Se.prototype;var se=Rr(P,function(){if(Object.getPrototypeOf(this)!==ve)throw new Ve("Use 'new' to construct "+$);if(re.constructor_body===void 0)throw new Ve($+" has no accessible constructor");var ae=re.constructor_body[arguments.length];if(ae===void 0)throw new Ve(`Tried to invoke ctor of ${$} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(re.constructor_body).toString()}) parameters instead!`);return ae.apply(this,arguments)}),ve=Object.create(J,{constructor:{value:se}});se.prototype=ve;var re=new hn($,se,ve,T,Y,u,f,m);re.baseClass&&(re.baseClass.__derivedClasses===void 0&&(re.baseClass.__derivedClasses=[]),re.baseClass.__derivedClasses.push(re));var qe=new $e($,re,!0,!1,!1),me=new $e($+"*",re,!1,!1,!1),De=new $e($+" const*",re,!1,!0,!1);return mt[e]={pointerType:me,constPointerType:De},wn(P,se),[qe,me,De]})}function bt(e,r){for(var t=[],n=0;n<e;n++)t.push(z[r+n*4>>2]);return t}function $n(e){for(;e.length;){var r=e.pop(),t=e.pop();t(r)}}function Et(e,r){if(!(e instanceof Function))throw new TypeError(`new_ called with constructor type ${typeof e} which is not a function`);var t=Rr(e.name||"unknownFunctionName",function(){});t.prototype=e.prototype;var n=new t,s=e.apply(n,r);return s instanceof Object?s:n}function Pt(e,r,t,n,s,u){var l=r.length;l<2&&V("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var f=r[1]!==null&&t!==null,g=!1,m=1;m<r.length;++m)if(r[m]!==null&&r[m].destructorFunction===void 0){g=!0;break}for(var $=r[0].name!=="void",k="",T="",m=0;m<l-2;++m)k+=(m!==0?", ":"")+"arg"+m,T+=(m!==0?", ":"")+"arg"+m+"Wired";var P=`
  5. return function ${Cr(e)}(${k}) {
  6. if (arguments.length !== ${l-2}) {
  7. throwBindingError('function ${e} called with ${arguments.length} arguments, expected ${l-2} args!');
  8. }`;g&&(P+=`var destructors = [];
  9. `);var x=g?"destructors":"null",Y=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],J=[V,n,s,$n,r[0],r[1]];f&&(P+="var thisWired = classParam.toWireType("+x+`, this);
  10. `);for(var m=0;m<l-2;++m)P+="var arg"+m+"Wired = argType"+m+".toWireType("+x+", arg"+m+"); // "+r[m+2].name+`
  11. `,Y.push("argType"+m),J.push(r[m+2]);if(f&&(T="thisWired"+(T.length>0?", ":"")+T),P+=($||u?"var rv = ":"")+"invoker(fn"+(T.length>0?", ":"")+T+`);
  12. `,g)P+=`runDestructors(destructors);
  13. `;else for(var m=f?1:2;m<r.length;++m){var se=m===1?"thisWired":"arg"+(m-2)+"Wired";r[m].destructorFunction!==null&&(P+=se+"_dtor("+se+"); // "+r[m].name+`
  14. `,Y.push(se+"_dtor"),J.push(r[m].destructorFunction))}return $&&(P+=`var ret = retType.fromWireType(rv);
  15. return ret;
  16. `),P+=`}
  17. `,Y.push(P),Et(Function,Y).apply(null,J)}function Tn(e,r,t,n,s,u){var l=bt(r,t);s=Le(n,s),tr([],[e],function(f){f=f[0];var g=`constructor ${f.name}`;if(f.registeredClass.constructor_body===void 0&&(f.registeredClass.constructor_body=[]),f.registeredClass.constructor_body[r-1]!==void 0)throw new Ve(`Cannot register multiple constructors with identical number of parameters (${r-1}) for class '${f.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return f.registeredClass.constructor_body[r-1]=()=>{Gr(`Cannot construct ${f.name} due to unbound types`,l)},tr([],l,function(m){return m.splice(1,0,null),f.registeredClass.constructor_body[r-1]=Pt(g,m,null,s,u),[]}),[]})}function Ct(e,r,t,n,s,u,l,f,g){var m=bt(t,n);r=he(r),u=Le(s,u),tr([],[e],function($){$=$[0];var k=`${$.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),f&&$.registeredClass.pureVirtualFunctions.push(r);function T(){Gr(`Cannot call ${k} due to unbound types`,m)}var P=$.registeredClass.instancePrototype,x=P[r];return x===void 0||x.overloadTable===void 0&&x.className!==$.name&&x.argCount===t-2?(T.argCount=t-2,T.className=$.name,P[r]=T):(je(P,r,k),P[r].overloadTable[t-2]=T),tr([],m,function(Y){var J=Pt(k,Y,$,u,l,g);return P[r].overloadTable===void 0?(J.argCount=t-2,P[r]=J):P[r].overloadTable[t-2]=J,[]}),[]})}function Sn(){Object.assign($t.prototype,{get(e){return this.allocated[e]},has(e){return this.allocated[e]!==void 0},allocate(e){var r=this.freelist.pop()||this.allocated.length;return this.allocated[r]=e,r},free(e){this.allocated[e]=void 0,this.freelist.push(e)}})}function $t(){this.allocated=[void 0],this.freelist=[]}var ge=new $t;function Tt(e){e>=ge.reserved&&--ge.get(e).refcount===0&&ge.free(e)}function Bt(){for(var e=0,r=ge.reserved;r<ge.allocated.length;++r)ge.allocated[r]!==void 0&&++e;return e}function kn(){ge.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),ge.reserved=ge.allocated.length,o.count_emval_handles=Bt}var Tr={toValue:e=>(e||V("Cannot use deleted val. handle = "+e),ge.get(e).value),toHandle:e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return ge.allocate({refcount:1,value:e})}}};function Ht(e,r){r=he(r),Ee(e,{name:r,fromWireType:function(t){var n=Tr.toValue(t);return Tt(t),n},toWireType:function(t,n){return Tr.toHandle(n)},argPackAdvance:8,readValueFromPointer:$r,destructorFunction:null})}function qr(e){if(e===null)return"null";var r=typeof e;return r==="object"||r==="array"||r==="function"?e.toString():""+e}function An(e,r){switch(r){case 2:return function(t){return this.fromWireType(dr[t>>2])};case 3:return function(t){return this.fromWireType(hr[t>>3])};default:throw new TypeError("Unknown float type: "+e)}}function Fn(e,r,t){var n=Wr(t);r=he(r),Ee(e,{name:r,fromWireType:function(s){return s},toWireType:function(s,u){return u},argPackAdvance:8,readValueFromPointer:An(r,n),destructorFunction:null})}function Dn(e,r,t){switch(r){case 0:return t?function(s){return ee[s]}:function(s){return K[s]};case 1:return t?function(s){return we[s>>1]}:function(s){return Je[s>>1]};case 2:return t?function(s){return W[s>>2]}:function(s){return z[s>>2]};default:throw new TypeError("Unknown integer type: "+e)}}function Rn(e,r,t,n,s){r=he(r);var u=Wr(t),l=k=>k;if(n===0){var f=32-8*t;l=k=>k<<f>>>f}var g=r.includes("unsigned"),m=(k,T)=>{},$;g?$=function(k,T){return m(T,this.name),T>>>0}:$=function(k,T){return m(T,this.name),T},Ee(e,{name:r,fromWireType:l,toWireType:$,argPackAdvance:8,readValueFromPointer:Dn(r,u,n!==0),destructorFunction:null})}function On(e,r,t){var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],s=n[r];function u(l){l=l>>2;var f=z,g=f[l],m=f[l+1];return new s(f.buffer,m,g)}t=he(t),Ee(e,{name:t,fromWireType:u,argPackAdvance:8,readValueFromPointer:u},{ignoreDuplicateRegistrations:!0})}var Un=(e,r,t)=>Lr(e,K,r,t);function or(e,r){r=he(r);var t=r==="std::string";Ee(e,{name:r,fromWireType:function(n){var s=z[n>>2],u=n+4,l;if(t)for(var f=u,g=0;g<=s;++g){var m=u+g;if(g==s||K[m]==0){var $=m-f,k=wr(f,$);l===void 0?l=k:(l+=String.fromCharCode(0),l+=k),f=m+1}}else{for(var T=new Array(s),g=0;g<s;++g)T[g]=String.fromCharCode(K[u+g]);l=T.join("")}return Fe(n),l},toWireType:function(n,s){s instanceof ArrayBuffer&&(s=new Uint8Array(s));var u,l=typeof s=="string";l||s instanceof Uint8Array||s instanceof Uint8ClampedArray||s instanceof Int8Array||V("Cannot pass non-string to std::string"),t&&l?u=jr(s):u=s.length;var f=kt(4+u+1),g=f+4;if(z[f>>2]=u,t&&l)Un(s,g,u+1);else if(l)for(var m=0;m<u;++m){var $=s.charCodeAt(m);$>255&&(Fe(g),V("String has UTF-16 code units that do not fit in 8 bits")),K[g+m]=$}else for(var m=0;m<u;++m)K[g+m]=s[m];return n!==null&&n.push(Fe,f),f},argPackAdvance:8,readValueFromPointer:$r,destructorFunction:function(n){Fe(n)}})}var Xr=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,Wt=(e,r)=>{for(var t=e,n=t>>1,s=n+r/2;!(n>=s)&&Je[n];)++n;if(t=n<<1,t-e>32&&Xr)return Xr.decode(K.subarray(e,t));for(var u="",l=0;!(l>=r/2);++l){var f=we[e+l*2>>1];if(f==0)break;u+=String.fromCharCode(f)}return u},zt=(e,r,t)=>{if(t===void 0&&(t=2147483647),t<2)return 0;t-=2;for(var n=r,s=t<e.length*2?t/2:e.length,u=0;u<s;++u){var l=e.charCodeAt(u);we[r>>1]=l,r+=2}return we[r>>1]=0,r-n},ut=e=>e.length*2,Nt=(e,r)=>{for(var t=0,n="";!(t>=r/4);){var s=W[e+t*4>>2];if(s==0)break;if(++t,s>=65536){var u=s-65536;n+=String.fromCharCode(55296|u>>10,56320|u&1023)}else n+=String.fromCharCode(s)}return n},c=(e,r,t)=>{if(t===void 0&&(t=2147483647),t<4)return 0;for(var n=r,s=n+t-4,u=0;u<e.length;++u){var l=e.charCodeAt(u);if(l>=55296&&l<=57343){var f=e.charCodeAt(++u);l=65536+((l&1023)<<10)|f&1023}if(W[r>>2]=l,r+=4,r+4>s)break}return W[r>>2]=0,r-n},d=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n>=55296&&n<=57343&&++t,r+=4}return r},v=function(e,r,t){t=he(t);var n,s,u,l,f;r===2?(n=Wt,s=zt,l=ut,u=()=>Je,f=1):r===4&&(n=Nt,s=c,l=d,u=()=>z,f=2),Ee(e,{name:t,fromWireType:function(g){for(var m=z[g>>2],$=u(),k,T=g+4,P=0;P<=m;++P){var x=g+4+P*r;if(P==m||$[x>>f]==0){var Y=x-T,J=n(T,Y);k===void 0?k=J:(k+=String.fromCharCode(0),k+=J),T=x+r}}return Fe(g),k},toWireType:function(g,m){typeof m!="string"&&V(`Cannot pass non-string to C++ string type ${t}`);var $=l(m),k=kt(4+$+r);return z[k>>2]=$>>f,s(m,k+4,$+r),g!==null&&g.push(Fe,k),k},argPackAdvance:8,readValueFromPointer:$r,destructorFunction:function(g){Fe(g)}})};function E(e,r){r=he(r),Ee(e,{isVoid:!0,name:r,argPackAdvance:0,fromWireType:function(){},toWireType:function(t,n){}})}var A={};function M(e){var r=A[e];return r===void 0?he(e):r}var I=[];function R(e,r,t,n){e=I[e],r=Tr.toValue(r),t=M(t),e(r,t,null,n)}function G(e){var r=I.length;return I.push(e),r}function j(e,r){var t=Ie[e];return t===void 0&&V(r+" has unknown type "+_t(e)),t}function ne(e,r){for(var t=new Array(e),n=0;n<e;++n)t[n]=j(z[r+n*4>>2],"parameter "+n);return t}var oe=[];function fe(e,r){var t=ne(e,r),n=t[0],s=n.name+"_$"+t.slice(1).map(function(x){return x.name}).join("_")+"$",u=oe[s];if(u!==void 0)return u;for(var l=["retType"],f=[n],g="",m=0;m<e-1;++m)g+=(m!==0?", ":"")+"arg"+m,l.push("argType"+m),f.push(t[1+m]);for(var $=Cr("methodCaller_"+s),k="return function "+$+`(handle, name, destructors, args) {
  18. `,T=0,m=0;m<e-1;++m)k+=" var arg"+m+" = argType"+m+".readValueFromPointer(args"+(T?"+"+T:"")+`);
  19. `,T+=t[m+1].argPackAdvance;k+=" var rv = handle[name]("+g+`);
  20. `;for(var m=0;m<e-1;++m)t[m+1].deleteObject&&(k+=" argType"+m+".deleteObject(arg"+m+`);
  21. `);n.isVoid||(k+=` return retType.toWireType(destructors, rv);
  22. `),k+=`};
  23. `,l.push(k);var P=Et(Function,l).apply(null,f);return u=G(P),oe[s]=u,u}function pe(e,r){return r+2097152>>>0<4194305-!!e?(e>>>0)+r*4294967296:NaN}var Te=()=>{Ue("")};function Be(){return Date.now()}var Re=()=>K.length,fr=()=>Re(),St=(e,r,t)=>K.copyWithin(e,r,r+t),Ge=e=>{Ue("OOM")},Mn=e=>{K.length,Ge()},Or={},Vt=()=>b||"./this.program",Ze=()=>{if(!Ze.strings){var e=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",r={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:Vt()};for(var t in Or)Or[t]===void 0?delete r[t]:r[t]=Or[t];var n=[];for(var t in r)n.push(`${t}=${r[t]}`);Ze.strings=n}return Ze.strings},ui=(e,r)=>{for(var t=0;t<e.length;++t)ee[r++>>0]=e.charCodeAt(t);ee[r>>0]=0},fi=(e,r)=>{var t=0;return Ze().forEach(function(n,s){var u=r+t;z[e+s*4>>2]=u,ui(n,u),t+=n.length+1}),0},li=(e,r)=>{var t=Ze();z[e>>2]=t.length;var n=0;return t.forEach(function(s){n+=s.length+1}),z[r>>2]=n,0};function ci(e){try{var r=ue.getStreamFromFD(e);return i.close(r),0}catch(t){if(typeof i>"u"||t.name!=="ErrnoError")throw t;return t.errno}}function di(e,r){try{var t=0,n=0,s=0,u=ue.getStreamFromFD(e),l=u.tty?2:i.isDir(u.mode)?3:i.isLink(u.mode)?7:4;return ee[r>>0]=l,we[r+2>>1]=s,Q=[t>>>0,(U=t,+Math.abs(U)>=1?U>0?+Math.floor(U/4294967296)>>>0:~~+Math.ceil((U-+(~~U>>>0))/4294967296)>>>0:0)],W[r+8>>2]=Q[0],W[r+12>>2]=Q[1],Q=[n>>>0,(U=n,+Math.abs(U)>=1?U>0?+Math.floor(U/4294967296)>>>0:~~+Math.ceil((U-+(~~U>>>0))/4294967296)>>>0:0)],W[r+16>>2]=Q[0],W[r+20>>2]=Q[1],0}catch(f){if(typeof i>"u"||f.name!=="ErrnoError")throw f;return f.errno}}var hi=(e,r,t,n)=>{for(var s=0,u=0;u<t;u++){var l=z[r>>2],f=z[r+4>>2];r+=8;var g=i.read(e,ee,l,f,n);if(g<0)return-1;if(s+=g,g<f)break;typeof n<"u"&&(n+=g)}return s};function pi(e,r,t,n){try{var s=ue.getStreamFromFD(e),u=hi(s,r,t);return z[n>>2]=u,0}catch(l){if(typeof i>"u"||l.name!=="ErrnoError")throw l;return l.errno}}function vi(e,r,t,n,s){var u=pe(r,t);try{if(isNaN(u))return 61;var l=ue.getStreamFromFD(e);return i.llseek(l,u,n),Q=[l.position>>>0,(U=l.position,+Math.abs(U)>=1?U>0?+Math.floor(U/4294967296)>>>0:~~+Math.ceil((U-+(~~U>>>0))/4294967296)>>>0:0)],W[s>>2]=Q[0],W[s+4>>2]=Q[1],l.getdents&&u===0&&n===0&&(l.getdents=null),0}catch(f){if(typeof i>"u"||f.name!=="ErrnoError")throw f;return f.errno}}var mi=(e,r,t,n)=>{for(var s=0,u=0;u<t;u++){var l=z[r>>2],f=z[r+4>>2];r+=8;var g=i.write(e,ee,l,f,n);if(g<0)return-1;s+=g,typeof n<"u"&&(n+=g)}return s};function gi(e,r,t,n){try{var s=ue.getStreamFromFD(e),u=mi(s,r,t);return z[n>>2]=u,0}catch(l){if(typeof i>"u"||l.name!=="ErrnoError")throw l;return l.errno}}var xn=function(e,r,t,n){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=i.nextInode++,this.name=r,this.mode=t,this.node_ops={},this.stream_ops={},this.rdev=n},Kr=365,Qr=146;Object.defineProperties(xn.prototype,{read:{get:function(){return(this.mode&Kr)===Kr},set:function(e){e?this.mode|=Kr:this.mode&=~Kr}},write:{get:function(){return(this.mode&Qr)===Qr},set:function(e){e?this.mode|=Qr:this.mode&=~Qr}},isFolder:{get:function(){return i.isDir(this.mode)}},isDevice:{get:function(){return i.isChrdev(this.mode)}}}),i.FSNode=xn,i.createPreloadedFile=Zt,i.staticInit(),nt(),Ve=o.BindingError=class extends Error{constructor(r){super(r),this.name="BindingError"}},Qe=o.InternalError=class extends Error{constructor(r){super(r),this.name="InternalError"}},jt(),Mt(),yn(),wt=o.UnboundTypeError=Pn(Error,"UnboundTypeError"),Sn(),kn();var yi={p:gr,C:en,w:Hr,t:rn,n:Ut,r:Cn,q:Tn,d:Ct,D:Ht,k:Fn,c:Rn,b:On,j:or,f:v,o:E,g:R,m:Tt,l:fe,a:Te,e:Be,v:fr,A:St,u:Mn,y:fi,z:li,i:ci,x:di,B:pi,s:vi,h:gi};Yt();var kt=e=>(kt=X.G)(e),Fe=e=>(Fe=X.I)(e),In=()=>(In=X.J)(),jn=e=>(jn=X.K)(e);o.__embind_initialize_bindings=()=>(o.__embind_initialize_bindings=X.L)();var Ln=e=>(Ln=X.M)(e);o.dynCall_jiji=(e,r,t,n,s)=>(o.dynCall_jiji=X.N)(e,r,t,n,s),o._ff_h264_cabac_tables=67061;var Yr;er=function e(){Yr||Bn(),Yr||(er=e)};function Bn(){if(Pe>0||(Mr(),Pe>0))return;function e(){Yr||(Yr=!0,o.calledRun=!0,!ie&&(xr(),h(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),He()))}o.setStatus?(o.setStatus("Running..."),setTimeout(function(){setTimeout(function(){o.setStatus("")},1),e()},1)):e()}if(o.preInit)for(typeof o.preInit=="function"&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return Bn(),a.ready}})();class yo extends Xt{constructor(a){super(qi,a?.wasmPath?fetch(a?.wasmPath).then(o=>o.arrayBuffer()):void 0,a?.workerMode,a?.canvas,a?.yuvMode)}}var Xi=(()=>{var p=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(a={}){var o=a,h,y;o.ready=new Promise((c,d)=>{h=c,y=d});var _=Object.assign({},o),b=typeof window=="object",D=typeof importScripts=="function";typeof process=="object"&&typeof process.versions=="object"&&process.versions.node;var S="";function w(c){return o.locateFile?o.locateFile(c,S):S+c}var C;(b||D)&&(D?S=self.location.href:typeof document<"u"&&document.currentScript&&(S=document.currentScript.src),p&&(S=p),S.indexOf("blob:")!==0?S=S.substr(0,S.replace(/[?#].*/,"").lastIndexOf("/")+1):S="",D&&(C=c=>{var d=new XMLHttpRequest;return d.open("GET",c,!1),d.responseType="arraybuffer",d.send(null),new Uint8Array(d.response)}));var F=o.print||console.log.bind(console),H=o.printErr||console.error.bind(console);Object.assign(o,_),_=null,o.arguments&&o.arguments,o.thisProgram&&o.thisProgram,o.quit&&o.quit;var te;o.wasmBinary&&(te=o.wasmBinary),o.noExitRuntime,typeof WebAssembly!="object"&&Pe("no native wasm support detected");var Z,N,B=!1,ce,X,ie,Oe,ee,K,we,Je;function W(){var c=Z.buffer;o.HEAP8=ce=new Int8Array(c),o.HEAP16=ie=new Int16Array(c),o.HEAP32=ee=new Int32Array(c),o.HEAPU8=X=new Uint8Array(c),o.HEAPU16=Oe=new Uint16Array(c),o.HEAPU32=K=new Uint32Array(c),o.HEAPF32=we=new Float32Array(c),o.HEAPF64=Je=new Float64Array(c)}var z,dr=[],hr=[],Sr=[];function pr(){if(o.preRun)for(typeof o.preRun=="function"&&(o.preRun=[o.preRun]);o.preRun.length;)vr(o.preRun.shift());Ir(dr)}function Zr(){Ir(hr)}function kr(){if(o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;)xr(o.postRun.shift());Ir(Sr)}function vr(c){dr.unshift(c)}function Mr(c){hr.unshift(c)}function xr(c){Sr.unshift(c)}var He=0,mr=null;function _e(c){He++,o.monitorRunDependencies&&o.monitorRunDependencies(He)}function be(c){if(He--,o.monitorRunDependencies&&o.monitorRunDependencies(He),He==0&&mr){var d=mr;mr=null,d()}}function Pe(c){o.onAbort&&o.onAbort(c),c="Aborted("+c+")",H(c),B=!0,c+=". Build with -sASSERTIONS for more info.";var d=new WebAssembly.RuntimeError(c);throw y(d),d}var er="data:application/octet-stream;base64,";function ri(c){return c.startsWith(er)}var Ke;Ke="videodec_simd.wasm",ri(Ke)||(Ke=w(Ke));function sr(c){if(c==Ke&&te)return new Uint8Array(te);if(C)return C(c);throw"both async and sync fetching of the wasm failed"}function Ue(c){return!te&&(b||D)&&typeof fetch=="function"?fetch(c,{credentials:"same-origin"}).then(d=>{if(!d.ok)throw"failed to load wasm binary file at '"+c+"'";return d.arrayBuffer()}).catch(()=>sr(c)):Promise.resolve().then(()=>sr(c))}function Ft(c,d,v){return Ue(c).then(E=>WebAssembly.instantiate(E,d)).then(E=>E).then(v,E=>{H("failed to asynchronously prepare wasm: "+E),Pe(E)})}function ct(c,d,v,E){return!c&&typeof WebAssembly.instantiateStreaming=="function"&&!ri(d)&&typeof fetch=="function"?fetch(d,{credentials:"same-origin"}).then(A=>{var M=WebAssembly.instantiateStreaming(A,v);return M.then(E,function(I){return H("wasm streaming compile failed: "+I),H("falling back to ArrayBuffer instantiation"),Ft(d,v,E)})}):Ft(d,v,E)}function We(){var c={a:Un};function d(E,A){var M=E.exports;return N=M,Z=N.v,W(),z=N.z,Mr(N.w),be(),M}_e();function v(E){d(E.instance)}if(o.instantiateWasm)try{return o.instantiateWasm(c,d)}catch(E){H("Module.instantiateWasm callback failed with error: "+E),y(E)}return ct(te,Ke,c,v).catch(y),{}}var Ir=c=>{for(;c.length>0;)c.shift()(o)};function Kt(c){this.excPtr=c,this.ptr=c-24,this.set_type=function(d){K[this.ptr+4>>2]=d},this.get_type=function(){return K[this.ptr+4>>2]},this.set_destructor=function(d){K[this.ptr+8>>2]=d},this.get_destructor=function(){return K[this.ptr+8>>2]},this.set_caught=function(d){d=d?1:0,ce[this.ptr+12>>0]=d},this.get_caught=function(){return ce[this.ptr+12>>0]!=0},this.set_rethrown=function(d){d=d?1:0,ce[this.ptr+13>>0]=d},this.get_rethrown=function(){return ce[this.ptr+13>>0]!=0},this.init=function(d,v){this.set_adjusted_ptr(0),this.set_type(d),this.set_destructor(v)},this.set_adjusted_ptr=function(d){K[this.ptr+16>>2]=d},this.get_adjusted_ptr=function(){return K[this.ptr+16>>2]},this.get_exception_ptr=function(){var d=zt(this.get_type());if(d)return K[this.excPtr>>2];var v=this.get_adjusted_ptr();return v!==0?v:this.excPtr}}var Jr=0;function Qt(c,d,v){var E=new Kt(c);throw E.init(d,v),Jr=c,Jr}function Yt(c,d,v,E,A){}function U(c){switch(c){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError(`Unknown type size: ${c}`)}}function Q(){for(var c=new Array(256),d=0;d<256;++d)c[d]=String.fromCharCode(d);Ar=c}var Ar=void 0;function Me(c){for(var d="",v=c;X[v];)d+=Ar[X[v++]];return d}var ar={},gr={},et={},q=void 0;function le(c){throw new q(c)}var rt=void 0;function ye(c){throw new rt(c)}function yr(c,d,v){c.forEach(function(R){et[R]=d});function E(R){var G=v(R);G.length!==c.length&&ye("Mismatched type converter count");for(var j=0;j<c.length;++j)xe(c[j],G[j])}var A=new Array(d.length),M=[],I=0;d.forEach((R,G)=>{gr.hasOwnProperty(R)?A[G]=gr[R]:(M.push(R),ar.hasOwnProperty(R)||(ar[R]=[]),ar[R].push(()=>{A[G]=gr[R],++I,I===M.length&&E(A)}))}),M.length===0&&E(A)}function ze(c,d,v={}){var E=d.name;if(c||le(`type "${E}" must have a positive integer typeid pointer`),gr.hasOwnProperty(c)){if(v.ignoreDuplicateRegistrations)return;le(`Cannot register type '${E}' twice`)}if(gr[c]=d,delete et[c],ar.hasOwnProperty(c)){var A=ar[c];delete ar[c],A.forEach(M=>M())}}function xe(c,d,v={}){if(!("argPackAdvance"in d))throw new TypeError("registerType registeredInstance requires argPackAdvance");return ze(c,d,v)}function jr(c,d,v,E,A){var M=U(v);d=Me(d),xe(c,{name:d,fromWireType:function(I){return!!I},toWireType:function(I,R){return R?E:A},argPackAdvance:8,readValueFromPointer:function(I){var R;if(v===1)R=ce;else if(v===2)R=ie;else if(v===4)R=ee;else throw new TypeError("Unknown boolean type size: "+d);return this.fromWireType(R[I>>M])},destructorFunction:null})}function Lr(c){if(!(this instanceof Qe)||!(c instanceof Qe))return!1;for(var d=this.$$.ptrType.registeredClass,v=this.$$.ptr,E=c.$$.ptrType.registeredClass,A=c.$$.ptr;d.baseClass;)v=d.upcast(v),d=d.baseClass;for(;E.baseClass;)A=E.upcast(A),E=E.baseClass;return d===E&&v===A}function Br(c){return{count:c.count,deleteScheduled:c.deleteScheduled,preservePointerOnDelete:c.preservePointerOnDelete,ptr:c.ptr,ptrType:c.ptrType,smartPtr:c.smartPtr,smartPtrType:c.smartPtrType}}function dt(c){function d(v){return v.$$.ptrType.registeredClass.name}le(d(c)+" instance already deleted")}var Ae=!1;function tt(c){}function L(c){c.smartPtr?c.smartPtrType.rawDestructor(c.smartPtr):c.ptrType.registeredClass.rawDestructor(c.ptr)}function Dt(c){c.count.value-=1;var d=c.count.value===0;d&&L(c)}function Rt(c,d,v){if(d===v)return c;if(v.baseClass===void 0)return null;var E=Rt(c,d,v.baseClass);return E===null?null:v.downcast(E)}var Ot={};function Zt(){return Object.keys(Hr).length}function Jt(){var c=[];for(var d in Hr)Hr.hasOwnProperty(d)&&c.push(Hr[d]);return c}var rr=[];function i(){for(;rr.length;){var c=rr.pop();c.$$.deleteScheduled=!1,c.delete()}}var wr=void 0;function ue(c){wr=c,rr.length&&wr&&wr(i)}function en(){o.getInheritedInstanceCount=Zt,o.getLiveInheritedInstances=Jt,o.flushPendingDeletes=i,o.setDelayFunction=ue}var Hr={};function rn(c,d){for(d===void 0&&le("ptr should not be undefined");c.baseClass;)d=c.upcast(d),c=c.baseClass;return d}function Wr(c,d){return d=rn(c,d),Hr[d]}function nt(c,d){(!d.ptrType||!d.ptr)&&ye("makeClassHandle requires ptr and ptrType");var v=!!d.smartPtrType,E=!!d.smartPtr;return v!==E&&ye("Both smartPtrType and smartPtr must be specified"),d.count={value:1},he(Object.create(c,{$$:{value:d}}))}function ht(c){var d=this.getPointee(c);if(!d)return this.destructor(c),null;var v=Wr(this.registeredClass,d);if(v!==void 0){if(v.$$.count.value===0)return v.$$.ptr=d,v.$$.smartPtr=c,v.clone();var E=v.clone();return this.destructor(c),E}function A(){return this.isSmartPointer?nt(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:d,smartPtrType:this,smartPtr:c}):nt(this.registeredClass.instancePrototype,{ptrType:this,ptr:c})}var M=this.registeredClass.getActualType(d),I=Ot[M];if(!I)return A.call(this);var R;this.isConst?R=I.constPointerType:R=I.pointerType;var G=Rt(d,this.registeredClass,R.registeredClass);return G===null?A.call(this):this.isSmartPointer?nt(R.registeredClass.instancePrototype,{ptrType:R,ptr:G,smartPtrType:this,smartPtr:c}):nt(R.registeredClass.instancePrototype,{ptrType:R,ptr:G})}var he=function(c){return typeof FinalizationRegistry>"u"?(he=d=>d,c):(Ae=new FinalizationRegistry(d=>{Dt(d.$$)}),he=d=>{var v=d.$$,E=!!v.smartPtr;if(E){var A={$$:v};Ae.register(d,A,d)}return d},tt=d=>Ae.unregister(d),he(c))};function Ne(){if(this.$$.ptr||dt(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var c=he(Object.create(Object.getPrototypeOf(this),{$$:{value:Br(this.$$)}}));return c.$$.count.value+=1,c.$$.deleteScheduled=!1,c}function Ie(){this.$$.ptr||dt(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&le("Object already scheduled for deletion"),tt(this),Dt(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function _r(){return!this.$$.ptr}function Ve(){return this.$$.ptr||dt(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&le("Object already scheduled for deletion"),rr.push(this),rr.length===1&&wr&&wr(i),this.$$.deleteScheduled=!0,this}function V(){Qe.prototype.isAliasOf=Lr,Qe.prototype.clone=Ne,Qe.prototype.delete=Ie,Qe.prototype.isDeleted=_r,Qe.prototype.deleteLater=Ve}function Qe(){}var br=48,tr=57;function it(c){if(c===void 0)return"_unknown";c=c.replace(/[^a-zA-Z0-9_]/g,"$");var d=c.charCodeAt(0);return d>=br&&d<=tr?`_${c}`:c}function Ee(c,d){return c=it(c),{[c]:function(){return d.apply(this,arguments)}}[c]}function Ut(c,d,v){if(c[d].overloadTable===void 0){var E=c[d];c[d]=function(){return c[d].overloadTable.hasOwnProperty(arguments.length)||le(`Function '${v}' called with an invalid number of arguments (${arguments.length}) - expects one of (${c[d].overloadTable})!`),c[d].overloadTable[arguments.length].apply(this,arguments)},c[d].overloadTable=[],c[d].overloadTable[E.argCount]=E}}function tn(c,d,v){o.hasOwnProperty(c)?((v===void 0||o[c].overloadTable!==void 0&&o[c].overloadTable[v]!==void 0)&&le(`Cannot register public name '${c}' twice`),Ut(o,c,c),o.hasOwnProperty(v)&&le(`Cannot register multiple overloads of a function with the same number of arguments (${v})!`),o[c].overloadTable[v]=d):(o[c]=d,v!==void 0&&(o[c].numArguments=v))}function nn(c,d,v,E,A,M,I,R){this.name=c,this.constructor=d,this.instancePrototype=v,this.rawDestructor=E,this.baseClass=A,this.getActualType=M,this.upcast=I,this.downcast=R,this.pureVirtualFunctions=[]}function Er(c,d,v){for(;d!==v;)d.upcast||le(`Expected null or instance of ${v.name}, got an instance of ${d.name}`),c=d.upcast(c),d=d.baseClass;return c}function zr(c,d){if(d===null)return this.isReference&&le(`null is not a valid ${this.name}`),0;d.$$||le(`Cannot pass "${yt(d)}" as a ${this.name}`),d.$$.ptr||le(`Cannot pass deleted object as a pointer of type ${this.name}`);var v=d.$$.ptrType.registeredClass,E=Er(d.$$.ptr,v,this.registeredClass);return E}function pt(c,d){var v;if(d===null)return this.isReference&&le(`null is not a valid ${this.name}`),this.isSmartPointer?(v=this.rawConstructor(),c!==null&&c.push(this.rawDestructor,v),v):0;d.$$||le(`Cannot pass "${yt(d)}" as a ${this.name}`),d.$$.ptr||le(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&d.$$.ptrType.isConst&&le(`Cannot convert argument of type ${d.$$.smartPtrType?d.$$.smartPtrType.name:d.$$.ptrType.name} to parameter type ${this.name}`);var E=d.$$.ptrType.registeredClass;if(v=Er(d.$$.ptr,E,this.registeredClass),this.isSmartPointer)switch(d.$$.smartPtr===void 0&&le("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:d.$$.smartPtrType===this?v=d.$$.smartPtr:le(`Cannot convert argument of type ${d.$$.smartPtrType?d.$$.smartPtrType.name:d.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:v=d.$$.smartPtr;break;case 2:if(d.$$.smartPtrType===this)v=d.$$.smartPtr;else{var A=d.clone();v=this.rawShare(v,st.toHandle(function(){A.delete()})),c!==null&&c.push(this.rawDestructor,v)}break;default:le("Unsupporting sharing policy")}return v}function on(c,d){if(d===null)return this.isReference&&le(`null is not a valid ${this.name}`),0;d.$$||le(`Cannot pass "${yt(d)}" as a ${this.name}`),d.$$.ptr||le(`Cannot pass deleted object as a pointer of type ${this.name}`),d.$$.ptrType.isConst&&le(`Cannot convert argument of type ${d.$$.ptrType.name} to parameter type ${this.name}`);var v=d.$$.ptrType.registeredClass,E=Er(d.$$.ptr,v,this.registeredClass);return E}function Fr(c){return this.fromWireType(ee[c>>2])}function vt(c){return this.rawGetPointee&&(c=this.rawGetPointee(c)),c}function mt(c){this.rawDestructor&&this.rawDestructor(c)}function sn(c){c!==null&&c.delete()}function an(){Ce.prototype.getPointee=vt,Ce.prototype.destructor=mt,Ce.prototype.argPackAdvance=8,Ce.prototype.readValueFromPointer=Fr,Ce.prototype.deleteObject=sn,Ce.prototype.fromWireType=ht}function Ce(c,d,v,E,A,M,I,R,G,j,ne){this.name=c,this.registeredClass=d,this.isReference=v,this.isConst=E,this.isSmartPointer=A,this.pointeeType=M,this.sharingPolicy=I,this.rawGetPointee=R,this.rawConstructor=G,this.rawShare=j,this.rawDestructor=ne,!A&&d.baseClass===void 0?E?(this.toWireType=zr,this.destructorFunction=null):(this.toWireType=on,this.destructorFunction=null):this.toWireType=pt}function Nr(c,d,v){o.hasOwnProperty(c)||ye("Replacing nonexistant public symbol"),o[c].overloadTable!==void 0&&v!==void 0?o[c].overloadTable[v]=d:(o[c]=d,o[c].argCount=v)}var nr=(c,d,v)=>{var E=o["dynCall_"+c];return v&&v.length?E.apply(null,[d].concat(v)):E.call(null,d)},ot=[],Mt=c=>{var d=ot[c];return d||(c>=ot.length&&(ot.length=c+1),ot[c]=d=z.get(c)),d},ir=(c,d,v)=>{if(c.includes("j"))return nr(c,d,v);var E=Mt(d).apply(null,v);return E},un=(c,d)=>{var v=[];return function(){return v.length=0,Object.assign(v,arguments),ir(c,d,v)}};function Dr(c,d){c=Me(c);function v(){return c.includes("j")?un(c,d):Mt(d)}var E=v();return typeof E!="function"&&le(`unknown function pointer with signature ${c}: ${d}`),E}function Pr(c,d){var v=Ee(d,function(E){this.name=d,this.message=E;var A=new Error(E).stack;A!==void 0&&(this.stack=this.toString()+`
  24. `+A.replace(/^Error(:[^\n]*)?\n/,""))});return v.prototype=Object.create(c.prototype),v.prototype.constructor=v,v.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},v}var xt=void 0;function Ye(c){var d=Wt(c),v=Me(d);return or(d),v}function gt(c,d){var v=[],E={};function A(M){if(!E[M]&&!gr[M]){if(et[M]){et[M].forEach(A);return}v.push(M),E[M]=!0}}throw d.forEach(A),new xt(`${c}: `+v.map(Ye).join([", "]))}function fn(c,d,v,E,A,M,I,R,G,j,ne,oe,fe){ne=Me(ne),M=Dr(A,M),R&&(R=Dr(I,R)),j&&(j=Dr(G,j)),fe=Dr(oe,fe);var pe=it(ne);tn(pe,function(){gt(`Cannot construct ${ne} due to unbound types`,[E])}),yr([c,d,v],E?[E]:[],function(Te){Te=Te[0];var Be,Re;E?(Be=Te.registeredClass,Re=Be.instancePrototype):Re=Qe.prototype;var fr=Ee(pe,function(){if(Object.getPrototypeOf(this)!==St)throw new q("Use 'new' to construct "+ne);if(Ge.constructor_body===void 0)throw new q(ne+" has no accessible constructor");var Ze=Ge.constructor_body[arguments.length];if(Ze===void 0)throw new q(`Tried to invoke ctor of ${ne} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(Ge.constructor_body).toString()}) parameters instead!`);return Ze.apply(this,arguments)}),St=Object.create(Re,{constructor:{value:fr}});fr.prototype=St;var Ge=new nn(ne,fr,St,fe,Be,M,R,j);Ge.baseClass&&(Ge.baseClass.__derivedClasses===void 0&&(Ge.baseClass.__derivedClasses=[]),Ge.baseClass.__derivedClasses.push(Ge));var Mn=new Ce(ne,Ge,!0,!1,!1),Or=new Ce(ne+"*",Ge,!1,!1,!1),Vt=new Ce(ne+" const*",Ge,!1,!0,!1);return Ot[c]={pointerType:Or,constPointerType:Vt},Nr(pe,fr),[Mn,Or,Vt]})}function It(c,d){for(var v=[],E=0;E<c;E++)v.push(K[d+E*4>>2]);return v}function ln(c){for(;c.length;){var d=c.pop(),v=c.pop();v(d)}}function jt(c,d){if(!(c instanceof Function))throw new TypeError(`new_ called with constructor type ${typeof c} which is not a function`);var v=Ee(c.name||"unknownFunctionName",function(){});v.prototype=c.prototype;var E=new v,A=c.apply(E,d);return A instanceof Object?A:E}function Se(c,d,v,E,A,M){var I=d.length;I<2&&le("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var R=d[1]!==null&&v!==null,G=!1,j=1;j<d.length;++j)if(d[j]!==null&&d[j].destructorFunction===void 0){G=!0;break}for(var ne=d[0].name!=="void",oe="",fe="",j=0;j<I-2;++j)oe+=(j!==0?", ":"")+"arg"+j,fe+=(j!==0?", ":"")+"arg"+j+"Wired";var pe=`
  25. return function ${it(c)}(${oe}) {
  26. if (arguments.length !== ${I-2}) {
  27. throwBindingError('function ${c} called with ${arguments.length} arguments, expected ${I-2} args!');
  28. }`;G&&(pe+=`var destructors = [];
  29. `);var Te=G?"destructors":"null",Be=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],Re=[le,E,A,ln,d[0],d[1]];R&&(pe+="var thisWired = classParam.toWireType("+Te+`, this);
  30. `);for(var j=0;j<I-2;++j)pe+="var arg"+j+"Wired = argType"+j+".toWireType("+Te+", arg"+j+"); // "+d[j+2].name+`
  31. `,Be.push("argType"+j),Re.push(d[j+2]);if(R&&(fe="thisWired"+(fe.length>0?", ":"")+fe),pe+=(ne||M?"var rv = ":"")+"invoker(fn"+(fe.length>0?", ":"")+fe+`);
  32. `,G)pe+=`runDestructors(destructors);
  33. `;else for(var j=R?1:2;j<d.length;++j){var fr=j===1?"thisWired":"arg"+(j-2)+"Wired";d[j].destructorFunction!==null&&(pe+=fr+"_dtor("+fr+"); // "+d[j].name+`
  34. `,Be.push(fr+"_dtor"),Re.push(d[j].destructorFunction))}return ne&&(pe+=`var ret = retType.fromWireType(rv);
  35. return ret;
  36. `),pe+=`}
  37. `,Be.push(pe),jt(Function,Be).apply(null,Re)}function cn(c,d,v,E,A,M){var I=It(d,v);A=Dr(E,A),yr([],[c],function(R){R=R[0];var G=`constructor ${R.name}`;if(R.registeredClass.constructor_body===void 0&&(R.registeredClass.constructor_body=[]),R.registeredClass.constructor_body[d-1]!==void 0)throw new q(`Cannot register multiple constructors with identical number of parameters (${d-1}) for class '${R.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return R.registeredClass.constructor_body[d-1]=()=>{gt(`Cannot construct ${R.name} due to unbound types`,I)},yr([],I,function(j){return j.splice(1,0,null),R.registeredClass.constructor_body[d-1]=Se(G,j,null,A,M),[]}),[]})}function dn(c,d,v,E,A,M,I,R,G){var j=It(v,E);d=Me(d),M=Dr(A,M),yr([],[c],function(ne){ne=ne[0];var oe=`${ne.name}.${d}`;d.startsWith("@@")&&(d=Symbol[d.substring(2)]),R&&ne.registeredClass.pureVirtualFunctions.push(d);function fe(){gt(`Cannot call ${oe} due to unbound types`,j)}var pe=ne.registeredClass.instancePrototype,Te=pe[d];return Te===void 0||Te.overloadTable===void 0&&Te.className!==ne.name&&Te.argCount===v-2?(fe.argCount=v-2,fe.className=ne.name,pe[d]=fe):(Ut(pe,d,oe),pe[d].overloadTable[v-2]=fe),yr([],j,function(Be){var Re=Se(oe,Be,ne,M,I,G);return pe[d].overloadTable===void 0?(Re.argCount=v-2,pe[d]=Re):pe[d].overloadTable[v-2]=Re,[]}),[]})}function Cr(){Object.assign(Rr.prototype,{get(c){return this.allocated[c]},has(c){return this.allocated[c]!==void 0},allocate(c){var d=this.freelist.pop()||this.allocated.length;return this.allocated[d]=c,d},free(c){this.allocated[c]=void 0,this.freelist.push(c)}})}function Rr(){this.allocated=[void 0],this.freelist=[]}var je=new Rr;function Lt(c){c>=je.reserved&&--je.get(c).refcount===0&&je.free(c)}function hn(){for(var c=0,d=je.reserved;d<je.allocated.length;++d)je.allocated[d]!==void 0&&++c;return c}function Vr(){je.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),je.reserved=je.allocated.length,o.count_emval_handles=hn}var st={toValue:c=>(c||le("Cannot use deleted val. handle = "+c),je.get(c).value),toHandle:c=>{switch(c){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return je.allocate({refcount:1,value:c})}}};function pn(c,d){d=Me(d),xe(c,{name:d,fromWireType:function(v){var E=st.toValue(v);return Lt(v),E},toWireType:function(v,E){return st.toHandle(E)},argPackAdvance:8,readValueFromPointer:Fr,destructorFunction:null})}function yt(c){if(c===null)return"null";var d=typeof c;return d==="object"||d==="array"||d==="function"?c.toString():""+c}function $r(c,d){switch(d){case 2:return function(v){return this.fromWireType(we[v>>2])};case 3:return function(v){return this.fromWireType(Je[v>>3])};default:throw new TypeError("Unknown float type: "+c)}}function vn(c,d,v){var E=U(v);d=Me(d),xe(c,{name:d,fromWireType:function(A){return A},toWireType:function(A,M){return M},argPackAdvance:8,readValueFromPointer:$r(d,E),destructorFunction:null})}function mn(c,d,v){switch(d){case 0:return v?function(A){return ce[A]}:function(A){return X[A]};case 1:return v?function(A){return ie[A>>1]}:function(A){return Oe[A>>1]};case 2:return v?function(A){return ee[A>>2]}:function(A){return K[A>>2]};default:throw new TypeError("Unknown integer type: "+c)}}function gn(c,d,v,E,A){d=Me(d);var M=U(v),I=oe=>oe;if(E===0){var R=32-8*v;I=oe=>oe<<R>>>R}var G=d.includes("unsigned"),j=(oe,fe)=>{},ne;G?ne=function(oe,fe){return j(fe,this.name),fe>>>0}:ne=function(oe,fe){return j(fe,this.name),fe},xe(c,{name:d,fromWireType:I,toWireType:ne,argPackAdvance:8,readValueFromPointer:mn(d,M,E!==0),destructorFunction:null})}function yn(c,d,v){var E=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],A=E[d];function M(I){I=I>>2;var R=K,G=R[I],j=R[I+1];return new A(R.buffer,j,G)}v=Me(v),xe(c,{name:v,fromWireType:M,argPackAdvance:8,readValueFromPointer:M},{ignoreDuplicateRegistrations:!0})}var $e=(c,d,v,E)=>{if(!(E>0))return 0;for(var A=v,M=v+E-1,I=0;I<c.length;++I){var R=c.charCodeAt(I);if(R>=55296&&R<=57343){var G=c.charCodeAt(++I);R=65536+((R&1023)<<10)|G&1023}if(R<=127){if(v>=M)break;d[v++]=R}else if(R<=2047){if(v+1>=M)break;d[v++]=192|R>>6,d[v++]=128|R&63}else if(R<=65535){if(v+2>=M)break;d[v++]=224|R>>12,d[v++]=128|R>>6&63,d[v++]=128|R&63}else{if(v+3>=M)break;d[v++]=240|R>>18,d[v++]=128|R>>12&63,d[v++]=128|R>>6&63,d[v++]=128|R&63}}return d[v]=0,v-A},wn=(c,d,v)=>$e(c,X,d,v),_n=c=>{for(var d=0,v=0;v<c.length;++v){var E=c.charCodeAt(v);E<=127?d++:E<=2047?d+=2:E>=55296&&E<=57343?(d+=4,++v):d+=3}return d},ur=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,at=(c,d,v)=>{for(var E=d+v,A=d;c[A]&&!(A>=E);)++A;if(A-d>16&&c.buffer&&ur)return ur.decode(c.subarray(d,A));for(var M="";d<A;){var I=c[d++];if(!(I&128)){M+=String.fromCharCode(I);continue}var R=c[d++]&63;if((I&224)==192){M+=String.fromCharCode((I&31)<<6|R);continue}var G=c[d++]&63;if((I&240)==224?I=(I&15)<<12|R<<6|G:I=(I&7)<<18|R<<12|G<<6|c[d++]&63,I<65536)M+=String.fromCharCode(I);else{var j=I-65536;M+=String.fromCharCode(55296|j>>10,56320|j&1023)}}return M},bn=(c,d)=>c?at(X,c,d):"";function En(c,d){d=Me(d);var v=d==="std::string";xe(c,{name:d,fromWireType:function(E){var A=K[E>>2],M=E+4,I;if(v)for(var R=M,G=0;G<=A;++G){var j=M+G;if(G==A||X[j]==0){var ne=j-R,oe=bn(R,ne);I===void 0?I=oe:(I+=String.fromCharCode(0),I+=oe),R=j+1}}else{for(var fe=new Array(A),G=0;G<A;++G)fe[G]=String.fromCharCode(X[M+G]);I=fe.join("")}return or(E),I},toWireType:function(E,A){A instanceof ArrayBuffer&&(A=new Uint8Array(A));var M,I=typeof A=="string";I||A instanceof Uint8Array||A instanceof Uint8ClampedArray||A instanceof Int8Array||le("Cannot pass non-string to std::string"),v&&I?M=_n(A):M=A.length;var R=Xr(4+M+1),G=R+4;if(K[R>>2]=M,v&&I)wn(A,G,M+1);else if(I)for(var j=0;j<M;++j){var ne=A.charCodeAt(j);ne>255&&(or(G),le("String has UTF-16 code units that do not fit in 8 bits")),X[G+j]=ne}else for(var j=0;j<M;++j)X[G+j]=A[j];return E!==null&&E.push(or,R),R},argPackAdvance:8,readValueFromPointer:Fr,destructorFunction:function(E){or(E)}})}var Le=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,Pn=(c,d)=>{for(var v=c,E=v>>1,A=E+d/2;!(E>=A)&&Oe[E];)++E;if(v=E<<1,v-c>32&&Le)return Le.decode(X.subarray(c,v));for(var M="",I=0;!(I>=d/2);++I){var R=ie[c+I*2>>1];if(R==0)break;M+=String.fromCharCode(R)}return M},wt=(c,d,v)=>{if(v===void 0&&(v=2147483647),v<2)return 0;v-=2;for(var E=d,A=v<c.length*2?v/2:c.length,M=0;M<A;++M){var I=c.charCodeAt(M);ie[d>>1]=I,d+=2}return ie[d>>1]=0,d-E},_t=c=>c.length*2,Gr=(c,d)=>{for(var v=0,E="";!(v>=d/4);){var A=ee[c+v*4>>2];if(A==0)break;if(++v,A>=65536){var M=A-65536;E+=String.fromCharCode(55296|M>>10,56320|M&1023)}else E+=String.fromCharCode(A)}return E},Cn=(c,d,v)=>{if(v===void 0&&(v=2147483647),v<4)return 0;for(var E=d,A=E+v-4,M=0;M<c.length;++M){var I=c.charCodeAt(M);if(I>=55296&&I<=57343){var R=c.charCodeAt(++M);I=65536+((I&1023)<<10)|R&1023}if(ee[d>>2]=I,d+=4,d+4>A)break}return ee[d>>2]=0,d-E},bt=c=>{for(var d=0,v=0;v<c.length;++v){var E=c.charCodeAt(v);E>=55296&&E<=57343&&++v,d+=4}return d},$n=function(c,d,v){v=Me(v);var E,A,M,I,R;d===2?(E=Pn,A=wt,I=_t,M=()=>Oe,R=1):d===4&&(E=Gr,A=Cn,I=bt,M=()=>K,R=2),xe(c,{name:v,fromWireType:function(G){for(var j=K[G>>2],ne=M(),oe,fe=G+4,pe=0;pe<=j;++pe){var Te=G+4+pe*d;if(pe==j||ne[Te>>R]==0){var Be=Te-fe,Re=E(fe,Be);oe===void 0?oe=Re:(oe+=String.fromCharCode(0),oe+=Re),fe=Te+d}}return or(G),oe},toWireType:function(G,j){typeof j!="string"&&le(`Cannot pass non-string to C++ string type ${v}`);var ne=I(j),oe=Xr(4+ne+d);return K[oe>>2]=ne>>R,A(j,oe+4,ne+d),G!==null&&G.push(or,oe),oe},argPackAdvance:8,readValueFromPointer:Fr,destructorFunction:function(G){or(G)}})};function Et(c,d){d=Me(d),xe(c,{isVoid:!0,name:d,argPackAdvance:0,fromWireType:function(){},toWireType:function(v,E){}})}var Pt={};function Tn(c){var d=Pt[c];return d===void 0?Me(c):d}var Ct=[];function Sn(c,d,v,E){c=Ct[c],d=st.toValue(d),v=Tn(v),c(d,v,null,E)}function $t(c){var d=Ct.length;return Ct.push(c),d}function ge(c,d){var v=gr[c];return v===void 0&&le(d+" has unknown type "+Ye(c)),v}function Tt(c,d){for(var v=new Array(c),E=0;E<c;++E)v[E]=ge(K[d+E*4>>2],"parameter "+E);return v}var Bt=[];function kn(c,d){var v=Tt(c,d),E=v[0],A=E.name+"_$"+v.slice(1).map(function(Te){return Te.name}).join("_")+"$",M=Bt[A];if(M!==void 0)return M;for(var I=["retType"],R=[E],G="",j=0;j<c-1;++j)G+=(j!==0?", ":"")+"arg"+j,I.push("argType"+j),R.push(v[1+j]);for(var ne=it("methodCaller_"+A),oe="return function "+ne+`(handle, name, destructors, args) {
  38. `,fe=0,j=0;j<c-1;++j)oe+=" var arg"+j+" = argType"+j+".readValueFromPointer(args"+(fe?"+"+fe:"")+`);
  39. `,fe+=v[j+1].argPackAdvance;oe+=" var rv = handle[name]("+G+`);
  40. `;for(var j=0;j<c-1;++j)v[j+1].deleteObject&&(oe+=" argType"+j+".deleteObject(arg"+j+`);
  41. `);E.isVoid||(oe+=` return retType.toWireType(destructors, rv);
  42. `),oe+=`};
  43. `,I.push(oe);var pe=jt(Function,I).apply(null,R);return M=$t(pe),Bt[A]=M,M}var Tr=()=>{Pe("")},Ht;Ht=()=>performance.now();var qr=(c,d,v)=>X.copyWithin(c,d,d+v),An=c=>{Pe("OOM")},Fn=c=>{X.length,An()},Dn=[null,[],[]],Rn=(c,d)=>{var v=Dn[c];d===0||d===10?((c===1?F:H)(at(v,0)),v.length=0):v.push(d)},On=(c,d,v,E)=>{for(var A=0,M=0;M<v;M++){var I=K[d>>2],R=K[d+4>>2];d+=8;for(var G=0;G<R;G++)Rn(c,X[I+G]);A+=R}return K[E>>2]=A,0};Q(),q=o.BindingError=class extends Error{constructor(d){super(d),this.name="BindingError"}},rt=o.InternalError=class extends Error{constructor(d){super(d),this.name="InternalError"}},V(),en(),an(),xt=o.UnboundTypeError=Pr(Error,"UnboundTypeError"),Cr(),Vr();var Un={o:Qt,r:Yt,m:jr,q:fn,p:cn,d:dn,u:pn,k:vn,b:gn,a:yn,j:En,g:$n,n:Et,e:Sn,l:Lt,h:kn,f:Tr,c:Ht,t:qr,s:Fn,i:On};We();var or=c=>(or=N.x)(c),Xr=c=>(Xr=N.y)(c),Wt=c=>(Wt=N.A)(c);o.__embind_initialize_bindings=()=>(o.__embind_initialize_bindings=N.B)();var zt=c=>(zt=N.C)(c);o.dynCall_jiji=(c,d,v,E,A)=>(o.dynCall_jiji=N.D)(c,d,v,E,A);var ut;mr=function c(){ut||Nt(),ut||(mr=c)};function Nt(){if(He>0||(pr(),He>0))return;function c(){ut||(ut=!0,o.calledRun=!0,!B&&(Zr(),h(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),kr()))}o.setStatus?(o.setStatus("Running..."),setTimeout(function(){setTimeout(function(){o.setStatus("")},1),c()},1)):c()}if(o.preInit)for(typeof o.preInit=="function"&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return Nt(),a.ready}})();class bo extends Xt{constructor(a){super(Xi,a?.wasmPath?fetch(a.wasmPath).then(o=>o.arrayBuffer()):void 0,a?.workerMode,a?.canvas,a?.yuvMode)}}var Ki=Object.defineProperty,Qi=Object.getOwnPropertyDescriptor,Kn=(p,a,o,h)=>{for(var y=h>1?void 0:h?Qi(a,o):a,_=p.length-1,b;_>=0;_--)(b=p[_])&&(y=(h?b(a,o,y):b(y))||y);return h&&y&&Ki(a,o,y),y};class Qn extends de{async initialize(){this.decoder=new VideoDecoder({output:a=>{this.emit(ft.VideoFrame,a)},error:a=>{this.close(),this.emit(ft.Error,a)}})}configure(a){this.config=a,!a.description&&a.codec!=="av1"&&(this.config[a.codec]={format:"annexb"}),this.decoder.configure({...a,codec:this.getCodec(a)})}getCodec(a){switch(a.codec){case"hevc":return"hvc1.1.6.L0.12.34.56.78.9A.BC";case"av1":return"av01.0.05M.08";case"avc":return"avc1.420028";default:return a.codec}}decode(a){this.decoder.state==="configured"&&this.decoder.decode(new EncodedVideoChunk(a))}flush(){this.decoder.flush()}reset(){this.decoder.reset()}close(){this.decoder.state!=="closed"&&this.decoder.close()}}Kn([ke([de.INIT,"closed"],"initialized")],Qn.prototype,"initialize",1);Kn([ke("initialized","configured",{sync:!0})],Qn.prototype,"configure",1);Kn([Ti("configured")],Qn.prototype,"decode",1);Kn([ke([],de.INIT,{sync:!0})],Qn.prototype,"reset",1);Kn([ke([],"closed",{ignoreError:!0,sync:!0})],Qn.prototype,"close",1);const O=class{static box(p,...a){let o=8,h=a.length;for(let b=0;b<h;b++)o+=a[b].byteLength;let y=new Uint8Array(o);y[0]=o>>>24&255,y[1]=o>>>16&255,y[2]=o>>>8&255,y[3]=o&255,y.set(p,4);let _=8;for(let b=0;b<h;b++)y.set(a[b],_),_+=a[b].byteLength;return y}static generateInitSegment(p){let a=O.box(O.types.ftyp,O.constants.FTYP),o=O.moov(p),h=new Uint8Array(a.byteLength+o.byteLength);return h.set(a,0),h.set(o,a.byteLength),h}static moov(p){let a=O.mvhd(p.timescale,p.duration),o=O.trak(p),h=O.mvex(p);return O.box(O.types.moov,a,o,h)}static mvhd(p,a){return O.box(O.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,p>>>24&255,p>>>16&255,p>>>8&255,p&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]))}static trak(p){return O.box(O.types.trak,O.tkhd(p),O.mdia(p))}static tkhd(p){let a=p.id,o=p.duration,h=p.presentWidth,y=p.presentHeight;return O.box(O.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,a>>>24&255,a>>>16&255,a>>>8&255,a&255,0,0,0,0,o>>>24&255,o>>>16&255,o>>>8&255,o&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,h>>>8&255,h&255,0,0,y>>>8&255,y&255,0,0]))}static mdia(p){return O.box(O.types.mdia,O.mdhd(p),O.hdlr(p),O.minf(p))}static mdhd(p){let a=p.timescale,o=p.duration;return O.box(O.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,a>>>24&255,a>>>16&255,a>>>8&255,a&255,o>>>24&255,o>>>16&255,o>>>8&255,o&255,85,196,0,0]))}static hdlr(p){let a=null;return p.type==="audio"?a=O.constants.HDLR_AUDIO:a=O.constants.HDLR_VIDEO,O.box(O.types.hdlr,a)}static minf(p){let a=null;return p.type==="audio"?a=O.box(O.types.smhd,O.constants.SMHD):a=O.box(O.types.vmhd,O.constants.VMHD),O.box(O.types.minf,a,O.dinf(),O.stbl(p))}static dinf(){return O.box(O.types.dinf,O.box(O.types.dref,O.constants.DREF))}static stbl(p){return O.box(O.types.stbl,O.stsd(p),O.box(O.types.stts,O.constants.STTS),O.box(O.types.stsc,O.constants.STSC),O.box(O.types.stsz,O.constants.STSZ),O.box(O.types.stco,O.constants.STCO))}static stsd(p){return p.type==="audio"?O.box(O.types.stsd,O.constants.STSD_PREFIX,O.mp4a(p)):p.videoType==="avc"?O.box(O.types.stsd,O.constants.STSD_PREFIX,O.avc1(p)):O.box(O.types.stsd,O.constants.STSD_PREFIX,O.hvc1(p))}static mp4a(p){let a=p.channelCount,o=p.audioSampleRate,h=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,a,0,16,0,0,0,0,o>>>8&255,o&255,0,0]);return O.box(O.types.mp4a,h,O.esds(p))}static esds(p){let a=p.config||[],o=a.length,h=new Uint8Array([0,0,0,0,3,23+o,0,1,0,4,15+o,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([o]).concat(a).concat([6,1,2]));return O.box(O.types.esds,h)}static avc1(p){let a=p.avcc;const o=p.codecWidth,h=p.codecHeight;let y=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,o>>>8&255,o&255,h>>>8&255,h&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return O.box(O.types.avc1,y,O.box(O.types.avcC,a))}static hvc1(p){let a=p.avcc;const o=p.codecWidth,h=p.codecHeight;let y=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,o>>>8&255,o&255,h>>>8&255,h&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return O.box(O.types.hvc1,y,O.box(O.types.hvcC,a))}static mvex(p){return O.box(O.types.mvex,O.trex(p))}static trex(p){let a=p.id,o=new Uint8Array([0,0,0,0,a>>>24&255,a>>>16&255,a>>>8&255,a&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return O.box(O.types.trex,o)}static moof(p,a){return O.box(O.types.moof,O.mfhd(p.sequenceNumber),O.traf(p,a))}static mfhd(p){let a=new Uint8Array([0,0,0,0,p>>>24&255,p>>>16&255,p>>>8&255,p&255]);return O.box(O.types.mfhd,a)}static traf(p,a){let o=p.id,h=O.box(O.types.tfhd,new Uint8Array([0,0,0,0,o>>>24&255,o>>>16&255,o>>>8&255,o&255])),y=O.box(O.types.tfdt,new Uint8Array([0,0,0,0,a>>>24&255,a>>>16&255,a>>>8&255,a&255])),_=O.sdtp(p),b=O.trun(p,_.byteLength+16+16+8+16+8+8);return O.box(O.types.traf,h,y,b,_)}static sdtp(p){let a=new Uint8Array(5),o=p.flags;return a[4]=o.isLeading<<6|o.dependsOn<<4|o.isDependedOn<<2|o.hasRedundancy,O.box(O.types.sdtp,a)}static trun(p,a){let o=28,h=new Uint8Array(o);a+=8+o,h.set([0,0,15,1,0,0,0,1,a>>>24&255,a>>>16&255,a>>>8&255,a&255],0);let y=p.duration,_=p.size,b=p.flags,D=p.cts;return h.set([y>>>24&255,y>>>16&255,y>>>8&255,y&255,_>>>24&255,_>>>16&255,_>>>8&255,_&255,b.isLeading<<2|b.dependsOn,b.isDependedOn<<6|b.hasRedundancy<<4|b.isNonSync,0,0,D>>>24&255,D>>>16&255,D>>>8&255,D&255],12),O.box(O.types.trun,h)}static mdat(p){return O.box(O.types.mdat,p)}};let Xe=O;Xe.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};Xe.constants={FTYP:new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),STSD_PREFIX:new Uint8Array([0,0,0,0,0,0,0,1]),STTS:new Uint8Array([0,0,0,0,0,0,0,0]),STSC:new Uint8Array([0,0,0,0,0,0,0,0]),STCO:new Uint8Array([0,0,0,0,0,0,0,0]),STSZ:new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),HDLR_VIDEO:new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),HDLR_AUDIO:new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),DREF:new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),SMHD:new Uint8Array([0,0,0,0,0,0,0,0]),VMHD:new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])};for(let p in Xe.types)Xe.types.hasOwnProperty(p)&&(Xe.types[p]=[p.charCodeAt(0),p.charCodeAt(1),p.charCodeAt(2),p.charCodeAt(3)]);Xe.constants.STSC=Xe.constants.STTS;Xe.constants.STCO=Xe.constants.STTS;class Yi{constructor(a){this.TAG="ExpGolomb",this._buffer=a,this._buffer_index=0,this._total_bytes=a.byteLength,this._total_bits=a.byteLength*8,this._current_word=0,this._current_word_bits_left=0}destroy(){this._buffer=new Uint8Array(0)}_fillCurrentWord(){const a=this._total_bytes-this._buffer_index;if(a<=0)throw new Error("ExpGolomb: _fillCurrentWord() but no bytes available");const o=Math.min(4,a),h=new Uint8Array(4);h.set(this._buffer.subarray(this._buffer_index,this._buffer_index+o)),this._current_word=new DataView(h.buffer).getUint32(0,!1),this._buffer_index+=o,this._current_word_bits_left=o*8}readBits(a){if(a>32)throw new Error("ExpGolomb: readBits() bits exceeded max 32bits!");if(a<=this._current_word_bits_left){const b=this._current_word>>>32-a;return this._current_word<<=a,this._current_word_bits_left-=a,b}let o=this._current_word_bits_left?this._current_word:0;o=o>>>32-this._current_word_bits_left;const h=a-this._current_word_bits_left;this._fillCurrentWord();const y=Math.min(h,this._current_word_bits_left),_=this._current_word>>>32-y;return this._current_word<<=y,this._current_word_bits_left-=y,o=o<<y|_,o}readBool(){return this.readBits(1)===1}readByte(){return this.readBits(8)}_skipLeadingZero(){let a;for(a=0;a<this._current_word_bits_left;a++)if(this._current_word&2147483648>>>a)return this._current_word<<=a,this._current_word_bits_left-=a,a;return this._fillCurrentWord(),a+this._skipLeadingZero()}readUEG(){const a=this._skipLeadingZero();return this.readBits(a+1)-1}readSEG(){const a=this.readUEG();return a&1?a+1>>>1:-1*(a>>>1)}}class Ur{static _ebsp2rbsp(a){let o=a,h=o.byteLength,y=new Uint8Array(h),_=0;for(let b=0;b<h;b++)b>=2&&o[b]===3&&o[b-1]===0&&o[b-2]===0||(y[_]=o[b],_++);return new Uint8Array(y.buffer,0,_)}static parseSPS(a){let o=a.subarray(1,4),h="avc1.";for(let _e=0;_e<3;_e++){let be=o[_e].toString(16);be.length<2&&(be="0"+be),h+=be}let y=Ur._ebsp2rbsp(a),_=new Yi(y);_.readByte();let b=_.readByte();_.readByte();let D=_.readByte();_.readUEG();let S=Ur.getProfileString(b),w=Ur.getLevelString(D),C=1,F=420,H=[0,420,422,444],te=8,Z=8;if((b===100||b===110||b===122||b===244||b===44||b===83||b===86||b===118||b===128||b===138||b===144)&&(C=_.readUEG(),C===3&&_.readBits(1),C<=3&&(F=H[C]),te=_.readUEG()+8,Z=_.readUEG()+8,_.readBits(1),_.readBool())){let _e=C!==3?8:12;for(let be=0;be<_e;be++)_.readBool()&&(be<6?Ur._skipScalingList(_,16):Ur._skipScalingList(_,64))}_.readUEG();let N=_.readUEG();if(N===0)_.readUEG();else if(N===1){_.readBits(1),_.readSEG(),_.readSEG();let _e=_.readUEG();for(let be=0;be<_e;be++)_.readSEG()}let B=_.readUEG();_.readBits(1);let ce=_.readUEG(),X=_.readUEG(),ie=_.readBits(1);ie===0&&_.readBits(1),_.readBits(1);let Oe=0,ee=0,K=0,we=0;_.readBool()&&(Oe=_.readUEG(),ee=_.readUEG(),K=_.readUEG(),we=_.readUEG());let W=1,z=1,dr=0,hr=!0,Sr=0,pr=0;if(_.readBool()){if(_.readBool()){let _e=_.readByte(),be=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],Pe=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];_e>0&&_e<16?(W=be[_e-1],z=Pe[_e-1]):_e===255&&(W=_.readByte()<<8|_.readByte(),z=_.readByte()<<8|_.readByte())}if(_.readBool()&&_.readBool(),_.readBool()&&(_.readBits(4),_.readBool()&&_.readBits(24)),_.readBool()&&(_.readUEG(),_.readUEG()),_.readBool()){let _e=_.readBits(32),be=_.readBits(32);hr=_.readBool(),Sr=be,pr=_e*2,dr=Sr/pr}}let kr=1;(W!==1||z!==1)&&(kr=W/z);let vr=0,Mr=0;if(C===0)vr=1,Mr=2-ie;else{let _e=C===3?1:2,be=C===1?2:1;vr=_e,Mr=be*(2-ie)}let xr=(ce+1)*16,He=(2-ie)*((X+1)*16);xr-=(Oe+ee)*vr,He-=(K+we)*Mr;let mr=Math.ceil(xr*kr);return _.destroy(),_=null,{codec_mimetype:h,profile_idc:b,level_idc:D,profile_string:S,level_string:w,chroma_format_idc:C,bit_depth:te,bit_depth_luma:te,bit_depth_chroma:Z,ref_frames:B,chroma_format:F,chroma_format_string:Ur.getChromaFormatString(F),frame_rate:{fixed:hr,fps:dr,fps_den:pr,fps_num:Sr},sar_ratio:{width:W,height:z},codec_size:{width:xr,height:He},present_size:{width:mr,height:He}}}static _skipScalingList(a,o){let h=8,y=8,_=0;for(let b=0;b<o;b++)y!==0&&(_=a.readSEG(),y=(h+_+256)%256),h=y===0?h:y}static getProfileString(a){switch(a){case 66:return"Baseline";case 77:return"Main";case 88:return"Extended";case 100:return"High";case 110:return"High10";case 122:return"High422";case 244:return"High444";default:return"Unknown"}}static getLevelString(a){return(a/10).toFixed(1)}static getChromaFormatString(a){switch(a){case 420:return"4:2:0";case 422:return"4:2:2";case 444:return"4:4:4";default:return"Unknown"}}}function Zi({sps:p,pps:a}){let o=8+p.byteLength+1+2+a.byteLength,h=!1;const y=Ur.parseSPS(p);p[3]!==66&&p[3]!==77&&p[3]!==88&&(h=!0,o+=4);let _=new Uint8Array(o);_[0]=1,_[1]=p[1],_[2]=p[2],_[3]=p[3],_[4]=255,_[5]=225;let b=p.byteLength;_[6]=b>>>8,_[7]=b&255;let D=8;_.set(p,8),D+=b,_[D]=1;let S=a.byteLength;_[D+1]=S>>>8,_[D+2]=S&255,_.set(a,D+3),D+=3+S,h&&(_[D]=252|y.chroma_format_idc,_[D+1]=248|y.bit_depth_luma-8,_[D+2]=248|y.bit_depth_chroma-8,_[D+3]=0,D+=4);const w=[23,0,0,0,0],C=new Uint8Array(w.length+_.byteLength);return C.set(w,0),C.set(_,w.length),C}var Ji=Object.defineProperty,eo=Object.getOwnPropertyDescriptor,si=(p,a,o,h)=>{for(var y=h>1?void 0:h?eo(a,o):a,_=p.length-1,b;_>=0;_--)(b=p[_])&&(y=(h?b(a,o,y):b(y))||y);return h&&y&&Ji(a,o,y),y};class ai extends de{constructor(){super(...arguments),this.sourceBufferCache=[]}decode(a){if(!!this.config?.description)try{const h=a.data.byteLength,y=8+h,_=new Uint8Array(y);new DataView(_.buffer,0).setUint32(0,y,!1),_.set(Xe.types.mdat,4);const D={id:1,sequenceNumber:++this.sequenceNumber,size:h,dts:a.timestamp,cts:a.timestamp,isKeyframe:a.type==="key",data:a.data,flags:{isLeading:0,dependsOn:2,isDependedOn:1,hasRedundancy:0,isNonSync:0},duration:40},S=Xe.moof(D,a.timestamp),w=new Uint8Array(S.byteLength+_.byteLength);w.set(S,0),w.set(_,S.byteLength),this.sourceBuffer?.updating?this.sourceBufferCache.push(w):this.sourceBuffer?.appendBuffer(w)}catch(h){this.element?.error,console.error(h)}else{const h=a.data instanceof ArrayBuffer?new Uint8Array(a.data):a.data;let y,_,b=!1;const S=(C=>{const F=[];for(let H=0;H<C.length-3;H++)C[H]===0&&C[H+1]===0&&C[H+2]===0&&C[H+3]===1?F.push(H+4):C[H]===0&&C[H+1]===0&&C[H+2]===1&&F.push(H+3);return F})(h),w=[];for(let C=0;C<S.length;C++){const F=S[C],H=C<S.length-1?S[C+1]:h.length;w.push(h.subarray(F,H))}if(w.forEach((C,F)=>{const H=C[0]&31;H===7?y=C:H===8?_=C:H===5&&(b=!0)}),y&&_&&!this.sourceBuffer){const C=Ur.parseSPS(y),F={id:1,type:"video",timescale:1e3,duration:0,avcc:Zi({sps:y,pps:_}),codecWidth:C.codec_size.width,codecHeight:C.codec_size.height,presentWidth:C.present_size.width,presentHeight:C.present_size.height,videoType:"avc"};this.sourceBuffer=this.mse.addSourceBuffer(`video/mp4; codecs="${C.codec_mimetype}"`),this.sourceBuffer.appendBuffer(Xe.generateInitSegment(F)),this.sourceBuffer.addEventListener("updateend",()=>{this.sourceBufferCache.length&&this.sourceBuffer.appendBuffer(this.sourceBufferCache.shift())})}else{const C=w.reduce((X,ie)=>X+ie.length+4,0),F=8+C,H=new Uint8Array(F),te=new DataView(H.buffer,0);te.setUint32(0,F,!1),H.set(Xe.types.mdat,4);let Z=8;w.forEach(X=>{te.setUint32(Z,X.length,!1),H.set(X,Z+4),Z+=X.length+4});const N={id:1,sequenceNumber:++this.sequenceNumber,size:C,dts:a.timestamp,cts:a.timestamp,isKeyframe:b,data:h,flags:{isLeading:0,dependsOn:2,isDependedOn:1,hasRedundancy:0,isNonSync:0},duration:40},B=Xe.moof(N,a.timestamp),ce=new Uint8Array(B.byteLength+H.byteLength);ce.set(B,0),ce.set(H,B.byteLength),this.sourceBuffer?.updating?this.sourceBufferCache.push(ce):this.sourceBuffer?.appendBuffer(ce)}}}flush(){throw new Error("Method not implemented.")}reset(){throw new Error("Method not implemented.")}close(){this.src&&URL.revokeObjectURL(this.src)}initialize(a){return this.mse=new MediaSource,this.src=URL.createObjectURL(this.mse),this.element=a,a.src=this.src,new Promise(o=>{this.mse.addEventListener("sourceopen",o)})}configure(a){if(this.config=a,a.description){const o=a.description,h=6,y=o[h]<<8|o[h+1],_=o.subarray(h+2,h+2+y),b=Ur.parseSPS(_),D={id:1,type:"video",timescale:1e3,duration:0,avcc:o,codecWidth:b.codec_size.width,codecHeight:b.codec_size.height,presentWidth:b.present_size.width,presentHeight:b.present_size.height,videoType:"avc"};this.sourceBuffer=this.mse.addSourceBuffer(`video/mp4; codecs="${b.codec_mimetype}"`),this.sourceBuffer.appendBuffer(Xe.generateInitSegment(D)),this.sourceBuffer.addEventListener("updateend",()=>{this.sourceBufferCache.length&&this.sourceBuffer.appendBuffer(this.sourceBufferCache.shift())})}}}si([ke([],de.INIT,{sync:!0})],ai.prototype,"reset",1);si([ke([],"closed",{ignoreError:!0,sync:!0})],ai.prototype,"close",1);si([ke([de.INIT,"closed"],"initialized")],ai.prototype,"initialize",1);si([ke("initialized","configured",{sync:!0})],ai.prototype,"configure",1);var ro=(()=>{var p=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(a={}){var o=a,h,y;o.ready=new Promise((e,r)=>{h=e,y=r});var _=Object.assign({},o),b="./this.program",D=typeof window=="object",S=typeof importScripts=="function";typeof process=="object"&&typeof process.versions=="object"&&process.versions.node;var w="";function C(e){return o.locateFile?o.locateFile(e,w):w+e}var F,H,te;(D||S)&&(S?w=self.location.href:typeof document<"u"&&document.currentScript&&(w=document.currentScript.src),p&&(w=p),w.indexOf("blob:")!==0?w=w.substr(0,w.replace(/[?#].*/,"").lastIndexOf("/")+1):w="",F=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.send(null),r.responseText},S&&(te=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),H=(e,r,t)=>{var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=()=>{if(n.status==200||n.status==0&&n.response){r(n.response);return}t()},n.onerror=t,n.send(null)});var Z=o.print||console.log.bind(console),N=o.printErr||console.error.bind(console);Object.assign(o,_),_=null,o.arguments&&o.arguments,o.thisProgram&&(b=o.thisProgram),o.quit&&o.quit;var B;o.wasmBinary&&(B=o.wasmBinary),o.noExitRuntime,typeof WebAssembly!="object"&&Ue("no native wasm support detected");var ce,X,ie=!1;function Oe(e,r){e||Ue(r)}var ee,K,we,Je,W,z,dr,hr;function Sr(){var e=ce.buffer;o.HEAP8=ee=new Int8Array(e),o.HEAP16=we=new Int16Array(e),o.HEAP32=W=new Int32Array(e),o.HEAPU8=K=new Uint8Array(e),o.HEAPU16=Je=new Uint16Array(e),o.HEAPU32=z=new Uint32Array(e),o.HEAPF32=dr=new Float32Array(e),o.HEAPF64=hr=new Float64Array(e)}var pr,Zr=[],kr=[],vr=[];function Mr(){if(o.preRun)for(typeof o.preRun=="function"&&(o.preRun=[o.preRun]);o.preRun.length;)mr(o.preRun.shift());Ar(Zr)}function xr(){!o.noFSInit&&!i.init.initialized&&i.init(),i.ignorePermissions=!1,Ar(kr)}function He(){if(o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;)be(o.postRun.shift());Ar(vr)}function mr(e){Zr.unshift(e)}function _e(e){kr.unshift(e)}function be(e){vr.unshift(e)}var Pe=0,er=null;function ri(e){return e}function Ke(e){Pe++,o.monitorRunDependencies&&o.monitorRunDependencies(Pe)}function sr(e){if(Pe--,o.monitorRunDependencies&&o.monitorRunDependencies(Pe),Pe==0&&er){var r=er;er=null,r()}}function Ue(e){o.onAbort&&o.onAbort(e),e="Aborted("+e+")",N(e),ie=!0,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw y(r),r}var Ft="data:application/octet-stream;base64,";function ct(e){return e.startsWith(Ft)}var We;We="audiodec.wasm",ct(We)||(We=C(We));function Ir(e){if(e==We&&B)return new Uint8Array(B);if(te)return te(e);throw"both async and sync fetching of the wasm failed"}function Kt(e){return!B&&(D||S)&&typeof fetch=="function"?fetch(e,{credentials:"same-origin"}).then(r=>{if(!r.ok)throw"failed to load wasm binary file at '"+e+"'";return r.arrayBuffer()}).catch(()=>Ir(e)):Promise.resolve().then(()=>Ir(e))}function Jr(e,r,t){return Kt(e).then(n=>WebAssembly.instantiate(n,r)).then(n=>n).then(t,n=>{N("failed to asynchronously prepare wasm: "+n),Ue(n)})}function Qt(e,r,t,n){return!e&&typeof WebAssembly.instantiateStreaming=="function"&&!ct(r)&&typeof fetch=="function"?fetch(r,{credentials:"same-origin"}).then(s=>{var u=WebAssembly.instantiateStreaming(s,t);return u.then(n,function(l){return N("wasm streaming compile failed: "+l),N("falling back to ArrayBuffer instantiation"),Jr(r,t,n)})}):Jr(r,t,n)}function Yt(){var e={a:yi};function r(n,s){var u=n.exports;return X=u,ce=X.E,Sr(),pr=X.H,_e(X.F),sr(),u}Ke();function t(n){r(n.instance)}if(o.instantiateWasm)try{return o.instantiateWasm(e,r)}catch(n){N("Module.instantiateWasm callback failed with error: "+n),y(n)}return Qt(B,We,e,t).catch(y),{}}var U,Q,Ar=e=>{for(;e.length>0;)e.shift()(o)};function Me(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(r){z[this.ptr+4>>2]=r},this.get_type=function(){return z[this.ptr+4>>2]},this.set_destructor=function(r){z[this.ptr+8>>2]=r},this.get_destructor=function(){return z[this.ptr+8>>2]},this.set_caught=function(r){r=r?1:0,ee[this.ptr+12>>0]=r},this.get_caught=function(){return ee[this.ptr+12>>0]!=0},this.set_rethrown=function(r){r=r?1:0,ee[this.ptr+13>>0]=r},this.get_rethrown=function(){return ee[this.ptr+13>>0]!=0},this.init=function(r,t){this.set_adjusted_ptr(0),this.set_type(r),this.set_destructor(t)},this.set_adjusted_ptr=function(r){z[this.ptr+16>>2]=r},this.get_adjusted_ptr=function(){return z[this.ptr+16>>2]},this.get_exception_ptr=function(){var r=Ln(this.get_type());if(r)return z[this.excPtr>>2];var t=this.get_adjusted_ptr();return t!==0?t:this.excPtr}}var ar=0;function gr(e,r,t){var n=new Me(e);throw n.init(r,t),ar=e,ar}var et=e=>(W[In()>>2]=e,e),q={isAbs:e=>e.charAt(0)==="/",splitPath:e=>{var r=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return r.exec(e).slice(1)},normalizeArray:(e,r)=>{for(var t=0,n=e.length-1;n>=0;n--){var s=e[n];s==="."?e.splice(n,1):s===".."?(e.splice(n,1),t++):t&&(e.splice(n,1),t--)}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=q.isAbs(e),t=e.substr(-1)==="/";return e=q.normalizeArray(e.split("/").filter(n=>!!n),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=q.splitPath(e),t=r[0],n=r[1];return!t&&!n?".":(n&&(n=n.substr(0,n.length-1)),t+n)},basename:e=>{if(e==="/")return"/";e=q.normalize(e),e=e.replace(/\/$/,"");var r=e.lastIndexOf("/");return r===-1?e:e.substr(r+1)},join:function(){var e=Array.prototype.slice.call(arguments);return q.normalize(e.join("/"))},join2:(e,r)=>q.normalize(e+"/"+r)},le=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return e=>crypto.getRandomValues(e);Ue("initRandomDevice")},rt=e=>(rt=le())(e),ye={resolve:function(){for(var e="",r=!1,t=arguments.length-1;t>=-1&&!r;t--){var n=t>=0?arguments[t]:i.cwd();if(typeof n!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!n)return"";e=n+"/"+e,r=q.isAbs(n)}return e=q.normalizeArray(e.split("/").filter(s=>!!s),!r).join("/"),(r?"/":"")+e||"."},relative:(e,r)=>{e=ye.resolve(e).substr(1),r=ye.resolve(r).substr(1);function t(m){for(var $=0;$<m.length&&m[$]==="";$++);for(var k=m.length-1;k>=0&&m[k]==="";k--);return $>k?[]:m.slice($,k-$+1)}for(var n=t(e.split("/")),s=t(r.split("/")),u=Math.min(n.length,s.length),l=u,f=0;f<u;f++)if(n[f]!==s[f]){l=f;break}for(var g=[],f=l;f<n.length;f++)g.push("..");return g=g.concat(s.slice(l)),g.join("/")}},yr=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,ze=(e,r,t)=>{for(var n=r+t,s=r;e[s]&&!(s>=n);)++s;if(s-r>16&&e.buffer&&yr)return yr.decode(e.subarray(r,s));for(var u="";r<s;){var l=e[r++];if(!(l&128)){u+=String.fromCharCode(l);continue}var f=e[r++]&63;if((l&224)==192){u+=String.fromCharCode((l&31)<<6|f);continue}var g=e[r++]&63;if((l&240)==224?l=(l&15)<<12|f<<6|g:l=(l&7)<<18|f<<12|g<<6|e[r++]&63,l<65536)u+=String.fromCharCode(l);else{var m=l-65536;u+=String.fromCharCode(55296|m>>10,56320|m&1023)}}return u},xe=[],jr=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n<=127?r++:n<=2047?r+=2:n>=55296&&n<=57343?(r+=4,++t):r+=3}return r},Lr=(e,r,t,n)=>{if(!(n>0))return 0;for(var s=t,u=t+n-1,l=0;l<e.length;++l){var f=e.charCodeAt(l);if(f>=55296&&f<=57343){var g=e.charCodeAt(++l);f=65536+((f&1023)<<10)|g&1023}if(f<=127){if(t>=u)break;r[t++]=f}else if(f<=2047){if(t+1>=u)break;r[t++]=192|f>>6,r[t++]=128|f&63}else if(f<=65535){if(t+2>=u)break;r[t++]=224|f>>12,r[t++]=128|f>>6&63,r[t++]=128|f&63}else{if(t+3>=u)break;r[t++]=240|f>>18,r[t++]=128|f>>12&63,r[t++]=128|f>>6&63,r[t++]=128|f&63}}return r[t]=0,t-s};function Br(e,r,t){var n=t>0?t:jr(e)+1,s=new Array(n),u=Lr(e,s,0,s.length);return r&&(s.length=u),s}var dt=()=>{if(!xe.length){var e=null;if(typeof window<"u"&&typeof window.prompt=="function"?(e=window.prompt("Input: "),e!==null&&(e+=`
  44. `)):typeof readline=="function"&&(e=readline(),e!==null&&(e+=`
  45. `)),!e)return null;xe=Br(e,!0)}return xe.shift()},Ae={ttys:[],init:function(){},shutdown:function(){},register:function(e,r){Ae.ttys[e]={input:[],output:[],ops:r},i.registerDevice(e,Ae.stream_ops)},stream_ops:{open:function(e){var r=Ae.ttys[e.node.rdev];if(!r)throw new i.ErrnoError(43);e.tty=r,e.seekable=!1},close:function(e){e.tty.ops.fsync(e.tty)},fsync:function(e){e.tty.ops.fsync(e.tty)},read:function(e,r,t,n,s){if(!e.tty||!e.tty.ops.get_char)throw new i.ErrnoError(60);for(var u=0,l=0;l<n;l++){var f;try{f=e.tty.ops.get_char(e.tty)}catch{throw new i.ErrnoError(29)}if(f===void 0&&u===0)throw new i.ErrnoError(6);if(f==null)break;u++,r[t+l]=f}return u&&(e.node.timestamp=Date.now()),u},write:function(e,r,t,n,s){if(!e.tty||!e.tty.ops.put_char)throw new i.ErrnoError(60);try{for(var u=0;u<n;u++)e.tty.ops.put_char(e.tty,r[t+u])}catch{throw new i.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),u}},default_tty_ops:{get_char:function(e){return dt()},put_char:function(e,r){r===null||r===10?(Z(ze(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},fsync:function(e){e.output&&e.output.length>0&&(Z(ze(e.output,0)),e.output=[])},ioctl_tcgets:function(e){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets:function(e,r,t){return 0},ioctl_tiocgwinsz:function(e){return[24,80]}},default_tty1_ops:{put_char:function(e,r){r===null||r===10?(N(ze(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},fsync:function(e){e.output&&e.output.length>0&&(N(ze(e.output,0)),e.output=[])}}},tt=e=>{Ue()},L={ops_table:null,mount(e){return L.createNode(null,"/",16895,0)},createNode(e,r,t,n){if(i.isBlkdev(t)||i.isFIFO(t))throw new i.ErrnoError(63);L.ops_table||(L.ops_table={dir:{node:{getattr:L.node_ops.getattr,setattr:L.node_ops.setattr,lookup:L.node_ops.lookup,mknod:L.node_ops.mknod,rename:L.node_ops.rename,unlink:L.node_ops.unlink,rmdir:L.node_ops.rmdir,readdir:L.node_ops.readdir,symlink:L.node_ops.symlink},stream:{llseek:L.stream_ops.llseek}},file:{node:{getattr:L.node_ops.getattr,setattr:L.node_ops.setattr},stream:{llseek:L.stream_ops.llseek,read:L.stream_ops.read,write:L.stream_ops.write,allocate:L.stream_ops.allocate,mmap:L.stream_ops.mmap,msync:L.stream_ops.msync}},link:{node:{getattr:L.node_ops.getattr,setattr:L.node_ops.setattr,readlink:L.node_ops.readlink},stream:{}},chrdev:{node:{getattr:L.node_ops.getattr,setattr:L.node_ops.setattr},stream:i.chrdev_stream_ops}});var s=i.createNode(e,r,t,n);return i.isDir(s.mode)?(s.node_ops=L.ops_table.dir.node,s.stream_ops=L.ops_table.dir.stream,s.contents={}):i.isFile(s.mode)?(s.node_ops=L.ops_table.file.node,s.stream_ops=L.ops_table.file.stream,s.usedBytes=0,s.contents=null):i.isLink(s.mode)?(s.node_ops=L.ops_table.link.node,s.stream_ops=L.ops_table.link.stream):i.isChrdev(s.mode)&&(s.node_ops=L.ops_table.chrdev.node,s.stream_ops=L.ops_table.chrdev.stream),s.timestamp=Date.now(),e&&(e.contents[r]=s,e.timestamp=s.timestamp),s},getFileDataAsTypedArray(e){return e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0)},expandFileStorage(e,r){var t=e.contents?e.contents.length:0;if(!(t>=r)){var n=1024*1024;r=Math.max(r,t*(t<n?2:1.125)>>>0),t!=0&&(r=Math.max(r,256));var s=e.contents;e.contents=new Uint8Array(r),e.usedBytes>0&&e.contents.set(s.subarray(0,e.usedBytes),0)}},resizeFileStorage(e,r){if(e.usedBytes!=r)if(r==0)e.contents=null,e.usedBytes=0;else{var t=e.contents;e.contents=new Uint8Array(r),t&&e.contents.set(t.subarray(0,Math.min(r,e.usedBytes))),e.usedBytes=r}},node_ops:{getattr(e){var r={};return r.dev=i.isChrdev(e.mode)?e.id:1,r.ino=e.id,r.mode=e.mode,r.nlink=1,r.uid=0,r.gid=0,r.rdev=e.rdev,i.isDir(e.mode)?r.size=4096:i.isFile(e.mode)?r.size=e.usedBytes:i.isLink(e.mode)?r.size=e.link.length:r.size=0,r.atime=new Date(e.timestamp),r.mtime=new Date(e.timestamp),r.ctime=new Date(e.timestamp),r.blksize=4096,r.blocks=Math.ceil(r.size/r.blksize),r},setattr(e,r){r.mode!==void 0&&(e.mode=r.mode),r.timestamp!==void 0&&(e.timestamp=r.timestamp),r.size!==void 0&&L.resizeFileStorage(e,r.size)},lookup(e,r){throw i.genericErrors[44]},mknod(e,r,t,n){return L.createNode(e,r,t,n)},rename(e,r,t){if(i.isDir(e.mode)){var n;try{n=i.lookupNode(r,t)}catch{}if(n)for(var s in n.contents)throw new i.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=t,r.contents[t]=e,r.timestamp=e.parent.timestamp,e.parent=r},unlink(e,r){delete e.contents[r],e.timestamp=Date.now()},rmdir(e,r){var t=i.lookupNode(e,r);for(var n in t.contents)throw new i.ErrnoError(55);delete e.contents[r],e.timestamp=Date.now()},readdir(e){var r=[".",".."];for(var t in e.contents)e.contents.hasOwnProperty(t)&&r.push(t);return r},symlink(e,r,t){var n=L.createNode(e,r,41471,0);return n.link=t,n},readlink(e){if(!i.isLink(e.mode))throw new i.ErrnoError(28);return e.link}},stream_ops:{read(e,r,t,n,s){var u=e.node.contents;if(s>=e.node.usedBytes)return 0;var l=Math.min(e.node.usedBytes-s,n);if(l>8&&u.subarray)r.set(u.subarray(s,s+l),t);else for(var f=0;f<l;f++)r[t+f]=u[s+f];return l},write(e,r,t,n,s,u){if(!n)return 0;var l=e.node;if(l.timestamp=Date.now(),r.subarray&&(!l.contents||l.contents.subarray)){if(u)return l.contents=r.subarray(t,t+n),l.usedBytes=n,n;if(l.usedBytes===0&&s===0)return l.contents=r.slice(t,t+n),l.usedBytes=n,n;if(s+n<=l.usedBytes)return l.contents.set(r.subarray(t,t+n),s),n}if(L.expandFileStorage(l,s+n),l.contents.subarray&&r.subarray)l.contents.set(r.subarray(t,t+n),s);else for(var f=0;f<n;f++)l.contents[s+f]=r[t+f];return l.usedBytes=Math.max(l.usedBytes,s+n),n},llseek(e,r,t){var n=r;if(t===1?n+=e.position:t===2&&i.isFile(e.node.mode)&&(n+=e.node.usedBytes),n<0)throw new i.ErrnoError(28);return n},allocate(e,r,t){L.expandFileStorage(e.node,r+t),e.node.usedBytes=Math.max(e.node.usedBytes,r+t)},mmap(e,r,t,n,s){if(!i.isFile(e.node.mode))throw new i.ErrnoError(43);var u,l,f=e.node.contents;if(!(s&2)&&f.buffer===ee.buffer)l=!1,u=f.byteOffset;else{if((t>0||t+r<f.length)&&(f.subarray?f=f.subarray(t,t+r):f=Array.prototype.slice.call(f,t,t+r)),l=!0,u=tt(),!u)throw new i.ErrnoError(48);ee.set(f,u)}return{ptr:u,allocated:l}},msync(e,r,t,n,s){return L.stream_ops.write(e,r,0,n,t,!1),0}}},Dt=(e,r,t,n)=>{var s=n?"":`al ${e}`;H(e,u=>{Oe(u,`Loading data file "${e}" failed (no arrayBuffer).`),r(new Uint8Array(u)),s&&sr()},u=>{if(t)t();else throw`Loading data file "${e}" failed.`}),s&&Ke()},Rt=o.preloadPlugins||[];function Ot(e,r,t,n){typeof Browser<"u"&&Browser.init();var s=!1;return Rt.forEach(function(u){s||u.canHandle(r)&&(u.handle(e,r,t,n),s=!0)}),s}function Zt(e,r,t,n,s,u,l,f,g,m){var $=r?ye.resolve(q.join2(e,r)):e;function k(T){function P(x){m&&m(),f||i.createDataFile(e,r,x,n,s,g),u&&u(),sr()}Ot(T,$,P,()=>{l&&l(),sr()})||P(T)}Ke(),typeof t=="string"?Dt(t,T=>k(T),l):k(t)}function Jt(e){var r={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},t=r[e];if(typeof t>"u")throw new Error(`Unknown file open mode: ${e}`);return t}function rr(e,r){var t=0;return e&&(t|=365),r&&(t|=146),t}var i={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath:(e,r={})=>{if(e=ye.resolve(e),!e)return{path:"",node:null};var t={follow_mount:!0,recurse_count:0};if(r=Object.assign(t,r),r.recurse_count>8)throw new i.ErrnoError(32);for(var n=e.split("/").filter(k=>!!k),s=i.root,u="/",l=0;l<n.length;l++){var f=l===n.length-1;if(f&&r.parent)break;if(s=i.lookupNode(s,n[l]),u=q.join2(u,n[l]),i.isMountpoint(s)&&(!f||f&&r.follow_mount)&&(s=s.mounted.root),!f||r.follow)for(var g=0;i.isLink(s.mode);){var m=i.readlink(u);u=ye.resolve(q.dirname(u),m);var $=i.lookupPath(u,{recurse_count:r.recurse_count+1});if(s=$.node,g++>40)throw new i.ErrnoError(32)}}return{path:u,node:s}},getPath:e=>{for(var r;;){if(i.isRoot(e)){var t=e.mount.mountpoint;return r?t[t.length-1]!=="/"?`${t}/${r}`:t+r:t}r=r?`${e.name}/${r}`:e.name,e=e.parent}},hashName:(e,r)=>{for(var t=0,n=0;n<r.length;n++)t=(t<<5)-t+r.charCodeAt(n)|0;return(e+t>>>0)%i.nameTable.length},hashAddNode:e=>{var r=i.hashName(e.parent.id,e.name);e.name_next=i.nameTable[r],i.nameTable[r]=e},hashRemoveNode:e=>{var r=i.hashName(e.parent.id,e.name);if(i.nameTable[r]===e)i.nameTable[r]=e.name_next;else for(var t=i.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next}},lookupNode:(e,r)=>{var t=i.mayLookup(e);if(t)throw new i.ErrnoError(t,e);for(var n=i.hashName(e.id,r),s=i.nameTable[n];s;s=s.name_next){var u=s.name;if(s.parent.id===e.id&&u===r)return s}return i.lookup(e,r)},createNode:(e,r,t,n)=>{var s=new i.FSNode(e,r,t,n);return i.hashAddNode(s),s},destroyNode:e=>{i.hashRemoveNode(e)},isRoot:e=>e===e.parent,isMountpoint:e=>!!e.mounted,isFile:e=>(e&61440)===32768,isDir:e=>(e&61440)===16384,isLink:e=>(e&61440)===40960,isChrdev:e=>(e&61440)===8192,isBlkdev:e=>(e&61440)===24576,isFIFO:e=>(e&61440)===4096,isSocket:e=>(e&49152)===49152,flagsToPermissionString:e=>{var r=["r","w","rw"][e&3];return e&512&&(r+="w"),r},nodePermissions:(e,r)=>i.ignorePermissions?0:r.includes("r")&&!(e.mode&292)||r.includes("w")&&!(e.mode&146)||r.includes("x")&&!(e.mode&73)?2:0,mayLookup:e=>{var r=i.nodePermissions(e,"x");return r||(e.node_ops.lookup?0:2)},mayCreate:(e,r)=>{try{var t=i.lookupNode(e,r);return 20}catch{}return i.nodePermissions(e,"wx")},mayDelete:(e,r,t)=>{var n;try{n=i.lookupNode(e,r)}catch(u){return u.errno}var s=i.nodePermissions(e,"wx");if(s)return s;if(t){if(!i.isDir(n.mode))return 54;if(i.isRoot(n)||i.getPath(n)===i.cwd())return 10}else if(i.isDir(n.mode))return 31;return 0},mayOpen:(e,r)=>e?i.isLink(e.mode)?32:i.isDir(e.mode)&&(i.flagsToPermissionString(r)!=="r"||r&512)?31:i.nodePermissions(e,i.flagsToPermissionString(r)):44,MAX_OPEN_FDS:4096,nextfd:()=>{for(var e=0;e<=i.MAX_OPEN_FDS;e++)if(!i.streams[e])return e;throw new i.ErrnoError(33)},getStreamChecked:e=>{var r=i.getStream(e);if(!r)throw new i.ErrnoError(8);return r},getStream:e=>i.streams[e],createStream:(e,r=-1)=>(i.FSStream||(i.FSStream=function(){this.shared={}},i.FSStream.prototype={},Object.defineProperties(i.FSStream.prototype,{object:{get(){return this.node},set(t){this.node=t}},isRead:{get(){return(this.flags&2097155)!==1}},isWrite:{get(){return(this.flags&2097155)!==0}},isAppend:{get(){return this.flags&1024}},flags:{get(){return this.shared.flags},set(t){this.shared.flags=t}},position:{get(){return this.shared.position},set(t){this.shared.position=t}}})),e=Object.assign(new i.FSStream,e),r==-1&&(r=i.nextfd()),e.fd=r,i.streams[r]=e,e),closeStream:e=>{i.streams[e]=null},chrdev_stream_ops:{open:e=>{var r=i.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:()=>{throw new i.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,r)=>e<<8|r,registerDevice:(e,r)=>{i.devices[e]={stream_ops:r}},getDevice:e=>i.devices[e],getMounts:e=>{for(var r=[],t=[e];t.length;){var n=t.pop();r.push(n),t.push.apply(t,n.mounts)}return r},syncfs:(e,r)=>{typeof e=="function"&&(r=e,e=!1),i.syncFSRequests++,i.syncFSRequests>1&&N(`warning: ${i.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var t=i.getMounts(i.root.mount),n=0;function s(l){return i.syncFSRequests--,r(l)}function u(l){if(l)return u.errored?void 0:(u.errored=!0,s(l));++n>=t.length&&s(null)}t.forEach(l=>{if(!l.type.syncfs)return u(null);l.type.syncfs(l,e,u)})},mount:(e,r,t)=>{var n=t==="/",s=!t,u;if(n&&i.root)throw new i.ErrnoError(10);if(!n&&!s){var l=i.lookupPath(t,{follow_mount:!1});if(t=l.path,u=l.node,i.isMountpoint(u))throw new i.ErrnoError(10);if(!i.isDir(u.mode))throw new i.ErrnoError(54)}var f={type:e,opts:r,mountpoint:t,mounts:[]},g=e.mount(f);return g.mount=f,f.root=g,n?i.root=g:u&&(u.mounted=f,u.mount&&u.mount.mounts.push(f)),g},unmount:e=>{var r=i.lookupPath(e,{follow_mount:!1});if(!i.isMountpoint(r.node))throw new i.ErrnoError(28);var t=r.node,n=t.mounted,s=i.getMounts(n);Object.keys(i.nameTable).forEach(l=>{for(var f=i.nameTable[l];f;){var g=f.name_next;s.includes(f.mount)&&i.destroyNode(f),f=g}}),t.mounted=null;var u=t.mount.mounts.indexOf(n);t.mount.mounts.splice(u,1)},lookup:(e,r)=>e.node_ops.lookup(e,r),mknod:(e,r,t)=>{var n=i.lookupPath(e,{parent:!0}),s=n.node,u=q.basename(e);if(!u||u==="."||u==="..")throw new i.ErrnoError(28);var l=i.mayCreate(s,u);if(l)throw new i.ErrnoError(l);if(!s.node_ops.mknod)throw new i.ErrnoError(63);return s.node_ops.mknod(s,u,r,t)},create:(e,r)=>(r=r!==void 0?r:438,r&=4095,r|=32768,i.mknod(e,r,0)),mkdir:(e,r)=>(r=r!==void 0?r:511,r&=1023,r|=16384,i.mknod(e,r,0)),mkdirTree:(e,r)=>{for(var t=e.split("/"),n="",s=0;s<t.length;++s)if(t[s]){n+="/"+t[s];try{i.mkdir(n,r)}catch(u){if(u.errno!=20)throw u}}},mkdev:(e,r,t)=>(typeof t>"u"&&(t=r,r=438),r|=8192,i.mknod(e,r,t)),symlink:(e,r)=>{if(!ye.resolve(e))throw new i.ErrnoError(44);var t=i.lookupPath(r,{parent:!0}),n=t.node;if(!n)throw new i.ErrnoError(44);var s=q.basename(r),u=i.mayCreate(n,s);if(u)throw new i.ErrnoError(u);if(!n.node_ops.symlink)throw new i.ErrnoError(63);return n.node_ops.symlink(n,s,e)},rename:(e,r)=>{var t=q.dirname(e),n=q.dirname(r),s=q.basename(e),u=q.basename(r),l,f,g;if(l=i.lookupPath(e,{parent:!0}),f=l.node,l=i.lookupPath(r,{parent:!0}),g=l.node,!f||!g)throw new i.ErrnoError(44);if(f.mount!==g.mount)throw new i.ErrnoError(75);var m=i.lookupNode(f,s),$=ye.relative(e,n);if($.charAt(0)!==".")throw new i.ErrnoError(28);if($=ye.relative(r,t),$.charAt(0)!==".")throw new i.ErrnoError(55);var k;try{k=i.lookupNode(g,u)}catch{}if(m!==k){var T=i.isDir(m.mode),P=i.mayDelete(f,s,T);if(P)throw new i.ErrnoError(P);if(P=k?i.mayDelete(g,u,T):i.mayCreate(g,u),P)throw new i.ErrnoError(P);if(!f.node_ops.rename)throw new i.ErrnoError(63);if(i.isMountpoint(m)||k&&i.isMountpoint(k))throw new i.ErrnoError(10);if(g!==f&&(P=i.nodePermissions(f,"w"),P))throw new i.ErrnoError(P);i.hashRemoveNode(m);try{f.node_ops.rename(m,g,u)}catch(x){throw x}finally{i.hashAddNode(m)}}},rmdir:e=>{var r=i.lookupPath(e,{parent:!0}),t=r.node,n=q.basename(e),s=i.lookupNode(t,n),u=i.mayDelete(t,n,!0);if(u)throw new i.ErrnoError(u);if(!t.node_ops.rmdir)throw new i.ErrnoError(63);if(i.isMountpoint(s))throw new i.ErrnoError(10);t.node_ops.rmdir(t,n),i.destroyNode(s)},readdir:e=>{var r=i.lookupPath(e,{follow:!0}),t=r.node;if(!t.node_ops.readdir)throw new i.ErrnoError(54);return t.node_ops.readdir(t)},unlink:e=>{var r=i.lookupPath(e,{parent:!0}),t=r.node;if(!t)throw new i.ErrnoError(44);var n=q.basename(e),s=i.lookupNode(t,n),u=i.mayDelete(t,n,!1);if(u)throw new i.ErrnoError(u);if(!t.node_ops.unlink)throw new i.ErrnoError(63);if(i.isMountpoint(s))throw new i.ErrnoError(10);t.node_ops.unlink(t,n),i.destroyNode(s)},readlink:e=>{var r=i.lookupPath(e),t=r.node;if(!t)throw new i.ErrnoError(44);if(!t.node_ops.readlink)throw new i.ErrnoError(28);return ye.resolve(i.getPath(t.parent),t.node_ops.readlink(t))},stat:(e,r)=>{var t=i.lookupPath(e,{follow:!r}),n=t.node;if(!n)throw new i.ErrnoError(44);if(!n.node_ops.getattr)throw new i.ErrnoError(63);return n.node_ops.getattr(n)},lstat:e=>i.stat(e,!0),chmod:(e,r,t)=>{var n;if(typeof e=="string"){var s=i.lookupPath(e,{follow:!t});n=s.node}else n=e;if(!n.node_ops.setattr)throw new i.ErrnoError(63);n.node_ops.setattr(n,{mode:r&4095|n.mode&-4096,timestamp:Date.now()})},lchmod:(e,r)=>{i.chmod(e,r,!0)},fchmod:(e,r)=>{var t=i.getStreamChecked(e);i.chmod(t.node,r)},chown:(e,r,t,n)=>{var s;if(typeof e=="string"){var u=i.lookupPath(e,{follow:!n});s=u.node}else s=e;if(!s.node_ops.setattr)throw new i.ErrnoError(63);s.node_ops.setattr(s,{timestamp:Date.now()})},lchown:(e,r,t)=>{i.chown(e,r,t,!0)},fchown:(e,r,t)=>{var n=i.getStreamChecked(e);i.chown(n.node,r,t)},truncate:(e,r)=>{if(r<0)throw new i.ErrnoError(28);var t;if(typeof e=="string"){var n=i.lookupPath(e,{follow:!0});t=n.node}else t=e;if(!t.node_ops.setattr)throw new i.ErrnoError(63);if(i.isDir(t.mode))throw new i.ErrnoError(31);if(!i.isFile(t.mode))throw new i.ErrnoError(28);var s=i.nodePermissions(t,"w");if(s)throw new i.ErrnoError(s);t.node_ops.setattr(t,{size:r,timestamp:Date.now()})},ftruncate:(e,r)=>{var t=i.getStreamChecked(e);if(!(t.flags&2097155))throw new i.ErrnoError(28);i.truncate(t.node,r)},utime:(e,r,t)=>{var n=i.lookupPath(e,{follow:!0}),s=n.node;s.node_ops.setattr(s,{timestamp:Math.max(r,t)})},open:(e,r,t)=>{if(e==="")throw new i.ErrnoError(44);r=typeof r=="string"?Jt(r):r,t=typeof t>"u"?438:t,r&64?t=t&4095|32768:t=0;var n;if(typeof e=="object")n=e;else{e=q.normalize(e);try{var s=i.lookupPath(e,{follow:!(r&131072)});n=s.node}catch{}}var u=!1;if(r&64)if(n){if(r&128)throw new i.ErrnoError(20)}else n=i.mknod(e,t,0),u=!0;if(!n)throw new i.ErrnoError(44);if(i.isChrdev(n.mode)&&(r&=-513),r&65536&&!i.isDir(n.mode))throw new i.ErrnoError(54);if(!u){var l=i.mayOpen(n,r);if(l)throw new i.ErrnoError(l)}r&512&&!u&&i.truncate(n,0),r&=-131713;var f=i.createStream({node:n,path:i.getPath(n),flags:r,seekable:!0,position:0,stream_ops:n.stream_ops,ungotten:[],error:!1});return f.stream_ops.open&&f.stream_ops.open(f),o.logReadFiles&&!(r&1)&&(i.readFiles||(i.readFiles={}),e in i.readFiles||(i.readFiles[e]=1)),f},close:e=>{if(i.isClosed(e))throw new i.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(r){throw r}finally{i.closeStream(e.fd)}e.fd=null},isClosed:e=>e.fd===null,llseek:(e,r,t)=>{if(i.isClosed(e))throw new i.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new i.ErrnoError(70);if(t!=0&&t!=1&&t!=2)throw new i.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read:(e,r,t,n,s)=>{if(n<0||s<0)throw new i.ErrnoError(28);if(i.isClosed(e))throw new i.ErrnoError(8);if((e.flags&2097155)===1)throw new i.ErrnoError(8);if(i.isDir(e.node.mode))throw new i.ErrnoError(31);if(!e.stream_ops.read)throw new i.ErrnoError(28);var u=typeof s<"u";if(!u)s=e.position;else if(!e.seekable)throw new i.ErrnoError(70);var l=e.stream_ops.read(e,r,t,n,s);return u||(e.position+=l),l},write:(e,r,t,n,s,u)=>{if(n<0||s<0)throw new i.ErrnoError(28);if(i.isClosed(e))throw new i.ErrnoError(8);if(!(e.flags&2097155))throw new i.ErrnoError(8);if(i.isDir(e.node.mode))throw new i.ErrnoError(31);if(!e.stream_ops.write)throw new i.ErrnoError(28);e.seekable&&e.flags&1024&&i.llseek(e,0,2);var l=typeof s<"u";if(!l)s=e.position;else if(!e.seekable)throw new i.ErrnoError(70);var f=e.stream_ops.write(e,r,t,n,s,u);return l||(e.position+=f),f},allocate:(e,r,t)=>{if(i.isClosed(e))throw new i.ErrnoError(8);if(r<0||t<=0)throw new i.ErrnoError(28);if(!(e.flags&2097155))throw new i.ErrnoError(8);if(!i.isFile(e.node.mode)&&!i.isDir(e.node.mode))throw new i.ErrnoError(43);if(!e.stream_ops.allocate)throw new i.ErrnoError(138);e.stream_ops.allocate(e,r,t)},mmap:(e,r,t,n,s)=>{if(n&2&&!(s&2)&&(e.flags&2097155)!==2)throw new i.ErrnoError(2);if((e.flags&2097155)===1)throw new i.ErrnoError(2);if(!e.stream_ops.mmap)throw new i.ErrnoError(43);return e.stream_ops.mmap(e,r,t,n,s)},msync:(e,r,t,n,s)=>e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,s):0,munmap:e=>0,ioctl:(e,r,t)=>{if(!e.stream_ops.ioctl)throw new i.ErrnoError(59);return e.stream_ops.ioctl(e,r,t)},readFile:(e,r={})=>{if(r.flags=r.flags||0,r.encoding=r.encoding||"binary",r.encoding!=="utf8"&&r.encoding!=="binary")throw new Error(`Invalid encoding type "${r.encoding}"`);var t,n=i.open(e,r.flags),s=i.stat(e),u=s.size,l=new Uint8Array(u);return i.read(n,l,0,u,0),r.encoding==="utf8"?t=ze(l,0):r.encoding==="binary"&&(t=l),i.close(n),t},writeFile:(e,r,t={})=>{t.flags=t.flags||577;var n=i.open(e,t.flags,t.mode);if(typeof r=="string"){var s=new Uint8Array(jr(r)+1),u=Lr(r,s,0,s.length);i.write(n,s,0,u,void 0,t.canOwn)}else if(ArrayBuffer.isView(r))i.write(n,r,0,r.byteLength,void 0,t.canOwn);else throw new Error("Unsupported data type");i.close(n)},cwd:()=>i.currentPath,chdir:e=>{var r=i.lookupPath(e,{follow:!0});if(r.node===null)throw new i.ErrnoError(44);if(!i.isDir(r.node.mode))throw new i.ErrnoError(54);var t=i.nodePermissions(r.node,"x");if(t)throw new i.ErrnoError(t);i.currentPath=r.path},createDefaultDirectories:()=>{i.mkdir("/tmp"),i.mkdir("/home"),i.mkdir("/home/web_user")},createDefaultDevices:()=>{i.mkdir("/dev"),i.registerDevice(i.makedev(1,3),{read:()=>0,write:(n,s,u,l,f)=>l}),i.mkdev("/dev/null",i.makedev(1,3)),Ae.register(i.makedev(5,0),Ae.default_tty_ops),Ae.register(i.makedev(6,0),Ae.default_tty1_ops),i.mkdev("/dev/tty",i.makedev(5,0)),i.mkdev("/dev/tty1",i.makedev(6,0));var e=new Uint8Array(1024),r=0,t=()=>(r===0&&(r=rt(e).byteLength),e[--r]);i.createDevice("/dev","random",t),i.createDevice("/dev","urandom",t),i.mkdir("/dev/shm"),i.mkdir("/dev/shm/tmp")},createSpecialDirectories:()=>{i.mkdir("/proc");var e=i.mkdir("/proc/self");i.mkdir("/proc/self/fd"),i.mount({mount:()=>{var r=i.createNode(e,"fd",16895,73);return r.node_ops={lookup:(t,n)=>{var s=+n,u=i.getStreamChecked(s),l={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>u.path}};return l.parent=l,l}},r}},{},"/proc/self/fd")},createStandardStreams:()=>{o.stdin?i.createDevice("/dev","stdin",o.stdin):i.symlink("/dev/tty","/dev/stdin"),o.stdout?i.createDevice("/dev","stdout",null,o.stdout):i.symlink("/dev/tty","/dev/stdout"),o.stderr?i.createDevice("/dev","stderr",null,o.stderr):i.symlink("/dev/tty1","/dev/stderr"),i.open("/dev/stdin",0),i.open("/dev/stdout",1),i.open("/dev/stderr",1)},ensureErrnoError:()=>{i.ErrnoError||(i.ErrnoError=function(r,t){this.name="ErrnoError",this.node=t,this.setErrno=function(n){this.errno=n},this.setErrno(r),this.message="FS error"},i.ErrnoError.prototype=new Error,i.ErrnoError.prototype.constructor=i.ErrnoError,[44].forEach(e=>{i.genericErrors[e]=new i.ErrnoError(e),i.genericErrors[e].stack="<generic error, no stack>"}))},staticInit:()=>{i.ensureErrnoError(),i.nameTable=new Array(4096),i.mount(L,{},"/"),i.createDefaultDirectories(),i.createDefaultDevices(),i.createSpecialDirectories(),i.filesystems={MEMFS:L}},init:(e,r,t)=>{i.init.initialized=!0,i.ensureErrnoError(),o.stdin=e||o.stdin,o.stdout=r||o.stdout,o.stderr=t||o.stderr,i.createStandardStreams()},quit:()=>{i.init.initialized=!1;for(var e=0;e<i.streams.length;e++){var r=i.streams[e];r&&i.close(r)}},findObject:(e,r)=>{var t=i.analyzePath(e,r);return t.exists?t.object:null},analyzePath:(e,r)=>{try{var t=i.lookupPath(e,{follow:!r});e=t.path}catch{}var n={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var t=i.lookupPath(e,{parent:!0});n.parentExists=!0,n.parentPath=t.path,n.parentObject=t.node,n.name=q.basename(e),t=i.lookupPath(e,{follow:!r}),n.exists=!0,n.path=t.path,n.object=t.node,n.name=t.node.name,n.isRoot=t.path==="/"}catch(s){n.error=s.errno}return n},createPath:(e,r,t,n)=>{e=typeof e=="string"?e:i.getPath(e);for(var s=r.split("/").reverse();s.length;){var u=s.pop();if(u){var l=q.join2(e,u);try{i.mkdir(l)}catch{}e=l}}return l},createFile:(e,r,t,n,s)=>{var u=q.join2(typeof e=="string"?e:i.getPath(e),r),l=rr(n,s);return i.create(u,l)},createDataFile:(e,r,t,n,s,u)=>{var l=r;e&&(e=typeof e=="string"?e:i.getPath(e),l=r?q.join2(e,r):e);var f=rr(n,s),g=i.create(l,f);if(t){if(typeof t=="string"){for(var m=new Array(t.length),$=0,k=t.length;$<k;++$)m[$]=t.charCodeAt($);t=m}i.chmod(g,f|146);var T=i.open(g,577);i.write(T,t,0,t.length,0,u),i.close(T),i.chmod(g,f)}return g},createDevice:(e,r,t,n)=>{var s=q.join2(typeof e=="string"?e:i.getPath(e),r),u=rr(!!t,!!n);i.createDevice.major||(i.createDevice.major=64);var l=i.makedev(i.createDevice.major++,0);return i.registerDevice(l,{open:f=>{f.seekable=!1},close:f=>{n&&n.buffer&&n.buffer.length&&n(10)},read:(f,g,m,$,k)=>{for(var T=0,P=0;P<$;P++){var x;try{x=t()}catch{throw new i.ErrnoError(29)}if(x===void 0&&T===0)throw new i.ErrnoError(6);if(x==null)break;T++,g[m+P]=x}return T&&(f.node.timestamp=Date.now()),T},write:(f,g,m,$,k)=>{for(var T=0;T<$;T++)try{n(g[m+T])}catch{throw new i.ErrnoError(29)}return $&&(f.node.timestamp=Date.now()),T}}),i.mkdev(s,u,l)},forceLoadFile:e=>{if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if(typeof XMLHttpRequest<"u")throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");if(F)try{e.contents=Br(F(e.url),!0),e.usedBytes=e.contents.length}catch{throw new i.ErrnoError(29)}else throw new Error("Cannot load without read() or XMLHttpRequest.")},createLazyFile:(e,r,t,n,s)=>{function u(){this.lengthKnown=!1,this.chunks=[]}if(u.prototype.get=function(P){if(!(P>this.length-1||P<0)){var x=P%this.chunkSize,Y=P/this.chunkSize|0;return this.getter(Y)[x]}},u.prototype.setDataGetter=function(P){this.getter=P},u.prototype.cacheLength=function(){var P=new XMLHttpRequest;if(P.open("HEAD",t,!1),P.send(null),!(P.status>=200&&P.status<300||P.status===304))throw new Error("Couldn't load "+t+". Status: "+P.status);var x=Number(P.getResponseHeader("Content-length")),Y,J=(Y=P.getResponseHeader("Accept-Ranges"))&&Y==="bytes",se=(Y=P.getResponseHeader("Content-Encoding"))&&Y==="gzip",ve=1024*1024;J||(ve=x);var re=(me,De)=>{if(me>De)throw new Error("invalid range ("+me+", "+De+") or no bytes requested!");if(De>x-1)throw new Error("only "+x+" bytes available! programmer error!");var ae=new XMLHttpRequest;if(ae.open("GET",t,!1),x!==ve&&ae.setRequestHeader("Range","bytes="+me+"-"+De),ae.responseType="arraybuffer",ae.overrideMimeType&&ae.overrideMimeType("text/plain; charset=x-user-defined"),ae.send(null),!(ae.status>=200&&ae.status<300||ae.status===304))throw new Error("Couldn't load "+t+". Status: "+ae.status);return ae.response!==void 0?new Uint8Array(ae.response||[]):Br(ae.responseText||"",!0)},qe=this;qe.setDataGetter(me=>{var De=me*ve,ae=(me+1)*ve-1;if(ae=Math.min(ae,x-1),typeof qe.chunks[me]>"u"&&(qe.chunks[me]=re(De,ae)),typeof qe.chunks[me]>"u")throw new Error("doXHR failed!");return qe.chunks[me]}),(se||!x)&&(ve=x=1,x=this.getter(0).length,ve=x,Z("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=x,this._chunkSize=ve,this.lengthKnown=!0},typeof XMLHttpRequest<"u"){if(!S)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var l=new u;Object.defineProperties(l,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var f={isDevice:!1,contents:l}}else var f={isDevice:!1,url:t};var g=i.createFile(e,r,f,n,s);f.contents?g.contents=f.contents:f.url&&(g.contents=null,g.url=f.url),Object.defineProperties(g,{usedBytes:{get:function(){return this.contents.length}}});var m={},$=Object.keys(g.stream_ops);$.forEach(T=>{var P=g.stream_ops[T];m[T]=function(){return i.forceLoadFile(g),P.apply(null,arguments)}});function k(T,P,x,Y,J){var se=T.node.contents;if(J>=se.length)return 0;var ve=Math.min(se.length-J,Y);if(se.slice)for(var re=0;re<ve;re++)P[x+re]=se[J+re];else for(var re=0;re<ve;re++)P[x+re]=se.get(J+re);return ve}return m.read=(T,P,x,Y,J)=>(i.forceLoadFile(g),k(T,P,x,Y,J)),m.mmap=(T,P,x,Y,J)=>{i.forceLoadFile(g);var se=tt();if(!se)throw new i.ErrnoError(48);return k(T,ee,se,P,x),{ptr:se,allocated:!0}},g.stream_ops=m,g}},wr=(e,r)=>e?ze(K,e,r):"",ue={DEFAULT_POLLMASK:5,calculateAt:function(e,r,t){if(q.isAbs(r))return r;var n;if(e===-100)n=i.cwd();else{var s=ue.getStreamFromFD(e);n=s.path}if(r.length==0){if(!t)throw new i.ErrnoError(44);return n}return q.join2(n,r)},doStat:function(e,r,t){try{var n=e(r)}catch(f){if(f&&f.node&&q.normalize(r)!==q.normalize(i.getPath(f.node)))return-54;throw f}W[t>>2]=n.dev,W[t+4>>2]=n.mode,z[t+8>>2]=n.nlink,W[t+12>>2]=n.uid,W[t+16>>2]=n.gid,W[t+20>>2]=n.rdev,Q=[n.size>>>0,(U=n.size,+Math.abs(U)>=1?U>0?+Math.floor(U/4294967296)>>>0:~~+Math.ceil((U-+(~~U>>>0))/4294967296)>>>0:0)],W[t+24>>2]=Q[0],W[t+28>>2]=Q[1],W[t+32>>2]=4096,W[t+36>>2]=n.blocks;var s=n.atime.getTime(),u=n.mtime.getTime(),l=n.ctime.getTime();return Q=[Math.floor(s/1e3)>>>0,(U=Math.floor(s/1e3),+Math.abs(U)>=1?U>0?+Math.floor(U/4294967296)>>>0:~~+Math.ceil((U-+(~~U>>>0))/4294967296)>>>0:0)],W[t+40>>2]=Q[0],W[t+44>>2]=Q[1],z[t+48>>2]=s%1e3*1e3,Q=[Math.floor(u/1e3)>>>0,(U=Math.floor(u/1e3),+Math.abs(U)>=1?U>0?+Math.floor(U/4294967296)>>>0:~~+Math.ceil((U-+(~~U>>>0))/4294967296)>>>0:0)],W[t+56>>2]=Q[0],W[t+60>>2]=Q[1],z[t+64>>2]=u%1e3*1e3,Q=[Math.floor(l/1e3)>>>0,(U=Math.floor(l/1e3),+Math.abs(U)>=1?U>0?+Math.floor(U/4294967296)>>>0:~~+Math.ceil((U-+(~~U>>>0))/4294967296)>>>0:0)],W[t+72>>2]=Q[0],W[t+76>>2]=Q[1],z[t+80>>2]=l%1e3*1e3,Q=[n.ino>>>0,(U=n.ino,+Math.abs(U)>=1?U>0?+Math.floor(U/4294967296)>>>0:~~+Math.ceil((U-+(~~U>>>0))/4294967296)>>>0:0)],W[t+88>>2]=Q[0],W[t+92>>2]=Q[1],0},doMsync:function(e,r,t,n,s){if(!i.isFile(r.node.mode))throw new i.ErrnoError(43);if(n&2)return 0;var u=K.slice(e,e+t);i.msync(r,u,s,t,n)},varargs:void 0,get(){ue.varargs+=4;var e=W[ue.varargs-4>>2];return e},getStr(e){var r=wr(e);return r},getStreamFromFD:function(e){var r=i.getStreamChecked(e);return r}};function en(e,r,t){ue.varargs=t;try{var n=ue.getStreamFromFD(e);switch(r){case 0:{var s=ue.get();if(s<0)return-28;var u;return u=i.createStream(n,s),u.fd}case 1:case 2:return 0;case 3:return n.flags;case 4:{var s=ue.get();return n.flags|=s,0}case 5:{var s=ue.get(),l=0;return we[s+l>>1]=2,0}case 6:case 7:return 0;case 16:case 8:return-28;case 9:return et(28),-1;default:return-28}}catch(f){if(typeof i>"u"||f.name!=="ErrnoError")throw f;return-f.errno}}function Hr(e,r,t,n){ue.varargs=n;try{r=ue.getStr(r),r=ue.calculateAt(e,r);var s=n?ue.get():0;return i.open(r,t,s).fd}catch(u){if(typeof i>"u"||u.name!=="ErrnoError")throw u;return-u.errno}}function rn(e,r,t,n,s){}function Wr(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}`)}}function nt(){for(var e=new Array(256),r=0;r<256;++r)e[r]=String.fromCharCode(r);ht=e}var ht=void 0;function he(e){for(var r="",t=e;K[t];)r+=ht[K[t++]];return r}var Ne={},Ie={},_r={},Ve=void 0;function V(e){throw new Ve(e)}var Qe=void 0;function br(e){throw new Qe(e)}function tr(e,r,t){e.forEach(function(f){_r[f]=r});function n(f){var g=t(f);g.length!==e.length&&br("Mismatched type converter count");for(var m=0;m<e.length;++m)Ee(e[m],g[m])}var s=new Array(r.length),u=[],l=0;r.forEach((f,g)=>{Ie.hasOwnProperty(f)?s[g]=Ie[f]:(u.push(f),Ne.hasOwnProperty(f)||(Ne[f]=[]),Ne[f].push(()=>{s[g]=Ie[f],++l,l===u.length&&n(s)}))}),u.length===0&&n(s)}function it(e,r,t={}){var n=r.name;if(e||V(`type "${n}" must have a positive integer typeid pointer`),Ie.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;V(`Cannot register type '${n}' twice`)}if(Ie[e]=r,delete _r[e],Ne.hasOwnProperty(e)){var s=Ne[e];delete Ne[e],s.forEach(u=>u())}}function Ee(e,r,t={}){if(!("argPackAdvance"in r))throw new TypeError("registerType registeredInstance requires argPackAdvance");return it(e,r,t)}function Ut(e,r,t,n,s){var u=Wr(t);r=he(r),Ee(e,{name:r,fromWireType:function(l){return!!l},toWireType:function(l,f){return f?n:s},argPackAdvance:8,readValueFromPointer:function(l){var f;if(t===1)f=ee;else if(t===2)f=we;else if(t===4)f=W;else throw new TypeError("Unknown boolean type size: "+r);return this.fromWireType(f[l>>u])},destructorFunction:null})}function tn(e){if(!(this instanceof Se)||!(e instanceof Se))return!1;for(var r=this.$$.ptrType.registeredClass,t=this.$$.ptr,n=e.$$.ptrType.registeredClass,s=e.$$.ptr;r.baseClass;)t=r.upcast(t),r=r.baseClass;for(;n.baseClass;)s=n.upcast(s),n=n.baseClass;return r===n&&t===s}function nn(e){return{count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}}function Er(e){function r(t){return t.$$.ptrType.registeredClass.name}V(r(e)+" instance already deleted")}var zr=!1;function pt(e){}function on(e){e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)}function Fr(e){e.count.value-=1;var r=e.count.value===0;r&&on(e)}function vt(e,r,t){if(r===t)return e;if(t.baseClass===void 0)return null;var n=vt(e,r,t.baseClass);return n===null?null:t.downcast(n)}var mt={};function sn(){return Object.keys(ir).length}function an(){var e=[];for(var r in ir)ir.hasOwnProperty(r)&&e.push(ir[r]);return e}var Ce=[];function Nr(){for(;Ce.length;){var e=Ce.pop();e.$$.deleteScheduled=!1,e.delete()}}var nr=void 0;function ot(e){nr=e,Ce.length&&nr&&nr(Nr)}function Mt(){o.getInheritedInstanceCount=sn,o.getLiveInheritedInstances=an,o.flushPendingDeletes=Nr,o.setDelayFunction=ot}var ir={};function un(e,r){for(r===void 0&&V("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r}function Dr(e,r){return r=un(e,r),ir[r]}function Pr(e,r){(!r.ptrType||!r.ptr)&&br("makeClassHandle requires ptr and ptrType");var t=!!r.smartPtrType,n=!!r.smartPtr;return t!==n&&br("Both smartPtrType and smartPtr must be specified"),r.count={value:1},Ye(Object.create(e,{$$:{value:r}}))}function xt(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=Dr(this.registeredClass,r);if(t!==void 0){if(t.$$.count.value===0)return t.$$.ptr=r,t.$$.smartPtr=e,t.clone();var n=t.clone();return this.destructor(e),n}function s(){return this.isSmartPointer?Pr(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):Pr(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var u=this.registeredClass.getActualType(r),l=mt[u];if(!l)return s.call(this);var f;this.isConst?f=l.constPointerType:f=l.pointerType;var g=vt(r,this.registeredClass,f.registeredClass);return g===null?s.call(this):this.isSmartPointer?Pr(f.registeredClass.instancePrototype,{ptrType:f,ptr:g,smartPtrType:this,smartPtr:e}):Pr(f.registeredClass.instancePrototype,{ptrType:f,ptr:g})}var Ye=function(e){return typeof FinalizationRegistry>"u"?(Ye=r=>r,e):(zr=new FinalizationRegistry(r=>{Fr(r.$$)}),Ye=r=>{var t=r.$$,n=!!t.smartPtr;if(n){var s={$$:t};zr.register(r,s,r)}return r},pt=r=>zr.unregister(r),Ye(e))};function gt(){if(this.$$.ptr||Er(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e=Ye(Object.create(Object.getPrototypeOf(this),{$$:{value:nn(this.$$)}}));return e.$$.count.value+=1,e.$$.deleteScheduled=!1,e}function fn(){this.$$.ptr||Er(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&V("Object already scheduled for deletion"),pt(this),Fr(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function It(){return!this.$$.ptr}function ln(){return this.$$.ptr||Er(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&V("Object already scheduled for deletion"),Ce.push(this),Ce.length===1&&nr&&nr(Nr),this.$$.deleteScheduled=!0,this}function jt(){Se.prototype.isAliasOf=tn,Se.prototype.clone=gt,Se.prototype.delete=fn,Se.prototype.isDeleted=It,Se.prototype.deleteLater=ln}function Se(){}var cn=48,dn=57;function Cr(e){if(e===void 0)return"_unknown";e=e.replace(/[^a-zA-Z0-9_]/g,"$");var r=e.charCodeAt(0);return r>=cn&&r<=dn?`_${e}`:e}function Rr(e,r){return e=Cr(e),{[e]:function(){return r.apply(this,arguments)}}[e]}function je(e,r,t){if(e[r].overloadTable===void 0){var n=e[r];e[r]=function(){return e[r].overloadTable.hasOwnProperty(arguments.length)||V(`Function '${t}' called with an invalid number of arguments (${arguments.length}) - expects one of (${e[r].overloadTable})!`),e[r].overloadTable[arguments.length].apply(this,arguments)},e[r].overloadTable=[],e[r].overloadTable[n.argCount]=n}}function Lt(e,r,t){o.hasOwnProperty(e)?((t===void 0||o[e].overloadTable!==void 0&&o[e].overloadTable[t]!==void 0)&&V(`Cannot register public name '${e}' twice`),je(o,e,e),o.hasOwnProperty(t)&&V(`Cannot register multiple overloads of a function with the same number of arguments (${t})!`),o[e].overloadTable[t]=r):(o[e]=r,t!==void 0&&(o[e].numArguments=t))}function hn(e,r,t,n,s,u,l,f){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=s,this.getActualType=u,this.upcast=l,this.downcast=f,this.pureVirtualFunctions=[]}function Vr(e,r,t){for(;r!==t;)r.upcast||V(`Expected null or instance of ${t.name}, got an instance of ${r.name}`),e=r.upcast(e),r=r.baseClass;return e}function st(e,r){if(r===null)return this.isReference&&V(`null is not a valid ${this.name}`),0;r.$$||V(`Cannot pass "${qr(r)}" as a ${this.name}`),r.$$.ptr||V(`Cannot pass deleted object as a pointer of type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=Vr(r.$$.ptr,t,this.registeredClass);return n}function pn(e,r){var t;if(r===null)return this.isReference&&V(`null is not a valid ${this.name}`),this.isSmartPointer?(t=this.rawConstructor(),e!==null&&e.push(this.rawDestructor,t),t):0;r.$$||V(`Cannot pass "${qr(r)}" as a ${this.name}`),r.$$.ptr||V(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&r.$$.ptrType.isConst&&V(`Cannot convert argument of type ${r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name} to parameter type ${this.name}`);var n=r.$$.ptrType.registeredClass;if(t=Vr(r.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(r.$$.smartPtr===void 0&&V("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:V(`Cannot convert argument of type ${r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:t=r.$$.smartPtr;break;case 2:if(r.$$.smartPtrType===this)t=r.$$.smartPtr;else{var s=r.clone();t=this.rawShare(t,Tr.toHandle(function(){s.delete()})),e!==null&&e.push(this.rawDestructor,t)}break;default:V("Unsupporting sharing policy")}return t}function yt(e,r){if(r===null)return this.isReference&&V(`null is not a valid ${this.name}`),0;r.$$||V(`Cannot pass "${qr(r)}" as a ${this.name}`),r.$$.ptr||V(`Cannot pass deleted object as a pointer of type ${this.name}`),r.$$.ptrType.isConst&&V(`Cannot convert argument of type ${r.$$.ptrType.name} to parameter type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=Vr(r.$$.ptr,t,this.registeredClass);return n}function $r(e){return this.fromWireType(W[e>>2])}function vn(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e}function mn(e){this.rawDestructor&&this.rawDestructor(e)}function gn(e){e!==null&&e.delete()}function yn(){$e.prototype.getPointee=vn,$e.prototype.destructor=mn,$e.prototype.argPackAdvance=8,$e.prototype.readValueFromPointer=$r,$e.prototype.deleteObject=gn,$e.prototype.fromWireType=xt}function $e(e,r,t,n,s,u,l,f,g,m,$){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=s,this.pointeeType=u,this.sharingPolicy=l,this.rawGetPointee=f,this.rawConstructor=g,this.rawShare=m,this.rawDestructor=$,!s&&r.baseClass===void 0?n?(this.toWireType=st,this.destructorFunction=null):(this.toWireType=yt,this.destructorFunction=null):this.toWireType=pn}function wn(e,r,t){o.hasOwnProperty(e)||br("Replacing nonexistant public symbol"),o[e].overloadTable!==void 0&&t!==void 0?o[e].overloadTable[t]=r:(o[e]=r,o[e].argCount=t)}var _n=(e,r,t)=>{var n=o["dynCall_"+e];return t&&t.length?n.apply(null,[r].concat(t)):n.call(null,r)},ur=[],at=e=>{var r=ur[e];return r||(e>=ur.length&&(ur.length=e+1),ur[e]=r=pr.get(e)),r},bn=(e,r,t)=>{if(e.includes("j"))return _n(e,r,t);var n=at(r).apply(null,t);return n},En=(e,r)=>{var t=[];return function(){return t.length=0,Object.assign(t,arguments),bn(e,r,t)}};function Le(e,r){e=he(e);function t(){return e.includes("j")?En(e,r):at(r)}var n=t();return typeof n!="function"&&V(`unknown function pointer with signature ${e}: ${r}`),n}function Pn(e,r){var t=Rr(r,function(n){this.name=r,this.message=n;var s=new Error(n).stack;s!==void 0&&(this.stack=this.toString()+`
  46. `+s.replace(/^Error(:[^\n]*)?\n/,""))});return t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},t}var wt=void 0;function _t(e){var r=jn(e),t=he(r);return Fe(r),t}function Gr(e,r){var t=[],n={};function s(u){if(!n[u]&&!Ie[u]){if(_r[u]){_r[u].forEach(s);return}t.push(u),n[u]=!0}}throw r.forEach(s),new wt(`${e}: `+t.map(_t).join([", "]))}function Cn(e,r,t,n,s,u,l,f,g,m,$,k,T){$=he($),u=Le(s,u),f&&(f=Le(l,f)),m&&(m=Le(g,m)),T=Le(k,T);var P=Cr($);Lt(P,function(){Gr(`Cannot construct ${$} due to unbound types`,[n])}),tr([e,r,t],n?[n]:[],function(x){x=x[0];var Y,J;n?(Y=x.registeredClass,J=Y.instancePrototype):J=Se.prototype;var se=Rr(P,function(){if(Object.getPrototypeOf(this)!==ve)throw new Ve("Use 'new' to construct "+$);if(re.constructor_body===void 0)throw new Ve($+" has no accessible constructor");var ae=re.constructor_body[arguments.length];if(ae===void 0)throw new Ve(`Tried to invoke ctor of ${$} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(re.constructor_body).toString()}) parameters instead!`);return ae.apply(this,arguments)}),ve=Object.create(J,{constructor:{value:se}});se.prototype=ve;var re=new hn($,se,ve,T,Y,u,f,m);re.baseClass&&(re.baseClass.__derivedClasses===void 0&&(re.baseClass.__derivedClasses=[]),re.baseClass.__derivedClasses.push(re));var qe=new $e($,re,!0,!1,!1),me=new $e($+"*",re,!1,!1,!1),De=new $e($+" const*",re,!1,!0,!1);return mt[e]={pointerType:me,constPointerType:De},wn(P,se),[qe,me,De]})}function bt(e,r){for(var t=[],n=0;n<e;n++)t.push(z[r+n*4>>2]);return t}function $n(e){for(;e.length;){var r=e.pop(),t=e.pop();t(r)}}function Et(e,r){if(!(e instanceof Function))throw new TypeError(`new_ called with constructor type ${typeof e} which is not a function`);var t=Rr(e.name||"unknownFunctionName",function(){});t.prototype=e.prototype;var n=new t,s=e.apply(n,r);return s instanceof Object?s:n}function Pt(e,r,t,n,s,u){var l=r.length;l<2&&V("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var f=r[1]!==null&&t!==null,g=!1,m=1;m<r.length;++m)if(r[m]!==null&&r[m].destructorFunction===void 0){g=!0;break}for(var $=r[0].name!=="void",k="",T="",m=0;m<l-2;++m)k+=(m!==0?", ":"")+"arg"+m,T+=(m!==0?", ":"")+"arg"+m+"Wired";var P=`
  47. return function ${Cr(e)}(${k}) {
  48. if (arguments.length !== ${l-2}) {
  49. throwBindingError('function ${e} called with ${arguments.length} arguments, expected ${l-2} args!');
  50. }`;g&&(P+=`var destructors = [];
  51. `);var x=g?"destructors":"null",Y=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],J=[V,n,s,$n,r[0],r[1]];f&&(P+="var thisWired = classParam.toWireType("+x+`, this);
  52. `);for(var m=0;m<l-2;++m)P+="var arg"+m+"Wired = argType"+m+".toWireType("+x+", arg"+m+"); // "+r[m+2].name+`
  53. `,Y.push("argType"+m),J.push(r[m+2]);if(f&&(T="thisWired"+(T.length>0?", ":"")+T),P+=($||u?"var rv = ":"")+"invoker(fn"+(T.length>0?", ":"")+T+`);
  54. `,g)P+=`runDestructors(destructors);
  55. `;else for(var m=f?1:2;m<r.length;++m){var se=m===1?"thisWired":"arg"+(m-2)+"Wired";r[m].destructorFunction!==null&&(P+=se+"_dtor("+se+"); // "+r[m].name+`
  56. `,Y.push(se+"_dtor"),J.push(r[m].destructorFunction))}return $&&(P+=`var ret = retType.fromWireType(rv);
  57. return ret;
  58. `),P+=`}
  59. `,Y.push(P),Et(Function,Y).apply(null,J)}function Tn(e,r,t,n,s,u){var l=bt(r,t);s=Le(n,s),tr([],[e],function(f){f=f[0];var g=`constructor ${f.name}`;if(f.registeredClass.constructor_body===void 0&&(f.registeredClass.constructor_body=[]),f.registeredClass.constructor_body[r-1]!==void 0)throw new Ve(`Cannot register multiple constructors with identical number of parameters (${r-1}) for class '${f.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return f.registeredClass.constructor_body[r-1]=()=>{Gr(`Cannot construct ${f.name} due to unbound types`,l)},tr([],l,function(m){return m.splice(1,0,null),f.registeredClass.constructor_body[r-1]=Pt(g,m,null,s,u),[]}),[]})}function Ct(e,r,t,n,s,u,l,f,g){var m=bt(t,n);r=he(r),u=Le(s,u),tr([],[e],function($){$=$[0];var k=`${$.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),f&&$.registeredClass.pureVirtualFunctions.push(r);function T(){Gr(`Cannot call ${k} due to unbound types`,m)}var P=$.registeredClass.instancePrototype,x=P[r];return x===void 0||x.overloadTable===void 0&&x.className!==$.name&&x.argCount===t-2?(T.argCount=t-2,T.className=$.name,P[r]=T):(je(P,r,k),P[r].overloadTable[t-2]=T),tr([],m,function(Y){var J=Pt(k,Y,$,u,l,g);return P[r].overloadTable===void 0?(J.argCount=t-2,P[r]=J):P[r].overloadTable[t-2]=J,[]}),[]})}function Sn(){Object.assign($t.prototype,{get(e){return this.allocated[e]},has(e){return this.allocated[e]!==void 0},allocate(e){var r=this.freelist.pop()||this.allocated.length;return this.allocated[r]=e,r},free(e){this.allocated[e]=void 0,this.freelist.push(e)}})}function $t(){this.allocated=[void 0],this.freelist=[]}var ge=new $t;function Tt(e){e>=ge.reserved&&--ge.get(e).refcount===0&&ge.free(e)}function Bt(){for(var e=0,r=ge.reserved;r<ge.allocated.length;++r)ge.allocated[r]!==void 0&&++e;return e}function kn(){ge.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),ge.reserved=ge.allocated.length,o.count_emval_handles=Bt}var Tr={toValue:e=>(e||V("Cannot use deleted val. handle = "+e),ge.get(e).value),toHandle:e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return ge.allocate({refcount:1,value:e})}}};function Ht(e,r){r=he(r),Ee(e,{name:r,fromWireType:function(t){var n=Tr.toValue(t);return Tt(t),n},toWireType:function(t,n){return Tr.toHandle(n)},argPackAdvance:8,readValueFromPointer:$r,destructorFunction:null})}function qr(e){if(e===null)return"null";var r=typeof e;return r==="object"||r==="array"||r==="function"?e.toString():""+e}function An(e,r){switch(r){case 2:return function(t){return this.fromWireType(dr[t>>2])};case 3:return function(t){return this.fromWireType(hr[t>>3])};default:throw new TypeError("Unknown float type: "+e)}}function Fn(e,r,t){var n=Wr(t);r=he(r),Ee(e,{name:r,fromWireType:function(s){return s},toWireType:function(s,u){return u},argPackAdvance:8,readValueFromPointer:An(r,n),destructorFunction:null})}function Dn(e,r,t){switch(r){case 0:return t?function(s){return ee[s]}:function(s){return K[s]};case 1:return t?function(s){return we[s>>1]}:function(s){return Je[s>>1]};case 2:return t?function(s){return W[s>>2]}:function(s){return z[s>>2]};default:throw new TypeError("Unknown integer type: "+e)}}function Rn(e,r,t,n,s){r=he(r);var u=Wr(t),l=k=>k;if(n===0){var f=32-8*t;l=k=>k<<f>>>f}var g=r.includes("unsigned"),m=(k,T)=>{},$;g?$=function(k,T){return m(T,this.name),T>>>0}:$=function(k,T){return m(T,this.name),T},Ee(e,{name:r,fromWireType:l,toWireType:$,argPackAdvance:8,readValueFromPointer:Dn(r,u,n!==0),destructorFunction:null})}function On(e,r,t){var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],s=n[r];function u(l){l=l>>2;var f=z,g=f[l],m=f[l+1];return new s(f.buffer,m,g)}t=he(t),Ee(e,{name:t,fromWireType:u,argPackAdvance:8,readValueFromPointer:u},{ignoreDuplicateRegistrations:!0})}var Un=(e,r,t)=>Lr(e,K,r,t);function or(e,r){r=he(r);var t=r==="std::string";Ee(e,{name:r,fromWireType:function(n){var s=z[n>>2],u=n+4,l;if(t)for(var f=u,g=0;g<=s;++g){var m=u+g;if(g==s||K[m]==0){var $=m-f,k=wr(f,$);l===void 0?l=k:(l+=String.fromCharCode(0),l+=k),f=m+1}}else{for(var T=new Array(s),g=0;g<s;++g)T[g]=String.fromCharCode(K[u+g]);l=T.join("")}return Fe(n),l},toWireType:function(n,s){s instanceof ArrayBuffer&&(s=new Uint8Array(s));var u,l=typeof s=="string";l||s instanceof Uint8Array||s instanceof Uint8ClampedArray||s instanceof Int8Array||V("Cannot pass non-string to std::string"),t&&l?u=jr(s):u=s.length;var f=kt(4+u+1),g=f+4;if(z[f>>2]=u,t&&l)Un(s,g,u+1);else if(l)for(var m=0;m<u;++m){var $=s.charCodeAt(m);$>255&&(Fe(g),V("String has UTF-16 code units that do not fit in 8 bits")),K[g+m]=$}else for(var m=0;m<u;++m)K[g+m]=s[m];return n!==null&&n.push(Fe,f),f},argPackAdvance:8,readValueFromPointer:$r,destructorFunction:function(n){Fe(n)}})}var Xr=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,Wt=(e,r)=>{for(var t=e,n=t>>1,s=n+r/2;!(n>=s)&&Je[n];)++n;if(t=n<<1,t-e>32&&Xr)return Xr.decode(K.subarray(e,t));for(var u="",l=0;!(l>=r/2);++l){var f=we[e+l*2>>1];if(f==0)break;u+=String.fromCharCode(f)}return u},zt=(e,r,t)=>{if(t===void 0&&(t=2147483647),t<2)return 0;t-=2;for(var n=r,s=t<e.length*2?t/2:e.length,u=0;u<s;++u){var l=e.charCodeAt(u);we[r>>1]=l,r+=2}return we[r>>1]=0,r-n},ut=e=>e.length*2,Nt=(e,r)=>{for(var t=0,n="";!(t>=r/4);){var s=W[e+t*4>>2];if(s==0)break;if(++t,s>=65536){var u=s-65536;n+=String.fromCharCode(55296|u>>10,56320|u&1023)}else n+=String.fromCharCode(s)}return n},c=(e,r,t)=>{if(t===void 0&&(t=2147483647),t<4)return 0;for(var n=r,s=n+t-4,u=0;u<e.length;++u){var l=e.charCodeAt(u);if(l>=55296&&l<=57343){var f=e.charCodeAt(++u);l=65536+((l&1023)<<10)|f&1023}if(W[r>>2]=l,r+=4,r+4>s)break}return W[r>>2]=0,r-n},d=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n>=55296&&n<=57343&&++t,r+=4}return r},v=function(e,r,t){t=he(t);var n,s,u,l,f;r===2?(n=Wt,s=zt,l=ut,u=()=>Je,f=1):r===4&&(n=Nt,s=c,l=d,u=()=>z,f=2),Ee(e,{name:t,fromWireType:function(g){for(var m=z[g>>2],$=u(),k,T=g+4,P=0;P<=m;++P){var x=g+4+P*r;if(P==m||$[x>>f]==0){var Y=x-T,J=n(T,Y);k===void 0?k=J:(k+=String.fromCharCode(0),k+=J),T=x+r}}return Fe(g),k},toWireType:function(g,m){typeof m!="string"&&V(`Cannot pass non-string to C++ string type ${t}`);var $=l(m),k=kt(4+$+r);return z[k>>2]=$>>f,s(m,k+4,$+r),g!==null&&g.push(Fe,k),k},argPackAdvance:8,readValueFromPointer:$r,destructorFunction:function(g){Fe(g)}})};function E(e,r){r=he(r),Ee(e,{isVoid:!0,name:r,argPackAdvance:0,fromWireType:function(){},toWireType:function(t,n){}})}var A={};function M(e){var r=A[e];return r===void 0?he(e):r}var I=[];function R(e,r,t,n){e=I[e],r=Tr.toValue(r),t=M(t),e(r,t,null,n)}function G(e){var r=I.length;return I.push(e),r}function j(e,r){var t=Ie[e];return t===void 0&&V(r+" has unknown type "+_t(e)),t}function ne(e,r){for(var t=new Array(e),n=0;n<e;++n)t[n]=j(z[r+n*4>>2],"parameter "+n);return t}var oe=[];function fe(e,r){var t=ne(e,r),n=t[0],s=n.name+"_$"+t.slice(1).map(function(x){return x.name}).join("_")+"$",u=oe[s];if(u!==void 0)return u;for(var l=["retType"],f=[n],g="",m=0;m<e-1;++m)g+=(m!==0?", ":"")+"arg"+m,l.push("argType"+m),f.push(t[1+m]);for(var $=Cr("methodCaller_"+s),k="return function "+$+`(handle, name, destructors, args) {
  60. `,T=0,m=0;m<e-1;++m)k+=" var arg"+m+" = argType"+m+".readValueFromPointer(args"+(T?"+"+T:"")+`);
  61. `,T+=t[m+1].argPackAdvance;k+=" var rv = handle[name]("+g+`);
  62. `;for(var m=0;m<e-1;++m)t[m+1].deleteObject&&(k+=" argType"+m+".deleteObject(arg"+m+`);
  63. `);n.isVoid||(k+=` return retType.toWireType(destructors, rv);
  64. `),k+=`};
  65. `,l.push(k);var P=Et(Function,l).apply(null,f);return u=G(P),oe[s]=u,u}function pe(e,r){return r+2097152>>>0<4194305-!!e?(e>>>0)+r*4294967296:NaN}var Te=()=>{Ue("")};function Be(){return Date.now()}var Re=()=>K.length,fr=()=>Re(),St=(e,r,t)=>K.copyWithin(e,r,r+t),Ge=e=>{Ue("OOM")},Mn=e=>{K.length,Ge()},Or={},Vt=()=>b||"./this.program",Ze=()=>{if(!Ze.strings){var e=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",r={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:Vt()};for(var t in Or)Or[t]===void 0?delete r[t]:r[t]=Or[t];var n=[];for(var t in r)n.push(`${t}=${r[t]}`);Ze.strings=n}return Ze.strings},ui=(e,r)=>{for(var t=0;t<e.length;++t)ee[r++>>0]=e.charCodeAt(t);ee[r>>0]=0},fi=(e,r)=>{var t=0;return Ze().forEach(function(n,s){var u=r+t;z[e+s*4>>2]=u,ui(n,u),t+=n.length+1}),0},li=(e,r)=>{var t=Ze();z[e>>2]=t.length;var n=0;return t.forEach(function(s){n+=s.length+1}),z[r>>2]=n,0};function ci(e){try{var r=ue.getStreamFromFD(e);return i.close(r),0}catch(t){if(typeof i>"u"||t.name!=="ErrnoError")throw t;return t.errno}}function di(e,r){try{var t=0,n=0,s=0,u=ue.getStreamFromFD(e),l=u.tty?2:i.isDir(u.mode)?3:i.isLink(u.mode)?7:4;return ee[r>>0]=l,we[r+2>>1]=s,Q=[t>>>0,(U=t,+Math.abs(U)>=1?U>0?+Math.floor(U/4294967296)>>>0:~~+Math.ceil((U-+(~~U>>>0))/4294967296)>>>0:0)],W[r+8>>2]=Q[0],W[r+12>>2]=Q[1],Q=[n>>>0,(U=n,+Math.abs(U)>=1?U>0?+Math.floor(U/4294967296)>>>0:~~+Math.ceil((U-+(~~U>>>0))/4294967296)>>>0:0)],W[r+16>>2]=Q[0],W[r+20>>2]=Q[1],0}catch(f){if(typeof i>"u"||f.name!=="ErrnoError")throw f;return f.errno}}var hi=(e,r,t,n)=>{for(var s=0,u=0;u<t;u++){var l=z[r>>2],f=z[r+4>>2];r+=8;var g=i.read(e,ee,l,f,n);if(g<0)return-1;if(s+=g,g<f)break;typeof n<"u"&&(n+=g)}return s};function pi(e,r,t,n){try{var s=ue.getStreamFromFD(e),u=hi(s,r,t);return z[n>>2]=u,0}catch(l){if(typeof i>"u"||l.name!=="ErrnoError")throw l;return l.errno}}function vi(e,r,t,n,s){var u=pe(r,t);try{if(isNaN(u))return 61;var l=ue.getStreamFromFD(e);return i.llseek(l,u,n),Q=[l.position>>>0,(U=l.position,+Math.abs(U)>=1?U>0?+Math.floor(U/4294967296)>>>0:~~+Math.ceil((U-+(~~U>>>0))/4294967296)>>>0:0)],W[s>>2]=Q[0],W[s+4>>2]=Q[1],l.getdents&&u===0&&n===0&&(l.getdents=null),0}catch(f){if(typeof i>"u"||f.name!=="ErrnoError")throw f;return f.errno}}var mi=(e,r,t,n)=>{for(var s=0,u=0;u<t;u++){var l=z[r>>2],f=z[r+4>>2];r+=8;var g=i.write(e,ee,l,f,n);if(g<0)return-1;s+=g,typeof n<"u"&&(n+=g)}return s};function gi(e,r,t,n){try{var s=ue.getStreamFromFD(e),u=mi(s,r,t);return z[n>>2]=u,0}catch(l){if(typeof i>"u"||l.name!=="ErrnoError")throw l;return l.errno}}var xn=function(e,r,t,n){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=i.nextInode++,this.name=r,this.mode=t,this.node_ops={},this.stream_ops={},this.rdev=n},Kr=365,Qr=146;Object.defineProperties(xn.prototype,{read:{get:function(){return(this.mode&Kr)===Kr},set:function(e){e?this.mode|=Kr:this.mode&=~Kr}},write:{get:function(){return(this.mode&Qr)===Qr},set:function(e){e?this.mode|=Qr:this.mode&=~Qr}},isFolder:{get:function(){return i.isDir(this.mode)}},isDevice:{get:function(){return i.isChrdev(this.mode)}}}),i.FSNode=xn,i.createPreloadedFile=Zt,i.staticInit(),nt(),Ve=o.BindingError=class extends Error{constructor(r){super(r),this.name="BindingError"}},Qe=o.InternalError=class extends Error{constructor(r){super(r),this.name="InternalError"}},jt(),Mt(),yn(),wt=o.UnboundTypeError=Pn(Error,"UnboundTypeError"),Sn(),kn();var yi={p:gr,C:en,w:Hr,t:rn,n:Ut,r:Cn,q:Tn,d:Ct,D:Ht,k:Fn,c:Rn,b:On,j:or,f:v,o:E,g:R,m:Tt,l:fe,a:Te,e:Be,v:fr,A:St,u:Mn,y:fi,z:li,i:ci,x:di,B:pi,s:vi,h:gi};Yt();var kt=e=>(kt=X.G)(e),Fe=e=>(Fe=X.I)(e),In=()=>(In=X.J)(),jn=e=>(jn=X.K)(e);o.__embind_initialize_bindings=()=>(o.__embind_initialize_bindings=X.L)();var Ln=e=>(Ln=X.M)(e);o.dynCall_viiijj=(e,r,t,n,s,u,l,f)=>(o.dynCall_viiijj=X.N)(e,r,t,n,s,u,l,f),o.dynCall_jij=(e,r,t,n)=>(o.dynCall_jij=X.O)(e,r,t,n),o.dynCall_jii=(e,r,t)=>(o.dynCall_jii=X.P)(e,r,t),o.dynCall_jiji=(e,r,t,n,s)=>(o.dynCall_jiji=X.Q)(e,r,t,n,s);var Yr;er=function e(){Yr||Bn(),Yr||(er=e)};function Bn(){if(Pe>0||(Mr(),Pe>0))return;function e(){Yr||(Yr=!0,o.calledRun=!0,!ie&&(xr(),h(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),He()))}o.setStatus?(o.setStatus("Running..."),setTimeout(function(){setTimeout(function(){o.setStatus("")},1),e()},1)):e()}if(o.preInit)for(typeof o.preInit=="function"&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return Bn(),a.ready}})(),to=Object.defineProperty,no=Object.getOwnPropertyDescriptor,Yn=(p,a,o,h)=>{for(var y=h>1?void 0:h?no(a,o):a,_=p.length-1,b;_>=0;_--)(b=p[_])&&(y=(h?b(a,o,y):b(y))||y);return h&&y&&to(a,o,y),y};class Zn extends de{constructor(){super(...arguments),this.sampleRate=0,this.channels=0}initialize(){return new Promise(a=>{const o={};o.print=h=>console.log(h),o.printErr=h=>console.log(`[JS] ERROR: ${h}`),o.onAbort=()=>console.log("[JS] FATAL: WASM ABORTED"),o.postRun=h=>{this.module=h,this.decoder=new this.module.AudioDecoder(this),a()},ro(o)})}configure(a){this.config=a,this.decoder.setCodec(this.config.codec,this.config.description??"")}decode(a){this.decoder.decode(a.data,a.timestamp)}flush(){}reset(){this.config=void 0,this.decoder&&this.decoder.clear()}close(){this.removeAllListeners(),this.decoder&&(this.decoder.clear(),this.decoder.delete())}audioInfo(a,o){this.sampleRate=a,this.channels=o;let h={sampleRate:a,channels:o,depth:16};this.emit(Gt.AudioCodecInfo,h)}pcmData(a,o,h){if(!this.module)return;let y=[],_=0,b=0;for(let S=0;S<this.channels;S++){let w=this.module.HEAPU32[(a>>2)+S]>>2;const C=this.module.HEAPF32.subarray(w,w+o);y.push(C),_+=C.length}const D=new Float32Array(_);this.emit(Gt.AudioFrame,new AudioData({format:"f32-planar",sampleRate:this.sampleRate,numberOfChannels:this.channels,timestamp:h,numberOfFrames:o,data:y.reduce((S,w)=>(S.subarray(b).set(w),b+=w.length,S),D)}))}errorInfo(a){let o={errMsg:a};this.emit(Gt.Error,o)}}Yn([ke(de.INIT,"initialized")],Zn.prototype,"initialize",1);Yn([ke("initialized","configured",{sync:!0})],Zn.prototype,"configure",1);Yn([Ti("configured")],Zn.prototype,"decode",1);Yn([ke("configured","initialized",{sync:!0})],Zn.prototype,"reset",1);Yn([ke([],"closed",{sync:!0})],Zn.prototype,"close",1);var io=Object.defineProperty,oo=Object.getOwnPropertyDescriptor,Jn=(p,a,o,h)=>{for(var y=h>1?void 0:h?oo(a,o):a,_=p.length-1,b;_>=0;_--)(b=p[_])&&(y=(h?b(a,o,y):b(y))||y);return h&&y&&io(a,o,y),y};class ei extends de{async initialize(){this.decoder=new AudioDecoder({output:a=>{this.emit(Gt.AudioFrame,a)},error:a=>{this.emit(Gt.Error,a),this.close()}})}configure(a){this.config=a,this.decoder.configure({...a,codec:this.getCodec(a)})}getCodec(a){switch(a.codec){case"aac":return"mp4a.40.2";case"pcma":return"alaw";case"pcmu":return"ulaw";default:return a.codec}}decode(a){this.decoder.state==="configured"&&this.decoder.decode(new EncodedAudioChunk(a))}flush(){this.decoder.flush()}reset(){this.decoder.reset()}close(){this.decoder.state!=="closed"&&this.decoder.close()}}Jn([ke([de.INIT,"closed"],"initialized")],ei.prototype,"initialize",1);Jn([ke("initialized","configured",{sync:!0})],ei.prototype,"configure",1);Jn([Ti("configured")],ei.prototype,"decode",1);Jn([ke([],de.INIT,{sync:!0})],ei.prototype,"reset",1);Jn([ke([],"closed",{ignoreError:!0,sync:!0})],ei.prototype,"close",1);var Hn=(p=>(p.AUDIO_ENCODER_CONFIG_CHANGED="audio-encoder-config-changed",p.VIDEO_ENCODER_CONFIG_CHANGED="video-encoder-config-changed",p.DEMUX_ERROR="demux-error",p))(Hn||{}),Wn=(p=>(p[p.PULL=0]="PULL",p[p.PUSH=1]="PUSH",p))(Wn||{});class so extends qt.EventEmitter{constructor(a,o=0,h="annexb"){super(),this.source=a,this.mode=o,this.format=h,Object.getPrototypeOf(this).constructor.name,a&&(o==0?this.startPull(a):a.oput=new qn(this.demux()))}startPull(a){this.mode=0,this.source=a,this.audioReadable=new ReadableStream({pull:async o=>o.enqueue(await this.pullAudio())}),this.videoReadable=new ReadableStream({pull:async o=>o.enqueue(await this.pullVideo())})}pullAudio(){return new Promise((a,o)=>{this.gotAudio=a,this.gotVideo&&this.pull().catch(o)})}pullVideo(){return new Promise((a,o)=>{this.gotVideo=a,this.gotAudio&&this.pull().catch(o)})}}const Oi=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350,-1,-1,-1];function Fi(p,a=!1,o){const h=new Uint8Array([0,0,0,1]);let y=0;if(a&&o&&o.length>0)for(const w of o)w instanceof Uint8Array&&w.length>0&&(y+=w.length+4);let _=0,b=0;for(;b<p.length&&!(b+4>p.length);){const w=p[b]<<24|p[b+1]<<16|p[b+2]<<8|p[b+3];if(w<0||b+4+w>p.length)break;_+=w+4,b+=4+w}y+=_;const D=new Uint8Array(y);let S=0;if(a&&o&&o.length>0){for(const w of o)if(w instanceof Uint8Array&&w.length>0){if(S+4+w.length>D.length)return console.error("Error writing parameter set: buffer overflow"),D.slice(0,S);D.set(h,S),D.set(w,S+4),S+=w.length+4}}for(b=0;b<p.length&&!(b+4>p.length);){const w=p[b]<<24|p[b+1]<<16|p[b+2]<<8|p[b+3];if(w<0||b+4+w>p.length)break;if(S+4+w>D.length){console.error("Error writing NALU from AVCC: buffer overflow");break}D.set(h,S),D.set(p.subarray(b+4,b+4+w),S+4),S+=w+4,b+=4+w}return S!==y?D.slice(0,S):D}function Co(p){const a=((p[2]&192)>>>6)+1,o=(p[2]&60)>>>2,h=(p[2]&1)<<2|(p[3]&192)>>>6,y=new Uint8Array([(a&3)<<3|(o&14)>>1,(o&1)<<7|(h&15)<<3]);return{profile:a,sampleRate:Oi[o],channel:h,audioSpecificConfig:y}}function Di(p){const a=[],o=[];let h=0;if(!p||p.length<7)return console.error("Invalid AVCC data: too short"),{sps:a,pps:o};h+=5;const y=p[h++]&31;for(let b=0;b<y;b++){if(h+2>p.length){console.error("Invalid AVCC data: not enough bytes for SPS length");break}const D=p[h]<<8|p[h+1];if(h+=2,h+D>p.length){console.error("Invalid AVCC data: not enough bytes for SPS NAL unit");break}a.push(p.subarray(h,h+D)),h+=D}if(h+1>p.length)return y>0&&a.length,{sps:a,pps:o};const _=p[h++];for(let b=0;b<_;b++){if(h+2>p.length){console.error("Invalid AVCC data: not enough bytes for PPS length");break}const D=p[h]<<8|p[h+1];if(h+=2,h+D>p.length){console.error("Invalid AVCC data: not enough bytes for PPS NAL unit");break}o.push(p.subarray(h,h+D)),h+=D}return{sps:a,pps:o}}function ao(p){const a=[],o=[],h=[];let y=0;if(!p||p.length<23)return console.error("Invalid HVCC data: too short for header"),{vps:a,sps:o,pps:h};y+=22;const _=p[y++];if(y+_*3>p.length)return console.error("Invalid HVCC data: numOfArrays inconsistent with data length"),{vps:a,sps:o,pps:h};for(let b=0;b<_;b++){if(y+3>p.length){console.error("Invalid HVCC data: not enough bytes for NAL unit array header");break}const D=p[y]&63;y++;const S=p[y]<<8|p[y+1];y+=2;let w=!1;for(let C=0;C<S;C++){if(y+2>p.length){console.error("Invalid HVCC data: not enough bytes for NAL unit length"),w=!0;break}const F=p[y]<<8|p[y+1];if(y+=2,y+F>p.length){console.error("Invalid HVCC data: not enough bytes for NAL unit data"),w=!0;break}const H=p.subarray(y,y+F);switch(y+=F,D){case 32:a.push(H);break;case 33:o.push(H);break;case 34:h.push(H);break}}if(w)break}return{vps:a,sps:o,pps:h}}const uo="hvc1",fo="av01";class $o extends so{constructor(){super(...arguments),this.tmp8=new Uint8Array(4),this.dv=new DataView(this.tmp8.buffer)}async pullTag(){const a=new Uint8Array(15);return this.pullTag=async()=>{await this.source.read(a);const o=a[4],h=this.readLength(a.subarray(5,8)),y=this.readTimestamp(a.subarray(8,11)),_=await this.source.read(h);return{type:o,data:_.slice(),timestamp:y}},console.time("flv"),await this.source.read(9).then(o=>{if(this.header=o,o.subarray(0,3).reduce((h,y)=>h+String.fromCharCode(y),"")!=="FLV")throw new Error("not flv");console.timeEnd("flv")}),this.pullTag()}readTag(a){const o=a[0],h=this.readLength(a.subarray(1,4)),y=this.readTimestamp(a.subarray(4,8));this.gotTag(o,a.subarray(11,11+h),y)}gotTag(a,o,h){switch(a){case 8:return this.audioDecoderConfig||(this.audioDecoderConfig={codec:{10:"aac",7:"pcma",8:"pcmu"}[o[0]>>4]||"unknown",numberOfChannels:1,sampleRate:8e3},this.audioDecoderConfig.codec=="aac"?(this.audioDecoderConfig.numberOfChannels=o[3]>>3&15,this.audioDecoderConfig.sampleRate=Oi[(o[2]&7)<<1|o[3]>>7]):this.emit(Hn.AUDIO_ENCODER_CONFIG_CHANGED,this.audioDecoderConfig)),this.audioDecoderConfig.codec=="aac"&&o[1]==0?(this.audioDecoderConfig.description=o.subarray(2),this.emit(Hn.AUDIO_ENCODER_CONFIG_CHANGED,this.audioDecoderConfig),this.mode==Wn.PULL?this.pull():void 0):this.gotAudio?.({type:"key",data:this.audioDecoderConfig.codec=="aac"?o.subarray(2):o.subarray(1),timestamp:h,duration:0});case 9:if(o[0]>>7){const b=o[0]&15;if(b){const D=(o[0]&112)>>4==1,S=b===3,w=o.subarray(S?5:8);return this.gotVideo?.({type:D?"key":"delta",data:this.format==="annexb"&&this.videoDecoderConfig?.codec!=="av1"?Fi(w,D,this.videoDecoderConfig.parameterSets):w,timestamp:h,duration:0})}else{switch(o.subarray(1,5).reduce((D,S)=>D+String.fromCharCode(S),"")){case uo:const D={codec:"hevc",description:o.subarray(5)};if(this.format==="annexb"){const S=ao(D.description);this.videoDecoderConfig={codec:"hevc",parameterSets:[S.vps[0],S.sps[0],S.pps[0]]}}else this.videoDecoderConfig=D;break;case fo:this.videoDecoderConfig={codec:"av1"};break}return this.emit(Hn.VIDEO_ENCODER_CONFIG_CHANGED,this.videoDecoderConfig),this.mode==Wn.PULL?this.pull():void 0}}else if(o[1]===0){const b={codec:{7:"avc",12:"hevc",13:"av1"}[o[0]&15]||"unknown",description:o.subarray(5)};if(b.codec=="av1")this.videoDecoderConfig={codec:"av1"};else if(this.format==="annexb"){const D=b.codec==="hevc";let S=[];if(D){const w=Di(b.description);S=[w.vps[0],w.sps[0],w.pps[0]]}else{const w=Di(b.description);S=[w.sps[0],w.pps[0]]}this.videoDecoderConfig={codec:b.codec,parameterSets:S}}else this.videoDecoderConfig=b;return this.emit(Hn.VIDEO_ENCODER_CONFIG_CHANGED,this.videoDecoderConfig),this.mode==Wn.PULL?this.pull():void 0}const y=o[0]>>4==1,_=o.subarray(5);return this.gotVideo?.({type:y?"key":"delta",data:this.format==="annexb"&&this.videoDecoderConfig?.codec!=="av1"?Fi(_,y,this.videoDecoderConfig.parameterSets):_,timestamp:h,duration:0});default:if(this.mode==Wn.PULL)return this.pull()}}async pull(){const a=await this.pullTag();if(a)return this.gotTag(a.type,a.data,a.timestamp)}readLength(a){return this.tmp8[0]=0,this.tmp8.set(a,1),this.dv.getUint32(0)}readTimestamp(a){this.tmp8.set(a.subarray(0,3),1);let o=this.dv.getUint32(0);return o===16777215&&(this.tmp8[0]=a[3],o=this.dv.getUint32(0)),o}readHead(a){if(console.time("flv"),this.header=a,a.subarray(0,3).reduce((o,h)=>o+String.fromCharCode(h),"")!=="FLV")throw new Error("not flv");console.timeEnd("flv")}*demux(){for(this.readHead(yield 13);;){let a=yield 11;const o=a[0],h=this.readLength(a.subarray(1,4)),y=this.readTimestamp(a.subarray(4,8));a=yield h,this.gotTag(o,a.slice(),y),yield 4}}}class To{constructor(a){this.initialized=!1,this.audioQueue=[],this.nextAudioStartTime=0,this.display=a;const o=a.getContext("2d");if(!o)throw new Error("Failed to get 2d context");this.ctx=o,this.audioContext=new AudioContext}async writeAudio(a){const o=a.numberOfChannels,h=a.numberOfFrames,y=a.sampleRate,_=new AudioBuffer({length:h,numberOfChannels:o,sampleRate:y});for(let b=0;b<o;b++){const D=new Float32Array(h);a.copyTo(D,{planeIndex:b}),_.copyToChannel(D,b)}this.scheduleAudioBuffer(_),a.close()}scheduleAudioBuffer(a){const o=this.audioContext.currentTime;this.audioQueue.length===0&&o>this.nextAudioStartTime&&(this.nextAudioStartTime=o),this.audioQueue.push({buffer:a,startTime:this.nextAudioStartTime}),this.nextAudioStartTime+=a.duration,this.processAudioQueue()}processAudioQueue(){const a=this.audioContext.currentTime;for(;this.audioQueue.length>0&&this.audioQueue[0].startTime+this.audioQueue[0].buffer.duration<a;)this.audioQueue.shift();for(;this.audioQueue.length>0;){const o=this.audioQueue[0];if(o.startTime>a)break;const h=this.audioContext.createBufferSource();h.buffer=o.buffer,h.connect(this.audioContext.destination);const y=Math.max(0,a-o.startTime);o.buffer.duration-y>0&&h.start(a,y),this.audioQueue.shift()}}writeVideo(a){(this.display.width!==a.displayWidth||this.display.height!==a.displayHeight)&&(this.display.width=a.displayWidth,this.display.height=a.displayHeight),this.ctx.drawImage(a,0,0,a.displayWidth,a.displayHeight),a.close()}close(){this.audioContext.close()}}export{Zn as A,so as B,To as C,Wn as D,$o as F,yo as V,vo as W,ei as a,ft as b,Gt as c,Qn as d,ho as e,Hn as f,bo as g,At as h,Co as i,po as j};
  66. //# sourceMappingURL=canvas-2aaf4e1d.js.map