canvas-14fb4930.js 200 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. var ft=(h=>(h.VideoCodecInfo="videoCodecInfo",h.VideoFrame="videoFrame",h.Error="error",h))(ft||{}),Gt=(h=>(h.AudioCodecInfo="audioCodecInfo",h.AudioFrame="audioFrame",h.Error="error",h))(Gt||{}),qt={},Ui={get exports(){return qt},set exports(h){qt=h}};(function(h){var a=Object.prototype.hasOwnProperty,o="~";function p(){}Object.create&&(p.prototype=Object.create(null),new p().__proto__||(o=!1));function g(F,w,T){this.fn=F,this.context=w,this.once=T||!1}function _(F,w,T,k,K){if(typeof T!="function")throw new TypeError("The listener must be a function");var Y=new g(T,k||F,K),X=o?o+w:w;return F._events[X]?F._events[X].fn?F._events[X]=[F._events[X],Y]:F._events[X].push(Y):(F._events[X]=Y,F._eventsCount++),F}function b(F,w){--F._eventsCount===0?F._events=new p:delete F._events[w]}function U(){this._events=new p,this._eventsCount=0}U.prototype.eventNames=function(){var w=[],T,k;if(this._eventsCount===0)return w;for(k in T=this._events)a.call(T,k)&&w.push(o?k.slice(1):k);return Object.getOwnPropertySymbols?w.concat(Object.getOwnPropertySymbols(T)):w},U.prototype.listeners=function(w){var T=o?o+w:w,k=this._events[T];if(!k)return[];if(k.fn)return[k.fn];for(var K=0,Y=k.length,X=new Array(Y);K<Y;K++)X[K]=k[K].fn;return X},U.prototype.listenerCount=function(w){var T=o?o+w:w,k=this._events[T];return k?k.fn?1:k.length:0},U.prototype.emit=function(w,T,k,K,Y,X){var W=o?o+w:w;if(!this._events[W])return!1;var R=this._events[W],oe=arguments.length,H,ne;if(R.fn){switch(R.once&&this.removeListener(w,R.fn,void 0,!0),oe){case 1:return R.fn.call(R.context),!0;case 2:return R.fn.call(R.context,T),!0;case 3:return R.fn.call(R.context,T,k),!0;case 4:return R.fn.call(R.context,T,k,K),!0;case 5:return R.fn.call(R.context,T,k,K,Y),!0;case 6:return R.fn.call(R.context,T,k,K,Y,X),!0}for(ne=1,H=new Array(oe-1);ne<oe;ne++)H[ne-1]=arguments[ne];R.fn.apply(R.context,H)}else{var Ce=R.length,ee;for(ne=0;ne<Ce;ne++)switch(R[ne].once&&this.removeListener(w,R[ne].fn,void 0,!0),oe){case 1:R[ne].fn.call(R[ne].context);break;case 2:R[ne].fn.call(R[ne].context,T);break;case 3:R[ne].fn.call(R[ne].context,T,k);break;case 4:R[ne].fn.call(R[ne].context,T,k,K);break;default:if(!H)for(ee=1,H=new Array(oe-1);ee<oe;ee++)H[ee-1]=arguments[ee];R[ne].fn.apply(R[ne].context,H)}}return!0},U.prototype.on=function(w,T,k){return _(this,w,T,k,!1)},U.prototype.once=function(w,T,k){return _(this,w,T,k,!0)},U.prototype.removeListener=function(w,T,k,K){var Y=o?o+w:w;if(!this._events[Y])return this;if(!T)return b(this,Y),this;var X=this._events[Y];if(X.fn)X.fn===T&&(!K||X.once)&&(!k||X.context===k)&&b(this,Y);else{for(var W=0,R=[],oe=X.length;W<oe;W++)(X[W].fn!==T||K&&!X[W].once||k&&X[W].context!==k)&&R.push(X[W]);R.length?this._events[Y]=R.length===1?R[0]:R:b(this,Y)}return this},U.prototype.removeAllListeners=function(w){var T;return w?(T=o?o+w:w,this._events[T]&&b(this,T)):(this._events=new p,this._eventsCount=0),this},U.prototype.off=U.prototype.removeListener,U.prototype.addListener=U.prototype.on,U.prefixed=o,U.EventEmitter=U,h.exports=U})(Ui);const Si=Symbol("instance"),wi=Symbol("cacheResult");let _i=class{constructor(a,o,p){this.oldState=a,this.newState=o,this.action=p,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,p){super(o),this.state=a,this.message=o,this.cause=p}};function Mi(h){return typeof h=="object"&&h&&"then"in h}const zn=new Map;function ii(h,a,o={}){return(p,g,_)=>{const b=o.action||g;if(!o.context){const F=zn.get(p)||[];zn.has(p)||zn.set(p,F),F.push({from:h,to:a,action:b})}const U=_.value;_.value=function(...F){let w=this;if(o.context&&(w=cr.get(typeof o.context=="function"?o.context.call(this,...F):o.context)),w.state===a)return w[wi];w.state instanceof _i&&w.state.action==o.abortAction&&w.state.abort(w);let T=null;if(Array.isArray(h)?h.length==0?w.state instanceof _i&&w.state.abort(w):(typeof w.state!="string"||!h.includes(w.state))&&(T=new ni(w._state,`${w.name} ${b} to ${a} failed: current state ${w._state} not in from config`)):h!==w.state&&(T=new ni(w._state,`${w.name} ${b} to ${a} failed: current state ${w._state} not from ${h}`)),T)if(o.fail)o.fail.call(this,T);else{if(o.ignoreError)return T;throw T}const k=w.state,K=new _i(k,a,b);Nn.call(w,K);const Y=W=>{var R;return w[wi]=W,K.aborted||(Nn.call(w,a),(R=o.success)===null||R===void 0||R.call(this,w[wi])),W},X=W=>{const R=W instanceof Error?W.message:String(W);if(Nn.call(w,k,W),o.fail)o.fail.call(this,new ni(w._state,`action '${b}' failed :${R}`,W instanceof Error?W:new Error(R)));else{if(o.ignoreError)return W;throw W}};try{const W=U.apply(this,F);return Mi(W)?W.then(Y).catch(X):Y(W)}catch(W){X(W)}}}}function xi(...h){return(a,o,p)=>{const g=p.value,_=o;p.value=function(...b){if(!h.includes(this.state.toString()))throw new ni(this.state,`${this.name} ${_} failed: current state ${this.state} not in ${h}`);return g.apply(this,b)}}}const Ii=(()=>typeof window<"u"&&window.__AFSM__?(o,p)=>{window.dispatchEvent(new CustomEvent(o,{detail:p}))}:typeof importScripts<"u"?(o,p)=>{postMessage({type:o,payload:p})}:()=>{})();function Nn(h,a){const o=this._state;this._state=h;const p=h.toString();h&&this.emit(p,o),this.emit(cr.STATECHANGED,h,o,a),this.updateDevTools({value:h,old:o,err:a instanceof Error?a.message:String(a)})}let cr=class lr extends qt{constructor(a,o,p){super(),this.name=a,this.groupName=o,this._state=lr.INIT,a||(a=Date.now().toString(36)),p?Object.setPrototypeOf(this,p):p=Object.getPrototypeOf(this),o||(this.groupName=this.constructor.name);const g=p[Si];g?this.name=g.name+"-"+g.count++:p[Si]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){const a=Object.getPrototypeOf(this),o=zn.get(a)||[];let p=new Set,g=[],_=[];const b=new Set,U=Object.getPrototypeOf(a);zn.has(U)&&(U.stateDiagram.forEach(w=>p.add(w)),U.allStates.forEach(w=>b.add(w))),o.forEach(({from:w,to:T,action:k})=>{typeof w=="string"?g.push({from:w,to:T,action:k}):w.length?w.forEach(K=>{g.push({from:K,to:T,action:k})}):_.push({to:T,action:k})}),g.forEach(({from:w,to:T,action:k})=>{b.add(w),b.add(T),b.add(k+"ing"),p.add(`${w} --> ${k}ing : ${k}`),p.add(`${k}ing --> ${T} : ${k} 🟢`),p.add(`${k}ing --> ${w} : ${k} 🔴`)}),_.forEach(({to:w,action:T})=>{p.add(`${T}ing --> ${w} : ${T} 🟢`),b.forEach(k=>{k!==w&&p.add(`${k} --> ${T}ing : ${T}`)})});const F=[...p];return Object.defineProperties(a,{stateDiagram:{value:F},allStates:{value:b}}),F}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=(h=>(h.CONNECTED="connected",h.DISCONNECTED="disconnected",h.RECONNECTED="reconnected",h))(lt||{}),ji=globalThis&&globalThis.__awaiter||function(h,a,o,p){function g(_){return _ instanceof o?_:new o(function(b){b(_)})}return new(o||(o=Promise))(function(_,b){function U(T){try{w(p.next(T))}catch(k){b(k)}}function F(T){try{w(p.throw(T))}catch(k){b(k)}}function w(T){T.done?_(T.value):g(T.value).then(U,F)}w((p=p.apply(h,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,p)=>{var g;this.reject=p,this.resolve=b=>{delete this.lastReadPromise,delete this.resolve,delete this.need,o(b)},this.demand(a,!0)||(g=this.pull)===null||g===void 0||g.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 p=0;const g=_=>o.length<(p=_);if(typeof this.need=="number"){if(g(this.need))return;a=o.subarray(0,p)}else if(this.need===Ei){if(g(4))return;a=o[0]<<24|o[1]<<16|o[2]<<8|o[3]}else if(this.need===Pi){if(g(2))return;a=o[0]<<8|o[1]}else if(this.need===Ci){if(g(1))return;a=o[0]}else if("buffer"in this.need){if("byteOffset"in this.need){if(g(this.need.byteLength-this.need.byteOffset))return;new Uint8Array(this.need.buffer,this.need.byteOffset).set(o.subarray(0,p)),a=this.need}else if(this.g){this.g.throw(new Error("Unsupported type"));return}}else{if(g(this.need.byteLength))return;new Uint8Array(this.need).set(o.subarray(0,p)),a=this.need}return this.consumed+=p,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,p=o+a;if(p<=this.buffer.buffer.byteLength-this.buffer.byteOffset)this.buffer=new Uint8Array(this.buffer.buffer,this.buffer.byteOffset,p);else{const g=new Uint8Array(p);g.set(this.buffer),this.buffer=g}return this.buffer.subarray(o,p)}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=(h,a,o,p)=>{for(var g=p>1?void 0:p?Bi(a,o):a,_=h.length-1,b;_>=0;_--)(b=h[_])&&(g=(p?b(a,o,g):b(g))||g);return p&&g&&Li(a,o,g),g};function Ri(h,a=1,o=1){return h<=1?o:Ri(h-1,o,a+o)}function Hi(h){const a=Math.round(h/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 p=>{var g;return this.down.add(p.length||p.byteLength),(g=this.oput)==null?void 0:g.write(p)}},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(p=>{`${this.url}`,o<this.options.reconnectCount&&this.reconnectAfter(this.options.reconnectTimeout(o),o+1)})},a)}close(){var a;(a=this.abortCtrl)==null||a.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,p)=>{a.onerror=p,a.onopen=()=>{o(new ReadableStream({start:g=>{a.onclose=_=>g.error(_),a.onmessage=_=>g.enqueue(_.data)}}))}})}_close(){var a;(a=this.ws)==null||a.close(1e3,"close")}_send(a){var o;(o=this.ws)==null||o.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(){var a;return this._audioTrack||((a=this._mediaStream)==null?void 0:a.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(){var a;return this._videoTrack||((a=this._mediaStream)==null?void 0:a.getVideoTracks()[0])}close(){this.emit("close")}}const Ai=Symbol("instance"),ti=Symbol("cacheResult");class bi{constructor(a,o,p){this.oldState=a,this.newState=o,this.action=p,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,p){super(o),this.state=a,this.message=o,this.cause=p}}function Wi(h){return typeof h=="object"&&h&&"then"in h}const Vn=new Map;function Ae(h,a,o={}){return(p,g,_)=>{const b=o.action||g;if(!o.context){const F=Vn.get(p)||[];Vn.has(p)||Vn.set(p,F),F.push({from:h,to:a,action:b})}const U=_.value;_.value=function(...F){let w=this;if(o.context&&(w=de.get(typeof o.context=="function"?o.context.call(this,...F):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 T=null;Array.isArray(h)?h.length==0?w.state instanceof bi&&w.state.abort(w):(typeof w.state!="string"||!h.includes(w.state))&&(T=new $i(w._state,`${w.name} ${b} to ${a} failed: current state ${w._state} not from ${h.join("|")}`)):h!==w.state&&(T=new $i(w._state,`${w.name} ${b} to ${a} failed: current state ${w._state} not from ${h}`));const k=R=>{if(o.fail&&o.fail.call(this,R),o.sync){if(o.ignoreError)return R;throw R}else return o.ignoreError?Promise.resolve(R):Promise.reject(R)};if(T)return k(T);const K=w.state,Y=new bi(K,a,b);Gn.call(w,Y);const X=R=>{var oe;return w[ti]=R,Y.aborted||(Gn.call(w,a),(oe=o.success)===null||oe===void 0||oe.call(this,w[ti])),R},W=R=>(Gn.call(w,K,R),k(R));try{const R=U.apply(this,F);return Wi(R)?R.then(X).catch(W):o.sync?X(R):Promise.resolve(X(R))}catch(R){return W(R)}}}}function Ti(...h){return(a,o,p)=>{const g=p.value,_=o;p.value=function(...b){if(!h.includes(this.state.toString()))throw new $i(this.state,`${this.name} ${_} failed: current state ${this.state} not in ${h}`);return g.apply(this,b)}}}const zi=(()=>typeof window<"u"&&window.__AFSM__?(o,p)=>{window.dispatchEvent(new CustomEvent(o,{detail:p}))}:typeof importScripts<"u"?(o,p)=>{postMessage({type:o,payload:p})}:()=>{})();function Gn(h,a){const o=this._state;this._state=h;const p=h.toString();h&&this.emit(p,o),this.emit(de.STATECHANGED,h,o,a),this.updateDevTools({value:h,old:o,err:a instanceof Error?a.message:String(a)})}class de extends qt{constructor(a,o,p){super(),this.name=a,this.groupName=o,this._state=de.INIT,a||(a=Date.now().toString(36)),p?Object.setPrototypeOf(this,p):p=Object.getPrototypeOf(this),o||(this.groupName=this.constructor.name);const g=p[Ai];g?this.name=g.name+"-"+g.count++:p[Ai]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){const a=Object.getPrototypeOf(this),o=Vn.get(a)||[];let p=new Set,g=[],_=[];const b=new Set,U=Object.getPrototypeOf(a);Vn.has(U)&&(U.stateDiagram.forEach(w=>p.add(w)),U.allStates.forEach(w=>b.add(w))),o.forEach(({from:w,to:T,action:k})=>{typeof w=="string"?g.push({from:w,to:T,action:k}):w.length?w.forEach(K=>{g.push({from:K,to:T,action:k})}):_.push({to:T,action:k})}),g.forEach(({from:w,to:T,action:k})=>{b.add(w),b.add(T),b.add(k+"ing"),p.add(`${w} --> ${k}ing : ${k}`),p.add(`${k}ing --> ${T} : ${k} 🟢`),p.add(`${k}ing --> ${w} : ${k} 🔴`)}),_.forEach(({to:w,action:T})=>{p.add(`${T}ing --> ${w} : ${T} 🟢`),b.forEach(k=>{k!==w&&p.add(`${k} --> ${T}ing : ${T}`)})});const F=[...p];return Object.defineProperties(a,{stateDiagram:{value:F},allStates:{value:b}}),F}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=(h,a,o,p)=>{for(var g=p>1?void 0:p?Vi(a,o):a,_=h.length-1,b;_>=0;_--)(b=h[_])&&(g=(p?b(a,o,g):b(g))||g);return p&&g&&Ni(a,o,g),g};function Gi(){var h;self.onmessage=a=>{if(a.data.type==="init"){const{canvas:o,wasmScript:p,wasmBinary:g}=a.data,_=o==null?void 0:o.getContext("2d");let b=0,U=0;const F={wasmBinary:g,postRun:()=>{h=new F.VideoDecoder({videoInfo(w,T){b=w,U=T},yuvData(w,T){const k=b*U,K=k>>2;let Y=F.HEAPU32[w>>2],X=F.HEAPU32[(w>>2)+1],W=F.HEAPU32[(w>>2)+2],R=F.HEAPU8.subarray(Y,Y+k),oe=F.HEAPU8.subarray(X,X+K),H=F.HEAPU8.subarray(W,W+K);const ne=new Uint8Array(k+K+K);ne.set(R),ne.set(oe,k),ne.set(H,k+K);const Ce=new VideoFrame(ne,{codedWidth:b,codedHeight:U,format:"I420",timestamp:T});o?(_==null||_.drawImage(Ce,0,0,o.width,o.height),_==null||_.commit()):self.postMessage({type:"yuvData",videoFrame:Ce},[Ce])}}),self.postMessage({type:"ready"})}};Function("var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;return "+p)()(F)}else if(a.data.type==="decode"){const{packet:o}=a.data;h==null||h.decode(o.data,o.type=="key",o.timestamp)}else if(a.data.type==="setCodec"){const{codec:o,format:p,description:g}=a.data;h==null||h.setCodec(o,p,g??"")}}}class Xt extends de{constructor(a,o,p=!1,g,_=!1){super(),this.createModule=a,this.wasmBinary=o,this.workerMode=p,this.canvas=g,this.yuvMode=_,this.module={},this.width=0,this.height=0}async initialize(a){var p;if(this.workerMode){const g=/\{(.+)\}/s.exec(Gi.toString())[1];this.worker=new Worker(URL.createObjectURL(new Blob([g],{type:"text/javascript"})));const _=(p=this.canvas)==null?void 0:p.transferControlToOffscreen(),b=await this.wasmBinary;return console.warn("worker mode",b),this.worker.postMessage({type:"init",canvas:_,wasmScript:this.createModule.toString(),wasmBinary:b},_?[_,b]:[b]),new Promise(U=>{this.worker.onmessage=F=>{if(F.data.type==="ready")delete this.wasmBinary,U(),console.warn("worker mode initialize success");else if(F.data.type==="yuvData"){const{videoFrame:w}=F.data;this.emit(ft.VideoFrame,w)}}})}const o=this.module;return this.wasmBinary&&(o.wasmBinary=await this.wasmBinary),o.print=g=>console.log(g),o.printErr=g=>console.log(`[JS] ERROR: ${g}`),o.onAbort=()=>console.log("[JS] FATAL: WASM ABORTED"),new Promise(g=>{o.postRun=_=>{this.decoder=new this.module.VideoDecoder(this),g()},a&&Object.assign(o,a),this.createModule(o)})}configure(a){var g,_;this.config=a;const o=this.config.codec.startsWith("avc")?"avc":"hevc",p=this.config.description?o=="avc"?"avcc":"hvcc":"annexb";(g=this.decoder)==null||g.setCodec(o,p,this.config.description??""),(_=this.worker)==null||_.postMessage({type:"setCodec",codec:o,format:p,description:this.config.description})}decode(a){var o,p;(o=this.decoder)==null||o.decode(a.data,a.type=="key",a.timestamp),this.state==="configured"&&((p=this.worker)==null||p.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 p={width:a,height:o};this.emit(ft.VideoCodecInfo,p)}yuvData(a,o){if(!this.module)return;const p=this.width*this.height,g=p>>2;let _=this.module.HEAPU32[a>>2],b=this.module.HEAPU32[(a>>2)+1],U=this.module.HEAPU32[(a>>2)+2],F=this.module.HEAPU8.subarray(_,_+p),w=this.module.HEAPU8.subarray(b,b+g),T=this.module.HEAPU8.subarray(U,U+g);if(this.yuvMode){this.emit(ft.VideoFrame,{y:F,u:w,v:T,timestamp:o});return}const k=new Uint8Array(p+g+g);k.set(F),k.set(w,p),k.set(T,p+g),this.emit(ft.VideoFrame,new VideoFrame(k,{codedWidth:this.width,codedHeight:this.height,format:"I420",timestamp:o}))}errorInfo(a){let o={errMsg:a};this.emit(ft.Error,o)}}oi([Ae([de.INIT,"closed"],"initialized")],Xt.prototype,"initialize",1);oi([Ae("initialized","configured",{sync:!0})],Xt.prototype,"configure",1);oi([Ae([],de.INIT,{sync:!0})],Xt.prototype,"reset",1);oi([Ae([],"closed",{sync:!0})],Xt.prototype,"close",1);var qi=(()=>{var h=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(a={}){var o=a,p,g;o.ready=new Promise((e,r)=>{p=e,g=r});var _=Object.assign({},o),b="./this.program",U=typeof window=="object",F=typeof importScripts=="function";typeof process=="object"&&typeof process.versions=="object"&&process.versions.node;var w="";function T(e){return o.locateFile?o.locateFile(e,w):w+e}var k,K,Y;(U||F)&&(F?w=self.location.href:typeof document<"u"&&document.currentScript&&(w=document.currentScript.src),h&&(w=h),w.indexOf("blob:")!==0?w=w.substr(0,w.replace(/[?#].*/,"").lastIndexOf("/")+1):w="",k=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.send(null),r.responseText},F&&(Y=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),K=(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 X=o.print||console.log.bind(console),W=o.printErr||console.error.bind(console);Object.assign(o,_),_=null,o.arguments&&o.arguments,o.thisProgram&&(b=o.thisProgram),o.quit&&o.quit;var R;o.wasmBinary&&(R=o.wasmBinary),o.noExitRuntime,typeof WebAssembly!="object"&&Me("no native wasm support detected");var oe,H,ne=!1;function Ce(e,r){e||Me(r)}var ee,Q,me,Fe,z,N,dr,hr;function Sr(){var e=oe.buffer;o.HEAP8=ee=new Int8Array(e),o.HEAP16=me=new Int16Array(e),o.HEAP32=z=new Int32Array(e),o.HEAPU8=Q=new Uint8Array(e),o.HEAPU16=Fe=new Uint16Array(e),o.HEAPU32=N=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 We(){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 Qe(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 Me(e){o.onAbort&&o.onAbort(e),e="Aborted("+e+")",W(e),ne=!0,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw g(r),r}var Ft="data:application/octet-stream;base64,";function ct(e){return e.startsWith(Ft)}var ze;ze="videodec.wasm",ct(ze)||(ze=T(ze));function Ir(e){if(e==ze&&R)return new Uint8Array(R);if(Y)return Y(e);throw"both async and sync fetching of the wasm failed"}function Kt(e){return!R&&(U||F)&&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=>{W("failed to asynchronously prepare wasm: "+n),Me(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 W("wasm streaming compile failed: "+l),W("falling back to ArrayBuffer instantiation"),Jr(r,t,n)})}):Jr(r,t,n)}function Yt(){var e={a:gi};function r(n,s){var u=n.exports;return H=u,oe=H.E,Sr(),pr=H.H,_e(H.F),sr(),u}Qe();function t(n){r(n.instance)}if(o.instantiateWasm)try{return o.instantiateWasm(e,r)}catch(n){W("Module.instantiateWasm callback failed with error: "+n),g(n)}return Qt(R,ze,e,t).catch(g),{}}var M,Z,Ar=e=>{for(;e.length>0;)e.shift()(o)};function xe(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(r){N[this.ptr+4>>2]=r},this.get_type=function(){return N[this.ptr+4>>2]},this.set_destructor=function(r){N[this.ptr+8>>2]=r},this.get_destructor=function(){return N[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){N[this.ptr+16>>2]=r},this.get_adjusted_ptr=function(){return N[this.ptr+16>>2]},this.get_exception_ptr=function(){var r=Ln(this.get_type());if(r)return N[this.excPtr>>2];var t=this.get_adjusted_ptr();return t!==0?t:this.excPtr}}var ar=0;function yr(e,r,t){var n=new xe(e);throw n.init(r,t),ar=e,ar}var et=e=>(z[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)},ce=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return e=>crypto.getRandomValues(e);Me("initRandomDevice")},rt=e=>(rt=ce())(e),we={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=we.resolve(e).substr(1),r=we.resolve(r).substr(1);function t(m){for(var C=0;C<m.length&&m[C]==="";C++);for(var S=m.length-1;S>=0&&m[S]==="";S--);return C>S?[]:m.slice(C,S-C+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 y=[],f=l;f<n.length;f++)y.push("..");return y=y.concat(s.slice(l)),y.join("/")}},gr=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Ne=(e,r,t)=>{for(var n=r+t,s=r;e[s]&&!(s>=n);)++s;if(s-r>16&&e.buffer&&gr)return gr.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 y=e[r++]&63;if((l&240)==224?l=(l&15)<<12|f<<6|y:l=(l&7)<<18|f<<12|y<<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},Ie=[],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 y=e.charCodeAt(++l);f=65536+((f&1023)<<10)|y&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(!Ie.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;Ie=Br(e,!0)}return Ie.shift()},De={ttys:[],init:function(){},shutdown:function(){},register:function(e,r){De.ttys[e]={input:[],output:[],ops:r},i.registerDevice(e,De.stream_ops)},stream_ops:{open:function(e){var r=De.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?(X(Ne(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},fsync:function(e){e.output&&e.output.length>0&&(X(Ne(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?(W(Ne(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},fsync:function(e){e.output&&e.output.length>0&&(W(Ne(e.output,0)),e.output=[])}}},tt=e=>{Me()},B={ops_table:null,mount(e){return B.createNode(null,"/",16895,0)},createNode(e,r,t,n){if(i.isBlkdev(t)||i.isFIFO(t))throw new i.ErrnoError(63);B.ops_table||(B.ops_table={dir:{node:{getattr:B.node_ops.getattr,setattr:B.node_ops.setattr,lookup:B.node_ops.lookup,mknod:B.node_ops.mknod,rename:B.node_ops.rename,unlink:B.node_ops.unlink,rmdir:B.node_ops.rmdir,readdir:B.node_ops.readdir,symlink:B.node_ops.symlink},stream:{llseek:B.stream_ops.llseek}},file:{node:{getattr:B.node_ops.getattr,setattr:B.node_ops.setattr},stream:{llseek:B.stream_ops.llseek,read:B.stream_ops.read,write:B.stream_ops.write,allocate:B.stream_ops.allocate,mmap:B.stream_ops.mmap,msync:B.stream_ops.msync}},link:{node:{getattr:B.node_ops.getattr,setattr:B.node_ops.setattr,readlink:B.node_ops.readlink},stream:{}},chrdev:{node:{getattr:B.node_ops.getattr,setattr:B.node_ops.setattr},stream:i.chrdev_stream_ops}});var s=i.createNode(e,r,t,n);return i.isDir(s.mode)?(s.node_ops=B.ops_table.dir.node,s.stream_ops=B.ops_table.dir.stream,s.contents={}):i.isFile(s.mode)?(s.node_ops=B.ops_table.file.node,s.stream_ops=B.ops_table.file.stream,s.usedBytes=0,s.contents=null):i.isLink(s.mode)?(s.node_ops=B.ops_table.link.node,s.stream_ops=B.ops_table.link.stream):i.isChrdev(s.mode)&&(s.node_ops=B.ops_table.chrdev.node,s.stream_ops=B.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&&B.resizeFileStorage(e,r.size)},lookup(e,r){throw i.genericErrors[44]},mknod(e,r,t,n){return B.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=B.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(B.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){B.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 B.stream_ops.write(e,r,0,n,t,!1),0}}},Dt=(e,r,t,n)=>{var s=n?"":`al ${e}`;K(e,u=>{Ce(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&&Qe()},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,y,m){var C=r?we.resolve(q.join2(e,r)):e;function S($){function P(I){m&&m(),f||i.createDataFile(e,r,I,n,s,y),u&&u(),sr()}Ot($,C,P,()=>{l&&l(),sr()})||P($)}Qe(),typeof t=="string"?Dt(t,$=>S($),l):S(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=we.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(S=>!!S),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 y=0;i.isLink(s.mode);){var m=i.readlink(u);u=we.resolve(q.dirname(u),m);var C=i.lookupPath(u,{recurse_count:r.recurse_count+1});if(s=C.node,y++>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&&W(`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:[]},y=e.mount(f);return y.mount=f,f.root=y,n?i.root=y:u&&(u.mounted=f,u.mount&&u.mount.mounts.push(f)),y},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 y=f.name_next;s.includes(f.mount)&&i.destroyNode(f),f=y}}),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(!we.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,y;if(l=i.lookupPath(e,{parent:!0}),f=l.node,l=i.lookupPath(r,{parent:!0}),y=l.node,!f||!y)throw new i.ErrnoError(44);if(f.mount!==y.mount)throw new i.ErrnoError(75);var m=i.lookupNode(f,s),C=we.relative(e,n);if(C.charAt(0)!==".")throw new i.ErrnoError(28);if(C=we.relative(r,t),C.charAt(0)!==".")throw new i.ErrnoError(55);var S;try{S=i.lookupNode(y,u)}catch{}if(m!==S){var $=i.isDir(m.mode),P=i.mayDelete(f,s,$);if(P)throw new i.ErrnoError(P);if(P=S?i.mayDelete(y,u,$):i.mayCreate(y,u),P)throw new i.ErrnoError(P);if(!f.node_ops.rename)throw new i.ErrnoError(63);if(i.isMountpoint(m)||S&&i.isMountpoint(S))throw new i.ErrnoError(10);if(y!==f&&(P=i.nodePermissions(f,"w"),P))throw new i.ErrnoError(P);i.hashRemoveNode(m);try{f.node_ops.rename(m,y,u)}catch(I){throw I}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 we.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=Ne(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)),De.register(i.makedev(5,0),De.default_tty_ops),De.register(i.makedev(6,0),De.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(B,{},"/"),i.createDefaultDirectories(),i.createDefaultDevices(),i.createSpecialDirectories(),i.filesystems={MEMFS:B}},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),y=i.create(l,f);if(t){if(typeof t=="string"){for(var m=new Array(t.length),C=0,S=t.length;C<S;++C)m[C]=t.charCodeAt(C);t=m}i.chmod(y,f|146);var $=i.open(y,577);i.write($,t,0,t.length,0,u),i.close($),i.chmod(y,f)}return y},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,y,m,C,S)=>{for(var $=0,P=0;P<C;P++){var I;try{I=t()}catch{throw new i.ErrnoError(29)}if(I===void 0&&$===0)throw new i.ErrnoError(6);if(I==null)break;$++,y[m+P]=I}return $&&(f.node.timestamp=Date.now()),$},write:(f,y,m,C,S)=>{for(var $=0;$<C;$++)try{n(y[m+$])}catch{throw new i.ErrnoError(29)}return C&&(f.node.timestamp=Date.now()),$}}),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(k)try{e.contents=Br(k(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 I=P%this.chunkSize,J=P/this.chunkSize|0;return this.getter(J)[I]}},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 I=Number(P.getResponseHeader("Content-length")),J,re=(J=P.getResponseHeader("Accept-Ranges"))&&J==="bytes",ae=(J=P.getResponseHeader("Content-Encoding"))&&J==="gzip",ve=1024*1024;re||(ve=I);var te=(ye,Oe)=>{if(ye>Oe)throw new Error("invalid range ("+ye+", "+Oe+") or no bytes requested!");if(Oe>I-1)throw new Error("only "+I+" bytes available! programmer error!");var ue=new XMLHttpRequest;if(ue.open("GET",t,!1),I!==ve&&ue.setRequestHeader("Range","bytes="+ye+"-"+Oe),ue.responseType="arraybuffer",ue.overrideMimeType&&ue.overrideMimeType("text/plain; charset=x-user-defined"),ue.send(null),!(ue.status>=200&&ue.status<300||ue.status===304))throw new Error("Couldn't load "+t+". Status: "+ue.status);return ue.response!==void 0?new Uint8Array(ue.response||[]):Br(ue.responseText||"",!0)},Xe=this;Xe.setDataGetter(ye=>{var Oe=ye*ve,ue=(ye+1)*ve-1;if(ue=Math.min(ue,I-1),typeof Xe.chunks[ye]>"u"&&(Xe.chunks[ye]=te(Oe,ue)),typeof Xe.chunks[ye]>"u")throw new Error("doXHR failed!");return Xe.chunks[ye]}),(ae||!I)&&(ve=I=1,I=this.getter(0).length,ve=I,X("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=I,this._chunkSize=ve,this.lengthKnown=!0},typeof XMLHttpRequest<"u"){if(!F)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 y=i.createFile(e,r,f,n,s);f.contents?y.contents=f.contents:f.url&&(y.contents=null,y.url=f.url),Object.defineProperties(y,{usedBytes:{get:function(){return this.contents.length}}});var m={},C=Object.keys(y.stream_ops);C.forEach($=>{var P=y.stream_ops[$];m[$]=function(){return i.forceLoadFile(y),P.apply(null,arguments)}});function S($,P,I,J,re){var ae=$.node.contents;if(re>=ae.length)return 0;var ve=Math.min(ae.length-re,J);if(ae.slice)for(var te=0;te<ve;te++)P[I+te]=ae[re+te];else for(var te=0;te<ve;te++)P[I+te]=ae.get(re+te);return ve}return m.read=($,P,I,J,re)=>(i.forceLoadFile(y),S($,P,I,J,re)),m.mmap=($,P,I,J,re)=>{i.forceLoadFile(y);var ae=tt();if(!ae)throw new i.ErrnoError(48);return S($,ee,ae,P,I),{ptr:ae,allocated:!0}},y.stream_ops=m,y}},wr=(e,r)=>e?Ne(Q,e,r):"",fe={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=fe.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}z[t>>2]=n.dev,z[t+4>>2]=n.mode,N[t+8>>2]=n.nlink,z[t+12>>2]=n.uid,z[t+16>>2]=n.gid,z[t+20>>2]=n.rdev,Z=[n.size>>>0,(M=n.size,+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[t+24>>2]=Z[0],z[t+28>>2]=Z[1],z[t+32>>2]=4096,z[t+36>>2]=n.blocks;var s=n.atime.getTime(),u=n.mtime.getTime(),l=n.ctime.getTime();return Z=[Math.floor(s/1e3)>>>0,(M=Math.floor(s/1e3),+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[t+40>>2]=Z[0],z[t+44>>2]=Z[1],N[t+48>>2]=s%1e3*1e3,Z=[Math.floor(u/1e3)>>>0,(M=Math.floor(u/1e3),+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[t+56>>2]=Z[0],z[t+60>>2]=Z[1],N[t+64>>2]=u%1e3*1e3,Z=[Math.floor(l/1e3)>>>0,(M=Math.floor(l/1e3),+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[t+72>>2]=Z[0],z[t+76>>2]=Z[1],N[t+80>>2]=l%1e3*1e3,Z=[n.ino>>>0,(M=n.ino,+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[t+88>>2]=Z[0],z[t+92>>2]=Z[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=Q.slice(e,e+t);i.msync(r,u,s,t,n)},varargs:void 0,get(){fe.varargs+=4;var e=z[fe.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){fe.varargs=t;try{var n=fe.getStreamFromFD(e);switch(r){case 0:{var s=fe.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=fe.get();return n.flags|=s,0}case 5:{var s=fe.get(),l=0;return me[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){fe.varargs=n;try{r=fe.getStr(r),r=fe.calculateAt(e,r);var s=n?fe.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;Q[t];)r+=ht[Q[t++]];return r}var Ve={},je={},_r={},Ge=void 0;function V(e){throw new Ge(e)}var Ye=void 0;function br(e){throw new Ye(e)}function tr(e,r,t){e.forEach(function(f){_r[f]=r});function n(f){var y=t(f);y.length!==e.length&&br("Mismatched type converter count");for(var m=0;m<e.length;++m)Ee(e[m],y[m])}var s=new Array(r.length),u=[],l=0;r.forEach((f,y)=>{je.hasOwnProperty(f)?s[y]=je[f]:(u.push(f),Ve.hasOwnProperty(f)||(Ve[f]=[]),Ve[f].push(()=>{s[y]=je[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`),je.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;V(`Cannot register type '${n}' twice`)}if(je[e]=r,delete _r[e],Ve.hasOwnProperty(e)){var s=Ve[e];delete Ve[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=me;else if(t===4)f=z;else throw new TypeError("Unknown boolean type size: "+r);return this.fromWireType(f[l>>u])},destructorFunction:null})}function tn(e){if(!(this instanceof ke)||!(e instanceof ke))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 $e=[];function Nr(){for(;$e.length;){var e=$e.pop();e.$$.deleteScheduled=!1,e.delete()}}var nr=void 0;function ot(e){nr=e,$e.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},Ze(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 y=vt(r,this.registeredClass,f.registeredClass);return y===null?s.call(this):this.isSmartPointer?Pr(f.registeredClass.instancePrototype,{ptrType:f,ptr:y,smartPtrType:this,smartPtr:e}):Pr(f.registeredClass.instancePrototype,{ptrType:f,ptr:y})}var Ze=function(e){return typeof FinalizationRegistry>"u"?(Ze=r=>r,e):(zr=new FinalizationRegistry(r=>{Fr(r.$$)}),Ze=r=>{var t=r.$$,n=!!t.smartPtr;if(n){var s={$$:t};zr.register(r,s,r)}return r},pt=r=>zr.unregister(r),Ze(e))};function yt(){if(this.$$.ptr||Er(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e=Ze(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"),$e.push(this),$e.length===1&&nr&&nr(Nr),this.$$.deleteScheduled=!0,this}function jt(){ke.prototype.isAliasOf=tn,ke.prototype.clone=yt,ke.prototype.delete=fn,ke.prototype.isDeleted=It,ke.prototype.deleteLater=ln}function ke(){}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 Le(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`),Le(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 gt(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(z[e>>2])}function vn(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e}function mn(e){this.rawDestructor&&this.rawDestructor(e)}function yn(e){e!==null&&e.delete()}function gn(){Te.prototype.getPointee=vn,Te.prototype.destructor=mn,Te.prototype.argPackAdvance=8,Te.prototype.readValueFromPointer=$r,Te.prototype.deleteObject=yn,Te.prototype.fromWireType=xt}function Te(e,r,t,n,s,u,l,f,y,m,C){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=y,this.rawShare=m,this.rawDestructor=C,!s&&r.baseClass===void 0?n?(this.toWireType=st,this.destructorFunction=null):(this.toWireType=gt,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 Be(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 Re(r),t}function Gr(e,r){var t=[],n={};function s(u){if(!n[u]&&!je[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,y,m,C,S,$){C=he(C),u=Be(s,u),f&&(f=Be(l,f)),m&&(m=Be(y,m)),$=Be(S,$);var P=Cr(C);Lt(P,function(){Gr(`Cannot construct ${C} due to unbound types`,[n])}),tr([e,r,t],n?[n]:[],function(I){I=I[0];var J,re;n?(J=I.registeredClass,re=J.instancePrototype):re=ke.prototype;var ae=Rr(P,function(){if(Object.getPrototypeOf(this)!==ve)throw new Ge("Use 'new' to construct "+C);if(te.constructor_body===void 0)throw new Ge(C+" has no accessible constructor");var ue=te.constructor_body[arguments.length];if(ue===void 0)throw new Ge(`Tried to invoke ctor of ${C} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(te.constructor_body).toString()}) parameters instead!`);return ue.apply(this,arguments)}),ve=Object.create(re,{constructor:{value:ae}});ae.prototype=ve;var te=new hn(C,ae,ve,$,J,u,f,m);te.baseClass&&(te.baseClass.__derivedClasses===void 0&&(te.baseClass.__derivedClasses=[]),te.baseClass.__derivedClasses.push(te));var Xe=new Te(C,te,!0,!1,!1),ye=new Te(C+"*",te,!1,!1,!1),Oe=new Te(C+" const*",te,!1,!0,!1);return mt[e]={pointerType:ye,constPointerType:Oe},wn(P,ae),[Xe,ye,Oe]})}function bt(e,r){for(var t=[],n=0;n<e;n++)t.push(N[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,y=!1,m=1;m<r.length;++m)if(r[m]!==null&&r[m].destructorFunction===void 0){y=!0;break}for(var C=r[0].name!=="void",S="",$="",m=0;m<l-2;++m)S+=(m!==0?", ":"")+"arg"+m,$+=(m!==0?", ":"")+"arg"+m+"Wired";var P=`
  5. return function ${Cr(e)}(${S}) {
  6. if (arguments.length !== ${l-2}) {
  7. throwBindingError('function ${e} called with ${arguments.length} arguments, expected ${l-2} args!');
  8. }`;y&&(P+=`var destructors = [];
  9. `);var I=y?"destructors":"null",J=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],re=[V,n,s,$n,r[0],r[1]];f&&(P+="var thisWired = classParam.toWireType("+I+`, this);
  10. `);for(var m=0;m<l-2;++m)P+="var arg"+m+"Wired = argType"+m+".toWireType("+I+", arg"+m+"); // "+r[m+2].name+`
  11. `,J.push("argType"+m),re.push(r[m+2]);if(f&&($="thisWired"+($.length>0?", ":"")+$),P+=(C||u?"var rv = ":"")+"invoker(fn"+($.length>0?", ":"")+$+`);
  12. `,y)P+=`runDestructors(destructors);
  13. `;else for(var m=f?1:2;m<r.length;++m){var ae=m===1?"thisWired":"arg"+(m-2)+"Wired";r[m].destructorFunction!==null&&(P+=ae+"_dtor("+ae+"); // "+r[m].name+`
  14. `,J.push(ae+"_dtor"),re.push(r[m].destructorFunction))}return C&&(P+=`var ret = retType.fromWireType(rv);
  15. return ret;
  16. `),P+=`}
  17. `,J.push(P),Et(Function,J).apply(null,re)}function Tn(e,r,t,n,s,u){var l=bt(r,t);s=Be(n,s),tr([],[e],function(f){f=f[0];var y=`constructor ${f.name}`;if(f.registeredClass.constructor_body===void 0&&(f.registeredClass.constructor_body=[]),f.registeredClass.constructor_body[r-1]!==void 0)throw new Ge(`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(y,m,null,s,u),[]}),[]})}function Ct(e,r,t,n,s,u,l,f,y){var m=bt(t,n);r=he(r),u=Be(s,u),tr([],[e],function(C){C=C[0];var S=`${C.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),f&&C.registeredClass.pureVirtualFunctions.push(r);function $(){Gr(`Cannot call ${S} due to unbound types`,m)}var P=C.registeredClass.instancePrototype,I=P[r];return I===void 0||I.overloadTable===void 0&&I.className!==C.name&&I.argCount===t-2?($.argCount=t-2,$.className=C.name,P[r]=$):(Le(P,r,S),P[r].overloadTable[t-2]=$),tr([],m,function(J){var re=Pt(S,J,C,u,l,y);return P[r].overloadTable===void 0?(re.argCount=t-2,P[r]=re):P[r].overloadTable[t-2]=re,[]}),[]})}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 Q[s]};case 1:return t?function(s){return me[s>>1]}:function(s){return Fe[s>>1]};case 2:return t?function(s){return z[s>>2]}:function(s){return N[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=S=>S;if(n===0){var f=32-8*t;l=S=>S<<f>>>f}var y=r.includes("unsigned"),m=(S,$)=>{},C;y?C=function(S,$){return m($,this.name),$>>>0}:C=function(S,$){return m($,this.name),$},Ee(e,{name:r,fromWireType:l,toWireType:C,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=N,y=f[l],m=f[l+1];return new s(f.buffer,m,y)}t=he(t),Ee(e,{name:t,fromWireType:u,argPackAdvance:8,readValueFromPointer:u},{ignoreDuplicateRegistrations:!0})}var Un=(e,r,t)=>Lr(e,Q,r,t);function or(e,r){r=he(r);var t=r==="std::string";Ee(e,{name:r,fromWireType:function(n){var s=N[n>>2],u=n+4,l;if(t)for(var f=u,y=0;y<=s;++y){var m=u+y;if(y==s||Q[m]==0){var C=m-f,S=wr(f,C);l===void 0?l=S:(l+=String.fromCharCode(0),l+=S),f=m+1}}else{for(var $=new Array(s),y=0;y<s;++y)$[y]=String.fromCharCode(Q[u+y]);l=$.join("")}return Re(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),y=f+4;if(N[f>>2]=u,t&&l)Un(s,y,u+1);else if(l)for(var m=0;m<u;++m){var C=s.charCodeAt(m);C>255&&(Re(y),V("String has UTF-16 code units that do not fit in 8 bits")),Q[y+m]=C}else for(var m=0;m<u;++m)Q[y+m]=s[m];return n!==null&&n.push(Re,f),f},argPackAdvance:8,readValueFromPointer:$r,destructorFunction:function(n){Re(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)&&Fe[n];)++n;if(t=n<<1,t-e>32&&Xr)return Xr.decode(Q.subarray(e,t));for(var u="",l=0;!(l>=r/2);++l){var f=me[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);me[r>>1]=l,r+=2}return me[r>>1]=0,r-n},ut=e=>e.length*2,Nt=(e,r)=>{for(var t=0,n="";!(t>=r/4);){var s=z[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(z[r>>2]=l,r+=4,r+4>s)break}return z[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=()=>Fe,f=1):r===4&&(n=Nt,s=c,l=d,u=()=>N,f=2),Ee(e,{name:t,fromWireType:function(y){for(var m=N[y>>2],C=u(),S,$=y+4,P=0;P<=m;++P){var I=y+4+P*r;if(P==m||C[I>>f]==0){var J=I-$,re=n($,J);S===void 0?S=re:(S+=String.fromCharCode(0),S+=re),$=I+r}}return Re(y),S},toWireType:function(y,m){typeof m!="string"&&V(`Cannot pass non-string to C++ string type ${t}`);var C=l(m),S=kt(4+C+r);return N[S>>2]=C>>f,s(m,S+4,C+r),y!==null&&y.push(Re,S),S},argPackAdvance:8,readValueFromPointer:$r,destructorFunction:function(y){Re(y)}})};function E(e,r){r=he(r),Ee(e,{isVoid:!0,name:r,argPackAdvance:0,fromWireType:function(){},toWireType:function(t,n){}})}var A={};function x(e){var r=A[e];return r===void 0?he(e):r}var j=[];function D(e,r,t,n){e=j[e],r=Tr.toValue(r),t=x(t),e(r,t,null,n)}function G(e){var r=j.length;return j.push(e),r}function L(e,r){var t=je[e];return t===void 0&&V(r+" has unknown type "+_t(e)),t}function ie(e,r){for(var t=new Array(e),n=0;n<e;++n)t[n]=L(N[r+n*4>>2],"parameter "+n);return t}var se=[];function le(e,r){var t=ie(e,r),n=t[0],s=n.name+"_$"+t.slice(1).map(function(I){return I.name}).join("_")+"$",u=se[s];if(u!==void 0)return u;for(var l=["retType"],f=[n],y="",m=0;m<e-1;++m)y+=(m!==0?", ":"")+"arg"+m,l.push("argType"+m),f.push(t[1+m]);for(var C=Cr("methodCaller_"+s),S="return function "+C+`(handle, name, destructors, args) {
  18. `,$=0,m=0;m<e-1;++m)S+=" var arg"+m+" = argType"+m+".readValueFromPointer(args"+($?"+"+$:"")+`);
  19. `,$+=t[m+1].argPackAdvance;S+=" var rv = handle[name]("+y+`);
  20. `;for(var m=0;m<e-1;++m)t[m+1].deleteObject&&(S+=" argType"+m+".deleteObject(arg"+m+`);
  21. `);n.isVoid||(S+=` return retType.toWireType(destructors, rv);
  22. `),S+=`};
  23. `,l.push(S);var P=Et(Function,l).apply(null,f);return u=G(P),se[s]=u,u}function pe(e,r){return r+2097152>>>0<4194305-!!e?(e>>>0)+r*4294967296:NaN}var Se=()=>{Me("")};function He(){return Date.now()}var Ue=()=>Q.length,fr=()=>Ue(),St=(e,r,t)=>Q.copyWithin(e,r,r+t),qe=e=>{Me("OOM")},Mn=e=>{Q.length,qe()},Or={},Vt=()=>b||"./this.program",Je=()=>{if(!Je.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]}`);Je.strings=n}return Je.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 Je().forEach(function(n,s){var u=r+t;N[e+s*4>>2]=u,ui(n,u),t+=n.length+1}),0},li=(e,r)=>{var t=Je();N[e>>2]=t.length;var n=0;return t.forEach(function(s){n+=s.length+1}),N[r>>2]=n,0};function ci(e){try{var r=fe.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=fe.getStreamFromFD(e),l=u.tty?2:i.isDir(u.mode)?3:i.isLink(u.mode)?7:4;return ee[r>>0]=l,me[r+2>>1]=s,Z=[t>>>0,(M=t,+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[r+8>>2]=Z[0],z[r+12>>2]=Z[1],Z=[n>>>0,(M=n,+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[r+16>>2]=Z[0],z[r+20>>2]=Z[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=N[r>>2],f=N[r+4>>2];r+=8;var y=i.read(e,ee,l,f,n);if(y<0)return-1;if(s+=y,y<f)break;typeof n<"u"&&(n+=y)}return s};function pi(e,r,t,n){try{var s=fe.getStreamFromFD(e),u=hi(s,r,t);return N[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=fe.getStreamFromFD(e);return i.llseek(l,u,n),Z=[l.position>>>0,(M=l.position,+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[s>>2]=Z[0],z[s+4>>2]=Z[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=N[r>>2],f=N[r+4>>2];r+=8;var y=i.write(e,ee,l,f,n);if(y<0)return-1;s+=y,typeof n<"u"&&(n+=y)}return s};function yi(e,r,t,n){try{var s=fe.getStreamFromFD(e),u=mi(s,r,t);return N[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(),Ge=o.BindingError=class extends Error{constructor(r){super(r),this.name="BindingError"}},Ye=o.InternalError=class extends Error{constructor(r){super(r),this.name="InternalError"}},jt(),Mt(),gn(),wt=o.UnboundTypeError=Pn(Error,"UnboundTypeError"),Sn(),kn();var gi={p:yr,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:D,m:Tt,l:le,a:Se,e:He,v:fr,A:St,u:Mn,y:fi,z:li,i:ci,x:di,B:pi,s:vi,h:yi};Yt();var kt=e=>(kt=H.G)(e),Re=e=>(Re=H.I)(e),In=()=>(In=H.J)(),jn=e=>(jn=H.K)(e);o.__embind_initialize_bindings=()=>(o.__embind_initialize_bindings=H.L)();var Ln=e=>(Ln=H.M)(e);o.dynCall_jiji=(e,r,t,n,s)=>(o.dynCall_jiji=H.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,!ne&&(xr(),p(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),We()))}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 go extends Xt{constructor(a){super(qi,a!=null&&a.wasmPath?fetch(a==null?void 0:a.wasmPath).then(o=>o.arrayBuffer()):void 0,a==null?void 0:a.workerMode,a==null?void 0:a.canvas,a==null?void 0:a.yuvMode)}}var Xi=(()=>{var h=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(a={}){var o=a,p,g;o.ready=new Promise((c,d)=>{p=c,g=d});var _=Object.assign({},o),b=typeof window=="object",U=typeof importScripts=="function";typeof process=="object"&&typeof process.versions=="object"&&process.versions.node;var F="";function w(c){return o.locateFile?o.locateFile(c,F):F+c}var T;(b||U)&&(U?F=self.location.href:typeof document<"u"&&document.currentScript&&(F=document.currentScript.src),h&&(F=h),F.indexOf("blob:")!==0?F=F.substr(0,F.replace(/[?#].*/,"").lastIndexOf("/")+1):F="",U&&(T=c=>{var d=new XMLHttpRequest;return d.open("GET",c,!1),d.responseType="arraybuffer",d.send(null),new Uint8Array(d.response)}));var k=o.print||console.log.bind(console),K=o.printErr||console.error.bind(console);Object.assign(o,_),_=null,o.arguments&&o.arguments,o.thisProgram&&o.thisProgram,o.quit&&o.quit;var Y;o.wasmBinary&&(Y=o.wasmBinary),o.noExitRuntime,typeof WebAssembly!="object"&&Pe("no native wasm support detected");var X,W,R=!1,oe,H,ne,Ce,ee,Q,me,Fe;function z(){var c=X.buffer;o.HEAP8=oe=new Int8Array(c),o.HEAP16=ne=new Int16Array(c),o.HEAP32=ee=new Int32Array(c),o.HEAPU8=H=new Uint8Array(c),o.HEAPU16=Ce=new Uint16Array(c),o.HEAPU32=Q=new Uint32Array(c),o.HEAPF32=me=new Float32Array(c),o.HEAPF64=Fe=new Float64Array(c)}var N,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 We=0,mr=null;function _e(c){We++,o.monitorRunDependencies&&o.monitorRunDependencies(We)}function be(c){if(We--,o.monitorRunDependencies&&o.monitorRunDependencies(We),We==0&&mr){var d=mr;mr=null,d()}}function Pe(c){o.onAbort&&o.onAbort(c),c="Aborted("+c+")",K(c),R=!0,c+=". Build with -sASSERTIONS for more info.";var d=new WebAssembly.RuntimeError(c);throw g(d),d}var er="data:application/octet-stream;base64,";function ri(c){return c.startsWith(er)}var Qe;Qe="videodec_simd.wasm",ri(Qe)||(Qe=w(Qe));function sr(c){if(c==Qe&&Y)return new Uint8Array(Y);if(T)return T(c);throw"both async and sync fetching of the wasm failed"}function Me(c){return!Y&&(b||U)&&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 Me(c).then(E=>WebAssembly.instantiate(E,d)).then(E=>E).then(v,E=>{K("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 x=WebAssembly.instantiateStreaming(A,v);return x.then(E,function(j){return K("wasm streaming compile failed: "+j),K("falling back to ArrayBuffer instantiation"),Ft(d,v,E)})}):Ft(d,v,E)}function ze(){var c={a:Un};function d(E,A){var x=E.exports;return W=x,X=W.v,z(),N=W.z,Mr(W.w),be(),x}_e();function v(E){d(E.instance)}if(o.instantiateWasm)try{return o.instantiateWasm(c,d)}catch(E){K("Module.instantiateWasm callback failed with error: "+E),g(E)}return ct(Y,Qe,c,v).catch(g),{}}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){Q[this.ptr+4>>2]=d},this.get_type=function(){return Q[this.ptr+4>>2]},this.set_destructor=function(d){Q[this.ptr+8>>2]=d},this.get_destructor=function(){return Q[this.ptr+8>>2]},this.set_caught=function(d){d=d?1:0,oe[this.ptr+12>>0]=d},this.get_caught=function(){return oe[this.ptr+12>>0]!=0},this.set_rethrown=function(d){d=d?1:0,oe[this.ptr+13>>0]=d},this.get_rethrown=function(){return oe[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){Q[this.ptr+16>>2]=d},this.get_adjusted_ptr=function(){return Q[this.ptr+16>>2]},this.get_exception_ptr=function(){var d=zt(this.get_type());if(d)return Q[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 M(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 Z(){for(var c=new Array(256),d=0;d<256;++d)c[d]=String.fromCharCode(d);Ar=c}var Ar=void 0;function xe(c){for(var d="",v=c;H[v];)d+=Ar[H[v++]];return d}var ar={},yr={},et={},q=void 0;function ce(c){throw new q(c)}var rt=void 0;function we(c){throw new rt(c)}function gr(c,d,v){c.forEach(function(D){et[D]=d});function E(D){var G=v(D);G.length!==c.length&&we("Mismatched type converter count");for(var L=0;L<c.length;++L)Ie(c[L],G[L])}var A=new Array(d.length),x=[],j=0;d.forEach((D,G)=>{yr.hasOwnProperty(D)?A[G]=yr[D]:(x.push(D),ar.hasOwnProperty(D)||(ar[D]=[]),ar[D].push(()=>{A[G]=yr[D],++j,j===x.length&&E(A)}))}),x.length===0&&E(A)}function Ne(c,d,v={}){var E=d.name;if(c||ce(`type "${E}" must have a positive integer typeid pointer`),yr.hasOwnProperty(c)){if(v.ignoreDuplicateRegistrations)return;ce(`Cannot register type '${E}' twice`)}if(yr[c]=d,delete et[c],ar.hasOwnProperty(c)){var A=ar[c];delete ar[c],A.forEach(x=>x())}}function Ie(c,d,v={}){if(!("argPackAdvance"in d))throw new TypeError("registerType registeredInstance requires argPackAdvance");return Ne(c,d,v)}function jr(c,d,v,E,A){var x=M(v);d=xe(d),Ie(c,{name:d,fromWireType:function(j){return!!j},toWireType:function(j,D){return D?E:A},argPackAdvance:8,readValueFromPointer:function(j){var D;if(v===1)D=oe;else if(v===2)D=ne;else if(v===4)D=ee;else throw new TypeError("Unknown boolean type size: "+d);return this.fromWireType(D[j>>x])},destructorFunction:null})}function Lr(c){if(!(this instanceof Ye)||!(c instanceof Ye))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}ce(d(c)+" instance already deleted")}var De=!1;function tt(c){}function B(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&&B(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 fe(c){wr=c,rr.length&&wr&&wr(i)}function en(){o.getInheritedInstanceCount=Zt,o.getLiveInheritedInstances=Jt,o.flushPendingDeletes=i,o.setDelayFunction=fe}var Hr={};function rn(c,d){for(d===void 0&&ce("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)&&we("makeClassHandle requires ptr and ptrType");var v=!!d.smartPtrType,E=!!d.smartPtr;return v!==E&&we("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 x=this.registeredClass.getActualType(d),j=Ot[x];if(!j)return A.call(this);var D;this.isConst?D=j.constPointerType:D=j.pointerType;var G=Rt(d,this.registeredClass,D.registeredClass);return G===null?A.call(this):this.isSmartPointer?nt(D.registeredClass.instancePrototype,{ptrType:D,ptr:G,smartPtrType:this,smartPtr:c}):nt(D.registeredClass.instancePrototype,{ptrType:D,ptr:G})}var he=function(c){return typeof FinalizationRegistry>"u"?(he=d=>d,c):(De=new FinalizationRegistry(d=>{Dt(d.$$)}),he=d=>{var v=d.$$,E=!!v.smartPtr;if(E){var A={$$:v};De.register(d,A,d)}return d},tt=d=>De.unregister(d),he(c))};function Ve(){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 je(){this.$$.ptr||dt(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&ce("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 Ge(){return this.$$.ptr||dt(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&ce("Object already scheduled for deletion"),rr.push(this),rr.length===1&&wr&&wr(i),this.$$.deleteScheduled=!0,this}function V(){Ye.prototype.isAliasOf=Lr,Ye.prototype.clone=Ve,Ye.prototype.delete=je,Ye.prototype.isDeleted=_r,Ye.prototype.deleteLater=Ge}function Ye(){}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)||ce(`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)&&ce(`Cannot register public name '${c}' twice`),Ut(o,c,c),o.hasOwnProperty(v)&&ce(`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,x,j,D){this.name=c,this.constructor=d,this.instancePrototype=v,this.rawDestructor=E,this.baseClass=A,this.getActualType=x,this.upcast=j,this.downcast=D,this.pureVirtualFunctions=[]}function Er(c,d,v){for(;d!==v;)d.upcast||ce(`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&&ce(`null is not a valid ${this.name}`),0;d.$$||ce(`Cannot pass "${gt(d)}" as a ${this.name}`),d.$$.ptr||ce(`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&&ce(`null is not a valid ${this.name}`),this.isSmartPointer?(v=this.rawConstructor(),c!==null&&c.push(this.rawDestructor,v),v):0;d.$$||ce(`Cannot pass "${gt(d)}" as a ${this.name}`),d.$$.ptr||ce(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&d.$$.ptrType.isConst&&ce(`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&&ce("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:d.$$.smartPtrType===this?v=d.$$.smartPtr:ce(`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:ce("Unsupporting sharing policy")}return v}function on(c,d){if(d===null)return this.isReference&&ce(`null is not a valid ${this.name}`),0;d.$$||ce(`Cannot pass "${gt(d)}" as a ${this.name}`),d.$$.ptr||ce(`Cannot pass deleted object as a pointer of type ${this.name}`),d.$$.ptrType.isConst&&ce(`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(){$e.prototype.getPointee=vt,$e.prototype.destructor=mt,$e.prototype.argPackAdvance=8,$e.prototype.readValueFromPointer=Fr,$e.prototype.deleteObject=sn,$e.prototype.fromWireType=ht}function $e(c,d,v,E,A,x,j,D,G,L,ie){this.name=c,this.registeredClass=d,this.isReference=v,this.isConst=E,this.isSmartPointer=A,this.pointeeType=x,this.sharingPolicy=j,this.rawGetPointee=D,this.rawConstructor=G,this.rawShare=L,this.rawDestructor=ie,!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)||we("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=N.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=xe(c);function v(){return c.includes("j")?un(c,d):Mt(d)}var E=v();return typeof E!="function"&&ce(`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 Ze(c){var d=Wt(c),v=xe(d);return or(d),v}function yt(c,d){var v=[],E={};function A(x){if(!E[x]&&!yr[x]){if(et[x]){et[x].forEach(A);return}v.push(x),E[x]=!0}}throw d.forEach(A),new xt(`${c}: `+v.map(Ze).join([", "]))}function fn(c,d,v,E,A,x,j,D,G,L,ie,se,le){ie=xe(ie),x=Dr(A,x),D&&(D=Dr(j,D)),L&&(L=Dr(G,L)),le=Dr(se,le);var pe=it(ie);tn(pe,function(){yt(`Cannot construct ${ie} due to unbound types`,[E])}),gr([c,d,v],E?[E]:[],function(Se){Se=Se[0];var He,Ue;E?(He=Se.registeredClass,Ue=He.instancePrototype):Ue=Ye.prototype;var fr=Ee(pe,function(){if(Object.getPrototypeOf(this)!==St)throw new q("Use 'new' to construct "+ie);if(qe.constructor_body===void 0)throw new q(ie+" has no accessible constructor");var Je=qe.constructor_body[arguments.length];if(Je===void 0)throw new q(`Tried to invoke ctor of ${ie} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(qe.constructor_body).toString()}) parameters instead!`);return Je.apply(this,arguments)}),St=Object.create(Ue,{constructor:{value:fr}});fr.prototype=St;var qe=new nn(ie,fr,St,le,He,x,D,L);qe.baseClass&&(qe.baseClass.__derivedClasses===void 0&&(qe.baseClass.__derivedClasses=[]),qe.baseClass.__derivedClasses.push(qe));var Mn=new $e(ie,qe,!0,!1,!1),Or=new $e(ie+"*",qe,!1,!1,!1),Vt=new $e(ie+" const*",qe,!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(Q[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 ke(c,d,v,E,A,x){var j=d.length;j<2&&ce("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var D=d[1]!==null&&v!==null,G=!1,L=1;L<d.length;++L)if(d[L]!==null&&d[L].destructorFunction===void 0){G=!0;break}for(var ie=d[0].name!=="void",se="",le="",L=0;L<j-2;++L)se+=(L!==0?", ":"")+"arg"+L,le+=(L!==0?", ":"")+"arg"+L+"Wired";var pe=`
  25. return function ${it(c)}(${se}) {
  26. if (arguments.length !== ${j-2}) {
  27. throwBindingError('function ${c} called with ${arguments.length} arguments, expected ${j-2} args!');
  28. }`;G&&(pe+=`var destructors = [];
  29. `);var Se=G?"destructors":"null",He=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],Ue=[ce,E,A,ln,d[0],d[1]];D&&(pe+="var thisWired = classParam.toWireType("+Se+`, this);
  30. `);for(var L=0;L<j-2;++L)pe+="var arg"+L+"Wired = argType"+L+".toWireType("+Se+", arg"+L+"); // "+d[L+2].name+`
  31. `,He.push("argType"+L),Ue.push(d[L+2]);if(D&&(le="thisWired"+(le.length>0?", ":"")+le),pe+=(ie||x?"var rv = ":"")+"invoker(fn"+(le.length>0?", ":"")+le+`);
  32. `,G)pe+=`runDestructors(destructors);
  33. `;else for(var L=D?1:2;L<d.length;++L){var fr=L===1?"thisWired":"arg"+(L-2)+"Wired";d[L].destructorFunction!==null&&(pe+=fr+"_dtor("+fr+"); // "+d[L].name+`
  34. `,He.push(fr+"_dtor"),Ue.push(d[L].destructorFunction))}return ie&&(pe+=`var ret = retType.fromWireType(rv);
  35. return ret;
  36. `),pe+=`}
  37. `,He.push(pe),jt(Function,He).apply(null,Ue)}function cn(c,d,v,E,A,x){var j=It(d,v);A=Dr(E,A),gr([],[c],function(D){D=D[0];var G=`constructor ${D.name}`;if(D.registeredClass.constructor_body===void 0&&(D.registeredClass.constructor_body=[]),D.registeredClass.constructor_body[d-1]!==void 0)throw new q(`Cannot register multiple constructors with identical number of parameters (${d-1}) for class '${D.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return D.registeredClass.constructor_body[d-1]=()=>{yt(`Cannot construct ${D.name} due to unbound types`,j)},gr([],j,function(L){return L.splice(1,0,null),D.registeredClass.constructor_body[d-1]=ke(G,L,null,A,x),[]}),[]})}function dn(c,d,v,E,A,x,j,D,G){var L=It(v,E);d=xe(d),x=Dr(A,x),gr([],[c],function(ie){ie=ie[0];var se=`${ie.name}.${d}`;d.startsWith("@@")&&(d=Symbol[d.substring(2)]),D&&ie.registeredClass.pureVirtualFunctions.push(d);function le(){yt(`Cannot call ${se} due to unbound types`,L)}var pe=ie.registeredClass.instancePrototype,Se=pe[d];return Se===void 0||Se.overloadTable===void 0&&Se.className!==ie.name&&Se.argCount===v-2?(le.argCount=v-2,le.className=ie.name,pe[d]=le):(Ut(pe,d,se),pe[d].overloadTable[v-2]=le),gr([],L,function(He){var Ue=ke(se,He,ie,x,j,G);return pe[d].overloadTable===void 0?(Ue.argCount=v-2,pe[d]=Ue):pe[d].overloadTable[v-2]=Ue,[]}),[]})}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 Le=new Rr;function Lt(c){c>=Le.reserved&&--Le.get(c).refcount===0&&Le.free(c)}function hn(){for(var c=0,d=Le.reserved;d<Le.allocated.length;++d)Le.allocated[d]!==void 0&&++c;return c}function Vr(){Le.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),Le.reserved=Le.allocated.length,o.count_emval_handles=hn}var st={toValue:c=>(c||ce("Cannot use deleted val. handle = "+c),Le.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 Le.allocate({refcount:1,value:c})}}};function pn(c,d){d=xe(d),Ie(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 gt(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(me[v>>2])};case 3:return function(v){return this.fromWireType(Fe[v>>3])};default:throw new TypeError("Unknown float type: "+c)}}function vn(c,d,v){var E=M(v);d=xe(d),Ie(c,{name:d,fromWireType:function(A){return A},toWireType:function(A,x){return x},argPackAdvance:8,readValueFromPointer:$r(d,E),destructorFunction:null})}function mn(c,d,v){switch(d){case 0:return v?function(A){return oe[A]}:function(A){return H[A]};case 1:return v?function(A){return ne[A>>1]}:function(A){return Ce[A>>1]};case 2:return v?function(A){return ee[A>>2]}:function(A){return Q[A>>2]};default:throw new TypeError("Unknown integer type: "+c)}}function yn(c,d,v,E,A){d=xe(d);var x=M(v),j=se=>se;if(E===0){var D=32-8*v;j=se=>se<<D>>>D}var G=d.includes("unsigned"),L=(se,le)=>{},ie;G?ie=function(se,le){return L(le,this.name),le>>>0}:ie=function(se,le){return L(le,this.name),le},Ie(c,{name:d,fromWireType:j,toWireType:ie,argPackAdvance:8,readValueFromPointer:mn(d,x,E!==0),destructorFunction:null})}function gn(c,d,v){var E=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],A=E[d];function x(j){j=j>>2;var D=Q,G=D[j],L=D[j+1];return new A(D.buffer,L,G)}v=xe(v),Ie(c,{name:v,fromWireType:x,argPackAdvance:8,readValueFromPointer:x},{ignoreDuplicateRegistrations:!0})}var Te=(c,d,v,E)=>{if(!(E>0))return 0;for(var A=v,x=v+E-1,j=0;j<c.length;++j){var D=c.charCodeAt(j);if(D>=55296&&D<=57343){var G=c.charCodeAt(++j);D=65536+((D&1023)<<10)|G&1023}if(D<=127){if(v>=x)break;d[v++]=D}else if(D<=2047){if(v+1>=x)break;d[v++]=192|D>>6,d[v++]=128|D&63}else if(D<=65535){if(v+2>=x)break;d[v++]=224|D>>12,d[v++]=128|D>>6&63,d[v++]=128|D&63}else{if(v+3>=x)break;d[v++]=240|D>>18,d[v++]=128|D>>12&63,d[v++]=128|D>>6&63,d[v++]=128|D&63}}return d[v]=0,v-A},wn=(c,d,v)=>Te(c,H,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 x="";d<A;){var j=c[d++];if(!(j&128)){x+=String.fromCharCode(j);continue}var D=c[d++]&63;if((j&224)==192){x+=String.fromCharCode((j&31)<<6|D);continue}var G=c[d++]&63;if((j&240)==224?j=(j&15)<<12|D<<6|G:j=(j&7)<<18|D<<12|G<<6|c[d++]&63,j<65536)x+=String.fromCharCode(j);else{var L=j-65536;x+=String.fromCharCode(55296|L>>10,56320|L&1023)}}return x},bn=(c,d)=>c?at(H,c,d):"";function En(c,d){d=xe(d);var v=d==="std::string";Ie(c,{name:d,fromWireType:function(E){var A=Q[E>>2],x=E+4,j;if(v)for(var D=x,G=0;G<=A;++G){var L=x+G;if(G==A||H[L]==0){var ie=L-D,se=bn(D,ie);j===void 0?j=se:(j+=String.fromCharCode(0),j+=se),D=L+1}}else{for(var le=new Array(A),G=0;G<A;++G)le[G]=String.fromCharCode(H[x+G]);j=le.join("")}return or(E),j},toWireType:function(E,A){A instanceof ArrayBuffer&&(A=new Uint8Array(A));var x,j=typeof A=="string";j||A instanceof Uint8Array||A instanceof Uint8ClampedArray||A instanceof Int8Array||ce("Cannot pass non-string to std::string"),v&&j?x=_n(A):x=A.length;var D=Xr(4+x+1),G=D+4;if(Q[D>>2]=x,v&&j)wn(A,G,x+1);else if(j)for(var L=0;L<x;++L){var ie=A.charCodeAt(L);ie>255&&(or(G),ce("String has UTF-16 code units that do not fit in 8 bits")),H[G+L]=ie}else for(var L=0;L<x;++L)H[G+L]=A[L];return E!==null&&E.push(or,D),D},argPackAdvance:8,readValueFromPointer:Fr,destructorFunction:function(E){or(E)}})}var Be=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)&&Ce[E];)++E;if(v=E<<1,v-c>32&&Be)return Be.decode(H.subarray(c,v));for(var x="",j=0;!(j>=d/2);++j){var D=ne[c+j*2>>1];if(D==0)break;x+=String.fromCharCode(D)}return x},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,x=0;x<A;++x){var j=c.charCodeAt(x);ne[d>>1]=j,d+=2}return ne[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 x=A-65536;E+=String.fromCharCode(55296|x>>10,56320|x&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,x=0;x<c.length;++x){var j=c.charCodeAt(x);if(j>=55296&&j<=57343){var D=c.charCodeAt(++x);j=65536+((j&1023)<<10)|D&1023}if(ee[d>>2]=j,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=xe(v);var E,A,x,j,D;d===2?(E=Pn,A=wt,j=_t,x=()=>Ce,D=1):d===4&&(E=Gr,A=Cn,j=bt,x=()=>Q,D=2),Ie(c,{name:v,fromWireType:function(G){for(var L=Q[G>>2],ie=x(),se,le=G+4,pe=0;pe<=L;++pe){var Se=G+4+pe*d;if(pe==L||ie[Se>>D]==0){var He=Se-le,Ue=E(le,He);se===void 0?se=Ue:(se+=String.fromCharCode(0),se+=Ue),le=Se+d}}return or(G),se},toWireType:function(G,L){typeof L!="string"&&ce(`Cannot pass non-string to C++ string type ${v}`);var ie=j(L),se=Xr(4+ie+d);return Q[se>>2]=ie>>D,A(L,se+4,ie+d),G!==null&&G.push(or,se),se},argPackAdvance:8,readValueFromPointer:Fr,destructorFunction:function(G){or(G)}})};function Et(c,d){d=xe(d),Ie(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?xe(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=yr[c];return v===void 0&&ce(d+" has unknown type "+Ze(c)),v}function Tt(c,d){for(var v=new Array(c),E=0;E<c;++E)v[E]=ge(Q[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(Se){return Se.name}).join("_")+"$",x=Bt[A];if(x!==void 0)return x;for(var j=["retType"],D=[E],G="",L=0;L<c-1;++L)G+=(L!==0?", ":"")+"arg"+L,j.push("argType"+L),D.push(v[1+L]);for(var ie=it("methodCaller_"+A),se="return function "+ie+`(handle, name, destructors, args) {
  38. `,le=0,L=0;L<c-1;++L)se+=" var arg"+L+" = argType"+L+".readValueFromPointer(args"+(le?"+"+le:"")+`);
  39. `,le+=v[L+1].argPackAdvance;se+=" var rv = handle[name]("+G+`);
  40. `;for(var L=0;L<c-1;++L)v[L+1].deleteObject&&(se+=" argType"+L+".deleteObject(arg"+L+`);
  41. `);E.isVoid||(se+=` return retType.toWireType(destructors, rv);
  42. `),se+=`};
  43. `,j.push(se);var pe=jt(Function,j).apply(null,D);return x=$t(pe),Bt[A]=x,x}var Tr=()=>{Pe("")},Ht;Ht=()=>performance.now();var qr=(c,d,v)=>H.copyWithin(c,d,d+v),An=c=>{Pe("OOM")},Fn=c=>{H.length,An()},Dn=[null,[],[]],Rn=(c,d)=>{var v=Dn[c];d===0||d===10?((c===1?k:K)(at(v,0)),v.length=0):v.push(d)},On=(c,d,v,E)=>{for(var A=0,x=0;x<v;x++){var j=Q[d>>2],D=Q[d+4>>2];d+=8;for(var G=0;G<D;G++)Rn(c,H[j+G]);A+=D}return Q[E>>2]=A,0};Z(),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:yn,a:gn,j:En,g:$n,n:Et,e:Sn,l:Lt,h:kn,f:Tr,c:Ht,t:qr,s:Fn,i:On};ze();var or=c=>(or=W.x)(c),Xr=c=>(Xr=W.y)(c),Wt=c=>(Wt=W.A)(c);o.__embind_initialize_bindings=()=>(o.__embind_initialize_bindings=W.B)();var zt=c=>(zt=W.C)(c);o.dynCall_jiji=(c,d,v,E,A)=>(o.dynCall_jiji=W.D)(c,d,v,E,A);var ut;mr=function c(){ut||Nt(),ut||(mr=c)};function Nt(){if(We>0||(pr(),We>0))return;function c(){ut||(ut=!0,o.calledRun=!0,!R&&(Zr(),p(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!=null&&a.wasmPath?fetch(a.wasmPath).then(o=>o.arrayBuffer()):void 0,a==null?void 0:a.workerMode,a==null?void 0:a.canvas,a==null?void 0:a.yuvMode)}}var Ki=Object.defineProperty,Qi=Object.getOwnPropertyDescriptor,Kn=(h,a,o,p)=>{for(var g=p>1?void 0:p?Qi(a,o):a,_=h.length-1,b;_>=0;_--)(b=h[_])&&(g=(p?b(a,o,g):b(g))||g);return p&&g&&Ki(a,o,g),g};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([Ae([de.INIT,"closed"],"initialized")],Qn.prototype,"initialize",1);Kn([Ae("initialized","configured",{sync:!0})],Qn.prototype,"configure",1);Kn([Ti("configured")],Qn.prototype,"decode",1);Kn([Ae([],de.INIT,{sync:!0})],Qn.prototype,"reset",1);Kn([Ae([],"closed",{ignoreError:!0,sync:!0})],Qn.prototype,"close",1);const O=class{static box(h,...a){let o=8,p=a.length;for(let b=0;b<p;b++)o+=a[b].byteLength;let g=new Uint8Array(o);g[0]=o>>>24&255,g[1]=o>>>16&255,g[2]=o>>>8&255,g[3]=o&255,g.set(h,4);let _=8;for(let b=0;b<p;b++)g.set(a[b],_),_+=a[b].byteLength;return g}static generateInitSegment(h){let a=O.box(O.types.ftyp,O.constants.FTYP),o=O.moov(h),p=new Uint8Array(a.byteLength+o.byteLength);return p.set(a,0),p.set(o,a.byteLength),p}static moov(h){let a=O.mvhd(h.timescale,h.duration),o=O.trak(h),p=O.mvex(h);return O.box(O.types.moov,a,o,p)}static mvhd(h,a){return O.box(O.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,h>>>24&255,h>>>16&255,h>>>8&255,h&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(h){return O.box(O.types.trak,O.tkhd(h),O.mdia(h))}static tkhd(h){let a=h.id,o=h.duration,p=h.presentWidth,g=h.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,p>>>8&255,p&255,0,0,g>>>8&255,g&255,0,0]))}static mdia(h){return O.box(O.types.mdia,O.mdhd(h),O.hdlr(h),O.minf(h))}static mdhd(h){let a=h.timescale,o=h.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(h){let a=null;return h.type==="audio"?a=O.constants.HDLR_AUDIO:a=O.constants.HDLR_VIDEO,O.box(O.types.hdlr,a)}static minf(h){let a=null;return h.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(h))}static dinf(){return O.box(O.types.dinf,O.box(O.types.dref,O.constants.DREF))}static stbl(h){return O.box(O.types.stbl,O.stsd(h),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(h){return h.type==="audio"?O.box(O.types.stsd,O.constants.STSD_PREFIX,O.mp4a(h)):h.videoType==="avc"?O.box(O.types.stsd,O.constants.STSD_PREFIX,O.avc1(h)):O.box(O.types.stsd,O.constants.STSD_PREFIX,O.hvc1(h))}static mp4a(h){let a=h.channelCount,o=h.audioSampleRate,p=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,p,O.esds(h))}static esds(h){let a=h.config||[],o=a.length,p=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,p)}static avc1(h){let a=h.avcc;const o=h.codecWidth,p=h.codecHeight;let g=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,p>>>8&255,p&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,g,O.box(O.types.avcC,a))}static hvc1(h){let a=h.avcc;const o=h.codecWidth,p=h.codecHeight;let g=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,p>>>8&255,p&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,g,O.box(O.types.hvcC,a))}static mvex(h){return O.box(O.types.mvex,O.trex(h))}static trex(h){let a=h.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(h,a){return O.box(O.types.moof,O.mfhd(h.sequenceNumber),O.traf(h,a))}static mfhd(h){let a=new Uint8Array([0,0,0,0,h>>>24&255,h>>>16&255,h>>>8&255,h&255]);return O.box(O.types.mfhd,a)}static traf(h,a){let o=h.id,p=O.box(O.types.tfhd,new Uint8Array([0,0,0,0,o>>>24&255,o>>>16&255,o>>>8&255,o&255])),g=O.box(O.types.tfdt,new Uint8Array([0,0,0,0,a>>>24&255,a>>>16&255,a>>>8&255,a&255])),_=O.sdtp(h),b=O.trun(h,_.byteLength+16+16+8+16+8+8);return O.box(O.types.traf,p,g,b,_)}static sdtp(h){let a=new Uint8Array(5),o=h.flags;return a[4]=o.isLeading<<6|o.dependsOn<<4|o.isDependedOn<<2|o.hasRedundancy,O.box(O.types.sdtp,a)}static trun(h,a){let o=28,p=new Uint8Array(o);a+=8+o,p.set([0,0,15,1,0,0,0,1,a>>>24&255,a>>>16&255,a>>>8&255,a&255],0);let g=h.duration,_=h.size,b=h.flags,U=h.cts;return p.set([g>>>24&255,g>>>16&255,g>>>8&255,g&255,_>>>24&255,_>>>16&255,_>>>8&255,_&255,b.isLeading<<2|b.dependsOn,b.isDependedOn<<6|b.hasRedundancy<<4|b.isNonSync,0,0,U>>>24&255,U>>>16&255,U>>>8&255,U&255],12),O.box(O.types.trun,p)}static mdat(h){return O.box(O.types.mdat,h)}};let Ke=O;Ke.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:[]};Ke.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 h in Ke.types)Ke.types.hasOwnProperty(h)&&(Ke.types[h]=[h.charCodeAt(0),h.charCodeAt(1),h.charCodeAt(2),h.charCodeAt(3)]);Ke.constants.STSC=Ke.constants.STTS;Ke.constants.STCO=Ke.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),p=new Uint8Array(4);p.set(this._buffer.subarray(this._buffer_index,this._buffer_index+o)),this._current_word=new DataView(p.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 p=a-this._current_word_bits_left;this._fillCurrentWord();const g=Math.min(p,this._current_word_bits_left),_=this._current_word>>>32-g;return this._current_word<<=g,this._current_word_bits_left-=g,o=o<<g|_,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,p=o.byteLength,g=new Uint8Array(p),_=0;for(let b=0;b<p;b++)b>=2&&o[b]===3&&o[b-1]===0&&o[b-2]===0||(g[_]=o[b],_++);return new Uint8Array(g.buffer,0,_)}static parseSPS(a){let o=a.subarray(1,4),p="avc1.";for(let _e=0;_e<3;_e++){let be=o[_e].toString(16);be.length<2&&(be="0"+be),p+=be}let g=Ur._ebsp2rbsp(a),_=new Yi(g);_.readByte();let b=_.readByte();_.readByte();let U=_.readByte();_.readUEG();let F=Ur.getProfileString(b),w=Ur.getLevelString(U),T=1,k=420,K=[0,420,422,444],Y=8,X=8;if((b===100||b===110||b===122||b===244||b===44||b===83||b===86||b===118||b===128||b===138||b===144)&&(T=_.readUEG(),T===3&&_.readBits(1),T<=3&&(k=K[T]),Y=_.readUEG()+8,X=_.readUEG()+8,_.readBits(1),_.readBool())){let _e=T!==3?8:12;for(let be=0;be<_e;be++)_.readBool()&&(be<6?Ur._skipScalingList(_,16):Ur._skipScalingList(_,64))}_.readUEG();let W=_.readUEG();if(W===0)_.readUEG();else if(W===1){_.readBits(1),_.readSEG(),_.readSEG();let _e=_.readUEG();for(let be=0;be<_e;be++)_.readSEG()}let R=_.readUEG();_.readBits(1);let oe=_.readUEG(),H=_.readUEG(),ne=_.readBits(1);ne===0&&_.readBits(1),_.readBits(1);let Ce=0,ee=0,Q=0,me=0;_.readBool()&&(Ce=_.readUEG(),ee=_.readUEG(),Q=_.readUEG(),me=_.readUEG());let z=1,N=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?(z=be[_e-1],N=Pe[_e-1]):_e===255&&(z=_.readByte()<<8|_.readByte(),N=_.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;(z!==1||N!==1)&&(kr=z/N);let vr=0,Mr=0;if(T===0)vr=1,Mr=2-ne;else{let _e=T===3?1:2,be=T===1?2:1;vr=_e,Mr=be*(2-ne)}let xr=(oe+1)*16,We=(2-ne)*((H+1)*16);xr-=(Ce+ee)*vr,We-=(Q+me)*Mr;let mr=Math.ceil(xr*kr);return _.destroy(),_=null,{codec_mimetype:p,profile_idc:b,level_idc:U,profile_string:F,level_string:w,chroma_format_idc:T,bit_depth:Y,bit_depth_luma:Y,bit_depth_chroma:X,ref_frames:R,chroma_format:k,chroma_format_string:Ur.getChromaFormatString(k),frame_rate:{fixed:hr,fps:dr,fps_den:pr,fps_num:Sr},sar_ratio:{width:z,height:N},codec_size:{width:xr,height:We},present_size:{width:mr,height:We}}}static _skipScalingList(a,o){let p=8,g=8,_=0;for(let b=0;b<o;b++)g!==0&&(_=a.readSEG(),g=(p+_+256)%256),p=g===0?p:g}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:h,pps:a}){let o=8+h.byteLength+1+2+a.byteLength,p=!1;const g=Ur.parseSPS(h);h[3]!==66&&h[3]!==77&&h[3]!==88&&(p=!0,o+=4);let _=new Uint8Array(o);_[0]=1,_[1]=h[1],_[2]=h[2],_[3]=h[3],_[4]=255,_[5]=225;let b=h.byteLength;_[6]=b>>>8,_[7]=b&255;let U=8;_.set(h,8),U+=b,_[U]=1;let F=a.byteLength;_[U+1]=F>>>8,_[U+2]=F&255,_.set(a,U+3),U+=3+F,p&&(_[U]=252|g.chroma_format_idc,_[U+1]=248|g.bit_depth_luma-8,_[U+2]=248|g.bit_depth_chroma-8,_[U+3]=0,U+=4);const w=[23,0,0,0,0],T=new Uint8Array(w.length+_.byteLength);return T.set(w,0),T.set(_,w.length),T}var Ji=Object.defineProperty,eo=Object.getOwnPropertyDescriptor,si=(h,a,o,p)=>{for(var g=p>1?void 0:p?eo(a,o):a,_=h.length-1,b;_>=0;_--)(b=h[_])&&(g=(p?b(a,o,g):b(g))||g);return p&&g&&Ji(a,o,g),g};class ai extends de{constructor(){super(...arguments),this.sourceBufferCache=[]}decode(a){var p,g,_,b,U,F;if(!!((p=this.config)!=null&&p.description))try{const w=a.data.byteLength,T=8+w,k=new Uint8Array(T);new DataView(k.buffer,0).setUint32(0,T,!1),k.set(Ke.types.mdat,4);const Y={id:1,sequenceNumber:++this.sequenceNumber,size:w,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},X=Ke.moof(Y,a.timestamp),W=new Uint8Array(X.byteLength+k.byteLength);W.set(X,0),W.set(k,X.byteLength),(b=this.sourceBuffer)!=null&&b.updating?this.sourceBufferCache.push(W):(U=this.sourceBuffer)==null||U.appendBuffer(W)}catch(w){(F=this.element)==null||F.error,console.error(w)}else{const w=a.data instanceof ArrayBuffer?new Uint8Array(a.data):a.data;let T,k,K=!1;const X=(R=>{const oe=[];for(let H=0;H<R.length-3;H++)R[H]===0&&R[H+1]===0&&R[H+2]===0&&R[H+3]===1?oe.push(H+4):R[H]===0&&R[H+1]===0&&R[H+2]===1&&oe.push(H+3);return oe})(w),W=[];for(let R=0;R<X.length;R++){const oe=X[R],H=R<X.length-1?X[R+1]:w.length;W.push(w.subarray(oe,H))}if(W.forEach((R,oe)=>{const H=R[0]&31;H===7?T=R:H===8?k=R:H===5&&(K=!0)}),T&&k&&!this.sourceBuffer){const R=Ur.parseSPS(T),oe={id:1,type:"video",timescale:1e3,duration:0,avcc:Zi({sps:T,pps:k}),codecWidth:R.codec_size.width,codecHeight:R.codec_size.height,presentWidth:R.present_size.width,presentHeight:R.present_size.height,videoType:"avc"};this.sourceBuffer=this.mse.addSourceBuffer(`video/mp4; codecs="${R.codec_mimetype}"`),this.sourceBuffer.appendBuffer(Ke.generateInitSegment(oe)),this.sourceBuffer.addEventListener("updateend",()=>{this.sourceBufferCache.length&&this.sourceBuffer.appendBuffer(this.sourceBufferCache.shift())})}else{const R=W.reduce((Fe,z)=>Fe+z.length+4,0),oe=8+R,H=new Uint8Array(oe),ne=new DataView(H.buffer,0);ne.setUint32(0,oe,!1),H.set(Ke.types.mdat,4);let Ce=8;W.forEach(Fe=>{ne.setUint32(Ce,Fe.length,!1),H.set(Fe,Ce+4),Ce+=Fe.length+4});const ee={id:1,sequenceNumber:++this.sequenceNumber,size:R,dts:a.timestamp,cts:a.timestamp,isKeyframe:K,data:w,flags:{isLeading:0,dependsOn:2,isDependedOn:1,hasRedundancy:0,isNonSync:0},duration:40},Q=Ke.moof(ee,a.timestamp),me=new Uint8Array(Q.byteLength+H.byteLength);me.set(Q,0),me.set(H,Q.byteLength),(g=this.sourceBuffer)!=null&&g.updating?this.sourceBufferCache.push(me):(_=this.sourceBuffer)==null||_.appendBuffer(me)}}}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,p=6,g=o[p]<<8|o[p+1],_=o.subarray(p+2,p+2+g),b=Ur.parseSPS(_),U={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(Ke.generateInitSegment(U)),this.sourceBuffer.addEventListener("updateend",()=>{this.sourceBufferCache.length&&this.sourceBuffer.appendBuffer(this.sourceBufferCache.shift())})}}}si([Ae([],de.INIT,{sync:!0})],ai.prototype,"reset",1);si([Ae([],"closed",{ignoreError:!0,sync:!0})],ai.prototype,"close",1);si([Ae([de.INIT,"closed"],"initialized")],ai.prototype,"initialize",1);si([Ae("initialized","configured",{sync:!0})],ai.prototype,"configure",1);var ro=(()=>{var h=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(a={}){var o=a,p,g;o.ready=new Promise((e,r)=>{p=e,g=r});var _=Object.assign({},o),b="./this.program",U=typeof window=="object",F=typeof importScripts=="function";typeof process=="object"&&typeof process.versions=="object"&&process.versions.node;var w="";function T(e){return o.locateFile?o.locateFile(e,w):w+e}var k,K,Y;(U||F)&&(F?w=self.location.href:typeof document<"u"&&document.currentScript&&(w=document.currentScript.src),h&&(w=h),w.indexOf("blob:")!==0?w=w.substr(0,w.replace(/[?#].*/,"").lastIndexOf("/")+1):w="",k=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.send(null),r.responseText},F&&(Y=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),K=(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 X=o.print||console.log.bind(console),W=o.printErr||console.error.bind(console);Object.assign(o,_),_=null,o.arguments&&o.arguments,o.thisProgram&&(b=o.thisProgram),o.quit&&o.quit;var R;o.wasmBinary&&(R=o.wasmBinary),o.noExitRuntime,typeof WebAssembly!="object"&&Me("no native wasm support detected");var oe,H,ne=!1;function Ce(e,r){e||Me(r)}var ee,Q,me,Fe,z,N,dr,hr;function Sr(){var e=oe.buffer;o.HEAP8=ee=new Int8Array(e),o.HEAP16=me=new Int16Array(e),o.HEAP32=z=new Int32Array(e),o.HEAPU8=Q=new Uint8Array(e),o.HEAPU16=Fe=new Uint16Array(e),o.HEAPU32=N=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 We(){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 Qe(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 Me(e){o.onAbort&&o.onAbort(e),e="Aborted("+e+")",W(e),ne=!0,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw g(r),r}var Ft="data:application/octet-stream;base64,";function ct(e){return e.startsWith(Ft)}var ze;ze="audiodec.wasm",ct(ze)||(ze=T(ze));function Ir(e){if(e==ze&&R)return new Uint8Array(R);if(Y)return Y(e);throw"both async and sync fetching of the wasm failed"}function Kt(e){return!R&&(U||F)&&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=>{W("failed to asynchronously prepare wasm: "+n),Me(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 W("wasm streaming compile failed: "+l),W("falling back to ArrayBuffer instantiation"),Jr(r,t,n)})}):Jr(r,t,n)}function Yt(){var e={a:gi};function r(n,s){var u=n.exports;return H=u,oe=H.E,Sr(),pr=H.H,_e(H.F),sr(),u}Qe();function t(n){r(n.instance)}if(o.instantiateWasm)try{return o.instantiateWasm(e,r)}catch(n){W("Module.instantiateWasm callback failed with error: "+n),g(n)}return Qt(R,ze,e,t).catch(g),{}}var M,Z,Ar=e=>{for(;e.length>0;)e.shift()(o)};function xe(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(r){N[this.ptr+4>>2]=r},this.get_type=function(){return N[this.ptr+4>>2]},this.set_destructor=function(r){N[this.ptr+8>>2]=r},this.get_destructor=function(){return N[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){N[this.ptr+16>>2]=r},this.get_adjusted_ptr=function(){return N[this.ptr+16>>2]},this.get_exception_ptr=function(){var r=Ln(this.get_type());if(r)return N[this.excPtr>>2];var t=this.get_adjusted_ptr();return t!==0?t:this.excPtr}}var ar=0;function yr(e,r,t){var n=new xe(e);throw n.init(r,t),ar=e,ar}var et=e=>(z[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)},ce=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return e=>crypto.getRandomValues(e);Me("initRandomDevice")},rt=e=>(rt=ce())(e),we={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=we.resolve(e).substr(1),r=we.resolve(r).substr(1);function t(m){for(var C=0;C<m.length&&m[C]==="";C++);for(var S=m.length-1;S>=0&&m[S]==="";S--);return C>S?[]:m.slice(C,S-C+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 y=[],f=l;f<n.length;f++)y.push("..");return y=y.concat(s.slice(l)),y.join("/")}},gr=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Ne=(e,r,t)=>{for(var n=r+t,s=r;e[s]&&!(s>=n);)++s;if(s-r>16&&e.buffer&&gr)return gr.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 y=e[r++]&63;if((l&240)==224?l=(l&15)<<12|f<<6|y:l=(l&7)<<18|f<<12|y<<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},Ie=[],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 y=e.charCodeAt(++l);f=65536+((f&1023)<<10)|y&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(!Ie.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;Ie=Br(e,!0)}return Ie.shift()},De={ttys:[],init:function(){},shutdown:function(){},register:function(e,r){De.ttys[e]={input:[],output:[],ops:r},i.registerDevice(e,De.stream_ops)},stream_ops:{open:function(e){var r=De.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?(X(Ne(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},fsync:function(e){e.output&&e.output.length>0&&(X(Ne(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?(W(Ne(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},fsync:function(e){e.output&&e.output.length>0&&(W(Ne(e.output,0)),e.output=[])}}},tt=e=>{Me()},B={ops_table:null,mount(e){return B.createNode(null,"/",16895,0)},createNode(e,r,t,n){if(i.isBlkdev(t)||i.isFIFO(t))throw new i.ErrnoError(63);B.ops_table||(B.ops_table={dir:{node:{getattr:B.node_ops.getattr,setattr:B.node_ops.setattr,lookup:B.node_ops.lookup,mknod:B.node_ops.mknod,rename:B.node_ops.rename,unlink:B.node_ops.unlink,rmdir:B.node_ops.rmdir,readdir:B.node_ops.readdir,symlink:B.node_ops.symlink},stream:{llseek:B.stream_ops.llseek}},file:{node:{getattr:B.node_ops.getattr,setattr:B.node_ops.setattr},stream:{llseek:B.stream_ops.llseek,read:B.stream_ops.read,write:B.stream_ops.write,allocate:B.stream_ops.allocate,mmap:B.stream_ops.mmap,msync:B.stream_ops.msync}},link:{node:{getattr:B.node_ops.getattr,setattr:B.node_ops.setattr,readlink:B.node_ops.readlink},stream:{}},chrdev:{node:{getattr:B.node_ops.getattr,setattr:B.node_ops.setattr},stream:i.chrdev_stream_ops}});var s=i.createNode(e,r,t,n);return i.isDir(s.mode)?(s.node_ops=B.ops_table.dir.node,s.stream_ops=B.ops_table.dir.stream,s.contents={}):i.isFile(s.mode)?(s.node_ops=B.ops_table.file.node,s.stream_ops=B.ops_table.file.stream,s.usedBytes=0,s.contents=null):i.isLink(s.mode)?(s.node_ops=B.ops_table.link.node,s.stream_ops=B.ops_table.link.stream):i.isChrdev(s.mode)&&(s.node_ops=B.ops_table.chrdev.node,s.stream_ops=B.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&&B.resizeFileStorage(e,r.size)},lookup(e,r){throw i.genericErrors[44]},mknod(e,r,t,n){return B.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=B.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(B.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){B.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 B.stream_ops.write(e,r,0,n,t,!1),0}}},Dt=(e,r,t,n)=>{var s=n?"":`al ${e}`;K(e,u=>{Ce(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&&Qe()},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,y,m){var C=r?we.resolve(q.join2(e,r)):e;function S($){function P(I){m&&m(),f||i.createDataFile(e,r,I,n,s,y),u&&u(),sr()}Ot($,C,P,()=>{l&&l(),sr()})||P($)}Qe(),typeof t=="string"?Dt(t,$=>S($),l):S(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=we.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(S=>!!S),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 y=0;i.isLink(s.mode);){var m=i.readlink(u);u=we.resolve(q.dirname(u),m);var C=i.lookupPath(u,{recurse_count:r.recurse_count+1});if(s=C.node,y++>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&&W(`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:[]},y=e.mount(f);return y.mount=f,f.root=y,n?i.root=y:u&&(u.mounted=f,u.mount&&u.mount.mounts.push(f)),y},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 y=f.name_next;s.includes(f.mount)&&i.destroyNode(f),f=y}}),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(!we.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,y;if(l=i.lookupPath(e,{parent:!0}),f=l.node,l=i.lookupPath(r,{parent:!0}),y=l.node,!f||!y)throw new i.ErrnoError(44);if(f.mount!==y.mount)throw new i.ErrnoError(75);var m=i.lookupNode(f,s),C=we.relative(e,n);if(C.charAt(0)!==".")throw new i.ErrnoError(28);if(C=we.relative(r,t),C.charAt(0)!==".")throw new i.ErrnoError(55);var S;try{S=i.lookupNode(y,u)}catch{}if(m!==S){var $=i.isDir(m.mode),P=i.mayDelete(f,s,$);if(P)throw new i.ErrnoError(P);if(P=S?i.mayDelete(y,u,$):i.mayCreate(y,u),P)throw new i.ErrnoError(P);if(!f.node_ops.rename)throw new i.ErrnoError(63);if(i.isMountpoint(m)||S&&i.isMountpoint(S))throw new i.ErrnoError(10);if(y!==f&&(P=i.nodePermissions(f,"w"),P))throw new i.ErrnoError(P);i.hashRemoveNode(m);try{f.node_ops.rename(m,y,u)}catch(I){throw I}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 we.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=Ne(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)),De.register(i.makedev(5,0),De.default_tty_ops),De.register(i.makedev(6,0),De.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(B,{},"/"),i.createDefaultDirectories(),i.createDefaultDevices(),i.createSpecialDirectories(),i.filesystems={MEMFS:B}},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),y=i.create(l,f);if(t){if(typeof t=="string"){for(var m=new Array(t.length),C=0,S=t.length;C<S;++C)m[C]=t.charCodeAt(C);t=m}i.chmod(y,f|146);var $=i.open(y,577);i.write($,t,0,t.length,0,u),i.close($),i.chmod(y,f)}return y},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,y,m,C,S)=>{for(var $=0,P=0;P<C;P++){var I;try{I=t()}catch{throw new i.ErrnoError(29)}if(I===void 0&&$===0)throw new i.ErrnoError(6);if(I==null)break;$++,y[m+P]=I}return $&&(f.node.timestamp=Date.now()),$},write:(f,y,m,C,S)=>{for(var $=0;$<C;$++)try{n(y[m+$])}catch{throw new i.ErrnoError(29)}return C&&(f.node.timestamp=Date.now()),$}}),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(k)try{e.contents=Br(k(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 I=P%this.chunkSize,J=P/this.chunkSize|0;return this.getter(J)[I]}},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 I=Number(P.getResponseHeader("Content-length")),J,re=(J=P.getResponseHeader("Accept-Ranges"))&&J==="bytes",ae=(J=P.getResponseHeader("Content-Encoding"))&&J==="gzip",ve=1024*1024;re||(ve=I);var te=(ye,Oe)=>{if(ye>Oe)throw new Error("invalid range ("+ye+", "+Oe+") or no bytes requested!");if(Oe>I-1)throw new Error("only "+I+" bytes available! programmer error!");var ue=new XMLHttpRequest;if(ue.open("GET",t,!1),I!==ve&&ue.setRequestHeader("Range","bytes="+ye+"-"+Oe),ue.responseType="arraybuffer",ue.overrideMimeType&&ue.overrideMimeType("text/plain; charset=x-user-defined"),ue.send(null),!(ue.status>=200&&ue.status<300||ue.status===304))throw new Error("Couldn't load "+t+". Status: "+ue.status);return ue.response!==void 0?new Uint8Array(ue.response||[]):Br(ue.responseText||"",!0)},Xe=this;Xe.setDataGetter(ye=>{var Oe=ye*ve,ue=(ye+1)*ve-1;if(ue=Math.min(ue,I-1),typeof Xe.chunks[ye]>"u"&&(Xe.chunks[ye]=te(Oe,ue)),typeof Xe.chunks[ye]>"u")throw new Error("doXHR failed!");return Xe.chunks[ye]}),(ae||!I)&&(ve=I=1,I=this.getter(0).length,ve=I,X("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=I,this._chunkSize=ve,this.lengthKnown=!0},typeof XMLHttpRequest<"u"){if(!F)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 y=i.createFile(e,r,f,n,s);f.contents?y.contents=f.contents:f.url&&(y.contents=null,y.url=f.url),Object.defineProperties(y,{usedBytes:{get:function(){return this.contents.length}}});var m={},C=Object.keys(y.stream_ops);C.forEach($=>{var P=y.stream_ops[$];m[$]=function(){return i.forceLoadFile(y),P.apply(null,arguments)}});function S($,P,I,J,re){var ae=$.node.contents;if(re>=ae.length)return 0;var ve=Math.min(ae.length-re,J);if(ae.slice)for(var te=0;te<ve;te++)P[I+te]=ae[re+te];else for(var te=0;te<ve;te++)P[I+te]=ae.get(re+te);return ve}return m.read=($,P,I,J,re)=>(i.forceLoadFile(y),S($,P,I,J,re)),m.mmap=($,P,I,J,re)=>{i.forceLoadFile(y);var ae=tt();if(!ae)throw new i.ErrnoError(48);return S($,ee,ae,P,I),{ptr:ae,allocated:!0}},y.stream_ops=m,y}},wr=(e,r)=>e?Ne(Q,e,r):"",fe={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=fe.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}z[t>>2]=n.dev,z[t+4>>2]=n.mode,N[t+8>>2]=n.nlink,z[t+12>>2]=n.uid,z[t+16>>2]=n.gid,z[t+20>>2]=n.rdev,Z=[n.size>>>0,(M=n.size,+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[t+24>>2]=Z[0],z[t+28>>2]=Z[1],z[t+32>>2]=4096,z[t+36>>2]=n.blocks;var s=n.atime.getTime(),u=n.mtime.getTime(),l=n.ctime.getTime();return Z=[Math.floor(s/1e3)>>>0,(M=Math.floor(s/1e3),+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[t+40>>2]=Z[0],z[t+44>>2]=Z[1],N[t+48>>2]=s%1e3*1e3,Z=[Math.floor(u/1e3)>>>0,(M=Math.floor(u/1e3),+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[t+56>>2]=Z[0],z[t+60>>2]=Z[1],N[t+64>>2]=u%1e3*1e3,Z=[Math.floor(l/1e3)>>>0,(M=Math.floor(l/1e3),+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[t+72>>2]=Z[0],z[t+76>>2]=Z[1],N[t+80>>2]=l%1e3*1e3,Z=[n.ino>>>0,(M=n.ino,+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[t+88>>2]=Z[0],z[t+92>>2]=Z[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=Q.slice(e,e+t);i.msync(r,u,s,t,n)},varargs:void 0,get(){fe.varargs+=4;var e=z[fe.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){fe.varargs=t;try{var n=fe.getStreamFromFD(e);switch(r){case 0:{var s=fe.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=fe.get();return n.flags|=s,0}case 5:{var s=fe.get(),l=0;return me[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){fe.varargs=n;try{r=fe.getStr(r),r=fe.calculateAt(e,r);var s=n?fe.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;Q[t];)r+=ht[Q[t++]];return r}var Ve={},je={},_r={},Ge=void 0;function V(e){throw new Ge(e)}var Ye=void 0;function br(e){throw new Ye(e)}function tr(e,r,t){e.forEach(function(f){_r[f]=r});function n(f){var y=t(f);y.length!==e.length&&br("Mismatched type converter count");for(var m=0;m<e.length;++m)Ee(e[m],y[m])}var s=new Array(r.length),u=[],l=0;r.forEach((f,y)=>{je.hasOwnProperty(f)?s[y]=je[f]:(u.push(f),Ve.hasOwnProperty(f)||(Ve[f]=[]),Ve[f].push(()=>{s[y]=je[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`),je.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;V(`Cannot register type '${n}' twice`)}if(je[e]=r,delete _r[e],Ve.hasOwnProperty(e)){var s=Ve[e];delete Ve[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=me;else if(t===4)f=z;else throw new TypeError("Unknown boolean type size: "+r);return this.fromWireType(f[l>>u])},destructorFunction:null})}function tn(e){if(!(this instanceof ke)||!(e instanceof ke))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 $e=[];function Nr(){for(;$e.length;){var e=$e.pop();e.$$.deleteScheduled=!1,e.delete()}}var nr=void 0;function ot(e){nr=e,$e.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},Ze(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 y=vt(r,this.registeredClass,f.registeredClass);return y===null?s.call(this):this.isSmartPointer?Pr(f.registeredClass.instancePrototype,{ptrType:f,ptr:y,smartPtrType:this,smartPtr:e}):Pr(f.registeredClass.instancePrototype,{ptrType:f,ptr:y})}var Ze=function(e){return typeof FinalizationRegistry>"u"?(Ze=r=>r,e):(zr=new FinalizationRegistry(r=>{Fr(r.$$)}),Ze=r=>{var t=r.$$,n=!!t.smartPtr;if(n){var s={$$:t};zr.register(r,s,r)}return r},pt=r=>zr.unregister(r),Ze(e))};function yt(){if(this.$$.ptr||Er(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e=Ze(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"),$e.push(this),$e.length===1&&nr&&nr(Nr),this.$$.deleteScheduled=!0,this}function jt(){ke.prototype.isAliasOf=tn,ke.prototype.clone=yt,ke.prototype.delete=fn,ke.prototype.isDeleted=It,ke.prototype.deleteLater=ln}function ke(){}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 Le(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`),Le(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 gt(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(z[e>>2])}function vn(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e}function mn(e){this.rawDestructor&&this.rawDestructor(e)}function yn(e){e!==null&&e.delete()}function gn(){Te.prototype.getPointee=vn,Te.prototype.destructor=mn,Te.prototype.argPackAdvance=8,Te.prototype.readValueFromPointer=$r,Te.prototype.deleteObject=yn,Te.prototype.fromWireType=xt}function Te(e,r,t,n,s,u,l,f,y,m,C){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=y,this.rawShare=m,this.rawDestructor=C,!s&&r.baseClass===void 0?n?(this.toWireType=st,this.destructorFunction=null):(this.toWireType=gt,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 Be(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 Re(r),t}function Gr(e,r){var t=[],n={};function s(u){if(!n[u]&&!je[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,y,m,C,S,$){C=he(C),u=Be(s,u),f&&(f=Be(l,f)),m&&(m=Be(y,m)),$=Be(S,$);var P=Cr(C);Lt(P,function(){Gr(`Cannot construct ${C} due to unbound types`,[n])}),tr([e,r,t],n?[n]:[],function(I){I=I[0];var J,re;n?(J=I.registeredClass,re=J.instancePrototype):re=ke.prototype;var ae=Rr(P,function(){if(Object.getPrototypeOf(this)!==ve)throw new Ge("Use 'new' to construct "+C);if(te.constructor_body===void 0)throw new Ge(C+" has no accessible constructor");var ue=te.constructor_body[arguments.length];if(ue===void 0)throw new Ge(`Tried to invoke ctor of ${C} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(te.constructor_body).toString()}) parameters instead!`);return ue.apply(this,arguments)}),ve=Object.create(re,{constructor:{value:ae}});ae.prototype=ve;var te=new hn(C,ae,ve,$,J,u,f,m);te.baseClass&&(te.baseClass.__derivedClasses===void 0&&(te.baseClass.__derivedClasses=[]),te.baseClass.__derivedClasses.push(te));var Xe=new Te(C,te,!0,!1,!1),ye=new Te(C+"*",te,!1,!1,!1),Oe=new Te(C+" const*",te,!1,!0,!1);return mt[e]={pointerType:ye,constPointerType:Oe},wn(P,ae),[Xe,ye,Oe]})}function bt(e,r){for(var t=[],n=0;n<e;n++)t.push(N[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,y=!1,m=1;m<r.length;++m)if(r[m]!==null&&r[m].destructorFunction===void 0){y=!0;break}for(var C=r[0].name!=="void",S="",$="",m=0;m<l-2;++m)S+=(m!==0?", ":"")+"arg"+m,$+=(m!==0?", ":"")+"arg"+m+"Wired";var P=`
  47. return function ${Cr(e)}(${S}) {
  48. if (arguments.length !== ${l-2}) {
  49. throwBindingError('function ${e} called with ${arguments.length} arguments, expected ${l-2} args!');
  50. }`;y&&(P+=`var destructors = [];
  51. `);var I=y?"destructors":"null",J=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],re=[V,n,s,$n,r[0],r[1]];f&&(P+="var thisWired = classParam.toWireType("+I+`, this);
  52. `);for(var m=0;m<l-2;++m)P+="var arg"+m+"Wired = argType"+m+".toWireType("+I+", arg"+m+"); // "+r[m+2].name+`
  53. `,J.push("argType"+m),re.push(r[m+2]);if(f&&($="thisWired"+($.length>0?", ":"")+$),P+=(C||u?"var rv = ":"")+"invoker(fn"+($.length>0?", ":"")+$+`);
  54. `,y)P+=`runDestructors(destructors);
  55. `;else for(var m=f?1:2;m<r.length;++m){var ae=m===1?"thisWired":"arg"+(m-2)+"Wired";r[m].destructorFunction!==null&&(P+=ae+"_dtor("+ae+"); // "+r[m].name+`
  56. `,J.push(ae+"_dtor"),re.push(r[m].destructorFunction))}return C&&(P+=`var ret = retType.fromWireType(rv);
  57. return ret;
  58. `),P+=`}
  59. `,J.push(P),Et(Function,J).apply(null,re)}function Tn(e,r,t,n,s,u){var l=bt(r,t);s=Be(n,s),tr([],[e],function(f){f=f[0];var y=`constructor ${f.name}`;if(f.registeredClass.constructor_body===void 0&&(f.registeredClass.constructor_body=[]),f.registeredClass.constructor_body[r-1]!==void 0)throw new Ge(`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(y,m,null,s,u),[]}),[]})}function Ct(e,r,t,n,s,u,l,f,y){var m=bt(t,n);r=he(r),u=Be(s,u),tr([],[e],function(C){C=C[0];var S=`${C.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),f&&C.registeredClass.pureVirtualFunctions.push(r);function $(){Gr(`Cannot call ${S} due to unbound types`,m)}var P=C.registeredClass.instancePrototype,I=P[r];return I===void 0||I.overloadTable===void 0&&I.className!==C.name&&I.argCount===t-2?($.argCount=t-2,$.className=C.name,P[r]=$):(Le(P,r,S),P[r].overloadTable[t-2]=$),tr([],m,function(J){var re=Pt(S,J,C,u,l,y);return P[r].overloadTable===void 0?(re.argCount=t-2,P[r]=re):P[r].overloadTable[t-2]=re,[]}),[]})}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 Q[s]};case 1:return t?function(s){return me[s>>1]}:function(s){return Fe[s>>1]};case 2:return t?function(s){return z[s>>2]}:function(s){return N[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=S=>S;if(n===0){var f=32-8*t;l=S=>S<<f>>>f}var y=r.includes("unsigned"),m=(S,$)=>{},C;y?C=function(S,$){return m($,this.name),$>>>0}:C=function(S,$){return m($,this.name),$},Ee(e,{name:r,fromWireType:l,toWireType:C,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=N,y=f[l],m=f[l+1];return new s(f.buffer,m,y)}t=he(t),Ee(e,{name:t,fromWireType:u,argPackAdvance:8,readValueFromPointer:u},{ignoreDuplicateRegistrations:!0})}var Un=(e,r,t)=>Lr(e,Q,r,t);function or(e,r){r=he(r);var t=r==="std::string";Ee(e,{name:r,fromWireType:function(n){var s=N[n>>2],u=n+4,l;if(t)for(var f=u,y=0;y<=s;++y){var m=u+y;if(y==s||Q[m]==0){var C=m-f,S=wr(f,C);l===void 0?l=S:(l+=String.fromCharCode(0),l+=S),f=m+1}}else{for(var $=new Array(s),y=0;y<s;++y)$[y]=String.fromCharCode(Q[u+y]);l=$.join("")}return Re(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),y=f+4;if(N[f>>2]=u,t&&l)Un(s,y,u+1);else if(l)for(var m=0;m<u;++m){var C=s.charCodeAt(m);C>255&&(Re(y),V("String has UTF-16 code units that do not fit in 8 bits")),Q[y+m]=C}else for(var m=0;m<u;++m)Q[y+m]=s[m];return n!==null&&n.push(Re,f),f},argPackAdvance:8,readValueFromPointer:$r,destructorFunction:function(n){Re(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)&&Fe[n];)++n;if(t=n<<1,t-e>32&&Xr)return Xr.decode(Q.subarray(e,t));for(var u="",l=0;!(l>=r/2);++l){var f=me[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);me[r>>1]=l,r+=2}return me[r>>1]=0,r-n},ut=e=>e.length*2,Nt=(e,r)=>{for(var t=0,n="";!(t>=r/4);){var s=z[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(z[r>>2]=l,r+=4,r+4>s)break}return z[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=()=>Fe,f=1):r===4&&(n=Nt,s=c,l=d,u=()=>N,f=2),Ee(e,{name:t,fromWireType:function(y){for(var m=N[y>>2],C=u(),S,$=y+4,P=0;P<=m;++P){var I=y+4+P*r;if(P==m||C[I>>f]==0){var J=I-$,re=n($,J);S===void 0?S=re:(S+=String.fromCharCode(0),S+=re),$=I+r}}return Re(y),S},toWireType:function(y,m){typeof m!="string"&&V(`Cannot pass non-string to C++ string type ${t}`);var C=l(m),S=kt(4+C+r);return N[S>>2]=C>>f,s(m,S+4,C+r),y!==null&&y.push(Re,S),S},argPackAdvance:8,readValueFromPointer:$r,destructorFunction:function(y){Re(y)}})};function E(e,r){r=he(r),Ee(e,{isVoid:!0,name:r,argPackAdvance:0,fromWireType:function(){},toWireType:function(t,n){}})}var A={};function x(e){var r=A[e];return r===void 0?he(e):r}var j=[];function D(e,r,t,n){e=j[e],r=Tr.toValue(r),t=x(t),e(r,t,null,n)}function G(e){var r=j.length;return j.push(e),r}function L(e,r){var t=je[e];return t===void 0&&V(r+" has unknown type "+_t(e)),t}function ie(e,r){for(var t=new Array(e),n=0;n<e;++n)t[n]=L(N[r+n*4>>2],"parameter "+n);return t}var se=[];function le(e,r){var t=ie(e,r),n=t[0],s=n.name+"_$"+t.slice(1).map(function(I){return I.name}).join("_")+"$",u=se[s];if(u!==void 0)return u;for(var l=["retType"],f=[n],y="",m=0;m<e-1;++m)y+=(m!==0?", ":"")+"arg"+m,l.push("argType"+m),f.push(t[1+m]);for(var C=Cr("methodCaller_"+s),S="return function "+C+`(handle, name, destructors, args) {
  60. `,$=0,m=0;m<e-1;++m)S+=" var arg"+m+" = argType"+m+".readValueFromPointer(args"+($?"+"+$:"")+`);
  61. `,$+=t[m+1].argPackAdvance;S+=" var rv = handle[name]("+y+`);
  62. `;for(var m=0;m<e-1;++m)t[m+1].deleteObject&&(S+=" argType"+m+".deleteObject(arg"+m+`);
  63. `);n.isVoid||(S+=` return retType.toWireType(destructors, rv);
  64. `),S+=`};
  65. `,l.push(S);var P=Et(Function,l).apply(null,f);return u=G(P),se[s]=u,u}function pe(e,r){return r+2097152>>>0<4194305-!!e?(e>>>0)+r*4294967296:NaN}var Se=()=>{Me("")};function He(){return Date.now()}var Ue=()=>Q.length,fr=()=>Ue(),St=(e,r,t)=>Q.copyWithin(e,r,r+t),qe=e=>{Me("OOM")},Mn=e=>{Q.length,qe()},Or={},Vt=()=>b||"./this.program",Je=()=>{if(!Je.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]}`);Je.strings=n}return Je.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 Je().forEach(function(n,s){var u=r+t;N[e+s*4>>2]=u,ui(n,u),t+=n.length+1}),0},li=(e,r)=>{var t=Je();N[e>>2]=t.length;var n=0;return t.forEach(function(s){n+=s.length+1}),N[r>>2]=n,0};function ci(e){try{var r=fe.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=fe.getStreamFromFD(e),l=u.tty?2:i.isDir(u.mode)?3:i.isLink(u.mode)?7:4;return ee[r>>0]=l,me[r+2>>1]=s,Z=[t>>>0,(M=t,+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[r+8>>2]=Z[0],z[r+12>>2]=Z[1],Z=[n>>>0,(M=n,+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[r+16>>2]=Z[0],z[r+20>>2]=Z[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=N[r>>2],f=N[r+4>>2];r+=8;var y=i.read(e,ee,l,f,n);if(y<0)return-1;if(s+=y,y<f)break;typeof n<"u"&&(n+=y)}return s};function pi(e,r,t,n){try{var s=fe.getStreamFromFD(e),u=hi(s,r,t);return N[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=fe.getStreamFromFD(e);return i.llseek(l,u,n),Z=[l.position>>>0,(M=l.position,+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[s>>2]=Z[0],z[s+4>>2]=Z[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=N[r>>2],f=N[r+4>>2];r+=8;var y=i.write(e,ee,l,f,n);if(y<0)return-1;s+=y,typeof n<"u"&&(n+=y)}return s};function yi(e,r,t,n){try{var s=fe.getStreamFromFD(e),u=mi(s,r,t);return N[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(),Ge=o.BindingError=class extends Error{constructor(r){super(r),this.name="BindingError"}},Ye=o.InternalError=class extends Error{constructor(r){super(r),this.name="InternalError"}},jt(),Mt(),gn(),wt=o.UnboundTypeError=Pn(Error,"UnboundTypeError"),Sn(),kn();var gi={p:yr,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:D,m:Tt,l:le,a:Se,e:He,v:fr,A:St,u:Mn,y:fi,z:li,i:ci,x:di,B:pi,s:vi,h:yi};Yt();var kt=e=>(kt=H.G)(e),Re=e=>(Re=H.I)(e),In=()=>(In=H.J)(),jn=e=>(jn=H.K)(e);o.__embind_initialize_bindings=()=>(o.__embind_initialize_bindings=H.L)();var Ln=e=>(Ln=H.M)(e);o.dynCall_viiijj=(e,r,t,n,s,u,l,f)=>(o.dynCall_viiijj=H.N)(e,r,t,n,s,u,l,f),o.dynCall_jij=(e,r,t,n)=>(o.dynCall_jij=H.O)(e,r,t,n),o.dynCall_jii=(e,r,t)=>(o.dynCall_jii=H.P)(e,r,t),o.dynCall_jiji=(e,r,t,n,s)=>(o.dynCall_jiji=H.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,!ne&&(xr(),p(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),We()))}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=(h,a,o,p)=>{for(var g=p>1?void 0:p?no(a,o):a,_=h.length-1,b;_>=0;_--)(b=h[_])&&(g=(p?b(a,o,g):b(g))||g);return p&&g&&to(a,o,g),g};class Zn extends de{constructor(){super(...arguments),this.sampleRate=0,this.channels=0}initialize(){return new Promise(a=>{const o={};o.print=p=>console.log(p),o.printErr=p=>console.log(`[JS] ERROR: ${p}`),o.onAbort=()=>console.log("[JS] FATAL: WASM ABORTED"),o.postRun=p=>{this.module=p,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 p={sampleRate:a,channels:o,depth:16};this.emit(Gt.AudioCodecInfo,p)}pcmData(a,o,p){if(!this.module)return;let g=[],_=0,b=0;for(let F=0;F<this.channels;F++){let w=this.module.HEAPU32[(a>>2)+F]>>2;const T=this.module.HEAPF32.subarray(w,w+o);g.push(T),_+=T.length}const U=new Float32Array(_);this.emit(Gt.AudioFrame,new AudioData({format:"f32-planar",sampleRate:this.sampleRate,numberOfChannels:this.channels,timestamp:p,numberOfFrames:o,data:g.reduce((F,w)=>(F.subarray(b).set(w),b+=w.length,F),U)}))}errorInfo(a){let o={errMsg:a};this.emit(Gt.Error,o)}}Yn([Ae(de.INIT,"initialized")],Zn.prototype,"initialize",1);Yn([Ae("initialized","configured",{sync:!0})],Zn.prototype,"configure",1);Yn([Ti("configured")],Zn.prototype,"decode",1);Yn([Ae("configured","initialized",{sync:!0})],Zn.prototype,"reset",1);Yn([Ae([],"closed",{sync:!0})],Zn.prototype,"close",1);var io=Object.defineProperty,oo=Object.getOwnPropertyDescriptor,Jn=(h,a,o,p)=>{for(var g=p>1?void 0:p?oo(a,o):a,_=h.length-1,b;_>=0;_--)(b=h[_])&&(g=(p?b(a,o,g):b(g))||g);return p&&g&&io(a,o,g),g};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){a.codec==="aac"&&(a.codec="mp4a.40.2"),this.config=a,this.decoder.configure(a)}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([Ae([de.INIT,"closed"],"initialized")],ei.prototype,"initialize",1);Jn([Ae("initialized","configured",{sync:!0})],ei.prototype,"configure",1);Jn([Ti("configured")],ei.prototype,"decode",1);Jn([Ae([],de.INIT,{sync:!0})],ei.prototype,"reset",1);Jn([Ae([],"closed",{ignoreError:!0,sync:!0})],ei.prototype,"close",1);var Hn=(h=>(h.AUDIO_ENCODER_CONFIG_CHANGED="audio-encoder-config-changed",h.VIDEO_ENCODER_CONFIG_CHANGED="video-encoder-config-changed",h.DEMUX_ERROR="demux-error",h))(Hn||{}),Wn=(h=>(h[h.PULL=0]="PULL",h[h.PUSH=1]="PUSH",h))(Wn||{});class so extends qt.EventEmitter{constructor(a,o=0,p="annexb"){super(),this.source=a,this.mode=o,this.format=p,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(h,a=!1,o){const p=new Uint8Array([0,0,0,1]);let g=0;if(a&&o&&o.length>0)for(const w of o)w instanceof Uint8Array&&w.length>0&&(g+=w.length+4);let _=0,b=0;for(;b<h.length&&!(b+4>h.length);){const w=h[b]<<24|h[b+1]<<16|h[b+2]<<8|h[b+3];if(w<0||b+4+w>h.length)break;_+=w+4,b+=4+w}g+=_;const U=new Uint8Array(g);let F=0;if(a&&o&&o.length>0){for(const w of o)if(w instanceof Uint8Array&&w.length>0){if(F+4+w.length>U.length)return console.error("Error writing parameter set: buffer overflow"),U.slice(0,F);U.set(p,F),U.set(w,F+4),F+=w.length+4}}for(b=0;b<h.length&&!(b+4>h.length);){const w=h[b]<<24|h[b+1]<<16|h[b+2]<<8|h[b+3];if(w<0||b+4+w>h.length)break;if(F+4+w>U.length){console.error("Error writing NALU from AVCC: buffer overflow");break}U.set(p,F),U.set(h.subarray(b+4,b+4+w),F+4),F+=w+4,b+=4+w}return F!==g?U.slice(0,F):U}function Co(h){const a=((h[2]&192)>>>6)+1,o=(h[2]&60)>>>2,p=(h[2]&1)<<2|(h[3]&192)>>>6,g=new Uint8Array([(a&3)<<3|(o&14)>>1,(o&1)<<7|(p&15)<<3]);return{profile:a,sampleRate:Oi[o],channel:p,audioSpecificConfig:g}}function Di(h){const a=[],o=[];let p=0;if(!h||h.length<7)return console.error("Invalid AVCC data: too short"),{sps:a,pps:o};p+=5;const g=h[p++]&31;for(let b=0;b<g;b++){if(p+2>h.length){console.error("Invalid AVCC data: not enough bytes for SPS length");break}const U=h[p]<<8|h[p+1];if(p+=2,p+U>h.length){console.error("Invalid AVCC data: not enough bytes for SPS NAL unit");break}a.push(h.subarray(p,p+U)),p+=U}if(p+1>h.length)return g>0&&a.length,{sps:a,pps:o};const _=h[p++];for(let b=0;b<_;b++){if(p+2>h.length){console.error("Invalid AVCC data: not enough bytes for PPS length");break}const U=h[p]<<8|h[p+1];if(p+=2,p+U>h.length){console.error("Invalid AVCC data: not enough bytes for PPS NAL unit");break}o.push(h.subarray(p,p+U)),p+=U}return{sps:a,pps:o}}function ao(h){const a=[],o=[],p=[];let g=0;if(!h||h.length<23)return console.error("Invalid HVCC data: too short for header"),{vps:a,sps:o,pps:p};g+=22;const _=h[g++];if(g+_*3>h.length)return console.error("Invalid HVCC data: numOfArrays inconsistent with data length"),{vps:a,sps:o,pps:p};for(let b=0;b<_;b++){if(g+3>h.length){console.error("Invalid HVCC data: not enough bytes for NAL unit array header");break}const U=h[g]&63;g++;const F=h[g]<<8|h[g+1];g+=2;let w=!1;for(let T=0;T<F;T++){if(g+2>h.length){console.error("Invalid HVCC data: not enough bytes for NAL unit length"),w=!0;break}const k=h[g]<<8|h[g+1];if(g+=2,g+k>h.length){console.error("Invalid HVCC data: not enough bytes for NAL unit data"),w=!0;break}const K=h.subarray(g,g+k);switch(g+=k,U){case 32:a.push(K);break;case 33:o.push(K);break;case 34:p.push(K);break}}if(w)break}return{vps:a,sps:o,pps:p}}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],p=this.readLength(a.subarray(5,8)),g=this.readTimestamp(a.subarray(8,11)),_=await this.source.read(p);return{type:o,data:_.slice(),timestamp:g}},console.time("flv"),await this.source.read(9).then(o=>{if(this.header=o,o.subarray(0,3).reduce((p,g)=>p+String.fromCharCode(g),"")!=="FLV")throw new Error("not flv");console.timeEnd("flv")}),this.pullTag()}readTag(a){const o=a[0],p=this.readLength(a.subarray(1,4)),g=this.readTimestamp(a.subarray(4,8));this.gotTag(o,a.subarray(11,11+p),g)}gotTag(a,o,p){var g,_,b,U,F;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):(g=this.gotAudio)==null?void 0:g.call(this,{type:"key",data:this.audioDecoderConfig.codec=="aac"?o.subarray(2):o.subarray(1),timestamp:p,duration:0});case 9:if(o[0]>>7){const k=o[0]&15;if(k){const K=(o[0]&112)>>4==1,Y=k===3,X=o.subarray(Y?5:8);return(b=this.gotVideo)==null?void 0:b.call(this,{type:K?"key":"delta",data:this.format==="annexb"&&((_=this.videoDecoderConfig)==null?void 0:_.codec)!=="av1"?Fi(X,K,this.videoDecoderConfig.parameterSets):X,timestamp:p,duration:0})}else{switch(o.subarray(1,5).reduce((K,Y)=>K+String.fromCharCode(Y),"")){case uo:const K={codec:"hevc",description:o.subarray(5)};if(this.format==="annexb"){const Y=ao(K.description);this.videoDecoderConfig={codec:"hevc",parameterSets:[Y.vps[0],Y.sps[0],Y.pps[0]]}}else this.videoDecoderConfig=K;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 k={codec:{7:"avc",12:"hevc",13:"av1"}[o[0]&15]||"unknown",description:o.subarray(5)};if(k.codec=="av1")this.videoDecoderConfig={codec:"av1"};else if(this.format==="annexb"){const K=k.codec==="hevc";let Y=[];if(K){const X=Di(k.description);Y=[X.vps[0],X.sps[0],X.pps[0]]}else{const X=Di(k.description);Y=[X.sps[0],X.pps[0]]}this.videoDecoderConfig={codec:k.codec,parameterSets:Y}}else this.videoDecoderConfig=k;return this.emit(Hn.VIDEO_ENCODER_CONFIG_CHANGED,this.videoDecoderConfig),this.mode==Wn.PULL?this.pull():void 0}const w=o[0]>>4==1,T=o.subarray(5);return(F=this.gotVideo)==null?void 0:F.call(this,{type:w?"key":"delta",data:this.format==="annexb"&&((U=this.videoDecoderConfig)==null?void 0:U.codec)!=="av1"?Fi(T,w,this.videoDecoderConfig.parameterSets):T,timestamp:p,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,p)=>o+String.fromCharCode(p),"")!=="FLV")throw new Error("not flv");console.timeEnd("flv")}*demux(){for(this.readHead(yield 13);;){let a=yield 11;const o=a[0],p=this.readLength(a.subarray(1,4)),g=this.readTimestamp(a.subarray(4,8));a=yield p,this.gotTag(o,a.slice(),g),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,p=a.numberOfFrames,g=a.sampleRate,_=new AudioBuffer({length:p,numberOfChannels:o,sampleRate:g});for(let b=0;b<o;b++){const U=new Float32Array(p);a.copyTo(U,{planeIndex:b}),_.copyToChannel(U,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 p=this.audioContext.createBufferSource();p.buffer=o.buffer,p.connect(this.audioContext.destination);const g=Math.max(0,a-o.startTime);o.buffer.duration-g>0&&p.start(a,g),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,go 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};