trtc-sdk-v5 5.9.0-wasm.5 → 5.9.0-wasm.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/index.d.ts +15 -1
  2. package/package.json +1 -1
  3. package/plugins/cdn-streaming/cdn-streaming.esm.js +1 -1
  4. package/plugins/cdn-streaming/cdn-streaming.iife.js +1 -1
  5. package/plugins/cdn-streaming/package.json +1 -1
  6. package/plugins/cross-room/cross-room.esm.js +1 -1
  7. package/plugins/cross-room/cross-room.iife.js +1 -1
  8. package/plugins/cross-room/package.json +1 -1
  9. package/plugins/custom-encryption/custom-encryption.esm.js +3 -3
  10. package/plugins/custom-encryption/custom-encryption.iife.js +3 -3
  11. package/plugins/custom-encryption/package.json +1 -1
  12. package/plugins/device-detector/device-detector.esm.js +5 -5
  13. package/plugins/device-detector/device-detector.iife.js +5 -5
  14. package/plugins/device-detector/package.json +1 -1
  15. package/plugins/video-decoder/package.json +1 -1
  16. package/plugins/video-decoder/video-decoder.esm.js +5 -5
  17. package/plugins/video-decoder/video-decoder.iife.js +5 -5
  18. package/plugins/video-effect/basic-beauty/basic-beauty.esm.js +2 -2
  19. package/plugins/video-effect/basic-beauty/basic-beauty.iife.js +2 -2
  20. package/plugins/video-effect/basic-beauty/package.json +1 -1
  21. package/plugins/video-effect/beauty/beauty.esm.js +35 -35
  22. package/plugins/video-effect/beauty/beauty.iife.js +35 -35
  23. package/plugins/video-effect/beauty/package.json +1 -1
  24. package/plugins/video-effect/virtual-background/package.json +1 -1
  25. package/plugins/video-effect/virtual-background/virtual-background.esm.js +10 -10
  26. package/plugins/video-effect/virtual-background/virtual-background.iife.js +12 -12
  27. package/plugins/video-effect/watermark/package.json +1 -1
  28. package/plugins/video-effect/watermark/watermark.esm.js +1 -1
  29. package/plugins/video-effect/watermark/watermark.iife.js +1 -1
  30. package/trtc.esm.js +54 -54
  31. package/assets/av_processing.wasm +0 -0
  32. package/assets/worker.js +0 -17
