lemon-mse 0.3.9 → 0.4.0

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.
@@ -0,0 +1,6 @@
1
+ (()=>{var _w=Object.create;var{getPrototypeOf:iw,defineProperty:n0,getOwnPropertyNames:lO,getOwnPropertyDescriptor:sw}=Object,nO=Object.prototype.hasOwnProperty;var o0=(Y,K,O)=>{O=Y!=null?_w(iw(Y)):{};let w=K||!Y||!Y.__esModule?n0(O,"default",{value:Y,enumerable:!0}):O;for(let G of lO(Y))if(!nO.call(w,G))n0(w,G,{get:()=>Y[G],enumerable:!0});return w},pO=new WeakMap,aw=(Y)=>{var K=pO.get(Y),O;if(K)return K;if(K=n0({},"__esModule",{value:!0}),Y&&typeof Y==="object"||typeof Y==="function")lO(Y).map((w)=>!nO.call(K,w)&&n0(K,w,{get:()=>Y[w],enumerable:!(O=sw(Y,w))||O.enumerable}));return pO.set(Y,K),K},tw=(Y,K)=>()=>(K||Y((K={exports:{}}).exports,K),K.exports);var ew=(Y,K)=>{for(var O in K)n0(Y,O,{get:K[O],enumerable:!0,configurable:!0,set:(w)=>K[O]=()=>w})};var k0=tw((k1,qO)=>{var Y1=Object.prototype.hasOwnProperty,Z0="~";function d0(){}if(Object.create){if(d0.prototype=Object.create(null),!new d0().__proto__)Z0=!1}function J1(Y,K,O){this.fn=Y,this.context=K,this.once=O||!1}function sO(Y,K,O,w,G){if(typeof O!=="function")throw new TypeError("The listener must be a function");var J=new J1(O,w||Y,G),Q=Z0?Z0+K:K;if(!Y._events[Q])Y._events[Q]=J,Y._eventsCount++;else if(!Y._events[Q].fn)Y._events[Q].push(J);else Y._events[Q]=[Y._events[Q],J];return Y}function YO(Y,K){if(--Y._eventsCount===0)Y._events=new d0;else delete Y._events[K]}function K0(){this._events=new d0,this._eventsCount=0}K0.prototype.eventNames=function Y(){var K=[],O,w;if(this._eventsCount===0)return K;for(w in O=this._events)if(Y1.call(O,w))K.push(Z0?w.slice(1):w);if(Object.getOwnPropertySymbols)return K.concat(Object.getOwnPropertySymbols(O));return K};K0.prototype.listeners=function Y(K){var O=Z0?Z0+K:K,w=this._events[O];if(!w)return[];if(w.fn)return[w.fn];for(var G=0,J=w.length,Q=new Array(J);G<J;G++)Q[G]=w[G].fn;return Q};K0.prototype.listenerCount=function Y(K){var O=Z0?Z0+K:K,w=this._events[O];if(!w)return 0;if(w.fn)return 1;return w.length};K0.prototype.emit=function Y(K,O,w,G,J,Q){var Z=Z0?Z0+K:K;if(!this._events[Z])return!1;var W=this._events[Z],X=arguments.length,U,D;if(W.fn){if(W.once)this.removeListener(K,W.fn,void 0,!0);switch(X){case 1:return W.fn.call(W.context),!0;case 2:return W.fn.call(W.context,O),!0;case 3:return W.fn.call(W.context,O,w),!0;case 4:return W.fn.call(W.context,O,w,G),!0;case 5:return W.fn.call(W.context,O,w,G,J),!0;case 6:return W.fn.call(W.context,O,w,G,J,Q),!0}for(D=1,U=new Array(X-1);D<X;D++)U[D-1]=arguments[D];W.fn.apply(W.context,U)}else{var V=W.length,q;for(D=0;D<V;D++){if(W[D].once)this.removeListener(K,W[D].fn,void 0,!0);switch(X){case 1:W[D].fn.call(W[D].context);break;case 2:W[D].fn.call(W[D].context,O);break;case 3:W[D].fn.call(W[D].context,O,w);break;case 4:W[D].fn.call(W[D].context,O,w,G);break;default:if(!U)for(q=1,U=new Array(X-1);q<X;q++)U[q-1]=arguments[q];W[D].fn.apply(W[D].context,U)}}}return!0};K0.prototype.on=function Y(K,O,w){return sO(this,K,O,w,!1)};K0.prototype.once=function Y(K,O,w){return sO(this,K,O,w,!0)};K0.prototype.removeListener=function Y(K,O,w,G){var J=Z0?Z0+K:K;if(!this._events[J])return this;if(!O)return YO(this,J),this;var Q=this._events[J];if(Q.fn){if(Q.fn===O&&(!G||Q.once)&&(!w||Q.context===w))YO(this,J)}else{for(var Z=0,W=[],X=Q.length;Z<X;Z++)if(Q[Z].fn!==O||G&&!Q[Z].once||w&&Q[Z].context!==w)W.push(Q[Z]);if(W.length)this._events[J]=W.length===1?W[0]:W;else YO(this,J)}return this};K0.prototype.removeAllListeners=function Y(K){var O;if(K){if(O=Z0?Z0+K:K,this._events[O])YO(this,O)}else this._events=new d0,this._eventsCount=0;return this};K0.prototype.off=K0.prototype.removeListener;K0.prototype.addListener=K0.prototype.on;K0.prefixed=Z0;K0.EventEmitter=K0;if(typeof qO!=="undefined")qO.exports=K0});var f1={};ew(f1,{Flv:()=>wO});function oO(Y,K){var O=Object.keys(Y);if(Object.getOwnPropertySymbols){var w=Object.getOwnPropertySymbols(Y);K&&(w=w.filter(function(G){return Object.getOwnPropertyDescriptor(Y,G).enumerable})),O.push.apply(O,w)}return O}function H0(Y){for(var K=1;K<arguments.length;K++){var O=arguments[K]!=null?arguments[K]:{};K%2?oO(Object(O),!0).forEach(function(w){y(Y,w,O[w])}):Object.getOwnPropertyDescriptors?Object.defineProperties(Y,Object.getOwnPropertyDescriptors(O)):oO(Object(O)).forEach(function(w){Object.defineProperty(Y,w,Object.getOwnPropertyDescriptor(O,w))})}return Y}function k(){k=function(){return Y};var Y={},K=Object.prototype,O=K.hasOwnProperty,w=Object.defineProperty||function(H,A,N){H[A]=N.value},G=typeof Symbol=="function"?Symbol:{},J=G.iterator||"@@iterator",Q=G.asyncIterator||"@@asyncIterator",Z=G.toStringTag||"@@toStringTag";function W(H,A,N){return Object.defineProperty(H,A,{value:N,enumerable:!0,configurable:!0,writable:!0}),H[A]}try{W({},"")}catch(H){W=function(A,N,B){return A[N]=B}}function X(H,A,N,B){var j=A&&A.prototype instanceof V?A:V,$=Object.create(j.prototype),T=new P(B||[]);return w($,"_invoke",{value:R(H,N,T)}),$}function U(H,A,N){try{return{type:"normal",arg:H.call(A,N)}}catch(B){return{type:"throw",arg:B}}}Y.wrap=X;var D={};function V(){}function q(){}function L(){}var z={};W(z,J,function(){return this});var I=Object.getPrototypeOf,E=I&&I(I(l([])));E&&E!==K&&O.call(E,J)&&(z=E);var S=L.prototype=V.prototype=Object.create(z);function x(H){["next","throw","return"].forEach(function(A){W(H,A,function(N){return this._invoke(A,N)})})}function C(H,A){function N(j,$,T,n){var o=U(H[j],H,$);if(o.type!=="throw"){var i=o.arg,w0=i.value;return w0&&typeof w0=="object"&&O.call(w0,"__await")?A.resolve(w0.__await).then(function(d){N("next",d,T,n)},function(d){N("throw",d,T,n)}):A.resolve(w0).then(function(d){i.value=d,T(i)},function(d){return N("throw",d,T,n)})}n(o.arg)}var B;w(this,"_invoke",{value:function(j,$){function T(){return new A(function(n,o){N(j,$,n,o)})}return B=B?B.then(T,T):T()}})}function R(H,A,N){var B="suspendedStart";return function(j,$){if(B==="executing")throw new Error("Generator is already running");if(B==="completed"){if(j==="throw")throw $;return Y0()}for(N.method=j,N.arg=$;;){var T=N.delegate;if(T){var n=v(T,N);if(n){if(n===D)continue;return n}}if(N.method==="next")N.sent=N._sent=N.arg;else if(N.method==="throw"){if(B==="suspendedStart")throw B="completed",N.arg;N.dispatchException(N.arg)}else N.method==="return"&&N.abrupt("return",N.arg);B="executing";var o=U(H,A,N);if(o.type==="normal"){if(B=N.done?"completed":"suspendedYield",o.arg===D)continue;return{value:o.arg,done:N.done}}o.type==="throw"&&(B="completed",N.method="throw",N.arg=o.arg)}}}function v(H,A){var N=A.method,B=H.iterator[N];if(B===void 0)return A.delegate=null,N==="throw"&&H.iterator.return&&(A.method="return",A.arg=void 0,v(H,A),A.method==="throw")||N!=="return"&&(A.method="throw",A.arg=new TypeError("The iterator does not provide a '"+N+"' method")),D;var j=U(B,H.iterator,A.arg);if(j.type==="throw")return A.method="throw",A.arg=j.arg,A.delegate=null,D;var $=j.arg;return $?$.done?(A[H.resultName]=$.value,A.next=H.nextLoc,A.method!=="return"&&(A.method="next",A.arg=void 0),A.delegate=null,D):$:(A.method="throw",A.arg=new TypeError("iterator result is not an object"),A.delegate=null,D)}function _(H){var A={tryLoc:H[0]};1 in H&&(A.catchLoc=H[1]),2 in H&&(A.finallyLoc=H[2],A.afterLoc=H[3]),this.tryEntries.push(A)}function t(H){var A=H.completion||{};A.type="normal",delete A.arg,H.completion=A}function P(H){this.tryEntries=[{tryLoc:"root"}],H.forEach(_,this),this.reset(!0)}function l(H){if(H){var A=H[J];if(A)return A.call(H);if(typeof H.next=="function")return H;if(!isNaN(H.length)){var N=-1,B=function j(){for(;++N<H.length;)if(O.call(H,N))return j.value=H[N],j.done=!1,j;return j.value=void 0,j.done=!0,j};return B.next=B}}return{next:Y0}}function Y0(){return{value:void 0,done:!0}}return q.prototype=L,w(S,"constructor",{value:L,configurable:!0}),w(L,"constructor",{value:q,configurable:!0}),q.displayName=W(L,Z,"GeneratorFunction"),Y.isGeneratorFunction=function(H){var A=typeof H=="function"&&H.constructor;return!!A&&(A===q||(A.displayName||A.name)==="GeneratorFunction")},Y.mark=function(H){return Object.setPrototypeOf?Object.setPrototypeOf(H,L):(H.__proto__=L,W(H,Z,"GeneratorFunction")),H.prototype=Object.create(S),H},Y.awrap=function(H){return{__await:H}},x(C.prototype),W(C.prototype,Q,function(){return this}),Y.AsyncIterator=C,Y.async=function(H,A,N,B,j){j===void 0&&(j=Promise);var $=new C(X(H,A,N,B),j);return Y.isGeneratorFunction(A)?$:$.next().then(function(T){return T.done?T.value:$.next()})},x(S),W(S,Z,"Generator"),W(S,J,function(){return this}),W(S,"toString",function(){return"[object Generator]"}),Y.keys=function(H){var A=Object(H),N=[];for(var B in A)N.push(B);return N.reverse(),function j(){for(;N.length;){var $=N.pop();if($ in A)return j.value=$,j.done=!1,j}return j.done=!0,j}},Y.values=l,P.prototype={constructor:P,reset:function(H){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(t),!H)for(var A in this)A.charAt(0)==="t"&&O.call(this,A)&&!isNaN(+A.slice(1))&&(this[A]=void 0)},stop:function(){this.done=!0;var H=this.tryEntries[0].completion;if(H.type==="throw")throw H.arg;return this.rval},dispatchException:function(H){if(this.done)throw H;var A=this;function N(o,i){return $.type="throw",$.arg=H,A.next=o,i&&(A.method="next",A.arg=void 0),!!i}for(var B=this.tryEntries.length-1;B>=0;--B){var j=this.tryEntries[B],$=j.completion;if(j.tryLoc==="root")return N("end");if(j.tryLoc<=this.prev){var T=O.call(j,"catchLoc"),n=O.call(j,"finallyLoc");if(T&&n){if(this.prev<j.catchLoc)return N(j.catchLoc,!0);if(this.prev<j.finallyLoc)return N(j.finallyLoc)}else if(T){if(this.prev<j.catchLoc)return N(j.catchLoc,!0)}else{if(!n)throw new Error("try statement without catch or finally");if(this.prev<j.finallyLoc)return N(j.finallyLoc)}}}},abrupt:function(H,A){for(var N=this.tryEntries.length-1;N>=0;--N){var B=this.tryEntries[N];if(B.tryLoc<=this.prev&&O.call(B,"finallyLoc")&&this.prev<B.finallyLoc){var j=B;break}}j&&(H==="break"||H==="continue")&&j.tryLoc<=A&&A<=j.finallyLoc&&(j=null);var $=j?j.completion:{};return $.type=H,$.arg=A,j?(this.method="next",this.next=j.finallyLoc,D):this.complete($)},complete:function(H,A){if(H.type==="throw")throw H.arg;return H.type==="break"||H.type==="continue"?this.next=H.arg:H.type==="return"?(this.rval=this.arg=H.arg,this.method="return",this.next="end"):H.type==="normal"&&A&&(this.next=A),D},finish:function(H){for(var A=this.tryEntries.length-1;A>=0;--A){var N=this.tryEntries[A];if(N.finallyLoc===H)return this.complete(N.completion,N.afterLoc),t(N),D}},catch:function(H){for(var A=this.tryEntries.length-1;A>=0;--A){var N=this.tryEntries[A];if(N.tryLoc===H){var B=N.completion;if(B.type==="throw"){var j=B.arg;t(N)}return j}}throw new Error("illegal catch attempt")},delegateYield:function(H,A,N){return this.delegate={iterator:l(H),resultName:A,nextLoc:N},this.method==="next"&&(this.arg=void 0),D}},Y}function dO(Y,K,O,w,G,J,Q){try{var Z=Y[J](Q),W=Z.value}catch(X){O(X);return}if(Z.done)K(W);else Promise.resolve(W).then(w,G)}function O0(Y){return function(){var K=this,O=arguments;return new Promise(function(w,G){var J=Y.apply(K,O);function Q(W){dO(J,w,G,Q,Z,"next",W)}function Z(W){dO(J,w,G,Q,Z,"throw",W)}Q(void 0)})}}function h0(Y,K){if(!(Y instanceof K))throw new TypeError("Cannot call a class as a function")}function cO(Y,K){for(var O=0;O<K.length;O++){var w=K[O];if(w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w)w.writable=!0;Object.defineProperty(Y,iO(w.key),w)}}function x0(Y,K,O){if(K)cO(Y.prototype,K);if(O)cO(Y,O);return Object.defineProperty(Y,"prototype",{writable:!1}),Y}function y(Y,K,O){if(K=iO(K),K in Y)Object.defineProperty(Y,K,{value:O,enumerable:!0,configurable:!0,writable:!0});else Y[K]=O;return Y}function rO(Y,K){if(typeof K!=="function"&&K!==null)throw new TypeError("Super expression must either be null or a function");if(Y.prototype=Object.create(K&&K.prototype,{constructor:{value:Y,writable:!0,configurable:!0}}),Object.defineProperty(Y,"prototype",{writable:!1}),K)VO(Y,K)}function GO(Y){return GO=Object.setPrototypeOf?Object.getPrototypeOf.bind():function K(O){return O.__proto__||Object.getPrototypeOf(O)},GO(Y)}function VO(Y,K){return VO=Object.setPrototypeOf?Object.setPrototypeOf.bind():function O(w,G){return w.__proto__=G,w},VO(Y,K)}function O1(){if(typeof Reflect==="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy==="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(Y){return!1}}function p(Y){if(Y===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return Y}function w1(Y,K){if(K&&(typeof K==="object"||typeof K==="function"))return K;else if(K!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return p(Y)}function _O(Y){var K=O1();return function O(){var w=GO(Y),G;if(K){var J=GO(this).constructor;G=Reflect.construct(w,arguments,J)}else G=w.apply(this,arguments);return w1(this,G)}}function G1(Y,K){if(typeof Y!=="object"||Y===null)return Y;var O=Y[Symbol.toPrimitive];if(O!==void 0){var w=O.call(Y,K||"default");if(typeof w!=="object")return w;throw new TypeError("@@toPrimitive must return a primitive value.")}return(K==="string"?String:Number)(Y)}function iO(Y){var K=G1(Y,"string");return typeof K==="symbol"?K:String(K)}function aO(Y,K){var O=Object.keys(Y);if(Object.getOwnPropertySymbols){var w=Object.getOwnPropertySymbols(Y);K&&(w=w.filter(function(G){return Object.getOwnPropertyDescriptor(Y,G).enumerable})),O.push.apply(O,w)}return O}function M0(Y){for(var K=1;K<arguments.length;K++){var O=arguments[K]!=null?arguments[K]:{};K%2?aO(Object(O),!0).forEach(function(w){F(Y,w,O[w])}):Object.getOwnPropertyDescriptors?Object.defineProperties(Y,Object.getOwnPropertyDescriptors(O)):aO(Object(O)).forEach(function(w){Object.defineProperty(Y,w,Object.getOwnPropertyDescriptor(O,w))})}return Y}function a(){a=function(){return Y};var Y={},K=Object.prototype,O=K.hasOwnProperty,w=Object.defineProperty||function(H,A,N){H[A]=N.value},G=typeof Symbol=="function"?Symbol:{},J=G.iterator||"@@iterator",Q=G.asyncIterator||"@@asyncIterator",Z=G.toStringTag||"@@toStringTag";function W(H,A,N){return Object.defineProperty(H,A,{value:N,enumerable:!0,configurable:!0,writable:!0}),H[A]}try{W({},"")}catch(H){W=function(A,N,B){return A[N]=B}}function X(H,A,N,B){var j=A&&A.prototype instanceof V?A:V,$=Object.create(j.prototype),T=new P(B||[]);return w($,"_invoke",{value:R(H,N,T)}),$}function U(H,A,N){try{return{type:"normal",arg:H.call(A,N)}}catch(B){return{type:"throw",arg:B}}}Y.wrap=X;var D={};function V(){}function q(){}function L(){}var z={};W(z,J,function(){return this});var I=Object.getPrototypeOf,E=I&&I(I(l([])));E&&E!==K&&O.call(E,J)&&(z=E);var S=L.prototype=V.prototype=Object.create(z);function x(H){["next","throw","return"].forEach(function(A){W(H,A,function(N){return this._invoke(A,N)})})}function C(H,A){function N(j,$,T,n){var o=U(H[j],H,$);if(o.type!=="throw"){var i=o.arg,w0=i.value;return w0&&typeof w0=="object"&&O.call(w0,"__await")?A.resolve(w0.__await).then(function(d){N("next",d,T,n)},function(d){N("throw",d,T,n)}):A.resolve(w0).then(function(d){i.value=d,T(i)},function(d){return N("throw",d,T,n)})}n(o.arg)}var B;w(this,"_invoke",{value:function(j,$){function T(){return new A(function(n,o){N(j,$,n,o)})}return B=B?B.then(T,T):T()}})}function R(H,A,N){var B="suspendedStart";return function(j,$){if(B==="executing")throw new Error("Generator is already running");if(B==="completed"){if(j==="throw")throw $;return Y0()}for(N.method=j,N.arg=$;;){var T=N.delegate;if(T){var n=v(T,N);if(n){if(n===D)continue;return n}}if(N.method==="next")N.sent=N._sent=N.arg;else if(N.method==="throw"){if(B==="suspendedStart")throw B="completed",N.arg;N.dispatchException(N.arg)}else N.method==="return"&&N.abrupt("return",N.arg);B="executing";var o=U(H,A,N);if(o.type==="normal"){if(B=N.done?"completed":"suspendedYield",o.arg===D)continue;return{value:o.arg,done:N.done}}o.type==="throw"&&(B="completed",N.method="throw",N.arg=o.arg)}}}function v(H,A){var N=A.method,B=H.iterator[N];if(B===void 0)return A.delegate=null,N==="throw"&&H.iterator.return&&(A.method="return",A.arg=void 0,v(H,A),A.method==="throw")||N!=="return"&&(A.method="throw",A.arg=new TypeError("The iterator does not provide a '"+N+"' method")),D;var j=U(B,H.iterator,A.arg);if(j.type==="throw")return A.method="throw",A.arg=j.arg,A.delegate=null,D;var $=j.arg;return $?$.done?(A[H.resultName]=$.value,A.next=H.nextLoc,A.method!=="return"&&(A.method="next",A.arg=void 0),A.delegate=null,D):$:(A.method="throw",A.arg=new TypeError("iterator result is not an object"),A.delegate=null,D)}function _(H){var A={tryLoc:H[0]};1 in H&&(A.catchLoc=H[1]),2 in H&&(A.finallyLoc=H[2],A.afterLoc=H[3]),this.tryEntries.push(A)}function t(H){var A=H.completion||{};A.type="normal",delete A.arg,H.completion=A}function P(H){this.tryEntries=[{tryLoc:"root"}],H.forEach(_,this),this.reset(!0)}function l(H){if(H){var A=H[J];if(A)return A.call(H);if(typeof H.next=="function")return H;if(!isNaN(H.length)){var N=-1,B=function j(){for(;++N<H.length;)if(O.call(H,N))return j.value=H[N],j.done=!1,j;return j.value=void 0,j.done=!0,j};return B.next=B}}return{next:Y0}}function Y0(){return{value:void 0,done:!0}}return q.prototype=L,w(S,"constructor",{value:L,configurable:!0}),w(L,"constructor",{value:q,configurable:!0}),q.displayName=W(L,Z,"GeneratorFunction"),Y.isGeneratorFunction=function(H){var A=typeof H=="function"&&H.constructor;return!!A&&(A===q||(A.displayName||A.name)==="GeneratorFunction")},Y.mark=function(H){return Object.setPrototypeOf?Object.setPrototypeOf(H,L):(H.__proto__=L,W(H,Z,"GeneratorFunction")),H.prototype=Object.create(S),H},Y.awrap=function(H){return{__await:H}},x(C.prototype),W(C.prototype,Q,function(){return this}),Y.AsyncIterator=C,Y.async=function(H,A,N,B,j){j===void 0&&(j=Promise);var $=new C(X(H,A,N,B),j);return Y.isGeneratorFunction(A)?$:$.next().then(function(T){return T.done?T.value:$.next()})},x(S),W(S,Z,"Generator"),W(S,J,function(){return this}),W(S,"toString",function(){return"[object Generator]"}),Y.keys=function(H){var A=Object(H),N=[];for(var B in A)N.push(B);return N.reverse(),function j(){for(;N.length;){var $=N.pop();if($ in A)return j.value=$,j.done=!1,j}return j.done=!0,j}},Y.values=l,P.prototype={constructor:P,reset:function(H){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(t),!H)for(var A in this)A.charAt(0)==="t"&&O.call(this,A)&&!isNaN(+A.slice(1))&&(this[A]=void 0)},stop:function(){this.done=!0;var H=this.tryEntries[0].completion;if(H.type==="throw")throw H.arg;return this.rval},dispatchException:function(H){if(this.done)throw H;var A=this;function N(o,i){return $.type="throw",$.arg=H,A.next=o,i&&(A.method="next",A.arg=void 0),!!i}for(var B=this.tryEntries.length-1;B>=0;--B){var j=this.tryEntries[B],$=j.completion;if(j.tryLoc==="root")return N("end");if(j.tryLoc<=this.prev){var T=O.call(j,"catchLoc"),n=O.call(j,"finallyLoc");if(T&&n){if(this.prev<j.catchLoc)return N(j.catchLoc,!0);if(this.prev<j.finallyLoc)return N(j.finallyLoc)}else if(T){if(this.prev<j.catchLoc)return N(j.catchLoc,!0)}else{if(!n)throw new Error("try statement without catch or finally");if(this.prev<j.finallyLoc)return N(j.finallyLoc)}}}},abrupt:function(H,A){for(var N=this.tryEntries.length-1;N>=0;--N){var B=this.tryEntries[N];if(B.tryLoc<=this.prev&&O.call(B,"finallyLoc")&&this.prev<B.finallyLoc){var j=B;break}}j&&(H==="break"||H==="continue")&&j.tryLoc<=A&&A<=j.finallyLoc&&(j=null);var $=j?j.completion:{};return $.type=H,$.arg=A,j?(this.method="next",this.next=j.finallyLoc,D):this.complete($)},complete:function(H,A){if(H.type==="throw")throw H.arg;return H.type==="break"||H.type==="continue"?this.next=H.arg:H.type==="return"?(this.rval=this.arg=H.arg,this.method="return",this.next="end"):H.type==="normal"&&A&&(this.next=A),D},finish:function(H){for(var A=this.tryEntries.length-1;A>=0;--A){var N=this.tryEntries[A];if(N.finallyLoc===H)return this.complete(N.completion,N.afterLoc),t(N),D}},catch:function(H){for(var A=this.tryEntries.length-1;A>=0;--A){var N=this.tryEntries[A];if(N.tryLoc===H){var B=N.completion;if(B.type==="throw"){var j=B.arg;t(N)}return j}}throw new Error("illegal catch attempt")},delegateYield:function(H,A,N){return this.delegate={iterator:l(H),resultName:A,nextLoc:N},this.method==="next"&&(this.arg=void 0),D}},Y}function z0(Y){return z0=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(K){return typeof K}:function(K){return K&&typeof Symbol=="function"&&K.constructor===Symbol&&K!==Symbol.prototype?"symbol":typeof K},z0(Y)}function tO(Y,K,O,w,G,J,Q){try{var Z=Y[J](Q),W=Z.value}catch(X){O(X);return}if(Z.done)K(W);else Promise.resolve(W).then(w,G)}function U0(Y){return function(){var K=this,O=arguments;return new Promise(function(w,G){var J=Y.apply(K,O);function Q(W){tO(J,w,G,Q,Z,"next",W)}function Z(W){tO(J,w,G,Q,Z,"throw",W)}Q(void 0)})}}function c(Y,K){if(!(Y instanceof K))throw new TypeError("Cannot call a class as a function")}function eO(Y,K){for(var O=0;O<K.length;O++){var w=K[O];if(w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w)w.writable=!0;Object.defineProperty(Y,Jw(w.key),w)}}function r(Y,K,O){if(K)eO(Y.prototype,K);if(O)eO(Y,O);return Object.defineProperty(Y,"prototype",{writable:!1}),Y}function F(Y,K,O){if(K=Jw(K),K in Y)Object.defineProperty(Y,K,{value:O,enumerable:!0,configurable:!0,writable:!0});else Y[K]=O;return Y}function V0(Y,K){if(typeof K!=="function"&&K!==null)throw new TypeError("Super expression must either be null or a function");if(Y.prototype=Object.create(K&&K.prototype,{constructor:{value:Y,writable:!0,configurable:!0}}),Object.defineProperty(Y,"prototype",{writable:!1}),K)r0(Y,K)}function v0(Y){return v0=Object.setPrototypeOf?Object.getPrototypeOf.bind():function K(O){return O.__proto__||Object.getPrototypeOf(O)},v0(Y)}function r0(Y,K){return r0=Object.setPrototypeOf?Object.setPrototypeOf.bind():function O(w,G){return w.__proto__=G,w},r0(Y,K)}function ww(){if(typeof Reflect==="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy==="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(Y){return!1}}function JO(Y,K,O){if(ww())JO=Reflect.construct.bind();else JO=function w(G,J,Q){var Z=[null];Z.push.apply(Z,J);var W=Function.bind.apply(G,Z),X=new W;if(Q)r0(X,Q.prototype);return X};return JO.apply(null,arguments)}function K1(Y){return Function.toString.call(Y).indexOf("[native code]")!==-1}function T0(Y){var K=typeof Map==="function"?new Map:void 0;return T0=function O(w){if(w===null||!K1(w))return w;if(typeof w!=="function")throw new TypeError("Super expression must either be null or a function");if(typeof K!=="undefined"){if(K.has(w))return K.get(w);K.set(w,G)}function G(){return JO(w,arguments,v0(this).constructor)}return G.prototype=Object.create(w.prototype,{constructor:{value:G,enumerable:!1,writable:!0,configurable:!0}}),r0(G,w)},T0(Y)}function Q1(Y,K){if(Y==null)return{};var O={},w=Object.keys(Y),G,J;for(J=0;J<w.length;J++){if(G=w[J],K.indexOf(G)>=0)continue;O[G]=Y[G]}return O}function Gw(Y,K){if(Y==null)return{};var O=Q1(Y,K),w,G;if(Object.getOwnPropertySymbols){var J=Object.getOwnPropertySymbols(Y);for(G=0;G<J.length;G++){if(w=J[G],K.indexOf(w)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(Y,w))continue;O[w]=Y[w]}}return O}function M(Y){if(Y===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return Y}function Z1(Y,K){if(K&&(typeof K==="object"||typeof K==="function"))return K;else if(K!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return M(Y)}function q0(Y){var K=ww();return function O(){var w=v0(Y),G;if(K){var J=v0(this).constructor;G=Reflect.construct(w,arguments,J)}else G=w.apply(this,arguments);return Z1(this,G)}}function W1(Y,K){while(!Object.prototype.hasOwnProperty.call(Y,K))if(Y=v0(Y),Y===null)break;return Y}function c0(){if(typeof Reflect!=="undefined"&&Reflect.get)c0=Reflect.get.bind();else c0=function Y(K,O,w){var G=W1(K,O);if(!G)return;var J=Object.getOwnPropertyDescriptor(G,O);if(J.get)return J.get.call(arguments.length<3?K:w);return J.value};return c0.apply(this,arguments)}function X1(Y,K){if(!Y)return;if(typeof Y==="string")return Ow(Y,K);var O=Object.prototype.toString.call(Y).slice(8,-1);if(O==="Object"&&Y.constructor)O=Y.constructor.name;if(O==="Map"||O==="Set")return Array.from(Y);if(O==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(O))return Ow(Y,K)}function Ow(Y,K){if(K==null||K>Y.length)K=Y.length;for(var O=0,w=new Array(K);O<K;O++)w[O]=Y[O];return w}function Yw(Y,K){var O=typeof Symbol!=="undefined"&&Y[Symbol.iterator]||Y["@@iterator"];if(!O){if(Array.isArray(Y)||(O=X1(Y))||K&&Y&&typeof Y.length==="number"){if(O)Y=O;var w=0,G=function(){};return{s:G,n:function(){if(w>=Y.length)return{done:!0};return{done:!1,value:Y[w++]}},e:function(W){throw W},f:G}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
2
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var J=!0,Q=!1,Z;return{s:function(){O=O.call(Y)},n:function(){var W=O.next();return J=W.done,W},e:function(W){Q=!0,Z=W},f:function(){try{if(!J&&O.return!=null)O.return()}finally{if(Q)throw Z}}}}function U1(Y,K){if(typeof Y!=="object"||Y===null)return Y;var O=Y[Symbol.toPrimitive];if(O!==void 0){var w=O.call(Y,K||"default");if(typeof w!=="object")return w;throw new TypeError("@@toPrimitive must return a primitive value.")}return(K==="string"?String:Number)(Y)}function Jw(Y){var K=U1(Y,"string");return typeof K==="symbol"?K:String(K)}var e=function(){function Y(){c(this,Y)}return r(Y,null,[{key:"start",value:function K(O){if(!O||!O.length)return 0;if(O.length===1&&O.end(0)-O.start(0)<0.000001)return 0;if(O.length===1&&O.start(0)<0)return 0;return O.start(0)}},{key:"end",value:function K(O){if(!O||!O.length)return 0;if(O.length===1&&O.end(0)-O.start(0)<0.000001)return 0;return O.end(O.length-1)}},{key:"get",value:function K(O){if(!O)return;try{return O.buffered}catch(w){}}},{key:"buffers",value:function K(O,w){if(!O||!O.length)return[];var G=[];for(var J=0,Q=O.length;J<Q;J++){var Z=G.length;if(!Z||!w)G.push([O.start(J),O.end(J)]);else{var W=G[Z-1],X=W[1],U=O.start(J);if(U-X<=w){var D=O.end(J);if(D>X)W[1]=D}else G.push([O.start(J),O.end(J)])}}return G}},{key:"totalLength",value:function K(O){if(!O||!O.length)return 0;return O.reduce(function(w,G){return w+=G[1]-G[0]},0)}},{key:"info",value:function K(O){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,G=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(!O||!O.length)return{start:0,end:0,buffers:[]};var J=0,Q=0,Z=0,W=0,X=0,U=0,D=0,V=Y.buffers(O,G);for(var q=0,L=V.length;q<L;q++){var z=V[q];if(w+G>=z[0]&&w<=z[1])J=z[0],Q=z[1],Z=q;else if(w+G<z[0]){W=z[0],X=z[1];break}else if(w+G>z[1])U=z[0],D=z[1]}return{start:J,end:Q,index:Z,buffers:V,nextStart:W,nextEnd:X,prevStart:U,prevEnd:D,currentTime:w,behind:w-J,remaining:Q?Q-w:0,length:Y.totalLength&&Y.totalLength(V)}}},{key:"isBuffered",value:function K(O,w){if(O){var G=Y.get(O);if(G!==null&&G!==void 0&&G.length){for(var J=0;J<G.length;J++)if(w>=G.start(J)&&w<=G.end(J))return!0}}return!1}}]),Y}();var Kw=typeof window!=="undefined";var X0,m={MANIFEST:"manifest",NETWORK:"network",NETWORK_TIMEOUT:"network_timeout",NETWORK_FORBIDDEN:"network_forbidden",NETWORK_NOTFOUND:"network_notfound",NETWROK_RANGE_NOT_SATISFIABLE:"network_range_not_satisfiable",DEMUX:"demux",REMUX:"remux",MEDIA:"media",DRM:"drm",OTHER:"other",RUNTIME:"runtime",SUB_TYPES:{FLV:"FLV",HLS:"HLS",MP4:"MP4",FMP4:"FMP4",MSE_ADD_SB:"MSE_ADD_SB",MSE_APPEND_BUFFER:"MSE_APPEND_BUFFER",MSE_OTHER:"MSE_OTHER",MSE_FULL:"MSE_FULL",MSE_CHANGE_TYPE:"MSE_CHANGE_TYPE",OPTION:"OPTION",DASH:"DASH",LICENSE:"LICENSE",CUSTOM_LICENSE:"CUSTOM_LICENSE",MSE_HIJACK:"MSE_HIJACK",EME_HIJACK:"EME_HIJACK",SIDX:"SIDX",NO_CANPLAY_ERROR:"NO_CANPLAY_ERROR",BUFFERBREAK_ERROR:"BUFFERBREAK_ERROR",WAITING_TIMEOUT_ERROR:"WAITING_TIMEOUT_ERROR",MEDIA_ERR_ABORTED:"MEDIA_ERR_ABORTED",MEDIA_ERR_NETWORK:"MEDIA_ERR_NETWORK",MEDIA_ERR_DECODE:"MEDIA_ERR_DECODE",MEDIA_ERR_SRC_NOT_SUPPORTED:"MEDIA_ERR_SRC_NOT_SUPPORTED",MEDIA_ERR_CODEC_NOT_SUPPORTED:"MEDIA_ERR_CODEC_NOT_SUPPORTED",MEDIA_ERR_URL_EMPTY:"MEDIA_ERR_URL_EMPTY"}},KO=(X0={},F(X0,m.MANIFEST,{HLS:1100,DASH:1200}),F(X0,m.NETWORK,2100),F(X0,m.NETWORK_TIMEOUT,2101),F(X0,m.NETWORK_FORBIDDEN,2103),F(X0,m.NETWORK_NOTFOUND,2104),F(X0,m.NETWROK_RANGE_NOT_SATISFIABLE,2116),F(X0,m.DEMUX,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400,SIDX:3410}),F(X0,m.REMUX,{FMP4:4100,MP4:4200}),F(X0,m.MEDIA,{MEDIA_ERR_ABORTED:5101,MEDIA_ERR_NETWORK:5102,MEDIA_ERR_DECODE:5103,MEDIA_ERR_SRC_NOT_SUPPORTED:5104,MEDIA_ERR_CODEC_NOT_SUPPORTED:5105,MEDIA_ERR_URL_EMPTY:5106,MSE_ADD_SB:5200,MSE_APPEND_BUFFER:5201,MSE_OTHER:5202,MSE_FULL:5203,MSE_HIJACK:5204,MSE_CHANGE_TYPE:5205,EME_HIJACK:5301}),F(X0,m.DRM,{LICENSE:7100,CUSTOM_LICENSE:7200}),F(X0,m.OTHER,8000),F(X0,m.RUNTIME,{NO_CANPLAY_ERROR:9001,BUFFERBREAK_ERROR:9002,WAITING_TIMEOUT_ERROR:9003}),X0),Q0=function(Y){V0(O,Y);var K=q0(O);function O(w,G,J,Q,Z){var W;if(c(this,O),W=K.call(this,Z||(J===null||J===void 0?void 0:J.message)),W.errorType=w===m.NETWORK_TIMEOUT?m.NETWORK:w,W.originError=J,W.ext=Q,W.errorCode=KO[w][G]||KO[w],W.errorMessage=W.message,!W.errorCode)W.errorType=m.OTHER,W.errorCode=KO[W.errorType];return W}return r(O,null,[{key:"create",value:function w(G,J,Q,Z,W){if(G instanceof O)return G;else if(G instanceof Error)Q=G,G="";if(!G)G=m.OTHER;return new O(G,J,Q,Z,W)}},{key:"network",value:function w(G){var J;return new O(G!==null&&G!==void 0&&G.isTimeout?m.NETWORK_TIMEOUT:m.NETWORK,null,G instanceof Error?G:null,{url:G===null||G===void 0?void 0:G.url,response:G===null||G===void 0?void 0:G.response,httpCode:G===null||G===void 0?void 0:(J=G.response)===null||J===void 0?void 0:J.status})}}]),O}(T0(Error));var i0={DEBUG:1,LOG:2,WARN:3,ERROR:4},D1=204800,A1=["Boolean","Number","String","Undefined","Null","Date","Object"],D0=function(){function Y(K,O){c(this,Y),this.name=K||"",this._prefix="[".concat(this.name,"]"),this.logCacheLevel=(O===null||O===void 0?void 0:O.logCacheLevel)||3,this.logMaxSize=(O===null||O===void 0?void 0:O.logMaxSize)||D1,this.logSize=0,this.logTextArray=[]}return r(Y,[{key:"debug",value:function K(){var O;for(var w=arguments.length,G=new Array(w),J=0;J<w;J++)G[J]=arguments[J];if(this.logCache.apply(this,[i0.DEBUG].concat(G)),Y.disabled)return;(O=console).debug.apply(O,["[".concat(_0(),"]"),this._prefix].concat(G))}},{key:"log",value:function K(){var O;for(var w=arguments.length,G=new Array(w),J=0;J<w;J++)G[J]=arguments[J];if(this.logCache.apply(this,[i0.LOG].concat(G)),Y.disabled)return;(O=console).log.apply(O,["[".concat(_0(),"]"),this._prefix].concat(G))}},{key:"warn",value:function K(){var O;for(var w=arguments.length,G=new Array(w),J=0;J<w;J++)G[J]=arguments[J];if(this.logCache.apply(this,[i0.WARN].concat(G)),Y.disabled)return;(O=console).warn.apply(O,["[".concat(_0(),"]"),this._prefix].concat(G))}},{key:"error",value:function K(){var O;for(var w=arguments.length,G=new Array(w),J=0;J<w;J++)G[J]=arguments[J];if(this.logCache.apply(this,[i0.ERROR].concat(G)),Y.disabled)return;(O=console).error.apply(O,["[".concat(_0(),"]"),this._prefix].concat(G))}},{key:"logCache",value:function K(O){if(O<this.logCacheLevel)return;var w="";try{for(var G=arguments.length,J=new Array(G>1?G-1:0),Q=1;Q<G;Q++)J[Q-1]=arguments[Q];var Z=J.map(function(X){return Qw(X)});w="[".concat(_0(),"]")+this._prefix+JSON.stringify(Z)}catch(X){return}if(O>=this.logCacheLevel)this.logSize+=w.length,this.logTextArray.push(w);if(this.logSize>this.logMaxSize){var W=this.logTextArray.shift();this.logSize-=W.length}}},{key:"getLogCache",value:function K(){var O=this.logTextArray.join(`
3
+ `);return this.reset(),O}},{key:"reset",value:function K(){this.logTextArray=[],this.logSize=0}},{key:"table",value:function K(){var O;if(Y.disabled)return;console.group(this._prefix),(O=console).table.apply(O,arguments),console.groupEnd()}},{key:"setLogLevel",value:function K(O){this.logCacheLevel=O}}],[{key:"enable",value:function K(){Y.disabled=!1}},{key:"disable",value:function K(){Y.disabled=!0}}]),Y}();F(D0,"disabled",!0);function _0(){return new Date().toLocaleString()}function H1(Y){if(z0(Y)!=="object")return Y;var K=Object.prototype.toString.call(Y).slice(8,-1);switch(K){case"Array":case"Uint8Array":case"ArrayBuffer":return K+"["+Y.length+"]";case"Object":return"{}";default:return K}}function Qw(Y,K,O){if(!O)O=1;if(!K)K=2;var w={};if(!Y||z0(Y)!=="object")return Y;var G=Object.prototype.toString.call(Y).slice(8,-1);if(!A1.includes(G))return G;if(O>K)return;for(var J in Y)if(Object.prototype.hasOwnProperty.call(Y,J))if(O===K)w[J]=H1(Y[J]);else if(z0(Y[J])==="object")w[J]=Qw(Y[J],K,O+1);else w[J]=Y[J];return w}function y0(){var Y,K,O=new Promise(function(w,G){Y=w,K=G});return O.used=!1,O.resolve=function(){return O.used=!0,Y.apply(void 0,arguments)},O.reject=function(){return O.used=!0,K.apply(void 0,arguments)},O}function f0(){try{return parseInt(performance.now(),10)}catch(Y){return new Date().getTime()}}var Zw={stringify:function Y(K){try{return JSON.stringify(K)}catch(O){return""}},parse:function Y(K){try{return JSON.parse(K)}catch(O){return}}};function Ww(){var Y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;try{if(!Kw)return null;if(Y&&typeof ManagedMediaSource!=="undefined")return ManagedMediaSource;return window.MediaSource}catch(K){}}function FO(Y){return/ManagedMediaSource/gi.test(Object.prototype.toString.call(Y))}function N1(Y){var K=[];if(Y instanceof TimeRanges)for(var O=0;O<Y.length;O++)K.push({start:Y.start(O),end:Y.end(O)});return K}var QO={APPEND:"appendBuffer",REMOVE:"removeBuffer",UPDATE_DURATION:"updateDuration"};var P0=function(){function Y(K,O){var w=this;if(c(this,Y),F(this,"media",null),F(this,"mediaSource",null),F(this,"_openPromise",y0()),F(this,"_queue",Object.create(null)),F(this,"_sourceBuffer",Object.create(null)),F(this,"_mseFullFlag",{}),F(this,"_st",0),F(this,"_opst",0),F(this,"_logger",null),F(this,"_config",null),F(this,"_url",null),F(this,"_onStartStreaming",function(){w._logger.debug("startstreaming")}),F(this,"_onEndStreaming",function(){w._logger.debug("endstreaming")}),F(this,"_onSBUpdateEnd",function(G){var J=w._queue[G];if(J){var Q=J[0];if((Q===null||Q===void 0?void 0:Q.opName)!==QO.UPDATE_DURATION)J.shift();if(Q){var Z,W,X=f0()-w._opst;w._logger.debug("UpdateEnd(".concat(G,"/").concat(Q.opName,")"),Zw.stringify(N1((Z=w._sourceBuffer[G])===null||Z===void 0?void 0:Z.buffered)),X,Q.context),Q.promise.resolve({name:Q.opName,context:Q.context,costtime:X});var U=(W=Q.context)===null||W===void 0?void 0:W.callback;if(U&&typeof U==="function")U(Q.context);w._startQueue(G)}}}),F(this,"_onSBUpdateError",function(G,J){var Q=w._queue[G];if(Q){var Z=Q[0];if(Z)w._logger.error("UpdateError",G,Z.opName,Z.context),Z.promise.reject(new Q0(m.MEDIA,m.SUB_TYPES.MSE_APPEND_BUFFER,J))}}),this._config=Object.assign(Y.getDefaultConfig(),O),K)this.bindMedia(K);if(this._logger=new D0("MSE"),this._config.openLog)D0.enable()}return r(Y,[{key:"isOpened",get:function K(){var O;return((O=this.mediaSource)===null||O===void 0?void 0:O.readyState)==="open"}},{key:"hasOpTasks",get:function K(){var O=this,w=!1;return Object.keys(this._queue).forEach(function(G){var J=O._queue[G];if(Array.isArray(J))w||(w=J.length>0)}),w}},{key:"url",get:function K(){return this._url}},{key:"duration",get:function K(){var O;return((O=this.mediaSource)===null||O===void 0?void 0:O.duration)||-1}},{key:"isEnded",get:function K(){return this.mediaSource?this.mediaSource.readyState==="ended":!1}},{key:"streaming",get:function K(){return FO(this.mediaSource)?this.mediaSource.streaming:!0}},{key:"isFull",value:function K(O){return O?this._mseFullFlag[O]:this._mseFullFlag[Y.VIDEO]}},{key:"updateDuration",value:function K(O){var w=this,G=this.mediaSource&&this.mediaSource.duration>O;if(this.mediaSource&&this.mediaSource.duration>O){var J=0;if(Object.keys(this._sourceBuffer).forEach(function(Q){try{J=Math.max(w.bufferEnd(Q)||0,J)}catch(Z){}}),O<J)return Promise.resolve()}return this._enqueueBlockingOp(function(){if(w.isEnded){w._logger.debug("setDuration but ended");return}if(w.mediaSource)w.mediaSource.duration=O,w._logger.debug("setDuration",O)},QO.UPDATE_DURATION,{isReduceDuration:G})}},{key:"open",value:function K(){var O=this;if(this._openPromise.used&&!this.isOpened&&this.mediaSource){var w=this.mediaSource,G=function J(){var Q=f0()-O._st;O._logger.debug("sourceopen",Q),w.removeEventListener("sourceopen",J),O._openPromise.resolve({costtime:Q})};w.addEventListener("sourceopen",G),this._openPromise=y0()}return this._openPromise}},{key:"bindMedia",value:function(){var K=U0(a().mark(function w(G){var J=this,Q,Z,W,X;return a().wrap(function U(D){while(!0)switch(D.prev=D.next){case 0:if(!(this.mediaSource||this.media)){D.next=3;break}return D.next=3,this.unbindMedia();case 3:if(Q=Ww(this._config.preferMMS),!(!G||!Q)){D.next=6;break}throw new Error("Param media or MediaSource does not exist");case 6:if(this.media=G,Z=this.mediaSource=new Q,W=FO(Z),this._st=f0(),X=function V(){var q=f0()-J._st;J._logger.debug("sourceopen"),Z.removeEventListener("sourceopen",V),URL.revokeObjectURL(G.src),J._openPromise.resolve({costtime:q})},Z.addEventListener("sourceopen",X),W)Z.addEventListener("startstreaming",this._onStartStreaming),Z.addEventListener("endstreaming",this._onEndStreaming);return this._url=URL.createObjectURL(Z),G.src=this._url,G.disableRemotePlayback=W,D.abrupt("return",this._openPromise);case 17:case"end":return D.stop()}},w,this)}));function O(w){return K.apply(this,arguments)}return O}()},{key:"unbindMedia",value:function(){var K=U0(a().mark(function w(){var G=this,J,Q,Z;return a().wrap(function W(X){while(!0)switch(X.prev=X.next){case 0:if(!this._openPromise.used)this._openPromise.resolve();if(J=this.mediaSource,J){if(Object.keys(this._queue).forEach(function(U){var D=G._queue[U];if(D)D.forEach(function(V){var q,L;return(q=V.promise)===null||q===void 0?void 0:(L=q.resolve)===null||L===void 0?void 0:L.call(q)})}),Q=!!this.media&&this.media.readyState>=1,Z=J.readyState==="open",Q&&Z)try{J.endOfStream()}catch(U){}if(Object.keys(this._sourceBuffer).forEach(function(U){try{J.removeSourceBuffer(G._sourceBuffer[U])}catch(D){}}),FO(J))J.removeEventListener("startstreaming",this._onStartStreaming),J.removeEventListener("endstreaming",this._onEndStreaming)}if(this.media){this.media.disableRemotePlayback=!1,this.media.removeAttribute("src");try{this.media.load()}catch(U){}this.media=null}this.mediaSource=null,this._openPromise=y0(),this._queue=Object.create(null),this._sourceBuffer=Object.create(null);case 8:case"end":return X.stop()}},w,this)}));function O(){return K.apply(this,arguments)}return O}()},{key:"createSource",value:function K(O,w){if(this._sourceBuffer[O]||!this.mediaSource)return;var G;try{G=this._sourceBuffer[O]=this.mediaSource.addSourceBuffer(w)}catch(J){throw new Q0(m.MEDIA,m.SUB_TYPES.MSE_ADD_SB,J)}G.mimeType=w,G.addEventListener("updateend",this._onSBUpdateEnd.bind(this,O)),G.addEventListener("error",this._onSBUpdateError.bind(this,O))}},{key:"changeType",value:function K(O,w){var G=this,J=this._sourceBuffer[O];if(!this.mediaSource||!J||J.mimeType===w)return Promise.resolve();if(typeof J.changeType!=="function")return Promise.reject(new Q0(m.MEDIA,m.SUB_TYPES.MSE_CHANGE_TYPE,new Error("changeType is not a function")));return this._enqueueOp(O,function(){try{J.changeType(w)}catch(Q){throw new Q0(m.MEDIA,m.SUB_TYPES.MSE_CHANGE_TYPE,Q)}J.mimeType=w,G._onSBUpdateEnd(O)},"changeType",{mimeType:w})}},{key:"createOrChangeSource",value:function K(O,w){return this.createSource(O,w),this.changeType(O,w)}},{key:"append",value:function K(O,w,G){var J=this;if(!w||!w.byteLength)return Promise.resolve();if(!this._sourceBuffer[O])return Promise.resolve();return this._enqueueOp(O,function(){var Q;if(!J.mediaSource||J.media.error)return;J._logger.debug("MSE APPEND START",G),J._opst=f0(),(Q=J._sourceBuffer[O])===null||Q===void 0||Q.appendBuffer(w)},QO.APPEND,G)}},{key:"remove",value:function K(O,w,G,J){var Q=this,Z=!1;if(this._mseFullFlag[O])Z=!0;return this._enqueueOp(O,function(){if(!Q.mediaSource||Q.media.error)return;var W=Q._sourceBuffer[O];if(w>=G||!W){Q._onSBUpdateEnd(O);return}Q._opst=f0(),Q._logger.debug("MSE REMOVE START",O,w,G,J),W.remove(w,G)},QO.REMOVE,J,Z)}},{key:"clearBuffer",value:function K(O,w){var G=this,J;return Object.keys(this._sourceBuffer).forEach(function(Q){J=G.remove(Q,O,w)}),J||Promise.resolve()}},{key:"clearAllBuffer",value:function K(){var O=this,w;return Object.keys(this._sourceBuffer).forEach(function(G){var J=O._sourceBuffer[G];w=O.remove(G,0,e.end(e.get(J)))}),w}},{key:"clearOpQueues",value:function K(O,w){var G;this._logger.debug("MSE clearOpQueue START");var J=this._queue[O];if(w&&J){this._queue[O]=[];return}if(!J||!J[O]||J.length<5)return;var Q=[];J.forEach(function(Z){if(Z.context&&Z.context.isinit)Q.push(Z)}),this._queue[O]=J.slice(0,2),Q.length>0&&(G=this._queue[O]).push.apply(G,Q)}},{key:"endOfStream",value:function K(O){var w=this;if(!this.mediaSource||this.mediaSource.readyState!=="open")return Promise.resolve();return this._enqueueBlockingOp(function(){var G=w.mediaSource;if(!G||G.readyState!=="open")return;if(w._logger.debug("MSE endOfStream START"),O)G.endOfStream(O);else G.endOfStream()},"endOfStream")}},{key:"setLiveSeekableRange",value:function K(O,w){var G=this.mediaSource;if(O<0||w<O||!(G!==null&&G!==void 0&&G.setLiveSeekableRange)||G.readyState!=="open")return;G.setLiveSeekableRange(O,w)}},{key:"getSourceBuffer",value:function K(O){return this._sourceBuffer[O]}},{key:"buffered",value:function K(O){return e.get(this._sourceBuffer[O])}},{key:"bufferStart",value:function K(O){return e.start(this.buffered(O))}},{key:"bufferEnd",value:function K(O){return e.end(this.buffered(O))}},{key:"_enqueueOp",value:function K(O,w,G,J,Q){var Z=this;if(!this.mediaSource)return Promise.resolve();var W=this._queue[O]=this._queue[O]||[],X={exec:w,promise:y0(),opName:G,context:J};if(Q)W.splice(0,0,X),this._mseFullFlag[O]=!1,this._startQueue(O);else W.push(X);if(this.isOpened||this.isEnded){if(W.length===1)this._startQueue(O)}else this._openPromise.then(function(){if(W.length===1)Z._startQueue(O)});return X.promise}},{key:"_enqueueBlockingOp",value:function(){var K=U0(a().mark(function w(G,J,Q){var Z=this,W,X;return a().wrap(function U(D){while(!0)switch(D.prev=D.next){case 0:if(this.mediaSource){D.next=2;break}return D.abrupt("return",Promise.resolve());case 2:if(W=Object.keys(this._sourceBuffer),W.length){D.next=5;break}return D.abrupt("return",G());case 5:return X=[],W.forEach(function(V){var q=Z._queue[V],L=y0();if(X.push(L),q.push({exec:function z(){L.resolve()},promise:L,opName:J,context:Q}),q.length===1)Z._startQueue(V)}),D.abrupt("return",Promise.all(X).then(function(){try{return G()}finally{W.forEach(function(V){var q=Z._queue[V],L=Z._sourceBuffer[V];if(q===null||q===void 0||q.shift(),!L||!L.updating)Z._startQueue(V)})}}));case 8:case"end":return D.stop()}},w,this)}));function O(w,G,J){return K.apply(this,arguments)}return O}()},{key:"_startQueue",value:function K(O){var w=this._queue[O];if(w){var G=w[0];if(G&&!this._mseFullFlag[O])try{G.exec()}catch(Z){if(Z&&Z.message&&Z.message.indexOf("SourceBuffer is full")>=0){var J;if(this._mseFullFlag[O]=!0,G.context&&z0(G.context)==="object")G.context.isFull=!0;this._logger.error("[MSE error], context,",G.context," ,name,",G.opName,",err,SourceBuffer is full"),G===null||G===void 0||(J=G.promise)===null||J===void 0||J.reject(new Q0(m.MEDIA,m.SUB_TYPES.MSE_FULL,Z))}else{var Q;this._logger.error(Z),G===null||G===void 0||(Q=G.promise)===null||Q===void 0||Q.reject(Z.constructor===Q0?Z:new Q0(m.MEDIA,m.SUB_TYPES.MSE_OTHER,Z)),w.shift(),this._startQueue(O)}}}}},{key:"setTimeoffset",value:function K(O,w,G){var J=this;return this._enqueueOp(O,function(){if(w<0)w+=0.001;J._sourceBuffer[O].timestampOffset=w,J._onSBUpdateEnd(O)},"setTimeoffset",G)}},{key:"abort",value:function K(O,w){var G=this;if(!this.isOpened)return Promise.resolve();return this._enqueueOp(O,function(){G._sourceBuffer[O].abort(),G._onSBUpdateEnd(O)},"abort",w)}}],[{key:"isSupported",value:function K(){var O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:'video/mp4; codecs="avc1.42E01E,mp4a.40.2"',w=Ww();if(!w)return!1;try{return w.isTypeSupported(O)}catch(G){return this._logger.error(O,G),!1}}},{key:"isMMSOnly",value:function K(){return typeof ManagedMediaSource!=="undefined"&&typeof MediaSource==="undefined"}},{key:"getDefaultConfig",value:function K(){return{openLog:!1,preferMMS:!1}}}]),Y}();F(P0,"VIDEO","video");F(P0,"AUDIO","audio");var F0={FETCH:"fetch",XHR:"xhr"},u0={ARRAY_BUFFER:"arraybuffer",TEXT:"text",JSON:"json"};var N0=function(Y){V0(O,Y);var K=q0(O);function O(w,G,J,Q){var Z;return c(this,O),Z=K.call(this,Q),F(M(Z),"retryCount",0),F(M(Z),"isTimeout",!1),F(M(Z),"loaderType",F0.FETCH),F(M(Z),"startTime",0),F(M(Z),"endTime",0),F(M(Z),"options",{}),Z.url=w,Z.request=G,Z.response=J,Z}return r(O)}(T0(Error));var Xw=Object.prototype.toString;function Uw(Y){return Y!==null&&z0(Y)==="object"}function LO(Y){if(Xw.call(Y)!=="[object Object]")return!1;var K=Object.getPrototypeOf(Y);return K===null||K===Object.prototype}function Dw(Y){return Xw.call(Y)==="[object Date]"}function ZO(Y){if(!Y||Y[0]===null||Y[0]===void 0||Y[0]===0&&(Y[1]===null||Y[1]===void 0))return;var K="bytes="+Y[0]+"-";if(Y[1])K+=Y[1];return K}function Aw(Y){return encodeURIComponent(Y).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function WO(Y,K){if(!Y)return;if(!K)return Y;var O,w=Object.keys(K).map(function(J){if(O=K[J],O===null||O===void 0)return;if(Array.isArray(O))J=J+"[]";else O=[O];return O.map(function(Q){if(Dw(Q))Q=Q.toISOString();else if(Uw(Q))Q=JSON.stringify(Q);return"".concat(Aw(J),"=").concat(Aw(Q))}).join("&")}).filter(Boolean).join("&");if(w){var G=Y.indexOf("#");if(G!==-1)Y=Y.slice(0,G);Y+=(Y.indexOf("?")===-1?"?":"&")+w}return Y}function s0(Y,K,O,w,G,J,Q,Z,W,X,U){if(G=G!==null&&G!==void 0?parseFloat(G):null,w=parseInt(w||"0",10),Number.isNaN(w))w=0;var D={range:W,vid:X,index:Z,contentLength:w,age:G,startTime:J,firstByteTime:Q,endTime:Date.now(),priOptions:U};return{data:Y,done:K,options:D,response:O}}function a0(Y,K){return Math.round(Y*8*1000/K/1024)}var u={ERROR:"error",TTFB:"core.ttfb",LOAD_START:"core.loadstart",LOAD_RESPONSE_HEADERS:"core.loadresponseheaders",LOAD_COMPLETE:"core.loadcomplete",LOAD_RETRY:"core.loadretry",SOURCEBUFFER_CREATED:"core.sourcebuffercreated",MEDIASOURCE_OPENED:"core.mediasourceopened",ANALYZE_DURATION_EXCEEDED:"core.analyzedurationexceeded",APPEND_BUFFER:"core.appendbuffer",REMOVE_BUFFER:"core.removebuffer",BUFFEREOS:"core.buffereos",KEYFRAME:"core.keyframe",CHASEFRAME:"core.chaseframe",METADATA_PARSED:"core.metadataparsed",SEI:"core.sei",SEI_IN_TIME:"core.seiintime",FLV_SCRIPT_DATA:"core.flvscriptdata",LOWDECODE:"core.lowdecode",SWITCH_URL_SUCCESS:"core.switchurlsuccess",SWITCH_URL_FAILED:"core.switchurlfailed",SPEED:"core.speed",HLS_MANIFEST_LOADED:"core.hlsmanifestloaded",HLS_LEVEL_LOADED:"core.hlslevelloaded",DEMUXED_TRACK:"core.demuxedtrack",STREAM_EXCEPTION:"core.streamexception",LARGE_AV_FIRST_FRAME_GAP_DETECT:"LARGE_AV_FIRST_FRAME_GAP_DETECT",LARGE_VIDEO_DTS_GAP_DETECT:"LARGE_VIDEO_DTS_GAP_DETECT",LARGE_AUDIO_DTS_GAP_DETECT:"LARGE_AUDIO_DTS_GAP_DETECT",AUDIO_GAP_DETECT:"AUDIO_GAP_DETECT",AUDIO_OVERLAP_DETECT:"AUDIO_OVERLAP_DETECT",MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT:"MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT",REAL_TIME_SPEED:"real_time_speed"};var Nw=o0(k0()),Hw=2097152,t0=function(Y){V0(O,Y);var K=q0(O);function O(){var w;return c(this,O),w=K.call(this),F(M(w),"_abortController",null),F(M(w),"_timeoutTimer",null),F(M(w),"_reader",null),F(M(w),"_response",null),F(M(w),"_aborted",!1),F(M(w),"_index",-1),F(M(w),"_range",null),F(M(w),"_receivedLength",0),F(M(w),"_running",!1),F(M(w),"_logger",null),F(M(w),"_vid",""),F(M(w),"_onProcessMinLen",0),F(M(w),"_onCancel",null),F(M(w),"_priOptions",null),w}return r(O,[{key:"load",value:function w(G){var J,Q=this,Z=G.url,W=G.vid,X=G.timeout,U=G.responseType,D=G.onProgress,V=G.index,q=G.onTimeout,L=G.onCancel,z=G.range,I=G.transformResponse,E=G.request,S=G.params,x=G.logger,C=G.method,R=G.headers,v=G.body,_=G.mode,t=G.credentials,P=G.cache,l=G.redirect,Y0=G.referrer,H=G.referrerPolicy,A=G.onProcessMinLen,N=G.priOptions;this._logger=x,this._aborted=!1,this._onProcessMinLen=A,this._onCancel=L,this._abortController=typeof AbortController!=="undefined"&&new AbortController,this._running=!0,this._index=V,this._range=z||[0,0],this._vid=W||Z,this._priOptions=N||{};var B={method:C,headers:R,body:v,mode:_,credentials:t,cache:P,redirect:l,referrer:Y0,referrerPolicy:H,signal:(J=this._abortController)===null||J===void 0?void 0:J.signal},j=!1;clearTimeout(this._timeoutTimer),Z=WO(Z,S);var $=ZO(z);if($){if(E)R=E.headers;else R=B.headers=B.headers||(Headers?new Headers:{});if(Headers&&R instanceof Headers)R.append("Range",$);else R.Range=$}if(X)this._timeoutTimer=setTimeout(function(){if(j=!0,Q.cancel(),q){var n=new N0(Z,B,null,"timeout");n.isTimeout=!0,q(n,{index:Q._index,range:Q._range,vid:Q._vid,priOptions:Q._priOptions})}},X);var T=Date.now();return this._logger.debug("[fetch load start], index,",V,",range,",z),new Promise(function(n,o){fetch(E||Z,E?void 0:B).then(function(){var i=U0(a().mark(function w0(d){var HO,C0,NO,mO;return a().wrap(function g1(G0){while(!0)switch(G0.prev=G0.next){case 0:if(clearTimeout(Q._timeoutTimer),Q._response=d,!(Q._aborted||!Q._running)){G0.next=4;break}return G0.abrupt("return");case 4:if(I)d=I(d,Z)||d;if(d.ok){G0.next=7;break}throw new N0(Z,B,d,"bad network response");case 7:if(HO=Date.now(),U!==u0.TEXT){G0.next=15;break}return G0.next=11,d.text();case 11:C0=G0.sent,Q._running=!1,G0.next=37;break;case 15:if(U!==u0.JSON){G0.next=22;break}return G0.next=18,d.json();case 18:C0=G0.sent,Q._running=!1,G0.next=37;break;case 22:if(!D){G0.next=29;break}return Q.resolve=n,Q.reject=o,Q._loadChunk(d,D,T,HO),G0.abrupt("return");case 29:return G0.next=31,d.arrayBuffer();case 31:C0=G0.sent,C0=new Uint8Array(C0),Q._running=!1,NO=Date.now()-T,mO=a0(C0.byteLength,NO),Q.emit(u.REAL_TIME_SPEED,{speed:mO,len:C0.byteLength,time:NO,vid:Q._vid,index:Q._index,range:Q._range,priOptions:Q._priOptions});case 37:Q._logger.debug("[fetch load end], index,",V,",range,",z),n(s0(C0,!0,d,d.headers.get("Content-Length"),d.headers.get("age"),T,HO,V,z,Q._vid,Q._priOptions));case 39:case"end":return G0.stop()}},w0)}));return function(w0){return i.apply(this,arguments)}}()).catch(function(i){var w0;if(clearTimeout(Q._timeoutTimer),Q._running=!1,Q._aborted&&!j)return;i=i instanceof N0?i:new N0(Z,B,null,(w0=i)===null||w0===void 0?void 0:w0.message),i.startTime=T,i.endTime=Date.now(),i.isTimeout=j,i.options={index:Q._index,range:Q._range,vid:Q._vid,priOptions:Q._priOptions},o(i)})})}},{key:"cancel",value:function(){var w=U0(a().mark(function J(){return a().wrap(function Q(Z){while(!0)switch(Z.prev=Z.next){case 0:if(!this._aborted){Z.next=2;break}return Z.abrupt("return");case 2:if(this._aborted=!0,this._running=!1,!this._response){Z.next=14;break}if(Z.prev=5,!this._reader){Z.next=9;break}return Z.next=9,this._reader.cancel();case 9:Z.next=13;break;case 11:Z.prev=11,Z.t0=Z.catch(5);case 13:this._response=this._reader=null;case 14:if(this._abortController){try{this._abortController.abort()}catch(W){}this._abortController=null}if(this._onCancel)this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions});case 16:case"end":return Z.stop()}},J,this,[[5,11]])}));function G(){return w.apply(this,arguments)}return G}()},{key:"_loadChunk",value:function w(G,J,Q,Z){var W=this;if(!G.body||!G.body.getReader){this._running=!1;var X=new N0(G.url,"",G,"onProgress of bad response.body.getReader");X.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this.reject(X);return}if(this._onProcessMinLen>0)this._cache=new Uint8Array(Hw),this._writeIdx=0;var U=this._reader=G.body.getReader(),D,V,q,L=function(){var z=U0(a().mark(function I(){var E,S,x,C,R,v,_,t;return a().wrap(function P(l){while(!0)switch(l.prev=l.next){case 0:return V=Date.now(),l.prev=1,l.next=4,U.read();case 4:D=l.sent,q=Date.now(),l.next=13;break;case 8:if(l.prev=8,l.t0=l.catch(1),q=Date.now(),!W._aborted)W._running=!1,l.t0.options={index:W._index,range:W._range,vid:W._vid,priOptions:W._priOptions},W.reject(l.t0);return l.abrupt("return");case 13:if(S=((E=W._range)===null||E===void 0?void 0:E.length)>0?W._range[0]:0,x=S+W._receivedLength,!W._aborted){l.next=19;break}return W._running=!1,J(void 0,!1,{range:[x,x],vid:W._vid,index:W._index,startTime:V,endTime:q,st:Q,firstByteTime:Z,priOptions:W._priOptions},G),l.abrupt("return");case 19:if(C=D.value?D.value.byteLength:0,W._receivedLength+=C,W._logger.debug("【fetchLoader,onProgress call】,task,",W._range,", start,",x,", end,",S+W._receivedLength,", done,",D.done),W._onProcessMinLen>0){if(W._writeIdx+C>=W._onProcessMinLen||D.done)R=new Uint8Array(W._writeIdx+C),R.set(W._cache.slice(0,W._writeIdx),0),C>0&&R.set(D.value,W._writeIdx),W._writeIdx=0,W._logger.debug("【fetchLoader,onProgress enough】,done,",D.done,",len,",R.byteLength,", writeIdx,",W._writeIdx);else if(C>0&&W._writeIdx+C<Hw)W._cache.set(D.value,W._writeIdx),W._writeIdx+=C,W._logger.debug("【fetchLoader,onProgress cache】,len,",C,", writeIdx,",W._writeIdx);else if(C>0)v=new Uint8Array(W._writeIdx+C+2048),W._logger.debug("【fetchLoader,onProgress extra start】,size,",W._writeIdx+C+2048,", datalen,",C,", writeIdx,",W._writeIdx),v.set(W._cache.slice(0,W._writeIdx),0),C>0&&v.set(D.value,W._writeIdx),W._writeIdx+=C,delete W._cache,W._cache=v,W._logger.debug("【fetchLoader,onProgress extra end】,len,",C,", writeIdx,",W._writeIdx)}else R=D.value;if(R&&R.byteLength>0||D.done)J(R,D.done,{range:[W._range[0]+W._receivedLength-(R?R.byteLength:0),W._range[0]+W._receivedLength],vid:W._vid,index:W._index,startTime:V,endTime:q,st:Q,firstByteTime:Z,priOptions:W._priOptions},G);if(!D.done)L();else _=Date.now()-Q,t=a0(W._receivedLength,_),W.emit(u.REAL_TIME_SPEED,{speed:t,len:W._receivedLength,time:_,vid:W._vid,index:W._index,range:W._range,priOptions:W._priOptions}),W._running=!1,W._logger.debug("[fetchLoader onProgress end],task,",W._range,",done,",D.done),W.resolve(s0(D,!0,G,G.headers.get("Content-Length"),G.headers.get("age"),Q,Z,W._index,W._range,W._vid,W._priOptions));case 25:case"end":return l.stop()}},I,null,[[1,8]])}));return function I(){return z.apply(this,arguments)}}();L()}},{key:"receiveLen",get:function w(){return this._receivedLength}},{key:"running",get:function w(){return this._running},set:function w(G){this._running=G}}],[{key:"isSupported",value:function w(){return typeof fetch!=="undefined"}}]),O}(Nw.default);function Vw(Y){return M0({loaderType:F0.FETCH,retry:0,retryDelay:0,timeout:0,request:null,onTimeout:void 0,onProgress:void 0,onRetryError:void 0,transformRequest:void 0,transformResponse:void 0,transformError:void 0,responseType:u0.TEXT,range:void 0,url:"",params:void 0,method:"GET",headers:{},body:void 0,mode:void 0,credentials:void 0,cache:void 0,redirect:void 0,referrer:void 0,referrerPolicy:void 0,integrity:void 0,onProcessMinLen:0},Y)}var qw=o0(k0()),Fw=function(Y){V0(O,Y);var K=q0(O);function O(){var w;return c(this,O),w=K.call(this),F(M(w),"_xhr",null),F(M(w),"_aborted",!1),F(M(w),"_timeoutTimer",null),F(M(w),"_range",null),F(M(w),"_receivedLength",0),F(M(w),"_url",null),F(M(w),"_onProgress",null),F(M(w),"_index",-1),F(M(w),"_headers",null),F(M(w),"_currentChunkSizeKB",384),F(M(w),"_timeout",null),F(M(w),"_xhr",null),F(M(w),"_withCredentials",null),F(M(w),"_startTime",-1),F(M(w),"_loadCompleteResolve",null),F(M(w),"_loadCompleteReject",null),F(M(w),"_runing",!1),F(M(w),"_logger",!1),F(M(w),"_vid",""),F(M(w),"_responseType",void 0),F(M(w),"_credentials",void 0),F(M(w),"_method",void 0),F(M(w),"_transformResponse",void 0),F(M(w),"_firstRtt",void 0),F(M(w),"_onCancel",null),F(M(w),"_priOptions",null),w}return r(O,[{key:"load",value:function w(G){var J=this;clearTimeout(this._timeoutTimer),this._logger=G.logger,this._range=G.range,this._onProgress=G.onProgress,this._index=G.index,this._headers=G.headers,this._withCredentials=G.credentials==="include"||G.credentials==="same-origin",this._body=G.body||null,G.method&&(this._method=G.method),this._timeout=G.timeout||null,this._runing=!0,this._vid=G.vid||G.url,this._responseType=G.responseType,this._firstRtt=-1,this._onTimeout=G.onTimeout,this._onCancel=G.onCancel,this._request=G.request,this._priOptions=G.priOptions||{},this._logger.debug("【xhrLoader task】, range",this._range),this._url=WO(G.url,G.params);var Q=Date.now();return new Promise(function(Z,W){J._loadCompleteResolve=Z,J._loadCompleteReject=W,J._startLoad()}).catch(function(Z){if(clearTimeout(J._timeoutTimer),J._runing=!1,J._aborted)return;throw Z=Z instanceof N0?Z:new N0(J._url,J._request),Z.startTime=Q,Z.endTime=Date.now(),Z.options={index:J._index,vid:J._vid,priOptions:J._priOptions},Z})}},{key:"_startLoad",value:function w(){var G=null;if(this._responseType===u0.ARRAY_BUFFER&&this._range&&this._range.length>1)if(this._onProgress){this._firstRtt=-1;var J=this._currentChunkSizeKB*1024,Q=this._range[0]+this._receivedLength,Z=this._range[1];if(J<this._range[1]-Q)Z=Q+J;G=[Q,Z],this._logger.debug("[xhr_loader->],tast :",this._range,", SubRange, ",G)}else G=this._range,this._logger.debug("[xhr_loader->],tast :",this._range,", allRange, ",G);this._internalOpen(G)}},{key:"_internalOpen",value:function w(G){var J=this;try{this._startTime=Date.now();var Q=this._xhr=new XMLHttpRequest;Q.open(this._method||"GET",this._url,!0),Q.responseType=this._responseType,this._timeout&&(Q.timeout=this._timeout),Q.withCredentials=this._withCredentials,Q.onload=this._onLoad.bind(this),Q.onreadystatechange=this._onReadyStatechange.bind(this),Q.onerror=function(X){var U,D,V;J._running=!1;var q=new N0(J._url,J._request,X===null||X===void 0?void 0:(U=X.currentTarget)===null||U===void 0?void 0:U.response,"xhr.onerror.status:"+(X===null||X===void 0?void 0:(D=X.currentTarget)===null||D===void 0?void 0:D.status)+",statusText,"+(X===null||X===void 0?void 0:(V=X.currentTarget)===null||V===void 0?void 0:V.statusText));q.options={index:J._index,range:J._range,vid:J._vid,priOptions:J._priOptions},J._loadCompleteReject(q)},Q.ontimeout=function(X){J.cancel();var U=new N0(J._url,J._request,{status:408},"timeout");if(J._onTimeout)U.isTimeout=!0,J._onTimeout(U,{index:J._index,range:J._range,vid:J._vid,priOptions:J._priOptions});U.options={index:J._index,range:J._range,vid:J._vid,priOptions:J._priOptions},J._loadCompleteReject(U)};var Z=this._headers||{},W=ZO(G);if(W)Z.Range=W;if(Z)Object.keys(Z).forEach(function(X){Q.setRequestHeader(X,Z[X])});this._logger.debug("[xhr.send->] tast,",this._range,",load sub range, ",G),Q.send(this._body)}catch(X){X.options={index:this._index,range:G,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(X)}}},{key:"_onReadyStatechange",value:function w(G){var J=G.target;if(J.readyState===2)this._firstRtt<0&&(this._firstRtt=Date.now())}},{key:"_onLoad",value:function w(G){var J,Q=G.target.status;if(Q<200||Q>299){var Z=new N0(this._url,null,M0(M0({},G.target.response),{},{status:Q}),"bad response,status:"+Q);return Z.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(Z)}var W=null,X=!1,U,D=((J=this._range)===null||J===void 0?void 0:J.length)>0?this._range[0]:0;if(this._responseType===u0.ARRAY_BUFFER){var V,q=new Uint8Array(G.target.response);if(U=D+this._receivedLength,q&&q.byteLength>0){this._receivedLength+=q.byteLength;var L=Date.now()-this._startTime,z=a0(this._receivedLength,L);this.emit(u.REAL_TIME_SPEED,{speed:z,len:this._receivedLength,time:L,vid:this._vid,index:this._index,range:[U,D+this._receivedLength],priOptions:this._priOptions})}if(W=q,((V=this._range)===null||V===void 0?void 0:V.length)>1&&this._range[1]&&this._receivedLength<this._range[1]-this._range[0])X=!1;else X=!0;this._logger.debug("[xhr load done->], tast :",this._range,", start",U,"end ",D+this._receivedLength,",dataLen,",q?q.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",X)}else X=!0,W=G.target.response;var I={ok:Q>=200&&Q<300,status:Q,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};if(this._transformResponse)I=this._transformResponse(I,this._url)||I;if(this._onProgress)this._onProgress(W,X,{index:this._index,vid:this._vid,range:[U,D+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},I);if(!X)this._startLoad();else this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(s0(this._onProgress?null:W,X,I,I.headers["content-length"],I.headers.age,this._startTime,this._firstRtt,this._index,this._range,this._vid,this._priOptions))}},{key:"cancel",value:function w(){if(this._aborted)return;if(this._aborted=!0,this._runing=!1,c0(v0(O.prototype),"removeAllListeners",this).call(this),this._onCancel)this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions});if(this._xhr)return this._xhr.abort()}},{key:"receiveLen",get:function w(){return this._receivedLength}},{key:"running",get:function w(){return this._running},set:function w(G){this._running=G}},{key:"_getHeaders",value:function w(G){var J=G.getAllResponseHeaders().trim().split(`\r
4
+ `),Q={},Z=Yw(J),W;try{for(Z.s();!(W=Z.n()).done;){var X=W.value,U=X.split(": ");Q[U[0].toLowerCase()]=U.slice(1).join(": ")}}catch(D){Z.e(D)}finally{Z.f()}return Q}}],[{key:"isSupported",value:function w(){return typeof XMLHttpRequest!=="undefined"}}]),O}(qw.default);var V1=["retry","retryDelay","onRetryError","transformError"],Lw=function(){function Y(K,O){c(this,Y),this.promise=y0(),this.alive=!!O.onProgress,!O.logger&&(O.logger=new D0("Loader")),this._loaderType=K,this._loader=K===F0.FETCH&&typeof fetch!=="undefined"?new t0:new Fw,this._config=O,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=O.retryCheckFunc,this._logger=O.logger}return r(Y,[{key:"exec",value:function K(){var O=this,w=this._config,G=w.retry,J=w.retryDelay,Q=w.onRetryError,Z=w.transformError,W=Gw(w,V1),X=function(){var U=U0(a().mark(function D(){var V,q,L;return a().wrap(function z(I){while(!0)switch(I.prev=I.next){case 0:return I.prev=0,I.next=3,O._loader.load(W);case 3:V=I.sent,O.promise.resolve(V),I.next=27;break;case 7:if(I.prev=7,I.t0=I.catch(0),O._loader.running=!1,O._logger.debug("[task request catch err]",I.t0),!O._canceled){I.next=13;break}return I.abrupt("return");case 13:if(I.t0.loaderType=O._loaderType,I.t0.retryCount=O._retryCount,q=I.t0,Z)q=Z(q)||q;if(Q&&O._retryCount>0)Q(q,O._retryCount,{index:W.index,vid:W.vid,range:W.range,priOptions:W.priOptions});if(O._retryCount++,L=!0,O._retryCheckFunc)L=O._retryCheckFunc(I.t0);if(!(L&&O._retryCount<=G)){I.next=26;break}return clearTimeout(O._retryTimer),O._logger.debug("[task request setTimeout],retry",O._retryCount,",retry range,",W.range),O._retryTimer=setTimeout(X,J),I.abrupt("return");case 26:O.promise.reject(q);case 27:case"end":return I.stop()}},D,null,[[0,7]])}));return function D(){return U.apply(this,arguments)}}();return X(),this.promise}},{key:"cancel",value:function(){var K=U0(a().mark(function w(){return a().wrap(function G(J){while(!0)switch(J.prev=J.next){case 0:return clearTimeout(this._retryTimer),this._canceled=!0,this._loader.running=!1,J.abrupt("return",this._loader.cancel());case 4:case"end":return J.stop()}},w,this)}));function O(){return K.apply(this,arguments)}return O}()},{key:"running",get:function K(){return this._loader&&this._loader.running}},{key:"loader",get:function K(){return this._loader}}]),Y}();function jO(Y){return Y&&!Y.paused&&!Y.ended&&Y.playbackRate!==0&&Y.readyState!==0}function bO(Y){if(!Y)return{};if(typeof Y.getVideoPlaybackQuality==="function"){var K=Y.getVideoPlaybackQuality();return{droppedVideoFrames:K.droppedVideoFrames||K.corruptedVideoFrames,totalVideoFrames:K.totalVideoFrames,creationTime:K.creationTime}}return{droppedVideoFrames:Y.webkitDroppedFrameCount,totalVideoFrames:Y.webkitDecodedFrameCount,creationTime:performance.now()}}function IO(){for(var Y=arguments.length,K=new Array(Y),O=0;O<Y;O++)K[O]=arguments[O];if(K=K.filter(Boolean),K.length<2)return K[0];var w=new Uint8Array(K.reduce(function(J,Q){return J+Q.byteLength},0)),G=0;return K.forEach(function(J){w.set(J,G),G+=J.byteLength}),w}function zO(){var Y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return new Promise(function(K){return setTimeout(K,Y)})}var jw=o0(k0()),BO=function(Y){V0(O,Y);var K=q0(O);function O(w){var G;if(c(this,O),G=K.call(this,w),F(M(G),"type",F0.FETCH),F(M(G),"_queue",[]),F(M(G),"_alive",[]),F(M(G),"_currentTask",null),F(M(G),"_finnalUrl",""),F(M(G),"_config",void 0),G._config=Vw(w),G._config.loaderType===F0.XHR||!t0.isSupported())G.type=F0.XHR;return G.log=w.logger,G}return r(O,[{key:"isFetch",value:function w(){return this.type===F0.FETCH}},{key:"load",value:function w(G){var J=this,Q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(typeof G==="string"||!G)Q.url=G||Q.url||this._config.url;else Q=G;if(Q=Object.assign({},this._config,Q),Q.params)Q.params=Object.assign({},Q.params);if(Q.headers&&LO(Q.headers))Q.headers=Object.assign({},Q.headers);if(Q.body&&LO(Q.body))Q.body=Object.assign({},Q.body);if(Q.transformRequest)Q=Q.transformRequest(Q)||Q;Q.logger=this.log;var Z=new Lw(this.type,Q);if(Z.loader.on(u.REAL_TIME_SPEED,function(W){J.emit(u.REAL_TIME_SPEED,W)}),this._queue.push(Z),this._queue.length===1&&(!this._currentTask||!this._currentTask.running))this._processTask();return Z.promise}},{key:"cancel",value:function(){var w=U0(a().mark(function J(){var Q;return a().wrap(function Z(W){while(!0)switch(W.prev=W.next){case 0:if(Q=this._queue.map(function(X){return X.cancel()}).concat(this._alive.map(function(X){return X.cancel()})),this._currentTask)Q.push(this._currentTask.cancel());return this._queue=[],this._alive=[],W.next=6,Promise.all(Q);case 6:return W.next=8,zO();case 8:case"end":return W.stop()}},J,this)}));function G(){return w.apply(this,arguments)}return G}()},{key:"_processTask",value:function w(){var G=this;if(this._currentTask=this._queue.shift(),!this._currentTask)return;if(this._currentTask.alive)this._alive.push(this._currentTask);var J=this._currentTask.exec().catch(function(Q){});if(!(J&&typeof J.finally==="function"))return;J.finally(function(){var Q,Z;if((Q=G._currentTask)!==null&&Q!==void 0&&Q.alive&&((Z=G._alive)===null||Z===void 0?void 0:Z.length)>0)G._alive=G._alive.filter(function(W){return W&&W!==G._currentTask});G._processTask()})}}],[{key:"isFetchSupport",value:function w(){return t0.isSupported()}}]),O}(jw.default);var RO=function(){function Y(){c(this,Y),F(this,"_prevCurrentTime",0)}return r(Y,[{key:"do",value:function K(O){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3,G=arguments.length>2?arguments[2]:void 0,J=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;if(!O)return;var Q=O.currentTime,Z=0;if(this._prevCurrentTime===Q){var W=e.info(e.get(O),Q);if(!W.buffers.length)return;if(G&&W.nextStart||W.nextStart&&W.nextStart-Q<w)Z=W.nextStart+0.1;else if(W.end&&W.end-Q>J&&!O.seeking)Z=Q+0.1}if(this._prevCurrentTime=Q,Z&&Q!==Z)O.currentTime=Z}}]),Y}();var EO=function(){function Y(K){var O=this;c(this,Y),F(this,"_seiSet",new Set),this.emitter=K,K.on(u.SEI,function(w){if(w)O._seiSet.add(w)})}return r(Y,[{key:"throw",value:function K(O,w){var G=this;if(O===null||O===void 0||!this._seiSet.size)return;var J=O-0.2,Q=O+0.2,Z=[];if(this._seiSet.forEach(function(W){if(W.time>=J&&W.time<=Q)Z.push(W)}),Z.forEach(function(W){G._seiSet.delete(W),G.emitter.emit(u.SEI_IN_TIME,W)}),!w)return;this._seiSet.forEach(function(W){if(W.time<O-5)G._seiSet.delete(W)})}},{key:"reset",value:function K(){this._seiSet.clear()}}]),Y}();var q1=1000,F1=50,L1=3,j1=3000,SO=function(){function Y(K){c(this,Y),F(this,"_chunkSpeed",0),F(this,"_chunkCache",[]),F(this,"_speeds",[]),F(this,"_totalSize",0),F(this,"_totalCost",0),this._opts=K||{}}return r(Y,[{key:"addRecord",value:function K(O,w){if(!O||!w)return;this._speeds.push(8000*O/w),this._speeds=this._speeds.slice(-L1)}},{key:"addChunkRecord",value:function K(O,w){var G,J;if(!O||!w||O<(((G=this._opts)===null||G===void 0?void 0:G.skipChunkSize)||q1))return;this._totalSize+=O,this._totalCost+=w,this._chunkSpeed=8000*O/w,this._chunkCache.push({size:O,duration:w,timestamp:performance.now()});var Q=((J=this._opts)===null||J===void 0?void 0:J.chunkCountForSpeed)||F1;if(this._chunkCache.length>Q)this._chunkCache=this._chunkCache.slice(-Q)}},{key:"getAvgSpeed",value:function K(){var O;if(!this._chunkCache.length&&!this._speeds.length)return 0;if(this._speeds.length)return this._speeds.reduce(function(Z,W){return Z+=W})/this._speeds.length;var w=this._chunkCache[this._chunkCache.length-1],G=performance.now()-w.timestamp;if(G>(((O=this._opts)===null||O===void 0?void 0:O.longtimeNoReceived)||j1))this._chunkCache.push({size:0,duration:G,timestamp:performance.now()});var J=this._chunkCache.reduce(function(Z,W){return Z+=W.size},0),Q=this._chunkCache.reduce(function(Z,W){return Z+=W.duration},0);return 8000*J/Q}},{key:"getLatestSpeed",value:function K(){if(!this._chunkCache.length&&!this._speeds.length)return 0;if(this._speeds.length)return this._speeds[this._speeds.length-1];return this._chunkSpeed}},{key:"getTotalSize",value:function K(){return this._totalSize}},{key:"getTotalCost",value:function K(){return this._totalCost}},{key:"reset",value:function K(){this._chunkCache=[],this._speeds=[],this._totalSize=0,this._totalCost=0}}]),Y}();var eG=o0(k0());var bw=function(){function Y(K){c(this,Y),F(this,"encodeType",""),F(this,"audioCodec",""),F(this,"videoCodec",""),F(this,"domain",""),F(this,"fps",0),F(this,"bitrate",0),F(this,"width",0),F(this,"height",0),F(this,"samplerate",0),F(this,"channelCount",0),F(this,"gop",0),F(this,"_bitsAccumulateSize",0),F(this,"_bitsAccumulateDuration",0),F(this,"_startGopId",-1),this._timescale=K}return r(Y,[{key:"getStats",value:function K(){return{encodeType:this.encodeType,audioCodec:this.audioCodec,videoCodec:this.videoCodec,domain:this.domain,fps:this.fps,bitrate:this.bitrate,width:this.width,height:this.height,samplerate:this.samplerate,channelCount:this.channelCount,gop:this.gop}}},{key:"setEncodeType",value:function K(O){this.encodeType=O}},{key:"setFpsFromScriptData",value:function K(O){var w,G=O.data,J=G===null||G===void 0?void 0:(w=G.onMetaData)===null||w===void 0?void 0:w.framerate;if(J&&J>0&&J<100)this.fps=J}},{key:"setVideoMeta",value:function K(O){if(this.width=O.width,this.height=O.height,this.videoCodec=O.codec,this.encodeType=O.codecType,O.fpsNum&&O.fpsDen){var w=O.fpsNum/O.fpsDen;if(w>0&&w<100)this.fps=w}}},{key:"setAudioMeta",value:function K(O){this.audioCodec=O.codec,this.samplerate=O.sampleRate,this.channelCount=O.channelCount}},{key:"setDomain",value:function K(O){this.domain=O.split("/").slice(2,3)[0]}},{key:"updateBitrate",value:function K(O){var w=this;if(!this.fps||this.fps>=100){if(O.length){var G=O.reduce(function(J,Q){return J+=Q.duration},0)/O.length;this.fps=Math.round(this._timescale/G)}}O.forEach(function(J){if(w._startGopId===-1)w._startGopId=J.gopId;if(J.gopId===w._startGopId)w.gop++;if(w._bitsAccumulateDuration+=J.duration/(w._timescale/1000),w._bitsAccumulateSize+=J.units.reduce(function(Q,Z){return Q+=Z.length},0),w._bitsAccumulateDuration>=1000)w.bitrate=w._bitsAccumulateSize*8,w._bitsAccumulateDuration=0,w._bitsAccumulateSize=0})}}]),Y}(),$O=function(){function Y(K){var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1000;c(this,Y),F(this,"_core",null),F(this,"_samples",[]),this._core=K,this._timescale=O,this._stats=new bw(O),this._bindEvents()}return r(Y,[{key:"getStats",value:function K(){var O,w,G,J,Q,Z,W,X,U,D,V,q=((O=this._core)===null||O===void 0?void 0:O.media)||{},L=q.currentTime,z=L===void 0?0:L,I=q.decodeFps,E=I===void 0?0:I;return M0(M0({},this._stats.getStats()),{},{downloadSpeed:((w=this._core)===null||w===void 0?void 0:(G=w.speedInfo)===null||G===void 0?void 0:G.call(w).speed)||0,avgSpeed:((J=this._core)===null||J===void 0?void 0:(Q=J.speedInfo)===null||Q===void 0?void 0:Q.call(J).avgSpeed)||0,totalReceivedByte:((Z=this._core)===null||Z===void 0?void 0:(W=Z.speedInfo)===null||W===void 0?void 0:W.call(Z).totalSize)||0,totalReceivedCost:((X=this._core)===null||X===void 0?void 0:(U=X.speedInfo)===null||U===void 0?void 0:U.call(X).totalCost)||0,currentTime:z,bufferEnd:((D=this._core)===null||D===void 0?void 0:(V=D.bufferInfo())===null||V===void 0?void 0:V.remaining)||0,decodeFps:E})}},{key:"_bindEvents",value:function K(){var O=this;this._core.on(u.DEMUXED_TRACK,function(w){var G=w.videoTrack;return O._stats.updateBitrate(G.samples)}),this._core.on(u.FLV_SCRIPT_DATA,function(w){O._stats.setFpsFromScriptData(w)}),this._core.on(u.METADATA_PARSED,function(w){if(w.type==="video")O._stats.setVideoMeta(w.track);else O._stats.setAudioMeta(w.track)}),this._core.on(u.TTFB,function(w){O._stats.setDomain(w.responseUrl)})}},{key:"reset",value:function K(){this._samples=[],this._stats=new bw(this._timescale)}}]),Y}();var rw=o0(k0());function b1(Y,K){var O=Y==null?null:typeof Symbol!="undefined"&&Y[Symbol.iterator]||Y["@@iterator"];if(O!=null){var w,G,J,Q,Z=[],W=!0,X=!1;try{if(J=(O=O.call(Y)).next,K===0){if(Object(O)!==O)return;W=!1}else for(;!(W=(w=J.call(O)).done)&&(Z.push(w.value),Z.length!==K);W=!0);}catch(U){X=!0,G=U}finally{try{if(!W&&O.return!=null&&(Q=O.return(),Object(Q)!==Q))return}finally{if(X)throw G}}return Z}}function f(Y,K){if(!(Y instanceof K))throw new TypeError("Cannot call a class as a function")}function Iw(Y,K){for(var O=0;O<K.length;O++){var w=K[O];if(w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w)w.writable=!0;Object.defineProperty(Y,Rw(w.key),w)}}function g(Y,K,O){if(K)Iw(Y.prototype,K);if(O)Iw(Y,O);return Object.defineProperty(Y,"prototype",{writable:!1}),Y}function b(Y,K,O){if(K=Rw(K),K in Y)Object.defineProperty(Y,K,{value:O,enumerable:!0,configurable:!0,writable:!0});else Y[K]=O;return Y}function MO(Y,K){if(typeof K!=="function"&&K!==null)throw new TypeError("Super expression must either be null or a function");if(Y.prototype=Object.create(K&&K.prototype,{constructor:{value:Y,writable:!0,configurable:!0}}),Object.defineProperty(Y,"prototype",{writable:!1}),K)CO(Y,K)}function XO(Y){return XO=Object.setPrototypeOf?Object.getPrototypeOf.bind():function K(O){return O.__proto__||Object.getPrototypeOf(O)},XO(Y)}function CO(Y,K){return CO=Object.setPrototypeOf?Object.setPrototypeOf.bind():function O(w,G){return w.__proto__=G,w},CO(Y,K)}function I1(){if(typeof Reflect==="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy==="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(Y){return!1}}function z1(Y){if(Y===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return Y}function B1(Y,K){if(K&&(typeof K==="object"||typeof K==="function"))return K;else if(K!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return z1(Y)}function yO(Y){var K=I1();return function O(){var w=XO(Y),G;if(K){var J=XO(this).constructor;G=Reflect.construct(w,arguments,J)}else G=w.apply(this,arguments);return B1(this,G)}}function zw(Y,K){return E1(Y)||b1(Y,K)||Bw(Y,K)||C1()}function L0(Y){return R1(Y)||S1(Y)||Bw(Y)||$1()}function R1(Y){if(Array.isArray(Y))return vO(Y)}function E1(Y){if(Array.isArray(Y))return Y}function S1(Y){if(typeof Symbol!=="undefined"&&Y[Symbol.iterator]!=null||Y["@@iterator"]!=null)return Array.from(Y)}function Bw(Y,K){if(!Y)return;if(typeof Y==="string")return vO(Y,K);var O=Object.prototype.toString.call(Y).slice(8,-1);if(O==="Object"&&Y.constructor)O=Y.constructor.name;if(O==="Map"||O==="Set")return Array.from(Y);if(O==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(O))return vO(Y,K)}function vO(Y,K){if(K==null||K>Y.length)K=Y.length;for(var O=0,w=new Array(K);O<K;O++)w[O]=Y[O];return w}function $1(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
5
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function C1(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
6
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function v1(Y,K){if(typeof Y!=="object"||Y===null)return Y;var O=Y[Symbol.toPrimitive];if(O!==void 0){var w=O.call(Y,K||"default");if(typeof w!=="object")return w;throw new TypeError("@@toPrimitive must return a primitive value.")}return(K==="string"?String:Number)(Y)}function Rw(Y){var K=v1(Y,"string");return typeof K==="symbol"?K:String(K)}var j0={VIDEO:"video",AUDIO:"audio",METADATA:"metadata"},R0={AV1:"av1",AVC:"avc",HEVC:"hevc"},s={AAC:"aac",G711PCMA:"g7110a",G711PCMU:"g7110m",OPUS:"opus",MP3:"mp3"},W0={LARGE_AV_SHIFT:"LARGE_AV_SHIFT",LARGE_VIDEO_GAP:"LARGE_VIDEO_GAP",LARGE_VIDEO_GAP_BETWEEN_CHUNK:"LARGE_VIDEO_GAP_BETWEEN_CHUNK",LARGE_AUDIO_GAP:"LARGE_AUDIO_GAP",AUDIO_FILLED:"AUDIO_FILLED",AUDIO_DROPPED:"AUDIO_DROPPED"};var Ew=function(){function Y(){f(this,Y),b(this,"id",1),b(this,"type",j0.VIDEO),b(this,"codecType",R0.AVC),b(this,"pid",-1),b(this,"hvcC",void 0),b(this,"codec",""),b(this,"timescale",0),b(this,"formatTimescale",0),b(this,"sequenceNumber",0),b(this,"baseMediaDecodeTime",0),b(this,"baseDts",0),b(this,"duration",0),b(this,"warnings",[]),b(this,"samples",[]),b(this,"pps",[]),b(this,"sps",[]),b(this,"vps",[]),b(this,"fpsNum",0),b(this,"fpsDen",0),b(this,"sarRatio",[]),b(this,"width",0),b(this,"height",0),b(this,"nalUnitSize",4),b(this,"present",!1),b(this,"isVideoEncryption",!1),b(this,"isAudioEncryption",!1),b(this,"isVideo",!0),b(this,"lastKeyFrameDts",0),b(this,"kid",null),b(this,"pssh",null),b(this,"ext",void 0)}return g(Y,[{key:"reset",value:function K(){this.sequenceNumber=this.width=this.height=this.fpsDen=this.fpsNum=this.duration=this.baseMediaDecodeTime=this.timescale=0,this.codec="",this.present=!1,this.pid=-1,this.pps=[],this.sps=[],this.vps=[],this.sarRatio=[],this.samples=[],this.warnings=[],this.hvcC=null}},{key:"firstDts",get:function K(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function K(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function K(){if(this.samples.length>0){var O=this.samples[0],w=this.samples[this.samples.length-1];return w.dts-O.dts+w.duration}return 0}},{key:"exist",value:function K(){if(/av01/.test(this.codec))return!0;return!!(this.pps.length&&this.sps.length&&this.codec)}},{key:"hasSample",value:function K(){return!!this.samples.length}},{key:"isEncryption",get:function K(){return this.isVideoEncryption}}]),Y}();var Sw=function(){function Y(){f(this,Y),b(this,"id",2),b(this,"type",j0.AUDIO),b(this,"codecType",s.AAC),b(this,"pid",-1),b(this,"codec",""),b(this,"container",""),b(this,"sequenceNumber",0),b(this,"sampleDuration",0),b(this,"timescale",0),b(this,"formatTimescale",0),b(this,"baseMediaDecodeTime",0),b(this,"duration",0),b(this,"warnings",[]),b(this,"samples",[]),b(this,"baseDts",0),b(this,"sampleSize",16),b(this,"sampleRate",0),b(this,"channelCount",0),b(this,"objectType",0),b(this,"sampleRateIndex",0),b(this,"config",[]),b(this,"present",!1),b(this,"isVideoEncryption",!1),b(this,"isAudioEncryption",!1),b(this,"kid",null),b(this,"ext",void 0)}return g(Y,[{key:"reset",value:function K(){this.sequenceNumber=0,this.timescale=0,this.sampleDuration=0,this.sampleRate=0,this.channelCount=0,this.baseMediaDecodeTime=0,this.present=!1,this.pid=-1,this.codec="",this.samples=[],this.config=[],this.warnings=[]}},{key:"exist",value:function K(){return!!(this.sampleRate&&this.channelCount&&(this.codec||this.container)&&(this.codecType===s.AAC||this.codecType===s.G711PCMA||this.codecType===s.G711PCMU||this.codecType===s.OPUS||this.codecType===s.MP3))}},{key:"hasSample",value:function K(){return!!this.samples.length}},{key:"isEncryption",get:function K(){return this.isAudioEncryption}},{key:"firstDts",get:function K(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function K(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function K(){if(this.samples.length>0){var O=this.samples[0],w=this.samples[this.samples.length-1];return w.dts-O.dts+w.duration}return 0}}]),Y}();var $w=function(){function Y(K,O,w){if(f(this,Y),b(this,"flag",{}),b(this,"keyframe",!1),b(this,"gopId",0),b(this,"duration",0),b(this,"size",0),b(this,"units",[]),b(this,"chromaFormat",420),this.originPts=this.pts=K,this.originDts=this.dts=O,w)this.units=w}return g(Y,[{key:"cts",get:function K(){return this.pts-this.dts}},{key:"setToKeyframe",value:function K(){this.keyframe=!0,this.flag.dependsOn=2,this.flag.isNonSyncSample=0}}]),Y}();var m0=g(function Y(K,O,w,G){if(f(this,Y),b(this,"duration",1024),b(this,"flag",{dependsOn:2,isNonSyncSample:0}),b(this,"keyframe",!0),this.originPts=this.pts=this.dts=K,this.data=O,this.size=O.byteLength,this.sampleOffset=G,w)this.duration=w});var Cw=g(function Y(K,O){f(this,Y),b(this,"time",0),this.data=K,this.originPts=this.pts=O}),vw=function(Y){MO(O,Y);var K=yO(O);function O(){return f(this,O),K.apply(this,arguments)}return g(O)}(Cw),Mw=function(Y){MO(O,Y);var K=yO(O);function O(){return f(this,O),K.apply(this,arguments)}return g(O)}(Cw),yw=function(){function Y(){f(this,Y),b(this,"id",3),b(this,"type",j0.METADATA),b(this,"timescale",0),b(this,"flvScriptSamples",[]),b(this,"seiSamples",[])}return g(Y,[{key:"exist",value:function K(){return!!((this.flvScriptSamples.length||this.seiSamples.length)&&this.timescale)}},{key:"reset",value:function K(){this.timescale=0,this.flvScriptSamples=[],this.seiSamples=[]}},{key:"hasSample",value:function K(){return!!(this.flvScriptSamples.length||this.seiSamples.length)}}]),Y}();var g0=function(){function Y(K){f(this,Y),this.name=K||"",this._prefix="[".concat(this.name,"]")}return g(Y,[{key:"warn",value:function K(){var O;if(Y.disabled)return;for(var w=arguments.length,G=new Array(w),J=0;J<w;J++)G[J]=arguments[J];(O=console).warn.apply(O,[this._prefix].concat(G))}}],[{key:"enable",value:function K(){Y.disabled=!1}},{key:"disable",value:function K(){Y.disabled=!0}}]),Y}();b(g0,"disabled",!0);var UO=typeof window!=="undefined",PO=UO&&navigator.userAgent.toLocaleLowerCase(),Pw=UO&&/^((?!chrome|android).)*safari/.test(PO),uw=UO&&PO.includes("firefox"),Tw=UO&&PO.includes("android");var p0=function(){function Y(){f(this,Y)}return g(Y,null,[{key:"getRateIndexByRate",value:function K(O){return Y.FREQ.indexOf(O)}},{key:"parseADTS",value:function K(O,w){var G=O.length,J=0;while(J+2<G){if(O[J]===255&&(O[J+1]&246)===240)break;J++}if(J>=G)return;var Q=J,Z=[],W=(O[J+2]&60)>>>2,X=Y.FREQ[W];if(!X)throw new Error("Invalid sampling index: ".concat(W));var U=((O[J+2]&192)>>>6)+1,D=(O[J+2]&1)<<2|(O[J+3]&192)>>>6,V=Y._getConfig(W,D,U),q=V.config,L=V.codec,z,I,E=0,S=Y.getFrameDuration(X);while(J+7<G){if(O[J]!==255||(O[J+1]&246)!==240){J++;continue}if(I=(O[J+3]&3)<<11|O[J+4]<<3|(O[J+5]&224)>>5,!I||G-J<I)break;z=(~O[J+1]&1)*2,Z.push({pts:w+E*S,data:O.subarray(J+7+z,J+I)}),E++,J+=I}return{skip:Q,remaining:J>=G?void 0:O.subarray(J),frames:Z,samplingFrequencyIndex:W,sampleRate:X,objectType:U,channelCount:D,codec:L,config:q,originCodec:"mp4a.40.".concat(U)}}},{key:"parseAudioSpecificConfig",value:function K(O){if(!O.length)return;var w=O[0]>>>3,G=(O[0]&7)<<1|O[1]>>>7,J=(O[1]&120)>>>3,Q=Y.FREQ[G];if(!Q)return;var Z=Y._getConfig(G,J,w),W=Z.config,X=Z.codec;return{samplingFrequencyIndex:G,sampleRate:Q,objectType:w,channelCount:J,config:W,codec:X,originCodec:"mp4a.40.".concat(w)}}},{key:"getFrameDuration",value:function K(O){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:90000;return 1024*w/O}},{key:"_getConfig",value:function K(O,w,G){var J=[],Q,Z;if(uw)if(O>=6)Q=5,Z=O-3;else Q=2,Z=O;else if(Tw)Q=2,Z=O;else if(Q=5,Z=O,O>=6)Z=O-3;else if(w===1)Q=2,Z=O;if(J[0]=Q<<3,J[0]|=(O&14)>>1,J[1]=(O&1)<<7,J[1]|=w<<3,Q===5)J[1]|=(Z&14)>>1,J[2]=(Z&1)<<7,J[2]|=8,J[3]=0;return{config:J,codec:"mp4a.40.".concat(Q)}}},{key:"getSilentFrame",value:function K(O,w){switch(O){case"mp4a.40.2":if(w===1)return new Uint8Array([0,200,0,128,35,128]);if(w===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(w===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(w===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(w===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(w===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(w===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(w===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(w===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}}]),Y}();b(p0,"FREQ",[96000,88200,64000,48000,44100,32000,24000,22050,16000,12000,11025,8000,7350]);var e0=function(){function Y(){f(this,Y)}return g(Y,null,[{key:"getFrameDuration",value:function K(O){return 20}},{key:"parseHeaderPackets",value:function K(O){if(!O.length)return;var w=new DataView(O.buffer,O.byteOffset,O.byteLength),G="";for(var J=0;J<8;J++)G+=String.fromCodePoint(O[J]);if(G!=="OpusHead")throw new Error("Invalid Opus MagicSignature");var Q=O[9];console.log("Pre-skip",O[10],O[11]);var Z=w.getUint32(12,!0),W=w.getInt16(16,!0);if(!Z)return;var X="opus",U="opus",D=new Uint8Array(O.buffer,O.byteOffset+8,O.byteLength-8);return{outputGain:W,sampleRate:Z,channelCount:Q,config:D,codec:X,originCodec:U}}}]),Y}();var M1=500,fw=3,uO=1000,TO=5000,y1=1000,P1=200,gw=5000,hw=5,xw=function(){function Y(K,O,w){f(this,Y),this.videoTrack=K,this.audioTrack=O,this.metadataTrack=w,this._baseDts=-1,this._baseDtsInited=!1,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastVideoDuration=0,this._keyFrameInNextChunk=!1,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0}return g(Y,[{key:"fix",value:function K(){var O=this,w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,G=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,J=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;w=Math.round(w*1000);var Q=this.videoTrack,Z=this.audioTrack;if(G||!J)this._videoLastSample=null,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0;if(G&&!J)this._baseDtsInited=!1;if(!this._baseDtsInited)this._calculateBaseDts(Z,Q);if(!J&&w)this._audioNextPts=this._videoNextDts=w;var W=this._baseDtsInited&&(this._videoTimestampBreak||!this.videoTrack.exist())&&(this._audioTimestampBreak||!this.audioTrack.exist());if(W)this._resetBaseDtsWhenStreamBreaked();if(this._fixAudio(Z),this._keyFrameInNextChunk=!1,this._fixVideo(Q),this.metadataTrack.exist()){var X=this.metadataTrack.timescale;this.metadataTrack.seiSamples.forEach(function(U){U.pts=U.originPts-O._baseDts,U.time=Math.max(0,U.pts)/X}),this.metadataTrack.flvScriptSamples.forEach(function(U){U.pts=U.originPts-O._baseDts,U.time=Math.max(0,U.pts)/X})}if(Q.samples.length)Q.baseMediaDecodeTime=Q.samples[0].dts;if(Z.samples.length)Z.baseMediaDecodeTime=Z.samples[0].pts*Z.timescale/1000}},{key:"_fixVideo",value:function K(O){var w=this,G=O.samples;if(!G.length)return;G.forEach(function(S){if(S.dts-=w._baseDts,S.pts-=w._baseDts,S.keyframe)w._keyFrameInNextChunk=!0});var J;if(O.fpsNum&&O.fpsDen)J=O.timescale*(O.fpsDen/O.fpsNum);else if(O.length>1){var Q=O.samples[0],Z=O.samples[G.length-1];J=Math.floor((Z.dts-Q.dts)/(G.length-1))}else J=this._lastVideoDuration||40;var W=G.pop();if(this._videoLastSample)G.unshift(this._videoLastSample);if(this._videoLastSample=W,!G.length)return;if(this._videoNextDts===void 0){var X=G[0];this._videoNextDts=X.dts}var U=G.length,D=0,V=G[0],q=this._videoNextDts-V.dts;if(Math.abs(q)>P1){if(Math.abs(V.dts-this._lastVideoExceptionChunkFirstDtsDot)>gw){var L;this._lastVideoExceptionChunkFirstDtsDot=V.dts,O.warnings.push({type:W0.LARGE_VIDEO_GAP_BETWEEN_CHUNK,nextDts:this._videoNextDts,firstSampleDts:V.dts,nextSampleDts:(L=G[1])===null||L===void 0?void 0:L.dts,sampleDuration:q})}if(this._videoTimestampBreak>=hw)this._videoNextDts=V.dts,this._videoTimestampBreak=0;else if(V.dts+=q,V.pts+=q,!this.audioTrack.exist())this._videoTimestampBreak=1}for(var z=0;z<U;z++){var I=G[z].dts,E=G[z+1];if(z<U-1)D=E.dts-I;else if(W)D=W.dts-I;else D=J;if(D>y1||D<0){if(this._videoTimestampBreak++,Math.abs(I-this._lastVideoExceptionLargeGapDot)>gw)this._lastVideoExceptionLargeGapDot=I,O.warnings.push({type:W0.LARGE_VIDEO_GAP,time:I/O.timescale,dts:I,originDts:G[z].originDts,nextDts:this._videoNextDts,sampleDuration:D,refSampleDuration:J});D=J}G[z].duration=D,this._videoNextDts+=D,this._lastVideoDuration=D}}},{key:"_fixAudio",value:function K(O){var w=this,G=O.samples;if(!G.length)return;G.forEach(function(J){J.dts=J.pts-=w._baseDts}),this._doFixAudioInternal(O,G,1000)}},{key:"_calculateBaseDts",value:function K(O,w){var G=O.samples,J=w.samples;if(!G.length&&!J.length)return!1;var Q=1/0,Z=1/0;if(G.length)O.baseDts=Q=G[0].pts;if(J.length)w.baseDts=Z=J[0].dts;this._baseDts=Math.min(Q,Z);var W=Z-Q;if(Number.isFinite(W)&&Math.abs(W)>M1)w.warnings.push({type:W0.LARGE_AV_SHIFT,videoBaseDts:Z,audioBasePts:Q,baseDts:this._baseDts,delta:W});return this._baseDtsInited=!0,!0}},{key:"_resetBaseDtsWhenStreamBreaked",value:function K(){var O=this._calculateBaseDts(this.audioTrack,this.videoTrack);if(!O)return;if(!this.audioTrack.exist())this._baseDts-=this._videoNextDts;else if(!this.videoTrack.exist())this._baseDts-=this._audioNextPts;else this._baseDts-=Math.min(this._audioNextPts,this._videoNextDts);this._videoTimestampBreak=0,this._audioTimestampBreak=0}},{key:"_doFixAudioInternal",value:function K(O,w,G){if(!O.sampleDuration)switch(O.codecType){case s.AAC:{O.sampleDuration=p0.getFrameDuration(O.timescale,G);break}case s.OPUS:{O.sampleDuration=e0.getFrameDuration(O.samples,G);break}case s.G711PCMA:case s.G711PCMU:{O.sampleDuration=this._getG711Duration(O);break}default:console.error("can't fix audio codecType:",O.codecType);break}var J=O.sampleDuration,Q=O.codecType===s.OPUS?20:O.codecType===s.AAC?1024:J*O.timescale/1000;if(this._audioNextPts===void 0){var Z=w[0];this._audioNextPts=Z.pts}for(var W=0;W<w.length;W++){var X=this._audioNextPts,U=w[W],D=U.pts-X;if(W===0&&this._audioTimestampBreak>=hw&&this._keyFrameInNextChunk)X=this._audioNextPts=U.dts,D=0,this._audioTimestampBreak=0;if(!this._audioTimestampBreak&&D>=fw*J&&D<=uO&&!Pw){var V=this._getSilentFrame(O)||w[0].data.subarray(),q=Math.floor(D/J);if(Math.abs(U.pts-this._lastAudioExceptionGapDot)>TO)this._lastAudioExceptionGapDot=U.pts,O.warnings.push({type:W0.AUDIO_FILLED,pts:U.pts,originPts:U.originPts,count:q,nextPts:X,refSampleDuration:J});for(var L=0;L<q;L++){var z=new m0(Math.floor(this._audioNextPts+J)-Math.floor(this._audioNextPts),V,Q);z.originPts=Math.floor(this._baseDts+X),w.splice(W,0,z),this._audioNextPts+=J,W++}W--}else if(D<=-fw*J&&D>=-1*uO){if(Math.abs(U.pts-this._lastAudioExceptionOverlapDot)>TO)this._lastAudioExceptionOverlapDot=U.pts,O.warnings.push({type:W0.AUDIO_DROPPED,pts:U.pts,originPts:U.originPts,nextPts:X,refSampleDuration:J});w.splice(W,1),W--}else{if(Math.abs(D)>uO){if(this._audioTimestampBreak++,Math.abs(U.pts-this._lastAudioExceptionLargeGapDot)>TO)this._lastAudioExceptionLargeGapDot=U.pts,O.warnings.push({type:W0.LARGE_AUDIO_GAP,time:U.pts/1000,pts:U.pts,originPts:U.originPts,nextPts:X,sampleDuration:D,refSampleDuration:J})}if(O.codecType===s.OPUS){var I=w[w.length-1];if(I)I.duration=U.pts-I.pts}else U.dts=U.pts=X,U.duration=Q;this._audioNextPts+=J}}}},{key:"_getG711Duration",value:function K(O){var{sampleSize:w,channelCount:G,sampleRate:J}=O,Q=O.samples[0];if(!Q)return;return Q.data.byteLength*2/G/(w/8)/J*1000}},{key:"_getSilentFrame",value:function K(O){if(O.codecType===s.AAC)return p0.getSilentFrame(O.codec,O.channelCount);return new Uint8Array(8*O.sampleDuration*O.channelCount)}}]),Y}();function A0(){for(var Y=arguments.length,K=new Array(Y),O=0;O<Y;O++)K[O]=arguments[O];K=K.filter(Boolean);var w=new Uint8Array(K.reduce(function(J,Q){return J+Q.byteLength},0)),G=0;return K.forEach(function(J){w.set(J,G),G+=J.byteLength}),w}var d2=Math.pow(2,32);function l0(Y){var K=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(Y[K]<<24>>>0)+(Y[K+1]<<16)+(Y[K+2]<<8)+(Y[K+3]||0)}function kw(Y){var K="avc1.",O;for(var w=0;w<3;w++){if(O=Y[w].toString(16),O.length<2)O="0".concat(O);K+=O}return K}function fO(Y){if(!Array.isArray(Y)){var K=[],O="";for(var w=0;w<Y.length;w++)if(w%2)O=Y[w-1]+Y[w],K.push(parseInt(O,16)),O="";return K}return Y.map(function(G){return parseInt(G,16)})}var E0=function(){function Y(){f(this,Y)}return g(Y,null,[{key:"parseAnnexB",value:function K(O){var w=O.byteLength-1,G=0;do{if(O[w]===0)G++;else break;w--}while(w>0);if(G>=3)O=O.subarray(0,w+1);var J=O.length,Q=2,Z=0;while(O[Q]!==null&&O[Q]!==void 0&&O[Q]!==1)Q++;if(Q++,Z=Q+2,Z>=J)return[];var W=[];while(Z<J)switch(O[Z]){case 0:if(O[Z-1]!==0){Z+=2;break}else if(O[Z-2]!==0){Z++;break}else if(Z<J-1&&O[Z+1]!==1){Z++;break}if(Q!==Z-2)W.push(O.subarray(Q,Z-2));do Z++;while(O[Z]!==1&&Z<J);Q=Z+1,Z=Q+2;break;case 1:if(O[Z-1]!==0||O[Z-2]!==0){Z+=3;break}if(Q!==Z-2)W.push(O.subarray(Q,Z-2));Q=Z+1,Z=Q+2;break;default:Z+=3;break}if(Q<J)W.push(O.subarray(Q));return W}},{key:"parseAvcC",value:function K(O){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;if(O.length<4)return;var G=O.length,J=[],Q=0,Z;while(Q+w<G){if(Z=l0(O,Q),w===3)Z>>>=8;if(Q+=w,!Z)continue;if(Q+Z>G)break;J.push(O.subarray(Q,Q+Z)),Q+=Z}return J}},{key:"parseSEI",value:function K(O,w){var G=O.length,J=w?2:1,Q=0,Z=0,W="";while(O[J]===255)Q+=255,J++;Q+=O[J++];while(O[J]===255)Z+=255,J++;if(Z+=O[J++],Q===5&&G>J+16)for(var X=0;X<16;X++)W+=O[J].toString(16),J++;return{payload:O.subarray(J,J+Z),type:Q,size:Z,uuid:W}}},{key:"removeEPB",value:function K(O){var w=O.byteLength,G=[],J=1;while(J<w-2)if(O[J]===0&&O[J+1]===0&&O[J+2]===3)G.push(J+2),J+=2;else J++;if(!G.length)return O;var Q=w-G.length,Z=new Uint8Array(Q),W=0;for(J=0;J<Q;W++,J++){if(W===G[0])W++,G.shift();Z[J]=O[W]}return Z}}]),Y}();var OO=function(){function Y(K){if(f(this,Y),b(this,"_bytesAvailable",void 0),b(this,"_bitsAvailable",0),b(this,"_word",0),!K)throw new Error("ExpGolomb data params is required");if(this._data=K,this._bytesAvailable=K.byteLength,this._bytesAvailable)this._loadWord()}return g(Y,[{key:"bitsAvailable",get:function K(){return this._bitsAvailable}},{key:"_loadWord",value:function K(){var O=this._data.byteLength-this._bytesAvailable,w=Math.min(4,this._bytesAvailable);if(w===0)throw new Error("No bytes available");var G=new Uint8Array(4);G.set(this._data.subarray(O,O+w)),this._word=new DataView(G.buffer).getUint32(0),this._bitsAvailable=w*8,this._bytesAvailable-=w}},{key:"skipBits",value:function K(O){if(this._bitsAvailable>O)this._word<<=O,this._bitsAvailable-=O;else{O-=this._bitsAvailable;var w=Math.floor(O/8);O-=w*8,this._bytesAvailable-=w,this._loadWord(),this._word<<=O,this._bitsAvailable-=O}}},{key:"readBits",value:function K(O){if(O>32)throw new Error("Cannot read more than 32 bits");var w=Math.min(this._bitsAvailable,O),G=this._word>>>32-w;if(this._bitsAvailable-=w,this._bitsAvailable>0)this._word<<=w;else if(this._bytesAvailable>0)this._loadWord();if(w=O-w,w>0&&this._bitsAvailable)return G<<w|this.readBits(w);return G}},{key:"skipLZ",value:function K(){var O;for(O=0;O<this._bitsAvailable;++O)if((this._word&2147483648>>>O)!==0)return this._word<<=O,this._bitsAvailable-=O,O;return this._loadWord(),O+this.skipLZ()}},{key:"skipUEG",value:function K(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function K(){var O=this.skipLZ();return this.readBits(O+1)-1}},{key:"readEG",value:function K(){var O=this.readUEG();if(1&O)return 1+O>>>1;return-1*(O>>>1)}},{key:"readBool",value:function K(){return this.readBits(1)===1}},{key:"readUByte",value:function K(){return this.readBits(8)}},{key:"skipScalingList",value:function K(O){var w=8,G=8,J;for(var Q=0;Q<O;Q++){if(G!==0)J=this.readEG(),G=(w+J+256)%256;w=G===0?w:G}}}]),Y}();var mw=function(){function Y(){f(this,Y)}return g(Y,null,[{key:"parseAVCDecoderConfigurationRecord",value:function K(O){if(O.length<7)return;var w=(O[4]&3)+1,G,J=[],Q=[],Z=6,W=O[5]&31,X;for(var U=0;U<W;U++){if(X=O[Z]<<8|O[Z+1],Z+=2,!X)continue;var D=O.subarray(Z,Z+X);if(Z+=X,J.push(D),!G)G=Y.parseSPS(E0.removeEPB(D))}var V=O[Z];Z++;var q;for(var L=0;L<V;L++){if(q=O[Z]<<8|O[Z+1],Z+=2,!q)continue;Q.push(O.subarray(Z,Z+q)),Z+=q}return{sps:G,spsArr:J,ppsArr:Q,nalUnitSize:w}}},{key:"parseSPS",value:function K(O){var w=new OO(O);w.readUByte();var G=w.readUByte(),J=w.readUByte(),Q=w.readUByte();w.skipUEG();var Z=420;if(G===100||G===110||G===122||G===244||G===44||G===83||G===86||G===118||G===128||G===138||G===144){var W=w.readUEG();if(W<=3)Z=[0,420,422,444][W];if(W===3)w.skipBits(1);if(w.skipUEG(),w.skipUEG(),w.skipBits(1),w.readBool()){var X=W!==3?8:12;for(var U=0;U<X;U++)if(w.readBool())if(U<6)w.skipScalingList(16);else w.skipScalingList(64)}}w.skipUEG();var D=w.readUEG();if(D===0)w.readUEG();else if(D===1){w.skipBits(1),w.skipUEG(),w.skipUEG();var V=w.readUEG();for(var q=0;q<V;q++)w.skipUEG()}w.skipUEG(),w.skipBits(1);var L=w.readUEG(),z=w.readUEG(),I=w.readBits(1);if(I===0)w.skipBits(1);w.skipBits(1);var E=0,S=0,x=0,C=0;if(w.readBool())E=w.readUEG(),S=w.readUEG(),x=w.readUEG(),C=w.readUEG();var R,v,_,t,P;if(w.readBool()){if(w.readBool()){var l=w.readUByte();switch(l){case 1:R=[1,1];break;case 2:R=[12,11];break;case 3:R=[10,11];break;case 4:R=[16,11];break;case 5:R=[40,33];break;case 6:R=[24,11];break;case 7:R=[20,11];break;case 8:R=[32,11];break;case 9:R=[80,33];break;case 10:R=[18,11];break;case 11:R=[15,11];break;case 12:R=[64,33];break;case 13:R=[160,99];break;case 14:R=[4,3];break;case 15:R=[3,2];break;case 16:R=[2,1];break;case 255:{R=[w.readUByte()<<8|w.readUByte(),w.readUByte()<<8|w.readUByte()];break}}}if(w.readBool())w.readBool();if(w.readBool()){if(w.readBits(4),w.readBool())w.readBits(24)}if(w.readBool())w.readUEG(),w.readUEG();if(w.readBool()){var Y0=w.readBits(32),H=w.readBits(32);v=w.readBool(),_=H,t=Y0*2,P=_/t}}return{codec:kw(O.subarray(1,4)),profileIdc:G,profileCompatibility:J,levelIdc:Q,chromaFormat:Z,width:Math.ceil((L+1)*16-2*(E+S)),height:(2-I)*(z+1)*16-(I?2:4)*(x+C),sarRatio:R,fpsNum:_,fpsDen:t,fps:P,fixedFrame:v}}}]),Y}();var pw=function(){function Y(){f(this,Y)}return g(Y,null,[{key:"parseHEVCDecoderConfigurationRecord",value:function K(O){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(O.length<23)return;w=w||{};var G=(O[21]&3)+1,J,Q,Z=[],W=[],X=[],U=23,D=O[22],V,q,L;for(var z=0;z<D;z++){V=O[U]&63,q=O[U+1]<<8|O[U+2],U+=3;for(var I=0;I<q;I++){if(L=O[U]<<8|O[U+1],U+=2,!L)continue;switch(V){case 32:{var E=O.subarray(U,U+L);if(!J)J=Y.parseVPS(E0.removeEPB(E),w);X.push(E)}break;case 33:{var S=O.subarray(U,U+L);if(!Q)Q=Y.parseSPS(E0.removeEPB(S),w);Z.push(S)}break;case 34:W.push(O.subarray(U,U+L));break}U+=L}}return{hvcC:w,sps:Q,spsArr:Z,ppsArr:W,vpsArr:X,nalUnitSize:G}}},{key:"parseVPS",value:function K(O,w){w=w||{};var G=new OO(O);G.readUByte(),G.readUByte(),G.readBits(12);var J=G.readBits(3);return w.numTemporalLayers=Math.max(w.numTemporalLayers||0,J+1),G.readBits(17),Y._parseProfileTierLevel(G,J,w),w}},{key:"parseSPS",value:function K(O){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};w=w||{};var G=new OO(O);G.readUByte(),G.readUByte(),G.readBits(4);var J=G.readBits(3);w.numTemporalLayers=Math.max(J+1,w.numTemporalLayers||0),w.temporalIdNested=G.readBits(1),Y._parseProfileTierLevel(G,J,w),G.readUEG();var Q=w.chromaFormatIdc=G.readUEG(),Z=420;if(Q<=3)Z=[0,420,422,444][Q];var W=0;if(Q===3)W=G.readBits(1);var X=G.readUEG(),U=G.readUEG(),D=G.readBits(1),V,q,L,z;if(D===1)V=G.readUEG(),q=G.readUEG(),L=G.readUEG(),z=G.readUEG();if(w.bitDepthLumaMinus8=G.readUEG(),w.bitDepthChromaMinus8=G.readUEG(),D===1){var I=(Q===1||Q===2)&&W===0?2:1,E=Q===1&&W===0?2:1;X-=I*(q+V),U-=E*(z+L)}return{codec:"hev1.1.6.L93.B0",width:X,height:U,chromaFormat:Z,hvcC:w}}},{key:"_parseProfileTierLevel",value:function K(O,w,G){var J=G.generalTierFlag||0;G.generalProfileSpace=O.readBits(2),G.generalTierFlag=Math.max(O.readBits(1),J),G.generalProfileIdc=Math.max(O.readBits(5),G.generalProfileIdc||0),G.generalProfileCompatibilityFlags=O.readBits(32),G.generalConstraintIndicatorFlags=[O.readBits(8),O.readBits(8),O.readBits(8),O.readBits(8),O.readBits(8),O.readBits(8)];var Q=O.readBits(8);if(J<G.generalTierFlag)G.generalLevelIdc=Q;else G.generalLevelIdc=Math.max(Q,G.generalLevelIdc||0);var Z=[],W=[];if(w>O.bitsAvailable)throw new Error("maxSubLayersMinus inavlid size ".concat(w));for(var X=0;X<w;X++)Z[X]=O.readBits(1),W[X]=O.readBits(1);if(w>0)O.readBits((8-w)*2);for(var U=0;U<w;U++){if(Z[U]!==0)O.readBits(2),O.readBits(1),O.readBits(5),O.readBits(16),O.readBits(16),O.readBits(4),O.readBits(16),O.readBits(16),O.readBits(12);if(W[U]!==0)O.readBits(8)}}}]),Y}();var gO=function(){function Y(){f(this,Y)}return g(Y,null,[{key:"decode",value:function K(O){var w=[],G=O,J=0,Q=O.length;while(J<Q){if(G[J]<128){w.push(String.fromCharCode(G[J])),++J;continue}else if(G[J]<192);else if(G[J]<224){if(Y._checkContinuation(G,J,1)){var Z=(G[J]&31)<<6|G[J+1]&63;if(Z>=128){w.push(String.fromCharCode(Z&65535)),J+=2;continue}}}else if(G[J]<240){if(Y._checkContinuation(G,J,2)){var W=(G[J]&15)<<12|(G[J+1]&63)<<6|G[J+2]&63;if(W>=2048&&(W&63488)!==55296){w.push(String.fromCharCode(W&65535)),J+=3;continue}}}else if(G[J]<248){if(Y._checkContinuation(G,J,3)){var X=(G[J]&7)<<18|(G[J+1]&63)<<12|(G[J+2]&63)<<6|G[J+3]&63;if(X>65536&&X<1114112){X-=65536,w.push(String.fromCharCode(X>>>10|55296)),w.push(String.fromCharCode(X&1023|56320)),J+=4;continue}}}w.push(String.fromCharCode(65533)),++J}return w.join("")}},{key:"_checkContinuation",value:function K(O,w,G){var J=O;if(w+G<J.length){while(G--)if((J[++w]&192)!==128)return!1;return!0}else return!1}}]),Y}();var lw=function(){function Y(){f(this,Y)}return g(Y,null,[{key:"parse",value:function K(O){if(O.length<3)return;var w={},G=Y._parseValue(new DataView(O.buffer,O.byteOffset,O.byteLength)),J=Y._parseValue(new DataView(O.buffer,O.byteOffset+G.size,O.byteLength-G.size));return w[G.data]=J.data,w}},{key:"_parseValue",value:function K(O){var w=O.byteLength,G=O.getUint8(0),J=1,Q=!1,Z;switch(G){case 0:Z=O.getFloat64(1),J+=8;break;case 1:{Z=!!O.getUint8(1),J+=1;break}case 2:{var W=Y._parseString(new DataView(O.buffer,O.byteOffset+J,O.byteLength-J)),X=W.data,U=W.size;Z=X,J+=U}break;case 3:{Z={};var D=0;if((O.getUint32(w-4)&16777215)===9)D=3;while(J<w-4){var V=Y._parseObject(new DataView(O.buffer,O.byteOffset+J,O.byteLength-J-D)),q=V.size,L=V.data,z=V.isEnd;if(z)break;Z[L.name]=L.value,J+=q}if(J<=w-3){var I=O.getUint32(J-1)&16777215;if(I===9)J+=3}}break;case 8:{Z={},J+=4;var E=0;if((O.getUint32(w-4)&16777215)===9)E=3;while(J<w-8){var S=Y._parseObject(new DataView(O.buffer,O.byteOffset+J,O.byteLength-J-E)),x=S.size,C=S.data,R=S.isEnd;if(R)break;Z[C.name]=C.value,J+=x}if(J<=w-3){var v=O.getUint32(J-1)&16777215;if(v===9)J+=3}}break;case 9:Z=void 0,J=1,Q=!0;break;case 10:{Z=[];var _=O.getUint32(1);J+=4;for(var t=0;t<_;t++){var P=Y._parseValue(new DataView(O.buffer,O.byteOffset+J,O.byteLength-J)),l=P.data,Y0=P.size;Z.push(l),J+=Y0}}break;case 11:{var H=O.getFloat64(J)+O.getInt16(J+8)*60000;Z=new Date(H),J+=10}break;case 12:{var A=O.getUint32(1);if(J+=4,Z="",A>0)Z=gO.decode(new Uint8Array(O.buffer,O.byteOffset+J,A));J+=A}break;default:J=w;break}return{data:Z,size:J,isEnd:Q}}},{key:"_parseString",value:function K(O){var w=O.getUint16(0),G="";if(w>0)G=gO.decode(new Uint8Array(O.buffer,O.byteOffset+2,w));return{data:G,size:2+w}}},{key:"_parseObject",value:function K(O){if(O.byteLength<3)return;var w=Y._parseString(O),G=Y._parseValue(new DataView(O.buffer,O.byteOffset+w.size,O.byteLength-w.size));return{data:{name:w.data,value:G.data},size:w.size+G.size,isEnd:G.isEnd}}}]),Y}();var b0={MP3:2,G711A:7,G711M:8,AAC:10,OPUS:13};var I0=new g0("FlvDemuxer"),DO=function(){function Y(K,O,w){f(this,Y),b(this,"_headerParsed",!1),b(this,"_remainingData",null),b(this,"_gopId",0),b(this,"_needAddMetaBeforeKeyFrameNal",!0),this.videoTrack=K||new Ew,this.audioTrack=O||new Sw,this.metadataTrack=w||new yw,this._fixer=new xw(this.videoTrack,this.audioTrack,this.metadataTrack)}return g(Y,[{key:"demux",value:function K(O){var w,G=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,J=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,Q=arguments.length>3?arguments[3]:void 0,Z=this.audioTrack,W=this.videoTrack,X=this.metadataTrack;if(G||!J)this._remainingData=null;if(G)this._headerParsed=!1;if(G)W.reset(),Z.reset(),X.reset();else if(W.samples=[],Z.samples=[],X.seiSamples=[],X.flvScriptSamples=[],W.warnings=[],Z.warnings=[],this._remainingData)O=A0(this._remainingData,O),this._remainingData=null;if(!O.length)return{videoTrack:W,audioTrack:Z,metadataTrack:X};var U=0;if(!this._headerParsed){if(!Y.probe(O))throw new Error("Invalid flv file");Z.present=(O[4]&4)>>>2!==0,W.present=(O[4]&1)!==0,this._headerParsed=!0,U=l0(O,5)+4}var D=O.length,V,q,L,z,I;while(U+15<D){if(V=O[U],q=O[U+1]<<16|O[U+2]<<8|O[U+3],U+15+q>D)break;if(L=(O[U+7]<<24>>>0)+(O[U+4]<<16)+(O[U+5]<<8)+O[U+6],U+=11,z=O.subarray(U,U+q),V===8)this._parseAudio(z,L);else if(V===9){if(Q)this.seamlessLoadingSwitching=!0;this._parseVideo(z,L)}else if(V===18)this._parseScript(z,L);else I0.warn("Invalid tag type: ".concat(V));if(U+=q,I=l0(O,U),I!==11+q)I0.warn("Invalid PrevTagSize ".concat(I," (").concat(11+q,")"));U+=4}if(U<D)this._remainingData=O.subarray(U);if(Z.formatTimescale=W.formatTimescale=W.timescale=X.timescale=1000,Z.timescale=Z.codecType===s.OPUS?1000:Z.sampleRate||0,!Z.exist()&&Z.hasSample())Z.reset();if(!W.exist()&&W.hasSample())W.reset();var E=X.flvScriptSamples[X.flvScriptSamples.length-1],S=E===null||E===void 0?void 0:(w=E.data)===null||w===void 0?void 0:w.onMetaData;if(S){if(W!==null&&W!==void 0&&W.exist()){if(S.hasOwnProperty("duration"))W.duration=S.duration*1000;if(S.hasOwnProperty("width")&&S.hasOwnProperty("height"))W.width=S.width,W.height=S.height}if(Z!==null&&Z!==void 0&&Z.exist()){if(S.hasOwnProperty("duration"))Z.duration=S.duration*1000}}return{videoTrack:W,audioTrack:Z,metadataTrack:X}}},{key:"fix",value:function K(O,w,G){return this._fixer.fix(O,w,G),{videoTrack:this.videoTrack,audioTrack:this.audioTrack,metadataTrack:this.metadataTrack}}},{key:"demuxAndFix",value:function K(O,w,G,J,Q){return this.demux(O,w,G,Q),this.fix(J,w,G)}},{key:"_parseAudio",value:function K(O,w){if(!O.length)return;var G=(O[0]&240)>>>4,J=this.audioTrack;if(G!==b0.AAC&&G!==b0.G711A&&G!==b0.G711M&&G!==b0.OPUS){I0.warn("Unsupported sound format: ".concat(G)),J.reset();return}if(G!==b0.AAC&&G!==b0.OPUS){var Q=(O[0]&12)>>2,Z=(O[0]&2)>>1,W=O[0]&1;J.sampleRate=Y.AUDIO_RATE[Q],J.sampleSize=Z?16:8,J.channelCount=W+1}switch(G){case b0.G711A:case b0.G711M:this._parseG711(O,w,G);break;case b0.AAC:this._parseAac(O,w);break;case b0.OPUS:this._parseOpus(O,w);break}}},{key:"_parseOpus",value:function K(O,w){var G=this.audioTrack,J=O[1];switch(G.codecType=s.OPUS,J){case 0:{var Q=e0.parseHeaderPackets(O.subarray(2));if(Q)G.codec=Q.codec,G.channelCount=Q.channelCount,G.sampleRate=Q.sampleRate,G.config=Q.config,G.sampleDuration=e0.getFrameDuration([],G.timescale);else G.reset(),I0.warn("Cannot parse AudioSpecificConfig",O);break}case 1:{if(w===void 0||w===null)return;var Z=new m0(w,O.subarray(2),G.sampleDuration);G.samples.push(Z);break}default:I0.warn("Unknown OpusPacketType: ".concat(J))}}},{key:"_parseG711",value:function K(O,w,G){var J=this.audioTrack,Q=O.subarray(1);if(Q.byteLength<1)return;var Z=new m0(w,Q);J.codecType=G===7?s.G711PCMA:s.G711PCMU,J.sampleRate=8000,J.codec=J.codecType,J.samples.push(Z)}},{key:"_parseAac",value:function K(O,w){var G=this.audioTrack;if(G.codecType=s.AAC,O[1]===0){var J=p0.parseAudioSpecificConfig(O.subarray(2));if(J)G.codec=J.codec,G.channelCount=J.channelCount,G.sampleRate=J.sampleRate,G.config=J.config,G.objectType=J.objectType,G.sampleRateIndex=J.samplingFrequencyIndex;else G.reset(),I0.warn("Cannot parse AudioSpecificConfig",O)}else if(O[1]===1){if(w===void 0||w===null)return;G.samples.push(new m0(w,O.subarray(2)))}else I0.warn("Unknown AACPacketType: ".concat(O[1]))}},{key:"_parseVideo",value:function K(O,w){var G=this;if(O.length<6)return;var J=(O[0]&240)>>>4,Q=O[0]&15,Z=this.videoTrack;if(Q!==7&&Q!==12){Z.reset(),I0.warn("Unsupported codecId: ".concat(Q));return}var W=Q===12;Z.codecType=W?R0.HEVC:R0.AVC;var X=O[1],U=(O[2]<<16|O[3]<<8|O[4])<<8>>8;if(X===0){var D=O.subarray(5),V=W?pw.parseHEVCDecoderConfigurationRecord(D):mw.parseAVCDecoderConfigurationRecord(D);if(V){var{hvcC:q,sps:L,ppsArr:z,spsArr:I,vpsArr:E,nalUnitSize:S}=V;if(q)Z.hvcC=Z.hvcC||q;if(L)Z.codec=L.codec,Z.width=L.width,Z.height=L.height,Z.sarRatio=L.sarRatio,Z.fpsNum=L.fpsNum,Z.fpsDen=L.fpsDen;if(I.length)Z.sps=I;if(z.length)Z.pps=z;if(E&&E.length)Z.vps=E;if(S)Z.nalUnitSize=S}else I0.warn("Cannot parse ".concat(W?"HEVC":"AVC","DecoderConfigurationRecord"),O)}else if(X===1){var x=E0.parseAvcC(O.subarray(5),Z.nalUnitSize);if(x=this._checkAddMetaNalToUnits(W,x,Z),x&&x.length){var C=new $w(w+U,w,x);if(this.seamlessLoadingSwitching&&w<Z.lastKeyFrameDts)return;if(this.seamlessLoadingSwitching=!1,J===1)C.setToKeyframe(),Z.lastKeyFrameDts=w;if(Z.samples.push(C),x.forEach(function(R){var v=W?R[0]>>>1&63:R[0]&31;switch(v){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!W&&v!==5||W&&v===5)break;C.setToKeyframe();break;case 6:case 39:case 40:if(!W&&v!==6||W&&v===6)break;G.metadataTrack.seiSamples.push(new Mw(E0.parseSEI(E0.removeEPB(R),W),w+U));break}}),C.keyframe)this._gopId++;C.gopId=this._gopId}else I0.warn("Cannot parse NALUs",O)}else if(X===2);else I0.warn("Unknown AVCPacketType: ".concat(X))}},{key:"_checkAddMetaNalToUnits",value:function K(O,w,G){if(!O||!this._needAddMetaBeforeKeyFrameNal)return this._needAddMetaBeforeKeyFrameNal=!1,w;var J=w.map(function(Q){return Q[0]>>>1&63});if(J.includes(32))return this._needAddMetaBeforeKeyFrameNal=!1,w;return w.unshift(G.pps[0]),w.unshift(G.sps[0]),w.unshift(G.vps[0]),w.filter(Boolean)}},{key:"_parseScript",value:function K(O,w){this.metadataTrack.flvScriptSamples.push(new vw(lw.parse(O),w))}}],[{key:"probe",value:function K(O){if(O[0]!==70||O[1]!==76||O[2]!==86||O[3]!==1)return!1;return l0(O,5)>=9}}]),Y}();b(DO,"AUDIO_RATE",[5500,11000,22000,44000]);function u1(Y){var K=0;for(var O=arguments.length,w=new Array(O>1?O-1:0),G=1;G<O;G++)w[G-1]=arguments[G];w.forEach(function(Z){K+=Z.length});var J=new Y(K),Q=0;return w.forEach(function(Z){J.set(Z,Q),Q+=Z.length}),J}var J0=function(){function Y(){f(this,Y),this.buffer=new Uint8Array(0)}return g(Y,[{key:"write",value:function K(){var O=this;for(var w=arguments.length,G=new Array(w),J=0;J<w;J++)G[J]=arguments[J];G.forEach(function(Q){if(Q)O.buffer=u1(Uint8Array,O.buffer,Q);else window.console.warn(Q)})}}],[{key:"writeUint16",value:function K(O){return new Uint8Array([O>>8&255,O&255])}},{key:"writeUint32",value:function K(O){return new Uint8Array([O>>24,O>>16&255,O>>8&255,O&255])}}]),Y}();var nw=Math.pow(2,32)-1,h=function(){function Y(){f(this,Y)}return g(Y,null,[{key:"box",value:function K(O){for(var w=arguments.length,G=new Array(w>1?w-1:0),J=1;J<w;J++)G[J-1]=arguments[J];G=G.filter(Boolean);var Q=8+G.reduce(function(X,U){return X+U.byteLength},0),Z=new Uint8Array(Q);Z[0]=Q>>24&255,Z[1]=Q>>16&255,Z[2]=Q>>8&255,Z[3]=Q&255,Z.set(O,4);var W=8;return G.forEach(function(X){Z.set(X,W),W+=X.byteLength}),Z}},{key:"ftyp",value:function K(O){var w=O.find(function(G){return G.type===j0.VIDEO&&G.codecType===R0.HEVC});return w?Y.FTYPHEV1:Y.FTYPAVC1}},{key:"initSegment",value:function K(O){var w=Y.ftyp(O),G=A0(w,Y.moov(O));return G}},{key:"pssh",value:function K(O){var w=new Uint8Array([1,0,0,0].concat([16,119,239,236,192,178,77,2,172,227,60,30,82,226,251,75],[0,0,0,1],fO(O.kid),[0,0,0,0]));return Y.box(Y.types.pssh,w)}},{key:"moov",value:function K(O){if(O[0].useEME&&(O[0].encv||O[0].enca)){if(!O[0].pssh)O[0].pssh={kid:O[0].kid};var w=this.pssh(O[0].pssh);return Y.box.apply(Y,[Y.types.moov,Y.mvhd(O[0].mvhdDurtion||O[0].duration,O[0].mvhdTimecale||O[0].timescale),Y.mvex(O)].concat(L0(O.map(function(G){return Y.trak(G)})),[w]))}else return Y.box.apply(Y,[Y.types.moov,Y.mvhd(O[0].mvhdDurtion||O[0].duration,O[0].mvhdTimecale||O[0].timescale)].concat(L0(O.map(function(G){return Y.trak(G)})),[Y.mvex(O)]))}},{key:"mvhd",value:function K(O){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:90000,G=Y.box(Y.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,w>>24&255,w>>16&255,w>>8&255,w&255,O>>24&255,O>>16&255,O>>8&255,O&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]));return G}},{key:"trak",value:function K(O){var w=Y.box(Y.types.trak,Y.tkhd(O.id,O.tkhdDuration||0,O.width,O.height),Y.mdia(O));return w}},{key:"tkhd",value:function K(O,w){var G=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,J=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,Q=Y.box(Y.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,O>>24&255,O>>16&255,O>>8&255,O&255,0,0,0,0,w>>24&255,w>>16&255,w>>8&255,w&255,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,G>>8&255,G&255,0,0,J>>8&255,J&255,0,0]));return Q}},{key:"mdia",value:function K(O){var w=Y.box(Y.types.mdia,Y.mdhd(O.duration,O.timescale),Y.hdlr(O.type),Y.minf(O));return w}},{key:"mdhd",value:function K(O){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:90000,G=Y.box(Y.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,w>>24&255,w>>16&255,w>>8&255,w&255,O>>24&255,O>>16&255,O>>8&255,O&255,85,196,0,0]));return G}},{key:"hdlr",value:function K(O){var w=Y.box(Y.types.hdlr,Y.HDLR_TYPES[O]);return w}},{key:"minf",value:function K(O){var w=Y.box(Y.types.minf,O.type===j0.VIDEO?Y.VMHD:Y.SMHD,Y.DINF,Y.stbl(O));return w}},{key:"stbl",value:function K(O){var w=[];if(O&&O.ext)O.ext.stss&&w.push(Y.stss(O.ext.stss.entries));var G=Y.box(Y.types.stbl,Y.stsd(O),Y.STTS,w[0],Y.STSC,Y.STSZ,Y.STCO);return G}},{key:"stsd",value:function K(O){var w;if(O.type==="audio")if(O.useEME&&O.enca)w=Y.enca(O);else if(O.codecType===s.OPUS)w=Y.opus(O);else w=Y.mp4a(O);else if(O.useEME&&O.encv)w=Y.encv(O);else if(O.av1C)w=Y.av01(O);else w=Y.avc1hev1(O);var G=Y.box(Y.types.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),w);return G}},{key:"enca",value:function K(O){var w=O.enca.channelCount,G=O.enca.sampleRate,J=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,w,0,16,0,0,0,0,G>>8&255,G&255,0,0]),Q=Y.esds(O.config),Z=Y.sinf(O.enca);return Y.box(Y.types.enca,J,Q,Z)}},{key:"encv",value:function K(O){var w,G,J=O.sps.length>0?O.sps[0]:[],Q=O.pps.length>0?O.pps[0]:[],Z=O.width,W=O.height,X=O.sarRatio[0],U=O.sarRatio[1],D=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,Z>>8&255,Z&255,W>>8&255,W&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),V=new Uint8Array((w=(G=[1,J[1],J[2],J[3],255,225,J.length>>>8&255,J.length&255]).concat.apply(G,L0(J)).concat([1,Q.length>>>8&255,Q.length&255])).concat.apply(w,L0(Q))),q=new Uint8Array([0,0,88,57,0,15,200,192,0,4,86,72]),L=Y.sinf(O.encv),z=new Uint8Array([X>>24,X>>16&255,X>>8&255,X&255,U>>24,U>>16&255,U>>8&255,U&255]);return Y.box(Y.types.encv,D,Y.box(Y.types.avcC,V),Y.box(Y.types.btrt,q),L,Y.box(Y.types.pasp,z))}},{key:"schi",value:function K(O){var w=new Uint8Array([]),G=Y.tenc(O);return Y.box(Y.types.schi,w,G)}},{key:"tenc",value:function K(O){var w=new Uint8Array([0,0,0,0,0,0,O.default_IsEncrypted&255,O.default_IV_size&255].concat(fO(O.default_KID)));return Y.box(Y.types.tenc,w)}},{key:"sinf",value:function K(O){var w=new Uint8Array([]),G=new Uint8Array([O.data_format.charCodeAt(0),O.data_format.charCodeAt(1),O.data_format.charCodeAt(2),O.data_format.charCodeAt(3)]),J=new Uint8Array([0,0,0,0,99,101,110,99,0,1,0,0]),Q=Y.schi(O);return Y.box(Y.types.sinf,w,Y.box(Y.types.frma,G),Y.box(Y.types.schm,J),Q)}},{key:"av01",value:function K(O){return Y.box(Y.types.av01,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,O.width>>8&255,O.width&255,O.height>>8&255,O.height&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),O.av1C,O.colr)}},{key:"avc1hev1",value:function K(O){var w=O.codecType===R0.HEVC,G=w?Y.types.hvc1:Y.types.avc1,J=w?Y.hvcC(O):Y.avcC(O),Q=[new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,O.width>>8&255,O.width&255,O.height>>8&255,O.height&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),J];if(w)Q.push(Y.box(Y.types.fiel,new Uint8Array([1,0])));else if(O.sarRatio&&O.sarRatio.length>1)Q.push(Y.pasp(O.sarRatio));return Y.box.apply(Y,[G].concat(Q))}},{key:"avcC",value:function K(O){var w,G,J=[],Q=[],Z;return O.sps.forEach(function(W){Z=W.byteLength,J.push(Z>>>8&255),J.push(Z&255),J.push.apply(J,L0(W))}),O.pps.forEach(function(W){Z=W.byteLength,Q.push(Z>>>8&255),Q.push(Z&255),Q.push.apply(Q,L0(W))}),Y.box(Y.types.avcC,new Uint8Array((w=(G=[1,J[3],J[4],J[5],255,224|O.sps.length]).concat.apply(G,J).concat([O.pps.length])).concat.apply(w,Q)))}},{key:"hvcC",value:function K(O){var w=O.hvcC;if(w instanceof ArrayBuffer||w instanceof Uint8Array)return w;var{vps:G,sps:J,pps:Q}=O,Z;if(w){var{generalProfileCompatibilityFlags:W,generalConstraintIndicatorFlags:X}=w,U=(G.length&&1)+(J.length&&1)+(Q.length&&1);Z=[1,w.generalProfileSpace<<6|w.generalTierFlag<<5|w.generalProfileIdc,W>>>24,W>>>16,W>>>8,W,X[0],X[1],X[2],X[3],X[4],X[5],w.generalLevelIdc,240,0,252,w.chromaFormatIdc|252,w.bitDepthLumaMinus8|248,w.bitDepthChromaMinus8|248,0,0,w.numTemporalLayers<<3|w.temporalIdNested<<2|3,U];var D=function V(q){var L;Z.push(q.length>>8,q.length),(L=Z).push.apply(L,L0(q))};if(G.length)Z.push(160,0,G.length),G.forEach(D);if(J.length)Z.push(161,0,J.length),J.forEach(D);if(Q.length)Z.push(162,0,Q.length),Q.forEach(D)}else Z=[1,1,96,0,0,0,144,0,0,0,0,0,93,240,0,252,253,248,248,0,0,15,3,160,0,1,0,24,64,1,12,1,255,255,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,153,152,9,161,0,1,0,45,66,1,1,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,160,2,128,128,45,22,89,153,164,147,43,154,128,128,128,130,0,0,3,0,2,0,0,3,0,50,16,162,0,1,0,7,68,1,193,114,180,98,64];return Y.box(Y.types.hvcC,new Uint8Array(Z))}},{key:"pasp",value:function K(O){var w=zw(O,2),G=w[0],J=w[1];return Y.box(Y.types.pasp,new Uint8Array([G>>24,G>>16&255,G>>8&255,G&255,J>>24,J>>16&255,J>>8&255,J&255]))}},{key:"mp4a",value:function K(O){return Y.box(Y.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,O.channelCount,0,16,0,0,0,0,O.sampleRate>>8&255,O.sampleRate&255,0,0]),O.config.length?Y.esds(O.config):void 0)}},{key:"esds",value:function K(O){var w=O.length,G=Y.box(Y.types.esds,new Uint8Array([0,0,0,0,3,23+w,0,0,0,4,15+w,64,21,0,6,0,0,0,218,192,0,0,218,192,5].concat([w]).concat(O).concat([6,1,2])));return G}},{key:"opus",value:function K(O){var w=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,O.channelCount,0,16,0,0,0,0,O.sampleRate>>8&255,O.sampleRate&255,0,0]),G=O.config.length?Y.dOps(O):[];return Y.box(Y.types.Opus,w,G)}},{key:"dOps",value:function K(O){if(O.config)return O.config[4]=O.sampleRate>>>24&255,O.config[5]=O.sampleRate>>>16&255,O.config[6]=O.sampleRate>>>8&255,O.config[7]=O.sampleRate&255,Y.box(Y.types.dOps,O.config)}},{key:"mvex",value:function K(O){var w=Y.box.apply(Y,[Y.types.mvex].concat(L0(O.map(function(G){return Y.trex(G.id)}))));return w}},{key:"trex",value:function K(O){var w=Y.box(Y.types.trex,new Uint8Array([0,0,0,0,O>>24,O>>16&255,O>>8&255,O&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]));return w}},{key:"trex1",value:function K(O){var w=Y.box(Y.types.trex,new Uint8Array([0,0,0,0,O>>24,O>>16&255,O>>8&255,O&255,0,0,0,1,0,0,2,0,0,0,0,0,0,1,0,0]));return w}},{key:"trex2",value:function K(O){var w=Y.box(Y.types.trex,new Uint8Array([0,0,0,0,O>>24,O>>16&255,O>>8&255,O&255,0,0,0,1,0,0,4,0,0,0,0,0,2,0,0,0]));return w}},{key:"moof",value:function K(O){var w=Y.box.apply(Y,[Y.types.moof,Y.mfhd(O[0].samples?O[0].samples[0].gopId:0)].concat(L0(O.map(function(G){return Y.traf(G)}))));return w}},{key:"mfhd",value:function K(O){var w=Y.box(Y.types.mfhd,new Uint8Array([0,0,0,0,O>>24,O>>16&255,O>>8&255,O&255]));return w}},{key:"traf",value:function K(O){var w=Y.tfhd(O.id),G=Y.tfdt(O,O.baseMediaDecodeTime),J=0,Q;if(O.isVideo&&O.videoSenc)Q=O.videoSenc,Q.forEach(function(A){if(J=J+8,A.subsamples&&A.subsamples.length)J=J+2,J=J+A.subsamples.length*6});if(O.videoSencLength=J,!O.useEME||!O.isVideoEncryption&&!O.isAudioEncryption){var Z=Y.sdtp(O),W=76;return Y.box(Y.types.traf,w,G,Z,Y.trun(O.samples,Z.byteLength+W))}else if(O.isVideoEncryption)if(O.isVideo){var X=Y.saiz(O),U=Y.saio(O),D=Y.trun1(O),V=Y.senc(O),q=Y.box(Y.types.traf,w,G,X,U,D,V);return q}else if(!O.isAudioEncryption){var L=Y.sbgp(),z=Y.trun1(O);return Y.box(Y.types.traf,w,G,L,z)}else{var I=Y.sbgp(),E=Y.saiz(O),S=Y.saio(O),x=Y.senc(O),C=Y.trun1(O),R=Y.box(Y.types.traf,w,G,I,E,S,x,C);return R}else if(O.isVideo){var v=Y.trun1(O);return Y.box(Y.types.traf,w,G,v)}else{var _=Y.sbgp(),t=Y.saiz(O),P=Y.saio(O),l=Y.senc(O),Y0=Y.trun1(O),H=Y.box(Y.types.traf,w,G,_,t,P,l,Y0);return H}}},{key:"sdtp",value:function K(O){var w=new J0;return O.samples.forEach(function(G){w.write(new Uint8Array(O.isVideo?[G.keyframe?32:16]:[16]))}),Y.box(Y.types.sdtp,this.extension(0,0),w.buffer)}},{key:"trun1",value:function K(O){var w=new J0,G=J0.writeUint32(O.samples.length),J=null;if(O.isVideo){var Q=O.videoSencLength;if(J=J0.writeUint32(O.samples.length*16+Q+149),!O.isVideoEncryption&&O.isAudioEncryption)J=J0.writeUint32(O.samples.length*16+92)}else{var Z=O.samples.length*12+124;if(O.isAudioEncryption)Z=O.samples.length*12+8*O.audioSenc.length+177;J=J0.writeUint32(Z)}return O.samples.forEach(function(W){if(w.write(J0.writeUint32(W.duration)),w.write(J0.writeUint32(W.size)),w.write(J0.writeUint32(W.keyframe?33554432:65536)),O.isVideo)w.write(J0.writeUint32(W.cts?W.cts:0))}),Y.box(Y.types.trun,this.extension(0,O.flags),G,J,w.buffer)}},{key:"senc",value:function K(O){var w=new J0,G=O.samples.length,J=O.isVideo?16:8,Q=O.isVideo?2:0,Z=[],W=0;if(O.isVideo)Z=O.videoSenc,W=O.videoSencLength;else Z=O.audioSenc;return W=W||J*G,w.write(J0.writeUint32(16+W),Y.types.senc,this.extension(0,Q)),w.write(J0.writeUint32(G)),Z.forEach(function(X){for(var U=0;U<X.InitializationVector.length;U++)w.write(new Uint8Array([X.InitializationVector[U]]));if(X.subsamples&&X.subsamples.length)w.write(J0.writeUint16(X.subsamples.length)),X.subsamples.forEach(function(D){w.write(J0.writeUint16(D.BytesOfClearData)),w.write(J0.writeUint32(D.BytesOfProtectedData))})}),w.buffer}},{key:"saio",value:function K(O){var w=O.samples.length*12+141;if(!O.isVideo&&O.isAudioEncryption)w=149;var G=new Uint8Array([1,0,0,0,0,0,0,1,0,0,0,0,w>>24&255,w>>16&255,w>>8&255,w&255]);return Y.box(Y.types.saio,G)}},{key:"saiz",value:function K(O){var w=O.samples.length,G=new Uint8Array([0,0,0,0,16,w>>24&255,w>>16&255,w>>8&255,w&255]);return Y.box(Y.types.saiz,G)}},{key:"sbgp",value:function K(){var O=new Uint8Array([114,111,108,108,0,0,0,1,0,0,1,25,0,0,0,1]);return Y.box(Y.types.sbgp,this.extension(0,0),O)}},{key:"extension",value:function K(O,w){return new Uint8Array([O,w>>16&255,w>>8&255,w&255])}},{key:"tfhd",value:function K(O){return Y.box(Y.types.tfhd,new Uint8Array([0,0,0,0,O>>24,O>>16&255,O>>8&255,O&255]))}},{key:"tfdt",value:function K(O,w){var G=Math.floor(w/(nw+1)),J=Math.floor(w%(nw+1));if(O.useEME&&(O.isVideoEncryption||O.isAudioEncryption))return Y.box(Y.types.tfdt,new Uint8Array([0,0,0,0,J>>24,J>>16&255,J>>8&255,J&255]));else return Y.box(Y.types.tfdt,new Uint8Array([1,0,0,0,G>>24,G>>16&255,G>>8&255,G&255,J>>24,J>>16&255,J>>8&255,J&255]))}},{key:"trun",value:function K(O,w){var G=O.length,J=12+16*G;w+=8+J;var Q=new Uint8Array(J);Q.set([0,0,15,1,G>>>24&255,G>>>16&255,G>>>8&255,G&255,w>>>24&255,w>>>16&255,w>>>8&255,w&255],0);for(var Z=0;Z<G;Z++){var W=O[Z],X=W.duration,U=W.size,D=W.flag,V=D===void 0?{}:D,q=W.cts,L=q===void 0?0:q;Q.set([X>>>24&255,X>>>16&255,X>>>8&255,X&255,U>>>24&255,U>>>16&255,U>>>8&255,U&255,V.isLeading<<2|(V.dependsOn===null||V.dependsOn===void 0?1:V.dependsOn),V.isDependedOn<<6|V.hasRedundancy<<4|V.paddingValue<<1|(V.isNonSyncSample===null||V.isNonSyncSample===void 0?1:V.isNonSyncSample),V.degradationPriority&61440,V.degradationPriority&15,L>>>24&255,L>>>16&255,L>>>8&255,L&255],12+16*Z)}return Y.box(Y.types.trun,Q)}},{key:"moovMP4",value:function K(O){return Y.box.apply(Y,[Y.types.moov,Y.mvhd(O[0].duration,O[0].timescale)].concat(L0(O.map(function(w){return Y.trackMP4(w)}))))}},{key:"trackMP4",value:function K(O){return Y.box(Y.types.trak,Y.tkhd(O.id,O.duration,O.width,O.height),Y.mdiaMP4(O))}},{key:"mdiaMP4",value:function K(O){return Y.box(Y.types.mdia,Y.mdhd(O.duration,O.timescale),Y.hdlr(O.type),Y.minfMP4(O))}},{key:"minfMP4",value:function K(O){return Y.box(Y.types.minf,O.type===j0.VIDEO?Y.VMHD:Y.SMHD,Y.DINF,Y.stblMP4(O))}},{key:"stblMP4",value:function K(O){var w=O.ext,G=[Y.stsd(O),Y.stts(w.stts),Y.stsc(w.stsc),Y.stsz(w.stsz),Y.stco(w.stco)];if(w.stss.length)G.push(Y.stss(w.stss));if(w.ctts.length)G.push(Y.ctts(w.ctts));return Y.box.apply(Y,[Y.types.stbl].concat(G))}},{key:"stts",value:function K(O){var w=O.length,G=new Uint8Array(8*w),J=0;return O.forEach(function(Q){var{value:Z,count:W}=Q;G.set([W>>24,W>>16&255,W>>8&255,W&255,Z>>24,Z>>16&255,Z>>8&255,Z&255],J),J+=8}),Y.box(Y.types.stts,A0(new Uint8Array([0,0,0,0,w>>24,w>>16&255,w>>8&255,w&255]),G))}},{key:"stsc",value:function K(O){var w=O.length,G=new Uint8Array(12*w),J=0;return O.forEach(function(Q){var{firstChunk:Z,samplesPerChunk:W,sampleDescIndex:X}=Q;G.set([Z>>24,Z>>16&255,Z>>8&255,Z&255,W>>24,W>>16&255,W>>8&255,W&255,X>>24,X>>16&255,X>>8&255,X&255],J),J+=12}),Y.box(Y.types.stsc,A0(new Uint8Array([0,0,0,0,w>>24,w>>16&255,w>>8&255,w&255]),G))}},{key:"stsz",value:function K(O){var w=O.length,G=new Uint8Array(4*w),J=0;return O.forEach(function(Q){G.set([Q>>24,Q>>16&255,Q>>8&255,Q&255],J),J+=4}),Y.box(Y.types.stsz,A0(new Uint8Array([0,0,0,0,0,0,0,0,w>>24,w>>16&255,w>>8&255,w&255]),G))}},{key:"stco",value:function K(O){var w=O.length,G=new Uint8Array(4*w),J=0;return O.forEach(function(Q){G.set([Q>>24,Q>>16&255,Q>>8&255,Q&255],J),J+=4}),Y.box(Y.types.stco,A0(new Uint8Array([0,0,0,0,w>>24,w>>16&255,w>>8&255,w&255]),G))}},{key:"stss",value:function K(O){var w=O.length,G=new Uint8Array(4*w),J=0;return O.forEach(function(Q){G.set([Q>>24,Q>>16&255,Q>>8&255,Q&255],J),J+=4}),Y.box(Y.types.stss,A0(new Uint8Array([0,0,0,0,w>>24,w>>16&255,w>>8&255,w&255]),G))}},{key:"ctts",value:function K(O){var w=O.length,G=new Uint8Array(8*w),J=0;return O.forEach(function(Q){var{value:Z,count:W}=Q;G.set([W>>24,W>>16&255,W>>8&255,W&255,Z>>24,Z>>16&255,Z>>8&255,Z&255],J),J+=8}),Y.box(Y.types.ctts,A0(new Uint8Array([0,0,0,0,w>>24,w>>16&255,w>>8&255,w&255]),G))}},{key:"styp",value:function K(){return Y.box(Y.types.styp,new Uint8Array([109,115,100,104,0,0,0,0,109,115,100,104,109,115,105,120]))}},{key:"sidx",value:function K(O){var w=O.timescale,G=O.samples[0].duration,J=G*O.samples.length,Q=O.samples[0].sampleOffset*G,Z=8;O.samples.forEach(function(V){Z+=V.size});var W=0;if(O.isVideo){var X=0,U;if(O.videoSenc)U=O.videoSenc;if(O.isVideo)U.forEach(function(V){if(X=X+8,V.subsamples&&V.subsamples.length)X=X+2,X=X+V.subsamples.length*6});if(O.videoSencLength=X,W=Z+141+O.samples.length*16+X,O.useEME&&O.isAudioEncryption&&!O.isVideoEncryption)W=Z+O.samples.length*16+84}else if(W=Z+116+O.samples.length*12,O.useEME&&O.isAudioEncryption)W=Z+169+O.samples.length*12+8*O.audioSenc.length;var D=new Uint8Array([0,0,0,0,0,0,0,O.id&255,w>>24&255,w>>16&255,w>>8&255,w&255,Q>>24&255,Q>>16&255,Q>>8&255,Q&255,0,0,0,0,0,0,0,1,0,W>>16&255,W>>8&255,W&255,J>>24&255,J>>16&255,J>>8&255,J&255,144,0,0,0]);return Y.box(Y.types.sidx,D)}},{key:"mdat",value:function K(O){var w=Y.box(Y.types.mdat,O);return w}}]),Y}();b(h,"types",["Opus","dOps","av01","av1C","avc1","avcC","hvc1","hvcC","dinf","dref","esds","ftyp","hdlr","mdat","mdhd","mdia","mfhd","minf","moof","moov","mp4a","mvex","mvhd","pasp","stbl","stco","stsc","stsd","stsz","stts","tfdt","tfhd","traf","trak","trex","tkhd","vmhd","smhd","ctts","stss","styp","pssh","sidx","sbgp","saiz","saio","senc","trun","encv","enca","sinf","btrt","frma","tenc","schm","schi","mehd","fiel","sdtp"].reduce(function(Y,K){return Y[K]=[K.charCodeAt(0),K.charCodeAt(1),K.charCodeAt(2),K.charCodeAt(3)],Y},Object.create(null)));b(h,"HDLR_TYPES",{video:new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),audio:new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0])});b(h,"FTYPAVC1",h.box(h.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49])));b(h,"FTYPHEV1",h.box(h.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49])));b(h,"DINF",h.box(h.types.dinf,h.box(h.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]))));b(h,"VMHD",h.box(h.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])));b(h,"SMHD",h.box(h.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0])));b(h,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0]));b(h,"STTS",h.box(h.types.stts,h.StblTable));b(h,"STSC",h.box(h.types.stsc,h.StblTable));b(h,"STSZ",h.box(h.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0])));b(h,"STCO",h.box(h.types.stco,h.StblTable));var hO=function(){function Y(K,O){f(this,Y),this.name=K||"",this._prefix="[".concat(this.name,"]"),Y.disabled=O}return g(Y,[{key:"debug",value:function K(){var O;if(Y.disabled)return;for(var w=arguments.length,G=new Array(w),J=0;J<w;J++)G[J]=arguments[J];(O=console).debug.apply(O,[this._prefix].concat(G))}},{key:"log",value:function K(){var O;if(Y.disabled)return;for(var w=arguments.length,G=new Array(w),J=0;J<w;J++)G[J]=arguments[J];(O=console).log.apply(O,[this._prefix].concat(G))}},{key:"warn",value:function K(){var O;if(Y.disabled)return;for(var w=arguments.length,G=new Array(w),J=0;J<w;J++)G[J]=arguments[J];(O=console).warn.apply(O,[this._prefix].concat(G))}},{key:"error",value:function K(){var O;if(Y.disabled)return;for(var w=arguments.length,G=new Array(w),J=0;J<w;J++)G[J]=arguments[J];(O=console).error.apply(O,[this._prefix].concat(G))}},{key:"table",value:function K(){var O;if(Y.disabled)return;console.group(this._prefix),(O=console).table.apply(O,arguments),console.groupEnd()}}],[{key:"enable",value:function K(){Y.disabled=!1}},{key:"disable",value:function K(){Y.disabled=!0}}]),Y}();b(hO,"disabled",!0);var xO=function(){function Y(K,O,w){f(this,Y),this.videoTrack=K,this.audioTrack=O;var G=/Chrome\/([^.]+)/.exec(navigator.userAgent);this.forceFirstIDR=G&&Number(G[1])<50,this.log=new hO("FMP4Remuxer",w&&w.openLog?!w.openLog:!0)}return g(Y,[{key:"remux",value:function K(){var O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},G=this.videoTrack,J=this.audioTrack,Q=G.exist(),Z=J.exist(),W,X,U,D=[];if(O)if(w&&w.initMerge){if(Q)D.push(this.videoTrack);if(Z)D.push(this.audioTrack);U=h.initSegment(D)}else{if(Q)W=h.initSegment([this.videoTrack]);if(Z)X=h.initSegment([this.audioTrack])}var V,q;if(Q&&G.hasSample())V=this._remuxVideo();if(Z&&J.hasSample())q=this._remuxAudio();return G.samples=[],J.samples=[],{initSegment:U,videoInitSegment:W,audioInitSegment:X,videoSegment:V,audioSegment:q}}},{key:"_remuxVideo",value:function K(){var O=this.videoTrack;if(this.forceFirstIDR)O.samples[0].flag={dependsOn:2,isNonSyncSample:0};var w=O.samples,G=/av01/.test(O.codec),J=0;if(G)w.forEach(function(x){J+=x.data.byteLength});else w.forEach(function(x){J+=x.units.reduce(function(C,R){return C+R.byteLength},0),J+=x.units.length*4});var Q=new Uint8Array(J);if(G)for(var Z=0,W=w.length,X=0,U;Z<W;Z++)U=w[Z],Q.set(U.data,X),U.size=U.data.byteLength,X+=U.size;else{var D=new DataView(Q.buffer),V=function x(C,R){R=w[q];var v=0;R.units.forEach(function(_){D.setUint32(C,_.byteLength),C+=4,Q.set(_,C),C+=_.byteLength,v+=4+_.byteLength}),R.size=v,z=C,I=R};for(var q=0,L=w.length,z=0,I;q<L;q++)V(z,I)}var E=h.mdat(Q),S=h.moof([O]);return A0(S,E)}},{key:"_remuxAudio",value:function K(){var O=this.audioTrack,w=new Uint8Array(O.samples.reduce(function(Q,Z){return Q+Z.size},0));O.samples.reduce(function(Q,Z){return w.set(Z.data,Q),Q+Z.size},0);var G=h.mdat(w),J=h.moof([O]);return A0(J,G)}},{key:"reset",value:function K(){this.videoTrack.reset(),this.audioTrack.reset()}}]),Y}();var ow=function(){function Y(){h0(this,Y),y(this,"_ttfb",0),y(this,"_demuxStart",0),y(this,"_demuxEnd",0),y(this,"_demuxCost",0),y(this,"_remuxStart",0),y(this,"_remuxEnd",0),y(this,"_remuxCost",0),y(this,"_appendStart",0),y(this,"_appendEnd",0),y(this,"_appendCost",0)}return x0(Y,[{key:"set",value:function K(O,w){this["_".concat(O)]=w}},{key:"start",value:function K(O){this["_".concat(O,"Start")]=Date.now()}},{key:"end",value:function K(O){this["_".concat(O,"End")]=Date.now(),this["_".concat(O,"Cost")]=this["_".concat(O,"Cost")]+(this["_".concat(O,"End")]-this["_".concat(O,"Start")])}},{key:"transferCost",get:function K(){return{ttfbCost:this._ttfb,demuxCost:this._demuxCost,remuxCost:this._remuxCost,appendCost:this._appendCost}}}]),Y}(),S0={TTFB:"ttfb",DEMUX:"demux",REMUX:"remux",APPEND:"append"};var $0=new D0("BufferService"),dw=function(){function Y(K,O){var w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(h0(this,Y),y(this,"flv",null),y(this,"_demuxer",new DO),y(this,"_remuxer",null),y(this,"_mse",null),y(this,"_softVideo",null),y(this,"_sourceCreated",!1),y(this,"_needInitSegment",!0),y(this,"_discontinuity",!0),y(this,"_contiguous",!1),y(this,"_initSegmentId",""),y(this,"_cachedBuffer",null),y(this,"_demuxStartTime",0),y(this,"_opts",null),this.flv=K,this._opts=w,O)this._softVideo=O;else this._remuxer=new xO(this._demuxer.videoTrack,this._demuxer.audioTrack),this._mse=new P0(null,{preferMMS:typeof w.preferMMS==="boolean"?w.preferMMS:!!w.perferMMS}),this._mse.bindMedia(K.media)}return x0(Y,[{key:"baseDts",get:function K(){var O,w;return(O=this._demuxer)===null||O===void 0?void 0:(w=O._fixer)===null||w===void 0?void 0:w._baseDts}},{key:"blobUrl",get:function K(){var O;return(O=this._mse)===null||O===void 0?void 0:O.url}},{key:"isFull",value:function K(){var O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:P0.VIDEO;return this._mse.isFull(O)}},{key:"seamlessSwitch",value:function K(){this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!0,this._initSegmentId=""}},{key:"unContiguous",value:function K(O){this._contiguous=!1,this._demuxStartTime=O}},{key:"reset",value:function(){var K=O0(k().mark(function w(){var G,J=arguments;return k().wrap(function Q(Z){while(!0)switch(Z.prev=Z.next){case 0:if(G=J.length>0&&J[0]!==void 0?J[0]:!1,!(this._mse&&!G)){Z.next=6;break}return Z.next=4,this._mse.unbindMedia();case 4:return Z.next=6,this._mse.bindMedia(this.flv.media);case 6:this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!1,this._sourceCreated=!1,this._initSegmentId="",this.resetSeamlessSwitchStats();case 12:case"end":return Z.stop()}},w,this)}));function O(){return K.apply(this,arguments)}return O}()},{key:"resetSeamlessSwitchStats",value:function K(){if(this.seamlessLoadingSwitch=null,this.seamlessLoadingSwitching=!1,this._demuxer)this._demuxer.seamlessLoadingSwitching=!1}},{key:"endOfStream",value:function(){var K=O0(k().mark(function w(){return k().wrap(function G(J){while(!0)switch(J.prev=J.next){case 0:if(!this._mse){J.next=7;break}if(!this._sourceCreated){J.next=5;break}return J.next=4,this._mse.endOfStream();case 4:this.flv.emit(u.BUFFEREOS);case 5:J.next=8;break;case 7:if(this._softVideo)this._softVideo.endOfStream();case 8:case"end":return J.stop()}},w,this)}));function O(){return K.apply(this,arguments)}return O}()},{key:"updateDuration",value:function(){var K=O0(k().mark(function w(G){return k().wrap(function J(Q){while(!0)switch(Q.prev=Q.next){case 0:if(!this._mse){Q.next=7;break}if(this._mse.isOpened){Q.next=4;break}return Q.next=4,this._mse.open();case 4:return $0.debug("update duration",G),Q.next=7,this._mse.updateDuration(G);case 7:case"end":return Q.stop()}},w,this)}));function O(w){return K.apply(this,arguments)}return O}()},{key:"destroy",value:function(){var K=O0(k().mark(function w(){return k().wrap(function G(J){while(!0)switch(J.prev=J.next){case 0:if(!this._mse){J.next=3;break}return J.next=3,this._mse.unbindMedia();case 3:this._mse=null,this._softVideo=null,this._demuxer=null,this._remuxer=null;case 7:case"end":return J.stop()}},w,this)}));function O(){return K.apply(this,arguments)}return O}()},{key:"appendBuffer",value:function(){var K=O0(k().mark(function w(G){var J=this,Q,Z,W,X,U,D,V,q,L,z,I,E,S,x,C,R,v,_;return k().wrap(function t(P){while(!0)switch(P.prev=P.next){case 0:if(Q=!1,this._cachedBuffer)G=IO(this._cachedBuffer,G),this._cachedBuffer=null;if(Z=this._demuxer,!(!G||!G.length||!Z)){P.next=5;break}return P.abrupt("return");case 5:P.prev=5,this.flv._transferCost.start(S0.DEMUX),Z.demuxAndFix(G,this.seamlessLoadingSwitching||this._discontinuity,this._contiguous,this._demuxStartTime,this.seamlessLoadingSwitching),this.seamlessLoadingSwitching=!1,this.flv._transferCost.end(S0.DEMUX),P.next=15;break;case 12:throw P.prev=12,P.t0=P.catch(5),new Q0(m.DEMUX,m.SUB_TYPES.FLV,P.t0);case 15:if(W=Z.videoTrack,X=Z.audioTrack,U=Z.metadataTrack,!this.seamlessLoadingSwitch){P.next=25;break}if(D=W.samples.findIndex(function(l){return l.originDts===W.lastKeyFrameDts}),!(D>=0)){P.next=25;break}return W.samples.splice(D),P.next=22,this.seamlessLoadingSwitch();case 22:this.seamlessLoadingSwitch=null,G=null,Q=!0;case 25:if(V=W.exist(),q=X.exist(),this._opts.onlyAudio)V=!1,W.present=!1;if(this._opts.onlyVideo)q=!1,X.present=!1;if(!(!V&&W.present||!q&&X.present)){P.next=42;break}if(L=0,z=V?W:q?X:void 0,z&&z.samples.length)L=(z.samples[z.samples.length-1].originPts-z.samples[0].originPts)/z.timescale*1000;if(!(L>this._opts.analyzeDuration)){P.next=40;break}$0.warn("analyze duration exceeded, ".concat(L,"ms"),z),W.present=V,X.present=q,this.flv.emit(u.ANALYZE_DURATION_EXCEEDED,{duration:L}),P.next=42;break;case 40:return this._cachedBuffer=G,P.abrupt("return");case 42:if(I=W.type,E=X.type,this._fireEvents(W,X,U),!Q)this._discontinuity=!1,this._contiguous=!0,this._demuxStartTime=0;if(S=this._mse,x=function l(){var Y0;if((Y0=J.flv)!==null&&Y0!==void 0&&Y0.emit){var H;(H=J.flv)===null||H===void 0||H.emit(u.APPEND_BUFFER,{})}},this.flv.emit(u.DEMUXED_TRACK,{videoTrack:W}),C="".concat(W.codec,"/").concat(W.width,"/").concat(W.height,"/").concat(X.codec,"/").concat(X.config),C!==this._initSegmentId)this._needInitSegment=!0,this._initSegmentId=C,this._emitMetaParsedEvent(W,X);if(!S){P.next=83;break}if(this._sourceCreated){P.next=59;break}return P.next=55,S.open();case 55:if(V)$0.log("codec: video/mp4;codecs=".concat(W.codec)),S.createSource(I,"video/mp4;codecs=".concat(W.codec));if(q)$0.log("codec: audio/mp4;codecs=".concat(X.codec)),S.createSource(E,"audio/mp4;codecs=".concat(X.codec));this._sourceCreated=!0,this.flv.emit(u.SOURCEBUFFER_CREATED);case 59:if(P.prev=59,this._needInitSegment&&!this._opts.mseLowLatency)W.duration=this._opts.durationForMSELowLatencyOff*W.timescale,X.duration=this._opts.durationForMSELowLatencyOff*q.timescale;this.flv._transferCost.start(S0.REMUX),R=this._remuxer.remux(this._needInitSegment),this.flv._transferCost.end(S0.REMUX),P.next=69;break;case 66:throw P.prev=66,P.t1=P.catch(59),new Q0(m.REMUX,m.SUB_TYPES.FMP4,P.t1);case 69:if(!(this._needInitSegment&&!R.videoInitSegment&&!R.audioInitSegment)){P.next=71;break}return P.abrupt("return");case 71:if(this._needInitSegment=!1,v=[],R.videoInitSegment)v.push(S.append(I,R.videoInitSegment));if(R.audioInitSegment)v.push(S.append(E,R.audioInitSegment));if(R.videoSegment)v.push(S.append(I,R.videoSegment));if(R.audioSegment)v.push(S.append(E,R.audioSegment));return this.flv._transferCost.start(S0.APPEND),_=Promise.all(v),_.then(x).then(function(){J.flv._transferCost.end(S0.APPEND),x()}),P.abrupt("return",_);case 83:if(this._softVideo)this._softVideo.appendBuffer(W,X),x();case 84:case"end":return P.stop()}},w,this,[[5,12],[59,66]])}));function O(w){return K.apply(this,arguments)}return O}()},{key:"evictBuffer",value:function(){var K=O0(k().mark(function w(G){var J=this,Q,Z,W,X;return k().wrap(function U(D){while(!0)switch(D.prev=D.next){case 0:if(Q=this.flv.media,!(!this._mse||!this._demuxer||!Q||!G||G<0)){D.next=3;break}return D.abrupt("return");case 3:if(Z=Q.currentTime,W=Z-G,!(W<=0)){D.next=7;break}return D.abrupt("return");case 7:if(X=e.start(e.get(Q)),!(X+1>=W)){D.next=10;break}return D.abrupt("return");case 10:return D.abrupt("return",this._mse.clearBuffer(0,W).then(function(){return J.flv.emit(u.REMOVE_BUFFER,{removeEnd:W})}));case 11:case"end":return D.stop()}},w,this)}));function O(w){return K.apply(this,arguments)}return O}()},{key:"_emitMetaParsedEvent",value:function K(O,w){if(O.exist())this.flv.emit(u.METADATA_PARSED,{type:"video",track:O,meta:{codec:O.codec,timescale:O.timescale,width:O.width,height:O.height,sarRatio:O.sarRatio,baseDts:O.baseDts}});if(w.exist())this.flv.emit(u.METADATA_PARSED,{type:"audio",track:w,meta:{codec:w.codec,channelCount:w.channelCount,sampleRate:w.sampleRate,timescale:w.timescale,baseDts:w.baseDts}});$0.debug("track parsed",O,w)}},{key:"_fireEvents",value:function K(O,w,G){var J=this;$0.debug("videoTrack samples count: ".concat(O.samples.length,", audioTrack samples count: ").concat(w.samples.length)),G.flvScriptSamples.forEach(function(Q){J.flv.emit(u.FLV_SCRIPT_DATA,Q),$0.debug("flvScriptData",Q)}),O.samples.forEach(function(Q){if(Q.keyframe)J.flv.emit(u.KEYFRAME,{pts:Q.originPts})}),O.warnings.forEach(function(Q){var Z;switch(Q.type){case W0.LARGE_AV_SHIFT:Z=u.LARGE_AV_FIRST_FRAME_GAP_DETECT;break;case W0.LARGE_VIDEO_GAP:Z=u.LARGE_VIDEO_DTS_GAP_DETECT;break;case W0.LARGE_VIDEO_GAP_BETWEEN_CHUNK:Z=u.MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT;break}if(Z)J.flv.emit(u.STREAM_EXCEPTION,H0(H0({},Q),{},{type:Z}));$0.warn("video exception",Q)}),w.warnings.forEach(function(Q){var Z;switch(Q.type){case W0.LARGE_AUDIO_GAP:Z=u.LARGE_AUDIO_DTS_GAP_DETECT;break;case W0.AUDIO_FILLED:Z=u.AUDIO_GAP_DETECT;break;case W0.AUDIO_DROPPED:Z=u.AUDIO_OVERLAP_DETECT;break}if(Z)J.flv.emit(u.STREAM_EXCEPTION,H0(H0({},Q),{},{type:Z}));$0.warn("audio exception",Q)}),G.seiSamples.forEach(function(Q){J.flv.emit(u.SEI,H0(H0({},Q),{},{sei:{code:Q.data.type,content:Q.data.payload,dts:Q.pts}}))})}}]),Y}();function cw(Y){var K=H0({retryCount:3,retryDelay:1000,disconnectRetryCount:0,loadTimeout:1e4,maxReaderInterval:5000,preloadTime:5,defaultVodLoadSize:1e7,isLive:!1,softDecode:!1,bufferBehind:10,maxJumpDistance:3,analyzeDuration:20000,seamlesslyReload:!1,keepStatusAfterSwitch:!0,onlyVideo:!1,onlyAudio:!1,preferMMS:!1,mseLowLatency:!0,durationForMSELowLatencyOff:6,chunkCountForSpeed:50,skipChunkSize:1000,longtimeNoReceived:3000,enableStartGapJump:!0},Y);if(K.isLive){if(K.preloadTime){if(!K.maxLatency)K.maxLatency=K.preloadTime*2;if(!K.targetLatency)K.targetLatency=K.preloadTime;if(K.disconnectTime===null||K.disconnectTime===void 0)K.disconnectTime=K.maxLatency}}return K}function kO(Y,K){var O=0,w=Y.length-1,G=0,J=0,Q=w;if(K<Y[0])O=0,J=Q+1;while(J<=Q)if(G=J+Math.floor((Q-J)/2),G===w||K>=Y[G]&&K<Y[G+1]){O=G;break}else if(Y[G]<K)J=G+1;else Q=G-1;return O}var B0=new D0("flv"),AO=0.1,T1=0.3,wO=function(Y){rO(O,Y);var K=_O(O);function O(w){var G;if(h0(this,O),G=K.call(this),y(p(G),"media",null),y(p(G),"_loading",!1),y(p(G),"_opts",null),y(p(G),"_bufferService",null),y(p(G),"_gapService",null),y(p(G),"_stats",null),y(p(G),"_mediaLoader",null),y(p(G),"_maxChunkWaitTimer",null),y(p(G),"_tickTimer",null),y(p(G),"_tickInterval",500),y(p(G),"_urlSwitching",!1),y(p(G),"_seamlessSwitching",!1),y(p(G),"_disconnectRetryCount",0),y(p(G),"_preLoadEndPoint",0),y(p(G),"_keyframes",null),y(p(G),"_acceptRanges",!0),y(p(G),"_onProgress",function(){var J=O0(k().mark(function Q(Z,W,X,U){var D,V,q,L,z,I,E,S,x,C;return k().wrap(function R(v){while(!0)switch(v.prev=v.next){case 0:if(D=X.startTime,V=X.endTime,q=X.st,L=X.firstByteTime,G._loading=!W,G._firstProgressEmit){v.next=13;break}if(G.media){v.next=6;break}return(z=G._mediaLoader)===null||z===void 0||z.cancel(),v.abrupt("return");case 6:I=U.headers,E=q?L-q:V-D,G.emit(u.TTFB,{url:G._opts.url,responseUrl:U.url,elapsed:E}),G.emit(u.LOAD_RESPONSE_HEADERS,{headers:I}),G._transferCost.set(S0.TTFB,E),G._acceptRanges=!!(I!==null&&I!==void 0&&I.get("Accept-Ranges"))||!!(I!==null&&I!==void 0&&I.get("Content-Range")),G._firstProgressEmit=!0;case 13:if(G._bufferService){v.next=15;break}return v.abrupt("return");case 15:return clearTimeout(G._maxChunkWaitTimer),G._bandwidthService.addChunkRecord(Z===null||Z===void 0?void 0:Z.byteLength,V-D),v.prev=17,v.next=20,G._bufferService.appendBuffer(Z);case 20:(S=G._bufferService)===null||S===void 0||S.evictBuffer(G._opts.bufferBehind),v.next=33;break;case 23:if(v.prev=23,v.t0=v.catch(17),!(!G.isLive&&G._bufferService.isFull())){v.next=32;break}return v.next=28,G._mediaLoader.cancel();case 28:return G._loading=!1,x=G.bufferInfo().remaining,G._opts.preloadTime=parseInt(x)/2,v.abrupt("return");case 32:return v.abrupt("return",G._emitError(Q0.create(v.t0)));case 33:if(G._urlSwitching)G._urlSwitching=!1,G.emit(u.SWITCH_URL_SUCCESS,{url:G._opts.url});if(G._seamlessSwitching)G._seamlessSwitching=!1,G._tick();if(!(W&&!G.media.seeking)){v.next=40;break}if(G.emit(u.LOAD_COMPLETE),B0.debug("load done"),G.isLive&&G._disconnectRetryCount<=0)G._end();return v.abrupt("return");case 40:if(G.isLive){v.next=42;break}return v.abrupt("return");case 42:if(C=G._opts.maxReaderInterval,C&&G._firstProgressEmit)clearTimeout(G._maxChunkWaitTimer),G._maxChunkWaitTimer=setTimeout(function(){if(G._disconnectRetryCount){G._disconnectRetryCount--,G.load();return}B0.debug("onMaxChunkWait",C),G._end()},C);case 44:case"end":return v.stop()}},Q,null,[[17,23]])}));return function(Q,Z,W,X){return J.apply(this,arguments)}}()),y(p(G),"_onRetryError",function(J,Q){B0.debug("load retry",J,Q),G.emit(u.LOAD_RETRY,{error:Q0.network(J),retryTime:Q})}),y(p(G),"_end",function(){if(G._clear(),G._bufferService)G._bufferService.endOfStream();B0.debug("end stream")}),y(p(G),"_resetDisconnectCount",function(){G._disconnectRetryCount=G._opts.disconnectRetryCount}),y(p(G),"_tick",function(){clearTimeout(G._tickTimer);var J=p(G),Q=J.media;if(!Q)return;G._tickTimer=setTimeout(G._tick,G._tickInterval);var Z=e.end(e.get(Q));if(Z<AO||!Q.readyState)return;var W=G._opts;if(jO(Q)&&Q.currentTime){if(G._gapService)G._gapService.do(Q,W.maxJumpDistance,G.isLive,3)}else{if(!Q.currentTime&&G._gapService&&W.enableStartGapJump){var X=G._opts.mseLowLatency||G._opts.mseLowLatency===!1&&G.bufferInfo(T1).nextStart;if(X)G._gapService.do(Q,W.maxJumpDistance,G.isLive,3);return}if(W.isLive&&Q.readyState===4&&Z-Q.currentTime>W.disconnectTime)G.disconnect()}}),y(p(G),"_onPlay",function(){var J,Q,Z=G._opts.softDecode||((J=G.media)===null||J===void 0?void 0:(Q=J.buffered)===null||Q===void 0?void 0:Q.length);if(G.isLive){if(!G._loading&&Z)G.replay(void 0,!0);return}var W=G.bufferInfo();if((W.start||W.nextStart)>AO)G._tick()}),y(p(G),"_onLoadeddata",function(){if(G.isLive&&!G._opts.mseLowLatency){if(G.media.duration!==1/0)G._bufferService.updateDuration(1/0).catch(function(J){})}}),y(p(G),"_onSeeking",O0(k().mark(function J(){return k().wrap(function Q(Z){while(!0)switch(Z.prev=Z.next){case 0:if(!G.isLive&&G.seekable)G._preLoadEndPoint=-1,G._checkPreload();case 1:case"end":return Z.stop()}},J)}))),y(p(G),"_onTimeupdate",function(){if(!G.media)return;var J=G._opts,Q=G.media.currentTime;if(J.isLive&&J.maxLatency&&J.targetLatency){var Z=e.end(e.get(G.media)),W=Z-Q;if(W>=J.maxLatency)G.media.currentTime=Z-J.targetLatency,G.emit(u.CHASEFRAME,{currentTime:G.media.currentTime,latency:J.targetLatency})}if(G._seiService.throw(Q,!0),J.isLive||!G.seekable||G._loading)return;G._checkPreload()}),y(p(G),"_onWaiting",function(){if(G.isLive&&!G._loading&&G._disconnectRetryCount)G._disconnectRetryCount--,G.load()}),y(p(G),"_onBufferUpdate",function(){if(G._opts.isLive)return;var J=G.bufferInfo(),Q=J.end,Z=J.nextEnd;if(Math.abs((Q||Z)-G.media.duration)<1){if(G._end(),G.media.readyState<=2)G._tick()}}),y(p(G),"_checkPreload",O0(k().mark(function J(){var Q,Z,W,X,U,D,V,q,L,z;return k().wrap(function I(E){while(!0)switch(E.prev=E.next){case 0:if(Q=G.bufferInfo(),Z=Q.remaining,W=Z===void 0?0:Z,X=G._opts,U=G._keyframes.filepositions,D=G._keyframes.times,V=G.media.currentTime,!(W<X.preloadTime)){E.next=19;break}if(q=kO(G._keyframes.times,V+W+AO),L=kO(G._keyframes.times,V+W+G._opts.preloadTime),L===q)L=q+1;if(G._preLoadEndPoint!==L){E.next=11;break}return E.abrupt("return");case 11:if(z=U[q],!(z===null||z===void 0)){E.next=14;break}return E.abrupt("return");case 14:return E.next=16,G._mediaLoader.cancel();case 16:G._loadData(null,[z,U[L]]),G._preLoadEndPoint=L,G._bufferService.unContiguous(D[q]);case 19:case"end":return E.stop()}},J)}))),y(p(G),"_onFlvScriptData",function(J){var Q,Z,W,X,U=(Q=J.data)===null||Q===void 0?void 0:(Z=Q.onMetaData)===null||Z===void 0?void 0:Z.keyframes,D=(W=J.data)===null||W===void 0?void 0:(X=W.onMetaData)===null||X===void 0?void 0:X.duration;if(U)G._keyframes=U;if(!G._opts.isLive&&D)G._bufferService.updateDuration(D)}),G._opts=cw(w),G.media=G._opts.media||document.createElement("video"),G._opts.media=null,G._firstProgressEmit=!1,G._mediaLoader=new BO(H0(H0({},G._opts.fetchOptions),{},{retry:G._opts.retryCount,retryDelay:G._opts.retryDelay,timeout:G._opts.loadTimeout,onRetryError:G._onRetryError,onProgress:G._onProgress,responseType:"arraybuffer"})),G._disconnectRetryCount=G._opts.disconnectRetryCount,G._transferCost=new ow,G._bufferService=new dw(p(G),G._opts.softDecode?G.media:void 0,G._opts),G._seiService=new EO(p(G)),G._bandwidthService=new SO({chunkCountForSpeed:G._opts.chunkCountForSpeed,skipChunkSize:G._opts.skipChunkSize,longtimeNoReceived:G._opts.longtimeNoReceived}),G._stats=new $O(p(G)),!G._opts.softDecode)G._gapService=new RO;return G.media.addEventListener("play",G._onPlay),G.media.addEventListener("loadeddata",G._onLoadeddata),G.media.addEventListener("seeking",G._onSeeking),G.media.addEventListener("timeupdate",G._onTimeupdate),G.media.addEventListener("progress",G._onBufferUpdate),G.media.addEventListener("waiting",G._onWaiting),G.on(u.FLV_SCRIPT_DATA,G._onFlvScriptData),G}return x0(O,[{key:"version",get:function w(){return"3.0.21"}},{key:"isLive",get:function w(){return this._opts.isLive}},{key:"baseDts",get:function w(){var G;return(G=this._bufferService)===null||G===void 0?void 0:G.baseDts}},{key:"seekable",get:function w(){return!!this._keyframes&&this._acceptRanges}},{key:"loader",get:function w(){return this._mediaLoader}},{key:"blobUrl",get:function w(){var G;return(G=this._bufferService)===null||G===void 0?void 0:G.blobUrl}},{key:"speedInfo",value:function w(){return{speed:this._bandwidthService.getLatestSpeed(),avgSpeed:this._bandwidthService.getAvgSpeed(),totalSize:this._bandwidthService.getTotalSize(),totalCost:this._bandwidthService.getTotalCost()}}},{key:"getStats",value:function w(){return this._stats.getStats()}},{key:"bufferInfo",value:function w(){var G,J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:AO;return e.info(e.get(this.media),(G=this.media)===null||G===void 0?void 0:G.currentTime,J)}},{key:"playbackQuality",value:function w(){return bO(this.media)}},{key:"load",value:function(){var w=O0(k().mark(function J(Q){var Z,W=arguments;return k().wrap(function X(U){while(!0)switch(U.prev=U.next){case 0:if(Z=W.length>1&&W[1]!==void 0?W[1]:!1,this._bufferService){U.next=3;break}return U.abrupt("return");case 3:return U.next=5,this._reset(Z);case 5:this._loadData(Q,this._opts.isLive?[]:[0,this._opts.defaultVodLoadSize]),clearTimeout(this._tickTimer),this._tickTimer=setTimeout(this._tick,this._tickInterval);case 8:case"end":return U.stop()}},J,this)}));function G(J){return w.apply(this,arguments)}return G}()},{key:"replay",value:function(){var w=O0(k().mark(function J(){var Q=this,Z,W,X=arguments;return k().wrap(function U(D){while(!0)switch(D.prev=D.next){case 0:if(Z=X.length>0&&X[0]!==void 0?X[0]:this._opts.seamlesslyReload,W=X.length>1?X[1]:void 0,this.media){D.next=4;break}return D.abrupt("return");case 4:if(this._resetDisconnectCount(),!Z){D.next=11;break}return D.next=8,this._clear();case 8:setTimeout(function(){Q._seamlessSwitching=!0,Q._loadData(Q._opts.url),Q._bufferService.seamlessSwitch()}),D.next=13;break;case 11:return D.next=13,this.load();case 13:return D.abrupt("return",this.media.play(!W).catch(function(){}));case 14:case"end":return D.stop()}},J,this)}));function G(){return w.apply(this,arguments)}return G}()},{key:"disconnect",value:function w(){var G;return B0.debug("disconnect!"),(G=this._bufferService)===null||G===void 0||G.resetSeamlessSwitchStats(),this._clear()}},{key:"switchURL",value:function(){var w=O0(k().mark(function J(Q,Z){var W=this;return k().wrap(function X(U){while(!0)switch(U.prev=U.next){case 0:if(this._bufferService){U.next=2;break}return U.abrupt("return");case 2:if(this._resetDisconnectCount(),!(this._loading&&Z)){U.next=6;break}return this._bufferService.seamlessLoadingSwitch=function(){var D=O0(k().mark(function V(q){return k().wrap(function L(z){while(!0)switch(z.prev=z.next){case 0:return z.next=2,W._clear();case 2:W._bufferService.seamlessLoadingSwitching=!0,W._urlSwitching=!0,W._seamlessSwitching=!0,W._bufferService.seamlessSwitch(),W._loadData(Q);case 7:case"end":return z.stop()}},V)}));return function(V){return D.apply(this,arguments)}}(),U.abrupt("return");case 6:if(!(!Z||!this._opts.isLive)){U.next=11;break}return U.next=9,this.load(Q);case 9:return this._urlSwitching=!0,U.abrupt("return",this.media.play(!0).catch(function(){}));case 11:return U.next=13,this._clear();case 13:setTimeout(function(){W._urlSwitching=!0,W._seamlessSwitching=!0,W._loadData(Q),W._bufferService.seamlessSwitch()});case 14:case"end":return U.stop()}},J,this)}));function G(J,Q){return w.apply(this,arguments)}return G}()},{key:"destroy",value:function(){var w=O0(k().mark(function J(){return k().wrap(function Q(Z){while(!0)switch(Z.prev=Z.next){case 0:if(this.media){Z.next=2;break}return Z.abrupt("return");case 2:return this.removeAllListeners(),this._seiService.reset(),this.media.removeEventListener("play",this._onPlay),this.media.removeEventListener("loadeddata",this._onLoadeddata),this.media.removeEventListener("seeking",this._onSeeking),this.media.removeEventListener("timeupdate",this._onTimeupdate),this.media.removeEventListener("waiting",this._onWaiting),this.media.removeEventListener("progress",this._onBufferUpdate),Z.next=12,Promise.all([this._clear(),this._bufferService.destroy()]);case 12:this.media=null,this._bufferService=null;case 14:case"end":return Z.stop()}},J,this)}));function G(){return w.apply(this,arguments)}return G}()},{key:"_emitError",value:function w(G){var J,Q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;if(B0.table(G),B0.error(G),B0.error((J=this.media)===null||J===void 0?void 0:J.error),this._urlSwitching)this._urlSwitching=!1,this._seamlessSwitching=!1,this.emit(u.SWITCH_URL_FAILED,G);if(this.emit(u.ERROR,G),Q)this._seiService.reset(),this._end()}},{key:"_reset",value:function(){var w=O0(k().mark(function J(){var Q,Z=arguments;return k().wrap(function W(X){while(!0)switch(X.prev=X.next){case 0:return Q=Z.length>0&&Z[0]!==void 0?Z[0]:!1,this._seiService.reset(),this._bandwidthService.reset(),this._stats.reset(),X.next=6,this._clear();case 6:return X.next=8,this._bufferService.reset(Q);case 8:case"end":return X.stop()}},J,this)}));function G(){return w.apply(this,arguments)}return G}()},{key:"_loadData",value:function(){var w=O0(k().mark(function J(Q,Z){var W;return k().wrap(function X(U){while(!0)switch(U.prev=U.next){case 0:if(Q)this._opts.url=Q;if(W=Q=this._opts.url,Q){U.next=4;break}throw new Error("Source url is missing");case 4:if(this._opts.preProcessUrl)W=this._opts.preProcessUrl(Q).url;if(this._mediaLoader.finnalUrl=W,this.emit(u.LOAD_START,{url:W,seamlessSwitching:this._seamlessSwitching}),B0.debug("load data, loading:",this._loading,W),!this._loading){U.next=11;break}return U.next=11,this._mediaLoader.cancel();case 11:return this._loading=!0,U.prev=12,U.next=15,this._mediaLoader.load({url:W,range:Z});case 15:U.next=21;break;case 17:return U.prev=17,U.t0=U.catch(12),this._loading=!1,U.abrupt("return",this._emitError(Q0.network(U.t0),!1));case 21:case"end":return U.stop()}},J,this,[[12,17]])}));function G(J,Q){return w.apply(this,arguments)}return G}()},{key:"_clear",value:function(){var w=O0(k().mark(function J(){return k().wrap(function Q(Z){while(!0)switch(Z.prev=Z.next){case 0:if(!this._mediaLoader){Z.next=3;break}return Z.next=3,this._mediaLoader.cancel();case 3:clearTimeout(this._maxChunkWaitTimer),clearTimeout(this._tickTimer),this._loading=!1,this._firstProgressEmit=!1;case 7:case"end":return Z.stop()}},J,this)}));function G(){return w.apply(this,arguments)}return G}()}],[{key:"isSupported",value:function w(G){if(!G||G==="video"||G==="audio")return P0.isSupported();return typeof WebAssembly!=="undefined"}},{key:"enableLogger",value:function w(){D0.enable(),g0.enable()}},{key:"disableLogger",value:function w(){D0.disable(),g0.disable()}}]),O}(rw.default);try{if(localStorage.getItem("xgd"))wO.enableLogger();else wO.disableLogger()}catch(Y){}})();