trtc-sdk-v5
Version:
Tencent Cloud RTC SDK for Web
1 lines • 100 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).TRTCVideoDecoder=t()}(this,(function(){"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function t(e,t,r,n,o,i,a){try{var s=e[i](a),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,o)}function r(e){return function(){var r=this,n=arguments;return new Promise((function(o,i){var a=e.apply(r,n);function s(e){t(a,o,i,s,c,"next",e)}function c(e){t(a,o,i,s,c,"throw",e)}s(void 0)}))}}function n(e,t,r){return t=u(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,l()?Reflect.construct(t,r||[],u(e).constructor):t.apply(e,r))}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,v(n.key),n)}}function a(e,t,r){return t&&i(e.prototype,t),r&&i(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=y(e))||t){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}function c(e,t,r){return(t=v(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function f(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(l=function(){return!!e})()}function d(){d=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var i=t&&t.prototype instanceof g?t:g,a=Object.create(i.prototype),s=new O(n||[]);return o(a,"_invoke",{value:A(e,r,s)}),a}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var h="suspendedStart",p="suspendedYield",v="executing",m="completed",y={};function g(){}function w(){}function b(){}var E={};u(E,a,(function(){return this}));var k=Object.getPrototypeOf,_=k&&k(k(F([])));_&&_!==r&&n.call(_,a)&&(E=_);var P=b.prototype=g.prototype=Object.create(E);function T(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function r(o,i,a,s){var c=l(e[o],e,i);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,a,s)}),(function(e){r("throw",e,a,s)})):t.resolve(f).then((function(e){u.value=e,a(u)}),(function(e){return r("throw",e,a,s)}))}s(c.arg)}var i;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return i=i?i.then(o,o):o()}})}function A(t,r,n){var o=h;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===m){if("throw"===i)throw a;return{value:e,done:!0}}for(n.method=i,n.arg=a;;){var s=n.delegate;if(s){var c=C(s,n);if(c){if(c===y)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var u=l(t,r,n);if("normal"===u.type){if(o=n.done?m:p,u.arg===y)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(o=m,n.method="throw",n.arg=u.arg)}}}function C(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,C(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var i=l(o,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var a=i.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function D(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function O(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(D,this),this.reset(!0)}function F(t){if(t||""===t){var r=t[a];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(typeof t+" is not iterable")}return w.prototype=b,o(P,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:w,configurable:!0}),w.displayName=u(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===w||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,c,"GeneratorFunction")),e.prototype=Object.create(P),e},t.awrap=function(e){return{__await:e}},T(S.prototype),u(S.prototype,s,(function(){return this})),t.AsyncIterator=S,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new S(f(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},T(P),u(P,c,"Generator"),u(P,a,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=F,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(x),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return s.type="throw",s.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),x(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:F(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function p(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||y(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function m(e){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},m(e)}function y(t,r){if(t){if("string"==typeof t)return e(t,r);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,r):void 0}}function g(e){var t="function"==typeof Map?new Map:void 0;return g=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return function(e,t,r){if(l())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var o=new(e.bind.apply(e,n));return r&&h(o,r.prototype),o}(e,arguments,u(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),h(r,e)},g(e)}var w,b,E=Object.create,k=Object.defineProperty,_=Object.defineProperties,P=Object.getOwnPropertyDescriptor,T=Object.getOwnPropertyDescriptors,S=Object.getOwnPropertyNames,A=Object.getOwnPropertySymbols,C=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable,O=function(e,t,r){return t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r},F=function(e,t){for(var r in t||(t={}))D.call(t,r)&&O(e,r,t[r]);if(A){var n,o=s(A(t));try{for(o.s();!(n=o.n()).done;){r=n.value;x.call(t,r)&&O(e,r,t[r])}}catch(e){o.e(e)}finally{o.f()}}return e},j=function(e,t){return _(e,T(t))},M=function(e,t,r,n){for(var o,i=P(t,r),a=e.length-1;a>=0;a--)(o=e[a])&&(i=o(t,r,i)||i);return i&&k(t,r,i),i},$=function(e,t,r){return O(e,"symbol"!==m(t)?t+"":t,r)},R=(w={"../node_modules/.pnpm/eventemitter3@4.0.7/node_modules/eventemitter3/index.js":function(e,t){var r=Object.prototype.hasOwnProperty,n="~";function o(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,r,o,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new i(r,o||e,a),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new o:delete e._events[t]}function c(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(n=!1)),c.prototype.eventNames=function(){var e,t,o=[];if(0===this._eventsCount)return o;for(t in e=this._events)r.call(e,t)&&o.push(n?t.slice(1):t);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},c.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,a=new Array(i);o<i;o++)a[o]=r[o].fn;return a},c.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},c.prototype.emit=function(e,t,r,o,i,a){var s=n?n+e:e;if(!this._events[s])return!1;var c,u,f=this._events[s],l=arguments.length;if(f.fn){switch(f.once&&this.removeListener(e,f.fn,void 0,!0),l){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,t),!0;case 3:return f.fn.call(f.context,t,r),!0;case 4:return f.fn.call(f.context,t,r,o),!0;case 5:return f.fn.call(f.context,t,r,o,i),!0;case 6:return f.fn.call(f.context,t,r,o,i,a),!0}for(u=1,c=new Array(l-1);u<l;u++)c[u-1]=arguments[u];f.fn.apply(f.context,c)}else{var d,h=f.length;for(u=0;u<h;u++)switch(f[u].once&&this.removeListener(e,f[u].fn,void 0,!0),l){case 1:f[u].fn.call(f[u].context);break;case 2:f[u].fn.call(f[u].context,t);break;case 3:f[u].fn.call(f[u].context,t,r);break;case 4:f[u].fn.call(f[u].context,t,r,o);break;default:if(!c)for(d=1,c=new Array(l-1);d<l;d++)c[d-1]=arguments[d];f[u].fn.apply(f[u].context,c)}}return!0},c.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},c.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},c.prototype.removeListener=function(e,t,r,o){var i=n?n+e:e;if(!this._events[i])return this;if(!t)return s(this,i),this;var a=this._events[i];if(a.fn)a.fn!==t||o&&!a.once||r&&a.context!==r||s(this,i);else{for(var c=0,u=[],f=a.length;c<f;c++)(a[c].fn!==t||o&&!a[c].once||r&&a[c].context!==r)&&u.push(a[c]);u.length?this._events[i]=1===u.length?u[0]:u:s(this,i)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&s(this,t)):(this._events=new o,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=n,c.EventEmitter=c,void 0!==t&&(t.exports=c)}},function(){return b||(0,w[S(w)[0]])((b={exports:{}}).exports,b),b.exports}),L=function(e,t,r){return r=null!=e?E(C(e)):{},function(e,t,r,n){if(t&&"object"===m(t)||"function"==typeof t){var o,i=s(S(t));try{var a=function(){var i=o.value;D.call(e,i)||i===r||k(e,i,{get:function(){return t[i]},enumerable:!(n=P(t,i))||n.enumerable})};for(i.s();!(o=i.n()).done;)a()}catch(e){i.e(e)}finally{i.f()}}return e}(k(r,"default",{value:e,enumerable:!0}),e)}(R()),N=Symbol("instance"),U=Symbol("cacheResult"),z=function(){return a((function e(t,r,n){o(this,e),this.oldState=t,this.newState=r,this.action=n,this.aborted=!1}),[{key:"abort",value:function(e){this.aborted=!0,q.call(e,this.oldState,new Error("action '".concat(this.action,"' aborted")))}},{key:"toString",value:function(){return"".concat(this.action,"ing")}}])}(),I=function(e){function t(e,r,i){var a;return o(this,t),(a=n(this,t,[r])).state=e,a.message=r,a.cause=i,a}return f(t,e),a(t)}(g(Error));var B=new Map;function W(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(n,o,i){var a=r.action||o;if(!r.context){var s=B.get(n)||[];B.has(n)||B.set(n,s),s.push({from:e,to:t,action:a})}var c=i.value;i.value=function(){for(var n,o=this,i=this,s=arguments.length,u=new Array(s),f=0;f<s;f++)u[f]=arguments[f];r.context&&(i=X.get("function"==typeof r.context?(n=r.context).call.apply(n,[this].concat(u)):r.context));if(i.state===t)return r.sync?i[U]:Promise.resolve(i[U]);i.state instanceof z&&i.state.action==r.abortAction&&i.state.abort(i);var l=null;Array.isArray(e)?0==e.length?i.state instanceof z&&i.state.abort(i):"string"==typeof i.state&&e.includes(i.state)||(l=new I(i._state,"".concat(i.name," ").concat(a," to ").concat(t," failed: current state ").concat(i._state," not from ").concat(e.join("|")))):e!==i.state&&(l=new I(i._state,"".concat(i.name," ").concat(a," to ").concat(t," failed: current state ").concat(i._state," not from ").concat(e)));var d=function(e){if(r.fail&&r.fail.call(o,e),r.sync){if(r.ignoreError)return e;throw e}return r.ignoreError?Promise.resolve(e):Promise.reject(e)};if(l)return d(l);var h=i.state,p=new z(h,t,a);q.call(i,p);var v,y=function(e){var n;return i[U]=e,p.aborted||(q.call(i,t),null===(n=r.success)||void 0===n||n.call(o,i[U])),e},g=function(e){return q.call(i,h,e),d(e)};try{var w=c.apply(this,u);return"object"===m(v=w)&&v&&"then"in v?w.then(y).catch(g):r.sync?y(w):Promise.resolve(y(w))}catch(r){return g(new I(i._state,"".concat(i.name," ").concat(a," from ").concat(e," to ").concat(t," failed: ").concat(r),r instanceof Error?r:new Error(String(r))))}}}}var H,V,G=(H="undefined"!=typeof window&&window.__AFSM__,V="undefined"!=typeof importScripts,H?function(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t}))}:V?function(e,t){postMessage({type:e,payload:t})}:function(){});function q(e,t){var r=this._state;this._state=e;var n=e.toString();e&&this.emit(n,r),this.emit(X.STATECHANGED,e,r,t),this.updateDevTools({value:e,old:r,err:t instanceof Error?t.message:String(t)})}var X=function(e){function t(e,r,i){var a;o(this,t),(a=n(this,t)).name=e,a.groupName=r,a._state=t.INIT,e||(e=Date.now().toString(36)),i?Object.setPrototypeOf(a,i):i=Object.getPrototypeOf(a),r||(a.groupName=a.constructor.name);var s=i[N];return s?a.name=s.name+"-"+s.count++:i[N]={name:a.name,count:0},a.updateDevTools({diagram:a.stateDiagram}),a}return f(t,e),a(t,[{key:"stateDiagram",get:function(){var e=Object.getPrototypeOf(this),t=B.get(e)||[],r=new Set,n=[],o=[],i=new Set,a=Object.getPrototypeOf(e);B.has(a)&&(a.stateDiagram.forEach((function(e){return r.add(e)})),a.allStates.forEach((function(e){return i.add(e)}))),t.forEach((function(e){var t=e.from,r=e.to,i=e.action;"string"==typeof t?n.push({from:t,to:r,action:i}):t.length?t.forEach((function(e){n.push({from:e,to:r,action:i})})):o.push({to:r,action:i})})),n.forEach((function(e){var t=e.from,n=e.to,o=e.action;i.add(t),i.add(n),i.add(o+"ing"),r.add("".concat(t," --\x3e ").concat(o,"ing : ").concat(o)),r.add("".concat(o,"ing --\x3e ").concat(n," : ").concat(o," 🟢")),r.add("".concat(o,"ing --\x3e ").concat(t," : ").concat(o," 🔴"))})),o.forEach((function(e){var t=e.to,n=e.action;r.add("".concat(n,"ing --\x3e ").concat(t," : ").concat(n," 🟢")),i.forEach((function(e){e!==t&&r.add("".concat(e," --\x3e ").concat(n,"ing : ").concat(n))}))}));var s=p(r);return Object.defineProperties(e,{stateDiagram:{value:s},allStates:{value:i}}),s}},{key:"updateDevTools",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};G(t.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},e))}},{key:"state",get:function(){return this._state},set:function(e){q.call(this,e)}}],[{key:"get",value:function(e){var r;return"string"==typeof e?(r=t.instances.get(e))||t.instances.set(e,r=new t(e,void 0,Object.create(t.prototype))):(r=t.instances2.get(e))||t.instances2.set(e,r=new t(e.constructor.name,void 0,Object.create(t.prototype))),r}},{key:"getState",value:function(e){var r;return null===(r=t.get(e))||void 0===r?void 0:r.state}}])}(L.default);X.STATECHANGED="stateChanged",X.UPDATEAFSM="updateAFSM",X.INIT="[*]",X.ON="on",X.OFF="off",X.instances=new Map,X.instances2=new WeakMap;var K=function(e){function t(){var e;return o(this,t),e=n(this,t,arguments),$(e,"decoder"),$(e,"config"),e}return f(t,e),a(t,[{key:"initialize",value:(i=r(d().mark((function e(){var t=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.decoder=new VideoDecoder({output:function(e){t.emit("videoFrame",e)},error:function(e){t.close(),t.emit("error",e)}});case 1:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"configure",value:function(e){this.config=e,this.decoder.configure(j(F({},e),{codec:this.getCodec(e)}))}},{key:"getCodec",value:function(e){switch(e.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 e.codec}}},{key:"decode",value:function(e){"configured"===this.decoder.state&&this.decoder.decode(new EncodedVideoChunk(e))}},{key:"flush",value:function(){this.decoder.flush()}},{key:"reset",value:function(){this.decoder.reset()}},{key:"close",value:function(){"closed"!==this.decoder.state&&this.decoder.close()}}]);var i}(X);function J(){var e;self.onmessage=function(t){if("init"===t.data.type){var r=t.data,n=r.canvas,o=r.wasmScript,i=r.wasmBinary,a=null==n?void 0:n.getContext("2d"),s=0,c=0,u={wasmBinary:i,postRun:function(){e=new u.VideoDecoder({videoInfo:function(e,t){s=e,c=t,console.log("video info",e,t)},yuvData:function(e,t){var r=s*c,o=r>>2,i=u.HEAPU32[e>>2],f=u.HEAPU32[1+(e>>2)],l=u.HEAPU32[2+(e>>2)],d=u.HEAPU8.subarray(i,i+r),h=u.HEAPU8.subarray(f,f+o),p=u.HEAPU8.subarray(l,l+o),v=new Uint8Array(r+o+o);v.set(d),v.set(h,r),v.set(p,r+o);var m=new VideoFrame(v,{codedWidth:s,codedHeight:c,format:"I420",timestamp:t});n?(null==a||a.drawImage(m,0,0,n.width,n.height),null==a||a.commit()):self.postMessage({type:"yuvData",videoFrame:m},[m])}}),self.postMessage({type:"ready"})}};Function("var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;return "+o)()(u)}else if("decode"===t.data.type){var f=t.data.packet;null==e||e.decode(f.data,"key"==f.type,f.timestamp)}else if("setCodec"===t.data.type){var l=t.data,d=l.codec,h=l.format,p=l.description;null==e||e.setCodec(d,h,null!=p?p:"")}}}M([W([X.INIT,"closed"],"initialized")],K.prototype,"initialize"),M([W("initialized","configured",{sync:!0})],K.prototype,"configure"),M([function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e,r,n){var o=n.value,i=r;n.value=function(){if(!t.includes(this.state.toString()))throw new I(this.state,"".concat(this.name," ").concat(i," failed: current state ").concat(this.state," not in ").concat(t));for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return o.apply(this,r)}}}("configured")],K.prototype,"decode"),M([W([],X.INIT,{sync:!0})],K.prototype,"reset"),M([W([],"closed",{ignoreError:!0,sync:!0})],K.prototype,"close");var Y=function(e){function t(e,r){var i,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=arguments.length>3?arguments[3]:void 0,c=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return o(this,t),(i=n(this,t)).createModule=e,i.wasmBinary=r,i.workerMode=a,i.canvas=s,i.yuvMode=c,$(i,"worker"),$(i,"decoder"),$(i,"config"),$(i,"module",{}),$(i,"width",0),$(i,"height",0),i}return f(t,e),a(t,[{key:"initialize",value:(i=r(d().mark((function e(t){var r,n,o,i,a,s=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.workerMode){e.next=10;break}return n=new RegExp("\\{(.+)\\}","s").exec(J.toString())[1],this.worker=new Worker(URL.createObjectURL(new Blob([n],{type:"text/javascript"}))),o=null==(r=this.canvas)?void 0:r.transferControlToOffscreen(),e.next=6,this.wasmBinary;case 6:return i=e.sent,console.warn("worker mode",i),this.worker.postMessage({type:"init",canvas:o,wasmScript:this.createModule.toString(),wasmBinary:i},o?[o,i]:[i]),e.abrupt("return",new Promise((function(e){s.worker.onmessage=function(t){if("ready"===t.data.type)delete s.wasmBinary,e(),console.warn("worker mode initialize success");else if("yuvData"===t.data.type){var r=t.data.videoFrame;s.emit("videoFrame",r)}}})));case 10:if(a=this.module,!this.wasmBinary){e.next=15;break}return e.next=14,this.wasmBinary;case 14:a.wasmBinary=e.sent;case 15:return a.print=function(e){return console.log(e)},a.printErr=function(e){return console.log("[JS] ERROR: ".concat(e))},a.onAbort=function(){return console.log("[JS] FATAL: WASM ABORTED")},e.abrupt("return",new Promise((function(e){a.postRun=function(t){s.decoder=new s.module.VideoDecoder(s),console.log("video soft decoder initialize success"),e()},t&&Object.assign(a,t),s.createModule(a)})));case 19:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"configure",value:function(e){var t,r,n;this.config=e;var o=this.config.codec.startsWith("avc")?"avc":"hevc",i=this.config.description?"avc"==o?"avcc":"hvcc":"annexb";null==(r=this.decoder)||r.setCodec(o,i,null!=(t=this.config.description)?t:""),null==(n=this.worker)||n.postMessage({type:"setCodec",codec:o,format:i,description:this.config.description})}},{key:"decode",value:function(e){var t,r;null==(t=this.decoder)||t.decode(e.data,"key"==e.type,e.timestamp),"configured"===this.state&&(null==(r=this.worker)||r.postMessage({type:"decode",packet:e}))}},{key:"flush",value:function(){}},{key:"reset",value:function(){this.config=void 0,this.decoder&&this.decoder.clear()}},{key:"close",value:function(){this.removeAllListeners(),this.decoder&&(this.decoder.clear(),this.decoder.delete())}},{key:"videoInfo",value:function(e,t){this.width=e,this.height=t;var r={width:e,height:t};this.emit("videoCodecInfo",r)}},{key:"yuvData",value:function(e,t){if(this.module){var r=this.width*this.height,n=r>>2,o=this.module.HEAPU32[e>>2],i=this.module.HEAPU32[1+(e>>2)],a=this.module.HEAPU32[2+(e>>2)],s=this.module.HEAPU8.subarray(o,o+r),c=this.module.HEAPU8.subarray(i,i+n),u=this.module.HEAPU8.subarray(a,a+n);if(this.yuvMode)this.emit("videoFrame",{y:s,u:c,v:u,timestamp:t});else{var f=new Uint8Array(r+n+n);f.set(s),f.set(c,r),f.set(u,r+n),this.emit("videoFrame",new VideoFrame(f,{codedWidth:this.width,codedHeight:this.height,format:"I420",timestamp:t}))}}}},{key:"errorInfo",value:function(e){var t={errMsg:e};this.emit("error",t)}}]);var i}(X);M([W([X.INIT,"closed"],"initialized")],Y.prototype,"initialize"),M([W("initialized","configured",{sync:!0})],Y.prototype,"configure"),M([W([],X.INIT,{sync:!0})],Y.prototype,"reset"),M([W([],"closed",{sync:!0})],Y.prototype,"close");var Z,Q=(Z="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(){var e,t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=r;i.ready=new Promise((function(r,n){e=r,t=n}));var s=Object.assign({},i),u="./this.program",l="object"==("undefined"==typeof window?"undefined":m(window)),d="function"==typeof importScripts;"object"==("undefined"==typeof process?"undefined":m(process))&&"object"==m(process.versions)&&process.versions.node;var h,p,v,y="";(l||d)&&(d?y=self.location.href:"undefined"!=typeof document&&document.currentScript&&(y=document.currentScript.src),Z&&(y=Z),y=0!==y.indexOf("blob:")?y.substr(0,y.replace(/[?#].*/,"").lastIndexOf("/")+1):"",h=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},d&&(v=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),p=function(e,t,r){var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=function(){200==n.status||0==n.status&&n.response?t(n.response):r()},n.onerror=r,n.send(null)});var w,b,E,k=i.print||console.log.bind(console),_=i.printErr||console.error.bind(console);Object.assign(i,s),s=null,i.arguments&&i.arguments,i.thisProgram&&(u=i.thisProgram),i.quit&&i.quit,i.wasmBinary&&(w=i.wasmBinary),i.noExitRuntime,"object"!=("undefined"==typeof WebAssembly?"undefined":m(WebAssembly))&&q("no native wasm support detected");var P,T,S,A,C,D,x,O,F,j=!1,M=[],$=[],R=[];function L(e){M.unshift(e)}function N(e){R.unshift(e)}var U,z,I,B,W=0,H=null;function V(e){W++,i.monitorRunDependencies&&i.monitorRunDependencies(W)}function G(e){if(W--,i.monitorRunDependencies&&i.monitorRunDependencies(W),0==W&&H){var t=H;H=null,t()}}function q(e){i.onAbort&&i.onAbort(e),_(e="Aborted("+e+")"),j=!0,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw t(r),r}function X(e){return e.startsWith("data:application/octet-stream;base64,")}function K(e){if(e==U&&w)return new Uint8Array(w);if(v)return v(e);throw"both async and sync fetching of the wasm failed"}function J(e,t,r){return function(e){return w||!l&&!d||"function"!=typeof fetch?Promise.resolve().then((function(){return K(e)})):fetch(e,{credentials:"same-origin"}).then((function(t){if(!t.ok)throw"failed to load wasm binary file at '"+e+"'";return t.arrayBuffer()})).catch((function(){return K(e)}))}(e).then((function(e){return WebAssembly.instantiate(e,t)})).then((function(e){return e})).then(r,(function(e){_("failed to asynchronously prepare wasm: "+e),q(e)}))}X(U="videodec.wasm")||(z=U,U=i.locateFile?i.locateFile(z,y):y+z);var Y=function(e){for(;e.length>0;)e.shift()(i)};function Q(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(e){D[this.ptr+4>>2]=e},this.get_type=function(){return D[this.ptr+4>>2]},this.set_destructor=function(e){D[this.ptr+8>>2]=e},this.get_destructor=function(){return D[this.ptr+8>>2]},this.set_caught=function(e){e=e?1:0,P[this.ptr+12|0]=e},this.get_caught=function(){return 0!=P[this.ptr+12|0]},this.set_rethrown=function(e){e=e?1:0,P[this.ptr+13|0]=e},this.get_rethrown=function(){return 0!=P[this.ptr+13|0]},this.init=function(e,t){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(t)},this.set_adjusted_ptr=function(e){D[this.ptr+16>>2]=e},this.get_adjusted_ptr=function(){return D[this.ptr+16>>2]},this.get_exception_ptr=function(){if(Qt(this.get_type()))return D[this.excPtr>>2];var e=this.get_adjusted_ptr();return 0!==e?e:this.excPtr}}var ee={isAbs:function(e){return"/"===e.charAt(0)},splitPath:function(e){return/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1)},normalizeArray:function(e,t){for(var r=0,n=e.length-1;n>=0;n--){var o=e[n];"."===o?e.splice(n,1):".."===o?(e.splice(n,1),r++):r&&(e.splice(n,1),r--)}if(t)for(;r;r--)e.unshift("..");return e},normalize:function(e){var t=ee.isAbs(e),r="/"===e.substr(-1);return(e=ee.normalizeArray(e.split("/").filter((function(e){return!!e})),!t).join("/"))||t||(e="."),e&&r&&(e+="/"),(t?"/":"")+e},dirname:function(e){var t=ee.splitPath(e),r=t[0],n=t[1];return r||n?(n&&(n=n.substr(0,n.length-1)),r+n):"."},basename:function(e){if("/"===e)return"/";var t=(e=(e=ee.normalize(e)).replace(/\/$/,"")).lastIndexOf("/");return-1===t?e:e.substr(t+1)},join:function(){var e=Array.prototype.slice.call(arguments);return ee.normalize(e.join("/"))},join2:function(e,t){return ee.normalize(e+"/"+t)}},te=function(e){return(te=function(){if("object"==("undefined"==typeof crypto?"undefined":m(crypto))&&"function"==typeof crypto.getRandomValues)return function(e){return crypto.getRandomValues(e)};q("initRandomDevice")}())(e)},re={resolve:function(){for(var e="",t=!1,r=arguments.length-1;r>=-1&&!t;r--){var n=r>=0?arguments[r]:ve.cwd();if("string"!=typeof n)throw new TypeError("Arguments to path.resolve must be strings");if(!n)return"";e=n+"/"+e,t=ee.isAbs(n)}return(t?"/":"")+(e=ee.normalizeArray(e.split("/").filter((function(e){return!!e})),!t).join("/"))||"."},relative:function(e,t){function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var r=e.length-1;r>=0&&""===e[r];r--);return t>r?[]:e.slice(t,r-t+1)}e=re.resolve(e).substr(1),t=re.resolve(t).substr(1);for(var n=r(e.split("/")),o=r(t.split("/")),i=Math.min(n.length,o.length),a=i,s=0;s<i;s++)if(n[s]!==o[s]){a=s;break}var c=[];for(s=a;s<n.length;s++)c.push("..");return(c=c.concat(o.slice(a))).join("/")}},ne="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,oe=function(e,t,r){for(var n=t+r,o=t;e[o]&&!(o>=n);)++o;if(o-t>16&&e.buffer&&ne)return ne.decode(e.subarray(t,o));for(var i="";t<o;){var a=e[t++];if(128&a){var s=63&e[t++];if(192!=(224&a)){var c=63&e[t++];if((a=224==(240&a)?(15&a)<<12|s<<6|c:(7&a)<<18|s<<12|c<<6|63&e[t++])<65536)i+=String.fromCharCode(a);else{var u=a-65536;i+=String.fromCharCode(55296|u>>10,56320|1023&u)}}else i+=String.fromCharCode((31&a)<<6|s)}else i+=String.fromCharCode(a)}return i},ie=[],ae=function(e){for(var t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);n<=127?t++:n<=2047?t+=2:n>=55296&&n<=57343?(t+=4,++r):t+=3}return t},se=function(e,t,r,n){if(!(n>0))return 0;for(var o=r,i=r+n-1,a=0;a<e.length;++a){var s=e.charCodeAt(a);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++a)),s<=127){if(r>=i)break;t[r++]=s}else if(s<=2047){if(r+1>=i)break;t[r++]=192|s>>6,t[r++]=128|63&s}else if(s<=65535){if(r+2>=i)break;t[r++]=224|s>>12,t[r++]=128|s>>6&63,t[r++]=128|63&s}else{if(r+3>=i)break;t[r++]=240|s>>18,t[r++]=128|s>>12&63,t[r++]=128|s>>6&63,t[r++]=128|63&s}}return t[r]=0,r-o};function ce(e,t,r){var n=ae(e)+1,o=new Array(n),i=se(e,o,0,o.length);return o.length=i,o}var ue={ttys:[],init:function(){},shutdown:function(){},register:function(e,t){ue.ttys[e]={input:[],output:[],ops:t},ve.registerDevice(e,ue.stream_ops)},stream_ops:{open:function(e){var t=ue.ttys[e.node.rdev];if(!t)throw new ve.ErrnoError(43);e.tty=t,e.seekable=!1},close:function(e){e.tty.ops.fsync(e.tty)},fsync:function(e){e.tty.ops.fsync(e.tty)},read:function(e,t,r,n,o){if(!e.tty||!e.tty.ops.get_char)throw new ve.ErrnoError(60);for(var i=0,a=0;a<n;a++){var s;try{s=e.tty.ops.get_char(e.tty)}catch(e){throw new ve.ErrnoError(29)}if(void 0===s&&0===i)throw new ve.ErrnoError(6);if(null==s)break;i++,t[r+a]=s}return i&&(e.node.timestamp=Date.now()),i},write:function(e,t,r,n,o){if(!e.tty||!e.tty.ops.put_char)throw new ve.ErrnoError(60);try{for(var i=0;i<n;i++)e.tty.ops.put_char(e.tty,t[r+i])}catch(e){throw new ve.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),i}},default_tty_ops:{get_char:function(e){return function(){if(!ie.length){var e=null;if("undefined"!=typeof window&&"function"==typeof window.prompt?null!==(e=window.prompt("Input: "))&&(e+="\n"):"function"==typeof readline&&null!==(e=readline())&&(e+="\n"),!e)return null;ie=ce(e)}return ie.shift()}()},put_char:function(e,t){null===t||10===t?(k(oe(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},fsync:function(e){e.output&&e.output.length>0&&(k(oe(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,t,r){return 0},ioctl_tiocgwinsz:function(e){return[24,80]}},default_tty1_ops:{put_char:function(e,t){null===t||10===t?(_(oe(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},fsync:function(e){e.output&&e.output.length>0&&(_(oe(e.output,0)),e.output=[])}}},fe=function(e){q()},le={ops_table:null,mount:function(e){return le.createNode(null,"/",16895,0)},createNode:function(e,t,r,n){if(ve.isBlkdev(r)||ve.isFIFO(r))throw new ve.ErrnoError(63);le.ops_table||(le.ops_table={dir:{node:{getattr:le.node_ops.getattr,setattr:le.node_ops.setattr,lookup:le.node_ops.lookup,mknod:le.node_ops.mknod,rename:le.node_ops.rename,unlink:le.node_ops.unlink,rmdir:le.node_ops.rmdir,readdir:le.node_ops.readdir,symlink:le.node_ops.symlink},stream:{llseek:le.stream_ops.llseek}},file:{node:{getattr:le.node_ops.getattr,setattr:le.node_ops.setattr},stream:{llseek:le.stream_ops.llseek,read:le.stream_ops.read,write:le.stream_ops.write,allocate:le.stream_ops.allocate,mmap:le.stream_ops.mmap,msync:le.stream_ops.msync}},link:{node:{getattr:le.node_ops.getattr,setattr:le.node_ops.setattr,readlink:le.node_ops.readlink},stream:{}},chrdev:{node:{getattr:le.node_ops.getattr,setattr:le.node_ops.setattr},stream:ve.chrdev_stream_ops}});var o=ve.createNode(e,t,r,n);return ve.isDir(o.mode)?(o.node_ops=le.ops_table.dir.node,o.stream_ops=le.ops_table.dir.stream,o.contents={}):ve.isFile(o.mode)?(o.node_ops=le.ops_table.file.node,o.stream_ops=le.ops_table.file.stream,o.usedBytes=0,o.contents=null):ve.isLink(o.mode)?(o.node_ops=le.ops_table.link.node,o.stream_ops=le.ops_table.link.stream):ve.isChrdev(o.mode)&&(o.node_ops=le.ops_table.chrdev.node,o.stream_ops=le.ops_table.chrdev.stream),o.timestamp=Date.now(),e&&(e.contents[t]=o,e.timestamp=o.timestamp),o},getFileDataAsTypedArray:function(e){return e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0)},expandFileStorage:function(e,t){var r=e.contents?e.contents.length:0;if(!(r>=t)){t=Math.max(t,r*(r<1048576?2:1.125)>>>0),0!=r&&(t=Math.max(t,256));var n=e.contents;e.contents=new Uint8Array(t),e.usedBytes>0&&e.contents.set(n.subarray(0,e.usedBytes),0)}},resizeFileStorage:function(e,t){if(e.usedBytes!=t)if(0==t)e.contents=null,e.usedBytes=0;else{var r=e.contents;e.contents=new Uint8Array(t),r&&e.contents.set(r.subarray(0,Math.min(t,e.usedBytes))),e.usedBytes=t}},node_ops:{getattr:function(e){var t={};return t.dev=ve.isChrdev(e.mode)?e.id:1,t.ino=e.id,t.mode=e.mode,t.nlink=1,t.uid=0,t.gid=0,t.rdev=e.rdev,ve.isDir(e.mode)?t.size=4096:ve.isFile(e.mode)?t.size=e.usedBytes:ve.isLink(e.mode)?t.size=e.link.length:t.size=0,t.atime=new Date(e.timestamp),t.mtime=new Date(e.timestamp),t.ctime=new Date(e.timestamp),t.blksize=4096,t.blocks=Math.ceil(t.size/t.blksize),t},setattr:function(e,t){void 0!==t.mode&&(e.mode=t.mode),void 0!==t.timestamp&&(e.timestamp=t.timestamp),void 0!==t.size&&le.resizeFileStorage(e,t.size)},lookup:function(e,t){throw ve.genericErrors[44]},mknod:function(e,t,r,n){return le.createNode(e,t,r,n)},rename:function(e,t,r){if(ve.isDir(e.mode)){var n;try{n=ve.lookupNode(t,r)}catch(e){}if(n)for(var o in n.contents)throw new ve.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=r,t.contents[r]=e,t.timestamp=e.parent.timestamp,e.parent=t},unlink:function(e,t){delete e.contents[t],e.timestamp=Date.now()},rmdir:function(e,t){var r=ve.lookupNode(e,t);for(var n in r.contents)throw new ve.ErrnoError(55);delete e.contents[t],e.timestamp=Date.now()},readdir:function(e){var t=[".",".."];for(var r in e.contents)e.contents.hasOwnProperty(r)&&t.push(r);return t},symlink:function(e,t,r){var n=le.createNode(e,t,41471,0);return n.link=r,n},readlink:function(e){if(!ve.isLink(e.mode))throw new ve.ErrnoError(28);return e.link}},stream_ops:{read:function(e,t,r,n,o){var i=e.node.contents;if(o>=e.node.usedBytes)return 0;var a=Math.min(e.node.usedBytes-o,n);if(a>8&&i.subarray)t.set(i.subarray(o,o+a),r);else for(var s=0;s<a;s++)t[r+s]=i[o+s];return a},write:function(e,t,r,n,o,i){if(!n)return 0;var a=e.node;if(a.timestamp=Date.now(),t.subarray&&(!a.contents||a.contents.subarray)){if(i)return a.contents=t.subarray(r,r+n),a.usedBytes=n,n;if(0===a.usedBytes&&0===o)return a.contents=t.slice(r,r+n),a.usedBytes=n,n;if(o+n<=a.usedBytes)return a.contents.set(t.subarray(r,r+n),o),n}if(le.expandFileStorage(a,o+n),a.contents.subarray&&t.subarray)a.contents.set(t.subarray(r,r+n),o);else for(var s=0;s<n;s++)a.contents[o+s]=t[r+s];return a.usedBytes=Math.max(a.usedBytes,o+n),n},llseek:function(e,t,r){var n=t;if(1===r?n+=e.position:2===r&&ve.isFile(e.node.mode)&&(n+=e.node.usedBytes),n<0)throw new ve.ErrnoError(28);return n},allocate:function(e,t,r){le.expandFileStorage(e.node,t+r),e.node.usedBytes=Math.max(e.node.usedBytes,t+r)},mmap:function(e,t,r,n,o){if(!ve.isFile(e.node.mode))throw new ve.ErrnoError(43);var i,a,s=e.node.contents;if(2&o||s.buffer!==P.buffer){if((r>0||r+t<s.length)&&(s=s.subarray?s.subarray(r,r+t):Array.prototype.slice.call(s,r,r+t)),a=!0,!(i=fe()))throw new ve.ErrnoError(48);P.set(s,i)}else a=!1,i=s.byteOffset;return{ptr:i,allocated:a}},msync:function(e,t,r,n,o){return le.stream_ops.write(e,t,0,n,r,!1),0}}},de=function(e,t,r,n){var o="al ".concat(e);p(e,(function(r){var n,i;n=r,i='Loading data file "'.concat(e,'" failed (no arrayBuffer).'),n||q(i),t(new Uint8Array(r)),o&&G()}),(function(t){if(!r)throw'Loading data file "'.concat(e,'" failed.');r()})),o&&V()},he=i.preloadPlugins||[];function pe(e,t){var r=0;return e&&(r|=365),t&&(r|=146),r}var ve={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(e=re.resolve(e)))return{path:"",node:null};if((t=Object.assign({follow_mount:!0,recurse_count:0},t)).recurse_count>8)throw new ve.ErrnoError(32);for(var r=e.split("/").filter((function(e){return!!e})),n=ve.root,o="/",i=0;i<r.length;i++){var a=i===r.length-1;if(a&&t.parent)break;if(n=ve.lookupNode(n,r[i]),o=ee.join2(o,r[i]),ve.isMountpoint(n)&&(!a||a&&t.follow_mount)&&(n=n.mounted.root),!a||t.follow)for(var s=0;ve.isLink(n.mode);){var c=ve.readlink(o);if(o=re.resolve(ee.dirname(o),c),n=ve.lookupPath(o,{recurse_count:t.recurse_count+1}).node,s++>40)throw new ve.ErrnoError(32)}}return{path:o,node:n}},getPath:function(e){for(var t;;){if(ve.isRoot(e)){var r=e.mount.mountpoint;return t?"/"!==r[r.length-1]?"".concat(r,"/").concat(t):r+t:r}t=t?"".concat(e.name,"/").concat(t):e.name,e=e.parent}},hashName:function(e,t){for(var r=0,n=0;n<t.length;n++)r=(r<<5)-r+t.charCodeAt(n)|0;return(e+r>>>0)%ve.nameTable.length},hashAddNode:function(e){var t=ve.hashName(e.parent.id,e.name);e.name_next=ve.nameTable[t],ve.nameTable[t]=e},hashRemoveNode:function(e){var t=ve.hashName(e.parent.id,e.name);if(ve.nameTable[t]===e)ve.nameTable[t]=e.name_next;else for(var r=ve.nameTable[t];r;){if(r.name_next===e){r.name_next=e.name_next;break}r=r.name_next}},lookupNode:function(e,t){var r=ve.mayLookup(e);if(r)throw new ve.ErrnoError(r,e);for(var n=ve.hashName(e.id,t),o=ve.nameTable[n];o;o=o.name_next){var i=o.name;if(o.parent.id===e.id&&i===t)return o}return ve.lookup(e,t)},createNode:function(e,t,r,n){var o=new ve.FSNode(e,t,r,n);return ve.hashAddNode(o),o},destroyNode:function(e){ve.hashRemoveNode(e)},isRoot:function(e){return e===e.parent},isMountpoint:function(e){return!!e.mounted},isFile:function(e){return 32768==(61440&e)},isDir:function(e){return 16384==(61440&e)},isLink:function(e){return 40960==(61440&e)},isChrdev:function(e){return 8192==(61440&e)},isBlkdev:function(e){return 24576==(61440&e)},isFIFO:function(e){return 4096==(61440&e)},isSocket:function(e){return!(49152&~e)},flagsToPermissionString:function(e){var t=["r","w","rw"][3&e];return 512&e&&(t+="w"),t},nodePermissions:function(e,t){return ve.ignorePermissions||(!t.includes("r")||292&e.mode)&&(!t.includes("w")||146&e.mode)&&(!t.includes("x")||73&e.mode)?0:2},mayLookup:function(e){var t=ve.nodePermissions(e,"x");return t||(e.node_ops.lookup?0:2)},mayCreate:function(e,t){try{return ve.lookupNode(e,t),20}catch(e){}return ve.nodePermissions(e,"wx")},mayDelete:function(e,t,r){var n;try{n=ve.lookupNode(e,t)}catch(e){return e.errno}var o=ve.nodePermissions(e,"wx");if(o)return o;if(r){if(!ve.isDir(n.mode))return 54;if(ve.isRoot(n)||ve.getPath(n)===ve.cwd())return 10}else if(ve.isDir(n.mode))return 31;return 0},mayOpen:function(e,t){return e?ve.isLink(e.mode)?32:ve.isDir(e.mode)&&("r"!==ve.flagsToPermissionString(t)||512&t)?31:ve.nodePermissions(e,ve.flagsToPermissionString(t)):44},MAX_OPEN_FDS:4096,nextfd:function(){for(var e=0;e<=ve.MAX_OPEN_FDS;e++)if(!ve.streams[e])return e;throw new ve.ErrnoError(33)},getStreamChecked:function(e){var t=ve.getStream(e);if(!t)throw new ve.ErrnoError(8);return t},getStream:function(e){return ve.streams[e]},createStream:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return ve.FSStream||(ve.FSStream=function(){this.shared={}},ve.FSStream.prototype={},Object.defineProperties(ve.FSStream.prototype,{object:{get:function(){return this.node},set:function(e){this.node=e}},isRead:{get:function(){return 1!=(2097155&this.flags)}},isWrite:{get:function(){return!!(2097155&this.flags)}},isAppend:{get:function(){return 1024&this.flags}},flags:{get:function(){return this.shared.flags},set:function(e){this.shared.flags=e}},position:{get:function(){return this.shared.position},set:function(e){this.shared.position=e}}})),e=Object.assign(new ve.FSStream,e),-1==t&&(t=ve.nextfd()),e.fd=t,ve.streams[t]=e,e},closeStream:function(e){ve.streams[e]=null},chrdev_stream_ops:{open:function(e){var t=ve.getDevice(e.node.rdev);e.stream_ops=t.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:function(){throw new ve.ErrnoError(70)}},major:function(e){return e>>8},minor:function(e){return 255&e},makedev:function(e,t){return e<<8|t},registerDevice:function(e,t){ve.devices[e]={stream_ops:t}},getDevice:function(e){return ve.devices[e]},getMounts:function(e){for(var t=[],r=[e];r.length;){var n=r.pop();t.push(n),r.push.apply(r,n.mounts)}return t},syncfs:function(e,t){"function"==typeof e&&(t=e,e=!1),ve.syncFSRequests++,ve.syncFSRequests>1&&_("warning: ".concat(ve.syncFSRequests," FS.syncfs operations in flight at once, probably just doing extra work"));var r=ve.getMounts(ve.root.mount),n=0;function o(e){return ve.syncFSRequests--,t(e)}function i(e){if(e)return i.errored?void 0:(i.errored=!0,o(e));++n>=r.length&&o(null)}r.forEach((function(t){if(!t.type.syncfs)return i(null);t.type.syncfs(t,e,i)}))},mount:function(e,t,r){var n,o="/"===r,i=!r;if(o&&ve.root)throw new ve.ErrnoError(10);if(!o&&!i){var a=ve.lookupPath(r,{follow_mount:!1});if(r=a.path,n=a.node,ve.isMountpoint(n))throw new ve.ErrnoError(10);if(!ve.isDir(n.mode))throw new ve.ErrnoError(54)}var s={type:e,opts:t,mountpoint:r,mounts:[]},c=e.mount(s);return c.mount=s,s.root=c,o?ve.root=c:n&&(n.mounted=s,n.mount&&n.mount.mounts.push(s)),c},unmount:function(e){var t=ve.lookupPath(e,{follow_mount:!1});if(!ve.isMountpoint(t.node))throw new ve.ErrnoError(28);var r=t.node,n=r.mounted,o=ve.getMounts(n);Object.keys(ve.nameTable).forEach((function(e){for(var t=ve.nameTable[e];t;){var r=t.name_next;o.includes(t.mount)&&ve.destroyNode(t),t=r}})),r.mounted=null;var i=r.mount.mounts.indexOf(n);r.mount.mounts.splice(i,1)},lookup:function(e,t){return e.node_ops.lookup(e,t)},mknod:function(e,t,r){var n=ve.lookupPath(e,{parent:!0}).node,o=ee.basename(e);if(!o||"."===o||".."===o)throw new ve.ErrnoError(28);var i=ve.mayCreate(n,o);if(i)throw new ve.ErrnoError(i);if(!n.node_ops.mknod)throw new ve.ErrnoError(63);return n.node_ops.mknod(n,o,t,r)},create:function(e,t){return t=void 0!==t?t:438,t&=4095,t|=32768,ve.mknod(e,t,0)},mkdir:function(e,t){return t=void 0!==t?t:511,t&=1023,t|=16384,ve.mknod(e,t,0)},mkdirTree:function(e,t){for(var r=e.split("/"),n="",o=0;o<r.length;++o)if(r[o]){n+="/"+r[o];try{ve.mkdir(n,t)}catch(e){if(20!=e.errno)throw e}}},mkdev:function(e,t,r){return void 0===r&&(r=t,t=438),t|=8192,ve.mknod(e,t,r)},symlink:function(e,t){if(!re.resolve(e))throw new ve.ErrnoError(44);var r=ve.lookupPath(t,{parent:!0}).node;if(!r)throw new ve.ErrnoError(44);var n=ee.basename(t),o=ve.mayCreate(r,n);if(o)throw new ve.ErrnoError(o);if(!r.node_ops.symlink)throw new ve.ErrnoError(63);return r.node_ops.symlink(r,n,e)},rename:function(e,t){var r,n,o=ee.dirname(e),i=ee.dirname(t),a=ee.basename(e),s=ee.basename(t);if(r=ve.lookupPath(e,{parent:!0}).node,n=ve.lookupPath(t,{parent:!0}).node,!r||!n)throw new ve.ErrnoError(44);if(r.mount!==n.mount)throw new ve.ErrnoError(75);var c,u=ve.lookupNode(r,a),f=re.relative(e,i);if("."!==f.charAt(0))throw new ve.ErrnoError(28);if("."!==(f=re.relative(t,o)).charAt(0))throw new ve.ErrnoError(55);try{c=ve.lookupNode(n,s)}catch(e){}if(u!==c){var l=ve.isDir(u.mode),d=ve.mayDelete(r,a,l);if(d)throw new ve.ErrnoError(d);if(d=c?ve.mayDelete(n,s,l):ve.mayCreate(n,s))throw new ve.ErrnoError(d);if(!r.node_ops.rename)throw new ve.ErrnoError(63);if(ve.isMountpoint(u)||c&&ve.isMountpoint(c))throw new ve.ErrnoError(10);if(n!==r&&(d=ve.nodePermissions(r,"w")))throw new ve.ErrnoError(d);ve.hashRemoveNode(u);try{r.node_ops.rename(u,n,s)}catch(e){throw e}finally{ve.hashAddNode(u)}}},rmdir:function(e){var t=ve.lookupPath(e,{parent:!0}).node,r=ee.basename(e),n=ve.lookupNode(t,r),o=ve.mayDelete(t,r,!0);if(o)throw new ve.ErrnoError(o);if(!t.node_ops.rmdir)throw new ve.ErrnoError(63);if(ve.isMountpoint(n))throw new ve.ErrnoError(10);t.node_ops.rmdir(t,r),ve.destroyNode(n)},readdir:function(e){var t=ve.lookupPath(e,{follow:!0}).node;if(!t.node_ops.readdir)throw new ve.ErrnoError(54);return t.node_ops.readdir(t)},unlink:function(e){var t=ve.lookupPath(e,{parent:!0}).node;if(!t)throw new ve.ErrnoError(44);var r=ee.basename(e),n=ve.lookupNode(t,r),o=ve.mayDelete(t,r,!1);if(o)throw new ve.ErrnoError(o);if(!t.node_ops.unlink)throw new ve.ErrnoError(63);if(ve.isMountpoint(n))throw new ve.ErrnoError(10);t.node_ops.unlink(t,r),ve.destroyNode(n)},readlink:function(e){var t=ve.lookupPath(e).node;if(!t)throw new ve.ErrnoError(44);if(!t.node_ops.readlink)throw new ve.ErrnoError(28);return re.resolve(ve.getPath(t.parent),t.node_ops.readlink(t))},stat:function(e,t){var r=ve.lookupPath(e,{follow:!t}).node;if(!r)throw new ve.ErrnoError(44);if(!r.node_ops.getattr)throw new ve.ErrnoError(63);return r.node_ops.getattr(r)},lstat:function(e){return ve.stat(e,!0)},chmod:function(e,t,r){var n;if(!(n="string"==typeof e?ve.lookupPath(e,{follow:!r}).node:e).node_ops.setattr)throw new ve.ErrnoError(63);n.node_ops.setattr(n,{mode:4095&t|-4096&n.mode,timestamp:Date.now()})},lchmod:function(e,t){ve.chmod(e,t,!0)},fchmod:function(e,t){var r=ve.getStreamChecked(e);ve.chmod(r.node,t)},chown:function(e,t,r,n){var o;if(!(o="string"==typeof e?ve.lookupPath(e,{follow:!n}).node:e).node_ops.setattr)throw new ve.ErrnoError(63);o.node_ops.setattr(o,{timestamp:Date.now()})},lchown:function(e,t,r){ve.chown(e,t,r,!0)},fchown:function(e,t,r){var n=ve.getStreamChecked(e);ve.chown(n.node,t,r)},truncate:function(e,t){if(t<0)throw new ve.ErrnoError(28);var r;if(!(r="string"==typeo