@@ -1,6 +1,6 @@
1
- var Ii=Object.create;var nn=Object.defineProperty,Oi=Object.defineProperties,gi=Object.getOwnPropertyDescriptor,Ui=Object.getOwnPropertyDescriptors,xi=Object.getOwnPropertyNames,vi=Object.getOwnPropertySymbols,Fi=Object.getPrototypeOf,yi=Object.prototype.hasOwnProperty,Ni=Object.prototype.propertyIsEnumerable;var ai=(_,p,s)=>p in _?nn(_,p,{enumerable:!0,configurable:!0,writable:!0,value:s}):_[p]=s,wr=(_,p)=>{for(var s in p||(p={}))yi.call(p,s)&&ai(_,s,p[s]);if(vi)for(var s of vi(p))Ni.call(p,s)&&ai(_,s,p[s]);return _},Er=(_,p)=>Oi(_,Ui(p));var Mi=(_,p)=>()=>(p||_((p={exports:{}}).exports,p),p.exports);var Li=(_,p,s,y)=>{if(p&&typeof p=="object"||typeof p=="function")for(let P of xi(p))!yi.call(_,P)&&P!==s&&nn(_,P,{get:()=>p[P],enumerable:!(y=gi(p,P))||y.enumerable});return _};var Wi=(_,p,s)=>(s=_!=null?Ii(Fi(_)):{},Li(p||!_||!_.__esModule?nn(s,"default",{value:_,enumerable:!0}):s,_));var Ne=(_,p,s,y)=>{for(var P=y>1?void 0:y?gi(p,s):p,D=_.length-1,$;D>=0;D--)($=_[D])&&(P=(y?$(p,s,P):$(P))||P);return y&&P&&nn(p,s,P),P};var _e=(_,p,s)=>(ai(_,typeof p!="symbol"?p+"":p,s),s);var _i=Mi((Qi,si)=>{"use strict";var Hi=Object.prototype.hasOwnProperty,we="~";function lt(){}Object.create&&(lt.prototype=Object.create(null),new lt().__proto__||(we=!1));function Bi(_,p,s){this.fn=_,this.context=p,this.once=s||!1}function bi(_,p,s,y,P){if(typeof s!="function")throw new TypeError("The listener must be a function");var D=new Bi(s,y||_,P),$=we?we+p:p;return _._events[$]?_._events[$].fn?_._events[$]=[_._events[$],D]:_._events[$].push(D):(_._events[$]=D,_._eventsCount++),_}function on(_,p){--_._eventsCount===0?_._events=new lt:delete _._events[p]}function fe(){this._events=new lt,this._eventsCount=0}fe.prototype.eventNames=function(){var p=[],s,y;if(this._eventsCount===0)return p;for(y in s=this._events)Hi.call(s,y)&&p.push(we?y.slice(1):y);return Object.getOwnPropertySymbols?p.concat(Object.getOwnPropertySymbols(s)):p};fe.prototype.listeners=function(p){var s=we?we+p:p,y=this._events[s];if(!y)return[];if(y.fn)return[y.fn];for(var P=0,D=y.length,$=new Array(D);P<D;P++)$[P]=y[P].fn;return $};fe.prototype.listenerCount=function(p){var s=we?we+p:p,y=this._events[s];return y?y.fn?1:y.length:0};fe.prototype.emit=function(p,s,y,P,D,$){var j=we?we+p:p;if(!this._events[j])return!1;var I=this._events[j],C=arguments.length,L,N;if(I.fn){switch(I.once&&this.removeListener(p,I.fn,void 0,!0),C){case 1:return I.fn.call(I.context),!0;case 2:return I.fn.call(I.context,s),!0;case 3:return I.fn.call(I.context,s,y),!0;case 4:return I.fn.call(I.context,s,y,P),!0;case 5:return I.fn.call(I.context,s,y,P,D),!0;case 6:return I.fn.call(I.context,s,y,P,D,$),!0}for(N=1,L=new Array(C-1);N<C;N++)L[N-1]=arguments[N];I.fn.apply(I.context,L)}else{var H=I.length,pe;for(N=0;N<H;N++)switch(I[N].once&&this.removeListener(p,I[N].fn,void 0,!0),C){case 1:I[N].fn.call(I[N].context);break;case 2:I[N].fn.call(I[N].context,s);break;case 3:I[N].fn.call(I[N].context,s,y);break;case 4:I[N].fn.call(I[N].context,s,y,P);break;default:if(!L)for(pe=1,L=new Array(C-1);pe<C;pe++)L[pe-1]=arguments[pe];I[N].fn.apply(I[N].context,L)}}return!0};fe.prototype.on=function(p,s,y){return bi(this,p,s,y,!1)};fe.prototype.once=function(p,s,y){return bi(this,p,s,y,!0)};fe.prototype.removeListener=function(p,s,y,P){var D=we?we+p:p;if(!this._events[D])return this;if(!s)return on(this,D),this;var $=this._events[D];if($.fn)$.fn===s&&(!P||$.once)&&(!y||$.context===y)&&on(this,D);else{for(var j=0,I=[],C=$.length;j<C;j++)($[j].fn!==s||P&&!$[j].once||y&&$[j].context!==y)&&I.push($[j]);I.length?this._events[D]=I.length===1?I[0]:I:on(this,D)}return this};fe.prototype.removeAllListeners=function(p){var s;return p?(s=we?we+p:p,this._events[s]&&on(this,s)):(this._events=new lt,this._eventsCount=0),this};fe.prototype.off=fe.prototype.removeListener;fe.prototype.addListener=fe.prototype.on;fe.prefixed=we;fe.EventEmitter=fe;typeof si!="undefined"&&(si.exports=fe)});var Ei=Wi(_i(),1),wi=Symbol("instance"),eo=Symbol("abortCtrl"),an=Symbol("cacheResult"),dt=class{constructor(p,s,y){this.oldState=p,this.newState=s,this.action=y,this.aborted=!1}abort(p){this.aborted=!0,pt.call(p,this.oldState,new Error(`action '${this.action}' aborted`))}toString(){return`${this.action}ing`}},xr=class extends Error{constructor(p,s,y){super(s),this.state=p,this.message=s,this.cause=y}};function Vi(_){return typeof _=="object"&&_&&"then"in _}var ft=new Map;function je(_,p,s={}){return(y,P,D)=>{let $=s.action||P;if(!s.context){let I=ft.get(y)||[];ft.has(y)||ft.set(y,I),I.push({from:_,to:p,action:$})}let j=D.value;D.value=function(...I){let C=this;if(s.context&&(C=ce.get(typeof s.context=="function"?s.context.call(this,...I):s.context)),C.state===p)return s.sync?C[an]:Promise.resolve(C[an]);C.state instanceof dt&&C.state.action==s.abortAction&&C.state.abort(C);let L=null;Array.isArray(_)?_.length==0?C.state instanceof dt&&C.state.abort(C):(typeof C.state!="string"||!_.includes(C.state))&&(L=new xr(C._state,`${C.name} ${$} to ${p} failed: current state ${C._state} not from ${_.join("|")}`)):_!==C.state&&(L=new xr(C._state,`${C.name} ${$} to ${p} failed: current state ${C._state} not from ${_}`));let N=K=>{if(s.fail&&s.fail.call(this,K),s.sync){if(s.ignoreError)return K;throw K}else return s.ignoreError?Promise.resolve(K):Promise.reject(K)};if(L)return N(L);let H=C.state,pe=new dt(H,p,$);pt.call(C,pe);let ke=K=>{var Ge;return C[an]=K,pe.aborted||(pt.call(C,p),(Ge=s.success)===null||Ge===void 0||Ge.call(this,C[an])),K},Me=K=>(pt.call(C,H,K),N(K));try{let K=j.apply(this,I);return Vi(K)?K.then(ke).catch(Me):s.sync?ke(K):Promise.resolve(ke(K))}catch(K){return Me(new xr(C._state,`${C.name} ${$} from ${_} to ${p} failed: ${K}`,K instanceof Error?K:new Error(String(K))))}}}}function Ti(..._){return(p,s,y)=>{let P=y.value,D=s;y.value=function(...$){if(!_.includes(this.state.toString()))throw new xr(this.state,`${this.name} ${D} failed: current state ${this.state} not in ${_}`);return P.apply(this,$)}}}var ji=(()=>typeof window!="undefined"&&window.__AFSM__?(s,y)=>{window.dispatchEvent(new CustomEvent(s,{detail:y}))}:typeof importScripts!="undefined"?(s,y)=>{postMessage({type:s,payload:y})}:()=>{})();function pt(_,p){let s=this._state;this._state=_;let y=_.toString();_&&this.emit(y,s),this.emit(ce.STATECHANGED,_,s,p),this.updateDevTools({value:_,old:s,err:p instanceof Error?p.message:String(p)})}var ce=class _ extends Ei.default{constructor(p,s,y){super(),this.name=p,this.groupName=s,this._state=_.INIT,p||(p=Date.now().toString(36)),y?Object.setPrototypeOf(this,y):y=Object.getPrototypeOf(this),s||(this.groupName=this.constructor.name);let P=y[wi];P?this.name=P.name+"-"+P.count++:y[wi]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){let p=Object.getPrototypeOf(this),s=ft.get(p)||[],y=new Set,P=[],D=[],$=new Set,j=Object.getPrototypeOf(p);ft.has(j)&&(j.stateDiagram.forEach(C=>y.add(C)),j.allStates.forEach(C=>$.add(C))),s.forEach(({from:C,to:L,action:N})=>{typeof C=="string"?P.push({from:C,to:L,action:N}):C.length?C.forEach(H=>{P.push({from:H,to:L,action:N})}):D.push({to:L,action:N})}),P.forEach(({from:C,to:L,action:N})=>{$.add(C),$.add(L),$.add(N+"ing"),y.add(`${C} --> ${N}ing : ${N}`),y.add(`${N}ing --> ${L} : ${N} \u{1F7E2}`),y.add(`${N}ing --> ${C} : ${N} \u{1F534}`)}),D.forEach(({to:C,action:L})=>{y.add(`${L}ing --> ${C} : ${L} \u{1F7E2}`),$.forEach(N=>{N!==C&&y.add(`${N} --> ${L}ing : ${L}`)})});let I=[...y];return Object.defineProperties(p,{stateDiagram:{value:I},allStates:{value:$}}),I}static get(p){let s;return typeof p=="string"?(s=_.instances.get(p),s||_.instances.set(p,s=new _(p,void 0,Object.create(_.prototype)))):(s=_.instances2.get(p),s||_.instances2.set(p,s=new _(p.constructor.name,void 0,Object.create(_.prototype)))),s}static getState(p){var s;return(s=_.get(p))===null||s===void 0?void 0:s.state}updateDevTools(p={}){ji(_.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},p))}get state(){return this._state}set state(p){pt.call(this,p)}};ce.STATECHANGED="stateChanged";ce.UPDATEAFSM="updateAFSM";ce.INIT="[*]";ce.ON="on";ce.OFF="off";ce.instances=new Map;ce.instances2=new WeakMap;var ir=class extends ce{constructor(){super(...arguments);_e(this,"decoder");_e(this,"config")}async initialize(){this.decoder=new VideoDecoder({output:s=>{this.emit("videoFrame",s)},error:s=>{this.close(),this.emit("error",s)}})}configure(s){this.config=s,this.decoder.configure(Er(wr({},s),{codec:this.getCodec(s)}))}getCodec(s){switch(s.codec){case"hevc":return"hvc1.1.6.L0.12.34.56.78.9A.BC";case"av1":return"av01.0.05M.08";case"avc":return"avc1.420028";default:return s.codec}}decode(s){this.decoder.state==="configured"&&this.decoder.decode(new EncodedVideoChunk(s))}flush(){this.decoder.flush()}reset(){this.decoder.reset()}close(){this.decoder.state!=="closed"&&this.decoder.close()}};Ne([je([ce.INIT,"closed"],"initialized")],ir.prototype,"initialize",1),Ne([je("initialized","configured",{sync:!0})],ir.prototype,"configure",1),Ne([Ti("configured")],ir.prototype,"decode",1),Ne([je([],ce.INIT)],ir.prototype,"reset",1),Ne([je([],"closed",{ignoreError:!0,sync:!0})],ir.prototype,"close",1);function Gi(){var _;self.onmessage=p=>{if(p.data.type==="init"){let{canvas:s,wasmScript:y,wasmBinary:P}=p.data,D=s==null?void 0:s.getContext("2d"),$=0,j=0,I={wasmBinary:P,postRun:()=>{_=new I.VideoDecoder({videoInfo(C,L){$=C,j=L,console.log("video info",C,L)},yuvData(C,L){let N=$*j,H=N>>2,pe=I.HEAPU32[C>>2],ke=I.HEAPU32[(C>>2)+1],Me=I.HEAPU32[(C>>2)+2],K=I.HEAPU8.subarray(pe,pe+N),Ge=I.HEAPU8.subarray(ke,ke+H),lr=I.HEAPU8.subarray(Me,Me+H),ae=new Uint8Array(N+H+H);ae.set(K),ae.set(Ge,N),ae.set(lr,N+H);let me=new VideoFrame(ae,{codedWidth:$,codedHeight:j,format:"I420",timestamp:L});s?(D==null||D.drawImage(me,0,0,s.width,s.height),D==null||D.commit()):self.postMessage({type:"yuvData",videoFrame:me},[me])}}),self.postMessage({type:"ready"})}};Function("var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;return "+y)()(I)}else if(p.data.type==="decode"){let{packet:s}=p.data;_==null||_.decode(s.data,s.type=="key",s.timestamp)}else if(p.data.type==="setCodec"){let{codec:s,format:y,description:P}=p.data;_==null||_.setCodec(s,y,P!=null?P:"")}}}var ze=class extends ce{constructor(s,y,P=!1,D,$=!1){super();this.createModule=s;this.wasmBinary=y;this.workerMode=P;this.canvas=D;this.yuvMode=$;_e(this,"worker");_e(this,"decoder");_e(this,"config");_e(this,"module",{});_e(this,"width",0);_e(this,"height",0)}async initialize(s){var P;if(this.workerMode){let D=new RegExp("\\{(.+)\\}","s").exec(Gi.toString())[1];this.worker=new Worker(URL.createObjectURL(new Blob([D],{type:"text/javascript"})));let $=(P=this.canvas)==null?void 0:P.transferControlToOffscreen(),j=await this.wasmBinary;return console.warn("worker mode",j),this.worker.postMessage({type:"init",canvas:$,wasmScript:this.createModule.toString(),wasmBinary:j},$?[$,j]:[j]),new Promise(I=>{this.worker.onmessage=C=>{if(C.data.type==="ready")delete this.wasmBinary,I(),console.warn("worker mode initialize success");else if(C.data.type==="yuvData"){let{videoFrame:L}=C.data;this.emit("videoFrame",L)}}})}let y=this.module;return this.wasmBinary&&(y.wasmBinary=await this.wasmBinary),y.print=D=>console.log(D),y.printErr=D=>console.log(`[JS] ERROR: ${D}`),y.onAbort=()=>console.log("[JS] FATAL: WASM ABORTED"),new Promise(D=>{y.postRun=$=>{this.decoder=new this.module.VideoDecoder(this),console.log("video soft decoder initialize success"),D()},s&&Object.assign(y,s),this.createModule(y)})}configure(s){var y,P,D;this.config=s,(P=this.decoder)==null||P.setCodec(this.config.codec,this.config.description?"avcc":"annexb",(y=this.config.description)!=null?y:""),(D=this.worker)==null||D.postMessage({type:"setCodec",codec:this.config.codec,format:this.config.description?"avcc":"annexb",description:this.config.description})}decode(s){var y,P;(y=this.decoder)==null||y.decode(s.data,s.type=="key",s.timestamp),this.state==="configured"&&((P=this.worker)==null||P.postMessage({type:"decode",packet:s}))}flush(){}reset(){this.config=void 0,this.decoder&&this.decoder.clear()}close(){this.removeAllListeners(),this.decoder&&(this.decoder.clear(),this.decoder.delete())}videoInfo(s,y){this.width=s,this.height=y;let P={width:s,height:y};this.emit("videoCodecInfo",P)}yuvData(s,y){if(!this.module)return;let P=this.width*this.height,D=P>>2,$=this.module.HEAPU32[s>>2],j=this.module.HEAPU32[(s>>2)+1],I=this.module.HEAPU32[(s>>2)+2],C=this.module.HEAPU8.subarray($,$+P),L=this.module.HEAPU8.subarray(j,j+D),N=this.module.HEAPU8.subarray(I,I+D);if(this.yuvMode){this.emit("videoFrame",[C,L,N]);return}let H=new Uint8Array(P+D+D);H.set(C),H.set(L,P),H.set(N,P+D),this.emit("videoFrame",new VideoFrame(H,{codedWidth:this.width,codedHeight:this.height,format:"I420",timestamp:y}))}errorInfo(s){let y={errMsg:s};this.emit("error",y)}};Ne([je([ce.INIT,"closed"],"initialized")],ze.prototype,"initialize",1),Ne([je("initialized","configured")],ze.prototype,"configure",1),Ne([je([],ce.INIT)],ze.prototype,"reset",1),Ne([je([],"closed")],ze.prototype,"close",1);var qi=(()=>{var _=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return function(p={}){var s=p,y,P;s.ready=new Promise((e,r)=>{y=e,P=r});var D=Object.assign({},s),$=[],j="./this.program",I=(e,r)=>{throw r},C=typeof window=="object",L=typeof importScripts=="function",N=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",H="";function pe(e){return s.locateFile?s.locateFile(e,H):H+e}var ke,Me,K,Ge;(C||L)&&(L?H=self.location.href:typeof document!="undefined"&&document.currentScript&&(H=document.currentScript.src),_&&(H=_),H.indexOf("blob:")!==0?H=H.substr(0,H.replace(/[?#].*/,"").lastIndexOf("/")+1):H="",ke=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.send(null),r.responseText},L&&(K=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),Me=(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)},Ge=e=>document.title=e);var lr=s.print||console.log.bind(console),ae=s.printErr||console.error.bind(console);Object.assign(s,D),D=null,s.arguments&&($=s.arguments),s.thisProgram&&(j=s.thisProgram),s.quit&&(I=s.quit);var me;s.wasmBinary&&(me=s.wasmBinary);var Ci=s.noExitRuntime||!0;typeof WebAssembly!="object"&&Le("no native wasm support detected");var Fr,ee,Nr=!1,ln;function qe(e,r){e||Le(r)}var J,oe,Te,Pe,U,X,Mr,mt;function ht(){var e=Fr.buffer;s.HEAP8=J=new Int8Array(e),s.HEAP16=Te=new Int16Array(e),s.HEAP32=U=new Int32Array(e),s.HEAPU8=oe=new Uint8Array(e),s.HEAPU16=Pe=new Uint16Array(e),s.HEAPU32=X=new Uint32Array(e),s.HEAPF32=Mr=new Float32Array(e),s.HEAPF64=mt=new Float64Array(e)}var Lr,Wr=[],Hr=[],vt=[],dn=!1;function fn(){if(s.preRun)for(typeof s.preRun=="function"&&(s.preRun=[s.preRun]);s.preRun.length;)hn(s.preRun.shift());zr(Wr)}function pn(){dn=!0,!s.noFSInit&&!a.init.initialized&&a.init(),a.ignorePermissions=!1,We.init(),zr(Hr)}function mn(){if(s.postRun)for(typeof s.postRun=="function"&&(s.postRun=[s.postRun]);s.postRun.length;)Xe(s.postRun.shift());zr(vt)}function hn(e){Wr.unshift(e)}function vn(e){Hr.unshift(e)}function Xe(e){vt.unshift(e)}var Re=0,Ke=null,dr=null;function ci(e){return e}function or(e){Re++,s.monitorRunDependencies&&s.monitorRunDependencies(Re)}function Tr(e){if(Re--,s.monitorRunDependencies&&s.monitorRunDependencies(Re),Re==0&&(Ke!==null&&(clearInterval(Ke),Ke=null),dr)){var r=dr;dr=null,r()}}function Le(e){s.onAbort&&s.onAbort(e),e="Aborted("+e+")",ae(e),Nr=!0,ln=1,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw P(r),r}var ar="data:application/octet-stream;base64,";function Br(e){return e.startsWith(ar)}var sr;sr="videodec.wasm",Br(sr)||(sr=pe(sr));function Vr(e){if(e==sr&&me)return new Uint8Array(me);if(K)return K(e);throw"both async and sync fetching of the wasm failed"}function gn(e){return!me&&(C||L)&&typeof fetch=="function"?fetch(e,{credentials:"same-origin"}).then(r=>{if(!r.ok)throw"failed to load wasm binary file at '"+e+"'";return r.arrayBuffer()}).catch(()=>Vr(e)):Promise.resolve().then(()=>Vr(e))}function gt(e,r,t){return gn(e).then(n=>WebAssembly.instantiate(n,r)).then(n=>n).then(t,n=>{ae("failed to asynchronously prepare wasm: "+n),Le(n)})}function jr(e,r,t,n){return!e&&typeof WebAssembly.instantiateStreaming=="function"&&!Br(r)&&typeof fetch=="function"?fetch(r,{credentials:"same-origin"}).then(u=>{var l=WebAssembly.instantiateStreaming(u,t);return l.then(n,function(f){return ae("wasm streaming compile failed: "+f),ae("falling back to ArrayBuffer instantiation"),gt(r,t,n)})}):gt(r,t,n)}function yn(){var e={a:ki};function r(n,u){var l=n.exports;return ee=l,Fr=ee.E,ht(),Lr=ee.H,vn(ee.F),Tr("wasm-instantiate"),l}or("wasm-instantiate");function t(n){r(n.instance)}if(s.instantiateWasm)try{return s.instantiateWasm(e,r)}catch(n){ae("Module.instantiateWasm callback failed with error: "+n),P(n)}return jr(me,sr,e,t).catch(P),{}}var x,Q,zr=e=>{for(;e.length>0;)e.shift()(s)};function bn(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(r){X[this.ptr+4>>2]=r},this.get_type=function(){return X[this.ptr+4>>2]},this.set_destructor=function(r){X[this.ptr+8>>2]=r},this.get_destructor=function(){return X[this.ptr+8>>2]},this.set_caught=function(r){r=r?1:0,J[this.ptr+12>>0]=r},this.get_caught=function(){return J[this.ptr+12>>0]!=0},this.set_rethrown=function(r){r=r?1:0,J[this.ptr+13>>0]=r},this.get_rethrown=function(){return J[this.ptr+13>>0]!=0},this.init=function(r,t){this.set_adjusted_ptr(0),this.set_type(r),this.set_destructor(t)},this.set_adjusted_ptr=function(r){X[this.ptr+16>>2]=r},this.get_adjusted_ptr=function(){return X[this.ptr+16>>2]},this.get_exception_ptr=function(){var r=mi(this.get_type());if(r)return X[this.excPtr>>2];var t=this.get_adjusted_ptr();return t!==0?t:this.excPtr}}var Pr=0,_n=0;function yt(e,r,t){var n=new bn(e);throw n.init(r,t),Pr=e,_n++,Pr}var he=e=>(U[fi()>>2]=e,e),z={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 u=e[n];u==="."?e.splice(n,1):u===".."?(e.splice(n,1),t++):t&&(e.splice(n,1),t--)}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=z.isAbs(e),t=e.substr(-1)==="/";return e=z.normalizeArray(e.split("/").filter(n=>!!n),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=z.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=z.normalize(e),e=e.replace(/\/$/,"");var r=e.lastIndexOf("/");return r===-1?e:e.substr(r+1)},join:function(){var e=Array.prototype.slice.call(arguments);return z.normalize(e.join("/"))},join2:(e,r)=>z.normalize(e+"/"+r)},Je=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return e=>crypto.getRandomValues(e);Le("initRandomDevice")},fr=e=>(fr=Je())(e),le={resolve:function(){for(var e="",r=!1,t=arguments.length-1;t>=-1&&!r;t--){var n=t>=0?arguments[t]:a.cwd();if(typeof n!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!n)return"";e=n+"/"+e,r=z.isAbs(n)}return e=z.normalizeArray(e.split("/").filter(u=>!!u),!r).join("/"),(r?"/":"")+e||"."},relative:(e,r)=>{e=le.resolve(e).substr(1),r=le.resolve(r).substr(1);function t(h){for(var A=0;A<h.length&&h[A]==="";A++);for(var O=h.length-1;O>=0&&h[O]==="";O--);return A>O?[]:h.slice(A,O-A+1)}for(var n=t(e.split("/")),u=t(r.split("/")),l=Math.min(n.length,u.length),f=l,d=0;d<l;d++)if(n[d]!==u[d]){f=d;break}for(var g=[],d=f;d<n.length;d++)g.push("..");return g=g.concat(u.slice(f)),g.join("/")}},G=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):void 0,Ye=(e,r,t)=>{for(var n=r+t,u=r;e[u]&&!(u>=n);)++u;if(u-r>16&&e.buffer&&G)return G.decode(e.subarray(r,u));for(var l="";r<u;){var f=e[r++];if(!(f&128)){l+=String.fromCharCode(f);continue}var d=e[r++]&63;if((f&224)==192){l+=String.fromCharCode((f&31)<<6|d);continue}var g=e[r++]&63;if((f&240)==224?f=(f&15)<<12|d<<6|g:f=(f&7)<<18|d<<12|g<<6|e[r++]&63,f<65536)l+=String.fromCharCode(f);else{var h=f-65536;l+=String.fromCharCode(55296|h>>10,56320|h&1023)}}return l},ur=[],Ze=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n<=127?r++:n<=2047?r+=2:n>=55296&&n<=57343?(r+=4,++t):r+=3}return r},Gr=(e,r,t,n)=>{if(!(n>0))return 0;for(var u=t,l=t+n-1,f=0;f<e.length;++f){var d=e.charCodeAt(f);if(d>=55296&&d<=57343){var g=e.charCodeAt(++f);d=65536+((d&1023)<<10)|g&1023}if(d<=127){if(t>=l)break;r[t++]=d}else if(d<=2047){if(t+1>=l)break;r[t++]=192|d>>6,r[t++]=128|d&63}else if(d<=65535){if(t+2>=l)break;r[t++]=224|d>>12,r[t++]=128|d>>6&63,r[t++]=128|d&63}else{if(t+3>=l)break;r[t++]=240|d>>18,r[t++]=128|d>>12&63,r[t++]=128|d>>6&63,r[t++]=128|d&63}}return r[t]=0,t-u};function Se(e,r,t){var n=t>0?t:Ze(e)+1,u=new Array(n),l=Gr(e,u,0,u.length);return r&&(u.length=l),u}var wn=()=>{if(!ur.length){var e=null;if(typeof window!="undefined"&&typeof window.prompt=="function"?(e=window.prompt("Input: "),e!==null&&(e+=`
1
+ var Ii=Object.create;var nn=Object.defineProperty,Oi=Object.defineProperties,gi=Object.getOwnPropertyDescriptor,Ui=Object.getOwnPropertyDescriptors,xi=Object.getOwnPropertyNames,vi=Object.getOwnPropertySymbols,Fi=Object.getPrototypeOf,yi=Object.prototype.hasOwnProperty,Ni=Object.prototype.propertyIsEnumerable;var ai=(_,p,s)=>p in _?nn(_,p,{enumerable:!0,configurable:!0,writable:!0,value:s}):_[p]=s,wr=(_,p)=>{for(var s in p||(p={}))yi.call(p,s)&&ai(_,s,p[s]);if(vi)for(var s of vi(p))Ni.call(p,s)&&ai(_,s,p[s]);return _},Er=(_,p)=>Oi(_,Ui(p));var Mi=(_,p)=>()=>(p||_((p={exports:{}}).exports,p),p.exports);var Li=(_,p,s,y)=>{if(p&&typeof p=="object"||typeof p=="function")for(let P of xi(p))!yi.call(_,P)&&P!==s&&nn(_,P,{get:()=>p[P],enumerable:!(y=gi(p,P))||y.enumerable});return _};var Wi=(_,p,s)=>(s=_!=null?Ii(Fi(_)):{},Li(p||!_||!_.__esModule?nn(s,"default",{value:_,enumerable:!0}):s,_));var Ne=(_,p,s,y)=>{for(var P=y>1?void 0:y?gi(p,s):p,D=_.length-1,$;D>=0;D--)($=_[D])&&(P=(y?$(p,s,P):$(P))||P);return y&&P&&nn(p,s,P),P};var _e=(_,p,s)=>ai(_,typeof p!="symbol"?p+"":p,s);var _i=Mi((Qi,si)=>{"use strict";var Hi=Object.prototype.hasOwnProperty,we="~";function lt(){}Object.create&&(lt.prototype=Object.create(null),new lt().__proto__||(we=!1));function Bi(_,p,s){this.fn=_,this.context=p,this.once=s||!1}function bi(_,p,s,y,P){if(typeof s!="function")throw new TypeError("The listener must be a function");var D=new Bi(s,y||_,P),$=we?we+p:p;return _._events[$]?_._events[$].fn?_._events[$]=[_._events[$],D]:_._events[$].push(D):(_._events[$]=D,_._eventsCount++),_}function on(_,p){--_._eventsCount===0?_._events=new lt:delete _._events[p]}function fe(){this._events=new lt,this._eventsCount=0}fe.prototype.eventNames=function(){var p=[],s,y;if(this._eventsCount===0)return p;for(y in s=this._events)Hi.call(s,y)&&p.push(we?y.slice(1):y);return Object.getOwnPropertySymbols?p.concat(Object.getOwnPropertySymbols(s)):p};fe.prototype.listeners=function(p){var s=we?we+p:p,y=this._events[s];if(!y)return[];if(y.fn)return[y.fn];for(var P=0,D=y.length,$=new Array(D);P<D;P++)$[P]=y[P].fn;return $};fe.prototype.listenerCount=function(p){var s=we?we+p:p,y=this._events[s];return y?y.fn?1:y.length:0};fe.prototype.emit=function(p,s,y,P,D,$){var j=we?we+p:p;if(!this._events[j])return!1;var I=this._events[j],C=arguments.length,L,N;if(I.fn){switch(I.once&&this.removeListener(p,I.fn,void 0,!0),C){case 1:return I.fn.call(I.context),!0;case 2:return I.fn.call(I.context,s),!0;case 3:return I.fn.call(I.context,s,y),!0;case 4:return I.fn.call(I.context,s,y,P),!0;case 5:return I.fn.call(I.context,s,y,P,D),!0;case 6:return I.fn.call(I.context,s,y,P,D,$),!0}for(N=1,L=new Array(C-1);N<C;N++)L[N-1]=arguments[N];I.fn.apply(I.context,L)}else{var H=I.length,pe;for(N=0;N<H;N++)switch(I[N].once&&this.removeListener(p,I[N].fn,void 0,!0),C){case 1:I[N].fn.call(I[N].context);break;case 2:I[N].fn.call(I[N].context,s);break;case 3:I[N].fn.call(I[N].context,s,y);break;case 4:I[N].fn.call(I[N].context,s,y,P);break;default:if(!L)for(pe=1,L=new Array(C-1);pe<C;pe++)L[pe-1]=arguments[pe];I[N].fn.apply(I[N].context,L)}}return!0};fe.prototype.on=function(p,s,y){return bi(this,p,s,y,!1)};fe.prototype.once=function(p,s,y){return bi(this,p,s,y,!0)};fe.prototype.removeListener=function(p,s,y,P){var D=we?we+p:p;if(!this._events[D])return this;if(!s)return on(this,D),this;var $=this._events[D];if($.fn)$.fn===s&&(!P||$.once)&&(!y||$.context===y)&&on(this,D);else{for(var j=0,I=[],C=$.length;j<C;j++)($[j].fn!==s||P&&!$[j].once||y&&$[j].context!==y)&&I.push($[j]);I.length?this._events[D]=I.length===1?I[0]:I:on(this,D)}return this};fe.prototype.removeAllListeners=function(p){var s;return p?(s=we?we+p:p,this._events[s]&&on(this,s)):(this._events=new lt,this._eventsCount=0),this};fe.prototype.off=fe.prototype.removeListener;fe.prototype.addListener=fe.prototype.on;fe.prefixed=we;fe.EventEmitter=fe;typeof si!="undefined"&&(si.exports=fe)});var Ei=Wi(_i(),1),wi=Symbol("instance"),eo=Symbol("abortCtrl"),an=Symbol("cacheResult"),dt=class{constructor(p,s,y){this.oldState=p,this.newState=s,this.action=y,this.aborted=!1}abort(p){this.aborted=!0,pt.call(p,this.oldState,new Error(`action '${this.action}' aborted`))}toString(){return`${this.action}ing`}},xr=class extends Error{constructor(p,s,y){super(s),this.state=p,this.message=s,this.cause=y}};function Vi(_){return typeof _=="object"&&_&&"then"in _}var ft=new Map;function je(_,p,s={}){return(y,P,D)=>{let $=s.action||P;if(!s.context){let I=ft.get(y)||[];ft.has(y)||ft.set(y,I),I.push({from:_,to:p,action:$})}let j=D.value;D.value=function(...I){let C=this;if(s.context&&(C=ce.get(typeof s.context=="function"?s.context.call(this,...I):s.context)),C.state===p)return s.sync?C[an]:Promise.resolve(C[an]);C.state instanceof dt&&C.state.action==s.abortAction&&C.state.abort(C);let L=null;Array.isArray(_)?_.length==0?C.state instanceof dt&&C.state.abort(C):(typeof C.state!="string"||!_.includes(C.state))&&(L=new xr(C._state,`${C.name} ${$} to ${p} failed: current state ${C._state} not from ${_.join("|")}`)):_!==C.state&&(L=new xr(C._state,`${C.name} ${$} to ${p} failed: current state ${C._state} not from ${_}`));let N=K=>{if(s.fail&&s.fail.call(this,K),s.sync){if(s.ignoreError)return K;throw K}else return s.ignoreError?Promise.resolve(K):Promise.reject(K)};if(L)return N(L);let H=C.state,pe=new dt(H,p,$);pt.call(C,pe);let ke=K=>{var Ge;return C[an]=K,pe.aborted||(pt.call(C,p),(Ge=s.success)===null||Ge===void 0||Ge.call(this,C[an])),K},Me=K=>(pt.call(C,H,K),N(K));try{let K=j.apply(this,I);return Vi(K)?K.then(ke).catch(Me):s.sync?ke(K):Promise.resolve(ke(K))}catch(K){return Me(new xr(C._state,`${C.name} ${$} from ${_} to ${p} failed: ${K}`,K instanceof Error?K:new Error(String(K))))}}}}function Ti(..._){return(p,s,y)=>{let P=y.value,D=s;y.value=function(...$){if(!_.includes(this.state.toString()))throw new xr(this.state,`${this.name} ${D} failed: current state ${this.state} not in ${_}`);return P.apply(this,$)}}}var ji=typeof window!="undefined"&&window.__AFSM__?(s,y)=>{window.dispatchEvent(new CustomEvent(s,{detail:y}))}:typeof importScripts!="undefined"?(s,y)=>{postMessage({type:s,payload:y})}:()=>{};function pt(_,p){let s=this._state;this._state=_;let y=_.toString();_&&this.emit(y,s),this.emit(ce.STATECHANGED,_,s,p),this.updateDevTools({value:_,old:s,err:p instanceof Error?p.message:String(p)})}var ce=class _ extends Ei.default{constructor(p,s,y){super(),this.name=p,this.groupName=s,this._state=_.INIT,p||(p=Date.now().toString(36)),y?Object.setPrototypeOf(this,y):y=Object.getPrototypeOf(this),s||(this.groupName=this.constructor.name);let P=y[wi];P?this.name=P.name+"-"+P.count++:y[wi]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){let p=Object.getPrototypeOf(this),s=ft.get(p)||[],y=new Set,P=[],D=[],$=new Set,j=Object.getPrototypeOf(p);ft.has(j)&&(j.stateDiagram.forEach(C=>y.add(C)),j.allStates.forEach(C=>$.add(C))),s.forEach(({from:C,to:L,action:N})=>{typeof C=="string"?P.push({from:C,to:L,action:N}):C.length?C.forEach(H=>{P.push({from:H,to:L,action:N})}):D.push({to:L,action:N})}),P.forEach(({from:C,to:L,action:N})=>{$.add(C),$.add(L),$.add(N+"ing"),y.add(`${C} --> ${N}ing : ${N}`),y.add(`${N}ing --> ${L} : ${N} \u{1F7E2}`),y.add(`${N}ing --> ${C} : ${N} \u{1F534}`)}),D.forEach(({to:C,action:L})=>{y.add(`${L}ing --> ${C} : ${L} \u{1F7E2}`),$.forEach(N=>{N!==C&&y.add(`${N} --> ${L}ing : ${L}`)})});let I=[...y];return Object.defineProperties(p,{stateDiagram:{value:I},allStates:{value:$}}),I}static get(p){let s;return typeof p=="string"?(s=_.instances.get(p),s||_.instances.set(p,s=new _(p,void 0,Object.create(_.prototype)))):(s=_.instances2.get(p),s||_.instances2.set(p,s=new _(p.constructor.name,void 0,Object.create(_.prototype)))),s}static getState(p){var s;return(s=_.get(p))===null||s===void 0?void 0:s.state}updateDevTools(p={}){ji(_.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},p))}get state(){return this._state}set state(p){pt.call(this,p)}};ce.STATECHANGED="stateChanged";ce.UPDATEAFSM="updateAFSM";ce.INIT="[*]";ce.ON="on";ce.OFF="off";ce.instances=new Map;ce.instances2=new WeakMap;var ir=class extends ce{constructor(){super(...arguments);_e(this,"decoder");_e(this,"config")}async initialize(){this.decoder=new VideoDecoder({output:s=>{this.emit("videoFrame",s)},error:s=>{this.close(),this.emit("error",s)}})}configure(s){this.config=s,this.decoder.configure(Er(wr({},s),{codec:this.getCodec(s)}))}getCodec(s){switch(s.codec){case"hevc":return"hvc1.1.6.L0.12.34.56.78.9A.BC";case"av1":return"av01.0.05M.08";case"avc":return"avc1.420028";default:return s.codec}}decode(s){this.decoder.state==="configured"&&this.decoder.decode(new EncodedVideoChunk(s))}flush(){this.decoder.flush()}reset(){this.decoder.reset()}close(){this.decoder.state!=="closed"&&this.decoder.close()}};Ne([je([ce.INIT,"closed"],"initialized")],ir.prototype,"initialize",1),Ne([je("initialized","configured",{sync:!0})],ir.prototype,"configure",1),Ne([Ti("configured")],ir.prototype,"decode",1),Ne([je([],ce.INIT)],ir.prototype,"reset",1),Ne([je([],"closed",{ignoreError:!0,sync:!0})],ir.prototype,"close",1);function Gi(){var _;self.onmessage=p=>{if(p.data.type==="init"){let{canvas:s,wasmScript:y,wasmBinary:P}=p.data,D=s==null?void 0:s.getContext("2d"),$=0,j=0,I={wasmBinary:P,postRun:()=>{_=new I.VideoDecoder({videoInfo(C,L){$=C,j=L,console.log("video info",C,L)},yuvData(C,L){let N=$*j,H=N>>2,pe=I.HEAPU32[C>>2],ke=I.HEAPU32[(C>>2)+1],Me=I.HEAPU32[(C>>2)+2],K=I.HEAPU8.subarray(pe,pe+N),Ge=I.HEAPU8.subarray(ke,ke+H),lr=I.HEAPU8.subarray(Me,Me+H),ae=new Uint8Array(N+H+H);ae.set(K),ae.set(Ge,N),ae.set(lr,N+H);let me=new VideoFrame(ae,{codedWidth:$,codedHeight:j,format:"I420",timestamp:L});s?(D==null||D.drawImage(me,0,0,s.width,s.height),D==null||D.commit()):self.postMessage({type:"yuvData",videoFrame:me},[me])}}),self.postMessage({type:"ready"})}};Function("var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;return "+y)()(I)}else if(p.data.type==="decode"){let{packet:s}=p.data;_==null||_.decode(s.data,s.type=="key",s.timestamp)}else if(p.data.type==="setCodec"){let{codec:s,format:y,description:P}=p.data;_==null||_.setCodec(s,y,P!=null?P:"")}}}var ze=class extends ce{constructor(s,y,P=!1,D,$=!1){super();this.createModule=s;this.wasmBinary=y;this.workerMode=P;this.canvas=D;this.yuvMode=$;_e(this,"worker");_e(this,"decoder");_e(this,"config");_e(this,"module",{});_e(this,"width",0);_e(this,"height",0)}async initialize(s){var P;if(this.workerMode){let D=new RegExp("\\{(.+)\\}","s").exec(Gi.toString())[1];this.worker=new Worker(URL.createObjectURL(new Blob([D],{type:"text/javascript"})));let $=(P=this.canvas)==null?void 0:P.transferControlToOffscreen(),j=await this.wasmBinary;return console.warn("worker mode",j),this.worker.postMessage({type:"init",canvas:$,wasmScript:this.createModule.toString(),wasmBinary:j},$?[$,j]:[j]),new Promise(I=>{this.worker.onmessage=C=>{if(C.data.type==="ready")delete this.wasmBinary,I(),console.warn("worker mode initialize success");else if(C.data.type==="yuvData"){let{videoFrame:L}=C.data;this.emit("videoFrame",L)}}})}let y=this.module;return this.wasmBinary&&(y.wasmBinary=await this.wasmBinary),y.print=D=>console.log(D),y.printErr=D=>console.log(`[JS] ERROR: ${D}`),y.onAbort=()=>console.log("[JS] FATAL: WASM ABORTED"),new Promise(D=>{y.postRun=$=>{this.decoder=new this.module.VideoDecoder(this),console.log("video soft decoder initialize success"),D()},s&&Object.assign(y,s),this.createModule(y)})}configure(s){var y,P,D;this.config=s,(P=this.decoder)==null||P.setCodec(this.config.codec,this.config.description?"avcc":"annexb",(y=this.config.description)!=null?y:""),(D=this.worker)==null||D.postMessage({type:"setCodec",codec:this.config.codec,format:this.config.description?"avcc":"annexb",description:this.config.description})}decode(s){var y,P;(y=this.decoder)==null||y.decode(s.data,s.type=="key",s.timestamp),this.state==="configured"&&((P=this.worker)==null||P.postMessage({type:"decode",packet:s}))}flush(){}reset(){this.config=void 0,this.decoder&&this.decoder.clear()}close(){this.removeAllListeners(),this.decoder&&(this.decoder.clear(),this.decoder.delete())}videoInfo(s,y){this.width=s,this.height=y;let P={width:s,height:y};this.emit("videoCodecInfo",P)}yuvData(s,y){if(!this.module)return;let P=this.width*this.height,D=P>>2,$=this.module.HEAPU32[s>>2],j=this.module.HEAPU32[(s>>2)+1],I=this.module.HEAPU32[(s>>2)+2],C=this.module.HEAPU8.subarray($,$+P),L=this.module.HEAPU8.subarray(j,j+D),N=this.module.HEAPU8.subarray(I,I+D);if(this.yuvMode){this.emit("videoFrame",[C,L,N]);return}let H=new Uint8Array(P+D+D);H.set(C),H.set(L,P),H.set(N,P+D),this.emit("videoFrame",new VideoFrame(H,{codedWidth:this.width,codedHeight:this.height,format:"I420",timestamp:y}))}errorInfo(s){let y={errMsg:s};this.emit("error",y)}};Ne([je([ce.INIT,"closed"],"initialized")],ze.prototype,"initialize",1),Ne([je("initialized","configured")],ze.prototype,"configure",1),Ne([je([],ce.INIT)],ze.prototype,"reset",1),Ne([je([],"closed")],ze.prototype,"close",1);var qi=(()=>{var _=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return function(p={}){var s=p,y,P;s.ready=new Promise((e,r)=>{y=e,P=r});var D=Object.assign({},s),$=[],j="./this.program",I=(e,r)=>{throw r},C=typeof window=="object",L=typeof importScripts=="function",N=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",H="";function pe(e){return s.locateFile?s.locateFile(e,H):H+e}var ke,Me,K,Ge;(C||L)&&(L?H=self.location.href:typeof document!="undefined"&&document.currentScript&&(H=document.currentScript.src),_&&(H=_),H.indexOf("blob:")!==0?H=H.substr(0,H.replace(/[?#].*/,"").lastIndexOf("/")+1):H="",ke=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.send(null),r.responseText},L&&(K=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),Me=(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)},Ge=e=>document.title=e);var lr=s.print||console.log.bind(console),ae=s.printErr||console.error.bind(console);Object.assign(s,D),D=null,s.arguments&&($=s.arguments),s.thisProgram&&(j=s.thisProgram),s.quit&&(I=s.quit);var me;s.wasmBinary&&(me=s.wasmBinary);var Ci=s.noExitRuntime||!0;typeof WebAssembly!="object"&&Le("no native wasm support detected");var Fr,ee,Nr=!1,ln;function qe(e,r){e||Le(r)}var J,oe,Te,Pe,U,X,Mr,mt;function ht(){var e=Fr.buffer;s.HEAP8=J=new Int8Array(e),s.HEAP16=Te=new Int16Array(e),s.HEAP32=U=new Int32Array(e),s.HEAPU8=oe=new Uint8Array(e),s.HEAPU16=Pe=new Uint16Array(e),s.HEAPU32=X=new Uint32Array(e),s.HEAPF32=Mr=new Float32Array(e),s.HEAPF64=mt=new Float64Array(e)}var Lr,Wr=[],Hr=[],vt=[],dn=!1;function fn(){if(s.preRun)for(typeof s.preRun=="function"&&(s.preRun=[s.preRun]);s.preRun.length;)hn(s.preRun.shift());zr(Wr)}function pn(){dn=!0,!s.noFSInit&&!a.init.initialized&&a.init(),a.ignorePermissions=!1,We.init(),zr(Hr)}function mn(){if(s.postRun)for(typeof s.postRun=="function"&&(s.postRun=[s.postRun]);s.postRun.length;)Xe(s.postRun.shift());zr(vt)}function hn(e){Wr.unshift(e)}function vn(e){Hr.unshift(e)}function Xe(e){vt.unshift(e)}var Re=0,Ke=null,dr=null;function ci(e){return e}function or(e){Re++,s.monitorRunDependencies&&s.monitorRunDependencies(Re)}function Tr(e){if(Re--,s.monitorRunDependencies&&s.monitorRunDependencies(Re),Re==0&&(Ke!==null&&(clearInterval(Ke),Ke=null),dr)){var r=dr;dr=null,r()}}function Le(e){s.onAbort&&s.onAbort(e),e="Aborted("+e+")",ae(e),Nr=!0,ln=1,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw P(r),r}var ar="data:application/octet-stream;base64,";function Br(e){return e.startsWith(ar)}var sr;sr="videodec.wasm",Br(sr)||(sr=pe(sr));function Vr(e){if(e==sr&&me)return new Uint8Array(me);if(K)return K(e);throw"both async and sync fetching of the wasm failed"}function gn(e){return!me&&(C||L)&&typeof fetch=="function"?fetch(e,{credentials:"same-origin"}).then(r=>{if(!r.ok)throw"failed to load wasm binary file at '"+e+"'";return r.arrayBuffer()}).catch(()=>Vr(e)):Promise.resolve().then(()=>Vr(e))}function gt(e,r,t){return gn(e).then(n=>WebAssembly.instantiate(n,r)).then(n=>n).then(t,n=>{ae("failed to asynchronously prepare wasm: "+n),Le(n)})}function jr(e,r,t,n){return!e&&typeof WebAssembly.instantiateStreaming=="function"&&!Br(r)&&typeof fetch=="function"?fetch(r,{credentials:"same-origin"}).then(u=>{var l=WebAssembly.instantiateStreaming(u,t);return l.then(n,function(f){return ae("wasm streaming compile failed: "+f),ae("falling back to ArrayBuffer instantiation"),gt(r,t,n)})}):gt(r,t,n)}function yn(){var e={a:ki};function r(n,u){var l=n.exports;return ee=l,Fr=ee.E,ht(),Lr=ee.H,vn(ee.F),Tr("wasm-instantiate"),l}or("wasm-instantiate");function t(n){r(n.instance)}if(s.instantiateWasm)try{return s.instantiateWasm(e,r)}catch(n){ae("Module.instantiateWasm callback failed with error: "+n),P(n)}return jr(me,sr,e,t).catch(P),{}}var x,Q,zr=e=>{for(;e.length>0;)e.shift()(s)};function bn(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(r){X[this.ptr+4>>2]=r},this.get_type=function(){return X[this.ptr+4>>2]},this.set_destructor=function(r){X[this.ptr+8>>2]=r},this.get_destructor=function(){return X[this.ptr+8>>2]},this.set_caught=function(r){r=r?1:0,J[this.ptr+12>>0]=r},this.get_caught=function(){return J[this.ptr+12>>0]!=0},this.set_rethrown=function(r){r=r?1:0,J[this.ptr+13>>0]=r},this.get_rethrown=function(){return J[this.ptr+13>>0]!=0},this.init=function(r,t){this.set_adjusted_ptr(0),this.set_type(r),this.set_destructor(t)},this.set_adjusted_ptr=function(r){X[this.ptr+16>>2]=r},this.get_adjusted_ptr=function(){return X[this.ptr+16>>2]},this.get_exception_ptr=function(){var r=mi(this.get_type());if(r)return X[this.excPtr>>2];var t=this.get_adjusted_ptr();return t!==0?t:this.excPtr}}var Pr=0,_n=0;function yt(e,r,t){var n=new bn(e);throw n.init(r,t),Pr=e,_n++,Pr}var he=e=>(U[fi()>>2]=e,e),z={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 u=e[n];u==="."?e.splice(n,1):u===".."?(e.splice(n,1),t++):t&&(e.splice(n,1),t--)}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=z.isAbs(e),t=e.substr(-1)==="/";return e=z.normalizeArray(e.split("/").filter(n=>!!n),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=z.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=z.normalize(e),e=e.replace(/\/$/,"");var r=e.lastIndexOf("/");return r===-1?e:e.substr(r+1)},join:function(){var e=Array.prototype.slice.call(arguments);return z.normalize(e.join("/"))},join2:(e,r)=>z.normalize(e+"/"+r)},Je=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return e=>crypto.getRandomValues(e);Le("initRandomDevice")},fr=e=>(fr=Je())(e),le={resolve:function(){for(var e="",r=!1,t=arguments.length-1;t>=-1&&!r;t--){var n=t>=0?arguments[t]:a.cwd();if(typeof n!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!n)return"";e=n+"/"+e,r=z.isAbs(n)}return e=z.normalizeArray(e.split("/").filter(u=>!!u),!r).join("/"),(r?"/":"")+e||"."},relative:(e,r)=>{e=le.resolve(e).substr(1),r=le.resolve(r).substr(1);function t(h){for(var A=0;A<h.length&&h[A]==="";A++);for(var O=h.length-1;O>=0&&h[O]==="";O--);return A>O?[]:h.slice(A,O-A+1)}for(var n=t(e.split("/")),u=t(r.split("/")),l=Math.min(n.length,u.length),f=l,d=0;d<l;d++)if(n[d]!==u[d]){f=d;break}for(var g=[],d=f;d<n.length;d++)g.push("..");return g=g.concat(u.slice(f)),g.join("/")}},G=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):void 0,Ye=(e,r,t)=>{for(var n=r+t,u=r;e[u]&&!(u>=n);)++u;if(u-r>16&&e.buffer&&G)return G.decode(e.subarray(r,u));for(var l="";r<u;){var f=e[r++];if(!(f&128)){l+=String.fromCharCode(f);continue}var d=e[r++]&63;if((f&224)==192){l+=String.fromCharCode((f&31)<<6|d);continue}var g=e[r++]&63;if((f&240)==224?f=(f&15)<<12|d<<6|g:f=(f&7)<<18|d<<12|g<<6|e[r++]&63,f<65536)l+=String.fromCharCode(f);else{var h=f-65536;l+=String.fromCharCode(55296|h>>10,56320|h&1023)}}return l},ur=[],Ze=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n<=127?r++:n<=2047?r+=2:n>=55296&&n<=57343?(r+=4,++t):r+=3}return r},Gr=(e,r,t,n)=>{if(!(n>0))return 0;for(var u=t,l=t+n-1,f=0;f<e.length;++f){var d=e.charCodeAt(f);if(d>=55296&&d<=57343){var g=e.charCodeAt(++f);d=65536+((d&1023)<<10)|g&1023}if(d<=127){if(t>=l)break;r[t++]=d}else if(d<=2047){if(t+1>=l)break;r[t++]=192|d>>6,r[t++]=128|d&63}else if(d<=65535){if(t+2>=l)break;r[t++]=224|d>>12,r[t++]=128|d>>6&63,r[t++]=128|d&63}else{if(t+3>=l)break;r[t++]=240|d>>18,r[t++]=128|d>>12&63,r[t++]=128|d>>6&63,r[t++]=128|d&63}}return r[t]=0,t-u};function Se(e,r,t){var n=t>0?t:Ze(e)+1,u=new Array(n),l=Gr(e,u,0,u.length);return r&&(u.length=l),u}var wn=()=>{if(!ur.length){var e=null;if(typeof window!="undefined"&&typeof window.prompt=="function"?(e=window.prompt("Input: "),e!==null&&(e+=`
2
2
  `)):typeof readline=="function"&&(e=readline(),e!==null&&(e+=`
3
- `)),!e)return null;ur=Se(e,!0)}return ur.shift()},We={ttys:[],init:function(){},shutdown:function(){},register:function(e,r){We.ttys[e]={input:[],output:[],ops:r},a.registerDevice(e,We.stream_ops)},stream_ops:{open:function(e){var r=We.ttys[e.node.rdev];if(!r)throw new a.ErrnoError(43);e.tty=r,e.seekable=!1},close:function(e){e.tty.ops.fsync(e.tty)},fsync:function(e){e.tty.ops.fsync(e.tty)},read:function(e,r,t,n,u){if(!e.tty||!e.tty.ops.get_char)throw new a.ErrnoError(60);for(var l=0,f=0;f<n;f++){var d;try{d=e.tty.ops.get_char(e.tty)}catch(g){throw new a.ErrnoError(29)}if(d===void 0&&l===0)throw new a.ErrnoError(6);if(d==null)break;l++,r[t+f]=d}return l&&(e.node.timestamp=Date.now()),l},write:function(e,r,t,n,u){if(!e.tty||!e.tty.ops.put_char)throw new a.ErrnoError(60);try{for(var l=0;l<n;l++)e.tty.ops.put_char(e.tty,r[t+l])}catch(f){throw new a.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),l}},default_tty_ops:{get_char:function(e){return wn()},put_char:function(e,r){r===null||r===10?(lr(Ye(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},fsync:function(e){e.output&&e.output.length>0&&(lr(Ye(e.output,0)),e.output=[])},ioctl_tcgets:function(e){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets:function(e,r,t){return 0},ioctl_tiocgwinsz:function(e){return[24,80]}},default_tty1_ops:{put_char:function(e,r){r===null||r===10?(ae(Ye(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},fsync:function(e){e.output&&e.output.length>0&&(ae(Ye(e.output,0)),e.output=[])}}},bt=e=>{Le()},M={ops_table:null,mount(e){return M.createNode(null,"/",16895,0)},createNode(e,r,t,n){if(a.isBlkdev(t)||a.isFIFO(t))throw new a.ErrnoError(63);M.ops_table||(M.ops_table={dir:{node:{getattr:M.node_ops.getattr,setattr:M.node_ops.setattr,lookup:M.node_ops.lookup,mknod:M.node_ops.mknod,rename:M.node_ops.rename,unlink:M.node_ops.unlink,rmdir:M.node_ops.rmdir,readdir:M.node_ops.readdir,symlink:M.node_ops.symlink},stream:{llseek:M.stream_ops.llseek}},file:{node:{getattr:M.node_ops.getattr,setattr:M.node_ops.setattr},stream:{llseek:M.stream_ops.llseek,read:M.stream_ops.read,write:M.stream_ops.write,allocate:M.stream_ops.allocate,mmap:M.stream_ops.mmap,msync:M.stream_ops.msync}},link:{node:{getattr:M.node_ops.getattr,setattr:M.node_ops.setattr,readlink:M.node_ops.readlink},stream:{}},chrdev:{node:{getattr:M.node_ops.getattr,setattr:M.node_ops.setattr},stream:a.chrdev_stream_ops}});var u=a.createNode(e,r,t,n);return a.isDir(u.mode)?(u.node_ops=M.ops_table.dir.node,u.stream_ops=M.ops_table.dir.stream,u.contents={}):a.isFile(u.mode)?(u.node_ops=M.ops_table.file.node,u.stream_ops=M.ops_table.file.stream,u.usedBytes=0,u.contents=null):a.isLink(u.mode)?(u.node_ops=M.ops_table.link.node,u.stream_ops=M.ops_table.link.stream):a.isChrdev(u.mode)&&(u.node_ops=M.ops_table.chrdev.node,u.stream_ops=M.ops_table.chrdev.stream),u.timestamp=Date.now(),e&&(e.contents[r]=u,e.timestamp=u.timestamp),u},getFileDataAsTypedArray(e){return e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0)},expandFileStorage(e,r){var t=e.contents?e.contents.length:0;if(!(t>=r)){var n=1024*1024;r=Math.max(r,t*(t<n?2:1.125)>>>0),t!=0&&(r=Math.max(r,256));var u=e.contents;e.contents=new Uint8Array(r),e.usedBytes>0&&e.contents.set(u.subarray(0,e.usedBytes),0)}},resizeFileStorage(e,r){if(e.usedBytes!=r)if(r==0)e.contents=null,e.usedBytes=0;else{var t=e.contents;e.contents=new Uint8Array(r),t&&e.contents.set(t.subarray(0,Math.min(r,e.usedBytes))),e.usedBytes=r}},node_ops:{getattr(e){var r={};return r.dev=a.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,a.isDir(e.mode)?r.size=4096:a.isFile(e.mode)?r.size=e.usedBytes:a.isLink(e.mode)?r.size=e.link.length:r.size=0,r.atime=new Date(e.timestamp),r.mtime=new Date(e.timestamp),r.ctime=new Date(e.timestamp),r.blksize=4096,r.blocks=Math.ceil(r.size/r.blksize),r},setattr(e,r){r.mode!==void 0&&(e.mode=r.mode),r.timestamp!==void 0&&(e.timestamp=r.timestamp),r.size!==void 0&&M.resizeFileStorage(e,r.size)},lookup(e,r){throw a.genericErrors[44]},mknod(e,r,t,n){return M.createNode(e,r,t,n)},rename(e,r,t){if(a.isDir(e.mode)){var n;try{n=a.lookupNode(r,t)}catch(l){}if(n)for(var u in n.contents)throw new a.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=t,r.contents[t]=e,r.timestamp=e.parent.timestamp,e.parent=r},unlink(e,r){delete e.contents[r],e.timestamp=Date.now()},rmdir(e,r){var t=a.lookupNode(e,r);for(var n in t.contents)throw new a.ErrnoError(55);delete e.contents[r],e.timestamp=Date.now()},readdir(e){var r=[".",".."];for(var t in e.contents)e.contents.hasOwnProperty(t)&&r.push(t);return r},symlink(e,r,t){var n=M.createNode(e,r,41471,0);return n.link=t,n},readlink(e){if(!a.isLink(e.mode))throw new a.ErrnoError(28);return e.link}},stream_ops:{read(e,r,t,n,u){var l=e.node.contents;if(u>=e.node.usedBytes)return 0;var f=Math.min(e.node.usedBytes-u,n);if(f>8&&l.subarray)r.set(l.subarray(u,u+f),t);else for(var d=0;d<f;d++)r[t+d]=l[u+d];return f},write(e,r,t,n,u,l){if(!n)return 0;var f=e.node;if(f.timestamp=Date.now(),r.subarray&&(!f.contents||f.contents.subarray)){if(l)return f.contents=r.subarray(t,t+n),f.usedBytes=n,n;if(f.usedBytes===0&&u===0)return f.contents=r.slice(t,t+n),f.usedBytes=n,n;if(u+n<=f.usedBytes)return f.contents.set(r.subarray(t,t+n),u),n}if(M.expandFileStorage(f,u+n),f.contents.subarray&&r.subarray)f.contents.set(r.subarray(t,t+n),u);else for(var d=0;d<n;d++)f.contents[u+d]=r[t+d];return f.usedBytes=Math.max(f.usedBytes,u+n),n},llseek(e,r,t){var n=r;if(t===1?n+=e.position:t===2&&a.isFile(e.node.mode)&&(n+=e.node.usedBytes),n<0)throw new a.ErrnoError(28);return n},allocate(e,r,t){M.expandFileStorage(e.node,r+t),e.node.usedBytes=Math.max(e.node.usedBytes,r+t)},mmap(e,r,t,n,u){if(!a.isFile(e.node.mode))throw new a.ErrnoError(43);var l,f,d=e.node.contents;if(!(u&2)&&d.buffer===J.buffer)f=!1,l=d.byteOffset;else{if((t>0||t+r<d.length)&&(d.subarray?d=d.subarray(t,t+r):d=Array.prototype.slice.call(d,t,t+r)),f=!0,l=bt(r),!l)throw new a.ErrnoError(48);J.set(d,l)}return{ptr:l,allocated:f}},msync(e,r,t,n,u){return M.stream_ops.write(e,r,0,n,t,!1),0}}},qr=(e,r,t,n)=>{var u=n?"":`al ${e}`;Me(e,l=>{qe(l,`Loading data file "${e}" failed (no arrayBuffer).`),r(new Uint8Array(l)),u&&Tr(u)},l=>{if(t)t();else throw`Loading data file "${e}" failed.`}),u&&or(u)},_t=s.preloadPlugins||[];function En(e,r,t,n){typeof Browser!="undefined"&&Browser.init();var u=!1;return _t.forEach(function(l){u||l.canHandle(r)&&(l.handle(e,r,t,n),u=!0)}),u}function wt(e,r,t,n,u,l,f,d,g,h){var A=r?le.resolve(z.join2(e,r)):e,O=`cp ${A}`;function R(S){function F(Z){h&&h(),d||a.createDataFile(e,r,Z,n,u,g),l&&l(),Tr(O)}En(S,A,F,()=>{f&&f(),Tr(O)})||F(S)}or(O),typeof t=="string"?qr(t,S=>R(S),f):R(t)}function Et(e){var r={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},t=r[e];if(typeof t=="undefined")throw new Error(`Unknown file open mode: ${e}`);return t}function Sr(e,r){var t=0;return e&&(t|=365),r&&(t|=146),t}var a={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=le.resolve(e),!e)return{path:"",node:null};var t={follow_mount:!0,recurse_count:0};if(r=Object.assign(t,r),r.recurse_count>8)throw new a.ErrnoError(32);for(var n=e.split("/").filter(O=>!!O),u=a.root,l="/",f=0;f<n.length;f++){var d=f===n.length-1;if(d&&r.parent)break;if(u=a.lookupNode(u,n[f]),l=z.join2(l,n[f]),a.isMountpoint(u)&&(!d||d&&r.follow_mount)&&(u=u.mounted.root),!d||r.follow)for(var g=0;a.isLink(u.mode);){var h=a.readlink(l);l=le.resolve(z.dirname(l),h);var A=a.lookupPath(l,{recurse_count:r.recurse_count+1});if(u=A.node,g++>40)throw new a.ErrnoError(32)}}return{path:l,node:u}},getPath:e=>{for(var r;;){if(a.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)%a.nameTable.length},hashAddNode:e=>{var r=a.hashName(e.parent.id,e.name);e.name_next=a.nameTable[r],a.nameTable[r]=e},hashRemoveNode:e=>{var r=a.hashName(e.parent.id,e.name);if(a.nameTable[r]===e)a.nameTable[r]=e.name_next;else for(var t=a.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next}},lookupNode:(e,r)=>{var t=a.mayLookup(e);if(t)throw new a.ErrnoError(t,e);for(var n=a.hashName(e.id,r),u=a.nameTable[n];u;u=u.name_next){var l=u.name;if(u.parent.id===e.id&&l===r)return u}return a.lookup(e,r)},createNode:(e,r,t,n)=>{var u=new a.FSNode(e,r,t,n);return a.hashAddNode(u),u},destroyNode:e=>{a.hashRemoveNode(e)},isRoot:e=>e===e.parent,isMountpoint:e=>!!e.mounted,isFile:e=>(e&61440)===32768,isDir:e=>(e&61440)===16384,isLink:e=>(e&61440)===40960,isChrdev:e=>(e&61440)===8192,isBlkdev:e=>(e&61440)===24576,isFIFO:e=>(e&61440)===4096,isSocket:e=>(e&49152)===49152,flagsToPermissionString:e=>{var r=["r","w","rw"][e&3];return e&512&&(r+="w"),r},nodePermissions:(e,r)=>a.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=a.nodePermissions(e,"x");return r||(e.node_ops.lookup?0:2)},mayCreate:(e,r)=>{try{var t=a.lookupNode(e,r);return 20}catch(n){}return a.nodePermissions(e,"wx")},mayDelete:(e,r,t)=>{var n;try{n=a.lookupNode(e,r)}catch(l){return l.errno}var u=a.nodePermissions(e,"wx");if(u)return u;if(t){if(!a.isDir(n.mode))return 54;if(a.isRoot(n)||a.getPath(n)===a.cwd())return 10}else if(a.isDir(n.mode))return 31;return 0},mayOpen:(e,r)=>e?a.isLink(e.mode)?32:a.isDir(e.mode)&&(a.flagsToPermissionString(r)!=="r"||r&512)?31:a.nodePermissions(e,a.flagsToPermissionString(r)):44,MAX_OPEN_FDS:4096,nextfd:()=>{for(var e=0;e<=a.MAX_OPEN_FDS;e++)if(!a.streams[e])return e;throw new a.ErrnoError(33)},getStreamChecked:e=>{var r=a.getStream(e);if(!r)throw new a.ErrnoError(8);return r},getStream:e=>a.streams[e],createStream:(e,r=-1)=>(a.FSStream||(a.FSStream=function(){this.shared={}},a.FSStream.prototype={},Object.defineProperties(a.FSStream.prototype,{object:{get(){return this.node},set(t){this.node=t}},isRead:{get(){return(this.flags&2097155)!==1}},isWrite:{get(){return(this.flags&2097155)!==0}},isAppend:{get(){return this.flags&1024}},flags:{get(){return this.shared.flags},set(t){this.shared.flags=t}},position:{get(){return this.shared.position},set(t){this.shared.position=t}}})),e=Object.assign(new a.FSStream,e),r==-1&&(r=a.nextfd()),e.fd=r,a.streams[r]=e,e),closeStream:e=>{a.streams[e]=null},chrdev_stream_ops:{open:e=>{var r=a.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:()=>{throw new a.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,r)=>e<<8|r,registerDevice:(e,r)=>{a.devices[e]={stream_ops:r}},getDevice:e=>a.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),a.syncFSRequests++,a.syncFSRequests>1&&ae(`warning: ${a.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var t=a.getMounts(a.root.mount),n=0;function u(f){return a.syncFSRequests--,r(f)}function l(f){if(f)return l.errored?void 0:(l.errored=!0,u(f));++n>=t.length&&u(null)}t.forEach(f=>{if(!f.type.syncfs)return l(null);f.type.syncfs(f,e,l)})},mount:(e,r,t)=>{var n=t==="/",u=!t,l;if(n&&a.root)throw new a.ErrnoError(10);if(!n&&!u){var f=a.lookupPath(t,{follow_mount:!1});if(t=f.path,l=f.node,a.isMountpoint(l))throw new a.ErrnoError(10);if(!a.isDir(l.mode))throw new a.ErrnoError(54)}var d={type:e,opts:r,mountpoint:t,mounts:[]},g=e.mount(d);return g.mount=d,d.root=g,n?a.root=g:l&&(l.mounted=d,l.mount&&l.mount.mounts.push(d)),g},unmount:e=>{var r=a.lookupPath(e,{follow_mount:!1});if(!a.isMountpoint(r.node))throw new a.ErrnoError(28);var t=r.node,n=t.mounted,u=a.getMounts(n);Object.keys(a.nameTable).forEach(f=>{for(var d=a.nameTable[f];d;){var g=d.name_next;u.includes(d.mount)&&a.destroyNode(d),d=g}}),t.mounted=null;var l=t.mount.mounts.indexOf(n);t.mount.mounts.splice(l,1)},lookup:(e,r)=>e.node_ops.lookup(e,r),mknod:(e,r,t)=>{var n=a.lookupPath(e,{parent:!0}),u=n.node,l=z.basename(e);if(!l||l==="."||l==="..")throw new a.ErrnoError(28);var f=a.mayCreate(u,l);if(f)throw new a.ErrnoError(f);if(!u.node_ops.mknod)throw new a.ErrnoError(63);return u.node_ops.mknod(u,l,r,t)},create:(e,r)=>(r=r!==void 0?r:438,r&=4095,r|=32768,a.mknod(e,r,0)),mkdir:(e,r)=>(r=r!==void 0?r:511,r&=1023,r|=16384,a.mknod(e,r,0)),mkdirTree:(e,r)=>{for(var t=e.split("/"),n="",u=0;u<t.length;++u)if(t[u]){n+="/"+t[u];try{a.mkdir(n,r)}catch(l){if(l.errno!=20)throw l}}},mkdev:(e,r,t)=>(typeof t=="undefined"&&(t=r,r=438),r|=8192,a.mknod(e,r,t)),symlink:(e,r)=>{if(!le.resolve(e))throw new a.ErrnoError(44);var t=a.lookupPath(r,{parent:!0}),n=t.node;if(!n)throw new a.ErrnoError(44);var u=z.basename(r),l=a.mayCreate(n,u);if(l)throw new a.ErrnoError(l);if(!n.node_ops.symlink)throw new a.ErrnoError(63);return n.node_ops.symlink(n,u,e)},rename:(e,r)=>{var t=z.dirname(e),n=z.dirname(r),u=z.basename(e),l=z.basename(r),f,d,g;if(f=a.lookupPath(e,{parent:!0}),d=f.node,f=a.lookupPath(r,{parent:!0}),g=f.node,!d||!g)throw new a.ErrnoError(44);if(d.mount!==g.mount)throw new a.ErrnoError(75);var h=a.lookupNode(d,u),A=le.relative(e,n);if(A.charAt(0)!==".")throw new a.ErrnoError(28);if(A=le.relative(r,t),A.charAt(0)!==".")throw new a.ErrnoError(55);var O;try{O=a.lookupNode(g,l)}catch(F){}if(h!==O){var R=a.isDir(h.mode),S=a.mayDelete(d,u,R);if(S)throw new a.ErrnoError(S);if(S=O?a.mayDelete(g,l,R):a.mayCreate(g,l),S)throw new a.ErrnoError(S);if(!d.node_ops.rename)throw new a.ErrnoError(63);if(a.isMountpoint(h)||O&&a.isMountpoint(O))throw new a.ErrnoError(10);if(g!==d&&(S=a.nodePermissions(d,"w"),S))throw new a.ErrnoError(S);a.hashRemoveNode(h);try{d.node_ops.rename(h,g,l)}catch(F){throw F}finally{a.hashAddNode(h)}}},rmdir:e=>{var r=a.lookupPath(e,{parent:!0}),t=r.node,n=z.basename(e),u=a.lookupNode(t,n),l=a.mayDelete(t,n,!0);if(l)throw new a.ErrnoError(l);if(!t.node_ops.rmdir)throw new a.ErrnoError(63);if(a.isMountpoint(u))throw new a.ErrnoError(10);t.node_ops.rmdir(t,n),a.destroyNode(u)},readdir:e=>{var r=a.lookupPath(e,{follow:!0}),t=r.node;if(!t.node_ops.readdir)throw new a.ErrnoError(54);return t.node_ops.readdir(t)},unlink:e=>{var r=a.lookupPath(e,{parent:!0}),t=r.node;if(!t)throw new a.ErrnoError(44);var n=z.basename(e),u=a.lookupNode(t,n),l=a.mayDelete(t,n,!1);if(l)throw new a.ErrnoError(l);if(!t.node_ops.unlink)throw new a.ErrnoError(63);if(a.isMountpoint(u))throw new a.ErrnoError(10);t.node_ops.unlink(t,n),a.destroyNode(u)},readlink:e=>{var r=a.lookupPath(e),t=r.node;if(!t)throw new a.ErrnoError(44);if(!t.node_ops.readlink)throw new a.ErrnoError(28);return le.resolve(a.getPath(t.parent),t.node_ops.readlink(t))},stat:(e,r)=>{var t=a.lookupPath(e,{follow:!r}),n=t.node;if(!n)throw new a.ErrnoError(44);if(!n.node_ops.getattr)throw new a.ErrnoError(63);return n.node_ops.getattr(n)},lstat:e=>a.stat(e,!0),chmod:(e,r,t)=>{var n;if(typeof e=="string"){var u=a.lookupPath(e,{follow:!t});n=u.node}else n=e;if(!n.node_ops.setattr)throw new a.ErrnoError(63);n.node_ops.setattr(n,{mode:r&4095|n.mode&-4096,timestamp:Date.now()})},lchmod:(e,r)=>{a.chmod(e,r,!0)},fchmod:(e,r)=>{var t=a.getStreamChecked(e);a.chmod(t.node,r)},chown:(e,r,t,n)=>{var u;if(typeof e=="string"){var l=a.lookupPath(e,{follow:!n});u=l.node}else u=e;if(!u.node_ops.setattr)throw new a.ErrnoError(63);u.node_ops.setattr(u,{timestamp:Date.now()})},lchown:(e,r,t)=>{a.chown(e,r,t,!0)},fchown:(e,r,t)=>{var n=a.getStreamChecked(e);a.chown(n.node,r,t)},truncate:(e,r)=>{if(r<0)throw new a.ErrnoError(28);var t;if(typeof e=="string"){var n=a.lookupPath(e,{follow:!0});t=n.node}else t=e;if(!t.node_ops.setattr)throw new a.ErrnoError(63);if(a.isDir(t.mode))throw new a.ErrnoError(31);if(!a.isFile(t.mode))throw new a.ErrnoError(28);var u=a.nodePermissions(t,"w");if(u)throw new a.ErrnoError(u);t.node_ops.setattr(t,{size:r,timestamp:Date.now()})},ftruncate:(e,r)=>{var t=a.getStreamChecked(e);if(!(t.flags&2097155))throw new a.ErrnoError(28);a.truncate(t.node,r)},utime:(e,r,t)=>{var n=a.lookupPath(e,{follow:!0}),u=n.node;u.node_ops.setattr(u,{timestamp:Math.max(r,t)})},open:(e,r,t)=>{if(e==="")throw new a.ErrnoError(44);r=typeof r=="string"?Et(r):r,t=typeof t=="undefined"?438:t,r&64?t=t&4095|32768:t=0;var n;if(typeof e=="object")n=e;else{e=z.normalize(e);try{var u=a.lookupPath(e,{follow:!(r&131072)});n=u.node}catch(g){}}var l=!1;if(r&64)if(n){if(r&128)throw new a.ErrnoError(20)}else n=a.mknod(e,t,0),l=!0;if(!n)throw new a.ErrnoError(44);if(a.isChrdev(n.mode)&&(r&=-513),r&65536&&!a.isDir(n.mode))throw new a.ErrnoError(54);if(!l){var f=a.mayOpen(n,r);if(f)throw new a.ErrnoError(f)}r&512&&!l&&a.truncate(n,0),r&=-131713;var d=a.createStream({node:n,path:a.getPath(n),flags:r,seekable:!0,position:0,stream_ops:n.stream_ops,ungotten:[],error:!1});return d.stream_ops.open&&d.stream_ops.open(d),s.logReadFiles&&!(r&1)&&(a.readFiles||(a.readFiles={}),e in a.readFiles||(a.readFiles[e]=1)),d},close:e=>{if(a.isClosed(e))throw new a.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(r){throw r}finally{a.closeStream(e.fd)}e.fd=null},isClosed:e=>e.fd===null,llseek:(e,r,t)=>{if(a.isClosed(e))throw new a.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new a.ErrnoError(70);if(t!=0&&t!=1&&t!=2)throw new a.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read:(e,r,t,n,u)=>{if(n<0||u<0)throw new a.ErrnoError(28);if(a.isClosed(e))throw new a.ErrnoError(8);if((e.flags&2097155)===1)throw new a.ErrnoError(8);if(a.isDir(e.node.mode))throw new a.ErrnoError(31);if(!e.stream_ops.read)throw new a.ErrnoError(28);var l=typeof u!="undefined";if(!l)u=e.position;else if(!e.seekable)throw new a.ErrnoError(70);var f=e.stream_ops.read(e,r,t,n,u);return l||(e.position+=f),f},write:(e,r,t,n,u,l)=>{if(n<0||u<0)throw new a.ErrnoError(28);if(a.isClosed(e))throw new a.ErrnoError(8);if(!(e.flags&2097155))throw new a.ErrnoError(8);if(a.isDir(e.node.mode))throw new a.ErrnoError(31);if(!e.stream_ops.write)throw new a.ErrnoError(28);e.seekable&&e.flags&1024&&a.llseek(e,0,2);var f=typeof u!="undefined";if(!f)u=e.position;else if(!e.seekable)throw new a.ErrnoError(70);var d=e.stream_ops.write(e,r,t,n,u,l);return f||(e.position+=d),d},allocate:(e,r,t)=>{if(a.isClosed(e))throw new a.ErrnoError(8);if(r<0||t<=0)throw new a.ErrnoError(28);if(!(e.flags&2097155))throw new a.ErrnoError(8);if(!a.isFile(e.node.mode)&&!a.isDir(e.node.mode))throw new a.ErrnoError(43);if(!e.stream_ops.allocate)throw new a.ErrnoError(138);e.stream_ops.allocate(e,r,t)},mmap:(e,r,t,n,u)=>{if(n&2&&!(u&2)&&(e.flags&2097155)!==2)throw new a.ErrnoError(2);if((e.flags&2097155)===1)throw new a.ErrnoError(2);if(!e.stream_ops.mmap)throw new a.ErrnoError(43);return e.stream_ops.mmap(e,r,t,n,u)},msync:(e,r,t,n,u)=>e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,u):0,munmap:e=>0,ioctl:(e,r,t)=>{if(!e.stream_ops.ioctl)throw new a.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=a.open(e,r.flags),u=a.stat(e),l=u.size,f=new Uint8Array(l);return a.read(n,f,0,l,0),r.encoding==="utf8"?t=Ye(f,0):r.encoding==="binary"&&(t=f),a.close(n),t},writeFile:(e,r,t={})=>{t.flags=t.flags||577;var n=a.open(e,t.flags,t.mode);if(typeof r=="string"){var u=new Uint8Array(Ze(r)+1),l=Gr(r,u,0,u.length);a.write(n,u,0,l,void 0,t.canOwn)}else if(ArrayBuffer.isView(r))a.write(n,r,0,r.byteLength,void 0,t.canOwn);else throw new Error("Unsupported data type");a.close(n)},cwd:()=>a.currentPath,chdir:e=>{var r=a.lookupPath(e,{follow:!0});if(r.node===null)throw new a.ErrnoError(44);if(!a.isDir(r.node.mode))throw new a.ErrnoError(54);var t=a.nodePermissions(r.node,"x");if(t)throw new a.ErrnoError(t);a.currentPath=r.path},createDefaultDirectories:()=>{a.mkdir("/tmp"),a.mkdir("/home"),a.mkdir("/home/web_user")},createDefaultDevices:()=>{a.mkdir("/dev"),a.registerDevice(a.makedev(1,3),{read:()=>0,write:(n,u,l,f,d)=>f}),a.mkdev("/dev/null",a.makedev(1,3)),We.register(a.makedev(5,0),We.default_tty_ops),We.register(a.makedev(6,0),We.default_tty1_ops),a.mkdev("/dev/tty",a.makedev(5,0)),a.mkdev("/dev/tty1",a.makedev(6,0));var e=new Uint8Array(1024),r=0,t=()=>(r===0&&(r=fr(e).byteLength),e[--r]);a.createDevice("/dev","random",t),a.createDevice("/dev","urandom",t),a.mkdir("/dev/shm"),a.mkdir("/dev/shm/tmp")},createSpecialDirectories:()=>{a.mkdir("/proc");var e=a.mkdir("/proc/self");a.mkdir("/proc/self/fd"),a.mount({mount:()=>{var r=a.createNode(e,"fd",16895,73);return r.node_ops={lookup:(t,n)=>{var u=+n,l=a.getStreamChecked(u),f={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>l.path}};return f.parent=f,f}},r}},{},"/proc/self/fd")},createStandardStreams:()=>{s.stdin?a.createDevice("/dev","stdin",s.stdin):a.symlink("/dev/tty","/dev/stdin"),s.stdout?a.createDevice("/dev","stdout",null,s.stdout):a.symlink("/dev/tty","/dev/stdout"),s.stderr?a.createDevice("/dev","stderr",null,s.stderr):a.symlink("/dev/tty1","/dev/stderr");var e=a.open("/dev/stdin",0),r=a.open("/dev/stdout",1),t=a.open("/dev/stderr",1)},ensureErrnoError:()=>{a.ErrnoError||(a.ErrnoError=function(r,t){this.name="ErrnoError",this.node=t,this.setErrno=function(n){this.errno=n},this.setErrno(r),this.message="FS error"},a.ErrnoError.prototype=new Error,a.ErrnoError.prototype.constructor=a.ErrnoError,[44].forEach(e=>{a.genericErrors[e]=new a.ErrnoError(e),a.genericErrors[e].stack="<generic error, no stack>"}))},staticInit:()=>{a.ensureErrnoError(),a.nameTable=new Array(4096),a.mount(M,{},"/"),a.createDefaultDirectories(),a.createDefaultDevices(),a.createSpecialDirectories(),a.filesystems={MEMFS:M}},init:(e,r,t)=>{a.init.initialized=!0,a.ensureErrnoError(),s.stdin=e||s.stdin,s.stdout=r||s.stdout,s.stderr=t||s.stderr,a.createStandardStreams()},quit:()=>{a.init.initialized=!1;for(var e=0;e<a.streams.length;e++){var r=a.streams[e];r&&a.close(r)}},findObject:(e,r)=>{var t=a.analyzePath(e,r);return t.exists?t.object:null},analyzePath:(e,r)=>{try{var t=a.lookupPath(e,{follow:!r});e=t.path}catch(u){}var n={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var t=a.lookupPath(e,{parent:!0});n.parentExists=!0,n.parentPath=t.path,n.parentObject=t.node,n.name=z.basename(e),t=a.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(u){n.error=u.errno}return n},createPath:(e,r,t,n)=>{e=typeof e=="string"?e:a.getPath(e);for(var u=r.split("/").reverse();u.length;){var l=u.pop();if(l){var f=z.join2(e,l);try{a.mkdir(f)}catch(d){}e=f}}return f},createFile:(e,r,t,n,u)=>{var l=z.join2(typeof e=="string"?e:a.getPath(e),r),f=Sr(n,u);return a.create(l,f)},createDataFile:(e,r,t,n,u,l)=>{var f=r;e&&(e=typeof e=="string"?e:a.getPath(e),f=r?z.join2(e,r):e);var d=Sr(n,u),g=a.create(f,d);if(t){if(typeof t=="string"){for(var h=new Array(t.length),A=0,O=t.length;A<O;++A)h[A]=t.charCodeAt(A);t=h}a.chmod(g,d|146);var R=a.open(g,577);a.write(R,t,0,t.length,0,l),a.close(R),a.chmod(g,d)}return g},createDevice:(e,r,t,n)=>{var u=z.join2(typeof e=="string"?e:a.getPath(e),r),l=Sr(!!t,!!n);a.createDevice.major||(a.createDevice.major=64);var f=a.makedev(a.createDevice.major++,0);return a.registerDevice(f,{open:d=>{d.seekable=!1},close:d=>{n&&n.buffer&&n.buffer.length&&n(10)},read:(d,g,h,A,O)=>{for(var R=0,S=0;S<A;S++){var F;try{F=t()}catch(Z){throw new a.ErrnoError(29)}if(F===void 0&&R===0)throw new a.ErrnoError(6);if(F==null)break;R++,g[h+S]=F}return R&&(d.node.timestamp=Date.now()),R},write:(d,g,h,A,O)=>{for(var R=0;R<A;R++)try{n(g[h+R])}catch(S){throw new a.ErrnoError(29)}return A&&(d.node.timestamp=Date.now()),R}}),a.mkdev(u,l,f)},forceLoadFile:e=>{if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if(typeof XMLHttpRequest!="undefined")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(ke)try{e.contents=Se(ke(e.url),!0),e.usedBytes=e.contents.length}catch(r){throw new a.ErrnoError(29)}else throw new Error("Cannot load without read() or XMLHttpRequest.")},createLazyFile:(e,r,t,n,u)=>{function l(){this.lengthKnown=!1,this.chunks=[]}if(l.prototype.get=function(S){if(!(S>this.length-1||S<0)){var F=S%this.chunkSize,Z=S/this.chunkSize|0;return this.getter(Z)[F]}},l.prototype.setDataGetter=function(S){this.getter=S},l.prototype.cacheLength=function(){var S=new XMLHttpRequest;if(S.open("HEAD",t,!1),S.send(null),!(S.status>=200&&S.status<300||S.status===304))throw new Error("Couldn't load "+t+". Status: "+S.status);var F=Number(S.getResponseHeader("Content-length")),Z,re=(Z=S.getResponseHeader("Accept-Ranges"))&&Z==="bytes",se=(Z=S.getResponseHeader("Content-Encoding"))&&Z==="gzip",be=1024*1024;re||(be=F);var ie=(Ae,nr)=>{if(Ae>nr)throw new Error("invalid range ("+Ae+", "+nr+") or no bytes requested!");if(nr>F-1)throw new Error("only "+F+" bytes available! programmer error!");var ue=new XMLHttpRequest;if(ue.open("GET",t,!1),F!==be&&ue.setRequestHeader("Range","bytes="+Ae+"-"+nr),ue.responseType="arraybuffer",ue.overrideMimeType&&ue.overrideMimeType("text/plain; charset=x-user-defined"),ue.send(null),!(ue.status>=200&&ue.status<300||ue.status===304))throw new Error("Couldn't load "+t+". Status: "+ue.status);return ue.response!==void 0?new Uint8Array(ue.response||[]):Se(ue.responseText||"",!0)},_r=this;_r.setDataGetter(Ae=>{var nr=Ae*be,ue=(Ae+1)*be-1;if(ue=Math.min(ue,F-1),typeof _r.chunks[Ae]=="undefined"&&(_r.chunks[Ae]=ie(nr,ue)),typeof _r.chunks[Ae]=="undefined")throw new Error("doXHR failed!");return _r.chunks[Ae]}),(se||!F)&&(be=F=1,F=this.getter(0).length,be=F,lr("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=F,this._chunkSize=be,this.lengthKnown=!0},typeof XMLHttpRequest!="undefined"){if(!L)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var f=new l;Object.defineProperties(f,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var d={isDevice:!1,contents:f}}else var d={isDevice:!1,url:t};var g=a.createFile(e,r,d,n,u);d.contents?g.contents=d.contents:d.url&&(g.contents=null,g.url=d.url),Object.defineProperties(g,{usedBytes:{get:function(){return this.contents.length}}});var h={},A=Object.keys(g.stream_ops);A.forEach(R=>{var S=g.stream_ops[R];h[R]=function(){return a.forceLoadFile(g),S.apply(null,arguments)}});function O(R,S,F,Z,re){var se=R.node.contents;if(re>=se.length)return 0;var be=Math.min(se.length-re,Z);if(se.slice)for(var ie=0;ie<be;ie++)S[F+ie]=se[re+ie];else for(var ie=0;ie<be;ie++)S[F+ie]=se.get(re+ie);return be}return h.read=(R,S,F,Z,re)=>(a.forceLoadFile(g),O(R,S,F,Z,re)),h.mmap=(R,S,F,Z,re)=>{a.forceLoadFile(g);var se=bt(S);if(!se)throw new a.ErrnoError(48);return O(R,J,se,S,F),{ptr:se,allocated:!0}},g.stream_ops=h,g}},Tt=(e,r)=>e?Ye(oe,e,r):"",te={DEFAULT_POLLMASK:5,calculateAt:function(e,r,t){if(z.isAbs(r))return r;var n;if(e===-100)n=a.cwd();else{var u=te.getStreamFromFD(e);n=u.path}if(r.length==0){if(!t)throw new a.ErrnoError(44);return n}return z.join2(n,r)},doStat:function(e,r,t){try{var n=e(r)}catch(d){if(d&&d.node&&z.normalize(r)!==z.normalize(a.getPath(d.node)))return-54;throw d}U[t>>2]=n.dev,U[t+4>>2]=n.mode,X[t+8>>2]=n.nlink,U[t+12>>2]=n.uid,U[t+16>>2]=n.gid,U[t+20>>2]=n.rdev,Q=[n.size>>>0,(x=n.size,+Math.abs(x)>=1?x>0?+Math.floor(x/4294967296)>>>0:~~+Math.ceil((x-+(~~x>>>0))/4294967296)>>>0:0)],U[t+24>>2]=Q[0],U[t+28>>2]=Q[1],U[t+32>>2]=4096,U[t+36>>2]=n.blocks;var u=n.atime.getTime(),l=n.mtime.getTime(),f=n.ctime.getTime();return Q=[Math.floor(u/1e3)>>>0,(x=Math.floor(u/1e3),+Math.abs(x)>=1?x>0?+Math.floor(x/4294967296)>>>0:~~+Math.ceil((x-+(~~x>>>0))/4294967296)>>>0:0)],U[t+40>>2]=Q[0],U[t+44>>2]=Q[1],X[t+48>>2]=u%1e3*1e3,Q=[Math.floor(l/1e3)>>>0,(x=Math.floor(l/1e3),+Math.abs(x)>=1?x>0?+Math.floor(x/4294967296)>>>0:~~+Math.ceil((x-+(~~x>>>0))/4294967296)>>>0:0)],U[t+56>>2]=Q[0],U[t+60>>2]=Q[1],X[t+64>>2]=l%1e3*1e3,Q=[Math.floor(f/1e3)>>>0,(x=Math.floor(f/1e3),+Math.abs(x)>=1?x>0?+Math.floor(x/4294967296)>>>0:~~+Math.ceil((x-+(~~x>>>0))/4294967296)>>>0:0)],U[t+72>>2]=Q[0],U[t+76>>2]=Q[1],X[t+80>>2]=f%1e3*1e3,Q=[n.ino>>>0,(x=n.ino,+Math.abs(x)>=1?x>0?+Math.floor(x/4294967296)>>>0:~~+Math.ceil((x-+(~~x>>>0))/4294967296)>>>0:0)],U[t+88>>2]=Q[0],U[t+92>>2]=Q[1],0},doMsync:function(e,r,t,n,u){if(!a.isFile(r.node.mode))throw new a.ErrnoError(43);if(n&2)return 0;var l=oe.slice(e,e+t);a.msync(r,l,u,t,n)},varargs:void 0,get(){te.varargs+=4;var e=U[te.varargs-4>>2];return e},getStr(e){var r=Tt(e);return r},getStreamFromFD:function(e){var r=a.getStreamChecked(e);return r}};function Xr(e,r,t){te.varargs=t;try{var n=te.getStreamFromFD(e);switch(r){case 0:{var u=te.get();if(u<0)return-28;var l;return l=a.createStream(n,u),l.fd}case 1:case 2:return 0;case 3:return n.flags;case 4:{var u=te.get();return n.flags|=u,0}case 5:{var u=te.get(),f=0;return Te[u+f>>1]=2,0}case 6:case 7:return 0;case 16:case 8:return-28;case 9:return he(28),-1;default:return-28}}catch(d){if(typeof a=="undefined"||d.name!=="ErrnoError")throw d;return-d.errno}}function pr(e,r,t,n){te.varargs=n;try{r=te.getStr(r),r=te.calculateAt(e,r);var u=n?te.get():0;return a.open(r,t,u).fd}catch(l){if(typeof a=="undefined"||l.name!=="ErrnoError")throw l;return-l.errno}}function Tn(e,r,t,n,u){}function Kr(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 mr(){for(var e=new Array(256),r=0;r<256;++r)e[r]=String.fromCharCode(r);Pt=e}var Pt=void 0;function ve(e){for(var r="",t=e;oe[t];)r+=Pt[oe[t++]];return r}var $e={},Qe={},He={},cr=void 0;function q(e){throw new cr(e)}var St=void 0;function Cr(e){throw new St(e)}function hr(e,r,t){e.forEach(function(d){He[d]=r});function n(d){var g=t(d);g.length!==e.length&&Cr("Mismatched type converter count");for(var h=0;h<e.length;++h)Ie(e[h],g[h])}var u=new Array(r.length),l=[],f=0;r.forEach((d,g)=>{Qe.hasOwnProperty(d)?u[g]=Qe[d]:(l.push(d),$e.hasOwnProperty(d)||($e[d]=[]),$e[d].push(()=>{u[g]=Qe[d],++f,f===l.length&&n(u)}))}),l.length===0&&n(u)}function Be(e,r,t={}){var n=r.name;if(e||q(`type "${n}" must have a positive integer typeid pointer`),Qe.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;q(`Cannot register type '${n}' twice`)}if(Qe[e]=r,delete He[e],$e.hasOwnProperty(e)){var u=$e[e];delete $e[e],u.forEach(l=>l())}}function Ie(e,r,t={}){if(!("argPackAdvance"in r))throw new TypeError("registerType registeredInstance requires argPackAdvance");return Be(e,r,t)}function Pn(e,r,t,n,u){var l=Kr(t);r=ve(r),Ie(e,{name:r,fromWireType:function(f){return!!f},toWireType:function(f,d){return d?n:u},argPackAdvance:8,readValueFromPointer:function(f){var d;if(t===1)d=J;else if(t===2)d=Te;else if(t===4)d=U;else throw new TypeError("Unknown boolean type size: "+r);return this.fromWireType(d[f>>l])},destructorFunction:null})}function Ar(e){if(!(this instanceof Ue)||!(e instanceof Ue))return!1;for(var r=this.$$.ptrType.registeredClass,t=this.$$.ptr,n=e.$$.ptrType.registeredClass,u=e.$$.ptr;r.baseClass;)t=r.upcast(t),r=r.baseClass;for(;n.baseClass;)u=n.upcast(u),n=n.baseClass;return r===n&&t===u}function Jr(e){return{count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}}function kr(e){function r(t){return t.$$.ptrType.registeredClass.name}q(r(e)+" instance already deleted")}var Yr=!1;function Ct(e){}function Zr(e){e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)}function At(e){e.count.value-=1;var r=e.count.value===0;r&&Zr(e)}function kt(e,r,t){if(r===t)return e;if(t.baseClass===void 0)return null;var n=kt(e,r,t.baseClass);return n===null?null:t.downcast(n)}var Dt={};function Dr(){return Object.keys(yr).length}function Sn(){var e=[];for(var r in yr)yr.hasOwnProperty(r)&&e.push(yr[r]);return e}var vr=[];function Qr(){for(;vr.length;){var e=vr.pop();e.$$.deleteScheduled=!1,e.delete()}}var gr=void 0;function Oe(e){gr=e,vr.length&&gr&&gr(Qr)}function Cn(){s.getInheritedInstanceCount=Dr,s.getLiveInheritedInstances=Sn,s.flushPendingDeletes=Qr,s.setDelayFunction=Oe}var yr={};function Rr(e,r){for(r===void 0&&q("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r}function Rt(e,r){return r=Rr(e,r),yr[r]}function $r(e,r){(!r.ptrType||!r.ptr)&&Cr("makeClassHandle requires ptr and ptrType");var t=!!r.smartPtrType,n=!!r.smartPtr;return t!==n&&Cr("Both smartPtrType and smartPtr must be specified"),r.count={value:1},De(Object.create(e,{$$:{value:r}}))}function An(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=Rt(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 u(){return this.isSmartPointer?$r(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):$r(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var l=this.registeredClass.getActualType(r),f=Dt[l];if(!f)return u.call(this);var d;this.isConst?d=f.constPointerType:d=f.pointerType;var g=kt(r,this.registeredClass,d.registeredClass);return g===null?u.call(this):this.isSmartPointer?$r(d.registeredClass.instancePrototype,{ptrType:d,ptr:g,smartPtrType:this,smartPtr:e}):$r(d.registeredClass.instancePrototype,{ptrType:d,ptr:g})}var De=function(e){return typeof FinalizationRegistry=="undefined"?(De=r=>r,e):(Yr=new FinalizationRegistry(r=>{At(r.$$)}),De=r=>{var t=r.$$,n=!!t.smartPtr;if(n){var u={$$:t};Yr.register(r,u,r)}return r},Ct=r=>Yr.unregister(r),De(e))};function kn(){if(this.$$.ptr||kr(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e=De(Object.create(Object.getPrototypeOf(this),{$$:{value:Jr(this.$$)}}));return e.$$.count.value+=1,e.$$.deleteScheduled=!1,e}function $t(){this.$$.ptr||kr(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&q("Object already scheduled for deletion"),Ct(this),At(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function It(){return!this.$$.ptr}function et(){return this.$$.ptr||kr(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&q("Object already scheduled for deletion"),vr.push(this),vr.length===1&&gr&&gr(Qr),this.$$.deleteScheduled=!0,this}function Dn(){Ue.prototype.isAliasOf=Ar,Ue.prototype.clone=kn,Ue.prototype.delete=$t,Ue.prototype.isDeleted=It,Ue.prototype.deleteLater=et}function Ue(){}var Rn=48,Ot=57;function br(e){if(e===void 0)return"_unknown";e=e.replace(/[^a-zA-Z0-9_]/g,"$");var r=e.charCodeAt(0);return r>=Rn&&r<=Ot?`_${e}`:e}function rt(e,r){return e=br(e),{[e]:function(){return r.apply(this,arguments)}}[e]}function Ut(e,r,t){if(e[r].overloadTable===void 0){var n=e[r];e[r]=function(){return e[r].overloadTable.hasOwnProperty(arguments.length)||q(`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){s.hasOwnProperty(e)?((t===void 0||s[e].overloadTable!==void 0&&s[e].overloadTable[t]!==void 0)&&q(`Cannot register public name '${e}' twice`),Ut(s,e,e),s.hasOwnProperty(t)&&q(`Cannot register multiple overloads of a function with the same number of arguments (${t})!`),s[e].overloadTable[t]=r):(s[e]=r,t!==void 0&&(s[e].numArguments=t))}function xt(e,r,t,n,u,l,f,d){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=u,this.getActualType=l,this.upcast=f,this.downcast=d,this.pureVirtualFunctions=[]}function ge(e,r,t){for(;r!==t;)r.upcast||q(`Expected null or instance of ${t.name}, got an instance of ${r.name}`),e=r.upcast(e),r=r.baseClass;return e}function Ft(e,r){if(r===null)return this.isReference&&q(`null is not a valid ${this.name}`),0;r.$$||q(`Cannot pass "${ot(r)}" as a ${this.name}`),r.$$.ptr||q(`Cannot pass deleted object as a pointer of type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=ge(r.$$.ptr,t,this.registeredClass);return n}function In(e,r){var t;if(r===null)return this.isReference&&q(`null is not a valid ${this.name}`),this.isSmartPointer?(t=this.rawConstructor(),e!==null&&e.push(this.rawDestructor,t),t):0;r.$$||q(`Cannot pass "${ot(r)}" as a ${this.name}`),r.$$.ptr||q(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&r.$$.ptrType.isConst&&q(`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=ge(r.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(r.$$.smartPtr===void 0&&q("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:q(`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 u=r.clone();t=this.rawShare(t,Or.toHandle(function(){u.delete()})),e!==null&&e.push(this.rawDestructor,t)}break;default:q("Unsupporting sharing policy")}return t}function On(e,r){if(r===null)return this.isReference&&q(`null is not a valid ${this.name}`),0;r.$$||q(`Cannot pass "${ot(r)}" as a ${this.name}`),r.$$.ptr||q(`Cannot pass deleted object as a pointer of type ${this.name}`),r.$$.ptrType.isConst&&q(`Cannot convert argument of type ${r.$$.ptrType.name} to parameter type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=ge(r.$$.ptr,t,this.registeredClass);return n}function er(e){return this.fromWireType(U[e>>2])}function Un(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e}function tt(e){this.rawDestructor&&this.rawDestructor(e)}function xn(e){e!==null&&e.delete()}function Fn(){xe.prototype.getPointee=Un,xe.prototype.destructor=tt,xe.prototype.argPackAdvance=8,xe.prototype.readValueFromPointer=er,xe.prototype.deleteObject=xn,xe.prototype.fromWireType=An}function xe(e,r,t,n,u,l,f,d,g,h,A){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=u,this.pointeeType=l,this.sharingPolicy=f,this.rawGetPointee=d,this.rawConstructor=g,this.rawShare=h,this.rawDestructor=A,!u&&r.baseClass===void 0?n?(this.toWireType=Ft,this.destructorFunction=null):(this.toWireType=On,this.destructorFunction=null):this.toWireType=In}function Nn(e,r,t){s.hasOwnProperty(e)||Cr("Replacing nonexistant public symbol"),s[e].overloadTable!==void 0&&t!==void 0?s[e].overloadTable[t]=r:(s[e]=r,s[e].argCount=t)}var Mn=(e,r,t)=>{var n=s["dynCall_"+e];return t&&t.length?n.apply(null,[r].concat(t)):n.call(null,r)},Ir=[],Nt=e=>{var r=Ir[e];return r||(e>=Ir.length&&(Ir.length=e+1),Ir[e]=r=Lr.get(e)),r},Ln=(e,r,t)=>{if(e.includes("j"))return Mn(e,r,t);var n=Nt(r).apply(null,t);return n},Mt=(e,r)=>{var t=[];return function(){return t.length=0,Object.assign(t,arguments),Ln(e,r,t)}};function rr(e,r){e=ve(e);function t(){return e.includes("j")?Mt(e,r):Nt(r)}var n=t();return typeof n!="function"&&q(`unknown function pointer with signature ${e}: ${r}`),n}function Lt(e,r){var t=rt(r,function(n){this.name=r,this.message=n;var u=new Error(n).stack;u!==void 0&&(this.stack=this.toString()+`
3
+ `)),!e)return null;ur=Se(e,!0)}return ur.shift()},We={ttys:[],init:function(){},shutdown:function(){},register:function(e,r){We.ttys[e]={input:[],output:[],ops:r},a.registerDevice(e,We.stream_ops)},stream_ops:{open:function(e){var r=We.ttys[e.node.rdev];if(!r)throw new a.ErrnoError(43);e.tty=r,e.seekable=!1},close:function(e){e.tty.ops.fsync(e.tty)},fsync:function(e){e.tty.ops.fsync(e.tty)},read:function(e,r,t,n,u){if(!e.tty||!e.tty.ops.get_char)throw new a.ErrnoError(60);for(var l=0,f=0;f<n;f++){var d;try{d=e.tty.ops.get_char(e.tty)}catch(g){throw new a.ErrnoError(29)}if(d===void 0&&l===0)throw new a.ErrnoError(6);if(d==null)break;l++,r[t+f]=d}return l&&(e.node.timestamp=Date.now()),l},write:function(e,r,t,n,u){if(!e.tty||!e.tty.ops.put_char)throw new a.ErrnoError(60);try{for(var l=0;l<n;l++)e.tty.ops.put_char(e.tty,r[t+l])}catch(f){throw new a.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),l}},default_tty_ops:{get_char:function(e){return wn()},put_char:function(e,r){r===null||r===10?(lr(Ye(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},fsync:function(e){e.output&&e.output.length>0&&(lr(Ye(e.output,0)),e.output=[])},ioctl_tcgets:function(e){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets:function(e,r,t){return 0},ioctl_tiocgwinsz:function(e){return[24,80]}},default_tty1_ops:{put_char:function(e,r){r===null||r===10?(ae(Ye(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},fsync:function(e){e.output&&e.output.length>0&&(ae(Ye(e.output,0)),e.output=[])}}},bt=e=>{Le()},M={ops_table:null,mount(e){return M.createNode(null,"/",16895,0)},createNode(e,r,t,n){if(a.isBlkdev(t)||a.isFIFO(t))throw new a.ErrnoError(63);M.ops_table||(M.ops_table={dir:{node:{getattr:M.node_ops.getattr,setattr:M.node_ops.setattr,lookup:M.node_ops.lookup,mknod:M.node_ops.mknod,rename:M.node_ops.rename,unlink:M.node_ops.unlink,rmdir:M.node_ops.rmdir,readdir:M.node_ops.readdir,symlink:M.node_ops.symlink},stream:{llseek:M.stream_ops.llseek}},file:{node:{getattr:M.node_ops.getattr,setattr:M.node_ops.setattr},stream:{llseek:M.stream_ops.llseek,read:M.stream_ops.read,write:M.stream_ops.write,allocate:M.stream_ops.allocate,mmap:M.stream_ops.mmap,msync:M.stream_ops.msync}},link:{node:{getattr:M.node_ops.getattr,setattr:M.node_ops.setattr,readlink:M.node_ops.readlink},stream:{}},chrdev:{node:{getattr:M.node_ops.getattr,setattr:M.node_ops.setattr},stream:a.chrdev_stream_ops}});var u=a.createNode(e,r,t,n);return a.isDir(u.mode)?(u.node_ops=M.ops_table.dir.node,u.stream_ops=M.ops_table.dir.stream,u.contents={}):a.isFile(u.mode)?(u.node_ops=M.ops_table.file.node,u.stream_ops=M.ops_table.file.stream,u.usedBytes=0,u.contents=null):a.isLink(u.mode)?(u.node_ops=M.ops_table.link.node,u.stream_ops=M.ops_table.link.stream):a.isChrdev(u.mode)&&(u.node_ops=M.ops_table.chrdev.node,u.stream_ops=M.ops_table.chrdev.stream),u.timestamp=Date.now(),e&&(e.contents[r]=u,e.timestamp=u.timestamp),u},getFileDataAsTypedArray(e){return e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0)},expandFileStorage(e,r){var t=e.contents?e.contents.length:0;if(!(t>=r)){var n=1024*1024;r=Math.max(r,t*(t<n?2:1.125)>>>0),t!=0&&(r=Math.max(r,256));var u=e.contents;e.contents=new Uint8Array(r),e.usedBytes>0&&e.contents.set(u.subarray(0,e.usedBytes),0)}},resizeFileStorage(e,r){if(e.usedBytes!=r)if(r==0)e.contents=null,e.usedBytes=0;else{var t=e.contents;e.contents=new Uint8Array(r),t&&e.contents.set(t.subarray(0,Math.min(r,e.usedBytes))),e.usedBytes=r}},node_ops:{getattr(e){var r={};return r.dev=a.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,a.isDir(e.mode)?r.size=4096:a.isFile(e.mode)?r.size=e.usedBytes:a.isLink(e.mode)?r.size=e.link.length:r.size=0,r.atime=new Date(e.timestamp),r.mtime=new Date(e.timestamp),r.ctime=new Date(e.timestamp),r.blksize=4096,r.blocks=Math.ceil(r.size/r.blksize),r},setattr(e,r){r.mode!==void 0&&(e.mode=r.mode),r.timestamp!==void 0&&(e.timestamp=r.timestamp),r.size!==void 0&&M.resizeFileStorage(e,r.size)},lookup(e,r){throw a.genericErrors[44]},mknod(e,r,t,n){return M.createNode(e,r,t,n)},rename(e,r,t){if(a.isDir(e.mode)){var n;try{n=a.lookupNode(r,t)}catch(l){}if(n)for(var u in n.contents)throw new a.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=t,r.contents[t]=e,r.timestamp=e.parent.timestamp,e.parent=r},unlink(e,r){delete e.contents[r],e.timestamp=Date.now()},rmdir(e,r){var t=a.lookupNode(e,r);for(var n in t.contents)throw new a.ErrnoError(55);delete e.contents[r],e.timestamp=Date.now()},readdir(e){var r=[".",".."];for(var t in e.contents)e.contents.hasOwnProperty(t)&&r.push(t);return r},symlink(e,r,t){var n=M.createNode(e,r,41471,0);return n.link=t,n},readlink(e){if(!a.isLink(e.mode))throw new a.ErrnoError(28);return e.link}},stream_ops:{read(e,r,t,n,u){var l=e.node.contents;if(u>=e.node.usedBytes)return 0;var f=Math.min(e.node.usedBytes-u,n);if(f>8&&l.subarray)r.set(l.subarray(u,u+f),t);else for(var d=0;d<f;d++)r[t+d]=l[u+d];return f},write(e,r,t,n,u,l){if(!n)return 0;var f=e.node;if(f.timestamp=Date.now(),r.subarray&&(!f.contents||f.contents.subarray)){if(l)return f.contents=r.subarray(t,t+n),f.usedBytes=n,n;if(f.usedBytes===0&&u===0)return f.contents=r.slice(t,t+n),f.usedBytes=n,n;if(u+n<=f.usedBytes)return f.contents.set(r.subarray(t,t+n),u),n}if(M.expandFileStorage(f,u+n),f.contents.subarray&&r.subarray)f.contents.set(r.subarray(t,t+n),u);else for(var d=0;d<n;d++)f.contents[u+d]=r[t+d];return f.usedBytes=Math.max(f.usedBytes,u+n),n},llseek(e,r,t){var n=r;if(t===1?n+=e.position:t===2&&a.isFile(e.node.mode)&&(n+=e.node.usedBytes),n<0)throw new a.ErrnoError(28);return n},allocate(e,r,t){M.expandFileStorage(e.node,r+t),e.node.usedBytes=Math.max(e.node.usedBytes,r+t)},mmap(e,r,t,n,u){if(!a.isFile(e.node.mode))throw new a.ErrnoError(43);var l,f,d=e.node.contents;if(!(u&2)&&d.buffer===J.buffer)f=!1,l=d.byteOffset;else{if((t>0||t+r<d.length)&&(d.subarray?d=d.subarray(t,t+r):d=Array.prototype.slice.call(d,t,t+r)),f=!0,l=bt(r),!l)throw new a.ErrnoError(48);J.set(d,l)}return{ptr:l,allocated:f}},msync(e,r,t,n,u){return M.stream_ops.write(e,r,0,n,t,!1),0}}},qr=(e,r,t,n)=>{var u=n?"":`al ${e}`;Me(e,l=>{qe(l,`Loading data file "${e}" failed (no arrayBuffer).`),r(new Uint8Array(l)),u&&Tr(u)},l=>{if(t)t();else throw`Loading data file "${e}" failed.`}),u&&or(u)},_t=s.preloadPlugins||[];function En(e,r,t,n){typeof Browser!="undefined"&&Browser.init();var u=!1;return _t.forEach(function(l){u||l.canHandle(r)&&(l.handle(e,r,t,n),u=!0)}),u}function wt(e,r,t,n,u,l,f,d,g,h){var A=r?le.resolve(z.join2(e,r)):e,O=`cp ${A}`;function R(S){function F(Z){h&&h(),d||a.createDataFile(e,r,Z,n,u,g),l&&l(),Tr(O)}En(S,A,F,()=>{f&&f(),Tr(O)})||F(S)}or(O),typeof t=="string"?qr(t,S=>R(S),f):R(t)}function Et(e){var r={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},t=r[e];if(typeof t=="undefined")throw new Error(`Unknown file open mode: ${e}`);return t}function Sr(e,r){var t=0;return e&&(t|=365),r&&(t|=146),t}var a={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=le.resolve(e),!e)return{path:"",node:null};var t={follow_mount:!0,recurse_count:0};if(r=Object.assign(t,r),r.recurse_count>8)throw new a.ErrnoError(32);for(var n=e.split("/").filter(O=>!!O),u=a.root,l="/",f=0;f<n.length;f++){var d=f===n.length-1;if(d&&r.parent)break;if(u=a.lookupNode(u,n[f]),l=z.join2(l,n[f]),a.isMountpoint(u)&&(!d||d&&r.follow_mount)&&(u=u.mounted.root),!d||r.follow)for(var g=0;a.isLink(u.mode);){var h=a.readlink(l);l=le.resolve(z.dirname(l),h);var A=a.lookupPath(l,{recurse_count:r.recurse_count+1});if(u=A.node,g++>40)throw new a.ErrnoError(32)}}return{path:l,node:u}},getPath:e=>{for(var r;;){if(a.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)%a.nameTable.length},hashAddNode:e=>{var r=a.hashName(e.parent.id,e.name);e.name_next=a.nameTable[r],a.nameTable[r]=e},hashRemoveNode:e=>{var r=a.hashName(e.parent.id,e.name);if(a.nameTable[r]===e)a.nameTable[r]=e.name_next;else for(var t=a.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next}},lookupNode:(e,r)=>{var t=a.mayLookup(e);if(t)throw new a.ErrnoError(t,e);for(var n=a.hashName(e.id,r),u=a.nameTable[n];u;u=u.name_next){var l=u.name;if(u.parent.id===e.id&&l===r)return u}return a.lookup(e,r)},createNode:(e,r,t,n)=>{var u=new a.FSNode(e,r,t,n);return a.hashAddNode(u),u},destroyNode:e=>{a.hashRemoveNode(e)},isRoot:e=>e===e.parent,isMountpoint:e=>!!e.mounted,isFile:e=>(e&61440)===32768,isDir:e=>(e&61440)===16384,isLink:e=>(e&61440)===40960,isChrdev:e=>(e&61440)===8192,isBlkdev:e=>(e&61440)===24576,isFIFO:e=>(e&61440)===4096,isSocket:e=>(e&49152)===49152,flagsToPermissionString:e=>{var r=["r","w","rw"][e&3];return e&512&&(r+="w"),r},nodePermissions:(e,r)=>a.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=a.nodePermissions(e,"x");return r||(e.node_ops.lookup?0:2)},mayCreate:(e,r)=>{try{var t=a.lookupNode(e,r);return 20}catch(n){}return a.nodePermissions(e,"wx")},mayDelete:(e,r,t)=>{var n;try{n=a.lookupNode(e,r)}catch(l){return l.errno}var u=a.nodePermissions(e,"wx");if(u)return u;if(t){if(!a.isDir(n.mode))return 54;if(a.isRoot(n)||a.getPath(n)===a.cwd())return 10}else if(a.isDir(n.mode))return 31;return 0},mayOpen:(e,r)=>e?a.isLink(e.mode)?32:a.isDir(e.mode)&&(a.flagsToPermissionString(r)!=="r"||r&512)?31:a.nodePermissions(e,a.flagsToPermissionString(r)):44,MAX_OPEN_FDS:4096,nextfd:()=>{for(var e=0;e<=a.MAX_OPEN_FDS;e++)if(!a.streams[e])return e;throw new a.ErrnoError(33)},getStreamChecked:e=>{var r=a.getStream(e);if(!r)throw new a.ErrnoError(8);return r},getStream:e=>a.streams[e],createStream:(e,r=-1)=>(a.FSStream||(a.FSStream=function(){this.shared={}},a.FSStream.prototype={},Object.defineProperties(a.FSStream.prototype,{object:{get(){return this.node},set(t){this.node=t}},isRead:{get(){return(this.flags&2097155)!==1}},isWrite:{get(){return(this.flags&2097155)!==0}},isAppend:{get(){return this.flags&1024}},flags:{get(){return this.shared.flags},set(t){this.shared.flags=t}},position:{get(){return this.shared.position},set(t){this.shared.position=t}}})),e=Object.assign(new a.FSStream,e),r==-1&&(r=a.nextfd()),e.fd=r,a.streams[r]=e,e),closeStream:e=>{a.streams[e]=null},chrdev_stream_ops:{open:e=>{var r=a.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:()=>{throw new a.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,r)=>e<<8|r,registerDevice:(e,r)=>{a.devices[e]={stream_ops:r}},getDevice:e=>a.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),a.syncFSRequests++,a.syncFSRequests>1&&ae(`warning: ${a.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var t=a.getMounts(a.root.mount),n=0;function u(f){return a.syncFSRequests--,r(f)}function l(f){if(f)return l.errored?void 0:(l.errored=!0,u(f));++n>=t.length&&u(null)}t.forEach(f=>{if(!f.type.syncfs)return l(null);f.type.syncfs(f,e,l)})},mount:(e,r,t)=>{var n=t==="/",u=!t,l;if(n&&a.root)throw new a.ErrnoError(10);if(!n&&!u){var f=a.lookupPath(t,{follow_mount:!1});if(t=f.path,l=f.node,a.isMountpoint(l))throw new a.ErrnoError(10);if(!a.isDir(l.mode))throw new a.ErrnoError(54)}var d={type:e,opts:r,mountpoint:t,mounts:[]},g=e.mount(d);return g.mount=d,d.root=g,n?a.root=g:l&&(l.mounted=d,l.mount&&l.mount.mounts.push(d)),g},unmount:e=>{var r=a.lookupPath(e,{follow_mount:!1});if(!a.isMountpoint(r.node))throw new a.ErrnoError(28);var t=r.node,n=t.mounted,u=a.getMounts(n);Object.keys(a.nameTable).forEach(f=>{for(var d=a.nameTable[f];d;){var g=d.name_next;u.includes(d.mount)&&a.destroyNode(d),d=g}}),t.mounted=null;var l=t.mount.mounts.indexOf(n);t.mount.mounts.splice(l,1)},lookup:(e,r)=>e.node_ops.lookup(e,r),mknod:(e,r,t)=>{var n=a.lookupPath(e,{parent:!0}),u=n.node,l=z.basename(e);if(!l||l==="."||l==="..")throw new a.ErrnoError(28);var f=a.mayCreate(u,l);if(f)throw new a.ErrnoError(f);if(!u.node_ops.mknod)throw new a.ErrnoError(63);return u.node_ops.mknod(u,l,r,t)},create:(e,r)=>(r=r!==void 0?r:438,r&=4095,r|=32768,a.mknod(e,r,0)),mkdir:(e,r)=>(r=r!==void 0?r:511,r&=1023,r|=16384,a.mknod(e,r,0)),mkdirTree:(e,r)=>{for(var t=e.split("/"),n="",u=0;u<t.length;++u)if(t[u]){n+="/"+t[u];try{a.mkdir(n,r)}catch(l){if(l.errno!=20)throw l}}},mkdev:(e,r,t)=>(typeof t=="undefined"&&(t=r,r=438),r|=8192,a.mknod(e,r,t)),symlink:(e,r)=>{if(!le.resolve(e))throw new a.ErrnoError(44);var t=a.lookupPath(r,{parent:!0}),n=t.node;if(!n)throw new a.ErrnoError(44);var u=z.basename(r),l=a.mayCreate(n,u);if(l)throw new a.ErrnoError(l);if(!n.node_ops.symlink)throw new a.ErrnoError(63);return n.node_ops.symlink(n,u,e)},rename:(e,r)=>{var t=z.dirname(e),n=z.dirname(r),u=z.basename(e),l=z.basename(r),f,d,g;if(f=a.lookupPath(e,{parent:!0}),d=f.node,f=a.lookupPath(r,{parent:!0}),g=f.node,!d||!g)throw new a.ErrnoError(44);if(d.mount!==g.mount)throw new a.ErrnoError(75);var h=a.lookupNode(d,u),A=le.relative(e,n);if(A.charAt(0)!==".")throw new a.ErrnoError(28);if(A=le.relative(r,t),A.charAt(0)!==".")throw new a.ErrnoError(55);var O;try{O=a.lookupNode(g,l)}catch(F){}if(h!==O){var R=a.isDir(h.mode),S=a.mayDelete(d,u,R);if(S)throw new a.ErrnoError(S);if(S=O?a.mayDelete(g,l,R):a.mayCreate(g,l),S)throw new a.ErrnoError(S);if(!d.node_ops.rename)throw new a.ErrnoError(63);if(a.isMountpoint(h)||O&&a.isMountpoint(O))throw new a.ErrnoError(10);if(g!==d&&(S=a.nodePermissions(d,"w"),S))throw new a.ErrnoError(S);a.hashRemoveNode(h);try{d.node_ops.rename(h,g,l)}catch(F){throw F}finally{a.hashAddNode(h)}}},rmdir:e=>{var r=a.lookupPath(e,{parent:!0}),t=r.node,n=z.basename(e),u=a.lookupNode(t,n),l=a.mayDelete(t,n,!0);if(l)throw new a.ErrnoError(l);if(!t.node_ops.rmdir)throw new a.ErrnoError(63);if(a.isMountpoint(u))throw new a.ErrnoError(10);t.node_ops.rmdir(t,n),a.destroyNode(u)},readdir:e=>{var r=a.lookupPath(e,{follow:!0}),t=r.node;if(!t.node_ops.readdir)throw new a.ErrnoError(54);return t.node_ops.readdir(t)},unlink:e=>{var r=a.lookupPath(e,{parent:!0}),t=r.node;if(!t)throw new a.ErrnoError(44);var n=z.basename(e),u=a.lookupNode(t,n),l=a.mayDelete(t,n,!1);if(l)throw new a.ErrnoError(l);if(!t.node_ops.unlink)throw new a.ErrnoError(63);if(a.isMountpoint(u))throw new a.ErrnoError(10);t.node_ops.unlink(t,n),a.destroyNode(u)},readlink:e=>{var r=a.lookupPath(e),t=r.node;if(!t)throw new a.ErrnoError(44);if(!t.node_ops.readlink)throw new a.ErrnoError(28);return le.resolve(a.getPath(t.parent),t.node_ops.readlink(t))},stat:(e,r)=>{var t=a.lookupPath(e,{follow:!r}),n=t.node;if(!n)throw new a.ErrnoError(44);if(!n.node_ops.getattr)throw new a.ErrnoError(63);return n.node_ops.getattr(n)},lstat:e=>a.stat(e,!0),chmod:(e,r,t)=>{var n;if(typeof e=="string"){var u=a.lookupPath(e,{follow:!t});n=u.node}else n=e;if(!n.node_ops.setattr)throw new a.ErrnoError(63);n.node_ops.setattr(n,{mode:r&4095|n.mode&-4096,timestamp:Date.now()})},lchmod:(e,r)=>{a.chmod(e,r,!0)},fchmod:(e,r)=>{var t=a.getStreamChecked(e);a.chmod(t.node,r)},chown:(e,r,t,n)=>{var u;if(typeof e=="string"){var l=a.lookupPath(e,{follow:!n});u=l.node}else u=e;if(!u.node_ops.setattr)throw new a.ErrnoError(63);u.node_ops.setattr(u,{timestamp:Date.now()})},lchown:(e,r,t)=>{a.chown(e,r,t,!0)},fchown:(e,r,t)=>{var n=a.getStreamChecked(e);a.chown(n.node,r,t)},truncate:(e,r)=>{if(r<0)throw new a.ErrnoError(28);var t;if(typeof e=="string"){var n=a.lookupPath(e,{follow:!0});t=n.node}else t=e;if(!t.node_ops.setattr)throw new a.ErrnoError(63);if(a.isDir(t.mode))throw new a.ErrnoError(31);if(!a.isFile(t.mode))throw new a.ErrnoError(28);var u=a.nodePermissions(t,"w");if(u)throw new a.ErrnoError(u);t.node_ops.setattr(t,{size:r,timestamp:Date.now()})},ftruncate:(e,r)=>{var t=a.getStreamChecked(e);if((t.flags&2097155)===0)throw new a.ErrnoError(28);a.truncate(t.node,r)},utime:(e,r,t)=>{var n=a.lookupPath(e,{follow:!0}),u=n.node;u.node_ops.setattr(u,{timestamp:Math.max(r,t)})},open:(e,r,t)=>{if(e==="")throw new a.ErrnoError(44);r=typeof r=="string"?Et(r):r,t=typeof t=="undefined"?438:t,r&64?t=t&4095|32768:t=0;var n;if(typeof e=="object")n=e;else{e=z.normalize(e);try{var u=a.lookupPath(e,{follow:!(r&131072)});n=u.node}catch(g){}}var l=!1;if(r&64)if(n){if(r&128)throw new a.ErrnoError(20)}else n=a.mknod(e,t,0),l=!0;if(!n)throw new a.ErrnoError(44);if(a.isChrdev(n.mode)&&(r&=-513),r&65536&&!a.isDir(n.mode))throw new a.ErrnoError(54);if(!l){var f=a.mayOpen(n,r);if(f)throw new a.ErrnoError(f)}r&512&&!l&&a.truncate(n,0),r&=-131713;var d=a.createStream({node:n,path:a.getPath(n),flags:r,seekable:!0,position:0,stream_ops:n.stream_ops,ungotten:[],error:!1});return d.stream_ops.open&&d.stream_ops.open(d),s.logReadFiles&&!(r&1)&&(a.readFiles||(a.readFiles={}),e in a.readFiles||(a.readFiles[e]=1)),d},close:e=>{if(a.isClosed(e))throw new a.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(r){throw r}finally{a.closeStream(e.fd)}e.fd=null},isClosed:e=>e.fd===null,llseek:(e,r,t)=>{if(a.isClosed(e))throw new a.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new a.ErrnoError(70);if(t!=0&&t!=1&&t!=2)throw new a.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read:(e,r,t,n,u)=>{if(n<0||u<0)throw new a.ErrnoError(28);if(a.isClosed(e))throw new a.ErrnoError(8);if((e.flags&2097155)===1)throw new a.ErrnoError(8);if(a.isDir(e.node.mode))throw new a.ErrnoError(31);if(!e.stream_ops.read)throw new a.ErrnoError(28);var l=typeof u!="undefined";if(!l)u=e.position;else if(!e.seekable)throw new a.ErrnoError(70);var f=e.stream_ops.read(e,r,t,n,u);return l||(e.position+=f),f},write:(e,r,t,n,u,l)=>{if(n<0||u<0)throw new a.ErrnoError(28);if(a.isClosed(e))throw new a.ErrnoError(8);if((e.flags&2097155)===0)throw new a.ErrnoError(8);if(a.isDir(e.node.mode))throw new a.ErrnoError(31);if(!e.stream_ops.write)throw new a.ErrnoError(28);e.seekable&&e.flags&1024&&a.llseek(e,0,2);var f=typeof u!="undefined";if(!f)u=e.position;else if(!e.seekable)throw new a.ErrnoError(70);var d=e.stream_ops.write(e,r,t,n,u,l);return f||(e.position+=d),d},allocate:(e,r,t)=>{if(a.isClosed(e))throw new a.ErrnoError(8);if(r<0||t<=0)throw new a.ErrnoError(28);if((e.flags&2097155)===0)throw new a.ErrnoError(8);if(!a.isFile(e.node.mode)&&!a.isDir(e.node.mode))throw new a.ErrnoError(43);if(!e.stream_ops.allocate)throw new a.ErrnoError(138);e.stream_ops.allocate(e,r,t)},mmap:(e,r,t,n,u)=>{if((n&2)!==0&&(u&2)===0&&(e.flags&2097155)!==2)throw new a.ErrnoError(2);if((e.flags&2097155)===1)throw new a.ErrnoError(2);if(!e.stream_ops.mmap)throw new a.ErrnoError(43);return e.stream_ops.mmap(e,r,t,n,u)},msync:(e,r,t,n,u)=>e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,u):0,munmap:e=>0,ioctl:(e,r,t)=>{if(!e.stream_ops.ioctl)throw new a.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=a.open(e,r.flags),u=a.stat(e),l=u.size,f=new Uint8Array(l);return a.read(n,f,0,l,0),r.encoding==="utf8"?t=Ye(f,0):r.encoding==="binary"&&(t=f),a.close(n),t},writeFile:(e,r,t={})=>{t.flags=t.flags||577;var n=a.open(e,t.flags,t.mode);if(typeof r=="string"){var u=new Uint8Array(Ze(r)+1),l=Gr(r,u,0,u.length);a.write(n,u,0,l,void 0,t.canOwn)}else if(ArrayBuffer.isView(r))a.write(n,r,0,r.byteLength,void 0,t.canOwn);else throw new Error("Unsupported data type");a.close(n)},cwd:()=>a.currentPath,chdir:e=>{var r=a.lookupPath(e,{follow:!0});if(r.node===null)throw new a.ErrnoError(44);if(!a.isDir(r.node.mode))throw new a.ErrnoError(54);var t=a.nodePermissions(r.node,"x");if(t)throw new a.ErrnoError(t);a.currentPath=r.path},createDefaultDirectories:()=>{a.mkdir("/tmp"),a.mkdir("/home"),a.mkdir("/home/web_user")},createDefaultDevices:()=>{a.mkdir("/dev"),a.registerDevice(a.makedev(1,3),{read:()=>0,write:(n,u,l,f,d)=>f}),a.mkdev("/dev/null",a.makedev(1,3)),We.register(a.makedev(5,0),We.default_tty_ops),We.register(a.makedev(6,0),We.default_tty1_ops),a.mkdev("/dev/tty",a.makedev(5,0)),a.mkdev("/dev/tty1",a.makedev(6,0));var e=new Uint8Array(1024),r=0,t=()=>(r===0&&(r=fr(e).byteLength),e[--r]);a.createDevice("/dev","random",t),a.createDevice("/dev","urandom",t),a.mkdir("/dev/shm"),a.mkdir("/dev/shm/tmp")},createSpecialDirectories:()=>{a.mkdir("/proc");var e=a.mkdir("/proc/self");a.mkdir("/proc/self/fd"),a.mount({mount:()=>{var r=a.createNode(e,"fd",16895,73);return r.node_ops={lookup:(t,n)=>{var u=+n,l=a.getStreamChecked(u),f={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>l.path}};return f.parent=f,f}},r}},{},"/proc/self/fd")},createStandardStreams:()=>{s.stdin?a.createDevice("/dev","stdin",s.stdin):a.symlink("/dev/tty","/dev/stdin"),s.stdout?a.createDevice("/dev","stdout",null,s.stdout):a.symlink("/dev/tty","/dev/stdout"),s.stderr?a.createDevice("/dev","stderr",null,s.stderr):a.symlink("/dev/tty1","/dev/stderr");var e=a.open("/dev/stdin",0),r=a.open("/dev/stdout",1),t=a.open("/dev/stderr",1)},ensureErrnoError:()=>{a.ErrnoError||(a.ErrnoError=function(r,t){this.name="ErrnoError",this.node=t,this.setErrno=function(n){this.errno=n},this.setErrno(r),this.message="FS error"},a.ErrnoError.prototype=new Error,a.ErrnoError.prototype.constructor=a.ErrnoError,[44].forEach(e=>{a.genericErrors[e]=new a.ErrnoError(e),a.genericErrors[e].stack="<generic error, no stack>"}))},staticInit:()=>{a.ensureErrnoError(),a.nameTable=new Array(4096),a.mount(M,{},"/"),a.createDefaultDirectories(),a.createDefaultDevices(),a.createSpecialDirectories(),a.filesystems={MEMFS:M}},init:(e,r,t)=>{a.init.initialized=!0,a.ensureErrnoError(),s.stdin=e||s.stdin,s.stdout=r||s.stdout,s.stderr=t||s.stderr,a.createStandardStreams()},quit:()=>{a.init.initialized=!1;for(var e=0;e<a.streams.length;e++){var r=a.streams[e];r&&a.close(r)}},findObject:(e,r)=>{var t=a.analyzePath(e,r);return t.exists?t.object:null},analyzePath:(e,r)=>{try{var t=a.lookupPath(e,{follow:!r});e=t.path}catch(u){}var n={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var t=a.lookupPath(e,{parent:!0});n.parentExists=!0,n.parentPath=t.path,n.parentObject=t.node,n.name=z.basename(e),t=a.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(u){n.error=u.errno}return n},createPath:(e,r,t,n)=>{e=typeof e=="string"?e:a.getPath(e);for(var u=r.split("/").reverse();u.length;){var l=u.pop();if(l){var f=z.join2(e,l);try{a.mkdir(f)}catch(d){}e=f}}return f},createFile:(e,r,t,n,u)=>{var l=z.join2(typeof e=="string"?e:a.getPath(e),r),f=Sr(n,u);return a.create(l,f)},createDataFile:(e,r,t,n,u,l)=>{var f=r;e&&(e=typeof e=="string"?e:a.getPath(e),f=r?z.join2(e,r):e);var d=Sr(n,u),g=a.create(f,d);if(t){if(typeof t=="string"){for(var h=new Array(t.length),A=0,O=t.length;A<O;++A)h[A]=t.charCodeAt(A);t=h}a.chmod(g,d|146);var R=a.open(g,577);a.write(R,t,0,t.length,0,l),a.close(R),a.chmod(g,d)}return g},createDevice:(e,r,t,n)=>{var u=z.join2(typeof e=="string"?e:a.getPath(e),r),l=Sr(!!t,!!n);a.createDevice.major||(a.createDevice.major=64);var f=a.makedev(a.createDevice.major++,0);return a.registerDevice(f,{open:d=>{d.seekable=!1},close:d=>{n&&n.buffer&&n.buffer.length&&n(10)},read:(d,g,h,A,O)=>{for(var R=0,S=0;S<A;S++){var F;try{F=t()}catch(Z){throw new a.ErrnoError(29)}if(F===void 0&&R===0)throw new a.ErrnoError(6);if(F==null)break;R++,g[h+S]=F}return R&&(d.node.timestamp=Date.now()),R},write:(d,g,h,A,O)=>{for(var R=0;R<A;R++)try{n(g[h+R])}catch(S){throw new a.ErrnoError(29)}return A&&(d.node.timestamp=Date.now()),R}}),a.mkdev(u,l,f)},forceLoadFile:e=>{if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if(typeof XMLHttpRequest!="undefined")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(ke)try{e.contents=Se(ke(e.url),!0),e.usedBytes=e.contents.length}catch(r){throw new a.ErrnoError(29)}else throw new Error("Cannot load without read() or XMLHttpRequest.")},createLazyFile:(e,r,t,n,u)=>{function l(){this.lengthKnown=!1,this.chunks=[]}if(l.prototype.get=function(S){if(!(S>this.length-1||S<0)){var F=S%this.chunkSize,Z=S/this.chunkSize|0;return this.getter(Z)[F]}},l.prototype.setDataGetter=function(S){this.getter=S},l.prototype.cacheLength=function(){var S=new XMLHttpRequest;if(S.open("HEAD",t,!1),S.send(null),!(S.status>=200&&S.status<300||S.status===304))throw new Error("Couldn't load "+t+". Status: "+S.status);var F=Number(S.getResponseHeader("Content-length")),Z,re=(Z=S.getResponseHeader("Accept-Ranges"))&&Z==="bytes",se=(Z=S.getResponseHeader("Content-Encoding"))&&Z==="gzip",be=1024*1024;re||(be=F);var ie=(Ae,nr)=>{if(Ae>nr)throw new Error("invalid range ("+Ae+", "+nr+") or no bytes requested!");if(nr>F-1)throw new Error("only "+F+" bytes available! programmer error!");var ue=new XMLHttpRequest;if(ue.open("GET",t,!1),F!==be&&ue.setRequestHeader("Range","bytes="+Ae+"-"+nr),ue.responseType="arraybuffer",ue.overrideMimeType&&ue.overrideMimeType("text/plain; charset=x-user-defined"),ue.send(null),!(ue.status>=200&&ue.status<300||ue.status===304))throw new Error("Couldn't load "+t+". Status: "+ue.status);return ue.response!==void 0?new Uint8Array(ue.response||[]):Se(ue.responseText||"",!0)},_r=this;_r.setDataGetter(Ae=>{var nr=Ae*be,ue=(Ae+1)*be-1;if(ue=Math.min(ue,F-1),typeof _r.chunks[Ae]=="undefined"&&(_r.chunks[Ae]=ie(nr,ue)),typeof _r.chunks[Ae]=="undefined")throw new Error("doXHR failed!");return _r.chunks[Ae]}),(se||!F)&&(be=F=1,F=this.getter(0).length,be=F,lr("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=F,this._chunkSize=be,this.lengthKnown=!0},typeof XMLHttpRequest!="undefined"){if(!L)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var f=new l;Object.defineProperties(f,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var d={isDevice:!1,contents:f}}else var d={isDevice:!1,url:t};var g=a.createFile(e,r,d,n,u);d.contents?g.contents=d.contents:d.url&&(g.contents=null,g.url=d.url),Object.defineProperties(g,{usedBytes:{get:function(){return this.contents.length}}});var h={},A=Object.keys(g.stream_ops);A.forEach(R=>{var S=g.stream_ops[R];h[R]=function(){return a.forceLoadFile(g),S.apply(null,arguments)}});function O(R,S,F,Z,re){var se=R.node.contents;if(re>=se.length)return 0;var be=Math.min(se.length-re,Z);if(se.slice)for(var ie=0;ie<be;ie++)S[F+ie]=se[re+ie];else for(var ie=0;ie<be;ie++)S[F+ie]=se.get(re+ie);return be}return h.read=(R,S,F,Z,re)=>(a.forceLoadFile(g),O(R,S,F,Z,re)),h.mmap=(R,S,F,Z,re)=>{a.forceLoadFile(g);var se=bt(S);if(!se)throw new a.ErrnoError(48);return O(R,J,se,S,F),{ptr:se,allocated:!0}},g.stream_ops=h,g}},Tt=(e,r)=>e?Ye(oe,e,r):"",te={DEFAULT_POLLMASK:5,calculateAt:function(e,r,t){if(z.isAbs(r))return r;var n;if(e===-100)n=a.cwd();else{var u=te.getStreamFromFD(e);n=u.path}if(r.length==0){if(!t)throw new a.ErrnoError(44);return n}return z.join2(n,r)},doStat:function(e,r,t){try{var n=e(r)}catch(d){if(d&&d.node&&z.normalize(r)!==z.normalize(a.getPath(d.node)))return-54;throw d}U[t>>2]=n.dev,U[t+4>>2]=n.mode,X[t+8>>2]=n.nlink,U[t+12>>2]=n.uid,U[t+16>>2]=n.gid,U[t+20>>2]=n.rdev,Q=[n.size>>>0,(x=n.size,+Math.abs(x)>=1?x>0?+Math.floor(x/4294967296)>>>0:~~+Math.ceil((x-+(~~x>>>0))/4294967296)>>>0:0)],U[t+24>>2]=Q[0],U[t+28>>2]=Q[1],U[t+32>>2]=4096,U[t+36>>2]=n.blocks;var u=n.atime.getTime(),l=n.mtime.getTime(),f=n.ctime.getTime();return Q=[Math.floor(u/1e3)>>>0,(x=Math.floor(u/1e3),+Math.abs(x)>=1?x>0?+Math.floor(x/4294967296)>>>0:~~+Math.ceil((x-+(~~x>>>0))/4294967296)>>>0:0)],U[t+40>>2]=Q[0],U[t+44>>2]=Q[1],X[t+48>>2]=u%1e3*1e3,Q=[Math.floor(l/1e3)>>>0,(x=Math.floor(l/1e3),+Math.abs(x)>=1?x>0?+Math.floor(x/4294967296)>>>0:~~+Math.ceil((x-+(~~x>>>0))/4294967296)>>>0:0)],U[t+56>>2]=Q[0],U[t+60>>2]=Q[1],X[t+64>>2]=l%1e3*1e3,Q=[Math.floor(f/1e3)>>>0,(x=Math.floor(f/1e3),+Math.abs(x)>=1?x>0?+Math.floor(x/4294967296)>>>0:~~+Math.ceil((x-+(~~x>>>0))/4294967296)>>>0:0)],U[t+72>>2]=Q[0],U[t+76>>2]=Q[1],X[t+80>>2]=f%1e3*1e3,Q=[n.ino>>>0,(x=n.ino,+Math.abs(x)>=1?x>0?+Math.floor(x/4294967296)>>>0:~~+Math.ceil((x-+(~~x>>>0))/4294967296)>>>0:0)],U[t+88>>2]=Q[0],U[t+92>>2]=Q[1],0},doMsync:function(e,r,t,n,u){if(!a.isFile(r.node.mode))throw new a.ErrnoError(43);if(n&2)return 0;var l=oe.slice(e,e+t);a.msync(r,l,u,t,n)},varargs:void 0,get(){te.varargs+=4;var e=U[te.varargs-4>>2];return e},getStr(e){var r=Tt(e);return r},getStreamFromFD:function(e){var r=a.getStreamChecked(e);return r}};function Xr(e,r,t){te.varargs=t;try{var n=te.getStreamFromFD(e);switch(r){case 0:{var u=te.get();if(u<0)return-28;var l;return l=a.createStream(n,u),l.fd}case 1:case 2:return 0;case 3:return n.flags;case 4:{var u=te.get();return n.flags|=u,0}case 5:{var u=te.get(),f=0;return Te[u+f>>1]=2,0}case 6:case 7:return 0;case 16:case 8:return-28;case 9:return he(28),-1;default:return-28}}catch(d){if(typeof a=="undefined"||d.name!=="ErrnoError")throw d;return-d.errno}}function pr(e,r,t,n){te.varargs=n;try{r=te.getStr(r),r=te.calculateAt(e,r);var u=n?te.get():0;return a.open(r,t,u).fd}catch(l){if(typeof a=="undefined"||l.name!=="ErrnoError")throw l;return-l.errno}}function Tn(e,r,t,n,u){}function Kr(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 mr(){for(var e=new Array(256),r=0;r<256;++r)e[r]=String.fromCharCode(r);Pt=e}var Pt=void 0;function ve(e){for(var r="",t=e;oe[t];)r+=Pt[oe[t++]];return r}var $e={},Qe={},He={},cr=void 0;function q(e){throw new cr(e)}var St=void 0;function Cr(e){throw new St(e)}function hr(e,r,t){e.forEach(function(d){He[d]=r});function n(d){var g=t(d);g.length!==e.length&&Cr("Mismatched type converter count");for(var h=0;h<e.length;++h)Ie(e[h],g[h])}var u=new Array(r.length),l=[],f=0;r.forEach((d,g)=>{Qe.hasOwnProperty(d)?u[g]=Qe[d]:(l.push(d),$e.hasOwnProperty(d)||($e[d]=[]),$e[d].push(()=>{u[g]=Qe[d],++f,f===l.length&&n(u)}))}),l.length===0&&n(u)}function Be(e,r,t={}){var n=r.name;if(e||q(`type "${n}" must have a positive integer typeid pointer`),Qe.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;q(`Cannot register type '${n}' twice`)}if(Qe[e]=r,delete He[e],$e.hasOwnProperty(e)){var u=$e[e];delete $e[e],u.forEach(l=>l())}}function Ie(e,r,t={}){if(!("argPackAdvance"in r))throw new TypeError("registerType registeredInstance requires argPackAdvance");return Be(e,r,t)}function Pn(e,r,t,n,u){var l=Kr(t);r=ve(r),Ie(e,{name:r,fromWireType:function(f){return!!f},toWireType:function(f,d){return d?n:u},argPackAdvance:8,readValueFromPointer:function(f){var d;if(t===1)d=J;else if(t===2)d=Te;else if(t===4)d=U;else throw new TypeError("Unknown boolean type size: "+r);return this.fromWireType(d[f>>l])},destructorFunction:null})}function Ar(e){if(!(this instanceof Ue)||!(e instanceof Ue))return!1;for(var r=this.$$.ptrType.registeredClass,t=this.$$.ptr,n=e.$$.ptrType.registeredClass,u=e.$$.ptr;r.baseClass;)t=r.upcast(t),r=r.baseClass;for(;n.baseClass;)u=n.upcast(u),n=n.baseClass;return r===n&&t===u}function Jr(e){return{count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}}function kr(e){function r(t){return t.$$.ptrType.registeredClass.name}q(r(e)+" instance already deleted")}var Yr=!1;function Ct(e){}function Zr(e){e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)}function At(e){e.count.value-=1;var r=e.count.value===0;r&&Zr(e)}function kt(e,r,t){if(r===t)return e;if(t.baseClass===void 0)return null;var n=kt(e,r,t.baseClass);return n===null?null:t.downcast(n)}var Dt={};function Dr(){return Object.keys(yr).length}function Sn(){var e=[];for(var r in yr)yr.hasOwnProperty(r)&&e.push(yr[r]);return e}var vr=[];function Qr(){for(;vr.length;){var e=vr.pop();e.$$.deleteScheduled=!1,e.delete()}}var gr=void 0;function Oe(e){gr=e,vr.length&&gr&&gr(Qr)}function Cn(){s.getInheritedInstanceCount=Dr,s.getLiveInheritedInstances=Sn,s.flushPendingDeletes=Qr,s.setDelayFunction=Oe}var yr={};function Rr(e,r){for(r===void 0&&q("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r}function Rt(e,r){return r=Rr(e,r),yr[r]}function $r(e,r){(!r.ptrType||!r.ptr)&&Cr("makeClassHandle requires ptr and ptrType");var t=!!r.smartPtrType,n=!!r.smartPtr;return t!==n&&Cr("Both smartPtrType and smartPtr must be specified"),r.count={value:1},De(Object.create(e,{$$:{value:r}}))}function An(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=Rt(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 u(){return this.isSmartPointer?$r(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):$r(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var l=this.registeredClass.getActualType(r),f=Dt[l];if(!f)return u.call(this);var d;this.isConst?d=f.constPointerType:d=f.pointerType;var g=kt(r,this.registeredClass,d.registeredClass);return g===null?u.call(this):this.isSmartPointer?$r(d.registeredClass.instancePrototype,{ptrType:d,ptr:g,smartPtrType:this,smartPtr:e}):$r(d.registeredClass.instancePrototype,{ptrType:d,ptr:g})}var De=function(e){return typeof FinalizationRegistry=="undefined"?(De=r=>r,e):(Yr=new FinalizationRegistry(r=>{At(r.$$)}),De=r=>{var t=r.$$,n=!!t.smartPtr;if(n){var u={$$:t};Yr.register(r,u,r)}return r},Ct=r=>Yr.unregister(r),De(e))};function kn(){if(this.$$.ptr||kr(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e=De(Object.create(Object.getPrototypeOf(this),{$$:{value:Jr(this.$$)}}));return e.$$.count.value+=1,e.$$.deleteScheduled=!1,e}function $t(){this.$$.ptr||kr(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&q("Object already scheduled for deletion"),Ct(this),At(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function It(){return!this.$$.ptr}function et(){return this.$$.ptr||kr(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&q("Object already scheduled for deletion"),vr.push(this),vr.length===1&&gr&&gr(Qr),this.$$.deleteScheduled=!0,this}function Dn(){Ue.prototype.isAliasOf=Ar,Ue.prototype.clone=kn,Ue.prototype.delete=$t,Ue.prototype.isDeleted=It,Ue.prototype.deleteLater=et}function Ue(){}var Rn=48,Ot=57;function br(e){if(e===void 0)return"_unknown";e=e.replace(/[^a-zA-Z0-9_]/g,"$");var r=e.charCodeAt(0);return r>=Rn&&r<=Ot?`_${e}`:e}function rt(e,r){return e=br(e),{[e]:function(){return r.apply(this,arguments)}}[e]}function Ut(e,r,t){if(e[r].overloadTable===void 0){var n=e[r];e[r]=function(){return e[r].overloadTable.hasOwnProperty(arguments.length)||q(`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){s.hasOwnProperty(e)?((t===void 0||s[e].overloadTable!==void 0&&s[e].overloadTable[t]!==void 0)&&q(`Cannot register public name '${e}' twice`),Ut(s,e,e),s.hasOwnProperty(t)&&q(`Cannot register multiple overloads of a function with the same number of arguments (${t})!`),s[e].overloadTable[t]=r):(s[e]=r,t!==void 0&&(s[e].numArguments=t))}function xt(e,r,t,n,u,l,f,d){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=u,this.getActualType=l,this.upcast=f,this.downcast=d,this.pureVirtualFunctions=[]}function ge(e,r,t){for(;r!==t;)r.upcast||q(`Expected null or instance of ${t.name}, got an instance of ${r.name}`),e=r.upcast(e),r=r.baseClass;return e}function Ft(e,r){if(r===null)return this.isReference&&q(`null is not a valid ${this.name}`),0;r.$$||q(`Cannot pass "${ot(r)}" as a ${this.name}`),r.$$.ptr||q(`Cannot pass deleted object as a pointer of type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=ge(r.$$.ptr,t,this.registeredClass);return n}function In(e,r){var t;if(r===null)return this.isReference&&q(`null is not a valid ${this.name}`),this.isSmartPointer?(t=this.rawConstructor(),e!==null&&e.push(this.rawDestructor,t),t):0;r.$$||q(`Cannot pass "${ot(r)}" as a ${this.name}`),r.$$.ptr||q(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&r.$$.ptrType.isConst&&q(`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=ge(r.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(r.$$.smartPtr===void 0&&q("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:q(`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 u=r.clone();t=this.rawShare(t,Or.toHandle(function(){u.delete()})),e!==null&&e.push(this.rawDestructor,t)}break;default:q("Unsupporting sharing policy")}return t}function On(e,r){if(r===null)return this.isReference&&q(`null is not a valid ${this.name}`),0;r.$$||q(`Cannot pass "${ot(r)}" as a ${this.name}`),r.$$.ptr||q(`Cannot pass deleted object as a pointer of type ${this.name}`),r.$$.ptrType.isConst&&q(`Cannot convert argument of type ${r.$$.ptrType.name} to parameter type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=ge(r.$$.ptr,t,this.registeredClass);return n}function er(e){return this.fromWireType(U[e>>2])}function Un(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e}function tt(e){this.rawDestructor&&this.rawDestructor(e)}function xn(e){e!==null&&e.delete()}function Fn(){xe.prototype.getPointee=Un,xe.prototype.destructor=tt,xe.prototype.argPackAdvance=8,xe.prototype.readValueFromPointer=er,xe.prototype.deleteObject=xn,xe.prototype.fromWireType=An}function xe(e,r,t,n,u,l,f,d,g,h,A){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=u,this.pointeeType=l,this.sharingPolicy=f,this.rawGetPointee=d,this.rawConstructor=g,this.rawShare=h,this.rawDestructor=A,!u&&r.baseClass===void 0?n?(this.toWireType=Ft,this.destructorFunction=null):(this.toWireType=On,this.destructorFunction=null):this.toWireType=In}function Nn(e,r,t){s.hasOwnProperty(e)||Cr("Replacing nonexistant public symbol"),s[e].overloadTable!==void 0&&t!==void 0?s[e].overloadTable[t]=r:(s[e]=r,s[e].argCount=t)}var Mn=(e,r,t)=>{var n=s["dynCall_"+e];return t&&t.length?n.apply(null,[r].concat(t)):n.call(null,r)},Ir=[],Nt=e=>{var r=Ir[e];return r||(e>=Ir.length&&(Ir.length=e+1),Ir[e]=r=Lr.get(e)),r},Ln=(e,r,t)=>{if(e.includes("j"))return Mn(e,r,t);var n=Nt(r).apply(null,t);return n},Mt=(e,r)=>{var t=[];return function(){return t.length=0,Object.assign(t,arguments),Ln(e,r,t)}};function rr(e,r){e=ve(e);function t(){return e.includes("j")?Mt(e,r):Nt(r)}var n=t();return typeof n!="function"&&q(`unknown function pointer with signature ${e}: ${r}`),n}function Lt(e,r){var t=rt(r,function(n){this.name=r,this.message=n;var u=new Error(n).stack;u!==void 0&&(this.stack=this.toString()+`
4
4
  `+u.replace(/^Error(:[^\n]*)?\n/,""))});return t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},t}var Wt=void 0;function nt(e){var r=pi(e),t=ve(r);return tr(r),t}function it(e,r){var t=[],n={};function u(l){if(!n[l]&&!Qe[l]){if(He[l]){He[l].forEach(u);return}t.push(l),n[l]=!0}}throw r.forEach(u),new Wt(`${e}: `+t.map(nt).join([", "]))}function Wn(e,r,t,n,u,l,f,d,g,h,A,O,R){A=ve(A),l=rr(u,l),d&&(d=rr(f,d)),h&&(h=rr(g,h)),R=rr(O,R);var S=br(A);$n(S,function(){it(`Cannot construct ${A} due to unbound types`,[n])}),hr([e,r,t],n?[n]:[],function(F){F=F[0];var Z,re;n?(Z=F.registeredClass,re=Z.instancePrototype):re=Ue.prototype;var se=rt(S,function(){if(Object.getPrototypeOf(this)!==be)throw new cr("Use 'new' to construct "+A);if(ie.constructor_body===void 0)throw new cr(A+" has no accessible constructor");var ue=ie.constructor_body[arguments.length];if(ue===void 0)throw new cr(`Tried to invoke ctor of ${A} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(ie.constructor_body).toString()}) parameters instead!`);return ue.apply(this,arguments)}),be=Object.create(re,{constructor:{value:se}});se.prototype=be;var ie=new xt(A,se,be,R,Z,l,d,h);ie.baseClass&&(ie.baseClass.__derivedClasses===void 0&&(ie.baseClass.__derivedClasses=[]),ie.baseClass.__derivedClasses.push(ie));var _r=new xe(A,ie,!0,!1,!1),Ae=new xe(A+"*",ie,!1,!1,!1),nr=new xe(A+" const*",ie,!1,!0,!1);return Dt[e]={pointerType:Ae,constPointerType:nr},Nn(S,se),[_r,Ae,nr]})}function Ht(e,r){for(var t=[],n=0;n<e;n++)t.push(X[r+n*4>>2]);return t}function Hn(e){for(;e.length;){var r=e.pop(),t=e.pop();t(r)}}function Bt(e,r){if(!(e instanceof Function))throw new TypeError(`new_ called with constructor type ${typeof e} which is not a function`);var t=rt(e.name||"unknownFunctionName",function(){});t.prototype=e.prototype;var n=new t,u=e.apply(n,r);return u instanceof Object?u:n}function Vt(e,r,t,n,u,l){var f=r.length;f<2&&q("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var d=r[1]!==null&&t!==null,g=!1,h=1;h<r.length;++h)if(r[h]!==null&&r[h].destructorFunction===void 0){g=!0;break}for(var A=r[0].name!=="void",O="",R="",h=0;h<f-2;++h)O+=(h!==0?", ":"")+"arg"+h,R+=(h!==0?", ":"")+"arg"+h+"Wired";var S=`
5
5
  return function ${br(e)}(${O}) {
6
6
  if (arguments.length !== ${f-2}) {
@@ -14,7 +14,7 @@ var Ii=Object.create;var nn=Object.defineProperty,Oi=Object.defineProperties,gi=
14
14
  `,Z.push(se+"_dtor"),re.push(r[h].destructorFunction))}return A&&(S+=`var ret = retType.fromWireType(rv);
15
15
  return ret;
16
16
  `),S+=`}
17
- `,Z.push(S),Bt(Function,Z).apply(null,re)}function Bn(e,r,t,n,u,l){var f=Ht(r,t);u=rr(n,u),hr([],[e],function(d){d=d[0];var g=`constructor ${d.name}`;if(d.registeredClass.constructor_body===void 0&&(d.registeredClass.constructor_body=[]),d.registeredClass.constructor_body[r-1]!==void 0)throw new cr(`Cannot register multiple constructors with identical number of parameters (${r-1}) for class '${d.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return d.registeredClass.constructor_body[r-1]=()=>{it(`Cannot construct ${d.name} due to unbound types`,f)},hr([],f,function(h){return h.splice(1,0,null),d.registeredClass.constructor_body[r-1]=Vt(g,h,null,u,l),[]}),[]})}function Vn(e,r,t,n,u,l,f,d,g){var h=Ht(t,n);r=ve(r),l=rr(u,l),hr([],[e],function(A){A=A[0];var O=`${A.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),d&&A.registeredClass.pureVirtualFunctions.push(r);function R(){it(`Cannot call ${O} due to unbound types`,h)}var S=A.registeredClass.instancePrototype,F=S[r];return F===void 0||F.overloadTable===void 0&&F.className!==A.name&&F.argCount===t-2?(R.argCount=t-2,R.className=A.name,S[r]=R):(Ut(S,r,O),S[r].overloadTable[t-2]=R),hr([],h,function(Z){var re=Vt(O,Z,A,l,f,g);return S[r].overloadTable===void 0?(re.argCount=t-2,S[r]=re):S[r].overloadTable[t-2]=re,[]}),[]})}function jn(){Object.assign(jt.prototype,{get(e){return this.allocated[e]},has(e){return this.allocated[e]!==void 0},allocate(e){var r=this.freelist.pop()||this.allocated.length;return this.allocated[r]=e,r},free(e){this.allocated[e]=void 0,this.freelist.push(e)}})}function jt(){this.allocated=[void 0],this.freelist=[]}var ye=new jt;function zt(e){e>=ye.reserved&&--ye.get(e).refcount===0&&ye.free(e)}function zn(){for(var e=0,r=ye.reserved;r<ye.allocated.length;++r)ye.allocated[r]!==void 0&&++e;return e}function Gn(){ye.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),ye.reserved=ye.allocated.length,s.count_emval_handles=zn}var Or={toValue:e=>(e||q("Cannot use deleted val. handle = "+e),ye.get(e).value),toHandle:e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return ye.allocate({refcount:1,value:e})}}};function Gt(e,r){r=ve(r),Ie(e,{name:r,fromWireType:function(t){var n=Or.toValue(t);return zt(t),n},toWireType:function(t,n){return Or.toHandle(n)},argPackAdvance:8,readValueFromPointer:er,destructorFunction:null})}function ot(e){if(e===null)return"null";var r=typeof e;return r==="object"||r==="array"||r==="function"?e.toString():""+e}function qn(e,r){switch(r){case 2:return function(t){return this.fromWireType(Mr[t>>2])};case 3:return function(t){return this.fromWireType(mt[t>>3])};default:throw new TypeError("Unknown float type: "+e)}}function qt(e,r,t){var n=Kr(t);r=ve(r),Ie(e,{name:r,fromWireType:function(u){return u},toWireType:function(u,l){return l},argPackAdvance:8,readValueFromPointer:qn(r,n),destructorFunction:null})}function Xn(e,r,t){switch(r){case 0:return t?function(u){return J[u]}:function(u){return oe[u]};case 1:return t?function(u){return Te[u>>1]}:function(u){return Pe[u>>1]};case 2:return t?function(u){return U[u>>2]}:function(u){return X[u>>2]};default:throw new TypeError("Unknown integer type: "+e)}}function Kn(e,r,t,n,u){r=ve(r),u===-1&&(u=4294967295);var l=Kr(t),f=O=>O;if(n===0){var d=32-8*t;f=O=>O<<d>>>d}var g=r.includes("unsigned"),h=(O,R)=>{},A;g?A=function(O,R){return h(R,this.name),R>>>0}:A=function(O,R){return h(R,this.name),R},Ie(e,{name:r,fromWireType:f,toWireType:A,argPackAdvance:8,readValueFromPointer:Xn(r,l,n!==0),destructorFunction:null})}function Jn(e,r,t){var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],u=n[r];function l(f){f=f>>2;var d=X,g=d[f],h=d[f+1];return new u(d.buffer,h,g)}t=ve(t),Ie(e,{name:t,fromWireType:l,argPackAdvance:8,readValueFromPointer:l},{ignoreDuplicateRegistrations:!0})}var Yn=(e,r,t)=>Gr(e,oe,r,t);function Zn(e,r){r=ve(r);var t=r==="std::string";Ie(e,{name:r,fromWireType:function(n){var u=X[n>>2],l=n+4,f;if(t)for(var d=l,g=0;g<=u;++g){var h=l+g;if(g==u||oe[h]==0){var A=h-d,O=Tt(d,A);f===void 0?f=O:(f+=String.fromCharCode(0),f+=O),d=h+1}}else{for(var R=new Array(u),g=0;g<u;++g)R[g]=String.fromCharCode(oe[l+g]);f=R.join("")}return tr(n),f},toWireType:function(n,u){u instanceof ArrayBuffer&&(u=new Uint8Array(u));var l,f=typeof u=="string";f||u instanceof Uint8Array||u instanceof Uint8ClampedArray||u instanceof Int8Array||q("Cannot pass non-string to std::string"),t&&f?l=Ze(u):l=u.length;var d=oi(4+l+1),g=d+4;if(X[d>>2]=l,t&&f)Yn(u,g,l+1);else if(f)for(var h=0;h<l;++h){var A=u.charCodeAt(h);A>255&&(tr(g),q("String has UTF-16 code units that do not fit in 8 bits")),oe[g+h]=A}else for(var h=0;h<l;++h)oe[g+h]=u[h];return n!==null&&n.push(tr,d),d},argPackAdvance:8,readValueFromPointer:er,destructorFunction:function(n){tr(n)}})}var at=typeof TextDecoder!="undefined"?new TextDecoder("utf-16le"):void 0,Qn=(e,r)=>{for(var t=e,n=t>>1,u=n+r/2;!(n>=u)&&Pe[n];)++n;if(t=n<<1,t-e>32&&at)return at.decode(oe.subarray(e,t));for(var l="",f=0;!(f>=r/2);++f){var d=Te[e+f*2>>1];if(d==0)break;l+=String.fromCharCode(d)}return l},ei=(e,r,t)=>{if(t===void 0&&(t=2147483647),t<2)return 0;t-=2;for(var n=r,u=t<e.length*2?t/2:e.length,l=0;l<u;++l){var f=e.charCodeAt(l);Te[r>>1]=f,r+=2}return Te[r>>1]=0,r-n},li=e=>e.length*2,ri=(e,r)=>{for(var t=0,n="";!(t>=r/4);){var u=U[e+t*4>>2];if(u==0)break;if(++t,u>=65536){var l=u-65536;n+=String.fromCharCode(55296|l>>10,56320|l&1023)}else n+=String.fromCharCode(u)}return n},Fe=(e,r,t)=>{if(t===void 0&&(t=2147483647),t<4)return 0;for(var n=r,u=n+t-4,l=0;l<e.length;++l){var f=e.charCodeAt(l);if(f>=55296&&f<=57343){var d=e.charCodeAt(++l);f=65536+((f&1023)<<10)|d&1023}if(U[r>>2]=f,r+=4,r+4>u)break}return U[r>>2]=0,r-n},st=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},Xt=function(e,r,t){t=ve(t);var n,u,l,f,d;r===2?(n=Qn,u=ei,f=li,l=()=>Pe,d=1):r===4&&(n=ri,u=Fe,f=st,l=()=>X,d=2),Ie(e,{name:t,fromWireType:function(g){for(var h=X[g>>2],A=l(),O,R=g+4,S=0;S<=h;++S){var F=g+4+S*r;if(S==h||A[F>>d]==0){var Z=F-R,re=n(R,Z);O===void 0?O=re:(O+=String.fromCharCode(0),O+=re),R=F+r}}return tr(g),O},toWireType:function(g,h){typeof h!="string"&&q(`Cannot pass non-string to C++ string type ${t}`);var A=f(h),O=oi(4+A+r);return X[O>>2]=A>>d,u(h,O+4,A+r),g!==null&&g.push(tr,O),O},argPackAdvance:8,readValueFromPointer:er,destructorFunction:function(g){tr(g)}})};function ti(e,r){r=ve(r),Ie(e,{isVoid:!0,name:r,argPackAdvance:0,fromWireType:function(){},toWireType:function(t,n){}})}var ni={};function Kt(e){var r=ni[e];return r===void 0?ve(e):r}var ut=[];function Ur(e,r,t,n){e=ut[e],r=Or.toValue(r),t=Kt(t),e(r,t,null,n)}function Jt(e){var r=ut.length;return ut.push(e),r}function i(e,r){var t=Qe[e];return t===void 0&&q(r+" has unknown type "+nt(e)),t}function o(e,r){for(var t=new Array(e),n=0;n<e;++n)t[n]=i(X[r+n*4>>2],"parameter "+n);return t}var c=[];function m(e,r){var t=o(e,r),n=t[0],u=n.name+"_$"+t.slice(1).map(function(F){return F.name}).join("_")+"$",l=c[u];if(l!==void 0)return l;for(var f=["retType"],d=[n],g="",h=0;h<e-1;++h)g+=(h!==0?", ":"")+"arg"+h,f.push("argType"+h),d.push(t[1+h]);for(var A=br("methodCaller_"+u),O="return function "+A+`(handle, name, destructors, args) {
17
+ `,Z.push(S),Bt(Function,Z).apply(null,re)}function Bn(e,r,t,n,u,l){var f=Ht(r,t);u=rr(n,u),hr([],[e],function(d){d=d[0];var g=`constructor ${d.name}`;if(d.registeredClass.constructor_body===void 0&&(d.registeredClass.constructor_body=[]),d.registeredClass.constructor_body[r-1]!==void 0)throw new cr(`Cannot register multiple constructors with identical number of parameters (${r-1}) for class '${d.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return d.registeredClass.constructor_body[r-1]=()=>{it(`Cannot construct ${d.name} due to unbound types`,f)},hr([],f,function(h){return h.splice(1,0,null),d.registeredClass.constructor_body[r-1]=Vt(g,h,null,u,l),[]}),[]})}function Vn(e,r,t,n,u,l,f,d,g){var h=Ht(t,n);r=ve(r),l=rr(u,l),hr([],[e],function(A){A=A[0];var O=`${A.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),d&&A.registeredClass.pureVirtualFunctions.push(r);function R(){it(`Cannot call ${O} due to unbound types`,h)}var S=A.registeredClass.instancePrototype,F=S[r];return F===void 0||F.overloadTable===void 0&&F.className!==A.name&&F.argCount===t-2?(R.argCount=t-2,R.className=A.name,S[r]=R):(Ut(S,r,O),S[r].overloadTable[t-2]=R),hr([],h,function(Z){var re=Vt(O,Z,A,l,f,g);return S[r].overloadTable===void 0?(re.argCount=t-2,S[r]=re):S[r].overloadTable[t-2]=re,[]}),[]})}function jn(){Object.assign(jt.prototype,{get(e){return this.allocated[e]},has(e){return this.allocated[e]!==void 0},allocate(e){var r=this.freelist.pop()||this.allocated.length;return this.allocated[r]=e,r},free(e){this.allocated[e]=void 0,this.freelist.push(e)}})}function jt(){this.allocated=[void 0],this.freelist=[]}var ye=new jt;function zt(e){e>=ye.reserved&&--ye.get(e).refcount===0&&ye.free(e)}function zn(){for(var e=0,r=ye.reserved;r<ye.allocated.length;++r)ye.allocated[r]!==void 0&&++e;return e}function Gn(){ye.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),ye.reserved=ye.allocated.length,s.count_emval_handles=zn}var Or={toValue:e=>(e||q("Cannot use deleted val. handle = "+e),ye.get(e).value),toHandle:e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return ye.allocate({refcount:1,value:e})}}};function Gt(e,r){r=ve(r),Ie(e,{name:r,fromWireType:function(t){var n=Or.toValue(t);return zt(t),n},toWireType:function(t,n){return Or.toHandle(n)},argPackAdvance:8,readValueFromPointer:er,destructorFunction:null})}function ot(e){if(e===null)return"null";var r=typeof e;return r==="object"||r==="array"||r==="function"?e.toString():""+e}function qn(e,r){switch(r){case 2:return function(t){return this.fromWireType(Mr[t>>2])};case 3:return function(t){return this.fromWireType(mt[t>>3])};default:throw new TypeError("Unknown float type: "+e)}}function qt(e,r,t){var n=Kr(t);r=ve(r),Ie(e,{name:r,fromWireType:function(u){return u},toWireType:function(u,l){return l},argPackAdvance:8,readValueFromPointer:qn(r,n),destructorFunction:null})}function Xn(e,r,t){switch(r){case 0:return t?function(u){return J[u]}:function(u){return oe[u]};case 1:return t?function(u){return Te[u>>1]}:function(u){return Pe[u>>1]};case 2:return t?function(u){return U[u>>2]}:function(u){return X[u>>2]};default:throw new TypeError("Unknown integer type: "+e)}}function Kn(e,r,t,n,u){r=ve(r),u===-1&&(u=4294967295);var l=Kr(t),f=O=>O;if(n===0){var d=32-8*t;f=O=>O<<d>>>d}var g=r.includes("unsigned"),h=(O,R)=>{},A;g?A=function(O,R){return h(R,this.name),R>>>0}:A=function(O,R){return h(R,this.name),R},Ie(e,{name:r,fromWireType:f,toWireType:A,argPackAdvance:8,readValueFromPointer:Xn(r,l,n!==0),destructorFunction:null})}function Jn(e,r,t){var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],u=n[r];function l(f){f=f>>2;var d=X,g=d[f],h=d[f+1];return new u(d.buffer,h,g)}t=ve(t),Ie(e,{name:t,fromWireType:l,argPackAdvance:8,readValueFromPointer:l},{ignoreDuplicateRegistrations:!0})}var Yn=(e,r,t)=>Gr(e,oe,r,t);function Zn(e,r){r=ve(r);var t=r==="std::string";Ie(e,{name:r,fromWireType:function(n){var u=X[n>>2],l=n+4,f;if(t)for(var d=l,g=0;g<=u;++g){var h=l+g;if(g==u||oe[h]==0){var A=h-d,O=Tt(d,A);f===void 0?f=O:(f+="\0",f+=O),d=h+1}}else{for(var R=new Array(u),g=0;g<u;++g)R[g]=String.fromCharCode(oe[l+g]);f=R.join("")}return tr(n),f},toWireType:function(n,u){u instanceof ArrayBuffer&&(u=new Uint8Array(u));var l,f=typeof u=="string";f||u instanceof Uint8Array||u instanceof Uint8ClampedArray||u instanceof Int8Array||q("Cannot pass non-string to std::string"),t&&f?l=Ze(u):l=u.length;var d=oi(4+l+1),g=d+4;if(X[d>>2]=l,t&&f)Yn(u,g,l+1);else if(f)for(var h=0;h<l;++h){var A=u.charCodeAt(h);A>255&&(tr(g),q("String has UTF-16 code units that do not fit in 8 bits")),oe[g+h]=A}else for(var h=0;h<l;++h)oe[g+h]=u[h];return n!==null&&n.push(tr,d),d},argPackAdvance:8,readValueFromPointer:er,destructorFunction:function(n){tr(n)}})}var at=typeof TextDecoder!="undefined"?new TextDecoder("utf-16le"):void 0,Qn=(e,r)=>{for(var t=e,n=t>>1,u=n+r/2;!(n>=u)&&Pe[n];)++n;if(t=n<<1,t-e>32&&at)return at.decode(oe.subarray(e,t));for(var l="",f=0;!(f>=r/2);++f){var d=Te[e+f*2>>1];if(d==0)break;l+=String.fromCharCode(d)}return l},ei=(e,r,t)=>{if(t===void 0&&(t=2147483647),t<2)return 0;t-=2;for(var n=r,u=t<e.length*2?t/2:e.length,l=0;l<u;++l){var f=e.charCodeAt(l);Te[r>>1]=f,r+=2}return Te[r>>1]=0,r-n},li=e=>e.length*2,ri=(e,r)=>{for(var t=0,n="";!(t>=r/4);){var u=U[e+t*4>>2];if(u==0)break;if(++t,u>=65536){var l=u-65536;n+=String.fromCharCode(55296|l>>10,56320|l&1023)}else n+=String.fromCharCode(u)}return n},Fe=(e,r,t)=>{if(t===void 0&&(t=2147483647),t<4)return 0;for(var n=r,u=n+t-4,l=0;l<e.length;++l){var f=e.charCodeAt(l);if(f>=55296&&f<=57343){var d=e.charCodeAt(++l);f=65536+((f&1023)<<10)|d&1023}if(U[r>>2]=f,r+=4,r+4>u)break}return U[r>>2]=0,r-n},st=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},Xt=function(e,r,t){t=ve(t);var n,u,l,f,d;r===2?(n=Qn,u=ei,f=li,l=()=>Pe,d=1):r===4&&(n=ri,u=Fe,f=st,l=()=>X,d=2),Ie(e,{name:t,fromWireType:function(g){for(var h=X[g>>2],A=l(),O,R=g+4,S=0;S<=h;++S){var F=g+4+S*r;if(S==h||A[F>>d]==0){var Z=F-R,re=n(R,Z);O===void 0?O=re:(O+="\0",O+=re),R=F+r}}return tr(g),O},toWireType:function(g,h){typeof h!="string"&&q(`Cannot pass non-string to C++ string type ${t}`);var A=f(h),O=oi(4+A+r);return X[O>>2]=A>>d,u(h,O+4,A+r),g!==null&&g.push(tr,O),O},argPackAdvance:8,readValueFromPointer:er,destructorFunction:function(g){tr(g)}})};function ti(e,r){r=ve(r),Ie(e,{isVoid:!0,name:r,argPackAdvance:0,fromWireType:function(){},toWireType:function(t,n){}})}var ni={};function Kt(e){var r=ni[e];return r===void 0?ve(e):r}var ut=[];function Ur(e,r,t,n){e=ut[e],r=Or.toValue(r),t=Kt(t),e(r,t,null,n)}function Jt(e){var r=ut.length;return ut.push(e),r}function i(e,r){var t=Qe[e];return t===void 0&&q(r+" has unknown type "+nt(e)),t}function o(e,r){for(var t=new Array(e),n=0;n<e;++n)t[n]=i(X[r+n*4>>2],"parameter "+n);return t}var c=[];function m(e,r){var t=o(e,r),n=t[0],u=n.name+"_$"+t.slice(1).map(function(F){return F.name}).join("_")+"$",l=c[u];if(l!==void 0)return l;for(var f=["retType"],d=[n],g="",h=0;h<e-1;++h)g+=(h!==0?", ":"")+"arg"+h,f.push("argType"+h),d.push(t[1+h]);for(var A=br("methodCaller_"+u),O="return function "+A+`(handle, name, destructors, args) {
18
18
  `,R=0,h=0;h<e-1;++h)O+=" var arg"+h+" = argType"+h+".readValueFromPointer(args"+(R?"+"+R:"")+`);
19
19
  `,R+=t[h+1].argPackAdvance;O+=" var rv = handle[name]("+g+`);
20
20
  `;for(var h=0;h<e-1;++h)t[h+1].deleteObject&&(O+=" argType"+h+".deleteObject(arg"+h+`);
@@ -34,10 +34,10 @@ return ret;
34
34
  `,Ee.push(Ve+"_dtor"),de.push(o[E].destructorFunction))}return W&&(Y+=`var ret = retType.fromWireType(rv);
35
35
  return ret;
36
36
  `),Y+=`}
37
- `,Ee.push(Y),Ot(Function,Ee).apply(null,de)}function rt(i,o,c,m,v,w){var T=Ue(o,c);v=De(m,v),Ze([],[i],function(b){b=b[0];var k=`constructor ${b.name}`;if(b.registeredClass.constructor_body===void 0&&(b.registeredClass.constructor_body=[]),b.registeredClass.constructor_body[o-1]!==void 0)throw new le(`Cannot register multiple constructors with identical number of parameters (${o-1}) for class '${b.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return b.registeredClass.constructor_body[o-1]=()=>{et(`Cannot construct ${b.name} due to unbound types`,T)},Ze([],T,function(E){return E.splice(1,0,null),b.registeredClass.constructor_body[o-1]=br(k,E,null,v,w),[]}),[]})}function Ut(i,o,c,m,v,w,T,b,k){var E=Ue(c,m);o=he(o),w=De(v,w),Ze([],[i],function(W){W=W[0];var B=`${W.name}.${o}`;o.startsWith("@@")&&(o=Symbol[o.substring(2)]),b&&W.registeredClass.pureVirtualFunctions.push(o);function V(){et(`Cannot call ${B} due to unbound types`,E)}var Y=W.registeredClass.instancePrototype,ne=Y[o];return ne===void 0||ne.overloadTable===void 0&&ne.className!==W.name&&ne.argCount===c-2?(V.argCount=c-2,V.className=W.name,Y[o]=V):(kr(Y,o,B),Y[o].overloadTable[c-2]=V),Ze([],E,function(Ee){var de=br(B,Ee,W,w,T,k);return Y[o].overloadTable===void 0?(de.argCount=c-2,Y[o]=de):Y[o].overloadTable[c-2]=de,[]}),[]})}function $n(){Object.assign(xt.prototype,{get(i){return this.allocated[i]},has(i){return this.allocated[i]!==void 0},allocate(i){var o=this.freelist.pop()||this.allocated.length;return this.allocated[o]=i,o},free(i){this.allocated[i]=void 0,this.freelist.push(i)}})}function xt(){this.allocated=[void 0],this.freelist=[]}var ge=new xt;function Ft(i){i>=ge.reserved&&--ge.get(i).refcount===0&&ge.free(i)}function In(){for(var i=0,o=ge.reserved;o<ge.allocated.length;++o)ge.allocated[o]!==void 0&&++i;return i}function On(){ge.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),ge.reserved=ge.allocated.length,s.count_emval_handles=In}var er={toValue:i=>(i||G("Cannot use deleted val. handle = "+i),ge.get(i).value),toHandle:i=>{switch(i){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return ge.allocate({refcount:1,value:i})}}};function Un(i,o){o=he(o),Se(i,{name:o,fromWireType:function(c){var m=er.toValue(c);return Ft(c),m},toWireType:function(c,m){return er.toHandle(m)},argPackAdvance:8,readValueFromPointer:Dr,destructorFunction:null})}function tt(i){if(i===null)return"null";var o=typeof i;return o==="object"||o==="array"||o==="function"?i.toString():""+i}function xn(i,o){switch(o){case 2:return function(c){return this.fromWireType(X[c>>2])};case 3:return function(c){return this.fromWireType(Mr[c>>3])};default:throw new TypeError("Unknown float type: "+i)}}function Fn(i,o,c){var m=Pr(c);o=he(o),Se(i,{name:o,fromWireType:function(v){return v},toWireType:function(v,w){return w},argPackAdvance:8,readValueFromPointer:xn(o,m),destructorFunction:null})}function xe(i,o,c){switch(o){case 0:return c?function(v){return qe[v]}:function(v){return J[v]};case 1:return c?function(v){return oe[v>>1]}:function(v){return Te[v>>1]};case 2:return c?function(v){return Pe[v>>2]}:function(v){return U[v>>2]};default:throw new TypeError("Unknown integer type: "+i)}}function Nn(i,o,c,m,v){o=he(o),v===-1&&(v=4294967295);var w=Pr(c),T=B=>B;if(m===0){var b=32-8*c;T=B=>B<<b>>>b}var k=o.includes("unsigned"),E=(B,V)=>{},W;k?W=function(B,V){return E(V,this.name),V>>>0}:W=function(B,V){return E(V,this.name),V},Se(i,{name:o,fromWireType:T,toWireType:W,argPackAdvance:8,readValueFromPointer:xe(o,w,m!==0),destructorFunction:null})}function Mn(i,o,c){var m=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],v=m[o];function w(T){T=T>>2;var b=U,k=b[T],E=b[T+1];return new v(b.buffer,E,k)}c=he(c),Se(i,{name:c,fromWireType:w,argPackAdvance:8,readValueFromPointer:w},{ignoreDuplicateRegistrations:!0})}var Ir=(i,o,c,m)=>{if(!(m>0))return 0;for(var v=c,w=c+m-1,T=0;T<i.length;++T){var b=i.charCodeAt(T);if(b>=55296&&b<=57343){var k=i.charCodeAt(++T);b=65536+((b&1023)<<10)|k&1023}if(b<=127){if(c>=w)break;o[c++]=b}else if(b<=2047){if(c+1>=w)break;o[c++]=192|b>>6,o[c++]=128|b&63}else if(b<=65535){if(c+2>=w)break;o[c++]=224|b>>12,o[c++]=128|b>>6&63,o[c++]=128|b&63}else{if(c+3>=w)break;o[c++]=240|b>>18,o[c++]=128|b>>12&63,o[c++]=128|b>>6&63,o[c++]=128|b&63}}return o[c]=0,c-v},Nt=(i,o,c)=>Ir(i,J,o,c),Ln=i=>{for(var o=0,c=0;c<i.length;++c){var m=i.charCodeAt(c);m<=127?o++:m<=2047?o+=2:m>=55296&&m<=57343?(o+=4,++c):o+=3}return o},Mt=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):void 0,rr=(i,o,c)=>{for(var m=o+c,v=o;i[v]&&!(v>=m);)++v;if(v-o>16&&i.buffer&&Mt)return Mt.decode(i.subarray(o,v));for(var w="";o<v;){var T=i[o++];if(!(T&128)){w+=String.fromCharCode(T);continue}var b=i[o++]&63;if((T&224)==192){w+=String.fromCharCode((T&31)<<6|b);continue}var k=i[o++]&63;if((T&240)==224?T=(T&15)<<12|b<<6|k:T=(T&7)<<18|b<<12|k<<6|i[o++]&63,T<65536)w+=String.fromCharCode(T);else{var E=T-65536;w+=String.fromCharCode(55296|E>>10,56320|E&1023)}}return w},Lt=(i,o)=>i?rr(J,i,o):"";function Wt(i,o){o=he(o);var c=o==="std::string";Se(i,{name:o,fromWireType:function(m){var v=U[m>>2],w=m+4,T;if(c)for(var b=w,k=0;k<=v;++k){var E=w+k;if(k==v||J[E]==0){var W=E-b,B=Lt(b,W);T===void 0?T=B:(T+=String.fromCharCode(0),T+=B),b=E+1}}else{for(var V=new Array(v),k=0;k<v;++k)V[k]=String.fromCharCode(J[w+k]);T=V.join("")}return Fe(m),T},toWireType:function(m,v){v instanceof ArrayBuffer&&(v=new Uint8Array(v));var w,T=typeof v=="string";T||v instanceof Uint8Array||v instanceof Uint8ClampedArray||v instanceof Int8Array||G("Cannot pass non-string to std::string"),c&&T?w=Ln(v):w=v.length;var b=st(4+w+1),k=b+4;if(U[b>>2]=w,c&&T)Nt(v,k,w+1);else if(T)for(var E=0;E<w;++E){var W=v.charCodeAt(E);W>255&&(Fe(k),G("String has UTF-16 code units that do not fit in 8 bits")),J[k+E]=W}else for(var E=0;E<w;++E)J[k+E]=v[E];return m!==null&&m.push(Fe,b),b},argPackAdvance:8,readValueFromPointer:Dr,destructorFunction:function(m){Fe(m)}})}var nt=typeof TextDecoder!="undefined"?new TextDecoder("utf-16le"):void 0,it=(i,o)=>{for(var c=i,m=c>>1,v=m+o/2;!(m>=v)&&Te[m];)++m;if(c=m<<1,c-i>32&&nt)return nt.decode(J.subarray(i,c));for(var w="",T=0;!(T>=o/2);++T){var b=oe[i+T*2>>1];if(b==0)break;w+=String.fromCharCode(b)}return w},Wn=(i,o,c)=>{if(c===void 0&&(c=2147483647),c<2)return 0;c-=2;for(var m=o,v=c<i.length*2?c/2:i.length,w=0;w<v;++w){var T=i.charCodeAt(w);oe[o>>1]=T,o+=2}return oe[o>>1]=0,o-m},Ht=i=>i.length*2,Hn=(i,o)=>{for(var c=0,m="";!(c>=o/4);){var v=Pe[i+c*4>>2];if(v==0)break;if(++c,v>=65536){var w=v-65536;m+=String.fromCharCode(55296|w>>10,56320|w&1023)}else m+=String.fromCharCode(v)}return m},Bt=(i,o,c)=>{if(c===void 0&&(c=2147483647),c<4)return 0;for(var m=o,v=m+c-4,w=0;w<i.length;++w){var T=i.charCodeAt(w);if(T>=55296&&T<=57343){var b=i.charCodeAt(++w);T=65536+((T&1023)<<10)|b&1023}if(Pe[o>>2]=T,o+=4,o+4>v)break}return Pe[o>>2]=0,o-m},Vt=i=>{for(var o=0,c=0;c<i.length;++c){var m=i.charCodeAt(c);m>=55296&&m<=57343&&++c,o+=4}return o},Bn=function(i,o,c){c=he(c);var m,v,w,T,b;o===2?(m=it,v=Wn,T=Ht,w=()=>Te,b=1):o===4&&(m=Hn,v=Bt,T=Vt,w=()=>U,b=2),Se(i,{name:c,fromWireType:function(k){for(var E=U[k>>2],W=w(),B,V=k+4,Y=0;Y<=E;++Y){var ne=k+4+Y*o;if(Y==E||W[ne>>b]==0){var Ee=ne-V,de=m(V,Ee);B===void 0?B=de:(B+=String.fromCharCode(0),B+=de),V=ne+o}}return Fe(k),B},toWireType:function(k,E){typeof E!="string"&&G(`Cannot pass non-string to C++ string type ${c}`);var W=T(E),B=st(4+W+o);return U[B>>2]=W>>b,v(E,B+4,W+o),k!==null&&k.push(Fe,B),B},argPackAdvance:8,readValueFromPointer:Dr,destructorFunction:function(k){Fe(k)}})};function Vn(i,o){o=he(o),Se(i,{isVoid:!0,name:o,argPackAdvance:0,fromWireType:function(){},toWireType:function(c,m){}})}var jn={};function jt(i){var o=jn[i];return o===void 0?he(i):o}var ye=[];function zt(i,o,c,m){i=ye[i],o=er.toValue(o),c=jt(c),i(o,c,null,m)}function zn(i){var o=ye.length;return ye.push(i),o}function Gn(i,o){var c=Je[i];return c===void 0&&G(o+" has unknown type "+It(i)),c}function Or(i,o){for(var c=new Array(i),m=0;m<i;++m)c[m]=Gn(U[o+m*4>>2],"parameter "+m);return c}var Gt=[];function ot(i,o){var c=Or(i,o),m=c[0],v=m.name+"_$"+c.slice(1).map(function(ne){return ne.name}).join("_")+"$",w=Gt[v];if(w!==void 0)return w;for(var T=["retType"],b=[m],k="",E=0;E<i-1;++E)k+=(E!==0?", ":"")+"arg"+E,T.push("argType"+E),b.push(c[1+E]);for(var W=Ar("methodCaller_"+v),B="return function "+W+`(handle, name, destructors, args) {
37
+ `,Ee.push(Y),Ot(Function,Ee).apply(null,de)}function rt(i,o,c,m,v,w){var T=Ue(o,c);v=De(m,v),Ze([],[i],function(b){b=b[0];var k=`constructor ${b.name}`;if(b.registeredClass.constructor_body===void 0&&(b.registeredClass.constructor_body=[]),b.registeredClass.constructor_body[o-1]!==void 0)throw new le(`Cannot register multiple constructors with identical number of parameters (${o-1}) for class '${b.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return b.registeredClass.constructor_body[o-1]=()=>{et(`Cannot construct ${b.name} due to unbound types`,T)},Ze([],T,function(E){return E.splice(1,0,null),b.registeredClass.constructor_body[o-1]=br(k,E,null,v,w),[]}),[]})}function Ut(i,o,c,m,v,w,T,b,k){var E=Ue(c,m);o=he(o),w=De(v,w),Ze([],[i],function(W){W=W[0];var B=`${W.name}.${o}`;o.startsWith("@@")&&(o=Symbol[o.substring(2)]),b&&W.registeredClass.pureVirtualFunctions.push(o);function V(){et(`Cannot call ${B} due to unbound types`,E)}var Y=W.registeredClass.instancePrototype,ne=Y[o];return ne===void 0||ne.overloadTable===void 0&&ne.className!==W.name&&ne.argCount===c-2?(V.argCount=c-2,V.className=W.name,Y[o]=V):(kr(Y,o,B),Y[o].overloadTable[c-2]=V),Ze([],E,function(Ee){var de=br(B,Ee,W,w,T,k);return Y[o].overloadTable===void 0?(de.argCount=c-2,Y[o]=de):Y[o].overloadTable[c-2]=de,[]}),[]})}function $n(){Object.assign(xt.prototype,{get(i){return this.allocated[i]},has(i){return this.allocated[i]!==void 0},allocate(i){var o=this.freelist.pop()||this.allocated.length;return this.allocated[o]=i,o},free(i){this.allocated[i]=void 0,this.freelist.push(i)}})}function xt(){this.allocated=[void 0],this.freelist=[]}var ge=new xt;function Ft(i){i>=ge.reserved&&--ge.get(i).refcount===0&&ge.free(i)}function In(){for(var i=0,o=ge.reserved;o<ge.allocated.length;++o)ge.allocated[o]!==void 0&&++i;return i}function On(){ge.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),ge.reserved=ge.allocated.length,s.count_emval_handles=In}var er={toValue:i=>(i||G("Cannot use deleted val. handle = "+i),ge.get(i).value),toHandle:i=>{switch(i){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return ge.allocate({refcount:1,value:i})}}};function Un(i,o){o=he(o),Se(i,{name:o,fromWireType:function(c){var m=er.toValue(c);return Ft(c),m},toWireType:function(c,m){return er.toHandle(m)},argPackAdvance:8,readValueFromPointer:Dr,destructorFunction:null})}function tt(i){if(i===null)return"null";var o=typeof i;return o==="object"||o==="array"||o==="function"?i.toString():""+i}function xn(i,o){switch(o){case 2:return function(c){return this.fromWireType(X[c>>2])};case 3:return function(c){return this.fromWireType(Mr[c>>3])};default:throw new TypeError("Unknown float type: "+i)}}function Fn(i,o,c){var m=Pr(c);o=he(o),Se(i,{name:o,fromWireType:function(v){return v},toWireType:function(v,w){return w},argPackAdvance:8,readValueFromPointer:xn(o,m),destructorFunction:null})}function xe(i,o,c){switch(o){case 0:return c?function(v){return qe[v]}:function(v){return J[v]};case 1:return c?function(v){return oe[v>>1]}:function(v){return Te[v>>1]};case 2:return c?function(v){return Pe[v>>2]}:function(v){return U[v>>2]};default:throw new TypeError("Unknown integer type: "+i)}}function Nn(i,o,c,m,v){o=he(o),v===-1&&(v=4294967295);var w=Pr(c),T=B=>B;if(m===0){var b=32-8*c;T=B=>B<<b>>>b}var k=o.includes("unsigned"),E=(B,V)=>{},W;k?W=function(B,V){return E(V,this.name),V>>>0}:W=function(B,V){return E(V,this.name),V},Se(i,{name:o,fromWireType:T,toWireType:W,argPackAdvance:8,readValueFromPointer:xe(o,w,m!==0),destructorFunction:null})}function Mn(i,o,c){var m=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],v=m[o];function w(T){T=T>>2;var b=U,k=b[T],E=b[T+1];return new v(b.buffer,E,k)}c=he(c),Se(i,{name:c,fromWireType:w,argPackAdvance:8,readValueFromPointer:w},{ignoreDuplicateRegistrations:!0})}var Ir=(i,o,c,m)=>{if(!(m>0))return 0;for(var v=c,w=c+m-1,T=0;T<i.length;++T){var b=i.charCodeAt(T);if(b>=55296&&b<=57343){var k=i.charCodeAt(++T);b=65536+((b&1023)<<10)|k&1023}if(b<=127){if(c>=w)break;o[c++]=b}else if(b<=2047){if(c+1>=w)break;o[c++]=192|b>>6,o[c++]=128|b&63}else if(b<=65535){if(c+2>=w)break;o[c++]=224|b>>12,o[c++]=128|b>>6&63,o[c++]=128|b&63}else{if(c+3>=w)break;o[c++]=240|b>>18,o[c++]=128|b>>12&63,o[c++]=128|b>>6&63,o[c++]=128|b&63}}return o[c]=0,c-v},Nt=(i,o,c)=>Ir(i,J,o,c),Ln=i=>{for(var o=0,c=0;c<i.length;++c){var m=i.charCodeAt(c);m<=127?o++:m<=2047?o+=2:m>=55296&&m<=57343?(o+=4,++c):o+=3}return o},Mt=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):void 0,rr=(i,o,c)=>{for(var m=o+c,v=o;i[v]&&!(v>=m);)++v;if(v-o>16&&i.buffer&&Mt)return Mt.decode(i.subarray(o,v));for(var w="";o<v;){var T=i[o++];if(!(T&128)){w+=String.fromCharCode(T);continue}var b=i[o++]&63;if((T&224)==192){w+=String.fromCharCode((T&31)<<6|b);continue}var k=i[o++]&63;if((T&240)==224?T=(T&15)<<12|b<<6|k:T=(T&7)<<18|b<<12|k<<6|i[o++]&63,T<65536)w+=String.fromCharCode(T);else{var E=T-65536;w+=String.fromCharCode(55296|E>>10,56320|E&1023)}}return w},Lt=(i,o)=>i?rr(J,i,o):"";function Wt(i,o){o=he(o);var c=o==="std::string";Se(i,{name:o,fromWireType:function(m){var v=U[m>>2],w=m+4,T;if(c)for(var b=w,k=0;k<=v;++k){var E=w+k;if(k==v||J[E]==0){var W=E-b,B=Lt(b,W);T===void 0?T=B:(T+="\0",T+=B),b=E+1}}else{for(var V=new Array(v),k=0;k<v;++k)V[k]=String.fromCharCode(J[w+k]);T=V.join("")}return Fe(m),T},toWireType:function(m,v){v instanceof ArrayBuffer&&(v=new Uint8Array(v));var w,T=typeof v=="string";T||v instanceof Uint8Array||v instanceof Uint8ClampedArray||v instanceof Int8Array||G("Cannot pass non-string to std::string"),c&&T?w=Ln(v):w=v.length;var b=st(4+w+1),k=b+4;if(U[b>>2]=w,c&&T)Nt(v,k,w+1);else if(T)for(var E=0;E<w;++E){var W=v.charCodeAt(E);W>255&&(Fe(k),G("String has UTF-16 code units that do not fit in 8 bits")),J[k+E]=W}else for(var E=0;E<w;++E)J[k+E]=v[E];return m!==null&&m.push(Fe,b),b},argPackAdvance:8,readValueFromPointer:Dr,destructorFunction:function(m){Fe(m)}})}var nt=typeof TextDecoder!="undefined"?new TextDecoder("utf-16le"):void 0,it=(i,o)=>{for(var c=i,m=c>>1,v=m+o/2;!(m>=v)&&Te[m];)++m;if(c=m<<1,c-i>32&&nt)return nt.decode(J.subarray(i,c));for(var w="",T=0;!(T>=o/2);++T){var b=oe[i+T*2>>1];if(b==0)break;w+=String.fromCharCode(b)}return w},Wn=(i,o,c)=>{if(c===void 0&&(c=2147483647),c<2)return 0;c-=2;for(var m=o,v=c<i.length*2?c/2:i.length,w=0;w<v;++w){var T=i.charCodeAt(w);oe[o>>1]=T,o+=2}return oe[o>>1]=0,o-m},Ht=i=>i.length*2,Hn=(i,o)=>{for(var c=0,m="";!(c>=o/4);){var v=Pe[i+c*4>>2];if(v==0)break;if(++c,v>=65536){var w=v-65536;m+=String.fromCharCode(55296|w>>10,56320|w&1023)}else m+=String.fromCharCode(v)}return m},Bt=(i,o,c)=>{if(c===void 0&&(c=2147483647),c<4)return 0;for(var m=o,v=m+c-4,w=0;w<i.length;++w){var T=i.charCodeAt(w);if(T>=55296&&T<=57343){var b=i.charCodeAt(++w);T=65536+((T&1023)<<10)|b&1023}if(Pe[o>>2]=T,o+=4,o+4>v)break}return Pe[o>>2]=0,o-m},Vt=i=>{for(var o=0,c=0;c<i.length;++c){var m=i.charCodeAt(c);m>=55296&&m<=57343&&++c,o+=4}return o},Bn=function(i,o,c){c=he(c);var m,v,w,T,b;o===2?(m=it,v=Wn,T=Ht,w=()=>Te,b=1):o===4&&(m=Hn,v=Bt,T=Vt,w=()=>U,b=2),Se(i,{name:c,fromWireType:function(k){for(var E=U[k>>2],W=w(),B,V=k+4,Y=0;Y<=E;++Y){var ne=k+4+Y*o;if(Y==E||W[ne>>b]==0){var Ee=ne-V,de=m(V,Ee);B===void 0?B=de:(B+="\0",B+=de),V=ne+o}}return Fe(k),B},toWireType:function(k,E){typeof E!="string"&&G(`Cannot pass non-string to C++ string type ${c}`);var W=T(E),B=st(4+W+o);return U[B>>2]=W>>b,v(E,B+4,W+o),k!==null&&k.push(Fe,B),B},argPackAdvance:8,readValueFromPointer:Dr,destructorFunction:function(k){Fe(k)}})};function Vn(i,o){o=he(o),Se(i,{isVoid:!0,name:o,argPackAdvance:0,fromWireType:function(){},toWireType:function(c,m){}})}var jn={};function jt(i){var o=jn[i];return o===void 0?he(i):o}var ye=[];function zt(i,o,c,m){i=ye[i],o=er.toValue(o),c=jt(c),i(o,c,null,m)}function zn(i){var o=ye.length;return ye.push(i),o}function Gn(i,o){var c=Je[i];return c===void 0&&G(o+" has unknown type "+It(i)),c}function Or(i,o){for(var c=new Array(i),m=0;m<i;++m)c[m]=Gn(U[o+m*4>>2],"parameter "+m);return c}var Gt=[];function ot(i,o){var c=Or(i,o),m=c[0],v=m.name+"_$"+c.slice(1).map(function(ne){return ne.name}).join("_")+"$",w=Gt[v];if(w!==void 0)return w;for(var T=["retType"],b=[m],k="",E=0;E<i-1;++E)k+=(E!==0?", ":"")+"arg"+E,T.push("argType"+E),b.push(c[1+E]);for(var W=Ar("methodCaller_"+v),B="return function "+W+`(handle, name, destructors, args) {
38
38
  `,V=0,E=0;E<i-1;++E)B+=" var arg"+E+" = argType"+E+".readValueFromPointer(args"+(V?"+"+V:"")+`);
39
39
  `,V+=c[E+1].argPackAdvance;B+=" var rv = handle[name]("+k+`);
40
40
  `;for(var E=0;E<i-1;++E)c[E+1].deleteObject&&(B+=" argType"+E+".deleteObject(arg"+E+`);
41
41
  `);m.isVoid||(B+=` return retType.toWireType(destructors, rv);
42
42
  `),B+=`};
43
- `,T.push(B);var Y=Ot(Function,T).apply(null,b);return w=zn(Y),Gt[v]=w,w}var qn=()=>{or("")},qt;qt=()=>performance.now();var Xn=(i,o,c)=>J.copyWithin(i,o,o+c),Kn=i=>{or("OOM")},Jn=i=>{var o=J.length;i>>>=0,Kn(i)},Yn=[null,[],[]],Zn=(i,o)=>{var c=Yn[i];o===0||o===10?((i===1?lr:ae)(rr(c,0)),c.length=0):c.push(o)},at={varargs:void 0,get(){at.varargs+=4;var i=Pe[at.varargs-4>>2];return i},getStr(i){var o=Lt(i);return o}},Qn=(i,o,c,m)=>{for(var v=0,w=0;w<c;w++){var T=U[o>>2],b=U[o+4>>2];o+=8;for(var k=0;k<b;k++)Zn(i,J[T+k]);v+=b}return U[m>>2]=v,0};_n(),le=s.BindingError=class extends Error{constructor(o){super(o),this.name="BindingError"}},Ye=s.InternalError=class extends Error{constructor(o){super(o),this.name="InternalError"}},hr(),Kr(),gr(),$t=s.UnboundTypeError=kn(Error,"UnboundTypeError"),$n(),On();var ei={o:zr,r:bn,m:wn,q:Dn,p:rt,d:Ut,u:Un,k:Fn,b:Nn,a:Mn,j:Wt,g:Bn,n:Vn,e:zt,l:Ft,h:ot,f:qn,c:qt,t:Xn,s:Jn,i:Qn},li=gt(),ri=()=>(ri=ee.w)(),Fe=i=>(Fe=ee.x)(i),st=i=>(st=ee.y)(i),Xt=i=>(Xt=ee.A)(i),ti=s.__embind_initialize_bindings=()=>(ti=s.__embind_initialize_bindings=ee.B)(),ni=()=>(ni=ee.__errno_location)(),Kt=i=>(Kt=ee.C)(i),ut=s.dynCall_jiji=(i,o,c,m,v)=>(ut=s.dynCall_jiji=ee.D)(i,o,c,m,v),Ur;Ke=function i(){Ur||Jt(),Ur||(Ke=i)};function Jt(){if(Xe>0||(dn(),Xe>0))return;function i(){Ur||(Ur=!0,s.calledRun=!0,!Nr&&(fn(),y(s),s.onRuntimeInitialized&&s.onRuntimeInitialized(),pn()))}s.setStatus?(s.setStatus("Running..."),setTimeout(function(){setTimeout(function(){s.setStatus("")},1),i()},1)):i()}if(s.preInit)for(typeof s.preInit=="function"&&(s.preInit=[s.preInit]);s.preInit.length>0;)s.preInit.pop()();return Jt(),p.ready}})(),Si=Xi;var un=class extends ze{constructor(p){super(Si,p!=null&&p.wasmPath?fetch(p.wasmPath).then(s=>s.arrayBuffer()):void 0,p==null?void 0:p.workerMode,p==null?void 0:p.canvas,p==null?void 0:p.yuvMode)}};var cn=class cn{constructor(p){this.core=p;_e(this,"contextMap",new Map);_e(this,"decodeProcessorMap",new WeakMap);this.createDecoder=this.createDecoder.bind(this)}getAlias(){return"videoDecoder"}getGroup(p){return p!=null&&p.track?`${p.track.userId}${p.track.streamType}`:"*"}getName(){return cn.Name}getValidateRule(p){return{type:this.core.enums.BASIC_TYPE.Object}}createDecoder(p,s){switch(p){case"wasm":return this.core.rtcDectection.isSIMDSupported()?new un(Er(wr({},s),{wasmPath:`${this.core.assetsPath}videodec_simd.wasm`})):new sn(Er(wr({},s),{wasmPath:`${this.core.assetsPath}videodec.wasm`}));case"webCodecs":return new ir;case"mse":throw new Error("mse decoder not supported yet");default:throw new Error("Unsupported decoder type")}}start(p){this.decodeProcessorMap.set(p.track,this.decode(p)),this.core.room.videoManager.addDecodeProcessor({processor:({frame:s,track:y})=>{var P;return((P=this.decodeProcessorMap.get(y))==null?void 0:P({frame:s,track:y}))||s},type:3})}decode(p){let{pipe:s,take:y,subscribe:P}=this.core.rx;return({frame:D,track:$})=>{if($!==p.track||D.type==="empty")return D;if(this.contextMap.has($))return this.contextMap.get($).decode(D);let j=this.core.room.videoManager.createDecodeContext(Er(wr({},p),{createDecoder:this.createDecoder}));return s(j.trackDoneOB,y(1),P(()=>{this.core.clearStarted(this,this.getGroup(p)),this.stop({track:$})})),this.contextMap.set($,j),j.decode(D)}}stop(p){if(!(p!=null&&p.track))this.contextMap.forEach((s,y)=>{s.close("stop"),this.contextMap.delete(y)});else{let s=this.contextMap.get(p.track);s&&(s.close("stop"),this.contextMap.delete(p.track))}this.contextMap.size===0&&this.core.room.videoManager.removeDecodeProcessor({type:3})}update(p){let s=this.contextMap.get(p.track);if(s){if(p.type==="mock"){s.mock(this.core.enums.DECODE_FAILED_ERROR_CODE.TEST);return}s.close("update"),this.contextMap.set(p.track,this.core.room.videoManager.createDecodeContext(Er(wr({},p),{createDecoder:this.createDecoder})))}}};_e(cn,"Name","TRTCVideoDecoder");var ui=cn;var Fo=ui;export{ui as VideoDecoderPlugin,Fo as default};
43
+ `,T.push(B);var Y=Ot(Function,T).apply(null,b);return w=zn(Y),Gt[v]=w,w}var qn=()=>{or("")},qt;qt=()=>performance.now();var Xn=(i,o,c)=>J.copyWithin(i,o,o+c),Kn=i=>{or("OOM")},Jn=i=>{var o=J.length;i>>>=0,Kn(i)},Yn=[null,[],[]],Zn=(i,o)=>{var c=Yn[i];o===0||o===10?((i===1?lr:ae)(rr(c,0)),c.length=0):c.push(o)},at={varargs:void 0,get(){at.varargs+=4;var i=Pe[at.varargs-4>>2];return i},getStr(i){var o=Lt(i);return o}},Qn=(i,o,c,m)=>{for(var v=0,w=0;w<c;w++){var T=U[o>>2],b=U[o+4>>2];o+=8;for(var k=0;k<b;k++)Zn(i,J[T+k]);v+=b}return U[m>>2]=v,0};_n(),le=s.BindingError=class extends Error{constructor(o){super(o),this.name="BindingError"}},Ye=s.InternalError=class extends Error{constructor(o){super(o),this.name="InternalError"}},hr(),Kr(),gr(),$t=s.UnboundTypeError=kn(Error,"UnboundTypeError"),$n(),On();var ei={o:zr,r:bn,m:wn,q:Dn,p:rt,d:Ut,u:Un,k:Fn,b:Nn,a:Mn,j:Wt,g:Bn,n:Vn,e:zt,l:Ft,h:ot,f:qn,c:qt,t:Xn,s:Jn,i:Qn},li=gt(),ri=()=>(ri=ee.w)(),Fe=i=>(Fe=ee.x)(i),st=i=>(st=ee.y)(i),Xt=i=>(Xt=ee.A)(i),ti=s.__embind_initialize_bindings=()=>(ti=s.__embind_initialize_bindings=ee.B)(),ni=()=>(ni=ee.__errno_location)(),Kt=i=>(Kt=ee.C)(i),ut=s.dynCall_jiji=(i,o,c,m,v)=>(ut=s.dynCall_jiji=ee.D)(i,o,c,m,v),Ur;Ke=function i(){Ur||Jt(),Ur||(Ke=i)};function Jt(){if(Xe>0||(dn(),Xe>0))return;function i(){Ur||(Ur=!0,s.calledRun=!0,!Nr&&(fn(),y(s),s.onRuntimeInitialized&&s.onRuntimeInitialized(),pn()))}s.setStatus?(s.setStatus("Running..."),setTimeout(function(){setTimeout(function(){s.setStatus("")},1),i()},1)):i()}if(s.preInit)for(typeof s.preInit=="function"&&(s.preInit=[s.preInit]);s.preInit.length>0;)s.preInit.pop()();return Jt(),p.ready}})(),Si=Xi;var un=class extends ze{constructor(p){super(Si,p!=null&&p.wasmPath?fetch(p.wasmPath).then(s=>s.arrayBuffer()):void 0,p==null?void 0:p.workerMode,p==null?void 0:p.canvas,p==null?void 0:p.yuvMode)}};var cn=class cn{constructor(p){this.core=p;_e(this,"contextMap",new Map);_e(this,"decodeProcessorMap",new WeakMap);this.createDecoder=this.createDecoder.bind(this)}getAlias(){return"videoDecoder"}getGroup(p){return p!=null&&p.track?`${p.track.userId}${p.track.streamType}`:"*"}getName(){return cn.Name}getValidateRule(p){return{type:this.core.enums.BASIC_TYPE.Object}}createDecoder(p,s){switch(p){case"wasm":return this.core.rtcDectection.isSIMDSupported()?new un(Er(wr({},s),{wasmPath:`${this.core.assetsPath||"."}/videodec_simd.wasm`})):new sn(Er(wr({},s),{wasmPath:`${this.core.assetsPath||"."}/videodec.wasm`}));case"webCodecs":return new ir;case"mse":throw new Error("mse decoder not supported yet");default:throw new Error("Unsupported decoder type")}}start(p){this.decodeProcessorMap.set(p.track,this.decode(p)),this.core.room.videoManager.addDecodeProcessor({processor:({frame:s,track:y})=>{var P;return((P=this.decodeProcessorMap.get(y))==null?void 0:P({frame:s,track:y}))||s},type:3})}decode(p){let{pipe:s,take:y,subscribe:P}=this.core.rx;return({frame:D,track:$})=>{if($!==p.track||D.type==="empty")return D;if(this.contextMap.has($))return this.contextMap.get($).decode(D);let j=this.core.room.videoManager.createDecodeContext(Er(wr({},p),{createDecoder:this.createDecoder}));return s(j.trackDoneOB,y(1),P(()=>{this.core.clearStarted(this,this.getGroup(p)),this.stop({track:$})})),this.contextMap.set($,j),j.decode(D)}}stop(p){if(!(p!=null&&p.track))this.contextMap.forEach((s,y)=>{s.close("stop"),this.contextMap.delete(y)});else{let s=this.contextMap.get(p.track);s&&(s.close("stop"),this.contextMap.delete(p.track))}this.contextMap.size===0&&this.core.room.videoManager.removeDecodeProcessor({type:3})}update(p){let s=this.contextMap.get(p.track);if(s){if(p.type==="mock"){s.mock(this.core.enums.DECODE_FAILED_ERROR_CODE.TEST);return}s.close("update"),this.contextMap.set(p.track,this.core.room.videoManager.createDecodeContext(Er(wr({},p),{createDecoder:this.createDecoder})))}}};_e(cn,"Name","TRTCVideoDecoder");var ui=cn;var Fo=ui;export{ui as VideoDecoderPlugin,Fo as default};