jb4-983fc7d0.js 94 KB

1234567891011121314151617181920212223242526
  1. import{d as Pi,k as Ur,r as Ci,b as Ti,s as yt,o as Si,x as Di,U as Ai,V as ki,t as Fi,A as Oi,f as Ri,u as $i,a8 as Ui,W as Ni,af as Ii}from"./vue-18ee037d.js";import"./dayjs-4778c158.js";import{av as hr,bH as Mi,af as ji,N as xi}from"./index-314658c5.js";var le=(v=>(v.VideoCodecInfo="videoCodecInfo",v.VideoFrame="videoFrame",v.Error="error",v))(le||{}),Pe=(v=>(v.AudioCodecInfo="audioCodecInfo",v.AudioFrame="audioFrame",v.Error="error",v))(Pe||{}),ze={},Li={get exports(){return ze},set exports(v){ze=v}};(function(v){var s=Object.prototype.hasOwnProperty,o="~";function d(){}Object.create&&(d.prototype=Object.create(null),new d().__proto__||(o=!1));function h(S,m,y){this.fn=S,this.context=m,this.once=y||!1}function _(S,m,y,P,j){if(typeof y!="function")throw new TypeError("The listener must be a function");var A=new h(y,P||S,j),$=o?o+m:m;return S._events[$]?S._events[$].fn?S._events[$]=[S._events[$],A]:S._events[$].push(A):(S._events[$]=A,S._eventsCount++),S}function g(S,m){--S._eventsCount===0?S._events=new d:delete S._events[m]}function D(){this._events=new d,this._eventsCount=0}D.prototype.eventNames=function(){var m=[],y,P;if(this._eventsCount===0)return m;for(P in y=this._events)s.call(y,P)&&m.push(o?P.slice(1):P);return Object.getOwnPropertySymbols?m.concat(Object.getOwnPropertySymbols(y)):m},D.prototype.listeners=function(m){var y=o?o+m:m,P=this._events[y];if(!P)return[];if(P.fn)return[P.fn];for(var j=0,A=P.length,$=new Array(A);j<A;j++)$[j]=P[j].fn;return $},D.prototype.listenerCount=function(m){var y=o?o+m:m,P=this._events[y];return P?P.fn?1:P.length:0},D.prototype.emit=function(m,y,P,j,A,$){var O=o?o+m:m;if(!this._events[O])return!1;var T=this._events[O],W=arguments.length,Q,U;if(T.fn){switch(T.once&&this.removeListener(m,T.fn,void 0,!0),W){case 1:return T.fn.call(T.context),!0;case 2:return T.fn.call(T.context,y),!0;case 3:return T.fn.call(T.context,y,P),!0;case 4:return T.fn.call(T.context,y,P,j),!0;case 5:return T.fn.call(T.context,y,P,j,A),!0;case 6:return T.fn.call(T.context,y,P,j,A,$),!0}for(U=1,Q=new Array(W-1);U<W;U++)Q[U-1]=arguments[U];T.fn.apply(T.context,Q)}else{var Qe=T.length,ee;for(U=0;U<Qe;U++)switch(T[U].once&&this.removeListener(m,T[U].fn,void 0,!0),W){case 1:T[U].fn.call(T[U].context);break;case 2:T[U].fn.call(T[U].context,y);break;case 3:T[U].fn.call(T[U].context,y,P);break;case 4:T[U].fn.call(T[U].context,y,P,j);break;default:if(!Q)for(ee=1,Q=new Array(W-1);ee<W;ee++)Q[ee-1]=arguments[ee];T[U].fn.apply(T[U].context,Q)}}return!0},D.prototype.on=function(m,y,P){return _(this,m,y,P,!1)},D.prototype.once=function(m,y,P){return _(this,m,y,P,!0)},D.prototype.removeListener=function(m,y,P,j){var A=o?o+m:m;if(!this._events[A])return this;if(!y)return g(this,A),this;var $=this._events[A];if($.fn)$.fn===y&&(!j||$.once)&&(!P||$.context===P)&&g(this,A);else{for(var O=0,T=[],W=$.length;O<W;O++)($[O].fn!==y||j&&!$[O].once||P&&$[O].context!==P)&&T.push($[O]);T.length?this._events[A]=T.length===1?T[0]:T:g(this,A)}return this},D.prototype.removeAllListeners=function(m){var y;return m?(y=o?o+m:m,this._events[y]&&g(this,y)):(this._events=new d,this._eventsCount=0),this},D.prototype.off=D.prototype.removeListener,D.prototype.addListener=D.prototype.on,D.prefixed=o,D.EventEmitter=D,v.exports=D})(Li);const wt=Symbol("instance"),Nr=Symbol("cacheResult");class Ir{constructor(s,o,d){this.oldState=s,this.newState=o,this.action=d,this.aborted=!1}abort(s){this.aborted=!0,He.call(s,this.oldState,new Error(`action '${this.action}' aborted`))}toString(){return`${this.action}ing`}}class pr extends Error{constructor(s,o,d){super(o),this.state=s,this.message=o,this.cause=d}}function Hi(v){return typeof v=="object"&&v&&"then"in v}const Le=new Map;function B(v,s,o={}){return(d,h,_)=>{const g=o.action||h;if(!o.context){const S=Le.get(d)||[];Le.has(d)||Le.set(d,S),S.push({from:v,to:s,action:g})}const D=_.value;_.value=function(...S){let m=this;if(o.context&&(m=N.get(typeof o.context=="function"?o.context.call(this,...S):o.context)),m.state===s)return m[Nr];m.state instanceof Ir&&m.state.action==o.abortAction&&m.state.abort(m);let y=null;if(Array.isArray(v)?v.length==0?m.state instanceof Ir&&m.state.abort(m):(typeof m.state!="string"||!v.includes(m.state))&&(y=new pr(m._state,`${m.name} ${g} to ${s} failed: current state ${m._state} not in from config`)):v!==m.state&&(y=new pr(m._state,`${m.name} ${g} to ${s} failed: current state ${m._state} not from ${v}`)),y)if(o.fail)o.fail.call(this,y);else{if(o.ignoreError)return y;throw y}const P=m.state,j=new Ir(P,s,g);He.call(m,j);const A=O=>{var T;return m[Nr]=O,j.aborted||(He.call(m,s),(T=o.success)===null||T===void 0||T.call(this,m[Nr])),O},$=O=>{const T=O instanceof Error?O.message:String(O);if(He.call(m,P,O),o.fail)o.fail.call(this,new pr(m._state,`action '${g}' failed :${T}`,O instanceof Error?O:new Error(T)));else{if(o.ignoreError)return O;throw O}};try{const O=D.apply(this,S);return Hi(O)?O.then(A).catch($):A(O)}catch(O){$(O)}}}}function Be(...v){return(s,o,d)=>{const h=d.value,_=o;d.value=function(...g){if(!v.includes(this.state.toString()))throw new pr(this.state,`${this.name} ${_} failed: current state ${this.state} not in ${v}`);return h.apply(this,g)}}}const zi=(()=>typeof window<"u"&&window.__AFSM__?(o,d)=>{window.dispatchEvent(new CustomEvent(o,{detail:d}))}:typeof importScripts<"u"?(o,d)=>{postMessage({type:o,payload:d})}:()=>{})();function He(v,s){const o=this._state;this._state=v;const d=v.toString();v&&this.emit(d,o),this.emit(N.STATECHANGED,v,o,s),this.updateDevTools({value:v,old:o,err:s instanceof Error?s.message:String(s)})}class N extends ze{constructor(s,o,d){super(),this.name=s,this.groupName=o,this._state=N.INIT,s||(s=Date.now().toString(36)),d?Object.setPrototypeOf(this,d):d=Object.getPrototypeOf(this),o||(this.groupName=this.constructor.name);const h=d[wt];h?this.name=h.name+"-"+h.count++:d[wt]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){const s=Object.getPrototypeOf(this),o=Le.get(s)||[];let d=new Set,h=[],_=[];const g=new Set,D=Object.getPrototypeOf(s);Le.has(D)&&(D.stateDiagram.forEach(m=>d.add(m)),D.allStates.forEach(m=>g.add(m))),o.forEach(({from:m,to:y,action:P})=>{typeof m=="string"?h.push({from:m,to:y,action:P}):m.length?m.forEach(j=>{h.push({from:j,to:y,action:P})}):_.push({to:y,action:P})}),h.forEach(({from:m,to:y,action:P})=>{g.add(m),g.add(y),g.add(P+"ing"),d.add(`${m} --> ${P}ing : ${P}`),d.add(`${P}ing --> ${y} : ${P} 🟢`),d.add(`${P}ing --> ${m} : ${P} 🔴`)}),_.forEach(({to:m,action:y})=>{d.add(`${y}ing --> ${m} : ${y} 🟢`),g.forEach(P=>{P!==m&&d.add(`${P} --> ${y}ing : ${y}`)})});const S=[...d];return Object.defineProperties(s,{stateDiagram:{value:S},allStates:{value:g}}),S}static get(s){let o;return typeof s=="string"?(o=N.instances.get(s),o||N.instances.set(s,o=new N(s,void 0,Object.create(N.prototype)))):(o=N.instances2.get(s),o||N.instances2.set(s,o=new N(s.constructor.name,void 0,Object.create(N.prototype)))),o}static getState(s){var o;return(o=N.get(s))===null||o===void 0?void 0:o.state}updateDevTools(s={}){zi(N.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},s))}get state(){return this._state}set state(s){He.call(this,s)}}N.STATECHANGED="stateChanged";N.UPDATEAFSM="updateAFSM";N.INIT="[*]";N.ON="on";N.OFF="off";N.instances=new Map;N.instances2=new WeakMap;var me=(v=>(v.CONNECTED="connected",v.DISCONNECTED="disconnected",v.RECONNECTED="reconnected",v))(me||{}),Bi=globalThis&&globalThis.__awaiter||function(v,s,o,d){function h(_){return _ instanceof o?_:new o(function(g){g(_)})}return new(o||(o=Promise))(function(_,g){function D(y){try{m(d.next(y))}catch(P){g(P)}}function S(y){try{m(d.throw(y))}catch(P){g(P)}}function m(y){y.done?_(y.value):h(y.value).then(D,S)}m((d=d.apply(v,s||[])).next())})};const jr=Symbol(32),xr=Symbol(16),Lr=Symbol(8);class We{constructor(s){this.g=s,this.consumed=0,s&&(this.need=s.next().value)}setG(s){this.g=s,this.demand(s.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(s,o){return o&&this.consume(),this.need=s,this.flush()}read(s){return Bi(this,void 0,void 0,function*(){return this.lastReadPromise&&(yield this.lastReadPromise),this.lastReadPromise=new Promise((o,d)=>{var h;this.reject=d,this.resolve=g=>{delete this.lastReadPromise,delete this.resolve,delete this.need,o(g)},this.demand(s,!0)||(h=this.pull)===null||h===void 0||h.call(this,s)})})}readU32(){return this.read(jr)}readU16(){return this.read(xr)}readU8(){return this.read(Lr)}close(){var s;this.g&&this.g.return(),this.buffer&&this.buffer.subarray(0,0),(s=this.reject)===null||s===void 0||s.call(this,new Error("EOF")),delete this.lastReadPromise}flush(){if(!this.buffer||!this.need)return;let s=null;const o=this.buffer.subarray(this.consumed);let d=0;const h=_=>o.length<(d=_);if(typeof this.need=="number"){if(h(this.need))return;s=o.subarray(0,d)}else if(this.need===jr){if(h(4))return;s=o[0]<<24|o[1]<<16|o[2]<<8|o[3]}else if(this.need===xr){if(h(2))return;s=o[0]<<8|o[1]}else if(this.need===Lr){if(h(1))return;s=o[0]}else if("buffer"in this.need){if("byteOffset"in this.need){if(h(this.need.byteLength-this.need.byteOffset))return;new Uint8Array(this.need.buffer,this.need.byteOffset).set(o.subarray(0,d)),s=this.need}else if(this.g){this.g.throw(new Error("Unsupported type"));return}}else{if(h(this.need.byteLength))return;new Uint8Array(this.need).set(o.subarray(0,d)),s=this.need}return this.consumed+=d,this.g?this.demand(this.g.next(s).value,!0):this.resolve&&this.resolve(s),s}write(s){if(s instanceof Uint8Array?this.malloc(s.length).set(s):"buffer"in s?this.malloc(s.byteLength).set(new Uint8Array(s.buffer,s.byteOffset,s.byteLength)):this.malloc(s.byteLength).set(new Uint8Array(s)),this.g||this.resolve)this.flush();else return new Promise(o=>this.pull=o)}writeU32(s){this.malloc(4).set([s>>24&255,s>>16&255,s>>8&255,s&255]),this.flush()}writeU16(s){this.malloc(2).set([s>>8&255,s&255]),this.flush()}writeU8(s){this.malloc(1)[0]=s,this.flush()}malloc(s){if(this.buffer){const o=this.buffer.length,d=o+s;if(d<=this.buffer.buffer.byteLength-this.buffer.byteOffset)this.buffer=new Uint8Array(this.buffer.buffer,this.buffer.byteOffset,d);else{const h=new Uint8Array(d);h.set(this.buffer),this.buffer=h}return this.buffer.subarray(o,d)}else return this.buffer=new Uint8Array(s),this.buffer}}We.U32=jr;We.U16=xr;We.U8=Lr;var Wi=Object.defineProperty,Vi=Object.getOwnPropertyDescriptor,Ve=(v,s,o,d)=>{for(var h=d>1?void 0:d?Vi(s,o):s,_=v.length-1,g;_>=0;_--)(g=v[_])&&(h=(d?g(s,o,h):g(h))||h);return d&&h&&Wi(s,o,h),h};function bt(v,s=1,o=1){return v<=1?o:bt(v-1,o,s+o)}function Gi(v){const s=Math.round(v/2)+1;return s>6?13*1e3:bt(s)*1e3}class _t{constructor(){this.total=0,this._buffer=0,this.lastTime=0,this._bps=0}add(s){const o=Date.now();this._buffer+=s,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+=s}get bps(){return Date.now()-this.lastTime>5e3?0:this._bps}}class he extends N{constructor(s,o={}){super(s||"conn","Connection"),this.url=s,this.options=o,this.up=new _t,this.down=new _t,this.underlyingSink={write:async d=>{var h;return this.down.add(d.length||d.byteLength),(h=this.oput)==null?void 0:h.write(d)}},this.options.reconnectTimeout||(this.options.reconnectTimeout=Gi)}read(s){return Promise.reject("not connected")}async connect(){this.abortCtrl=new AbortController,`${this.url}`,console.time(this.url),this.onConnected(await this._connect())}_close(){}_send(s){}async reconnect(){`${this.url}`,console.time(this.url),this.abortCtrl=new AbortController,this.onConnected(await this._connect())}onConnected(s){if(console.timeEnd(this.url),!!s)return this.oput||(this.oput=new We),this.read=this.oput.read.bind(this.oput),s.pipeTo(new WritableStream(this.underlyingSink),this.abortCtrl).catch(o=>{this.abortCtrl.signal.aborted||this.disconnect(o)})}disconnect(s){console.warn(`disconnect: ${this.url}`,s),this.options.reconnectCount&&this.reconnectAfter()}reconnectAfter(s=1e3,o=0){setTimeout(()=>{this.reconnect().catch(d=>{`${this.url}`,o<this.options.reconnectCount&&this.reconnectAfter(this.options.reconnectTimeout(o),o+1)})},s)}close(){var s;(s=this.abortCtrl)==null||s.abort(),this._close()}send(s){this.up.add(s.byteLength-("byteOffset"in s?s.byteOffset:0)),this._send(s)}}Ve([Be(me.CONNECTED)],he.prototype,"read",1);Ve([B([me.DISCONNECTED,N.INIT],me.CONNECTED)],he.prototype,"connect",1);Ve([B(me.DISCONNECTED,me.RECONNECTED)],he.prototype,"reconnect",1);Ve([B(me.CONNECTED,me.DISCONNECTED)],he.prototype,"disconnect",1);Ve([B([],N.INIT)],he.prototype,"close",1);class Et extends he{async _connect(){const s=new WebSocket(this.url);return this.ws=s,s.binaryType="arraybuffer",new Promise((o,d)=>{s.onerror=d,s.onopen=()=>{o(new ReadableStream({start:h=>{s.onclose=_=>h.error(_),s.onmessage=_=>h.enqueue(_.data)}}))}})}_close(){var s;(s=this.ws)==null||s.close(1e3,"close")}_send(s){var o;(o=this.ws)==null||o.send(s)}}class qi extends he{async _connect(){const s=await fetch(this.url,{...this.options.requestInit,signal:this.abortCtrl.signal});if(!s.body)throw new Error("no body");return s.body}}class Xi extends he{constructor(s){super(s.label),this.dc=s}async _connect(){return new ReadableStream({start:s=>{this.dc.onclose=()=>{s.close()},this.dc.onerror=o=>{s.error(o)},this.dc.onmessage=o=>{s.enqueue(o.data)}}})}_close(){this.dc.close()}_send(s){this.dc.send(s)}}class Yi extends ze.EventEmitter{constructor(s,o="recvonly"){super(),this.id=s,this.direction=o}get mediaStream(){return this._mediaStream}set mediaStream(s){this._mediaStream=s,s&&this.emit("change",s)}set audioTrack(s){if(this._audioTrack=s,this._mediaStream){const o=this._mediaStream.getAudioTracks()[0];o&&this._mediaStream.removeTrack(o)}s&&(this._mediaStream?this._mediaStream.addTrack(s):this._mediaStream=new MediaStream([s])),this._mediaStream&&this.emit("change",this._mediaStream)}get audioTrack(){var s;return this._audioTrack||((s=this._mediaStream)==null?void 0:s.getAudioTracks()[0])}set videoTrack(s){if(this._videoTrack=s,this._mediaStream){const o=this._mediaStream.getVideoTracks()[0];o&&this._mediaStream.removeTrack(o)}s&&(this._mediaStream?this._mediaStream.addTrack(s):this._mediaStream=new MediaStream([s])),this._mediaStream&&this.emit("change",this._mediaStream)}get videoTrack(){var s;return this._videoTrack||((s=this._mediaStream)==null?void 0:s.getVideoTracks()[0])}close(){this.emit("close")}}class Ki extends he{constructor(){super(...arguments),this.webrtc=new RTCPeerConnection(this.options.rtcConfig),this.streams=new Map,this.videoTransceiver=new Array,this.audioTransceiver=new Array}async _connect(){const s=await this.webrtc.createOffer();await this.webrtc.setLocalDescription(s);const d=await(await fetch(this.url,{method:"POST",body:s.sdp,...this.options.requestInit||{}})).text();return await this.webrtc.setRemoteDescription({type:"answer",sdp:d}),this.webrtc.ontrack=({track:h,streams:_,transceiver:g})=>{if(_.length){const D=this.streams.get(_[0].id);D&&D.direction==="recvonly"&&(D.mediaStream=_[0])}},new Promise((h,_)=>{this.webrtc.onconnectionstatechange=g=>{switch(this.webrtc.connectionState){case"disconnected":this.disconnect(g);break;case"connected":h();break;case"failed":_(g)}}})}addStream(s){return this.audioTransceiver.length?(s.audioTransceiver=this.audioTransceiver.pop(),s.audioTransceiver.direction=s.direction):s.audioTransceiver=this.webrtc.addTransceiver(s.audioTrack||"audio",{direction:s.direction}),this.videoTransceiver.length?(s.videoTransceiver=this.videoTransceiver.pop(),s.videoTransceiver.direction=s.direction):s.videoTransceiver=this.webrtc.addTransceiver(s.videoTrack||"video",{direction:s.direction}),this.streams.set(s.id,s),s}deleteStream(s){const o=this.streams.get(s);o&&(delete o.mediaStream,o.audioTransceiver.direction="inactive",o.videoTransceiver.direction="inactive",this.audioTransceiver.push(o.audioTransceiver),this.videoTransceiver.push(o.videoTransceiver),this.streams.delete(s))}_close(){var s;(s=this.webrtc)==null||s.close()}}var Ji=Object.defineProperty,Qi=Object.getOwnPropertyDescriptor,Ge=(v,s,o,d)=>{for(var h=d>1?void 0:d?Qi(s,o):s,_=v.length-1,g;_>=0;_--)(g=v[_])&&(h=(d?g(s,o,h):g(h))||h);return d&&h&&Ji(s,o,h),h};class qe extends N{constructor(s){super(),this.module={},this.width=0,this.height=0,this.createModule=s}initialize(){return new Promise(s=>{const o=this.module;o.print=d=>console.log(d),o.printErr=d=>console.log(`[JS] ERROR: ${d}`),o.onAbort=()=>console.log("[JS] FATAL: WASM ABORTED"),o.postRun=d=>{this.decoder=new this.module.VideoDecoder(this),s()},this.createModule(o)})}configure(s){this.config=s,this.decoder.setCodec(this.config.codec,this.config.description?"avcc":"annexb",this.config.description??"")}decode(s){this.decoder.decode(s.data,s.type=="key",s.timestamp)}flush(){}reset(){this.config=void 0,this.decoder&&this.decoder.clear()}close(){this.removeAllListeners(),this.decoder&&(this.decoder.clear(),this.decoder.delete())}videoInfo(s,o){this.width=s,this.height=o;let d={width:s,height:o};this.emit(le.VideoCodecInfo,d)}yuvData(s,o){if(!this.module)return;const d=this.width*this.height,h=d>>2;let _=this.module.HEAPU32[s>>2],g=this.module.HEAPU32[(s>>2)+1],D=this.module.HEAPU32[(s>>2)+2],S=this.module.HEAPU8.subarray(_,_+d),m=this.module.HEAPU8.subarray(g,g+h),y=this.module.HEAPU8.subarray(D,D+h);const P=new Uint8Array(d+h+h);P.set(S),P.set(m,d),P.set(y,d+h),this.emit(le.VideoFrame,new VideoFrame(P,{codedWidth:this.width,codedHeight:this.height,format:"I420",timestamp:o}))}errorInfo(s){let o={errMsg:s};this.emit(le.Error,o)}}Ge([B([N.INIT,"closed"],"initialized")],qe.prototype,"initialize",1);Ge([B("initialized","configured")],qe.prototype,"configure",1);Ge([Be("configured")],qe.prototype,"decode",1);Ge([B([],N.INIT)],qe.prototype,"reset",1);Ge([B([],"closed")],qe.prototype,"close",1);var Zi=Object.defineProperty,eo=Object.getOwnPropertyDescriptor,Xe=(v,s,o,d)=>{for(var h=d>1?void 0:d?eo(s,o):s,_=v.length-1,g;_>=0;_--)(g=v[_])&&(h=(d?g(s,o,h):g(h))||h);return d&&h&&Zi(s,o,h),h};class ke extends N{async initialize(){this.decoder=new VideoDecoder({output:s=>{this.emit(le.VideoFrame,s)},error:s=>{this.emit(le.Error,s),this.close()}})}configure(s){this.config=s,this.decoder.configure({...s,codec:s.codec=="hevc"?"hvc1.1.6.L0.12.34.56.78.9A.BC":"avc1.420028"})}decode(s){this.decoder.state==="configured"&&this.decoder.decode(new EncodedVideoChunk(s))}flush(){this.decoder.flush()}reset(){this.decoder.reset()}close(){this.decoder.close()}}Xe([B([N.INIT,"closed"],"initialized")],ke.prototype,"initialize",1);Xe([B("initialized","configured")],ke.prototype,"configure",1);Xe([Be("configured")],ke.prototype,"decode",1);Xe([B([],N.INIT)],ke.prototype,"reset",1);Xe([B([],"closed",{ignoreError:!0})],ke.prototype,"close",1);var ro=(()=>{var v=import.meta.url;return function(o){o=o||{};var o=typeof o<"u"?o:{},d,h;o.ready=new Promise(function(e,r){d=e,h=r});var _=Object.assign({},o),g="./this.program",D=typeof window=="object",S=typeof importScripts=="function",m=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",y="";function P(e){return o.locateFile?o.locateFile(e,y):y+e}var j,A,$,O,T,W;m?(S?y=require("path").dirname(y)+"/":y=__dirname+"/",W=()=>{T||(O=require("fs"),T=require("path"))},j=function(r,t){return W(),r=T.normalize(r),O.readFileSync(r,t?void 0:"utf8")},$=e=>{var r=j(e,!0);return r.buffer||(r=new Uint8Array(r)),r},A=(e,r,t)=>{W(),e=T.normalize(e),O.readFile(e,function(n,a){n?t(n):r(a.buffer)})},process.argv.length>1&&(g=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),process.on("uncaughtException",function(e){if(!(e instanceof bi))throw e}),process.on("unhandledRejection",function(e){throw e}),o.inspect=function(){return"[Emscripten Module object]"}):(D||S)&&(S?y=self.location.href:typeof document<"u"&&document.currentScript&&(y=document.currentScript.src),v&&(y=v),y.indexOf("blob:")!==0?y=y.substr(0,y.replace(/[?#].*/,"").lastIndexOf("/")+1):y="",j=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.send(null),r.responseText},S&&($=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),A=(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 Q=o.print||console.log.bind(console),U=o.printErr||console.warn.bind(console);Object.assign(o,_),_=null,o.arguments&&o.arguments,o.thisProgram&&(g=o.thisProgram),o.quit&&o.quit;var Qe=4,ee;o.wasmBinary&&(ee=o.wasmBinary),o.noExitRuntime,typeof WebAssembly!="object"&&we("no native wasm support detected");var Ce,ie=!1;function Oe(e,r){e||we(r)}var Re=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function Te(e,r,t){for(var n=r+t,a=r;e[a]&&!(a>=n);)++a;if(a-r>16&&e.buffer&&Re)return Re.decode(e.subarray(r,a));for(var u="";r<a;){var f=e[r++];if(!(f&128)){u+=String.fromCharCode(f);continue}var c=e[r++]&63;if((f&224)==192){u+=String.fromCharCode((f&31)<<6|c);continue}var l=e[r++]&63;if((f&240)==224?f=(f&15)<<12|c<<6|l:f=(f&7)<<18|c<<12|l<<6|e[r++]&63,f<65536)u+=String.fromCharCode(f);else{var p=f-65536;u+=String.fromCharCode(55296|p>>10,56320|p&1023)}}return u}function Hr(e,r){return e?Te(X,e,r):""}function vr(e,r,t,n){if(!(n>0))return 0;for(var a=t,u=t+n-1,f=0;f<e.length;++f){var c=e.charCodeAt(f);if(c>=55296&&c<=57343){var l=e.charCodeAt(++f);c=65536+((c&1023)<<10)|l&1023}if(c<=127){if(t>=u)break;r[t++]=c}else if(c<=2047){if(t+1>=u)break;r[t++]=192|c>>6,r[t++]=128|c&63}else if(c<=65535){if(t+2>=u)break;r[t++]=224|c>>12,r[t++]=128|c>>6&63,r[t++]=128|c&63}else{if(t+3>=u)break;r[t++]=240|c>>18,r[t++]=128|c>>12&63,r[t++]=128|c>>6&63,r[t++]=128|c&63}}return r[t]=0,t-a}function Tt(e,r,t){return vr(e,X,r,t)}function mr(e){for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n>=55296&&n<=57343&&(n=65536+((n&1023)<<10)|e.charCodeAt(++t)&1023),n<=127?++r:n<=2047?r+=2:n<=65535?r+=3:r+=4}return r}var zr=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0;function St(e,r){for(var t=e,n=t>>1,a=n+r/2;!(n>=a)&&Ze[n];)++n;if(t=n<<1,t-e>32&&zr)return zr.decode(X.subarray(e,t));for(var u="",f=0;!(f>=r/2);++f){var c=ge[e+f*2>>1];if(c==0)break;u+=String.fromCharCode(c)}return u}function Dt(e,r,t){if(t===void 0&&(t=2147483647),t<2)return 0;t-=2;for(var n=r,a=t<e.length*2?t/2:e.length,u=0;u<a;++u){var f=e.charCodeAt(u);ge[r>>1]=f,r+=2}return ge[r>>1]=0,r-n}function At(e){return e.length*2}function kt(e,r){for(var t=0,n="";!(t>=r/4);){var a=R[e+t*4>>2];if(a==0)break;if(++t,a>=65536){var u=a-65536;n+=String.fromCharCode(55296|u>>10,56320|u&1023)}else n+=String.fromCharCode(a)}return n}function Ft(e,r,t){if(t===void 0&&(t=2147483647),t<4)return 0;for(var n=r,a=n+t-4,u=0;u<e.length;++u){var f=e.charCodeAt(u);if(f>=55296&&f<=57343){var c=e.charCodeAt(++u);f=65536+((f&1023)<<10)|c&1023}if(R[r>>2]=f,r+=4,r+4>a)break}return R[r>>2]=0,r-n}function Ot(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}function Rt(e,r,t){for(var n=0;n<e.length;++n)Z[r++>>0]=e.charCodeAt(n);t||(Z[r>>0]=0)}var gr,Z,X,ge,Ze,R,L,Br,Wr;function $t(e){gr=e,o.HEAP8=Z=new Int8Array(e),o.HEAP16=ge=new Int16Array(e),o.HEAP32=R=new Int32Array(e),o.HEAPU8=X=new Uint8Array(e),o.HEAPU16=Ze=new Uint16Array(e),o.HEAPU32=L=new Uint32Array(e),o.HEAPF32=Br=new Float32Array(e),o.HEAPF64=Wr=new Float64Array(e)}o.INITIAL_MEMORY;var Vr,Gr=[],qr=[],Xr=[];function Ut(){if(o.preRun)for(typeof o.preRun=="function"&&(o.preRun=[o.preRun]);o.preRun.length;)Mt(o.preRun.shift());wr(Gr)}function Nt(){!o.noFSInit&&!i.init.initialized&&i.init(),i.ignorePermissions=!1,wr(qr)}function It(){if(o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;)xt(o.postRun.shift());wr(Xr)}function Mt(e){Gr.unshift(e)}function jt(e){qr.unshift(e)}function xt(e){Xr.unshift(e)}var ye=0,$e=null;function Co(e){return e}function yr(e){ye++,o.monitorRunDependencies&&o.monitorRunDependencies(ye)}function er(e){if(ye--,o.monitorRunDependencies&&o.monitorRunDependencies(ye),ye==0&&$e){var r=$e;$e=null,r()}}function we(e){o.onAbort&&o.onAbort(e),e="Aborted("+e+")",U(e),ie=!0,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw h(r),r}var Lt="data:application/octet-stream;base64,";function Yr(e){return e.startsWith(Lt)}function Kr(e){return e.startsWith("file://")}var K;o.locateFile?(K="audiodec.wasm",Yr(K)||(K=P(K))):K=new URL("/plugin/media/assets/audiodec-28b192dd.wasm",self.location).toString();function Jr(e){try{if(e==K&&ee)return new Uint8Array(ee);if($)return $(e);throw"both async and sync fetching of the wasm failed"}catch(r){we(r)}}function Ht(){if(!ee&&(D||S)){if(typeof fetch=="function"&&!Kr(K))return fetch(K,{credentials:"same-origin"}).then(function(e){if(!e.ok)throw"failed to load wasm binary file at '"+K+"'";return e.arrayBuffer()}).catch(function(){return Jr(K)});if(A)return new Promise(function(e,r){A(K,function(t){e(new Uint8Array(t))},r)})}return Promise.resolve().then(function(){return Jr(K)})}function zt(){var e={a:Ei};function r(f,c){var l=f.exports;o.asm=l,Ce=o.asm.G,$t(Ce.buffer),Vr=o.asm.J,jt(o.asm.H),er()}yr();function t(f){r(f.instance)}function n(f){return Ht().then(function(c){return WebAssembly.instantiate(c,e)}).then(function(c){return c}).then(f,function(c){U("failed to asynchronously prepare wasm: "+c),we(c)})}function a(){return!ee&&typeof WebAssembly.instantiateStreaming=="function"&&!Yr(K)&&!Kr(K)&&!m&&typeof fetch=="function"?fetch(K,{credentials:"same-origin"}).then(function(f){var c=WebAssembly.instantiateStreaming(f,e);return c.then(t,function(l){return U("wasm streaming compile failed: "+l),U("falling back to ArrayBuffer instantiation"),n(t)})}):n(t)}if(o.instantiateWasm)try{var u=o.instantiateWasm(e,r);return u}catch(f){return U("Module.instantiateWasm callback failed with error: "+f),!1}return a().catch(h),{}}var V,oe;function wr(e){for(;e.length>0;){var r=e.shift();if(typeof r=="function"){r(o);continue}var t=r.func;typeof t=="number"?r.arg===void 0?tr(t)():tr(t)(r.arg):t(r.arg===void 0?null:r.arg)}}var rr=[];function tr(e){var r=rr[e];return r||(e>=rr.length&&(rr.length=e+1),rr[e]=r=Vr.get(e)),r}function Bt(e){return lr(e+24)+24}function Wt(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(r){L[this.ptr+4>>2]=r},this.get_type=function(){return L[this.ptr+4>>2]},this.set_destructor=function(r){L[this.ptr+8>>2]=r},this.get_destructor=function(){return L[this.ptr+8>>2]},this.set_refcount=function(r){R[this.ptr>>2]=r},this.set_caught=function(r){r=r?1:0,Z[this.ptr+12>>0]=r},this.get_caught=function(){return Z[this.ptr+12>>0]!=0},this.set_rethrown=function(r){r=r?1:0,Z[this.ptr+13>>0]=r},this.get_rethrown=function(){return Z[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_refcount(0),this.set_caught(!1),this.set_rethrown(!1)},this.add_ref=function(){var r=R[this.ptr>>2];R[this.ptr>>2]=r+1},this.release_ref=function(){var r=R[this.ptr>>2];return R[this.ptr>>2]=r-1,r===1},this.set_adjusted_ptr=function(r){L[this.ptr+16>>2]=r},this.get_adjusted_ptr=function(){return L[this.ptr+16>>2]},this.get_exception_ptr=function(){var r=gt(this.get_type());if(r)return L[this.excPtr>>2];var t=this.get_adjusted_ptr();return t!==0?t:this.excPtr}}function Vt(e,r,t){var n=new Wt(e);throw n.init(r,t),e}function Gt(e){return R[pt()>>2]=e,e}var I={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 a=e[n];a==="."?e.splice(n,1):a===".."?(e.splice(n,1),t++):t&&(e.splice(n,1),t--)}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=I.isAbs(e),t=e.substr(-1)==="/";return e=I.normalizeArray(e.split("/").filter(n=>!!n),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=I.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=I.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,0);return I.normalize(e.join("/"))},join2:(e,r)=>I.normalize(e+"/"+r)};function qt(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var e=new Uint8Array(1);return function(){return crypto.getRandomValues(e),e[0]}}else if(m)try{var r=require("crypto");return function(){return r.randomBytes(1)[0]}}catch{}return function(){we("randomDevice")}}var se={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=I.isAbs(n)}return e=I.normalizeArray(e.split("/").filter(a=>!!a),!r).join("/"),(r?"/":"")+e||"."},relative:(e,r)=>{e=se.resolve(e).substr(1),r=se.resolve(r).substr(1);function t(p){for(var E=0;E<p.length&&p[E]==="";E++);for(var b=p.length-1;b>=0&&p[b]==="";b--);return E>b?[]:p.slice(E,b-E+1)}for(var n=t(e.split("/")),a=t(r.split("/")),u=Math.min(n.length,a.length),f=u,c=0;c<u;c++)if(n[c]!==a[c]){f=c;break}for(var l=[],c=f;c<n.length;c++)l.push("..");return l=l.concat(a.slice(f)),l.join("/")}},_e={ttys:[],init:function(){},shutdown:function(){},register:function(e,r){_e.ttys[e]={input:[],output:[],ops:r},i.registerDevice(e,_e.stream_ops)},stream_ops:{open:function(e){var r=_e.ttys[e.node.rdev];if(!r)throw new i.ErrnoError(43);e.tty=r,e.seekable=!1},close:function(e){e.tty.ops.flush(e.tty)},flush:function(e){e.tty.ops.flush(e.tty)},read:function(e,r,t,n,a){if(!e.tty||!e.tty.ops.get_char)throw new i.ErrnoError(60);for(var u=0,f=0;f<n;f++){var c;try{c=e.tty.ops.get_char(e.tty)}catch{throw new i.ErrnoError(29)}if(c===void 0&&u===0)throw new i.ErrnoError(6);if(c==null)break;u++,r[t+f]=c}return u&&(e.node.timestamp=Date.now()),u},write:function(e,r,t,n,a){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){if(!e.input.length){var r=null;if(m){var t=256,n=Buffer.alloc(t),a=0;try{a=O.readSync(process.stdin.fd,n,0,t,-1)}catch(u){if(u.toString().includes("EOF"))a=0;else throw u}a>0?r=n.slice(0,a).toString("utf-8"):r=null}else typeof window<"u"&&typeof window.prompt=="function"?(r=window.prompt("Input: "),r!==null&&(r+=`
  2. `)):typeof readline=="function"&&(r=readline(),r!==null&&(r+=`
  3. `));if(!r)return null;e.input=Rr(r,!0)}return e.input.shift()},put_char:function(e,r){r===null||r===10?(Q(Te(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},flush:function(e){e.output&&e.output.length>0&&(Q(Te(e.output,0)),e.output=[])}},default_tty1_ops:{put_char:function(e,r){r===null||r===10?(U(Te(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},flush:function(e){e.output&&e.output.length>0&&(U(Te(e.output,0)),e.output=[])}}};function Xt(e,r){X.fill(0,e,e+r)}function Yt(e,r){return Math.ceil(e/r)*r}function Qr(e){e=Yt(e,65536);var r=mt(65536,e);return r?(Xt(r,e),r):0}var F={ops_table:null,mount:function(e){return F.createNode(null,"/",16895,0)},createNode:function(e,r,t,n){if(i.isBlkdev(t)||i.isFIFO(t))throw new i.ErrnoError(63);F.ops_table||(F.ops_table={dir:{node:{getattr:F.node_ops.getattr,setattr:F.node_ops.setattr,lookup:F.node_ops.lookup,mknod:F.node_ops.mknod,rename:F.node_ops.rename,unlink:F.node_ops.unlink,rmdir:F.node_ops.rmdir,readdir:F.node_ops.readdir,symlink:F.node_ops.symlink},stream:{llseek:F.stream_ops.llseek}},file:{node:{getattr:F.node_ops.getattr,setattr:F.node_ops.setattr},stream:{llseek:F.stream_ops.llseek,read:F.stream_ops.read,write:F.stream_ops.write,allocate:F.stream_ops.allocate,mmap:F.stream_ops.mmap,msync:F.stream_ops.msync}},link:{node:{getattr:F.node_ops.getattr,setattr:F.node_ops.setattr,readlink:F.node_ops.readlink},stream:{}},chrdev:{node:{getattr:F.node_ops.getattr,setattr:F.node_ops.setattr},stream:i.chrdev_stream_ops}});var a=i.createNode(e,r,t,n);return i.isDir(a.mode)?(a.node_ops=F.ops_table.dir.node,a.stream_ops=F.ops_table.dir.stream,a.contents={}):i.isFile(a.mode)?(a.node_ops=F.ops_table.file.node,a.stream_ops=F.ops_table.file.stream,a.usedBytes=0,a.contents=null):i.isLink(a.mode)?(a.node_ops=F.ops_table.link.node,a.stream_ops=F.ops_table.link.stream):i.isChrdev(a.mode)&&(a.node_ops=F.ops_table.chrdev.node,a.stream_ops=F.ops_table.chrdev.stream),a.timestamp=Date.now(),e&&(e.contents[r]=a,e.timestamp=a.timestamp),a},getFileDataAsTypedArray:function(e){return e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0)},expandFileStorage:function(e,r){var t=e.contents?e.contents.length:0;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 a=e.contents;e.contents=new Uint8Array(r),e.usedBytes>0&&e.contents.set(a.subarray(0,e.usedBytes),0)}},resizeFileStorage:function(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:function(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:function(e,r){r.mode!==void 0&&(e.mode=r.mode),r.timestamp!==void 0&&(e.timestamp=r.timestamp),r.size!==void 0&&F.resizeFileStorage(e,r.size)},lookup:function(e,r){throw i.genericErrors[44]},mknod:function(e,r,t,n){return F.createNode(e,r,t,n)},rename:function(e,r,t){if(i.isDir(e.mode)){var n;try{n=i.lookupNode(r,t)}catch{}if(n)for(var a 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:function(e,r){delete e.contents[r],e.timestamp=Date.now()},rmdir:function(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:function(e){var r=[".",".."];for(var t in e.contents)e.contents.hasOwnProperty(t)&&r.push(t);return r},symlink:function(e,r,t){var n=F.createNode(e,r,41471,0);return n.link=t,n},readlink:function(e){if(!i.isLink(e.mode))throw new i.ErrnoError(28);return e.link}},stream_ops:{read:function(e,r,t,n,a){var u=e.node.contents;if(a>=e.node.usedBytes)return 0;var f=Math.min(e.node.usedBytes-a,n);if(f>8&&u.subarray)r.set(u.subarray(a,a+f),t);else for(var c=0;c<f;c++)r[t+c]=u[a+c];return f},write:function(e,r,t,n,a,u){if(!n)return 0;var f=e.node;if(f.timestamp=Date.now(),r.subarray&&(!f.contents||f.contents.subarray)){if(u)return f.contents=r.subarray(t,t+n),f.usedBytes=n,n;if(f.usedBytes===0&&a===0)return f.contents=r.slice(t,t+n),f.usedBytes=n,n;if(a+n<=f.usedBytes)return f.contents.set(r.subarray(t,t+n),a),n}if(F.expandFileStorage(f,a+n),f.contents.subarray&&r.subarray)f.contents.set(r.subarray(t,t+n),a);else for(var c=0;c<n;c++)f.contents[a+c]=r[t+c];return f.usedBytes=Math.max(f.usedBytes,a+n),n},llseek:function(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:function(e,r,t){F.expandFileStorage(e.node,r+t),e.node.usedBytes=Math.max(e.node.usedBytes,r+t)},mmap:function(e,r,t,n,a){if(!i.isFile(e.node.mode))throw new i.ErrnoError(43);var u,f,c=e.node.contents;if(!(a&2)&&c.buffer===gr)f=!1,u=c.byteOffset;else{if((t>0||t+r<c.length)&&(c.subarray?c=c.subarray(t,t+r):c=Array.prototype.slice.call(c,t,t+r)),f=!0,u=Qr(r),!u)throw new i.ErrnoError(48);Z.set(c,u)}return{ptr:u,allocated:f}},msync:function(e,r,t,n,a){if(!i.isFile(e.node.mode))throw new i.ErrnoError(43);return a&2||F.stream_ops.write(e,r,0,n,t,!1),0}}};function Kt(e,r,t,n){var a=n?"":"al "+e;A(e,function(u){Oe(u,'Loading data file "'+e+'" failed (no arrayBuffer).'),r(new Uint8Array(u)),a&&er()},function(u){if(t)t();else throw'Loading data file "'+e+'" failed.'}),a&&yr()}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=se.resolve(i.cwd(),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=I.normalizeArray(e.split("/").filter(b=>!!b),!1),a=i.root,u="/",f=0;f<n.length;f++){var c=f===n.length-1;if(c&&r.parent)break;if(a=i.lookupNode(a,n[f]),u=I.join2(u,n[f]),i.isMountpoint(a)&&(!c||c&&r.follow_mount)&&(a=a.mounted.root),!c||r.follow)for(var l=0;i.isLink(a.mode);){var p=i.readlink(u);u=se.resolve(I.dirname(u),p);var E=i.lookupPath(u,{recurse_count:r.recurse_count+1});if(a=E.node,l++>40)throw new i.ErrnoError(32)}}return{path:u,node:a}},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),a=i.nameTable[n];a;a=a.name_next){var u=a.name;if(a.parent.id===e.id&&u===r)return a}return i.lookup(e,r)},createNode:(e,r,t,n)=>{var a=new i.FSNode(e,r,t,n);return i.hashAddNode(a),a},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,flagModes:{r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},modeStringToFlags:e=>{var r=i.flagModes[e];if(typeof r>"u")throw new Error("Unknown file open mode: "+e);return r},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 a=i.nodePermissions(e,"wx");if(a)return a;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:(e=0,r=i.MAX_OPEN_FDS)=>{for(var t=e;t<=r;t++)if(!i.streams[t])return t;throw new i.ErrnoError(33)},getStream:e=>i.streams[e],createStream:(e,r,t)=>{i.FSStream||(i.FSStream=function(){this.shared={}},i.FSStream.prototype={},Object.defineProperties(i.FSStream.prototype,{object:{get:function(){return this.node},set:function(a){this.node=a}},isRead:{get:function(){return(this.flags&2097155)!==1}},isWrite:{get:function(){return(this.flags&2097155)!==0}},isAppend:{get:function(){return this.flags&1024}},flags:{get:function(){return this.shared.flags},set:function(a){this.shared.flags=a}},position:{get:function(){return this.shared.position},set:function(a){this.shared.position=a}}})),e=Object.assign(new i.FSStream,e);var n=i.nextfd(r,t);return e.fd=n,i.streams[n]=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&&U("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 a(f){return i.syncFSRequests--,r(f)}function u(f){if(f)return u.errored?void 0:(u.errored=!0,a(f));++n>=t.length&&a(null)}t.forEach(f=>{if(!f.type.syncfs)return u(null);f.type.syncfs(f,e,u)})},mount:(e,r,t)=>{var n=t==="/",a=!t,u;if(n&&i.root)throw new i.ErrnoError(10);if(!n&&!a){var f=i.lookupPath(t,{follow_mount:!1});if(t=f.path,u=f.node,i.isMountpoint(u))throw new i.ErrnoError(10);if(!i.isDir(u.mode))throw new i.ErrnoError(54)}var c={type:e,opts:r,mountpoint:t,mounts:[]},l=e.mount(c);return l.mount=c,c.root=l,n?i.root=l:u&&(u.mounted=c,u.mount&&u.mount.mounts.push(c)),l},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,a=i.getMounts(n);Object.keys(i.nameTable).forEach(f=>{for(var c=i.nameTable[f];c;){var l=c.name_next;a.includes(c.mount)&&i.destroyNode(c),c=l}}),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}),a=n.node,u=I.basename(e);if(!u||u==="."||u==="..")throw new i.ErrnoError(28);var f=i.mayCreate(a,u);if(f)throw new i.ErrnoError(f);if(!a.node_ops.mknod)throw new i.ErrnoError(63);return a.node_ops.mknod(a,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="",a=0;a<t.length;++a)if(t[a]){n+="/"+t[a];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(!se.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 a=I.basename(r),u=i.mayCreate(n,a);if(u)throw new i.ErrnoError(u);if(!n.node_ops.symlink)throw new i.ErrnoError(63);return n.node_ops.symlink(n,a,e)},rename:(e,r)=>{var t=I.dirname(e),n=I.dirname(r),a=I.basename(e),u=I.basename(r),f,c,l;if(f=i.lookupPath(e,{parent:!0}),c=f.node,f=i.lookupPath(r,{parent:!0}),l=f.node,!c||!l)throw new i.ErrnoError(44);if(c.mount!==l.mount)throw new i.ErrnoError(75);var p=i.lookupNode(c,a),E=se.relative(e,n);if(E.charAt(0)!==".")throw new i.ErrnoError(28);if(E=se.relative(r,t),E.charAt(0)!==".")throw new i.ErrnoError(55);var b;try{b=i.lookupNode(l,u)}catch{}if(p!==b){var w=i.isDir(p.mode),C=i.mayDelete(c,a,w);if(C)throw new i.ErrnoError(C);if(C=b?i.mayDelete(l,u,w):i.mayCreate(l,u),C)throw new i.ErrnoError(C);if(!c.node_ops.rename)throw new i.ErrnoError(63);if(i.isMountpoint(p)||b&&i.isMountpoint(b))throw new i.ErrnoError(10);if(l!==c&&(C=i.nodePermissions(c,"w"),C))throw new i.ErrnoError(C);i.hashRemoveNode(p);try{c.node_ops.rename(p,l,u)}catch(k){throw k}finally{i.hashAddNode(p)}}},rmdir:e=>{var r=i.lookupPath(e,{parent:!0}),t=r.node,n=I.basename(e),a=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(a))throw new i.ErrnoError(10);t.node_ops.rmdir(t,n),i.destroyNode(a)},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=I.basename(e),a=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(a))throw new i.ErrnoError(10);t.node_ops.unlink(t,n),i.destroyNode(a)},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 se.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 a=i.lookupPath(e,{follow:!t});n=a.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.getStream(e);if(!t)throw new i.ErrnoError(8);i.chmod(t.node,r)},chown:(e,r,t,n)=>{var a;if(typeof e=="string"){var u=i.lookupPath(e,{follow:!n});a=u.node}else a=e;if(!a.node_ops.setattr)throw new i.ErrnoError(63);a.node_ops.setattr(a,{timestamp:Date.now()})},lchown:(e,r,t)=>{i.chown(e,r,t,!0)},fchown:(e,r,t)=>{var n=i.getStream(e);if(!n)throw new i.ErrnoError(8);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 a=i.nodePermissions(t,"w");if(a)throw new i.ErrnoError(a);t.node_ops.setattr(t,{size:r,timestamp:Date.now()})},ftruncate:(e,r)=>{var t=i.getStream(e);if(!t)throw new i.ErrnoError(8);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}),a=n.node;a.node_ops.setattr(a,{timestamp:Math.max(r,t)})},open:(e,r,t)=>{if(e==="")throw new i.ErrnoError(44);r=typeof r=="string"?i.modeStringToFlags(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=I.normalize(e);try{var a=i.lookupPath(e,{follow:!(r&131072)});n=a.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 f=i.mayOpen(n,r);if(f)throw new i.ErrnoError(f)}r&512&&!u&&i.truncate(n,0),r&=-131713;var c=i.createStream({node:n,path:i.getPath(n),flags:r,seekable:!0,position:0,stream_ops:n.stream_ops,ungotten:[],error:!1});return c.stream_ops.open&&c.stream_ops.open(c),o.logReadFiles&&!(r&1)&&(i.readFiles||(i.readFiles={}),e in i.readFiles||(i.readFiles[e]=1)),c},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,a)=>{if(n<0||a<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 a<"u";if(!u)a=e.position;else if(!e.seekable)throw new i.ErrnoError(70);var f=e.stream_ops.read(e,r,t,n,a);return u||(e.position+=f),f},write:(e,r,t,n,a,u)=>{if(n<0||a<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 f=typeof a<"u";if(!f)a=e.position;else if(!e.seekable)throw new i.ErrnoError(70);var c=e.stream_ops.write(e,r,t,n,a,u);return f||(e.position+=c),c},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,a)=>{if(n&2&&!(a&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,a)},msync:(e,r,t,n,a)=>!e||!e.stream_ops.msync?0:e.stream_ops.msync(e,r,t,n,a),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),a=i.stat(e),u=a.size,f=new Uint8Array(u);return i.read(n,f,0,u,0),r.encoding==="utf8"?t=Te(f,0):r.encoding==="binary"&&(t=f),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 a=new Uint8Array(mr(r)+1),u=vr(r,a,0,a.length);i.write(n,a,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:(r,t,n,a,u)=>a}),i.mkdev("/dev/null",i.makedev(1,3)),_e.register(i.makedev(5,0),_e.default_tty_ops),_e.register(i.makedev(6,0),_e.default_tty1_ops),i.mkdev("/dev/tty",i.makedev(5,0)),i.mkdev("/dev/tty1",i.makedev(6,0));var e=qt();i.createDevice("/dev","random",e),i.createDevice("/dev","urandom",e),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 a=+n,u=i.getStream(a);if(!u)throw new i.ErrnoError(8);var f={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>u.path}};return f.parent=f,f}},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.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(F,{},"/"),i.createDefaultDirectories(),i.createDefaultDevices(),i.createSpecialDirectories(),i.filesystems={MEMFS:F}},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)}},getMode:(e,r)=>{var t=0;return e&&(t|=365),r&&(t|=146),t},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=I.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(a){n.error=a.errno}return n},createPath:(e,r,t,n)=>{e=typeof e=="string"?e:i.getPath(e);for(var a=r.split("/").reverse();a.length;){var u=a.pop();if(u){var f=I.join2(e,u);try{i.mkdir(f)}catch{}e=f}}return f},createFile:(e,r,t,n,a)=>{var u=I.join2(typeof e=="string"?e:i.getPath(e),r),f=i.getMode(n,a);return i.create(u,f)},createDataFile:(e,r,t,n,a,u)=>{var f=r;e&&(e=typeof e=="string"?e:i.getPath(e),f=r?I.join2(e,r):e);var c=i.getMode(n,a),l=i.create(f,c);if(t){if(typeof t=="string"){for(var p=new Array(t.length),E=0,b=t.length;E<b;++E)p[E]=t.charCodeAt(E);t=p}i.chmod(l,c|146);var w=i.open(l,577);i.write(w,t,0,t.length,0,u),i.close(w),i.chmod(l,c)}return l},createDevice:(e,r,t,n)=>{var a=I.join2(typeof e=="string"?e:i.getPath(e),r),u=i.getMode(!!t,!!n);i.createDevice.major||(i.createDevice.major=64);var f=i.makedev(i.createDevice.major++,0);return i.registerDevice(f,{open:c=>{c.seekable=!1},close:c=>{n&&n.buffer&&n.buffer.length&&n(10)},read:(c,l,p,E,b)=>{for(var w=0,C=0;C<E;C++){var k;try{k=t()}catch{throw new i.ErrnoError(29)}if(k===void 0&&w===0)throw new i.ErrnoError(6);if(k==null)break;w++,l[p+C]=k}return w&&(c.node.timestamp=Date.now()),w},write:(c,l,p,E,b)=>{for(var w=0;w<E;w++)try{n(l[p+w])}catch{throw new i.ErrnoError(29)}return E&&(c.node.timestamp=Date.now()),w}}),i.mkdev(a,u,f)},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(j)try{e.contents=Rr(j(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,a)=>{function u(){this.lengthKnown=!1,this.chunks=[]}if(u.prototype.get=function(C){if(!(C>this.length-1||C<0)){var k=C%this.chunkSize,x=C/this.chunkSize|0;return this.getter(x)[k]}},u.prototype.setDataGetter=function(C){this.getter=C},u.prototype.cacheLength=function(){var C=new XMLHttpRequest;if(C.open("HEAD",t,!1),C.send(null),!(C.status>=200&&C.status<300||C.status===304))throw new Error("Couldn't load "+t+". Status: "+C.status);var k=Number(C.getResponseHeader("Content-length")),x,H=(x=C.getResponseHeader("Accept-Ranges"))&&x==="bytes",G=(x=C.getResponseHeader("Content-Encoding"))&&x==="gzip",J=1024*1024;H||(J=k);var q=(te,fe)=>{if(te>fe)throw new Error("invalid range ("+te+", "+fe+") or no bytes requested!");if(fe>k-1)throw new Error("only "+k+" bytes available! programmer error!");var z=new XMLHttpRequest;if(z.open("GET",t,!1),k!==J&&z.setRequestHeader("Range","bytes="+te+"-"+fe),z.responseType="arraybuffer",z.overrideMimeType&&z.overrideMimeType("text/plain; charset=x-user-defined"),z.send(null),!(z.status>=200&&z.status<300||z.status===304))throw new Error("Couldn't load "+t+". Status: "+z.status);return z.response!==void 0?new Uint8Array(z.response||[]):Rr(z.responseText||"",!0)},be=this;be.setDataGetter(te=>{var fe=te*J,z=(te+1)*J-1;if(z=Math.min(z,k-1),typeof be.chunks[te]>"u"&&(be.chunks[te]=q(fe,z)),typeof be.chunks[te]>"u")throw new Error("doXHR failed!");return be.chunks[te]}),(G||!k)&&(J=k=1,k=this.getter(0).length,J=k,Q("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=k,this._chunkSize=J,this.lengthKnown=!0},typeof XMLHttpRequest<"u"){if(!S)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var f=new u;Object.defineProperties(f,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var c={isDevice:!1,contents:f}}else var c={isDevice:!1,url:t};var l=i.createFile(e,r,c,n,a);c.contents?l.contents=c.contents:c.url&&(l.contents=null,l.url=c.url),Object.defineProperties(l,{usedBytes:{get:function(){return this.contents.length}}});var p={},E=Object.keys(l.stream_ops);E.forEach(w=>{var C=l.stream_ops[w];p[w]=function(){return i.forceLoadFile(l),C.apply(null,arguments)}});function b(w,C,k,x,H){var G=w.node.contents;if(H>=G.length)return 0;var J=Math.min(G.length-H,x);if(G.slice)for(var q=0;q<J;q++)C[k+q]=G[H+q];else for(var q=0;q<J;q++)C[k+q]=G.get(H+q);return J}return p.read=(w,C,k,x,H)=>(i.forceLoadFile(l),b(w,C,k,x,H)),p.mmap=(w,C,k,x,H)=>{i.forceLoadFile(l);var G=Qr(C);if(!G)throw new i.ErrnoError(48);return b(w,Z,G,C,k),{ptr:G,allocated:!0}},l.stream_ops=p,l},createPreloadedFile:(e,r,t,n,a,u,f,c,l,p)=>{var E=r?se.resolve(I.join2(e,r)):e;function b(w){function C(k){p&&p(),c||i.createDataFile(e,r,k,n,a,l),u&&u(),er()}Browser.handledByPreloadPlugin(w,E,C,()=>{f&&f(),er()})||C(w)}yr(),typeof t=="string"?Kt(t,w=>b(w),f):b(t)},indexedDB:()=>window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB,DB_NAME:()=>"EM_FS_"+window.location.pathname,DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:(e,r,t)=>{r=r||(()=>{}),t=t||(()=>{});var n=i.indexedDB();try{var a=n.open(i.DB_NAME(),i.DB_VERSION)}catch(u){return t(u)}a.onupgradeneeded=()=>{Q("creating db");var u=a.result;u.createObjectStore(i.DB_STORE_NAME)},a.onsuccess=()=>{var u=a.result,f=u.transaction([i.DB_STORE_NAME],"readwrite"),c=f.objectStore(i.DB_STORE_NAME),l=0,p=0,E=e.length;function b(){p==0?r():t()}e.forEach(w=>{var C=c.put(i.analyzePath(w).object.contents,w);C.onsuccess=()=>{l++,l+p==E&&b()},C.onerror=()=>{p++,l+p==E&&b()}}),f.onerror=t},a.onerror=t},loadFilesFromDB:(e,r,t)=>{r=r||(()=>{}),t=t||(()=>{});var n=i.indexedDB();try{var a=n.open(i.DB_NAME(),i.DB_VERSION)}catch(u){return t(u)}a.onupgradeneeded=t,a.onsuccess=()=>{var u=a.result;try{var f=u.transaction([i.DB_STORE_NAME],"readonly")}catch(w){t(w);return}var c=f.objectStore(i.DB_STORE_NAME),l=0,p=0,E=e.length;function b(){p==0?r():t()}e.forEach(w=>{var C=c.get(w);C.onsuccess=()=>{i.analyzePath(w).exists&&i.unlink(w),i.createDataFile(I.dirname(w),I.basename(w),C.result,!0,!0,!0),l++,l+p==E&&b()},C.onerror=()=>{p++,l+p==E&&b()}}),f.onerror=t},a.onerror=t}},Y={DEFAULT_POLLMASK:5,calculateAt:function(e,r,t){if(I.isAbs(r))return r;var n;if(e===-100)n=i.cwd();else{var a=i.getStream(e);if(!a)throw new i.ErrnoError(8);n=a.path}if(r.length==0){if(!t)throw new i.ErrnoError(44);return n}return I.join2(n,r)},doStat:function(e,r,t){try{var n=e(r)}catch(a){if(a&&a.node&&I.normalize(r)!==I.normalize(i.getPath(a.node)))return-54;throw a}return R[t>>2]=n.dev,R[t+4>>2]=0,R[t+8>>2]=n.ino,R[t+12>>2]=n.mode,R[t+16>>2]=n.nlink,R[t+20>>2]=n.uid,R[t+24>>2]=n.gid,R[t+28>>2]=n.rdev,R[t+32>>2]=0,oe=[n.size>>>0,(V=n.size,+Math.abs(V)>=1?V>0?(Math.min(+Math.floor(V/4294967296),4294967295)|0)>>>0:~~+Math.ceil((V-+(~~V>>>0))/4294967296)>>>0:0)],R[t+40>>2]=oe[0],R[t+44>>2]=oe[1],R[t+48>>2]=4096,R[t+52>>2]=n.blocks,R[t+56>>2]=n.atime.getTime()/1e3|0,R[t+60>>2]=0,R[t+64>>2]=n.mtime.getTime()/1e3|0,R[t+68>>2]=0,R[t+72>>2]=n.ctime.getTime()/1e3|0,R[t+76>>2]=0,oe=[n.ino>>>0,(V=n.ino,+Math.abs(V)>=1?V>0?(Math.min(+Math.floor(V/4294967296),4294967295)|0)>>>0:~~+Math.ceil((V-+(~~V>>>0))/4294967296)>>>0:0)],R[t+80>>2]=oe[0],R[t+84>>2]=oe[1],0},doMsync:function(e,r,t,n,a){var u=X.slice(e,e+t);i.msync(r,u,a,t,n)},varargs:void 0,get:function(){Y.varargs+=4;var e=R[Y.varargs-4>>2];return e},getStr:function(e){var r=Hr(e);return r},getStreamFromFD:function(e){var r=i.getStream(e);if(!r)throw new i.ErrnoError(8);return r}};function Jt(e,r,t){Y.varargs=t;try{var n=Y.getStreamFromFD(e);switch(r){case 0:{var a=Y.get();if(a<0)return-28;var u;return u=i.createStream(n,a),u.fd}case 1:case 2:return 0;case 3:return n.flags;case 4:{var a=Y.get();return n.flags|=a,0}case 5:{var a=Y.get(),f=0;return ge[a+f>>1]=2,0}case 6:case 7:return 0;case 16:case 8:return-28;case 9:return Gt(28),-1;default:return-28}}catch(c){if(typeof i>"u"||!(c instanceof i.ErrnoError))throw c;return-c.errno}}function Qt(e,r,t,n){Y.varargs=n;try{r=Y.getStr(r),r=Y.calculateAt(e,r);var a=n?Y.get():0;return i.open(r,t,a).fd}catch(u){if(typeof i>"u"||!(u instanceof i.ErrnoError))throw u;return-u.errno}}function Zt(e,r,t,n,a){}function _r(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 en(){for(var e=new Array(256),r=0;r<256;++r)e[r]=String.fromCharCode(r);Zr=e}var Zr=void 0;function re(e){for(var r="",t=e;X[t];)r+=Zr[X[t++]];return r}var Se={},Ee={},nr={},rn=48,tn=57;function ir(e){if(e===void 0)return"_unknown";e=e.replace(/[^a-zA-Z0-9_]/g,"$");var r=e.charCodeAt(0);return r>=rn&&r<=tn?"_"+e:e}function Er(e,r){return e=ir(e),new Function("body","return function "+e+`() {
  4. "use strict"; return body.apply(this, arguments);
  5. };
  6. `)(r)}function br(e,r){var t=Er(r,function(n){this.name=r,this.message=n;var a=new Error(n).stack;a!==void 0&&(this.stack=this.toString()+`
  7. `+a.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 De=void 0;function M(e){throw new De(e)}var et=void 0;function or(e){throw new et(e)}function Ue(e,r,t){e.forEach(function(c){nr[c]=r});function n(c){var l=t(c);l.length!==e.length&&or("Mismatched type converter count");for(var p=0;p<e.length;++p)ae(e[p],l[p])}var a=new Array(r.length),u=[],f=0;r.forEach((c,l)=>{Ee.hasOwnProperty(c)?a[l]=Ee[c]:(u.push(c),Se.hasOwnProperty(c)||(Se[c]=[]),Se[c].push(()=>{a[l]=Ee[c],++f,f===u.length&&n(a)}))}),u.length===0&&n(a)}function ae(e,r,t={}){if(!("argPackAdvance"in r))throw new TypeError("registerType registeredInstance requires argPackAdvance");var n=r.name;if(e||M('type "'+n+'" must have a positive integer typeid pointer'),Ee.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;M("Cannot register type '"+n+"' twice")}if(Ee[e]=r,delete nr[e],Se.hasOwnProperty(e)){var a=Se[e];delete Se[e],a.forEach(u=>u())}}function nn(e,r,t,n,a){var u=_r(t);r=re(r),ae(e,{name:r,fromWireType:function(f){return!!f},toWireType:function(f,c){return c?n:a},argPackAdvance:8,readValueFromPointer:function(f){var c;if(t===1)c=Z;else if(t===2)c=ge;else if(t===4)c=R;else throw new TypeError("Unknown boolean type size: "+r);return this.fromWireType(c[f>>u])},destructorFunction:null})}function on(e){if(!(this instanceof pe)||!(e instanceof pe))return!1;for(var r=this.$$.ptrType.registeredClass,t=this.$$.ptr,n=e.$$.ptrType.registeredClass,a=e.$$.ptr;r.baseClass;)t=r.upcast(t),r=r.baseClass;for(;n.baseClass;)a=n.upcast(a),n=n.baseClass;return r===n&&t===a}function sn(e){return{count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}}function Pr(e){function r(t){return t.$$.ptrType.registeredClass.name}M(r(e)+" instance already deleted")}var Cr=!1;function rt(e){}function an(e){e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)}function tt(e){e.count.value-=1;var r=e.count.value===0;r&&an(e)}function nt(e,r,t){if(r===t)return e;if(t.baseClass===void 0)return null;var n=nt(e,r,t.baseClass);return n===null?null:t.downcast(n)}var it={};function un(){return Object.keys(Me).length}function cn(){var e=[];for(var r in Me)Me.hasOwnProperty(r)&&e.push(Me[r]);return e}var Ne=[];function Tr(){for(;Ne.length;){var e=Ne.pop();e.$$.deleteScheduled=!1,e.delete()}}var Ie=void 0;function fn(e){Ie=e,Ne.length&&Ie&&Ie(Tr)}function ln(){o.getInheritedInstanceCount=un,o.getLiveInheritedInstances=cn,o.flushPendingDeletes=Tr,o.setDelayFunction=fn}var Me={};function dn(e,r){for(r===void 0&&M("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r}function hn(e,r){return r=dn(e,r),Me[r]}function sr(e,r){(!r.ptrType||!r.ptr)&&or("makeClassHandle requires ptr and ptrType");var t=!!r.smartPtrType,n=!!r.smartPtr;return t!==n&&or("Both smartPtrType and smartPtr must be specified"),r.count={value:1},je(Object.create(e,{$$:{value:r}}))}function pn(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=hn(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 a(){return this.isSmartPointer?sr(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):sr(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var u=this.registeredClass.getActualType(r),f=it[u];if(!f)return a.call(this);var c;this.isConst?c=f.constPointerType:c=f.pointerType;var l=nt(r,this.registeredClass,c.registeredClass);return l===null?a.call(this):this.isSmartPointer?sr(c.registeredClass.instancePrototype,{ptrType:c,ptr:l,smartPtrType:this,smartPtr:e}):sr(c.registeredClass.instancePrototype,{ptrType:c,ptr:l})}function je(e){return typeof FinalizationRegistry>"u"?(je=r=>r,e):(Cr=new FinalizationRegistry(r=>{tt(r.$$)}),je=r=>{var t=r.$$,n=!!t.smartPtr;if(n){var a={$$:t};Cr.register(r,a,r)}return r},rt=r=>Cr.unregister(r),je(e))}function vn(){if(this.$$.ptr||Pr(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e=je(Object.create(Object.getPrototypeOf(this),{$$:{value:sn(this.$$)}}));return e.$$.count.value+=1,e.$$.deleteScheduled=!1,e}function mn(){this.$$.ptr||Pr(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&M("Object already scheduled for deletion"),rt(this),tt(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function gn(){return!this.$$.ptr}function yn(){return this.$$.ptr||Pr(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&M("Object already scheduled for deletion"),Ne.push(this),Ne.length===1&&Ie&&Ie(Tr),this.$$.deleteScheduled=!0,this}function wn(){pe.prototype.isAliasOf=on,pe.prototype.clone=vn,pe.prototype.delete=mn,pe.prototype.isDeleted=gn,pe.prototype.deleteLater=yn}function pe(){}function ot(e,r,t){if(e[r].overloadTable===void 0){var n=e[r];e[r]=function(){return e[r].overloadTable.hasOwnProperty(arguments.length)||M("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 _n(e,r,t){o.hasOwnProperty(e)?((t===void 0||o[e].overloadTable!==void 0&&o[e].overloadTable[t]!==void 0)&&M("Cannot register public name '"+e+"' twice"),ot(o,e,e),o.hasOwnProperty(t)&&M("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 En(e,r,t,n,a,u,f,c){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=a,this.getActualType=u,this.upcast=f,this.downcast=c,this.pureVirtualFunctions=[]}function Sr(e,r,t){for(;r!==t;)r.upcast||M("Expected null or instance of "+t.name+", got an instance of "+r.name),e=r.upcast(e),r=r.baseClass;return e}function bn(e,r){if(r===null)return this.isReference&&M("null is not a valid "+this.name),0;r.$$||M('Cannot pass "'+kr(r)+'" as a '+this.name),r.$$.ptr||M("Cannot pass deleted object as a pointer of type "+this.name);var t=r.$$.ptrType.registeredClass,n=Sr(r.$$.ptr,t,this.registeredClass);return n}function Pn(e,r){var t;if(r===null)return this.isReference&&M("null is not a valid "+this.name),this.isSmartPointer?(t=this.rawConstructor(),e!==null&&e.push(this.rawDestructor,t),t):0;r.$$||M('Cannot pass "'+kr(r)+'" as a '+this.name),r.$$.ptr||M("Cannot pass deleted object as a pointer of type "+this.name),!this.isConst&&r.$$.ptrType.isConst&&M("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=Sr(r.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(r.$$.smartPtr===void 0&&M("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:M("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 a=r.clone();t=this.rawShare(t,ur.toHandle(function(){a.delete()})),e!==null&&e.push(this.rawDestructor,t)}break;default:M("Unsupporting sharing policy")}return t}function Cn(e,r){if(r===null)return this.isReference&&M("null is not a valid "+this.name),0;r.$$||M('Cannot pass "'+kr(r)+'" as a '+this.name),r.$$.ptr||M("Cannot pass deleted object as a pointer of type "+this.name),r.$$.ptrType.isConst&&M("Cannot convert argument of type "+r.$$.ptrType.name+" to parameter type "+this.name);var t=r.$$.ptrType.registeredClass,n=Sr(r.$$.ptr,t,this.registeredClass);return n}function ar(e){return this.fromWireType(L[e>>2])}function Tn(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e}function Sn(e){this.rawDestructor&&this.rawDestructor(e)}function Dn(e){e!==null&&e.delete()}function An(){ue.prototype.getPointee=Tn,ue.prototype.destructor=Sn,ue.prototype.argPackAdvance=8,ue.prototype.readValueFromPointer=ar,ue.prototype.deleteObject=Dn,ue.prototype.fromWireType=pn}function ue(e,r,t,n,a,u,f,c,l,p,E){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=a,this.pointeeType=u,this.sharingPolicy=f,this.rawGetPointee=c,this.rawConstructor=l,this.rawShare=p,this.rawDestructor=E,!a&&r.baseClass===void 0?n?(this.toWireType=bn,this.destructorFunction=null):(this.toWireType=Cn,this.destructorFunction=null):this.toWireType=Pn}function kn(e,r,t){o.hasOwnProperty(e)||or("Replacing nonexistant public symbol"),o[e].overloadTable!==void 0&&t!==void 0?o[e].overloadTable[t]=r:(o[e]=r,o[e].argCount=t)}function Fn(e,r,t){var n=o["dynCall_"+e];return t&&t.length?n.apply(null,[r].concat(t)):n.call(null,r)}function On(e,r,t){return e.includes("j")?Fn(e,r,t):tr(r).apply(null,t)}function Rn(e,r){var t=[];return function(){return t.length=0,Object.assign(t,arguments),On(e,r,t)}}function Ae(e,r){e=re(e);function t(){return e.includes("j")?Rn(e,r):tr(r)}var n=t();return typeof n!="function"&&M("unknown function pointer with signature "+e+": "+r),n}var st=void 0;function at(e){var r=vt(e),t=re(r);return ce(r),t}function Dr(e,r){var t=[],n={};function a(u){if(!n[u]&&!Ee[u]){if(nr[u]){nr[u].forEach(a);return}t.push(u),n[u]=!0}}throw r.forEach(a),new st(e+": "+t.map(at).join([", "]))}function $n(e,r,t,n,a,u,f,c,l,p,E,b,w){E=re(E),u=Ae(a,u),c&&(c=Ae(f,c)),p&&(p=Ae(l,p)),w=Ae(b,w);var C=ir(E);_n(C,function(){Dr("Cannot construct "+E+" due to unbound types",[n])}),Ue([e,r,t],n?[n]:[],function(k){k=k[0];var x,H;n?(x=k.registeredClass,H=x.instancePrototype):H=pe.prototype;var G=Er(C,function(){if(Object.getPrototypeOf(this)!==J)throw new De("Use 'new' to construct "+E);if(q.constructor_body===void 0)throw new De(E+" has no accessible constructor");var z=q.constructor_body[arguments.length];if(z===void 0)throw new De("Tried to invoke ctor of "+E+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(q.constructor_body).toString()+") parameters instead!");return z.apply(this,arguments)}),J=Object.create(H,{constructor:{value:G}});G.prototype=J;var q=new En(E,G,J,w,x,u,c,p),be=new ue(E,q,!0,!1,!1),te=new ue(E+"*",q,!1,!1,!1),fe=new ue(E+" const*",q,!1,!0,!1);return it[e]={pointerType:te,constPointerType:fe},kn(C,G),[be,te,fe]})}function ut(e,r){for(var t=[],n=0;n<e;n++)t.push(R[(r>>2)+n]);return t}function Un(e){for(;e.length;){var r=e.pop(),t=e.pop();t(r)}}function ct(e,r){if(!(e instanceof Function))throw new TypeError("new_ called with constructor type "+typeof e+" which is not a function");var t=Er(e.name||"unknownFunctionName",function(){});t.prototype=e.prototype;var n=new t,a=e.apply(n,r);return a instanceof Object?a:n}function ft(e,r,t,n,a){var u=r.length;u<2&&M("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var f=r[1]!==null&&t!==null,c=!1,l=1;l<r.length;++l)if(r[l]!==null&&r[l].destructorFunction===void 0){c=!0;break}for(var p=r[0].name!=="void",E="",b="",l=0;l<u-2;++l)E+=(l!==0?", ":"")+"arg"+l,b+=(l!==0?", ":"")+"arg"+l+"Wired";var w="return function "+ir(e)+"("+E+`) {
  8. if (arguments.length !== `+(u-2)+`) {
  9. throwBindingError('function `+e+" called with ' + arguments.length + ' arguments, expected "+(u-2)+` args!');
  10. }
  11. `;c&&(w+=`var destructors = [];
  12. `);var C=c?"destructors":"null",k=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],x=[M,n,a,Un,r[0],r[1]];f&&(w+="var thisWired = classParam.toWireType("+C+`, this);
  13. `);for(var l=0;l<u-2;++l)w+="var arg"+l+"Wired = argType"+l+".toWireType("+C+", arg"+l+"); // "+r[l+2].name+`
  14. `,k.push("argType"+l),x.push(r[l+2]);if(f&&(b="thisWired"+(b.length>0?", ":"")+b),w+=(p?"var rv = ":"")+"invoker(fn"+(b.length>0?", ":"")+b+`);
  15. `,c)w+=`runDestructors(destructors);
  16. `;else for(var l=f?1:2;l<r.length;++l){var H=l===1?"thisWired":"arg"+(l-2)+"Wired";r[l].destructorFunction!==null&&(w+=H+"_dtor("+H+"); // "+r[l].name+`
  17. `,k.push(H+"_dtor"),x.push(r[l].destructorFunction))}p&&(w+=`var ret = retType.fromWireType(rv);
  18. return ret;
  19. `),w+=`}
  20. `,k.push(w);var G=ct(Function,k).apply(null,x);return G}function Nn(e,r,t,n,a,u){Oe(r>0);var f=ut(r,t);a=Ae(n,a),Ue([],[e],function(c){c=c[0];var l="constructor "+c.name;if(c.registeredClass.constructor_body===void 0&&(c.registeredClass.constructor_body=[]),c.registeredClass.constructor_body[r-1]!==void 0)throw new De("Cannot register multiple constructors with identical number of parameters ("+(r-1)+") for class '"+c.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return c.registeredClass.constructor_body[r-1]=()=>{Dr("Cannot construct "+c.name+" due to unbound types",f)},Ue([],f,function(p){return p.splice(1,0,null),c.registeredClass.constructor_body[r-1]=ft(l,p,null,a,u),[]}),[]})}function In(e,r,t,n,a,u,f,c){var l=ut(t,n);r=re(r),u=Ae(a,u),Ue([],[e],function(p){p=p[0];var E=p.name+"."+r;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),c&&p.registeredClass.pureVirtualFunctions.push(r);function b(){Dr("Cannot call "+E+" due to unbound types",l)}var w=p.registeredClass.instancePrototype,C=w[r];return C===void 0||C.overloadTable===void 0&&C.className!==p.name&&C.argCount===t-2?(b.argCount=t-2,b.className=p.name,w[r]=b):(ot(w,r,E),w[r].overloadTable[t-2]=b),Ue([],l,function(k){var x=ft(E,k,p,u,f);return w[r].overloadTable===void 0?(x.argCount=t-2,w[r]=x):w[r].overloadTable[t-2]=x,[]}),[]})}var Ar=[],ne=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function lt(e){e>4&&--ne[e].refcount===0&&(ne[e]=void 0,Ar.push(e))}function Mn(){for(var e=0,r=5;r<ne.length;++r)ne[r]!==void 0&&++e;return e}function jn(){for(var e=5;e<ne.length;++e)if(ne[e]!==void 0)return ne[e];return null}function xn(){o.count_emval_handles=Mn,o.get_first_emval=jn}var ur={toValue:e=>(e||M("Cannot use deleted val. handle = "+e),ne[e].value),toHandle:e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:{var r=Ar.length?Ar.pop():ne.length;return ne[r]={refcount:1,value:e},r}}}};function Ln(e,r){r=re(r),ae(e,{name:r,fromWireType:function(t){var n=ur.toValue(t);return lt(t),n},toWireType:function(t,n){return ur.toHandle(n)},argPackAdvance:8,readValueFromPointer:ar,destructorFunction:null})}function kr(e){if(e===null)return"null";var r=typeof e;return r==="object"||r==="array"||r==="function"?e.toString():""+e}function Hn(e,r){switch(r){case 2:return function(t){return this.fromWireType(Br[t>>2])};case 3:return function(t){return this.fromWireType(Wr[t>>3])};default:throw new TypeError("Unknown float type: "+e)}}function zn(e,r,t){var n=_r(t);r=re(r),ae(e,{name:r,fromWireType:function(a){return a},toWireType:function(a,u){return u},argPackAdvance:8,readValueFromPointer:Hn(r,n),destructorFunction:null})}function Bn(e,r,t){switch(r){case 0:return t?function(a){return Z[a]}:function(a){return X[a]};case 1:return t?function(a){return ge[a>>1]}:function(a){return Ze[a>>1]};case 2:return t?function(a){return R[a>>2]}:function(a){return L[a>>2]};default:throw new TypeError("Unknown integer type: "+e)}}function Wn(e,r,t,n,a){r=re(r);var u=_r(t),f=b=>b;if(n===0){var c=32-8*t;f=b=>b<<c>>>c}var l=r.includes("unsigned"),p=(b,w)=>{},E;l?E=function(b,w){return p(w,this.name),w>>>0}:E=function(b,w){return p(w,this.name),w},ae(e,{name:r,fromWireType:f,toWireType:E,argPackAdvance:8,readValueFromPointer:Bn(r,u,n!==0),destructorFunction:null})}function Vn(e,r,t){var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],a=n[r];function u(f){f=f>>2;var c=L,l=c[f],p=c[f+1];return new a(gr,p,l)}t=re(t),ae(e,{name:t,fromWireType:u,argPackAdvance:8,readValueFromPointer:u},{ignoreDuplicateRegistrations:!0})}function Gn(e,r){r=re(r);var t=r==="std::string";ae(e,{name:r,fromWireType:function(n){var a=L[n>>2],u;if(t)for(var f=n+4,c=0;c<=a;++c){var l=n+4+c;if(c==a||X[l]==0){var p=l-f,E=Hr(f,p);u===void 0?u=E:(u+=String.fromCharCode(0),u+=E),f=l+1}}else{for(var b=new Array(a),c=0;c<a;++c)b[c]=String.fromCharCode(X[n+4+c]);u=b.join("")}return ce(n),u},toWireType:function(n,a){a instanceof ArrayBuffer&&(a=new Uint8Array(a));var u,f=typeof a=="string";f||a instanceof Uint8Array||a instanceof Uint8ClampedArray||a instanceof Int8Array||M("Cannot pass non-string to std::string"),t&&f?u=()=>mr(a):u=()=>a.length;var c=u(),l=lr(4+c+1);if(L[l>>2]=c,t&&f)Tt(a,l+4,c+1);else if(f)for(var p=0;p<c;++p){var E=a.charCodeAt(p);E>255&&(ce(l),M("String has UTF-16 code units that do not fit in 8 bits")),X[l+4+p]=E}else for(var p=0;p<c;++p)X[l+4+p]=a[p];return n!==null&&n.push(ce,l),l},argPackAdvance:8,readValueFromPointer:ar,destructorFunction:function(n){ce(n)}})}function qn(e,r,t){t=re(t);var n,a,u,f,c;r===2?(n=St,a=Dt,f=At,u=()=>Ze,c=1):r===4&&(n=kt,a=Ft,f=Ot,u=()=>L,c=2),ae(e,{name:t,fromWireType:function(l){for(var p=L[l>>2],E=u(),b,w=l+4,C=0;C<=p;++C){var k=l+4+C*r;if(C==p||E[k>>c]==0){var x=k-w,H=n(w,x);b===void 0?b=H:(b+=String.fromCharCode(0),b+=H),w=k+r}}return ce(l),b},toWireType:function(l,p){typeof p!="string"&&M("Cannot pass non-string to C++ string type "+t);var E=f(p),b=lr(4+E+r);return L[b>>2]=E>>c,a(p,b+4,E+r),l!==null&&l.push(ce,b),b},argPackAdvance:8,readValueFromPointer:ar,destructorFunction:function(l){ce(l)}})}function Xn(e,r){r=re(r),ae(e,{isVoid:!0,name:r,argPackAdvance:0,fromWireType:function(){},toWireType:function(t,n){}})}function Yn(){return Date.now()}var Kn={};function Jn(e){var r=Kn[e];return r===void 0?re(e):r}var Fr=[];function Qn(e,r,t,n){e=Fr[e],r=ur.toValue(r),t=Jn(t),e(r,t,null,n)}function Zn(e){var r=Fr.length;return Fr.push(e),r}function ei(e,r){var t=Ee[e];return t===void 0&&M(r+" has unknown type "+at(e)),t}function ri(e,r){for(var t=new Array(e),n=0;n<e;++n)t[n]=ei(L[r+n*Qe>>2],"parameter "+n);return t}var dt=[];function ti(e,r){var t=ri(e,r),n=t[0],a=n.name+"_$"+t.slice(1).map(function(k){return k.name}).join("_")+"$",u=dt[a];if(u!==void 0)return u;for(var f=["retType"],c=[n],l="",p=0;p<e-1;++p)l+=(p!==0?", ":"")+"arg"+p,f.push("argType"+p),c.push(t[1+p]);for(var E=ir("methodCaller_"+a),b="return function "+E+`(handle, name, destructors, args) {
  21. `,w=0,p=0;p<e-1;++p)b+=" var arg"+p+" = argType"+p+".readValueFromPointer(args"+(w?"+"+w:"")+`);
  22. `,w+=t[p+1].argPackAdvance;b+=" var rv = handle[name]("+l+`);
  23. `;for(var p=0;p<e-1;++p)t[p+1].deleteObject&&(b+=" argType"+p+".deleteObject(arg"+p+`);
  24. `);n.isVoid||(b+=` return retType.toWireType(destructors, rv);
  25. `),b+=`};
  26. `,f.push(b);var C=ct(Function,f).apply(null,c);return u=Zn(C),dt[a]=u,u}function ni(){we("")}function ii(){return X.length}function oi(){return ii()}function si(e,r,t){X.copyWithin(e,r,r+t)}function ai(e){we("OOM")}function ui(e){X.length,ai()}var Or={};function ci(){return g||"./this.program"}function xe(){if(!xe.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,_:ci()};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]);xe.strings=n}return xe.strings}function fi(e,r){var t=0;return xe().forEach(function(n,a){var u=r+t;L[e+a*4>>2]=u,Rt(n,u),t+=n.length+1}),0}function li(e,r){var t=xe();L[e>>2]=t.length;var n=0;return t.forEach(function(a){n+=a.length+1}),L[r>>2]=n,0}function di(e){try{var r=Y.getStreamFromFD(e);return i.close(r),0}catch(t){if(typeof i>"u"||!(t instanceof i.ErrnoError))throw t;return t.errno}}function hi(e,r){try{var t=Y.getStreamFromFD(e),n=t.tty?2:i.isDir(t.mode)?3:i.isLink(t.mode)?7:4;return Z[r>>0]=n,0}catch(a){if(typeof i>"u"||!(a instanceof i.ErrnoError))throw a;return a.errno}}function pi(e,r,t,n){for(var a=0,u=0;u<t;u++){var f=L[r>>2],c=L[r+4>>2];r+=8;var l=i.read(e,Z,f,c,n);if(l<0)return-1;if(a+=l,l<c)break}return a}function vi(e,r,t,n){try{var a=Y.getStreamFromFD(e),u=pi(a,r,t);return R[n>>2]=u,0}catch(f){if(typeof i>"u"||!(f instanceof i.ErrnoError))throw f;return f.errno}}function mi(e,r){return r+2097152>>>0<4194305-!!e?(e>>>0)+r*4294967296:NaN}function gi(e,r,t,n,a){try{var u=mi(r,t);if(isNaN(u))return 61;var f=Y.getStreamFromFD(e);return i.llseek(f,u,n),oe=[f.position>>>0,(V=f.position,+Math.abs(V)>=1?V>0?(Math.min(+Math.floor(V/4294967296),4294967295)|0)>>>0:~~+Math.ceil((V-+(~~V>>>0))/4294967296)>>>0:0)],R[a>>2]=oe[0],R[a+4>>2]=oe[1],f.getdents&&u===0&&n===0&&(f.getdents=null),0}catch(c){if(typeof i>"u"||!(c instanceof i.ErrnoError))throw c;return c.errno}}function yi(e,r,t,n){for(var a=0,u=0;u<t;u++){var f=L[r>>2],c=L[r+4>>2];r+=8;var l=i.write(e,Z,f,c,n);if(l<0)return-1;a+=l}return a}function wi(e,r,t,n){try{var a=Y.getStreamFromFD(e),u=yi(a,r,t);return L[n>>2]=u,0}catch(f){if(typeof i>"u"||!(f instanceof i.ErrnoError))throw f;return f.errno}}function _i(e){}var ht=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},cr=365,fr=146;Object.defineProperties(ht.prototype,{read:{get:function(){return(this.mode&cr)===cr},set:function(e){e?this.mode|=cr:this.mode&=~cr}},write:{get:function(){return(this.mode&fr)===fr},set:function(e){e?this.mode|=fr:this.mode&=~fr}},isFolder:{get:function(){return i.isDir(this.mode)}},isDevice:{get:function(){return i.isChrdev(this.mode)}}}),i.FSNode=ht,i.staticInit(),en(),De=o.BindingError=br(Error,"BindingError"),et=o.InternalError=br(Error,"InternalError"),wn(),ln(),An(),st=o.UnboundTypeError=br(Error,"UnboundTypeError"),xn();function Rr(e,r,t){var n=t>0?t:mr(e)+1,a=new Array(n),u=vr(e,a,0,a.length);return r&&(a.length=u),a}var Ei={q:Bt,p:Vt,D:Jt,x:Qt,t:Zt,F:nn,u:$n,r:Nn,d:In,E:Ln,l:zn,c:Wn,b:Vn,k:Gn,g:qn,o:Xn,f:Yn,i:Qn,n:lt,m:ti,a:ni,w:oi,B:si,v:ui,z:fi,A:li,j:di,y:hi,C:vi,s:gi,h:wi,e:_i};zt(),o.___wasm_call_ctors=function(){return(o.___wasm_call_ctors=o.asm.H).apply(null,arguments)};var lr=o._malloc=function(){return(lr=o._malloc=o.asm.I).apply(null,arguments)},ce=o._free=function(){return(ce=o._free=o.asm.K).apply(null,arguments)},pt=o.___errno_location=function(){return(pt=o.___errno_location=o.asm.L).apply(null,arguments)},vt=o.___getTypeName=function(){return(vt=o.___getTypeName=o.asm.M).apply(null,arguments)};o.___embind_register_native_and_builtin_types=function(){return(o.___embind_register_native_and_builtin_types=o.asm.N).apply(null,arguments)};var mt=o._emscripten_builtin_memalign=function(){return(mt=o._emscripten_builtin_memalign=o.asm.O).apply(null,arguments)},gt=o.___cxa_is_pointer_type=function(){return(gt=o.___cxa_is_pointer_type=o.asm.P).apply(null,arguments)};o.dynCall_viiijj=function(){return(o.dynCall_viiijj=o.asm.Q).apply(null,arguments)},o.dynCall_jij=function(){return(o.dynCall_jij=o.asm.R).apply(null,arguments)},o.dynCall_jii=function(){return(o.dynCall_jii=o.asm.S).apply(null,arguments)},o.dynCall_jiji=function(){return(o.dynCall_jiji=o.asm.T).apply(null,arguments)};var dr;function bi(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}$e=function e(){dr||$r(),dr||($e=e)};function $r(e){if(ye>0||(Ut(),ye>0))return;function r(){dr||(dr=!0,o.calledRun=!0,!ie&&(Nt(),d(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),It()))}o.setStatus?(o.setStatus("Running..."),setTimeout(function(){setTimeout(function(){o.setStatus("")},1),r()},1)):r()}if(o.run=$r,o.preInit)for(typeof o.preInit=="function"&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return $r(),o.ready}})(),to=Object.defineProperty,no=Object.getOwnPropertyDescriptor,Ye=(v,s,o,d)=>{for(var h=d>1?void 0:d?no(s,o):s,_=v.length-1,g;_>=0;_--)(g=v[_])&&(h=(d?g(s,o,h):g(h))||h);return d&&h&&to(s,o,h),h};class Ke extends N{constructor(){super(...arguments),this.sampleRate=0,this.channels=0}initialize(){return new Promise(s=>{const o={};o.print=d=>console.log(d),o.printErr=d=>console.log(`[JS] ERROR: ${d}`),o.onAbort=()=>console.log("[JS] FATAL: WASM ABORTED"),o.postRun=d=>{this.module=d,this.decoder=new this.module.AudioDecoder(this),s()},ro(o)})}configure(s){this.config=s,this.decoder.setCodec(this.config.codec,this.config.description)}decode(s){this.decoder.decode(s.data,s.timestamp)}flush(){}reset(){this.config=void 0,this.decoder&&this.decoder.clear()}close(){this.removeAllListeners(),this.decoder&&(this.decoder.clear(),this.decoder.delete())}audioInfo(s,o){this.sampleRate=s,this.channels=o;let d={sampleRate:s,channels:o,depth:16};this.emit(Pe.AudioCodecInfo,d)}pcmData(s,o,d){if(!this.module)return;let h=[];for(let g=0;g<this.channels;g++){let D=this.module.HEAPU32[(s>>2)+g]>>2;h.push(Float32Array.of(...this.module.HEAPF32.subarray(D,D+o)))}let _={datas:h,sampleNum:o,channles:this.channels,pts:d};this.emit(Pe.AudioFrame,_)}errorInfo(s){let o={errMsg:s};this.emit(Pe.Error,o)}}Ye([B(N.INIT,"initialized")],Ke.prototype,"initialize",1);Ye([B("initialized","configured")],Ke.prototype,"configure",1);Ye([Be("configured")],Ke.prototype,"decode",1);Ye([B("configured","initialized")],Ke.prototype,"reset",1);Ye([B([],"closed")],Ke.prototype,"close",1);var io=Object.defineProperty,oo=Object.getOwnPropertyDescriptor,Je=(v,s,o,d)=>{for(var h=d>1?void 0:d?oo(s,o):s,_=v.length-1,g;_>=0;_--)(g=v[_])&&(h=(d?g(s,o,h):g(h))||h);return d&&h&&io(s,o,h),h};class Fe extends N{async initialize(){this.decoder=new AudioDecoder({output:s=>{this.emit(Pe.AudioFrame,s)},error:s=>{this.emit(Pe.Error,s),this.close()}})}configure(s){this.config=s,this.decoder.configure({codec:{aac:"mp4a.40.2",pcma:"alaw",pcmu:"ulaw"}[s.codec],description:s.description,sampleRate:s.sampleRate,numberOfChannels:s.numberOfChannels})}decode(s){this.decoder.state==="configured"&&this.decoder.decode(new EncodedAudioChunk(s))}flush(){this.decoder.flush()}reset(){this.decoder.reset()}close(){this.decoder.close()}}Je([B([N.INIT,"closed"],"initialized")],Fe.prototype,"initialize",1);Je([B("initialized","configured")],Fe.prototype,"configure",1);Je([Be("configured")],Fe.prototype,"decode",1);Je([B([],N.INIT)],Fe.prototype,"reset",1);Je([B([],"closed",{ignoreError:!0})],Fe.prototype,"close",1);var de=(v=>(v.AUDIO_ENCODER_CONFIG_CHANGED="audio-encoder-config-changed",v.VIDEO_ENCODER_CONFIG_CHANGED="video-encoder-config-changed",v))(de||{}),ve=(v=>(v[v.PULL=0]="PULL",v[v.PUSH=1]="PUSH",v))(ve||{});class Pt extends ze.EventEmitter{constructor(s,o=0){super(),this.source=s,this.mode=o,Object.getPrototypeOf(this).constructor.name,s&&(o==0?this.startPull(s):s.oput=new We(this.demux()))}startPull(s){this.mode=0,this.source=s,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((s,o)=>{this.gotAudio=s,this.gotVideo&&this.pull().catch(o)})}pullVideo(){return new Promise((s,o)=>{this.gotVideo=s,this.gotAudio&&this.pull().catch(o)})}}const Ct=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350,-1,-1,-1];function so(v){const s=((v[2]&192)>>>6)+1,o=(v[2]&60)>>>2,d=(v[2]&1)<<2|(v[3]&192)>>>6,h=new Uint8Array([(s&3)<<3|(o&14)>>1,(o&1)<<7|(d&15)<<3]);return{profile:s,sampleRate:Ct[o],channel:d,audioSpecificConfig:h}}class Mr extends Pt{constructor(){super(...arguments),this.tmp8=new Uint8Array(4),this.dv=new DataView(this.tmp8.buffer)}async pullTag(){const s=new Uint8Array(15);return this.pullTag=async()=>{await this.source.read(s);const o=s[4],d=this.readLength(s.subarray(5,8)),h=this.readTimestamp(s.subarray(8,11)),_=await this.source.read(d);return{type:o,data:_.slice(),timestamp:h}},console.time("flv"),await this.source.read(9).then(o=>{if(this.header=o,o[0]!="F".charCodeAt(0)||o[1]!="L".charCodeAt(0)||o[2]!="V".charCodeAt(0))throw new Error("not flv");console.timeEnd("flv")}),this.pullTag()}readTag(s){const o=s[0],d=this.readLength(s.subarray(1,4)),h=this.readTimestamp(s.subarray(4,8));this.gotTag(o,s.subarray(11,11+d),h)}gotTag(s,o,d){var h,_;switch(s){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=Ct[(o[2]&7)<<1|o[3]>>7]):this.emit(de.AUDIO_ENCODER_CONFIG_CHANGED,this.audioDecoderConfig)),this.audioDecoderConfig.codec=="aac"&&o[1]==0?(this.audioDecoderConfig.description=o.subarray(2),this.emit(de.AUDIO_ENCODER_CONFIG_CHANGED,this.audioDecoderConfig),this.mode==ve.PULL?this.pull():void 0):(h=this.gotAudio)==null?void 0:h.call(this,{type:"key",data:this.audioDecoderConfig.codec=="aac"?o.subarray(2):o.subarray(1),timestamp:d,duration:0});case 9:return this.videoDecoderConfig||(this.videoDecoderConfig={codec:{7:"avc",12:"hevc"}[o[0]&15]||"unknown",description:o.subarray(5)}),o[1]==0?(this.emit(de.VIDEO_ENCODER_CONFIG_CHANGED,this.videoDecoderConfig),this.mode==ve.PULL?this.pull():void 0):(_=this.gotVideo)==null?void 0:_.call(this,{type:o[0]>>4==1?"key":"delta",data:o.subarray(5),timestamp:d,duration:0});default:if(this.mode==ve.PULL)return this.pull()}}async pull(){const s=await this.pullTag();if(s)return this.gotTag(s.type,s.data,s.timestamp)}readLength(s){return this.tmp8[0]=0,this.tmp8.set(s,1),this.dv.getUint32(0)}readTimestamp(s){this.tmp8.set(s.subarray(0,3),1);let o=this.dv.getUint32(0);return o===16777215&&(this.tmp8[0]=s[3],o=this.dv.getUint32(0)),o}readHead(s){if(console.time("flv"),this.header=s,s[0]!="F".charCodeAt(0)||s[1]!="L".charCodeAt(0)||s[2]!="V".charCodeAt(0))throw new Error("not flv");console.timeEnd("flv")}*demux(){for(this.readHead(yield 13);;){let s=yield 11;const o=s[0],d=this.readLength(s.subarray(1,4)),h=this.readTimestamp(s.subarray(4,8));s=yield d,this.gotTag(o,s.slice(),h),yield 4}}}const ao=442,uo=443,co=444,fo=480,lo=448,ho=445,po=441,vo=27,mo=36,go=15,yo=144,wo=145;class _o extends Pt{constructor(){super(...arguments),this.videoStreamType=0,this.audioStreamType=0,this.pts=0,this.dts=0}pull(){throw new Error("Method not implemented.")}*demux(){var D,S,m,y,P;let s=0;const o=new Uint8Array(4),d=new DataView(o.buffer),h=[];let _=0,g=0;for(;;){yield o;const j=d.getUint32(0);switch(j.toString(16),j){case ao:yield 9,yield o.subarray(0,1),yield d.getUint8(0)&7;break;case uo:case ho:yield o.subarray(0,2),yield d.getUint16(0);break;case co:yield o.subarray(0,2);const T=yield d.getUint16(0);this.decProgramStreamMap(T);break;case fo:yield o.subarray(0,2);const W=d.getUint16(0),Q=yield W,U=this.parsePESPacket(Q);if(U.length,!s)if((U[4]&15)==7)s=Date.now(),g=this.pts;else break;if(g==this.pts){_+=U.length,h.push(U.slice());break}if(h.length&&g!=this.pts){let ie=0;(D=this.gotVideo)==null||D.call(this,{type:(h[0][4]&15)==1?"delta":"key",data:h.length==1?h[0]:h.reduce((Oe,Re)=>(Oe.subarray(ie).set(Re),ie+=Re.length,Oe),new Uint8Array(_)),timestamp:(Date.now()-s)*1e3}),h.length=0}_+=U.length,h.push(U.slice()),g=this.pts;break;case lo:yield o.subarray(0,2);const ee=yield d.getUint16(0),Ce=this.parsePESPacket(ee);if(((S=this.audioDecoderConfig)==null?void 0:S.codec)=="aac"&&!((m=this.audioDecoderConfig)!=null&&m.description)){const ie=so(Ce.subarray(7));this.audioDecoderConfig={codec:"aac",description:ie.audioSpecificConfig,sampleRate:ie.sampleRate,numberOfChannels:ie.channel},this.emit(de.AUDIO_ENCODER_CONFIG_CHANGED,this.audioDecoderConfig)}(P=this.gotAudio)==null||P.call(this,{type:"key",data:((y=this.audioDecoderConfig)==null?void 0:y.codec)=="aac"?Ce.subarray(7):Ce,timestamp:this.dts,duration:0});break;case po:return;default:debugger}}}parsePESPacket(s){if(s.length<4)throw new Error("Short buffer");const o=s[1],d=o>>7==1,h=(o&64)>>6==1,_=s[2];if(s.length<_+3)throw new Error("Short buffer");const g=s.subarray(3,3+_);return d&&g.length>4&&(this.pts=(g[0]&14)<<29|g[1]<<22|(g[2]&254)<<14|g[3]<<7|g[4]>>1,h&&g.length>9?this.dts=(g[5]&14)<<29|g[6]<<22|(g[7]&254)<<14|g[8]<<7|g[9]>>1:this.dts=this.pts),s.subarray(3+_)}decProgramStreamMap(s){const o=new DataView(s.buffer,s.byteOffset,s.byteLength),d=s.length;let h=2;const _=o.getUint16(h);h+=2,h+=_;let g=o.getUint16(h);for(h+=2;g>0&&!(d<=h+1);){const D=s[h];h++;const S=s[h];if(h++,S>=224&&S<=239?(this.videoStreamType=D,this.videoDecoderConfig={codec:{[vo]:"avc",[mo]:"hevc"}[D]||"unknown"},this.emit(de.VIDEO_ENCODER_CONFIG_CHANGED,this.videoDecoderConfig)):S>=192&&S<=223&&(this.audioStreamType=D,this.audioDecoderConfig={codec:{[go]:"aac",[yo]:"pcma",[wo]:"pcmu"}[D]||"unknown",numberOfChannels:1,sampleRate:8e3},this.audioDecoderConfig.codec!="aac"&&this.emit(de.AUDIO_ENCODER_CONFIG_CHANGED,this.audioDecoderConfig)),d<=h+1)break;const m=o.getUint16(h);h+=2,h+=m,g-=4+m}}}const Eo={class:"video-container"},bo=["srcObject"],Po=Pi({__name:"jb4",props:{videoShadow:null,streamPath:null,format:null,webrtcStream:null},setup(v){const s=v;let o;const d=Ur();let h,_;const g=Ur(),D=new ke,S=new Fe,m=Ci(new Yi(""));D.on(le.VideoCodecInfo,A=>{}),D.on(le.VideoFrame,A=>{_.write(A)}),S.on(Pe.AudioFrame,A=>{h.write(A)}),D.on(le.Error,A=>{console.error(A)});function y(){var A;d.value&&((A=s.webrtcStream)!=null&&A.mediaStream)&&(g.value=s.webrtcStream.mediaStream)}Ti(()=>{var A;(A=s.webrtcStream)==null||A.off("change",y)}),yt(()=>{m.mediaStream&&(g.value=m.mediaStream),s.webrtcStream&&(y(),s.webrtcStream.on("change",y))}),yt(async()=>{if(s.streamPath&&s.format){switch(o&&(D.close(),S.close(),await o.close()),await D.initialize(),await S.initialize(),s.format){case"ps":o=new Et(`${hr("ps","","ws")}/${s.streamPath}`),P(new _o(o,ve.PUSH));break;case"http-flv":o=new qi(`${hr("hdl","")}/${s.streamPath}.flv`),P(new Mr(o,ve.PUSH));break;case"ws-flv":o=new Et(`${hr("jessica","","ws")}/${s.streamPath}.flv`),P(new Mr(o,ve.PUSH));break;case"webrtc":const A=new Ki(`${hr("webrtc","/play")}/${s.streamPath}`);o=A;const $=A.webrtc;m.id=s.streamPath,A.addStream(m),$.ondatachannel=O=>{const T=O.channel,W=new Xi(T);P(new Mr(W,ve.PUSH)),W.connect()};break}await o.connect()}});function P(A){const $=new MediaStreamTrackGenerator({kind:"audio"});h=$.writable.getWriter();const O=new MediaStreamTrackGenerator({kind:"video"});_=O.writable.getWriter(),g.value=new MediaStream([$,O]),A.on(de.VIDEO_ENCODER_CONFIG_CHANGED,T=>{D.configure(T)}),A.on(de.AUDIO_ENCODER_CONFIG_CHANGED,T=>{S.configure(T)}),A.gotVideo=T=>D.decode(T),A.gotAudio=T=>S.decode(T)}const j=Ur(!0);return Si(()=>{Mi(d.value,"canplay",()=>{j.value=!1})}),Di(()=>o==null?void 0:o.close()),(A,$)=>(Ai(),ki("div",Eo,[Fi(Ri($i(ji),{class:"loading",size:"large"},null,512),[[Oi,j.value]]),Ui("video",{ref_key:"videoEle",ref:d,class:Ni(["video",{videoShadow:v.videoShadow}]),srcObject:g.value,autoplay:""},null,10,bo),Ii(A.$slots,"default",{},void 0,!0)]))}});const Ao=xi(Po,[["__scopeId","data-v-f7af0892"]]);export{Fe as A,Xi as D,Mr as F,Ao as V,Yi as W,Ki as a,ve as b,ke as c,de as d,le as e,Pe as f};