lemon-mse 0.0.1 → 0.1.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.
package/dist/xg-flv.mjs DELETED
@@ -1,6 +0,0 @@
1
- function lt(n,a){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(n);a&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),e.push.apply(e,t)}return e}function le(n){for(var a=1;a<arguments.length;a++){var e=arguments[a]!=null?arguments[a]:{};a%2?lt(Object(e),!0).forEach(function(t){C(n,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):lt(Object(e)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))})}return n}function M(){M=function(){return n};var n={},a=Object.prototype,e=a.hasOwnProperty,t=Object.defineProperty||function(d,h,g){d[h]=g.value},r=typeof Symbol=="function"?Symbol:{},i=r.iterator||"@@iterator",s=r.asyncIterator||"@@asyncIterator",o=r.toStringTag||"@@toStringTag";function u(d,h,g){return Object.defineProperty(d,h,{value:g,enumerable:!0,configurable:!0,writable:!0}),d[h]}try{u({},"")}catch{u=function(h,g,T){return h[g]=T}}function l(d,h,g,T){var y=h&&h.prototype instanceof p?h:p,R=Object.create(y.prototype),P=new q(T||[]);return t(R,"_invoke",{value:A(d,g,P)}),R}function f(d,h,g){try{return{type:"normal",arg:d.call(h,g)}}catch(T){return{type:"throw",arg:T}}}n.wrap=l;var c={};function p(){}function _(){}function m(){}var b={};u(b,i,function(){return this});var v=Object.getPrototypeOf,w=v&&v(v(N([])));w&&w!==a&&e.call(w,i)&&(b=w);var D=m.prototype=p.prototype=Object.create(b);function O(d){["next","throw","return"].forEach(function(h){u(d,h,function(g){return this._invoke(h,g)})})}function k(d,h){function g(y,R,P,U){var F=f(d[y],d,R);if(F.type!=="throw"){var $=F.arg,X=$.value;return X&&typeof X=="object"&&e.call(X,"__await")?h.resolve(X.__await).then(function(G){g("next",G,P,U)},function(G){g("throw",G,P,U)}):h.resolve(X).then(function(G){$.value=G,P($)},function(G){return g("throw",G,P,U)})}U(F.arg)}var T;t(this,"_invoke",{value:function(y,R){function P(){return new h(function(U,F){g(y,R,U,F)})}return T=T?T.then(P,P):P()}})}function A(d,h,g){var T="suspendedStart";return function(y,R){if(T==="executing")throw new Error("Generator is already running");if(T==="completed"){if(y==="throw")throw R;return ie()}for(g.method=y,g.arg=R;;){var P=g.delegate;if(P){var U=j(P,g);if(U){if(U===c)continue;return U}}if(g.method==="next")g.sent=g._sent=g.arg;else if(g.method==="throw"){if(T==="suspendedStart")throw T="completed",g.arg;g.dispatchException(g.arg)}else g.method==="return"&&g.abrupt("return",g.arg);T="executing";var F=f(d,h,g);if(F.type==="normal"){if(T=g.done?"completed":"suspendedYield",F.arg===c)continue;return{value:F.arg,done:g.done}}F.type==="throw"&&(T="completed",g.method="throw",g.arg=F.arg)}}}function j(d,h){var g=h.method,T=d.iterator[g];if(T===void 0)return h.delegate=null,g==="throw"&&d.iterator.return&&(h.method="return",h.arg=void 0,j(d,h),h.method==="throw")||g!=="return"&&(h.method="throw",h.arg=new TypeError("The iterator does not provide a '"+g+"' method")),c;var y=f(T,d.iterator,h.arg);if(y.type==="throw")return h.method="throw",h.arg=y.arg,h.delegate=null,c;var R=y.arg;return R?R.done?(h[d.resultName]=R.value,h.next=d.nextLoc,h.method!=="return"&&(h.method="next",h.arg=void 0),h.delegate=null,c):R:(h.method="throw",h.arg=new TypeError("iterator result is not an object"),h.delegate=null,c)}function Q(d){var h={tryLoc:d[0]};1 in d&&(h.catchLoc=d[1]),2 in d&&(h.finallyLoc=d[2],h.afterLoc=d[3]),this.tryEntries.push(h)}function W(d){var h=d.completion||{};h.type="normal",delete h.arg,d.completion=h}function q(d){this.tryEntries=[{tryLoc:"root"}],d.forEach(Q,this),this.reset(!0)}function N(d){if(d){var h=d[i];if(h)return h.call(d);if(typeof d.next=="function")return d;if(!isNaN(d.length)){var g=-1,T=function y(){for(;++g<d.length;)if(e.call(d,g))return y.value=d[g],y.done=!1,y;return y.value=void 0,y.done=!0,y};return T.next=T}}return{next:ie}}function ie(){return{value:void 0,done:!0}}return _.prototype=m,t(D,"constructor",{value:m,configurable:!0}),t(m,"constructor",{value:_,configurable:!0}),_.displayName=u(m,o,"GeneratorFunction"),n.isGeneratorFunction=function(d){var h=typeof d=="function"&&d.constructor;return!!h&&(h===_||(h.displayName||h.name)==="GeneratorFunction")},n.mark=function(d){return Object.setPrototypeOf?Object.setPrototypeOf(d,m):(d.__proto__=m,u(d,o,"GeneratorFunction")),d.prototype=Object.create(D),d},n.awrap=function(d){return{__await:d}},O(k.prototype),u(k.prototype,s,function(){return this}),n.AsyncIterator=k,n.async=function(d,h,g,T,y){y===void 0&&(y=Promise);var R=new k(l(d,h,g,T),y);return n.isGeneratorFunction(h)?R:R.next().then(function(P){return P.done?P.value:R.next()})},O(D),u(D,o,"Generator"),u(D,i,function(){return this}),u(D,"toString",function(){return"[object Generator]"}),n.keys=function(d){var h=Object(d),g=[];for(var T in h)g.push(T);return g.reverse(),function y(){for(;g.length;){var R=g.pop();if(R in h)return y.value=R,y.done=!1,y}return y.done=!0,y}},n.values=N,q.prototype={constructor:q,reset:function(d){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(W),!d)for(var h in this)h.charAt(0)==="t"&&e.call(this,h)&&!isNaN(+h.slice(1))&&(this[h]=void 0)},stop:function(){this.done=!0;var d=this.tryEntries[0].completion;if(d.type==="throw")throw d.arg;return this.rval},dispatchException:function(d){if(this.done)throw d;var h=this;function g(F,$){return R.type="throw",R.arg=d,h.next=F,$&&(h.method="next",h.arg=void 0),!!$}for(var T=this.tryEntries.length-1;T>=0;--T){var y=this.tryEntries[T],R=y.completion;if(y.tryLoc==="root")return g("end");if(y.tryLoc<=this.prev){var P=e.call(y,"catchLoc"),U=e.call(y,"finallyLoc");if(P&&U){if(this.prev<y.catchLoc)return g(y.catchLoc,!0);if(this.prev<y.finallyLoc)return g(y.finallyLoc)}else if(P){if(this.prev<y.catchLoc)return g(y.catchLoc,!0)}else{if(!U)throw new Error("try statement without catch or finally");if(this.prev<y.finallyLoc)return g(y.finallyLoc)}}}},abrupt:function(d,h){for(var g=this.tryEntries.length-1;g>=0;--g){var T=this.tryEntries[g];if(T.tryLoc<=this.prev&&e.call(T,"finallyLoc")&&this.prev<T.finallyLoc){var y=T;break}}y&&(d==="break"||d==="continue")&&y.tryLoc<=h&&h<=y.finallyLoc&&(y=null);var R=y?y.completion:{};return R.type=d,R.arg=h,y?(this.method="next",this.next=y.finallyLoc,c):this.complete(R)},complete:function(d,h){if(d.type==="throw")throw d.arg;return d.type==="break"||d.type==="continue"?this.next=d.arg:d.type==="return"?(this.rval=this.arg=d.arg,this.method="return",this.next="end"):d.type==="normal"&&h&&(this.next=h),c},finish:function(d){for(var h=this.tryEntries.length-1;h>=0;--h){var g=this.tryEntries[h];if(g.finallyLoc===d)return this.complete(g.completion,g.afterLoc),W(g),c}},catch:function(d){for(var h=this.tryEntries.length-1;h>=0;--h){var g=this.tryEntries[h];if(g.tryLoc===d){var T=g.completion;if(T.type==="throw"){var y=T.arg;W(g)}return y}}throw new Error("illegal catch attempt")},delegateYield:function(d,h,g){return this.delegate={iterator:N(d),resultName:h,nextLoc:g},this.method==="next"&&(this.arg=void 0),c}},n}function ft(n,a,e,t,r,i,s){try{var o=n[i](s),u=o.value}catch(l){e(l);return}o.done?a(u):Promise.resolve(u).then(t,r)}function J(n){return function(){var a=this,e=arguments;return new Promise(function(t,r){var i=n.apply(a,e);function s(u){ft(i,t,r,s,o,"next",u)}function o(u){ft(i,t,r,s,o,"throw",u)}s(void 0)})}}function ct(n,a){if(!(n instanceof a))throw new TypeError("Cannot call a class as a function")}function ht(n,a){for(var e=0;e<a.length;e++){var t=a[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(n,vt(t.key),t)}}function dt(n,a,e){return a&&ht(n.prototype,a),e&&ht(n,e),Object.defineProperty(n,"prototype",{writable:!1}),n}function C(n,a,e){return a=vt(a),a in n?Object.defineProperty(n,a,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[a]=e,n}function qt(n,a){if(typeof a!="function"&&a!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(a&&a.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),a&&qe(n,a)}function Ie(n){return Ie=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Ie(n)}function qe(n,a){return qe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},qe(n,a)}function Xt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function B(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function Yt(n,a){if(a&&(typeof a=="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return B(n)}function Qt(n){var a=Xt();return function(){var t=Ie(n),r;if(a){var i=Ie(this).constructor;r=Reflect.construct(t,arguments,i)}else r=t.apply(this,arguments);return Yt(this,r)}}function Jt(n,a){if(typeof n!="object"||n===null)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var t=e.call(n,a||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(n)}function vt(n){var a=Jt(n,"string");return typeof a=="symbol"?a:String(a)}function pt(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var _t={exports:{}};(function(n){var a=Object.prototype.hasOwnProperty,e="~";function t(){}Object.create&&(t.prototype=Object.create(null),new t().__proto__||(e=!1));function r(u,l,f){this.fn=u,this.context=l,this.once=f||!1}function i(u,l,f,c,p){if(typeof f!="function")throw new TypeError("The listener must be a function");var _=new r(f,c||u,p),m=e?e+l:l;return u._events[m]?u._events[m].fn?u._events[m]=[u._events[m],_]:u._events[m].push(_):(u._events[m]=_,u._eventsCount++),u}function s(u,l){--u._eventsCount===0?u._events=new t:delete u._events[l]}function o(){this._events=new t,this._eventsCount=0}o.prototype.eventNames=function(){var l=[],f,c;if(this._eventsCount===0)return l;for(c in f=this._events)a.call(f,c)&&l.push(e?c.slice(1):c);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(f)):l},o.prototype.listeners=function(l){var f=e?e+l:l,c=this._events[f];if(!c)return[];if(c.fn)return[c.fn];for(var p=0,_=c.length,m=new Array(_);p<_;p++)m[p]=c[p].fn;return m},o.prototype.listenerCount=function(l){var f=e?e+l:l,c=this._events[f];return c?c.fn?1:c.length:0},o.prototype.emit=function(l,f,c,p,_,m){var b=e?e+l:l;if(!this._events[b])return!1;var v=this._events[b],w=arguments.length,D,O;if(v.fn){switch(v.once&&this.removeListener(l,v.fn,void 0,!0),w){case 1:return v.fn.call(v.context),!0;case 2:return v.fn.call(v.context,f),!0;case 3:return v.fn.call(v.context,f,c),!0;case 4:return v.fn.call(v.context,f,c,p),!0;case 5:return v.fn.call(v.context,f,c,p,_),!0;case 6:return v.fn.call(v.context,f,c,p,_,m),!0}for(O=1,D=new Array(w-1);O<w;O++)D[O-1]=arguments[O];v.fn.apply(v.context,D)}else{var k=v.length,A;for(O=0;O<k;O++)switch(v[O].once&&this.removeListener(l,v[O].fn,void 0,!0),w){case 1:v[O].fn.call(v[O].context);break;case 2:v[O].fn.call(v[O].context,f);break;case 3:v[O].fn.call(v[O].context,f,c);break;case 4:v[O].fn.call(v[O].context,f,c,p);break;default:if(!D)for(A=1,D=new Array(w-1);A<w;A++)D[A-1]=arguments[A];v[O].fn.apply(v[O].context,D)}}return!0},o.prototype.on=function(l,f,c){return i(this,l,f,c,!1)},o.prototype.once=function(l,f,c){return i(this,l,f,c,!0)},o.prototype.removeListener=function(l,f,c,p){var _=e?e+l:l;if(!this._events[_])return this;if(!f)return s(this,_),this;var m=this._events[_];if(m.fn)m.fn===f&&(!p||m.once)&&(!c||m.context===c)&&s(this,_);else{for(var b=0,v=[],w=m.length;b<w;b++)(m[b].fn!==f||p&&!m[b].once||c&&m[b].context!==c)&&v.push(m[b]);v.length?this._events[_]=v.length===1?v[0]:v:s(this,_)}return this},o.prototype.removeAllListeners=function(l){var f;return l?(f=e?e+l:l,this._events[f]&&s(this,f)):(this._events=new t,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=e,o.EventEmitter=o,n.exports=o})(_t);var Zt=_t.exports;const er=pt(Zt);function mt(n,a){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(n);a&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),e.push.apply(e,t)}return e}function Ae(n){for(var a=1;a<arguments.length;a++){var e=arguments[a]!=null?arguments[a]:{};a%2?mt(Object(e),!0).forEach(function(t){E(n,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):mt(Object(e)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))})}return n}function K(){K=function(){return n};var n={},a=Object.prototype,e=a.hasOwnProperty,t=Object.defineProperty||function(d,h,g){d[h]=g.value},r=typeof Symbol=="function"?Symbol:{},i=r.iterator||"@@iterator",s=r.asyncIterator||"@@asyncIterator",o=r.toStringTag||"@@toStringTag";function u(d,h,g){return Object.defineProperty(d,h,{value:g,enumerable:!0,configurable:!0,writable:!0}),d[h]}try{u({},"")}catch{u=function(h,g,T){return h[g]=T}}function l(d,h,g,T){var y=h&&h.prototype instanceof p?h:p,R=Object.create(y.prototype),P=new q(T||[]);return t(R,"_invoke",{value:A(d,g,P)}),R}function f(d,h,g){try{return{type:"normal",arg:d.call(h,g)}}catch(T){return{type:"throw",arg:T}}}n.wrap=l;var c={};function p(){}function _(){}function m(){}var b={};u(b,i,function(){return this});var v=Object.getPrototypeOf,w=v&&v(v(N([])));w&&w!==a&&e.call(w,i)&&(b=w);var D=m.prototype=p.prototype=Object.create(b);function O(d){["next","throw","return"].forEach(function(h){u(d,h,function(g){return this._invoke(h,g)})})}function k(d,h){function g(y,R,P,U){var F=f(d[y],d,R);if(F.type!=="throw"){var $=F.arg,X=$.value;return X&&typeof X=="object"&&e.call(X,"__await")?h.resolve(X.__await).then(function(G){g("next",G,P,U)},function(G){g("throw",G,P,U)}):h.resolve(X).then(function(G){$.value=G,P($)},function(G){return g("throw",G,P,U)})}U(F.arg)}var T;t(this,"_invoke",{value:function(y,R){function P(){return new h(function(U,F){g(y,R,U,F)})}return T=T?T.then(P,P):P()}})}function A(d,h,g){var T="suspendedStart";return function(y,R){if(T==="executing")throw new Error("Generator is already running");if(T==="completed"){if(y==="throw")throw R;return ie()}for(g.method=y,g.arg=R;;){var P=g.delegate;if(P){var U=j(P,g);if(U){if(U===c)continue;return U}}if(g.method==="next")g.sent=g._sent=g.arg;else if(g.method==="throw"){if(T==="suspendedStart")throw T="completed",g.arg;g.dispatchException(g.arg)}else g.method==="return"&&g.abrupt("return",g.arg);T="executing";var F=f(d,h,g);if(F.type==="normal"){if(T=g.done?"completed":"suspendedYield",F.arg===c)continue;return{value:F.arg,done:g.done}}F.type==="throw"&&(T="completed",g.method="throw",g.arg=F.arg)}}}function j(d,h){var g=h.method,T=d.iterator[g];if(T===void 0)return h.delegate=null,g==="throw"&&d.iterator.return&&(h.method="return",h.arg=void 0,j(d,h),h.method==="throw")||g!=="return"&&(h.method="throw",h.arg=new TypeError("The iterator does not provide a '"+g+"' method")),c;var y=f(T,d.iterator,h.arg);if(y.type==="throw")return h.method="throw",h.arg=y.arg,h.delegate=null,c;var R=y.arg;return R?R.done?(h[d.resultName]=R.value,h.next=d.nextLoc,h.method!=="return"&&(h.method="next",h.arg=void 0),h.delegate=null,c):R:(h.method="throw",h.arg=new TypeError("iterator result is not an object"),h.delegate=null,c)}function Q(d){var h={tryLoc:d[0]};1 in d&&(h.catchLoc=d[1]),2 in d&&(h.finallyLoc=d[2],h.afterLoc=d[3]),this.tryEntries.push(h)}function W(d){var h=d.completion||{};h.type="normal",delete h.arg,d.completion=h}function q(d){this.tryEntries=[{tryLoc:"root"}],d.forEach(Q,this),this.reset(!0)}function N(d){if(d){var h=d[i];if(h)return h.call(d);if(typeof d.next=="function")return d;if(!isNaN(d.length)){var g=-1,T=function y(){for(;++g<d.length;)if(e.call(d,g))return y.value=d[g],y.done=!1,y;return y.value=void 0,y.done=!0,y};return T.next=T}}return{next:ie}}function ie(){return{value:void 0,done:!0}}return _.prototype=m,t(D,"constructor",{value:m,configurable:!0}),t(m,"constructor",{value:_,configurable:!0}),_.displayName=u(m,o,"GeneratorFunction"),n.isGeneratorFunction=function(d){var h=typeof d=="function"&&d.constructor;return!!h&&(h===_||(h.displayName||h.name)==="GeneratorFunction")},n.mark=function(d){return Object.setPrototypeOf?Object.setPrototypeOf(d,m):(d.__proto__=m,u(d,o,"GeneratorFunction")),d.prototype=Object.create(D),d},n.awrap=function(d){return{__await:d}},O(k.prototype),u(k.prototype,s,function(){return this}),n.AsyncIterator=k,n.async=function(d,h,g,T,y){y===void 0&&(y=Promise);var R=new k(l(d,h,g,T),y);return n.isGeneratorFunction(h)?R:R.next().then(function(P){return P.done?P.value:R.next()})},O(D),u(D,o,"Generator"),u(D,i,function(){return this}),u(D,"toString",function(){return"[object Generator]"}),n.keys=function(d){var h=Object(d),g=[];for(var T in h)g.push(T);return g.reverse(),function y(){for(;g.length;){var R=g.pop();if(R in h)return y.value=R,y.done=!1,y}return y.done=!0,y}},n.values=N,q.prototype={constructor:q,reset:function(d){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(W),!d)for(var h in this)h.charAt(0)==="t"&&e.call(this,h)&&!isNaN(+h.slice(1))&&(this[h]=void 0)},stop:function(){this.done=!0;var d=this.tryEntries[0].completion;if(d.type==="throw")throw d.arg;return this.rval},dispatchException:function(d){if(this.done)throw d;var h=this;function g(F,$){return R.type="throw",R.arg=d,h.next=F,$&&(h.method="next",h.arg=void 0),!!$}for(var T=this.tryEntries.length-1;T>=0;--T){var y=this.tryEntries[T],R=y.completion;if(y.tryLoc==="root")return g("end");if(y.tryLoc<=this.prev){var P=e.call(y,"catchLoc"),U=e.call(y,"finallyLoc");if(P&&U){if(this.prev<y.catchLoc)return g(y.catchLoc,!0);if(this.prev<y.finallyLoc)return g(y.finallyLoc)}else if(P){if(this.prev<y.catchLoc)return g(y.catchLoc,!0)}else{if(!U)throw new Error("try statement without catch or finally");if(this.prev<y.finallyLoc)return g(y.finallyLoc)}}}},abrupt:function(d,h){for(var g=this.tryEntries.length-1;g>=0;--g){var T=this.tryEntries[g];if(T.tryLoc<=this.prev&&e.call(T,"finallyLoc")&&this.prev<T.finallyLoc){var y=T;break}}y&&(d==="break"||d==="continue")&&y.tryLoc<=h&&h<=y.finallyLoc&&(y=null);var R=y?y.completion:{};return R.type=d,R.arg=h,y?(this.method="next",this.next=y.finallyLoc,c):this.complete(R)},complete:function(d,h){if(d.type==="throw")throw d.arg;return d.type==="break"||d.type==="continue"?this.next=d.arg:d.type==="return"?(this.rval=this.arg=d.arg,this.method="return",this.next="end"):d.type==="normal"&&h&&(this.next=h),c},finish:function(d){for(var h=this.tryEntries.length-1;h>=0;--h){var g=this.tryEntries[h];if(g.finallyLoc===d)return this.complete(g.completion,g.afterLoc),W(g),c}},catch:function(d){for(var h=this.tryEntries.length-1;h>=0;--h){var g=this.tryEntries[h];if(g.tryLoc===d){var T=g.completion;if(T.type==="throw"){var y=T.arg;W(g)}return y}}throw new Error("illegal catch attempt")},delegateYield:function(d,h,g){return this.delegate={iterator:N(d),resultName:h,nextLoc:g},this.method==="next"&&(this.arg=void 0),c}},n}function be(n){"@babel/helpers - typeof";return be=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},be(n)}function gt(n,a,e,t,r,i,s){try{var o=n[i](s),u=o.value}catch(l){e(l);return}o.done?a(u):Promise.resolve(u).then(t,r)}function fe(n){return function(){var a=this,e=arguments;return new Promise(function(t,r){var i=n.apply(a,e);function s(u){gt(i,t,r,s,o,"next",u)}function o(u){gt(i,t,r,s,o,"throw",u)}s(void 0)})}}function te(n,a){if(!(n instanceof a))throw new TypeError("Cannot call a class as a function")}function yt(n,a){for(var e=0;e<a.length;e++){var t=a[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(n,St(t.key),t)}}function re(n,a,e){return a&&yt(n.prototype,a),e&&yt(n,e),Object.defineProperty(n,"prototype",{writable:!1}),n}function E(n,a,e){return a=St(a),a in n?Object.defineProperty(n,a,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[a]=e,n}function ke(n,a){if(typeof a!="function"&&a!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(a&&a.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),a&&Oe(n,a)}function ge(n){return ge=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},ge(n)}function Oe(n,a){return Oe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},Oe(n,a)}function bt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function xe(n,a,e){return bt()?xe=Reflect.construct.bind():xe=function(r,i,s){var o=[null];o.push.apply(o,i);var u=Function.bind.apply(r,o),l=new u;return s&&Oe(l,s.prototype),l},xe.apply(null,arguments)}function tr(n){return Function.toString.call(n).indexOf("[native code]")!==-1}function Ue(n){var a=typeof Map=="function"?new Map:void 0;return Ue=function(t){if(t===null||!tr(t))return t;if(typeof t!="function")throw new TypeError("Super expression must either be null or a function");if(typeof a<"u"){if(a.has(t))return a.get(t);a.set(t,r)}function r(){return xe(t,arguments,ge(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),Oe(r,t)},Ue(n)}function rr(n,a){if(n==null)return{};var e={},t=Object.keys(n),r,i;for(i=0;i<t.length;i++)r=t[i],!(a.indexOf(r)>=0)&&(e[r]=n[r]);return e}function nr(n,a){if(n==null)return{};var e=rr(n,a),t,r;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);for(r=0;r<i.length;r++)t=i[r],!(a.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(n,t)&&(e[t]=n[t])}return e}function L(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function ir(n,a){if(a&&(typeof a=="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return L(n)}function De(n){var a=bt();return function(){var t=ge(n),r;if(a){var i=ge(this).constructor;r=Reflect.construct(t,arguments,i)}else r=t.apply(this,arguments);return ir(this,r)}}function ar(n,a){for(;!Object.prototype.hasOwnProperty.call(n,a)&&(n=ge(n),n!==null););return n}function Me(){return typeof Reflect<"u"&&Reflect.get?Me=Reflect.get.bind():Me=function(a,e,t){var r=ar(a,e);if(r){var i=Object.getOwnPropertyDescriptor(r,e);return i.get?i.get.call(arguments.length<3?a:t):i.value}},Me.apply(this,arguments)}function sr(n,a){if(n){if(typeof n=="string")return Et(n,a);var e=Object.prototype.toString.call(n).slice(8,-1);if(e==="Object"&&n.constructor&&(e=n.constructor.name),e==="Map"||e==="Set")return Array.from(n);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return Et(n,a)}}function Et(n,a){(a==null||a>n.length)&&(a=n.length);for(var e=0,t=new Array(a);e<a;e++)t[e]=n[e];return t}function or(n,a){var e=typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(!e){if(Array.isArray(n)||(e=sr(n))||a&&n&&typeof n.length=="number"){e&&(n=e);var t=0,r=function(){};return{s:r,n:function(){return t>=n.length?{done:!0}:{done:!1,value:n[t++]}},e:function(u){throw u},f:r}}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 i=!0,s=!1,o;return{s:function(){e=e.call(n)},n:function(){var u=e.next();return i=u.done,u},e:function(u){s=!0,o=u},f:function(){try{!i&&e.return!=null&&e.return()}finally{if(s)throw o}}}}function ur(n,a){if(typeof n!="object"||n===null)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var t=e.call(n,a||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(n)}function St(n){var a=ur(n,"string");return typeof a=="symbol"?a:String(a)}function Ee(){var n,a,e=new Promise(function(t,r){n=t,a=r});return e.used=!1,e.resolve=function(){return e.used=!0,n.apply(void 0,arguments)},e.reject=function(){return e.used=!0,a.apply(void 0,arguments)},e}function Se(){try{return parseInt(performance.now(),10)}catch{return new Date().getTime()}}var ee=function(){function n(){te(this,n)}return re(n,null,[{key:"start",value:function(e){return!e||!e.length||e.length===1&&e.end(0)-e.start(0)<1e-6||e.length===1&&e.start(0)<0?0:e.start(0)}},{key:"end",value:function(e){return!e||!e.length||e.length===1&&e.end(0)-e.start(0)<1e-6?0:e.end(e.length-1)}},{key:"get",value:function(e){if(e)try{return e.buffered}catch{}}},{key:"buffers",value:function(e,t){if(!e||!e.length)return[];for(var r=[],i=0,s=e.length;i<s;i++){var o=r.length;if(!o||!t)r.push([e.start(i),e.end(i)]);else{var u=r[o-1],l=u[1],f=e.start(i);if(f-l<=t){var c=e.end(i);c>l&&(u[1]=c)}else r.push([e.start(i),e.end(i)])}}return r}},{key:"totalLength",value:function(e){return!e||!e.length?0:e.reduce(function(t,r){return t+=r[1]-r[0]},0)}},{key:"info",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(!e||!e.length)return{start:0,end:0,buffers:[]};for(var i=0,s=0,o=0,u=0,l=0,f=0,c=0,p=n.buffers(e,r),_=0,m=p.length;_<m;_++){var b=p[_];if(t+r>=b[0]&&t<=b[1])i=b[0],s=b[1],o=_;else if(t+r<b[0]){u=b[0],l=b[1];break}else t+r>b[1]&&(f=b[0],c=b[1])}return{start:i,end:s,index:o,buffers:p,nextStart:u,nextEnd:l,prevStart:f,prevEnd:c,currentTime:t,behind:t-i,remaining:s?s-t:0,length:n.totalLength&&n.totalLength(p)}}}]),n}(),ne,V={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",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"}},Xe=(ne={},E(ne,V.MANIFEST,{HLS:1100,DASH:1200}),E(ne,V.NETWORK,2100),E(ne,V.NETWORK_TIMEOUT,2101),E(ne,V.NETWORK_FORBIDDEN,2103),E(ne,V.NETWORK_NOTFOUND,2104),E(ne,V.NETWROK_RANGE_NOT_SATISFIABLE,2116),E(ne,V.DEMUX,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400,SIDX:3410}),E(ne,V.REMUX,{FMP4:4100,MP4:4200}),E(ne,V.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,EME_HIJACK:5301}),E(ne,V.DRM,{LICENSE:7100,CUSTOM_LICENSE:7200}),E(ne,V.OTHER,8e3),E(ne,V.RUNTIME,{NO_CANPLAY_ERROR:9001,BUFFERBREAK_ERROR:9002,WAITING_TIMEOUT_ERROR:9003}),ne),ce=function(n){ke(e,n);var a=De(e);function e(t,r,i,s,o){var u;return te(this,e),u=a.call(this,o||i?.message),u.errorType=t===V.NETWORK_TIMEOUT?V.NETWORK:t,u.originError=i,u.ext=s,u.errorCode=Xe[t][r]||Xe[t],u.errorMessage=u.message,u.errorCode||(u.errorType=V.OTHER,u.errorCode=Xe[u.errorType]),u}return re(e,null,[{key:"create",value:function(r,i,s,o,u){return r instanceof e?r:(r instanceof Error&&(s=r,r=""),r||(r=V.OTHER),new e(r,i,s,o,u))}},{key:"network",value:function(r){var i;return new e(r!=null&&r.isTimeout?V.NETWORK_TIMEOUT:V.NETWORK,null,r instanceof Error?r:null,{url:r?.url,response:r?.response,httpCode:r==null||(i=r.response)===null||i===void 0?void 0:i.status})}}]),e}(Ue(Error)),lr=typeof window<"u",Be={DEBUG:1,LOG:2,WARN:3,ERROR:4},fr=200*1024,cr=["Boolean","Number","String","Undefined","Null","Date","Object"],_e=function(){function n(a,e){te(this,n),this.name=a||"",this._prefix="[".concat(this.name,"]"),this.logCacheLevel=e?.logCacheLevel||3,this.logMaxSize=e?.logMaxSize||fr,this.logSize=0,this.logTextArray=[]}return re(n,[{key:"debug",value:function(){for(var e,t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];this.logCache.apply(this,[Be.DEBUG].concat(r)),!n.disabled&&(e=console).debug.apply(e,[this._prefix,Re()].concat(r))}},{key:"log",value:function(){for(var e,t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];this.logCache.apply(this,[Be.LOG].concat(r)),!n.disabled&&(e=console).log.apply(e,[this._prefix,Re()].concat(r))}},{key:"warn",value:function(){for(var e,t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];this.logCache.apply(this,[Be.WARN].concat(r)),!n.disabled&&(e=console).warn.apply(e,[this._prefix,Re()].concat(r))}},{key:"error",value:function(){for(var e,t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];this.logCache.apply(this,[Be.ERROR].concat(r)),!n.disabled&&(e=console).error.apply(e,[this._prefix,Re()].concat(r))}},{key:"logCache",value:function(e){if(!(e<this.logCacheLevel)){var t="";try{for(var r=arguments.length,i=new Array(r>1?r-1:0),s=1;s<r;s++)i[s-1]=arguments[s];var o=i.map(function(l){return wt(l)});t=this._prefix+Re()+JSON.stringify(o)}catch{return}if(e>=this.logCacheLevel&&(this.logSize+=t.length,this.logTextArray.push(t)),this.logSize>this.logMaxSize){var u=this.logTextArray.shift();this.logSize-=u.length}}}},{key:"getLogCache",value:function(){var e=this.logTextArray.join(`
3
- `);return this.reset(),e}},{key:"reset",value:function(){this.logTextArray=[],this.logSize=0}},{key:"table",value:function(){var e;n.disabled||(console.group(this._prefix),(e=console).table.apply(e,arguments),console.groupEnd())}},{key:"setLogLevel",value:function(e){this.logCacheLevel=e}}],[{key:"enable",value:function(){n.disabled=!1}},{key:"disable",value:function(){n.disabled=!0}}]),n}();E(_e,"disabled",!0);function Re(){return new Date().toLocaleString()}function hr(n){if(be(n)!=="object")return n;var a=Object.prototype.toString.call(n).slice(8,-1);switch(a){case"Array":case"Uint8Array":case"ArrayBuffer":return a+"["+n.length+"]";case"Object":return"{}";default:return a}}function wt(n,a,e){e||(e=1),a||(a=2);var t={};if(!n||be(n)!=="object")return n;var r=Object.prototype.toString.call(n).slice(8,-1);if(!cr.includes(r))return r;if(!(e>a)){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e===a?t[i]=hr(n[i]):be(n[i])==="object"?t[i]=wt(n[i],a,e+1):t[i]=n[i]);return t}}function Tt(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;try{return lr?n&&typeof ManagedMediaSource<"u"?ManagedMediaSource:window.MediaSource:null}catch{}}function Ye(n){return/ManagedMediaSource/gi.test(Object.prototype.toString.call(n))}var Ne={APPEND:"appendBuffer",REMOVE:"removeBuffer",UPDATE_DURATION:"updateDuration"},Le=function(){function n(a,e){var t=this;te(this,n),E(this,"media",null),E(this,"mediaSource",null),E(this,"_openPromise",Ee()),E(this,"_queue",Object.create(null)),E(this,"_sourceBuffer",Object.create(null)),E(this,"_mseFullFlag",{}),E(this,"_st",0),E(this,"_opst",0),E(this,"_logger",null),E(this,"_config",null),E(this,"_url",null),E(this,"_onStartStreaming",function(){t._logger.debug("startstreaming")}),E(this,"_onEndStreaming",function(){t._logger.debug("endstreaming")}),E(this,"_onSBUpdateEnd",function(r){var i=t._queue[r];if(i){var s=i[0];if(s?.opName!==Ne.UPDATE_DURATION&&i.shift(),s){var o=Se()-t._opst;t._logger.debug("UpdateEnd",s.opName,o,s.context),s.promise.resolve({name:s.opName,context:s.context,costtime:o}),t._startQueue(r)}}}),E(this,"_onSBUpdateError",function(r,i){var s=t._queue[r];if(s){var o=s[0];o&&(t._logger.error("UpdateError",r,o.opName,o.context),o.promise.reject(new ce(V.MEDIA,V.SUB_TYPES.MSE_APPEND_BUFFER,i)))}}),this._config=Object.assign(n.getDefaultConfig(),e),a&&this.bindMedia(a),this._logger=new _e("MSE"),this._config.openLog&&_e.enable()}return re(n,[{key:"isOpened",get:function(){var e;return((e=this.mediaSource)===null||e===void 0?void 0:e.readyState)==="open"}},{key:"url",get:function(){return this._url}},{key:"duration",get:function(){var e;return((e=this.mediaSource)===null||e===void 0?void 0:e.duration)||-1}},{key:"isEnded",get:function(){return this.mediaSource?this.mediaSource.readyState==="ended":!1}},{key:"streaming",get:function(){return Ye(this.mediaSource)?this.mediaSource.streaming:!0}},{key:"isFull",value:function(e){return e?this._mseFullFlag[e]:this._mseFullFlag[n.VIDEO]}},{key:"updateDuration",value:function(e){var t=this,r=this.mediaSource&&this.mediaSource.duration>e;if(this.mediaSource&&this.mediaSource.duration>e){var i=0;if(Object.keys(this._sourceBuffer).forEach(function(s){try{i=Math.max(t.bufferEnd(s)||0,i)}catch{}}),e<i)return Promise.resolve()}return this._enqueueBlockingOp(function(){if(t.isEnded){t._logger.debug("setDuration but ended");return}t.mediaSource&&(t.mediaSource.duration=e,t._logger.debug("setDuration",e))},Ne.UPDATE_DURATION,{isReduceDuration:r})}},{key:"open",value:function(){var e=this;if(this._openPromise.used&&!this.isOpened&&this.mediaSource){var t=this.mediaSource,r=function i(){var s=Se()-e._st;e._logger.debug("sourceopen",s),t.removeEventListener("sourceopen",i),e._openPromise.resolve({costtime:s})};t.addEventListener("sourceopen",r),this._openPromise=Ee()}return this._openPromise}},{key:"bindMedia",value:function(){var a=fe(K().mark(function t(r){var i=this,s,o,u,l;return K().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(!(this.mediaSource||this.media)){c.next=3;break}return c.next=3,this.unbindMedia();case 3:if(s=Tt(this._config.preferMMS),!(!r||!s)){c.next=6;break}throw new Error("Param media or MediaSource does not exist");case 6:return this.media=r,o=this.mediaSource=new s,u=Ye(o),this._st=Se(),l=function p(){var _=Se()-i._st;i._logger.debug("sourceopen"),o.removeEventListener("sourceopen",p),URL.revokeObjectURL(r.src),i._openPromise.resolve({costtime:_})},o.addEventListener("sourceopen",l),u&&(o.addEventListener("startstreaming",this._onStartStreaming),o.addEventListener("endstreaming",this._onEndStreaming)),this._url=URL.createObjectURL(o),r.src=this._url,r.disableRemotePlayback=u,c.abrupt("return",this._openPromise);case 17:case"end":return c.stop()}},t,this)}));function e(t){return a.apply(this,arguments)}return e}()},{key:"unbindMedia",value:function(){var a=fe(K().mark(function t(){var r=this,i,s,o;return K().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(this._openPromise.used||this._openPromise.resolve(),i=this.mediaSource,i){if(Object.keys(this._queue).forEach(function(f){var c=r._queue[f];c&&c.forEach(function(p){var _,m;return(_=p.promise)===null||_===void 0||(m=_.resolve)===null||m===void 0?void 0:m.call(_)})}),s=!!this.media&&this.media.readyState>=1,o=i.readyState==="open",s&&o)try{i.endOfStream()}catch{}Object.keys(this._sourceBuffer).forEach(function(f){try{i.removeSourceBuffer(r._sourceBuffer[f])}catch{}}),Ye(i)&&(i.removeEventListener("startstreaming",this._onStartStreaming),i.removeEventListener("endstreaming",this._onEndStreaming))}if(this.media){this.media.disableRemotePlayback=!1,this.media.removeAttribute("src");try{this.media.load()}catch{}this.media=null}this.mediaSource=null,this._openPromise=Ee(),this._queue=Object.create(null),this._sourceBuffer=Object.create(null);case 8:case"end":return l.stop()}},t,this)}));function e(){return a.apply(this,arguments)}return e}()},{key:"createSource",value:function(e,t){if(!(this._sourceBuffer[e]||!this.mediaSource)){var r;try{r=this._sourceBuffer[e]=this.mediaSource.addSourceBuffer(t)}catch(i){throw new ce(V.MEDIA,V.SUB_TYPES.MSE_ADD_SB,i)}r.mimeType=t,r.addEventListener("updateend",this._onSBUpdateEnd.bind(this,e)),r.addEventListener("error",this._onSBUpdateError.bind(this,e))}}},{key:"changeType",value:function(e,t){var r=this,i=this._sourceBuffer[e];return!this.mediaSource||!i||i.mimeType===t?Promise.resolve():typeof i.changeType!="function"?Promise.reject():this._enqueueOp(e,function(){i.changeType(t),i.mimeType=t,r._onSBUpdateEnd(e)},"changeType",{mimeType:t})}},{key:"createOrChangeSource",value:function(e,t){return this.createSource(e,t),this.changeType(e,t)}},{key:"append",value:function(e,t,r){var i=this;return!t||!t.byteLength||!this._sourceBuffer[e]?Promise.resolve():this._enqueueOp(e,function(){var s;!i.mediaSource||i.media.error||(i._logger.debug("MSE APPEND START",r),i._opst=Se(),(s=i._sourceBuffer[e])===null||s===void 0||s.appendBuffer(t))},Ne.APPEND,r)}},{key:"remove",value:function(e,t,r,i){var s=this,o=!1;return this._mseFullFlag[e]&&(o=!0),this._enqueueOp(e,function(){if(!(!s.mediaSource||s.media.error)){var u=s._sourceBuffer[e];if(t>=r||!u){s._onSBUpdateEnd(e);return}s._opst=Se(),s._logger.debug("MSE REMOVE START",e,t,r,i),u.remove(t,r)}},Ne.REMOVE,i,o)}},{key:"clearBuffer",value:function(e,t){var r=this,i;return Object.keys(this._sourceBuffer).forEach(function(s){i=r.remove(s,e,t)}),i||Promise.resolve()}},{key:"clearAllBuffer",value:function(){var e=this,t;return Object.keys(this._sourceBuffer).forEach(function(r){var i=e._sourceBuffer[r];t=e.remove(r,0,ee.end(ee.get(i)))}),t}},{key:"clearOpQueues",value:function(e,t){var r;this._logger.debug("MSE clearOpQueue START");var i=this._queue[e];if(t&&i){this._queue[e]=[];return}if(!(!i||!i[e]||i.length<5)){var s=[];i.forEach(function(o){o.context&&o.context.isinit&&s.push(o)}),this._queue[e]=i.slice(0,2),s.length>0&&(r=this._queue[e]).push.apply(r,s)}}},{key:"endOfStream",value:function(e){var t=this;return!this.mediaSource||this.mediaSource.readyState!=="open"?Promise.resolve():this._enqueueBlockingOp(function(){var r=t.mediaSource;!r||r.readyState!=="open"||(t._logger.debug("MSE endOfStream START"),e?r.endOfStream(e):r.endOfStream())},"endOfStream")}},{key:"setLiveSeekableRange",value:function(e,t){var r=this.mediaSource;e<0||t<e||!(r!=null&&r.setLiveSeekableRange)||r.readyState!=="open"||r.setLiveSeekableRange(e,t)}},{key:"getSourceBuffer",value:function(e){return this._sourceBuffer[e]}},{key:"buffered",value:function(e){return ee.get(this._sourceBuffer[e])}},{key:"bufferStart",value:function(e){return ee.start(this.buffered(e))}},{key:"bufferEnd",value:function(e){return ee.end(this.buffered(e))}},{key:"_enqueueOp",value:function(e,t,r,i,s){var o=this;if(!this.mediaSource)return Promise.resolve();var u=this._queue[e]=this._queue[e]||[],l={exec:t,promise:Ee(),opName:r,context:i};return s?(u.splice(0,0,l),this._mseFullFlag[e]=!1,this._startQueue(e)):u.push(l),this.isOpened||this.isEnded?u.length===1&&this._startQueue(e):this._openPromise.then(function(){u.length===1&&o._startQueue(e)}),l.promise}},{key:"_enqueueBlockingOp",value:function(){var a=fe(K().mark(function t(r,i,s){var o=this,u,l;return K().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(this.mediaSource){c.next=2;break}return c.abrupt("return",Promise.resolve());case 2:if(u=Object.keys(this._sourceBuffer),u.length){c.next=5;break}return c.abrupt("return",r());case 5:return l=[],u.forEach(function(p){var _=o._queue[p],m=Ee();l.push(m),_.push({exec:function(){m.resolve()},promise:m,opName:i,context:s}),_.length===1&&o._startQueue(p)}),c.abrupt("return",Promise.all(l).then(function(){try{return r()}finally{u.forEach(function(p){var _=o._queue[p],m=o._sourceBuffer[p];_?.shift(),(!m||!m.updating)&&o._startQueue(p)})}}));case 8:case"end":return c.stop()}},t,this)}));function e(t,r,i){return a.apply(this,arguments)}return e}()},{key:"_startQueue",value:function(e){var t=this._queue[e];if(t){var r=t[0];if(r&&!this._mseFullFlag[e])try{r.exec()}catch(i){i&&i.message&&i.message.indexOf("SourceBuffer is full")>=0?(this._mseFullFlag[e]=!0,this._logger.error("[MSE error], context,",r.context," ,name,",r.opName,",err,SourceBuffer is full"),r.promise.reject(new ce(V.MEDIA,V.SUB_TYPES.MSE_FULL,i))):(this._logger.error(i),r.promise.reject(new ce(V.MEDIA,V.SUB_TYPES.MSE_OTHER,i)),t.shift(),this._startQueue(e))}}}},{key:"setTimeoffset",value:function(e,t,r){var i=this;return this._enqueueOp(e,function(){t<0&&(t+=.001),i._sourceBuffer[e].timestampOffset=t,i._onSBUpdateEnd(e)},"setTimeoffset",r)}},{key:"abort",value:function(e,t){var r=this;return this.isOpened?this._enqueueOp(e,function(){r._sourceBuffer[e].abort(),r._onSBUpdateEnd(e)},"abort",t):Promise.resolve()}}],[{key:"isSupported",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:'video/mp4; codecs="avc1.42E01E,mp4a.40.2"',t=Tt();if(!t)return!1;try{return t.isTypeSupported(e)}catch(r){return this._logger.error(e,r),!1}}},{key:"getDefaultConfig",value:function(){return{openLog:!1,preferMMS:!1}}}]),n}();E(Le,"VIDEO","video"),E(Le,"AUDIO","audio");var ye={FETCH:"fetch",XHR:"xhr"},Pe={ARRAY_BUFFER:"arraybuffer",TEXT:"text",JSON:"json"},se=function(n){ke(e,n);var a=De(e);function e(t,r,i,s){var o;return te(this,e),o=a.call(this,s),E(L(o),"retryCount",0),E(L(o),"isTimeout",!1),E(L(o),"loaderType",ye.FETCH),E(L(o),"startTime",0),E(L(o),"endTime",0),E(L(o),"options",{}),o.url=t,o.request=r,o.response=i,o}return re(e)}(Ue(Error)),At=Object.prototype.toString;function dr(n){return n!==null&&be(n)==="object"}function kt(n){if(At.call(n)!=="[object Object]")return!1;var a=Object.getPrototypeOf(n);return a===null||a===Object.prototype}function vr(n){return At.call(n)==="[object Date]"}function Ot(n){if(!(!n||n[0]===null||n[0]===void 0||n[0]===0&&(n[1]===null||n[1]===void 0))){var a="bytes="+n[0]+"-";return n[1]&&(a+=n[1]),a}}function Dt(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Rt(n,a){if(n){if(!a)return n;var e,t=Object.keys(a).map(function(i){if(e=a[i],e!=null)return Array.isArray(e)?i=i+"[]":e=[e],e.map(function(s){return vr(s)?s=s.toISOString():dr(s)&&(s=JSON.stringify(s)),"".concat(Dt(i),"=").concat(Dt(s))}).join("&")}).filter(Boolean).join("&");if(t){var r=n.indexOf("#");r!==-1&&(n=n.slice(0,r)),n+=(n.indexOf("?")===-1?"?":"&")+t}return n}}function Qe(n,a,e,t,r,i,s,o,u,l,f){r=r!=null?parseFloat(r):null,t=parseInt(t||"0",10),Number.isNaN(t)&&(t=0);var c={range:u,vid:l,index:o,contentLength:t,age:r,startTime:i,firstByteTime:s,endTime:Date.now(),priOptions:f};return{data:n,done:a,options:c,response:e}}function Je(n,a){return Math.round(n*8*1e3/a/1024)}var x={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",ANALYZE_DURATION_EXCEEDED:"core.analyzedurationexceeded",REMOVE_BUFFER:"core.removebuffer",BUFFEREOS:"core.buffereos",KEYFRAME:"core.keyframe",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"},Lt={exports:{}};(function(n){var a=Object.prototype.hasOwnProperty,e="~";function t(){}Object.create&&(t.prototype=Object.create(null),new t().__proto__||(e=!1));function r(u,l,f){this.fn=u,this.context=l,this.once=f||!1}function i(u,l,f,c,p){if(typeof f!="function")throw new TypeError("The listener must be a function");var _=new r(f,c||u,p),m=e?e+l:l;return u._events[m]?u._events[m].fn?u._events[m]=[u._events[m],_]:u._events[m].push(_):(u._events[m]=_,u._eventsCount++),u}function s(u,l){--u._eventsCount===0?u._events=new t:delete u._events[l]}function o(){this._events=new t,this._eventsCount=0}o.prototype.eventNames=function(){var l=[],f,c;if(this._eventsCount===0)return l;for(c in f=this._events)a.call(f,c)&&l.push(e?c.slice(1):c);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(f)):l},o.prototype.listeners=function(l){var f=e?e+l:l,c=this._events[f];if(!c)return[];if(c.fn)return[c.fn];for(var p=0,_=c.length,m=new Array(_);p<_;p++)m[p]=c[p].fn;return m},o.prototype.listenerCount=function(l){var f=e?e+l:l,c=this._events[f];return c?c.fn?1:c.length:0},o.prototype.emit=function(l,f,c,p,_,m){var b=e?e+l:l;if(!this._events[b])return!1;var v=this._events[b],w=arguments.length,D,O;if(v.fn){switch(v.once&&this.removeListener(l,v.fn,void 0,!0),w){case 1:return v.fn.call(v.context),!0;case 2:return v.fn.call(v.context,f),!0;case 3:return v.fn.call(v.context,f,c),!0;case 4:return v.fn.call(v.context,f,c,p),!0;case 5:return v.fn.call(v.context,f,c,p,_),!0;case 6:return v.fn.call(v.context,f,c,p,_,m),!0}for(O=1,D=new Array(w-1);O<w;O++)D[O-1]=arguments[O];v.fn.apply(v.context,D)}else{var k=v.length,A;for(O=0;O<k;O++)switch(v[O].once&&this.removeListener(l,v[O].fn,void 0,!0),w){case 1:v[O].fn.call(v[O].context);break;case 2:v[O].fn.call(v[O].context,f);break;case 3:v[O].fn.call(v[O].context,f,c);break;case 4:v[O].fn.call(v[O].context,f,c,p);break;default:if(!D)for(A=1,D=new Array(w-1);A<w;A++)D[A-1]=arguments[A];v[O].fn.apply(v[O].context,D)}}return!0},o.prototype.on=function(l,f,c){return i(this,l,f,c,!1)},o.prototype.once=function(l,f,c){return i(this,l,f,c,!0)},o.prototype.removeListener=function(l,f,c,p){var _=e?e+l:l;if(!this._events[_])return this;if(!f)return s(this,_),this;var m=this._events[_];if(m.fn)m.fn===f&&(!p||m.once)&&(!c||m.context===c)&&s(this,_);else{for(var b=0,v=[],w=m.length;b<w;b++)(m[b].fn!==f||p&&!m[b].once||c&&m[b].context!==c)&&v.push(m[b]);v.length?this._events[_]=v.length===1?v[0]:v:s(this,_)}return this},o.prototype.removeAllListeners=function(l){var f;return l?(f=e?e+l:l,this._events[f]&&s(this,f)):(this._events=new t,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=e,o.EventEmitter=o,n.exports=o})(Lt);var pr=Lt.exports;const Ze=pt(pr);var Pt=2*1024*1024,et=function(n){ke(e,n);var a=De(e);function e(){var t;return te(this,e),t=a.call(this),E(L(t),"_abortController",null),E(L(t),"_timeoutTimer",null),E(L(t),"_reader",null),E(L(t),"_response",null),E(L(t),"_aborted",!1),E(L(t),"_index",-1),E(L(t),"_range",null),E(L(t),"_receivedLength",0),E(L(t),"_running",!1),E(L(t),"_logger",null),E(L(t),"_vid",""),E(L(t),"_onProcessMinLen",0),E(L(t),"_onCancel",null),E(L(t),"_priOptions",null),t}return re(e,[{key:"load",value:function(r){var i,s=this,o=r.url,u=r.vid,l=r.timeout,f=r.responseType,c=r.onProgress,p=r.index,_=r.onTimeout,m=r.onCancel,b=r.range,v=r.transformResponse,w=r.request,D=r.params,O=r.logger,k=r.method,A=r.headers,j=r.body,Q=r.mode,W=r.credentials,q=r.cache,N=r.redirect,ie=r.referrer,d=r.referrerPolicy,h=r.onProcessMinLen,g=r.priOptions;this._logger=O,this._aborted=!1,this._onProcessMinLen=h,this._onCancel=m,this._abortController=typeof AbortController<"u"&&new AbortController,this._running=!0,this._index=p,this._range=b||[0,0],this._vid=u||o,this._priOptions=g||{};var T={method:k,headers:A,body:j,mode:Q,credentials:W,cache:q,redirect:N,referrer:ie,referrerPolicy:d,signal:(i=this._abortController)===null||i===void 0?void 0:i.signal},y=!1;clearTimeout(this._timeoutTimer),o=Rt(o,D);var R=Ot(b);R&&(w?A=w.headers:A=T.headers=T.headers||(Headers?new Headers:{}),Headers&&A instanceof Headers?A.append("Range",R):A.Range=R),l&&(this._timeoutTimer=setTimeout(function(){if(y=!0,s.cancel(),_){var U=new se(o,T,null,"timeout");U.isTimeout=!0,_(U,{index:s._index,range:s._range,vid:s._vid,priOptions:s._priOptions})}},l));var P=Date.now();return this._logger.debug("[fetch load start], index,",p,",range,",b),new Promise(function(U,F){fetch(w||o,w?void 0:T).then(function(){var $=fe(K().mark(function X(G){var We,pe,Ke,ut;return K().wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:if(clearTimeout(s._timeoutTimer),s._response=G,!(s._aborted||!s._running)){Y.next=4;break}return Y.abrupt("return");case 4:if(v&&(G=v(G,o)||G),G.ok){Y.next=7;break}throw new se(o,T,G,"bad network response");case 7:if(We=Date.now(),f!==Pe.TEXT){Y.next=15;break}return Y.next=11,G.text();case 11:pe=Y.sent,s._running=!1,Y.next=37;break;case 15:if(f!==Pe.JSON){Y.next=22;break}return Y.next=18,G.json();case 18:pe=Y.sent,s._running=!1,Y.next=37;break;case 22:if(!c){Y.next=29;break}return s.resolve=U,s.reject=F,s._loadChunk(G,c,P,We),Y.abrupt("return");case 29:return Y.next=31,G.arrayBuffer();case 31:pe=Y.sent,pe=new Uint8Array(pe),s._running=!1,Ke=Date.now()-P,ut=Je(pe.byteLength,Ke),s.emit(x.REAL_TIME_SPEED,{speed:ut,len:pe.byteLength,time:Ke,vid:s._vid,index:s._index,range:s._range,priOptions:s._priOptions});case 37:s._logger.debug("[fetch load end], index,",p,",range,",b),U(Qe(pe,!0,G,G.headers.get("Content-Length"),G.headers.get("age"),P,We,p,b,s._vid,s._priOptions));case 39:case"end":return Y.stop()}},X)}));return function(X){return $.apply(this,arguments)}}()).catch(function($){var X;clearTimeout(s._timeoutTimer),s._running=!1,!(s._aborted&&!y)&&($=$ instanceof se?$:new se(o,T,null,(X=$)===null||X===void 0?void 0:X.message),$.startTime=P,$.endTime=Date.now(),$.isTimeout=y,$.options={index:s._index,range:s._range,vid:s._vid,priOptions:s._priOptions},F($))})})}},{key:"cancel",value:function(){var t=fe(K().mark(function i(){return K().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(!this._aborted){o.next=2;break}return o.abrupt("return");case 2:if(this._aborted=!0,this._running=!1,!this._response){o.next=14;break}if(o.prev=5,!this._reader){o.next=9;break}return o.next=9,this._reader.cancel();case 9:o.next=13;break;case 11:o.prev=11,o.t0=o.catch(5);case 13:this._response=this._reader=null;case 14:if(this._abortController){try{this._abortController.abort()}catch{}this._abortController=null}this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions});case 16:case"end":return o.stop()}},i,this,[[5,11]])}));function r(){return t.apply(this,arguments)}return r}()},{key:"_loadChunk",value:function(r,i,s,o){var u=this;if(!r.body||!r.body.getReader){this._running=!1;var l=new se(r.url,"",r,"onProgress of bad response.body.getReader");l.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this.reject(l);return}this._onProcessMinLen>0&&(this._cache=new Uint8Array(Pt),this._writeIdx=0);var f=this._reader=r.body.getReader(),c,p,_,m=function(){var b=fe(K().mark(function v(){var w,D,O,k,A,j,Q,W;return K().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:return p=Date.now(),N.prev=1,N.next=4,f.read();case 4:c=N.sent,_=Date.now(),N.next=13;break;case 8:return N.prev=8,N.t0=N.catch(1),_=Date.now(),u._aborted||(u._running=!1,N.t0.options={index:u._index,range:u._range,vid:u._vid,priOptions:u._priOptions},u.reject(N.t0)),N.abrupt("return");case 13:if(D=((w=u._range)===null||w===void 0?void 0:w.length)>0?u._range[0]:0,O=D+u._receivedLength,!u._aborted){N.next=19;break}return u._running=!1,i(void 0,!1,{range:[O,O],vid:u._vid,index:u._index,startTime:p,endTime:_,st:s,firstByteTime:o,priOptions:u._priOptions},r),N.abrupt("return");case 19:k=c.value?c.value.byteLength:0,u._receivedLength+=k,u._logger.debug("\u3010fetchLoader,onProgress call\u3011,task,",u._range,", start,",O,", end,",D+u._receivedLength,", done,",c.done),u._onProcessMinLen>0?u._writeIdx+k>=u._onProcessMinLen||c.done?(A=new Uint8Array(u._writeIdx+k),A.set(u._cache.slice(0,u._writeIdx),0),k>0&&A.set(c.value,u._writeIdx),u._writeIdx=0,u._logger.debug("\u3010fetchLoader,onProgress enough\u3011,done,",c.done,",len,",A.byteLength,", writeIdx,",u._writeIdx)):k>0&&u._writeIdx+k<Pt?(u._cache.set(c.value,u._writeIdx),u._writeIdx+=k,u._logger.debug("\u3010fetchLoader,onProgress cache\u3011,len,",k,", writeIdx,",u._writeIdx)):k>0&&(j=new Uint8Array(u._writeIdx+k+2048),u._logger.debug("\u3010fetchLoader,onProgress extra start\u3011,size,",u._writeIdx+k+2048,", datalen,",k,", writeIdx,",u._writeIdx),j.set(u._cache.slice(0,u._writeIdx),0),k>0&&j.set(c.value,u._writeIdx),u._writeIdx+=k,delete u._cache,u._cache=j,u._logger.debug("\u3010fetchLoader,onProgress extra end\u3011,len,",k,", writeIdx,",u._writeIdx)):A=c.value,(A&&A.byteLength>0||c.done)&&i(A,c.done,{range:[u._range[0]+u._receivedLength-(A?A.byteLength:0),u._range[0]+u._receivedLength],vid:u._vid,index:u._index,startTime:p,endTime:_,st:s,firstByteTime:o,priOptions:u._priOptions},r),c.done?(Q=Date.now()-s,W=Je(u._receivedLength,Q),u.emit(x.REAL_TIME_SPEED,{speed:W,len:u._receivedLength,time:Q,vid:u._vid,index:u._index,range:u._range,priOptions:u._priOptions}),u._running=!1,u._logger.debug("[fetchLoader onProgress end],task,",u._range,",done,",c.done),u.resolve(Qe(c,!0,r,r.headers.get("Content-Length"),r.headers.get("age"),s,o,u._index,u._range,u._vid,u._priOptions))):m();case 25:case"end":return N.stop()}},v,null,[[1,8]])}));return function(){return b.apply(this,arguments)}}();m()}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(r){this._running=r}}],[{key:"isSupported",value:function(){return typeof fetch<"u"}}]),e}(Ze);function _r(n){return Ae({loaderType:ye.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:Pe.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},n)}var mr=function(n){ke(e,n);var a=De(e);function e(){var t;return te(this,e),t=a.call(this),E(L(t),"_xhr",null),E(L(t),"_aborted",!1),E(L(t),"_timeoutTimer",null),E(L(t),"_range",null),E(L(t),"_receivedLength",0),E(L(t),"_url",null),E(L(t),"_onProgress",null),E(L(t),"_index",-1),E(L(t),"_headers",null),E(L(t),"_currentChunkSizeKB",384),E(L(t),"_timeout",null),E(L(t),"_xhr",null),E(L(t),"_withCredentials",null),E(L(t),"_startTime",-1),E(L(t),"_loadCompleteResolve",null),E(L(t),"_loadCompleteReject",null),E(L(t),"_runing",!1),E(L(t),"_logger",!1),E(L(t),"_vid",""),E(L(t),"_responseType",void 0),E(L(t),"_credentials",void 0),E(L(t),"_method",void 0),E(L(t),"_transformResponse",void 0),E(L(t),"_firstRtt",void 0),E(L(t),"_onCancel",null),E(L(t),"_priOptions",null),t}return re(e,[{key:"load",value:function(r){var i=this;clearTimeout(this._timeoutTimer),this._logger=r.logger,this._range=r.range,this._onProgress=r.onProgress,this._index=r.index,this._headers=r.headers,this._withCredentials=r.credentials==="include"||r.credentials==="same-origin",this._body=r.body||null,r.method&&(this._method=r.method),this._timeout=r.timeout||null,this._runing=!0,this._vid=r.vid||r.url,this._responseType=r.responseType,this._firstRtt=-1,this._onTimeout=r.onTimeout,this._onCancel=r.onCancel,this._request=r.request,this._priOptions=r.priOptions||{},this._logger.debug("\u3010xhrLoader task\u3011, range",this._range),this._url=Rt(r.url,r.params);var s=Date.now();return new Promise(function(o,u){i._loadCompleteResolve=o,i._loadCompleteReject=u,i._startLoad()}).catch(function(o){if(clearTimeout(i._timeoutTimer),i._runing=!1,!i._aborted)throw o=o instanceof se?o:new se(i._url,i._request),o.startTime=s,o.endTime=Date.now(),o.options={index:i._index,vid:i._vid,priOptions:i._priOptions},o})}},{key:"_startLoad",value:function(){var r=null;if(this._responseType===Pe.ARRAY_BUFFER&&this._range&&this._range.length>1)if(this._onProgress){this._firstRtt=-1;var i=this._currentChunkSizeKB*1024,s=this._range[0]+this._receivedLength,o=this._range[1];i<this._range[1]-s&&(o=s+i),r=[s,o],this._logger.debug("[xhr_loader->],tast :",this._range,", SubRange, ",r)}else r=this._range,this._logger.debug("[xhr_loader->],tast :",this._range,", allRange, ",r);this._internalOpen(r)}},{key:"_internalOpen",value:function(r){var i=this;try{this._startTime=Date.now();var s=this._xhr=new XMLHttpRequest;s.open(this._method||"GET",this._url,!0),s.responseType=this._responseType,this._timeout&&(s.timeout=this._timeout),s.withCredentials=this._withCredentials,s.onload=this._onLoad.bind(this),s.onreadystatechange=this._onReadyStatechange.bind(this),s.onerror=function(l){var f,c,p;i._running=!1;var _=new se(i._url,i._request,l==null||(f=l.currentTarget)===null||f===void 0?void 0:f.response,"xhr.onerror.status:"+(l==null||(c=l.currentTarget)===null||c===void 0?void 0:c.status)+",statusText,"+(l==null||(p=l.currentTarget)===null||p===void 0?void 0:p.statusText));_.options={index:i._index,range:i._range,vid:i._vid,priOptions:i._priOptions},i._loadCompleteReject(_)},s.ontimeout=function(l){i.cancel();var f=new se(i._url,i._request,{status:408},"timeout");i._onTimeout&&(f.isTimeout=!0,i._onTimeout(f,{index:i._index,range:i._range,vid:i._vid,priOptions:i._priOptions})),f.options={index:i._index,range:i._range,vid:i._vid,priOptions:i._priOptions},i._loadCompleteReject(f)};var o=this._headers||{},u=Ot(r);u&&(o.Range=u),o&&Object.keys(o).forEach(function(l){s.setRequestHeader(l,o[l])}),this._logger.debug("[xhr.send->] tast,",this._range,",load sub range, ",r),s.send(this._body)}catch(l){l.options={index:this._index,range:r,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(l)}}},{key:"_onReadyStatechange",value:function(r){var i=r.target;i.readyState===2&&this._firstRtt<0&&(this._firstRtt=Date.now())}},{key:"_onLoad",value:function(r){var i,s=r.target.status;if(s<200||s>299){var o=new se(this._url,null,Ae(Ae({},r.target.response),{},{status:s}),"bad response,status:"+s);return o.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(o)}var u=null,l=!1,f,c=((i=this._range)===null||i===void 0?void 0:i.length)>0?this._range[0]:0;if(this._responseType===Pe.ARRAY_BUFFER){var p,_=new Uint8Array(r.target.response);if(f=c+this._receivedLength,_&&_.byteLength>0){this._receivedLength+=_.byteLength;var m=Date.now()-this._startTime,b=Je(this._receivedLength,m);this.emit(x.REAL_TIME_SPEED,{speed:b,len:this._receivedLength,time:m,vid:this._vid,index:this._index,range:[f,c+this._receivedLength],priOptions:this._priOptions})}u=_,((p=this._range)===null||p===void 0?void 0:p.length)>1&&this._range[1]&&this._receivedLength<this._range[1]-this._range[0]?l=!1:l=!0,this._logger.debug("[xhr load done->], tast :",this._range,", start",f,"end ",c+this._receivedLength,",dataLen,",_?_.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",l)}else l=!0,u=r.target.response;var v={ok:s>=200&&s<300,status:s,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};this._transformResponse&&(v=this._transformResponse(v,this._url)||v),this._onProgress&&this._onProgress(u,l,{index:this._index,vid:this._vid,range:[f,c+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},v),l?(this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(Qe(this._onProgress?null:u,l,v,v.headers["content-length"],v.headers.age,this._startTime,this._firstRtt,this._index,this._range,this._vid,this._priOptions))):this._startLoad()}},{key:"cancel",value:function(){if(!this._aborted&&(this._aborted=!0,this._runing=!1,Me(ge(e.prototype),"removeAllListeners",this).call(this),this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions}),this._xhr))return this._xhr.abort()}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(r){this._running=r}},{key:"_getHeaders",value:function(r){var i=r.getAllResponseHeaders().trim().split(`\r
4
- `),s={},o=or(i),u;try{for(o.s();!(u=o.n()).done;){var l=u.value,f=l.split(": ");s[f[0].toLowerCase()]=f.slice(1).join(": ")}}catch(c){o.e(c)}finally{o.f()}return s}}],[{key:"isSupported",value:function(){return typeof XMLHttpRequest<"u"}}]),e}(Ze),gr=["retry","retryDelay","onRetryError","transformError"],yr=function(){function n(a,e){te(this,n),this.promise=Ee(),this.alive=!!e.onProgress,!e.logger&&(e.logger=new _e("Loader")),this._loaderType=a,this._loader=a===ye.FETCH&&typeof fetch<"u"?new et:new mr,this._config=e,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=e.retryCheckFunc,this._logger=e.logger}return re(n,[{key:"exec",value:function(){var e=this,t=this._config,r=t.retry,i=t.retryDelay,s=t.onRetryError,o=t.transformError,u=nr(t,gr),l=function(){var f=fe(K().mark(function c(){var p,_,m;return K().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return v.prev=0,v.next=3,e._loader.load(u);case 3:p=v.sent,e.promise.resolve(p),v.next=27;break;case 7:if(v.prev=7,v.t0=v.catch(0),e._loader.running=!1,e._logger.debug("[task request catch err]",v.t0),!e._canceled){v.next=13;break}return v.abrupt("return");case 13:if(v.t0.loaderType=e._loaderType,v.t0.retryCount=e._retryCount,_=v.t0,o&&(_=o(_)||_),s&&e._retryCount>0&&s(_,e._retryCount,{index:u.index,vid:u.vid,range:u.range,priOptions:u.priOptions}),e._retryCount++,m=!0,e._retryCheckFunc&&(m=e._retryCheckFunc(v.t0)),!(m&&e._retryCount<=r)){v.next=26;break}return clearTimeout(e._retryTimer),e._logger.debug("[task request setTimeout],retry",e._retryCount,",retry range,",u.range),e._retryTimer=setTimeout(l,i),v.abrupt("return");case 26:e.promise.reject(_);case 27:case"end":return v.stop()}},c,null,[[0,7]])}));return function(){return f.apply(this,arguments)}}();return l(),this.promise}},{key:"cancel",value:function(){var a=fe(K().mark(function t(){return K().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return clearTimeout(this._retryTimer),this._canceled=!0,this._loader.running=!1,i.abrupt("return",this._loader.cancel());case 4:case"end":return i.stop()}},t,this)}));function e(){return a.apply(this,arguments)}return e}()},{key:"running",get:function(){return this._loader&&this._loader.running}},{key:"loader",get:function(){return this._loader}}]),n}();function br(n){return n&&!n.paused&&!n.ended&&n.playbackRate!==0&&n.readyState!==0}function Er(n){if(!n)return{};if(typeof n.getVideoPlaybackQuality=="function"){var a=n.getVideoPlaybackQuality();return{droppedVideoFrames:a.droppedVideoFrames||a.corruptedVideoFrames,totalVideoFrames:a.totalVideoFrames,creationTime:a.creationTime}}return{droppedVideoFrames:n.webkitDroppedFrameCount,totalVideoFrames:n.webkitDecodedFrameCount,creationTime:performance.now()}}function Sr(){for(var n=arguments.length,a=new Array(n),e=0;e<n;e++)a[e]=arguments[e];if(a=a.filter(Boolean),a.length<2)return a[0];var t=new Uint8Array(a.reduce(function(i,s){return i+s.byteLength},0)),r=0;return a.forEach(function(i){t.set(i,r),r+=i.byteLength}),t}function wr(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return new Promise(function(a){return setTimeout(a,n)})}var Tr=function(n){ke(e,n);var a=De(e);function e(t){var r;return te(this,e),r=a.call(this,t),E(L(r),"type",ye.FETCH),E(L(r),"_queue",[]),E(L(r),"_alive",[]),E(L(r),"_currentTask",null),E(L(r),"_finnalUrl",""),E(L(r),"_config",void 0),r._config=_r(t),(r._config.loaderType===ye.XHR||!et.isSupported())&&(r.type=ye.XHR),r.log=t.logger,r}return re(e,[{key:"isFetch",value:function(){return this.type===ye.FETCH}},{key:"load",value:function(r){var i=this,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};typeof r=="string"||!r?s.url=r||s.url||this._config.url:s=r,s=Object.assign({},this._config,s),s.params&&(s.params=Object.assign({},s.params)),s.headers&&kt(s.headers)&&(s.headers=Object.assign({},s.headers)),s.body&&kt(s.body)&&(s.body=Object.assign({},s.body)),s.transformRequest&&(s=s.transformRequest(s)||s),s.logger=this.log;var o=new yr(this.type,s);return o.loader.on(x.REAL_TIME_SPEED,function(u){i.emit(x.REAL_TIME_SPEED,u)}),this._queue.push(o),this._queue.length===1&&(!this._currentTask||!this._currentTask.running)&&this._processTask(),o.promise}},{key:"cancel",value:function(){var t=fe(K().mark(function i(){var s;return K().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return s=this._queue.map(function(l){return l.cancel()}).concat(this._alive.map(function(l){return l.cancel()})),this._currentTask&&s.push(this._currentTask.cancel()),this._queue=[],this._alive=[],u.next=6,Promise.all(s);case 6:return u.next=8,wr();case 8:case"end":return u.stop()}},i,this)}));function r(){return t.apply(this,arguments)}return r}()},{key:"_processTask",value:function(){var r=this;if(this._currentTask=this._queue.shift(),!!this._currentTask){this._currentTask.alive&&this._alive.push(this._currentTask);var i=this._currentTask.exec().catch(function(s){});i&&typeof i.finally=="function"&&i.finally(function(){var s,o;(s=r._currentTask)!==null&&s!==void 0&&s.alive&&((o=r._alive)===null||o===void 0?void 0:o.length)>0&&(r._alive=r._alive.filter(function(u){return u&&u!==r._currentTask})),r._processTask()})}}}],[{key:"isFetchSupport",value:function(){return et.isSupported()}}]),e}(Ze),Ar=function(){function n(){te(this,n),E(this,"_prevCurrentTime",0)}return re(n,[{key:"do",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3,r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;if(e){var s=e.currentTime,o=0;if(this._prevCurrentTime===s){var u=ee.info(ee.get(e),s);if(!u.buffers.length)return;r&&u.nextStart||u.nextStart&&u.nextStart-s<t?o=u.nextStart+.1:u.end&&u.end-s>i&&!e.seeking&&(o=s+.1)}this._prevCurrentTime=s,o&&s!==o&&(e.currentTime=o)}}}]),n}(),kr=function(){function n(a){var e=this;te(this,n),E(this,"_seiSet",new Set),this.emitter=a,a.on(x.SEI,function(t){t&&e._seiSet.add(t)})}return re(n,[{key:"throw",value:function(e,t){var r=this;if(!(e==null||!this._seiSet.size)){var i=e-.2,s=e+.2,o=[];this._seiSet.forEach(function(u){u.time>=i&&u.time<=s&&o.push(u)}),o.forEach(function(u){r._seiSet.delete(u),r.emitter.emit(x.SEI_IN_TIME,u)}),t&&this._seiSet.forEach(function(u){u.time<e-5&&r._seiSet.delete(u)})}}},{key:"reset",value:function(){this._seiSet.clear()}}]),n}(),Or=function(){function n(){te(this,n),E(this,"_chunkSpeeds",[]),E(this,"_speeds",[])}return re(n,[{key:"addRecord",value:function(e,t){!e||!t||(this._speeds.push(8e3*e/t),this._speeds=this._speeds.slice(-3))}},{key:"addChunkRecord",value:function(e,t){!e||!t||(this._chunkSpeeds.push(8e3*e/t),this._chunkSpeeds=this._chunkSpeeds.slice(-100))}},{key:"getAvgSpeed",value:function(){return!this._chunkSpeeds.length&&!this._speeds.length?0:this._speeds.length?this._speeds.reduce(function(e,t){return e+=t})/this._speeds.length:this._chunkSpeeds.reduce(function(e,t){return e+=t})/this._chunkSpeeds.length}},{key:"getLatestSpeed",value:function(){return!this._chunkSpeeds.length&&!this._speeds.length?0:this._speeds.length?this._speeds[this._speeds.length-1]:this._chunkSpeeds[this._chunkSpeeds.length-1]}},{key:"reset",value:function(){this._chunkSpeeds=[],this._speeds=[]}}]),n}(),Ct=function(){function n(a){te(this,n),E(this,"encodeType",""),E(this,"audioCodec",""),E(this,"videoCodec",""),E(this,"domain",""),E(this,"fps",0),E(this,"bitrate",0),E(this,"width",0),E(this,"height",0),E(this,"samplerate",0),E(this,"channelCount",0),E(this,"gop",0),E(this,"_bitsAccumulateSize",0),E(this,"_bitsAccumulateDuration",0),E(this,"_startGopId",-1),this._timescale=a}return re(n,[{key:"getStats",value:function(){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(e){this.encodeType=e}},{key:"setFpsFromScriptData",value:function(e){var t,r=e.data,i=r==null||(t=r.onMetaData)===null||t===void 0?void 0:t.framerate;i&&i>0&&i<100&&(this.fps=i)}},{key:"setVideoMeta",value:function(e){if(this.width=e.width,this.height=e.height,this.videoCodec=e.codec,this.encodeType=e.codecType,e.fpsNum&&e.fpsDen){var t=e.fpsNum/e.fpsDen;t>0&&t<100&&(this.fps=t)}}},{key:"setAudioMeta",value:function(e){this.audioCodec=e.codec,this.samplerate=e.sampleRate,this.channelCount=e.channelCount}},{key:"setDomain",value:function(e){this.domain=e.split("/").slice(2,3)[0]}},{key:"updateBitrate",value:function(e){var t=this;if((!this.fps||this.fps>=100)&&e.length){var r=e.reduce(function(i,s){return i+=s.duration},0)/e.length;this.fps=Math.round(this._timescale/r)}e.forEach(function(i){t._startGopId===-1&&(t._startGopId=i.gopId),i.gopId===t._startGopId&&t.gop++,t._bitsAccumulateDuration+=i.duration/(t._timescale/1e3),t._bitsAccumulateSize+=i.units.reduce(function(s,o){return s+=o.length},0),t._bitsAccumulateDuration>=1e3&&(t.bitrate=t._bitsAccumulateSize*8,t._bitsAccumulateDuration=0,t._bitsAccumulateSize=0)})}}]),n}(),Dr=function(){function n(a){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1e3;te(this,n),E(this,"_core",null),E(this,"_samples",[]),this._core=a,this._timescale=e,this._stats=new Ct(e),this._bindEvents()}return re(n,[{key:"getStats",value:function(){var e,t,r,i,s,o,u,l=((e=this._core)===null||e===void 0?void 0:e.media)||{},f=l.currentTime,c=f===void 0?0:f,p=l.decodeFps,_=p===void 0?0:p;return Ae(Ae({},this._stats.getStats()),{},{downloadSpeed:((t=this._core)===null||t===void 0||(r=t.speedInfo)===null||r===void 0?void 0:r.call(t).speed)||0,avgSpeed:((i=this._core)===null||i===void 0||(s=i.speedInfo)===null||s===void 0?void 0:s.call(i).avgSpeed)||0,currentTime:c,bufferEnd:((o=this._core)===null||o===void 0||(u=o.bufferInfo())===null||u===void 0?void 0:u.remaining)||0,decodeFps:_})}},{key:"_bindEvents",value:function(){var e=this;this._core.on(x.DEMUXED_TRACK,function(t){var r=t.videoTrack;return e._stats.updateBitrate(r.samples)}),this._core.on(x.FLV_SCRIPT_DATA,function(t){e._stats.setFpsFromScriptData(t)}),this._core.on(x.METADATA_PARSED,function(t){t.type==="video"?e._stats.setVideoMeta(t.track):e._stats.setAudioMeta(t.track)}),this._core.on(x.TTFB,function(t){e._stats.setDomain(t.responseUrl)})}},{key:"reset",value:function(){this._samples=[],this._stats=new Ct(this._timescale)}}]),n}();function Rr(n,a){var e=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(e!=null){var t,r,i,s,o=[],u=!0,l=!1;try{if(i=(e=e.call(n)).next,a===0){if(Object(e)!==e)return;u=!1}else for(;!(u=(t=i.call(e)).done)&&(o.push(t.value),o.length!==a);u=!0);}catch(f){l=!0,r=f}finally{try{if(!u&&e.return!=null&&(s=e.return(),Object(s)!==s))return}finally{if(l)throw r}}return o}}function H(n,a){if(!(n instanceof a))throw new TypeError("Cannot call a class as a function")}function It(n,a){for(var e=0;e<a.length;e++){var t=a[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(n,Bt(t.key),t)}}function z(n,a,e){return a&&It(n.prototype,a),e&&It(n,e),Object.defineProperty(n,"prototype",{writable:!1}),n}function S(n,a,e){return a=Bt(a),a in n?Object.defineProperty(n,a,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[a]=e,n}function xt(n,a){if(typeof a!="function"&&a!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(a&&a.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),a&&tt(n,a)}function Fe(n){return Fe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Fe(n)}function tt(n,a){return tt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},tt(n,a)}function Lr(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Pr(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function Cr(n,a){if(a&&(typeof a=="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Pr(n)}function Ut(n){var a=Lr();return function(){var t=Fe(n),r;if(a){var i=Fe(this).constructor;r=Reflect.construct(t,arguments,i)}else r=t.apply(this,arguments);return Cr(this,r)}}function Ir(n,a){return Ur(n)||Rr(n,a)||Mt(n,a)||Nr()}function oe(n){return xr(n)||Mr(n)||Mt(n)||Br()}function xr(n){if(Array.isArray(n))return rt(n)}function Ur(n){if(Array.isArray(n))return n}function Mr(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function Mt(n,a){if(n){if(typeof n=="string")return rt(n,a);var e=Object.prototype.toString.call(n).slice(8,-1);if(e==="Object"&&n.constructor&&(e=n.constructor.name),e==="Map"||e==="Set")return Array.from(n);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return rt(n,a)}}function rt(n,a){(a==null||a>n.length)&&(a=n.length);for(var e=0,t=new Array(a);e<a;e++)t[e]=n[e];return t}function Br(){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 Nr(){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 Fr(n,a){if(typeof n!="object"||n===null)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var t=e.call(n,a||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(n)}function Bt(n){var a=Fr(n,"string");return typeof a=="symbol"?a:String(a)}var we={VIDEO:"video",AUDIO:"audio",METADATA:"metadata"},Ce={AVC:"avc",HEVC:"hevc"},me={AAC:"aac",G711PCMA:"g7110a",G711PCMU:"g7110m"},ae={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"},Vr=function(){function n(){H(this,n),S(this,"id",1),S(this,"type",we.VIDEO),S(this,"codecType",Ce.AVC),S(this,"pid",-1),S(this,"hvcC",void 0),S(this,"codec",""),S(this,"timescale",0),S(this,"formatTimescale",0),S(this,"sequenceNumber",0),S(this,"baseMediaDecodeTime",0),S(this,"baseDts",0),S(this,"duration",0),S(this,"warnings",[]),S(this,"samples",[]),S(this,"pps",[]),S(this,"sps",[]),S(this,"vps",[]),S(this,"fpsNum",0),S(this,"fpsDen",0),S(this,"sarRatio",[]),S(this,"width",0),S(this,"height",0),S(this,"nalUnitSize",4),S(this,"present",!1),S(this,"isVideoEncryption",!1),S(this,"isAudioEncryption",!1),S(this,"isVideo",!0),S(this,"kid",null),S(this,"pssh",null),S(this,"ext",void 0)}return z(n,[{key:"reset",value:function(){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:"exist",value:function(){return!!(this.pps.length&&this.sps.length&&this.codec)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isVideoEncryption}}]),n}(),Gr=function(){function n(){H(this,n),S(this,"id",2),S(this,"type",we.AUDIO),S(this,"codecType",me.AAC),S(this,"pid",-1),S(this,"codec",""),S(this,"sequenceNumber",0),S(this,"sampleDuration",0),S(this,"timescale",0),S(this,"formatTimescale",0),S(this,"baseMediaDecodeTime",0),S(this,"duration",0),S(this,"warnings",[]),S(this,"samples",[]),S(this,"baseDts",0),S(this,"sampleSize",16),S(this,"sampleRate",0),S(this,"channelCount",0),S(this,"objectType",0),S(this,"sampleRateIndex",0),S(this,"config",[]),S(this,"present",!1),S(this,"isVideoEncryption",!1),S(this,"isAudioEncryption",!1),S(this,"kid",null),S(this,"ext",void 0)}return z(n,[{key:"reset",value:function(){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(){return!!(this.sampleRate&&this.channelCount&&this.codec&&this.codecType===me.AAC)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isAudioEncryption}}]),n}(),jr=function(){function n(a,e,t){H(this,n),S(this,"flag",{}),S(this,"keyframe",!1),S(this,"gopId",0),S(this,"duration",0),S(this,"size",0),S(this,"units",[]),S(this,"chromaFormat",420),this.originPts=this.pts=a,this.originDts=this.dts=e,t&&(this.units=t)}return z(n,[{key:"cts",get:function(){return this.pts-this.dts}},{key:"setToKeyframe",value:function(){this.keyframe=!0,this.flag.dependsOn=2,this.flag.isNonSyncSample=0}}]),n}(),nt=z(function n(a,e,t,r){H(this,n),S(this,"duration",1024),S(this,"flag",{dependsOn:2,isNonSyncSample:0}),S(this,"keyframe",!0),this.originPts=this.pts=this.dts=a,this.data=e,this.size=e.byteLength,this.sampleOffset=r,t&&(this.duration=t)}),Nt=z(function n(a,e){H(this,n),S(this,"time",0),this.data=a,this.originPts=this.pts=e}),$r=function(n){xt(e,n);var a=Ut(e);function e(){return H(this,e),a.apply(this,arguments)}return z(e)}(Nt),Hr=function(n){xt(e,n);var a=Ut(e);function e(){return H(this,e),a.apply(this,arguments)}return z(e)}(Nt),zr=function(){function n(){H(this,n),S(this,"id",3),S(this,"type",we.METADATA),S(this,"timescale",0),S(this,"flvScriptSamples",[]),S(this,"seiSamples",[])}return z(n,[{key:"exist",value:function(){return!!((this.flvScriptSamples.length||this.seiSamples.length)&&this.timescale)}},{key:"reset",value:function(){this.timescale=0,this.flvScriptSamples=[],this.seiSamples=[]}},{key:"hasSample",value:function(){return!!(this.flvScriptSamples.length||this.seiSamples.length)}}]),n}(),Ve=function(){function n(a){H(this,n),this.name=a||"",this._prefix="[".concat(this.name,"]")}return z(n,[{key:"warn",value:function(){var e;if(!n.disabled){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];(e=console).warn.apply(e,[this._prefix].concat(r))}}}],[{key:"enable",value:function(){n.disabled=!1}},{key:"disable",value:function(){n.disabled=!0}}]),n}();S(Ve,"disabled",!0);var Ge=typeof window<"u",it=Ge&&navigator.userAgent.toLocaleLowerCase(),Wr=Ge&&/^((?!chrome|android).)*safari/.test(it),Kr=Ge&&it.includes("firefox"),qr=Ge&&it.includes("android"),je=function(){function n(){H(this,n)}return z(n,null,[{key:"getRateIndexByRate",value:function(e){return n.FREQ.indexOf(e)}},{key:"parseADTS",value:function(e,t){for(var r=e.length,i=0;i+2<r&&!(e[i]===255&&(e[i+1]&246)===240);)i++;if(!(i>=r)){var s=i,o=[],u=(e[i+2]&60)>>>2,l=n.FREQ[u];if(!l)throw new Error("Invalid sampling index: ".concat(u));for(var f=((e[i+2]&192)>>>6)+1,c=(e[i+2]&1)<<2|(e[i+3]&192)>>>6,p=n._getConfig(u,c,f),_=p.config,m=p.codec,b,v,w=0,D=n.getFrameDuration(l);i+7<r;){if(e[i]!==255||(e[i+1]&246)!==240){i++;continue}if(v=(e[i+3]&3)<<11|e[i+4]<<3|(e[i+5]&224)>>5,r-i<v)break;b=(~e[i+1]&1)*2,o.push({pts:t+w*D,data:e.subarray(i+7+b,i+v)}),w++,i+=v}return{skip:s,remaining:i>=r?void 0:e.subarray(i),frames:o,samplingFrequencyIndex:u,sampleRate:l,objectType:f,channelCount:c,codec:m,config:_,originCodec:"mp4a.40.".concat(f)}}}},{key:"parseAudioSpecificConfig",value:function(e){if(e.length){var t=e[0]>>>3,r=(e[0]&7)<<1|e[1]>>>7,i=(e[1]&120)>>>3,s=n.FREQ[r];if(s){var o=n._getConfig(r,i,t),u=o.config,l=o.codec;return{samplingFrequencyIndex:r,sampleRate:s,objectType:t,channelCount:i,config:u,codec:l,originCodec:"mp4a.40.".concat(t)}}}}},{key:"getFrameDuration",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:9e4;return 1024*t/e}},{key:"_getConfig",value:function(e,t,r){var i=[],s,o;return Kr?e>=6?(s=5,o=e-3):(s=2,o=e):qr?(s=2,o=e):(s=r===2||r===5?r:5,o=e,e>=6?o=e-3:t===1&&(s=2,o=e)),i[0]=s<<3,i[0]|=(e&14)>>1,i[1]=(e&1)<<7,i[1]|=t<<3,s===5&&(i[1]|=(o&14)>>1,i[2]=(o&1)<<7,i[2]|=8,i[3]=0),{config:i,codec:"mp4a.40.".concat(s)}}},{key:"getSilentFrame",value:function(e,t){switch(e){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===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(t===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(t===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(t===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(t===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}}}]),n}();S(je,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]);var Xr=500,Ft=3,at=1e3,st=5e3,Yr=1e3,Qr=200,Vt=5e3,Gt=5,Jr=function(){function n(a,e,t){H(this,n),this.videoTrack=a,this.audioTrack=e,this.metadataTrack=t,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 z(n,[{key:"fix",value:function(){var e=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;t=Math.round(t*1e3);var s=this.videoTrack,o=this.audioTrack;(r||!i)&&(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),r&&!i&&(this._baseDtsInited=!1),this._baseDtsInited||this._calculateBaseDts(o,s),!i&&t&&(this._audioNextPts=this._videoNextDts=t);var u=this._baseDtsInited&&(this._videoTimestampBreak||!this.videoTrack.exist())&&(this._audioTimestampBreak||!this.audioTrack.exist());if(u&&this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(o),this._keyFrameInNextChunk=!1,this._fixVideo(s),this.metadataTrack.exist()){var l=this.metadataTrack.timescale;this.metadataTrack.seiSamples.forEach(function(f){f.pts=f.originPts-e._baseDts,f.time=Math.max(0,f.pts)/l}),this.metadataTrack.flvScriptSamples.forEach(function(f){f.pts=f.originPts-e._baseDts,f.time=Math.max(0,f.pts)/l})}s.samples.length&&(s.baseMediaDecodeTime=s.samples[0].dts),o.samples.length&&(o.baseMediaDecodeTime=o.samples[0].pts*o.timescale/1e3)}},{key:"_fixVideo",value:function(e){var t=this,r=e.samples;if(r.length){r.forEach(function(D){D.dts-=t._baseDts,D.pts-=t._baseDts,D.keyframe&&(t._keyFrameInNextChunk=!0)});var i;if(e.fpsNum&&e.fpsDen)i=e.timescale*(e.fpsDen/e.fpsNum);else if(e.length>1){var s=e.samples[0],o=e.samples[r.length-1];i=Math.floor((o.dts-s.dts)/(r.length-1))}else i=this._lastVideoDuration||40;var u=r.pop();if(this._videoLastSample&&r.unshift(this._videoLastSample),this._videoLastSample=u,!!r.length){if(this._videoNextDts===void 0){var l=r[0];this._videoNextDts=l.dts}var f=r.length,c=0,p=r[0],_=this._videoNextDts-p.dts;if(Math.abs(_)>Qr){if(Math.abs(p.dts-this._lastVideoExceptionChunkFirstDtsDot)>Vt){var m;this._lastVideoExceptionChunkFirstDtsDot=p.dts,e.warnings.push({type:ae.LARGE_VIDEO_GAP_BETWEEN_CHUNK,nextDts:this._videoNextDts,firstSampleDts:p.dts,nextSampleDts:(m=r[1])===null||m===void 0?void 0:m.dts,sampleDuration:_})}this._videoTimestampBreak>=Gt?(this._videoNextDts=p.dts,this._videoTimestampBreak=0):(p.dts+=_,p.pts+=_,this.audioTrack.exist()||(this._videoTimestampBreak=1))}for(var b=0;b<f;b++){var v=r[b].dts,w=r[b+1];b<f-1?c=w.dts-v:u?c=u.dts-v:c=i,(c>Yr||c<0)&&(this._videoTimestampBreak++,Math.abs(v-this._lastVideoExceptionLargeGapDot)>Vt&&(this._lastVideoExceptionLargeGapDot=v,e.warnings.push({type:ae.LARGE_VIDEO_GAP,time:v/e.timescale,dts:v,originDts:r[b].originDts,nextDts:this._videoNextDts,sampleDuration:c,refSampleDuration:i})),c=i),r[b].duration=c,this._videoNextDts+=c,this._lastVideoDuration=c}}}}},{key:"_fixAudio",value:function(e){var t=this,r=e.samples;r.length&&(r.forEach(function(i){i.dts=i.pts-=t._baseDts}),this._doFixAudioInternal(e,r,1e3))}},{key:"_calculateBaseDts",value:function(e,t){var r=e.samples,i=t.samples;if(!r.length&&!i.length)return!1;var s=1/0,o=1/0;r.length&&(e.baseDts=s=r[0].pts),i.length&&(t.baseDts=o=i[0].dts),this._baseDts=Math.min(s,o);var u=o-s;return Number.isFinite(u)&&Math.abs(u)>Xr&&t.warnings.push({type:ae.LARGE_AV_SHIFT,videoBaseDts:o,audioBasePts:s,baseDts:this._baseDts,delta:u}),this._baseDtsInited=!0,!0}},{key:"_resetBaseDtsWhenStreamBreaked",value:function(){var e=this._calculateBaseDts(this.audioTrack,this.videoTrack);e&&(this.audioTrack.exist()?this.videoTrack.exist()?this._baseDts-=Math.min(this._audioNextPts,this._videoNextDts):this._baseDts-=this._audioNextPts:this._baseDts-=this._videoNextDts,this._videoTimestampBreak=0,this._audioTimestampBreak=0)}},{key:"_doFixAudioInternal",value:function(e,t,r){e.sampleDuration||(e.sampleDuration=e.codecType===me.AAC?je.getFrameDuration(e.timescale,r):this._getG711Duration(e));var i=e.sampleDuration,s=e.codecType===me.AAC?1024:i*e.timescale/1e3;if(this._audioNextPts===void 0){var o=t[0];this._audioNextPts=o.pts}for(var u=0;u<t.length;u++){var l=this._audioNextPts,f=t[u],c=f.pts-l;if(u===0&&this._audioTimestampBreak>=Gt&&this._keyFrameInNextChunk&&(l=this._audioNextPts=f.dts,c=0,this._audioTimestampBreak=0),!this._audioTimestampBreak&&c>=Ft*i&&c<=at&&!Wr){var p=this._getSilentFrame(e)||t[0].data.subarray(),_=Math.floor(c/i);Math.abs(f.pts-this._lastAudioExceptionGapDot)>st&&(this._lastAudioExceptionGapDot=f.pts,e.warnings.push({type:ae.AUDIO_FILLED,pts:f.pts,originPts:f.originPts,count:_,nextPts:l,refSampleDuration:i}));for(var m=0;m<_;m++){var b=new nt(Math.floor(this._audioNextPts+i)-Math.floor(this._audioNextPts),p,s);b.originPts=Math.floor(this._baseDts+l),t.splice(u,0,b),this._audioNextPts+=i,u++}u--}else c<=-Ft*i&&c>=-1*at?(Math.abs(f.pts-this._lastAudioExceptionOverlapDot)>st&&(this._lastAudioExceptionOverlapDot=f.pts,e.warnings.push({type:ae.AUDIO_DROPPED,pts:f.pts,originPts:f.originPts,nextPts:l,refSampleDuration:i})),t.splice(u,1),u--):(Math.abs(c)>at&&(this._audioTimestampBreak++,Math.abs(f.pts-this._lastAudioExceptionLargeGapDot)>st&&(this._lastAudioExceptionLargeGapDot=f.pts,e.warnings.push({type:ae.LARGE_AUDIO_GAP,time:f.pts/1e3,pts:f.pts,originPts:f.originPts,nextPts:l,sampleDuration:c,refSampleDuration:i}))),f.dts=f.pts=l,f.duration=s,this._audioNextPts+=i)}}},{key:"_getG711Duration",value:function(e){var t=e.sampleSize,r=e.channelCount,i=e.sampleRate,s=e.samples[0];if(s)return s.data.byteLength*2/r/(t/8)/i*1e3}},{key:"_getSilentFrame",value:function(e){return e.codecType===me.AAC?je.getSilentFrame(e.codec,e.channelCount):new Uint8Array(8*e.sampleDuration*e.channelCount)}}]),n}();function ue(){for(var n=arguments.length,a=new Array(n),e=0;e<n;e++)a[e]=arguments[e];a=a.filter(Boolean);var t=new Uint8Array(a.reduce(function(i,s){return i+s.byteLength},0)),r=0;return a.forEach(function(i){t.set(i,r),r+=i.byteLength}),t}function $e(n){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(n[a]<<24>>>0)+(n[a+1]<<16)+(n[a+2]<<8)+(n[a+3]||0)}function Zr(n){for(var a="avc1.",e,t=0;t<3;t++)e=n[t].toString(16),e.length<2&&(e="0".concat(e)),a+=e;return a}function jt(n){if(!Array.isArray(n)){for(var a=[],e="",t=0;t<n.length;t++)t%2&&(e=n[t-1]+n[t],a.push(parseInt(e,16)),e="");return a}return n.map(function(r){return parseInt(r,16)})}var Te=function(){function n(){H(this,n)}return z(n,null,[{key:"parseAnnexB",value:function(e){for(var t=e.length,r=2,i=0;e[r]!==null&&e[r]!==void 0&&e[r]!==1;)r++;if(r++,i=r+2,i>=t)return[];for(var s=[];i<t;)switch(e[i]){case 0:if(e[i-1]!==0){i+=2;break}else if(e[i-2]!==0){i++;break}r!==i-2&&s.push(e.subarray(r,i-2));do i++;while(e[i]!==1&&i<t);r=i+1,i=r+2;break;case 1:if(e[i-1]!==0||e[i-2]!==0){i+=3;break}r!==i-2&&s.push(e.subarray(r,i-2)),r=i+1,i=r+2;break;default:i+=3;break}return r<t&&s.push(e.subarray(r)),s}},{key:"parseAvcC",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;if(!(e.length<4)){for(var r=e.length,i=[],s=0,o;s+t<r;)if(o=$e(e,s),t===3&&(o>>>=8),s+=t,!!o){if(s+o>r)break;i.push(e.subarray(s,s+o)),s+=o}return i}}},{key:"parseSEI",value:function(e,t){for(var r=e.length,i=t?2:1,s=0,o=0,u="";e[i]===255;)s+=255,i++;for(s+=e[i++];e[i]===255;)o+=255,i++;if(o+=e[i++],s===5&&r>i+16)for(var l=0;l<16;l++)u+=e[i].toString(16),i++;return{payload:e.subarray(i,i+o),type:s,size:o,uuid:u}}},{key:"removeEPB",value:function(e){for(var t=e.byteLength,r=[],i=1;i<t-2;)e[i]===0&&e[i+1]===0&&e[i+2]===3?(r.push(i+2),i+=2):i++;if(!r.length)return e;var s=t-r.length,o=new Uint8Array(s),u=0;for(i=0;i<s;u++,i++)u===r[0]&&(u++,r.shift()),o[i]=e[u];return o}}]),n}(),ot=function(){function n(a){if(H(this,n),S(this,"_bytesAvailable",void 0),S(this,"_bitsAvailable",0),S(this,"_word",0),!a)throw new Error("ExpGolomb data params is required");this._data=a,this._bytesAvailable=a.byteLength,this._bytesAvailable&&this._loadWord()}return z(n,[{key:"bitsAvailable",get:function(){return this._bitsAvailable}},{key:"_loadWord",value:function(){var e=this._data.byteLength-this._bytesAvailable,t=Math.min(4,this._bytesAvailable);if(t===0)throw new Error("No bytes available");var r=new Uint8Array(4);r.set(this._data.subarray(e,e+t)),this._word=new DataView(r.buffer).getUint32(0),this._bitsAvailable=t*8,this._bytesAvailable-=t}},{key:"skipBits",value:function(e){if(this._bitsAvailable>e)this._word<<=e,this._bitsAvailable-=e;else{e-=this._bitsAvailable;var t=Math.floor(e/8);e-=t*8,this._bytesAvailable-=t,this._loadWord(),this._word<<=e,this._bitsAvailable-=e}}},{key:"readBits",value:function(e){if(e>32)throw new Error("Cannot read more than 32 bits");var t=Math.min(this._bitsAvailable,e),r=this._word>>>32-t;return this._bitsAvailable-=t,this._bitsAvailable>0?this._word<<=t:this._bytesAvailable>0&&this._loadWord(),t=e-t,t>0&&this._bitsAvailable?r<<t|this.readBits(t):r}},{key:"skipLZ",value:function(){var e;for(e=0;e<this._bitsAvailable;++e)if(this._word&2147483648>>>e)return this._word<<=e,this._bitsAvailable-=e,e;return this._loadWord(),e+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var e=this.skipLZ();return this.readBits(e+1)-1}},{key:"readEG",value:function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}},{key:"readBool",value:function(){return this.readBits(1)===1}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"skipScalingList",value:function(e){for(var t=8,r=8,i,s=0;s<e;s++)r!==0&&(i=this.readEG(),r=(t+i+256)%256),t=r===0?t:r}}]),n}(),en=function(){function n(){H(this,n)}return z(n,null,[{key:"parseAVCDecoderConfigurationRecord",value:function(e){if(!(e.length<7)){for(var t=(e[4]&3)+1,r,i=[],s=[],o=6,u=e[5]&31,l,f=0;f<u;f++)if(l=e[o]<<8|e[o+1],o+=2,!!l){var c=e.subarray(o,o+l);o+=l,i.push(c),r||(r=n.parseSPS(Te.removeEPB(c)))}var p=e[o];o++;for(var _,m=0;m<p;m++)_=e[o]<<8|e[o+1],o+=2,_&&(s.push(e.subarray(o,o+_)),o+=_);return{sps:r,spsArr:i,ppsArr:s,nalUnitSize:t}}}},{key:"parseSPS",value:function(e){var t=new ot(e);t.readUByte();var r=t.readUByte(),i=t.readUByte(),s=t.readUByte();t.skipUEG();var o=420;if(r===100||r===110||r===122||r===244||r===44||r===83||r===86||r===118||r===128||r===138||r===144){var u=t.readUEG();if(u<=3&&(o=[0,420,422,444][u]),u===3&&t.skipBits(1),t.skipUEG(),t.skipUEG(),t.skipBits(1),t.readBool())for(var l=u!==3?8:12,f=0;f<l;f++)t.readBool()&&(f<6?t.skipScalingList(16):t.skipScalingList(64))}t.skipUEG();var c=t.readUEG();if(c===0)t.readUEG();else if(c===1){t.skipBits(1),t.skipUEG(),t.skipUEG();for(var p=t.readUEG(),_=0;_<p;_++)t.skipUEG()}t.skipUEG(),t.skipBits(1);var m=t.readUEG(),b=t.readUEG(),v=t.readBits(1);v===0&&t.skipBits(1),t.skipBits(1);var w=0,D=0,O=0,k=0;t.readBool()&&(w=t.readUEG(),D=t.readUEG(),O=t.readUEG(),k=t.readUEG());var A,j,Q,W,q;if(t.readBool()){if(t.readBool()){var N=t.readUByte();switch(N){case 1:A=[1,1];break;case 2:A=[12,11];break;case 3:A=[10,11];break;case 4:A=[16,11];break;case 5:A=[40,33];break;case 6:A=[24,11];break;case 7:A=[20,11];break;case 8:A=[32,11];break;case 9:A=[80,33];break;case 10:A=[18,11];break;case 11:A=[15,11];break;case 12:A=[64,33];break;case 13:A=[160,99];break;case 14:A=[4,3];break;case 15:A=[3,2];break;case 16:A=[2,1];break;case 255:{A=[t.readUByte()<<8|t.readUByte(),t.readUByte()<<8|t.readUByte()];break}}}if(t.readBool()&&t.readBool(),t.readBool()&&(t.readBits(4),t.readBool()&&t.readBits(24)),t.readBool()&&(t.readUEG(),t.readUEG()),t.readBool()){var ie=t.readBits(32),d=t.readBits(32);j=t.readBool(),Q=d,W=ie*2,q=Q/W}}return{codec:Zr(e.subarray(1,4)),profileIdc:r,profileCompatibility:i,levelIdc:s,chromaFormat:o,width:Math.ceil((m+1)*16-2*(w+D)),height:(2-v)*(b+1)*16-(v?2:4)*(O+k),sarRatio:A,fpsNum:Q,fpsDen:W,fps:q,fixedFrame:j}}}]),n}(),tn=function(){function n(){H(this,n)}return z(n,null,[{key:"parseHEVCDecoderConfigurationRecord",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!(e.length<23)){t=t||{};for(var r=(e[21]&3)+1,i,s,o=[],u=[],l=[],f=23,c=e[22],p,_,m,b=0;b<c;b++){p=e[f]&63,_=e[f+1]<<8|e[f+2],f+=3;for(var v=0;v<_;v++)if(m=e[f]<<8|e[f+1],f+=2,!!m){switch(p){case 32:{var w=e.subarray(f,f+m);i||(i=n.parseVPS(Te.removeEPB(w),t)),l.push(w)}break;case 33:{var D=e.subarray(f,f+m);s||(s=n.parseSPS(Te.removeEPB(D),t)),o.push(D)}break;case 34:u.push(e.subarray(f,f+m));break}f+=m}}return{hvcC:t,sps:s,spsArr:o,ppsArr:u,vpsArr:l,nalUnitSize:r}}}},{key:"parseVPS",value:function(e,t){t=t||{};var r=new ot(e);r.readUByte(),r.readUByte(),r.readBits(12);var i=r.readBits(3);return t.numTemporalLayers=Math.max(t.numTemporalLayers||0,i+1),r.readBits(17),n._parseProfileTierLevel(r,i,t),t}},{key:"parseSPS",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};t=t||{};var r=new ot(e);r.readUByte(),r.readUByte(),r.readBits(4);var i=r.readBits(3);t.numTemporalLayers=Math.max(i+1,t.numTemporalLayers||0),t.temporalIdNested=r.readBits(1),n._parseProfileTierLevel(r,i,t),r.readUEG();var s=t.chromaFormatIdc=r.readUEG(),o=420;s<=3&&(o=[0,420,422,444][s]);var u=0;s===3&&(u=r.readBits(1));var l=r.readUEG(),f=r.readUEG(),c=r.readBits(1),p,_,m,b;if(c===1&&(p=r.readUEG(),_=r.readUEG(),m=r.readUEG(),b=r.readUEG()),t.bitDepthLumaMinus8=r.readUEG(),t.bitDepthChromaMinus8=r.readUEG(),c===1){var v=(s===1||s===2)&&u===0?2:1,w=s===1&&u===0?2:1;l-=v*(_+p),f-=w*(b+m)}return{codec:"hev1.1.6.L93.B0",width:l,height:f,chromaFormat:o,hvcC:t}}},{key:"_parseProfileTierLevel",value:function(e,t,r){var i=r.generalTierFlag||0;r.generalProfileSpace=e.readBits(2),r.generalTierFlag=Math.max(e.readBits(1),i),r.generalProfileIdc=Math.max(e.readBits(5),r.generalProfileIdc||0),r.generalProfileCompatibilityFlags=e.readBits(32),r.generalConstraintIndicatorFlags=[e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8)];var s=e.readBits(8);i<r.generalTierFlag?r.generalLevelIdc=s:r.generalLevelIdc=Math.max(s,r.generalLevelIdc||0);var o=[],u=[];if(t>e.bitsAvailable)throw new Error("maxSubLayersMinus inavlid size ".concat(t));for(var l=0;l<t;l++)o[l]=e.readBits(1),u[l]=e.readBits(1);t>0&&e.readBits((8-t)*2);for(var f=0;f<t;f++)o[f]!==0&&(e.readBits(2),e.readBits(1),e.readBits(5),e.readBits(16),e.readBits(16),e.readBits(4),e.readBits(16),e.readBits(16),e.readBits(12)),u[f]!==0&&e.readBits(8)}}]),n}(),$t=function(){function n(){H(this,n)}return z(n,null,[{key:"decode",value:function(e){for(var t=[],r=e,i=0,s=e.length;i<s;){if(r[i]<128){t.push(String.fromCharCode(r[i])),++i;continue}else if(!(r[i]<192)){if(r[i]<224){if(n._checkContinuation(r,i,1)){var o=(r[i]&31)<<6|r[i+1]&63;if(o>=128){t.push(String.fromCharCode(o&65535)),i+=2;continue}}}else if(r[i]<240){if(n._checkContinuation(r,i,2)){var u=(r[i]&15)<<12|(r[i+1]&63)<<6|r[i+2]&63;if(u>=2048&&(u&63488)!==55296){t.push(String.fromCharCode(u&65535)),i+=3;continue}}}else if(r[i]<248&&n._checkContinuation(r,i,3)){var l=(r[i]&7)<<18|(r[i+1]&63)<<12|(r[i+2]&63)<<6|r[i+3]&63;if(l>65536&&l<1114112){l-=65536,t.push(String.fromCharCode(l>>>10|55296)),t.push(String.fromCharCode(l&1023|56320)),i+=4;continue}}}t.push("\uFFFD"),++i}return t.join("")}},{key:"_checkContinuation",value:function(e,t,r){var i=e;if(t+r<i.length){for(;r--;)if((i[++t]&192)!==128)return!1;return!0}else return!1}}]),n}(),rn=function(){function n(){H(this,n)}return z(n,null,[{key:"parse",value:function(e){if(!(e.length<3)){var t={},r=n._parseValue(new DataView(e.buffer,e.byteOffset,e.byteLength)),i=n._parseValue(new DataView(e.buffer,e.byteOffset+r.size,e.byteLength-r.size));return t[r.data]=i.data,t}}},{key:"_parseValue",value:function(e){var t=e.byteLength,r=e.getUint8(0),i=1,s=!1,o;switch(r){case 0:o=e.getFloat64(1),i+=8;break;case 1:{o=!!e.getUint8(1),i+=1;break}case 2:{var u=n._parseString(new DataView(e.buffer,e.byteOffset+i,e.byteLength-i)),l=u.data,f=u.size;o=l,i+=f}break;case 3:{o={};var c=0;for((e.getUint32(t-4)&16777215)===9&&(c=3);i<t-4;){var p=n._parseObject(new DataView(e.buffer,e.byteOffset+i,e.byteLength-i-c)),_=p.size,m=p.data,b=p.isEnd;if(b)break;o[m.name]=m.value,i+=_}if(i<=t-3){var v=e.getUint32(i-1)&16777215;v===9&&(i+=3)}}break;case 8:{o={},i+=4;var w=0;for((e.getUint32(t-4)&16777215)===9&&(w=3);i<t-8;){var D=n._parseObject(new DataView(e.buffer,e.byteOffset+i,e.byteLength-i-w)),O=D.size,k=D.data,A=D.isEnd;if(A)break;o[k.name]=k.value,i+=O}if(i<=t-3){var j=e.getUint32(i-1)&16777215;j===9&&(i+=3)}}break;case 9:o=void 0,i=1,s=!0;break;case 10:{o=[];var Q=e.getUint32(1);i+=4;for(var W=0;W<Q;W++){var q=n._parseValue(new DataView(e.buffer,e.byteOffset+i,e.byteLength-i)),N=q.data,ie=q.size;o.push(N),i+=ie}}break;case 11:{var d=e.getFloat64(i)+e.getInt16(i+8)*6e4;o=new Date(d),i+=10}break;case 12:{var h=e.getUint32(1);i+=4,o="",h>0&&(o=$t.decode(new Uint8Array(e.buffer,e.byteOffset+i,h))),i+=h}break;default:i=t;break}return{data:o,size:i,isEnd:s}}},{key:"_parseString",value:function(e){var t=e.getUint16(0),r="";return t>0&&(r=$t.decode(new Uint8Array(e.buffer,e.byteOffset+2,t))),{data:r,size:2+t}}},{key:"_parseObject",value:function(e){if(!(e.byteLength<3)){var t=n._parseString(e),r=n._parseValue(new DataView(e.buffer,e.byteOffset+t.size,e.byteLength-t.size));return{data:{name:t.data,value:r.data},size:t.size+r.size,isEnd:r.isEnd}}}}]),n}(),he=new Ve("FlvDemuxer"),Ht=function(){function n(a,e,t){H(this,n),S(this,"_headerParsed",!1),S(this,"_remainingData",null),S(this,"_gopId",0),S(this,"_needAddMetaBeforeKeyFrameNal",!0),this.videoTrack=a||new Vr,this.audioTrack=e||new Gr,this.metadataTrack=t||new zr,this._fixer=new Jr(this.videoTrack,this.audioTrack,this.metadataTrack)}return z(n,[{key:"demux",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,i=this.audioTrack,s=this.videoTrack,o=this.metadataTrack;if((t||!r)&&(this._remainingData=null),t&&(this._headerParsed=!1),t?(s.reset(),i.reset(),o.reset()):(s.samples=[],i.samples=[],o.seiSamples=[],o.flvScriptSamples=[],s.warnings=[],i.warnings=[],this._remainingData&&(e=ue(this._remainingData,e),this._remainingData=null)),!e.length)return{videoTrack:s,audioTrack:i,metadataTrack:o};var u=0;if(!this._headerParsed){if(!n.probe(e))throw new Error("Invalid flv file");i.present=(e[4]&4)>>>2!==0,s.present=(e[4]&1)!==0,this._headerParsed=!0,u=$e(e,5)+4}for(var l=e.length,f,c,p,_,m;u+15<l&&(f=e[u],c=e[u+1]<<16|e[u+2]<<8|e[u+3],!(u+15+c>l));)p=(e[u+7]<<24>>>0)+(e[u+4]<<16)+(e[u+5]<<8)+e[u+6],u+=11,_=e.subarray(u,u+c),f===8?this._parseAudio(_,p):f===9?this._parseVideo(_,p):f===18?this._parseScript(_,p):he.warn("Invalid tag type: ".concat(f)),u+=c,m=$e(e,u),m!==11+c&&he.warn("Invalid PrevTagSize ".concat(m," (").concat(11+c,")")),u+=4;return u<l&&(this._remainingData=e.subarray(u)),i.formatTimescale=s.formatTimescale=s.timescale=o.timescale=1e3,i.timescale=i.sampleRate||0,!i.exist()&&i.hasSample()&&i.reset(),!s.exist()&&s.hasSample()&&s.reset(),{videoTrack:s,audioTrack:i,metadataTrack:o}}},{key:"fix",value:function(e,t,r){return this._fixer.fix(e,t,r),{videoTrack:this.videoTrack,audioTrack:this.audioTrack,metadataTrack:this.metadataTrack}}},{key:"demuxAndFix",value:function(e,t,r,i){return this.demux(e,t,r),this.fix(i,t,r)}},{key:"_parseAudio",value:function(e,t){if(e.length){var r=(e[0]&240)>>>4,i=this.audioTrack;if(r!==10&&r!==7&&r!==8){he.warn("Unsupported sound format: ".concat(r)),i.reset();return}if(r!==10){var s=(e[0]&12)>>2,o=(e[0]&2)>>1,u=e[0]&1;i.sampleRate=n.AUDIO_RATE[s],i.sampleSize=o?16:8,i.channelCount=u+1}r===10?this._parseAac(e,t):this._parseG711(e,t,r)}}},{key:"_parseG711",value:function(e,t,r){var i=this.audioTrack;i.codecType=r===7?me.G711PCMA:me.G711PCMU,i.sampleRate=8e3,i.codec=i.codecType,i.samples.push(new nt(t,e.subarray(1)))}},{key:"_parseAac",value:function(e,t){var r=this.audioTrack;if(r.codecType=me.AAC,e[1]===0){var i=je.parseAudioSpecificConfig(e.subarray(2));i?(r.codec=i.codec,r.channelCount=i.channelCount,r.sampleRate=i.sampleRate,r.config=i.config,r.objectType=i.objectType,r.sampleRateIndex=i.samplingFrequencyIndex):(r.reset(),he.warn("Cannot parse AudioSpecificConfig",e))}else if(e[1]===1){if(t==null)return;r.samples.push(new nt(t,e.subarray(2)))}else he.warn("Unknown AACPacketType: ".concat(e[1]))}},{key:"_parseVideo",value:function(e,t){var r=this;if(!(e.length<6)){var i=(e[0]&240)>>>4,s=e[0]&15,o=this.videoTrack;if(s!==7&&s!==12){o.reset(),he.warn("Unsupported codecId: ".concat(s));return}var u=s===12;o.codecType=u?Ce.HEVC:Ce.AVC;var l=e[1],f=(e[2]<<16|e[3]<<8|e[4])<<8>>8;if(l===0){var c=e.subarray(5),p=u?tn.parseHEVCDecoderConfigurationRecord(c):en.parseAVCDecoderConfigurationRecord(c);if(p){var _=p.hvcC,m=p.sps,b=p.ppsArr,v=p.spsArr,w=p.vpsArr,D=p.nalUnitSize;_&&(o.hvcC=o.hvcC||_),m&&(o.codec=m.codec,o.width=m.width,o.height=m.height,o.sarRatio=m.sarRatio,o.fpsNum=m.fpsNum,o.fpsDen=m.fpsDen),v.length&&(o.sps=v),b.length&&(o.pps=b),w&&w.length&&(o.vps=w),D&&(o.nalUnitSize=D)}else he.warn("Cannot parse ".concat(u?"HEVC":"AVC","DecoderConfigurationRecord"),e)}else if(l===1){var O=Te.parseAvcC(e.subarray(5),o.nalUnitSize);if(O=this._checkAddMetaNalToUnits(u,O,o),O&&O.length){var k=new jr(t+f,t,O);i===1&&k.setToKeyframe(),o.samples.push(k),O.forEach(function(A){var j=u?A[0]>>>1&63:A[0]&31;switch(j){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!u&&j!==5||u&&j===5)break;k.setToKeyframe();break;case 6:case 39:case 40:if(!u&&j!==6||u&&j===6)break;r.metadataTrack.seiSamples.push(new Hr(Te.parseSEI(Te.removeEPB(A),u),t+f));break}}),k.keyframe&&this._gopId++,k.gopId=this._gopId}else he.warn("Cannot parse NALUs",e)}else l===2||he.warn("Unknown AVCPacketType: ".concat(l))}}},{key:"_checkAddMetaNalToUnits",value:function(e,t,r){if(!e||!this._needAddMetaBeforeKeyFrameNal)return this._needAddMetaBeforeKeyFrameNal=!1,t;var i=t.map(function(s){return s[0]>>>1&63});return i.includes(32)?(this._needAddMetaBeforeKeyFrameNal=!1,t):(t.unshift(r.pps[0]),t.unshift(r.sps[0]),t.unshift(r.vps[0]),t.filter(Boolean))}},{key:"_parseScript",value:function(e,t){this.metadataTrack.flvScriptSamples.push(new $r(rn.parse(e),t))}}],[{key:"probe",value:function(e){return e[0]!==70||e[1]!==76||e[2]!==86||e[3]!==1?!1:$e(e,5)>=9}}]),n}();S(Ht,"AUDIO_RATE",[5500,11e3,22e3,44e3]);function nn(n){for(var a=0,e=arguments.length,t=new Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];t.forEach(function(o){a+=o.length});var i=new n(a),s=0;return t.forEach(function(o){i.set(o,s),s+=o.length}),i}var Z=function(){function n(){H(this,n),this.buffer=new Uint8Array(0)}return z(n,[{key:"write",value:function(){for(var e=this,t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];r.forEach(function(s){s?e.buffer=nn(Uint8Array,e.buffer,s):window.console.warn(s)})}}],[{key:"writeUint16",value:function(e){return new Uint8Array([e>>8&255,e&255])}},{key:"writeUint32",value:function(e){return new Uint8Array([e>>24,e>>16&255,e>>8&255,e&255])}}]),n}(),zt=Math.pow(2,32)-1,I=function(){function n(){H(this,n)}return z(n,null,[{key:"box",value:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];r=r.filter(Boolean);var s=8+r.reduce(function(l,f){return l+f.byteLength},0),o=new Uint8Array(s);o[0]=s>>24&255,o[1]=s>>16&255,o[2]=s>>8&255,o[3]=s&255,o.set(e,4);var u=8;return r.forEach(function(l){o.set(l,u),u+=l.byteLength}),o}},{key:"ftyp",value:function(e){var t=e.find(function(r){return r.type===we.VIDEO&&r.codecType===Ce.HEVC});return t?n.FTYPHEV1:n.FTYPAVC1}},{key:"initSegment",value:function(e){var t=n.ftyp(e),r=ue(t,n.moov(e));return r}},{key:"pssh",value:function(e){var t=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],jt(e.kid),[0,0,0,0]));return n.box(n.types.pssh,t)}},{key:"moov",value:function(e){if(e[0].useEME&&(e[0].encv||e[0].enca)){e[0].pssh||(e[0].pssh={kid:e[0].kid});var t=this.pssh(e[0].pssh);return n.box.apply(n,[n.types.moov,n.mvhd(e[0].mvhdDurtion||e[0].duration,e[0].mvhdTimecale||e[0].timescale),n.mvex(e)].concat(oe(e.map(function(r){return n.trak(r)})),[t]))}else return n.box.apply(n,[n.types.moov,n.mvhd(e[0].mvhdDurtion||e[0].duration,e[0].mvhdTimecale||e[0].timescale)].concat(oe(e.map(function(r){return n.trak(r)})),[n.mvex(e)]))}},{key:"mvhd",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:9e4,r=n.box(n.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,t>>24&255,t>>16&255,t>>8&255,t&255,e>>24&255,e>>16&255,e>>8&255,e&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 r}},{key:"trak",value:function(e){var t=n.box(n.types.trak,n.tkhd(e.id,e.tkhdDuration||0,e.width,e.height),n.mdia(e));return t}},{key:"tkhd",value:function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=n.box(n.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,e>>24&255,e>>16&255,e>>8&255,e&255,0,0,0,0,t>>24&255,t>>16&255,t>>8&255,t&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,r>>8&255,r&255,0,0,i>>8&255,i&255,0,0]));return s}},{key:"mdia",value:function(e){var t=n.box(n.types.mdia,n.mdhd(e.duration,e.timescale),n.hdlr(e.type),n.minf(e));return t}},{key:"mdhd",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:9e4,r=n.box(n.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,t>>24&255,t>>16&255,t>>8&255,t&255,e>>24&255,e>>16&255,e>>8&255,e&255,85,196,0,0]));return r}},{key:"hdlr",value:function(e){var t=n.box(n.types.hdlr,n.HDLR_TYPES[e]);return t}},{key:"minf",value:function(e){var t=n.box(n.types.minf,e.type===we.VIDEO?n.VMHD:n.SMHD,n.DINF,n.stbl(e));return t}},{key:"stbl",value:function(e){var t=[];e&&e.ext&&e.ext.stss&&t.push(n.stss(e.ext.stss.entries));var r=n.box(n.types.stbl,n.stsd(e),n.STTS,t[0],n.STSC,n.STSZ,n.STCO);return r}},{key:"stsd",value:function(e){var t;e.type==="audio"?e.useEME&&e.enca?t=n.enca(e):t=n.mp4a(e):e.useEME&&e.encv?t=n.encv(e):t=n.avc1hev1(e);var r=n.box(n.types.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),t);return r}},{key:"enca",value:function(e){var t=e.enca.channelCount,r=e.enca.sampleRate,i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,r>>8&255,r&255,0,0]),s=n.esds(e.config),o=n.sinf(e.enca);return n.box(n.types.enca,i,s,o)}},{key:"encv",value:function(e){var t,r,i=e.sps.length>0?e.sps[0]:[],s=e.pps.length>0?e.pps[0]:[],o=e.width,u=e.height,l=e.sarRatio[0],f=e.sarRatio[1],c=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,o>>8&255,o&255,u>>8&255,u&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]),p=new Uint8Array((t=(r=[1,i[1],i[2],i[3],255,225,i.length>>>8&255,i.length&255]).concat.apply(r,oe(i)).concat([1,s.length>>>8&255,s.length&255])).concat.apply(t,oe(s))),_=new Uint8Array([0,0,88,57,0,15,200,192,0,4,86,72]),m=n.sinf(e.encv),b=new Uint8Array([l>>24,l>>16&255,l>>8&255,l&255,f>>24,f>>16&255,f>>8&255,f&255]);return n.box(n.types.encv,c,n.box(n.types.avcC,p),n.box(n.types.btrt,_),m,n.box(n.types.pasp,b))}},{key:"schi",value:function(e){var t=new Uint8Array([]),r=n.tenc(e);return n.box(n.types.schi,t,r)}},{key:"tenc",value:function(e){var t=new Uint8Array([0,0,0,0,0,0,e.default_IsEncrypted&255,e.default_IV_size&255].concat(jt(e.default_KID)));return n.box(n.types.tenc,t)}},{key:"sinf",value:function(e){var t=new Uint8Array([]),r=new Uint8Array([e.data_format.charCodeAt(0),e.data_format.charCodeAt(1),e.data_format.charCodeAt(2),e.data_format.charCodeAt(3)]),i=new Uint8Array([0,0,0,0,99,101,110,99,0,1,0,0]),s=n.schi(e);return n.box(n.types.sinf,t,n.box(n.types.frma,r),n.box(n.types.schm,i),s)}},{key:"avc1hev1",value:function(e){var t=e.codecType===Ce.HEVC,r=t?n.types.hvc1:n.types.avc1,i=t?n.hvcC(e):n.avcC(e),s=[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,e.width>>8&255,e.width&255,e.height>>8&255,e.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]),i];return t?s.push(n.box(n.types.fiel,new Uint8Array([1,0]))):e.sarRatio&&e.sarRatio.length>1&&s.push(n.pasp(e.sarRatio)),n.box.apply(n,[r].concat(s))}},{key:"avcC",value:function(e){var t,r,i=[],s=[],o;return e.sps.forEach(function(u){o=u.byteLength,i.push(o>>>8&255),i.push(o&255),i.push.apply(i,oe(u))}),e.pps.forEach(function(u){o=u.byteLength,s.push(o>>>8&255),s.push(o&255),s.push.apply(s,oe(u))}),n.box(n.types.avcC,new Uint8Array((t=(r=[1,i[3],i[4],i[5],255,224|e.sps.length]).concat.apply(r,i).concat([e.pps.length])).concat.apply(t,s)))}},{key:"hvcC",value:function(e){var t=e.hvcC;if(t instanceof ArrayBuffer||t instanceof Uint8Array)return t;var r=e.vps,i=e.sps,s=e.pps,o;if(t){var u=t.generalProfileCompatibilityFlags,l=t.generalConstraintIndicatorFlags,f=(r.length&&1)+(i.length&&1)+(s.length&&1);o=[1,t.generalProfileSpace<<6|t.generalTierFlag<<5|t.generalProfileIdc,u>>>24,u>>>16,u>>>8,u,l[0],l[1],l[2],l[3],l[4],l[5],t.generalLevelIdc,240,0,252,t.chromaFormatIdc|252,t.bitDepthLumaMinus8|248,t.bitDepthChromaMinus8|248,0,0,t.numTemporalLayers<<3|t.temporalIdNested<<2|3,f];var c=function(_){var m;o.push(_.length>>8,_.length),(m=o).push.apply(m,oe(_))};r.length&&(o.push(160,0,r.length),r.forEach(c)),i.length&&(o.push(161,0,i.length),i.forEach(c)),s.length&&(o.push(162,0,s.length),s.forEach(c))}else o=[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 n.box(n.types.hvcC,new Uint8Array(o))}},{key:"pasp",value:function(e){var t=Ir(e,2),r=t[0],i=t[1];return n.box(n.types.pasp,new Uint8Array([r>>24,r>>16&255,r>>8&255,r&255,i>>24,i>>16&255,i>>8&255,i&255]))}},{key:"mp4a",value:function(e){return n.box(n.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,e.sampleRate>>8&255,e.sampleRate&255,0,0]),e.config.length?n.esds(e.config):void 0)}},{key:"esds",value:function(e){var t=e.length,r=n.box(n.types.esds,new Uint8Array([0,0,0,0,3,23+t,0,0,0,4,15+t,64,21,0,6,0,0,0,218,192,0,0,218,192,5].concat([t]).concat(e).concat([6,1,2])));return r}},{key:"mvex",value:function(e){var t=n.box.apply(n,[n.types.mvex].concat(oe(e.map(function(r){return n.trex(r.id)}))));return t}},{key:"trex",value:function(e){var t=n.box(n.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]));return t}},{key:"trex1",value:function(e){var t=n.box(n.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255,0,0,0,1,0,0,2,0,0,0,0,0,0,1,0,0]));return t}},{key:"trex2",value:function(e){var t=n.box(n.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255,0,0,0,1,0,0,4,0,0,0,0,0,2,0,0,0]));return t}},{key:"moof",value:function(e){var t=n.box.apply(n,[n.types.moof,n.mfhd(e[0].samples?e[0].samples[0].gopId:0)].concat(oe(e.map(function(r){return n.traf(r)}))));return t}},{key:"mfhd",value:function(e){var t=n.box(n.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]));return t}},{key:"traf",value:function(e){var t=n.tfhd(e.id),r=n.tfdt(e,e.baseMediaDecodeTime),i=0,s;if(e.isVideo&&e.videoSenc&&(s=e.videoSenc,s.forEach(function(h){i=i+8,h.subsamples&&h.subsamples.length&&(i=i+2,i=i+h.subsamples.length*6)})),e.videoSencLength=i,!e.useEME||!e.isVideoEncryption&&!e.isAudioEncryption){var o=n.sdtp(e),u=76;return n.box(n.types.traf,t,r,o,n.trun(e.samples,o.byteLength+u))}else if(e.isVideoEncryption)if(e.isVideo){var l=n.saiz(e),f=n.saio(e),c=n.trun1(e),p=n.senc(e),_=n.box(n.types.traf,t,r,l,f,c,p);return _}else if(e.isAudioEncryption){var v=n.sbgp(),w=n.saiz(e),D=n.saio(e),O=n.senc(e),k=n.trun1(e),A=n.box(n.types.traf,t,r,v,w,D,O,k);return A}else{var m=n.sbgp(),b=n.trun1(e);return n.box(n.types.traf,t,r,m,b)}else if(e.isVideo){var j=n.trun1(e);return n.box(n.types.traf,t,r,j)}else{var Q=n.sbgp(),W=n.saiz(e),q=n.saio(e),N=n.senc(e),ie=n.trun1(e),d=n.box(n.types.traf,t,r,Q,W,q,N,ie);return d}}},{key:"sdtp",value:function(e){var t=new Z;return e.samples.forEach(function(r){t.write(new Uint8Array(e.isVideo?[r.keyframe?32:16]:[16]))}),n.box(n.types.sdtp,this.extension(0,0),t.buffer)}},{key:"trun1",value:function(e){var t=new Z,r=Z.writeUint32(e.samples.length),i=null;if(e.isVideo){var s=e.videoSencLength;i=Z.writeUint32(e.samples.length*16+s+149),!e.isVideoEncryption&&e.isAudioEncryption&&(i=Z.writeUint32(e.samples.length*16+92))}else{var o=e.samples.length*12+124;e.isAudioEncryption&&(o=e.samples.length*12+8*e.audioSenc.length+177),i=Z.writeUint32(o)}return e.samples.forEach(function(u){t.write(Z.writeUint32(u.duration)),t.write(Z.writeUint32(u.size)),t.write(Z.writeUint32(u.keyframe?33554432:65536)),e.isVideo&&t.write(Z.writeUint32(u.cts?u.cts:0))}),n.box(n.types.trun,this.extension(0,e.flags),r,i,t.buffer)}},{key:"senc",value:function(e){var t=new Z,r=e.samples.length,i=e.isVideo?16:8,s=e.isVideo?2:0,o=[],u=0;return e.isVideo?(o=e.videoSenc,u=e.videoSencLength):o=e.audioSenc,u=u||i*r,t.write(Z.writeUint32(16+u),n.types.senc,this.extension(0,s)),t.write(Z.writeUint32(r)),o.forEach(function(l){for(var f=0;f<l.InitializationVector.length;f++)t.write(new Uint8Array([l.InitializationVector[f]]));l.subsamples&&l.subsamples.length&&(t.write(Z.writeUint16(l.subsamples.length)),l.subsamples.forEach(function(c){t.write(Z.writeUint16(c.BytesOfClearData)),t.write(Z.writeUint32(c.BytesOfProtectedData))}))}),t.buffer}},{key:"saio",value:function(e){var t=e.samples.length*12+141;!e.isVideo&&e.isAudioEncryption&&(t=149);var r=new Uint8Array([1,0,0,0,0,0,0,1,0,0,0,0,t>>24&255,t>>16&255,t>>8&255,t&255]);return n.box(n.types.saio,r)}},{key:"saiz",value:function(e){var t=e.samples.length,r=new Uint8Array([0,0,0,0,16,t>>24&255,t>>16&255,t>>8&255,t&255]);return n.box(n.types.saiz,r)}},{key:"sbgp",value:function(){var e=new Uint8Array([114,111,108,108,0,0,0,1,0,0,1,25,0,0,0,1]);return n.box(n.types.sbgp,this.extension(0,0),e)}},{key:"extension",value:function(e,t){return new Uint8Array([e,t>>16&255,t>>8&255,t&255])}},{key:"tfhd",value:function(e){return n.box(n.types.tfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}},{key:"tfdt",value:function(e,t){var r=Math.floor(t/(zt+1)),i=Math.floor(t%(zt+1));return e.useEME&&(e.isVideoEncryption||e.isAudioEncryption)?n.box(n.types.tfdt,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,i&255])):n.box(n.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,r&255,i>>24,i>>16&255,i>>8&255,i&255]))}},{key:"trun",value:function(e,t){var r=e.length,i=12+16*r;t+=8+i;var s=new Uint8Array(i);s.set([0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,r&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0);for(var o=0;o<r;o++){var u=e[o],l=u.duration,f=u.size,c=u.flag,p=c===void 0?{}:c,_=u.cts,m=_===void 0?0:_;s.set([l>>>24&255,l>>>16&255,l>>>8&255,l&255,f>>>24&255,f>>>16&255,f>>>8&255,f&255,p.isLeading<<2|(p.dependsOn===null||p.dependsOn===void 0?1:p.dependsOn),p.isDependedOn<<6|p.hasRedundancy<<4|p.paddingValue<<1|(p.isNonSyncSample===null||p.isNonSyncSample===void 0?1:p.isNonSyncSample),p.degradationPriority&61440,p.degradationPriority&15,m>>>24&255,m>>>16&255,m>>>8&255,m&255],12+16*o)}return n.box(n.types.trun,s)}},{key:"moovMP4",value:function(e){return n.box.apply(n,[n.types.moov,n.mvhd(e[0].duration,e[0].timescale)].concat(oe(e.map(function(t){return n.trackMP4(t)}))))}},{key:"trackMP4",value:function(e){return n.box(n.types.trak,n.tkhd(e.id,e.duration,e.width,e.height),n.mdiaMP4(e))}},{key:"mdiaMP4",value:function(e){return n.box(n.types.mdia,n.mdhd(e.duration,e.timescale),n.hdlr(e.type),n.minfMP4(e))}},{key:"minfMP4",value:function(e){return n.box(n.types.minf,e.type===we.VIDEO?n.VMHD:n.SMHD,n.DINF,n.stblMP4(e))}},{key:"stblMP4",value:function(e){var t=e.ext,r=[n.stsd(e),n.stts(t.stts),n.stsc(t.stsc),n.stsz(t.stsz),n.stco(t.stco)];return t.stss.length&&r.push(n.stss(t.stss)),t.ctts.length&&r.push(n.ctts(t.ctts)),n.box.apply(n,[n.types.stbl].concat(r))}},{key:"stts",value:function(e){var t=e.length,r=new Uint8Array(8*t),i=0;return e.forEach(function(s){var o=s.value,u=s.count;r.set([u>>24,u>>16&255,u>>8&255,u&255,o>>24,o>>16&255,o>>8&255,o&255],i),i+=8}),n.box(n.types.stts,ue(new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]),r))}},{key:"stsc",value:function(e){var t=e.length,r=new Uint8Array(12*t),i=0;return e.forEach(function(s){var o=s.firstChunk,u=s.samplesPerChunk,l=s.sampleDescIndex;r.set([o>>24,o>>16&255,o>>8&255,o&255,u>>24,u>>16&255,u>>8&255,u&255,l>>24,l>>16&255,l>>8&255,l&255],i),i+=12}),n.box(n.types.stsc,ue(new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]),r))}},{key:"stsz",value:function(e){var t=e.length,r=new Uint8Array(4*t),i=0;return e.forEach(function(s){r.set([s>>24,s>>16&255,s>>8&255,s&255],i),i+=4}),n.box(n.types.stsz,ue(new Uint8Array([0,0,0,0,0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]),r))}},{key:"stco",value:function(e){var t=e.length,r=new Uint8Array(4*t),i=0;return e.forEach(function(s){r.set([s>>24,s>>16&255,s>>8&255,s&255],i),i+=4}),n.box(n.types.stco,ue(new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]),r))}},{key:"stss",value:function(e){var t=e.length,r=new Uint8Array(4*t),i=0;return e.forEach(function(s){r.set([s>>24,s>>16&255,s>>8&255,s&255],i),i+=4}),n.box(n.types.stss,ue(new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]),r))}},{key:"ctts",value:function(e){var t=e.length,r=new Uint8Array(8*t),i=0;return e.forEach(function(s){var o=s.value,u=s.count;r.set([u>>24,u>>16&255,u>>8&255,u&255,o>>24,o>>16&255,o>>8&255,o&255],i),i+=8}),n.box(n.types.ctts,ue(new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]),r))}},{key:"styp",value:function(){return n.box(n.types.styp,new Uint8Array([109,115,100,104,0,0,0,0,109,115,100,104,109,115,105,120]))}},{key:"sidx",value:function(e){var t=e.timescale,r=e.samples[0].duration,i=r*e.samples.length,s=e.samples[0].sampleOffset*r,o=8;e.samples.forEach(function(p){o+=p.size});var u=0;if(e.isVideo){var l=0,f;e.videoSenc&&(f=e.videoSenc),e.isVideo&&f.forEach(function(p){l=l+8,p.subsamples&&p.subsamples.length&&(l=l+2,l=l+p.subsamples.length*6)}),e.videoSencLength=l,u=o+141+e.samples.length*16+l,e.useEME&&e.isAudioEncryption&&!e.isVideoEncryption&&(u=o+e.samples.length*16+84)}else u=o+116+e.samples.length*12,e.useEME&&e.isAudioEncryption&&(u=o+169+e.samples.length*12+8*e.audioSenc.length);var c=new Uint8Array([0,0,0,0,0,0,0,e.id&255,t>>24&255,t>>16&255,t>>8&255,t&255,s>>24&255,s>>16&255,s>>8&255,s&255,0,0,0,0,0,0,0,1,0,u>>16&255,u>>8&255,u&255,i>>24&255,i>>16&255,i>>8&255,i&255,144,0,0,0]);return n.box(n.types.sidx,c)}},{key:"mdat",value:function(e){var t=n.box(n.types.mdat,e);return t}}]),n}();S(I,"types",["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(n,a){return n[a]=[a.charCodeAt(0),a.charCodeAt(1),a.charCodeAt(2),a.charCodeAt(3)],n},Object.create(null))),S(I,"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])}),S(I,"FTYPAVC1",I.box(I.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]))),S(I,"FTYPHEV1",I.box(I.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49]))),S(I,"DINF",I.box(I.types.dinf,I.box(I.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])))),S(I,"VMHD",I.box(I.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]))),S(I,"SMHD",I.box(I.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0]))),S(I,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0])),S(I,"STTS",I.box(I.types.stts,I.StblTable)),S(I,"STSC",I.box(I.types.stsc,I.StblTable)),S(I,"STSZ",I.box(I.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]))),S(I,"STCO",I.box(I.types.stco,I.StblTable));var Wt=function(){function n(a,e){H(this,n),this.name=a||"",this._prefix="[".concat(this.name,"]"),n.disabled=e}return z(n,[{key:"debug",value:function(){var e;if(!n.disabled){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];(e=console).debug.apply(e,[this._prefix].concat(r))}}},{key:"log",value:function(){var e;if(!n.disabled){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];(e=console).log.apply(e,[this._prefix].concat(r))}}},{key:"warn",value:function(){var e;if(!n.disabled){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];(e=console).warn.apply(e,[this._prefix].concat(r))}}},{key:"error",value:function(){var e;if(!n.disabled){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];(e=console).error.apply(e,[this._prefix].concat(r))}}},{key:"table",value:function(){var e;n.disabled||(console.group(this._prefix),(e=console).table.apply(e,arguments),console.groupEnd())}}],[{key:"enable",value:function(){n.disabled=!1}},{key:"disable",value:function(){n.disabled=!0}}]),n}();S(Wt,"disabled",!0);var an=function(){function n(a,e,t){H(this,n),this.videoTrack=a,this.audioTrack=e;var r=/Chrome\/([^.]+)/.exec(navigator.userAgent);this.forceFirstIDR=r&&Number(r[1])<50,this.log=new Wt("FMP4Remuxer",t&&t.openLog?!t.openLog:!0)}return z(n,[{key:"remux",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=this.videoTrack,i=this.audioTrack,s=r.exist(),o=i.exist(),u,l,f,c=[];e&&(t&&t.initMerge?(s&&c.push(this.videoTrack),o&&c.push(this.audioTrack),f=I.initSegment(c)):(s&&(u=I.initSegment([this.videoTrack])),o&&(l=I.initSegment([this.audioTrack]))));var p,_;return s&&r.hasSample()&&(p=this._remuxVideo()),o&&i.hasSample()&&(_=this._remuxAudio()),r.samples=[],i.samples=[],{initSegment:f,videoInitSegment:u,audioInitSegment:l,videoSegment:p,audioSegment:_}}},{key:"_remuxVideo",value:function(){var e=this.videoTrack;this.forceFirstIDR&&(e.samples[0].flag={dependsOn:2,isNonSyncSample:0});var t=e.samples,r=0;t.forEach(function(m){r+=m.units.reduce(function(b,v){return b+v.byteLength},0),r+=m.units.length*4});for(var i=new Uint8Array(r),s=new DataView(i.buffer),o=function(b,v){v=t[u];var w=0;v.units.forEach(function(D){s.setUint32(b,D.byteLength),b+=4,i.set(D,b),b+=D.byteLength,w+=4+D.byteLength}),v.size=w,f=b,c=v},u=0,l=t.length,f=0,c;u<l;u++)o(f,c);var p=I.mdat(i),_=I.moof([e]);return ue(_,p)}},{key:"_remuxAudio",value:function(){var e=this.audioTrack,t=new Uint8Array(e.samples.reduce(function(s,o){return s+o.size},0));e.samples.reduce(function(s,o){return t.set(o.data,s),s+o.size},0);var r=I.mdat(t),i=I.moof([e]);return ue(i,r)}},{key:"reset",value:function(){this.videoTrack.reset(),this.audioTrack.reset()}}]),n}(),de=new _e("BufferService"),sn=function(){function n(a,e,t){ct(this,n),C(this,"flv",null),C(this,"_demuxer",new Ht),C(this,"_remuxer",null),C(this,"_mse",null),C(this,"_softVideo",null),C(this,"_sourceCreated",!1),C(this,"_needInitSegment",!0),C(this,"_discontinuity",!0),C(this,"_contiguous",!1),C(this,"_initSegmentId",""),C(this,"_cachedBuffer",null),C(this,"_demuxStartTime",0),C(this,"_opts",null),this.flv=a,this._opts=t,e?this._softVideo=e:(this._remuxer=new an(this._demuxer.videoTrack,this._demuxer.audioTrack),this._mse=new Le(null,{preferMMS:typeof t.preferMMS=="boolean"?t.preferMMS:!!t.perferMMS}),this._mse.bindMedia(a.media))}return dt(n,[{key:"baseDts",get:function(){var e,t;return(e=this._demuxer)===null||e===void 0||(t=e._fixer)===null||t===void 0?void 0:t._baseDts}},{key:"blobUrl",get:function(){var e;return(e=this._mse)===null||e===void 0?void 0:e.url}},{key:"isFull",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Le.VIDEO;return this._mse.isFull(e)}},{key:"seamlessSwitch",value:function(){this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!0,this._initSegmentId=""}},{key:"unContiguous",value:function(e){this._contiguous=!1,this._demuxStartTime=e}},{key:"reset",value:function(){var a=J(M().mark(function t(){var r,i=arguments;return M().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(r=i.length>0&&i[0]!==void 0?i[0]:!1,!(this._mse&&!r)){o.next=6;break}return o.next=4,this._mse.unbindMedia();case 4:return o.next=6,this._mse.bindMedia(this.flv.media);case 6:this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!1,this._sourceCreated=!1,this._initSegmentId="";case 11:case"end":return o.stop()}},t,this)}));function e(){return a.apply(this,arguments)}return e}()},{key:"endOfStream",value:function(){var a=J(M().mark(function t(){return M().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(!this._mse){i.next=7;break}if(!this._sourceCreated){i.next=5;break}return i.next=4,this._mse.endOfStream();case 4:this.flv.emit(x.BUFFEREOS);case 5:i.next=8;break;case 7:this._softVideo&&this._softVideo.endOfStream();case 8:case"end":return i.stop()}},t,this)}));function e(){return a.apply(this,arguments)}return e}()},{key:"updateDuration",value:function(){var a=J(M().mark(function t(r){return M().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(!this._mse){s.next=7;break}if(this._mse.isOpened){s.next=4;break}return s.next=4,this._mse.open();case 4:return de.debug("update duration",r),s.next=7,this._mse.updateDuration(r);case 7:case"end":return s.stop()}},t,this)}));function e(t){return a.apply(this,arguments)}return e}()},{key:"destroy",value:function(){var a=J(M().mark(function t(){return M().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(!this._mse){i.next=3;break}return i.next=3,this._mse.unbindMedia();case 3:this._mse=null,this._softVideo=null,this._demuxer=null,this._remuxer=null;case 7:case"end":return i.stop()}},t,this)}));function e(){return a.apply(this,arguments)}return e}()},{key:"appendBuffer",value:function(){var a=J(M().mark(function t(r){var i,s,o,u,l,f,c,p,_,m,b,v,w,D;return M().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:if(this._cachedBuffer&&(r=Sr(this._cachedBuffer,r),this._cachedBuffer=null),i=this._demuxer,!(!r||!r.length||!i)){k.next=4;break}return k.abrupt("return");case 4:k.prev=4,i.demuxAndFix(r,this._discontinuity,this._contiguous,this._demuxStartTime),k.next=11;break;case 8:throw k.prev=8,k.t0=k.catch(4),new ce(V.DEMUX,V.SUB_TYPES.FLV,k.t0);case 11:if(s=i.videoTrack,o=i.audioTrack,u=i.metadataTrack,l=s.exist(),f=o.exist(),this._opts.onlyAudio&&(l=!1,s.present=!1),this._opts.onlyVideo&&(f=!1,o.present=!1),!(!l&&s.present||!f&&o.present)){k.next=29;break}if(c=0,p=l?s:f?o:void 0,p&&p.samples.length&&(c=(p.samples[p.samples.length-1].originPts-p.samples[0].originPts)/p.timescale*1e3),!(c>this._opts.analyzeDuration)){k.next=27;break}de.warn("analyze duration exceeded, ".concat(c,"ms"),p),s.present=l,o.present=f,this.flv.emit(x.ANALYZE_DURATION_EXCEEDED,{duration:c}),k.next=29;break;case 27:return this._cachedBuffer=r,k.abrupt("return");case 29:if(_=s.type,m=o.type,this._fireEvents(s,o,u),this._discontinuity=!1,this._contiguous=!0,this._demuxStartTime=0,b=this._mse,this.flv.emit(x.DEMUXED_TRACK,{videoTrack:s}),v="".concat(s.codec,"/").concat(s.width,"/").concat(s.height,"/").concat(o.codec,"/").concat(o.config),v!==this._initSegmentId&&(this._needInitSegment=!0,this._initSegmentId=v,this._emitMetaParsedEvent(s,o)),!b){k.next=65;break}if(this._sourceCreated){k.next=47;break}return k.next=43,b.open();case 43:l&&(de.log("codec: video/mp4;codecs=".concat(s.codec)),b.createSource(_,"video/mp4;codecs=".concat(s.codec))),f&&(de.log("codec: audio/mp4;codecs=".concat(o.codec)),b.createSource(m,"audio/mp4;codecs=".concat(o.codec))),this._sourceCreated=!0,this.flv.emit(x.SOURCEBUFFER_CREATED);case 47:k.prev=47,w=this._remuxer.remux(this._needInitSegment),k.next=54;break;case 51:throw k.prev=51,k.t1=k.catch(47),new ce(V.REMUX,V.SUB_TYPES.FMP4,k.t1);case 54:if(!(this._needInitSegment&&!w.videoInitSegment&&!w.audioInitSegment)){k.next=56;break}return k.abrupt("return");case 56:return this._needInitSegment=!1,D=[],w.videoInitSegment&&D.push(b.append(_,w.videoInitSegment)),w.audioInitSegment&&D.push(b.append(m,w.audioInitSegment)),w.videoSegment&&D.push(b.append(_,w.videoSegment)),w.audioSegment&&D.push(b.append(m,w.audioSegment)),k.abrupt("return",Promise.all(D));case 65:this._softVideo&&this._softVideo.appendBuffer(s,o);case 66:case"end":return k.stop()}},t,this,[[4,8],[47,51]])}));function e(t){return a.apply(this,arguments)}return e}()},{key:"evictBuffer",value:function(){var a=J(M().mark(function t(r){var i=this,s,o,u,l;return M().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(s=this.flv.media,!(!this._mse||!this._demuxer||!s||!r||r<0)){c.next=3;break}return c.abrupt("return");case 3:if(o=s.currentTime,u=o-r,!(u<=0)){c.next=7;break}return c.abrupt("return");case 7:if(l=ee.start(ee.get(s)),!(l+1>=u)){c.next=10;break}return c.abrupt("return");case 10:return c.abrupt("return",this._mse.clearBuffer(0,u).then(function(){return i.flv.emit(x.REMOVE_BUFFER,{removeEnd:u})}));case 11:case"end":return c.stop()}},t,this)}));function e(t){return a.apply(this,arguments)}return e}()},{key:"_emitMetaParsedEvent",value:function(e,t){e.exist()&&this.flv.emit(x.METADATA_PARSED,{type:"video",track:e,meta:{codec:e.codec,timescale:e.timescale,width:e.width,height:e.height,sarRatio:e.sarRatio,baseDts:e.baseDts}}),t.exist()&&this.flv.emit(x.METADATA_PARSED,{type:"audio",track:t,meta:{codec:t.codec,channelCount:t.channelCount,sampleRate:t.sampleRate,timescale:t.timescale,baseDts:t.baseDts}}),de.debug("track parsed",e,t)}},{key:"_fireEvents",value:function(e,t,r){var i=this;de.debug(e.samples,t.samples),r.flvScriptSamples.forEach(function(s){i.flv.emit(x.FLV_SCRIPT_DATA,s),de.debug("flvScriptData",s)}),e.samples.forEach(function(s){s.keyframe&&i.flv.emit(x.KEYFRAME,{pts:s.pts})}),e.warnings.forEach(function(s){var o;switch(s.type){case ae.LARGE_AV_SHIFT:o=x.LARGE_AV_FIRST_FRAME_GAP_DETECT;break;case ae.LARGE_VIDEO_GAP:o=x.LARGE_VIDEO_DTS_GAP_DETECT;break;case ae.LARGE_VIDEO_GAP_BETWEEN_CHUNK:o=x.MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT;break}o&&i.flv.emit(x.STREAM_EXCEPTION,le(le({},s),{},{type:o})),de.warn("video exception",s)}),t.warnings.forEach(function(s){var o;switch(s.type){case ae.LARGE_AUDIO_GAP:o=x.LARGE_AUDIO_DTS_GAP_DETECT;break;case ae.AUDIO_FILLED:o=x.AUDIO_GAP_DETECT;break;case ae.AUDIO_DROPPED:o=x.AUDIO_OVERLAP_DETECT;break}o&&i.flv.emit(x.STREAM_EXCEPTION,le(le({},s),{},{type:o})),de.warn("audio exception",s)}),r.seiSamples.forEach(function(s){i.flv.emit(x.SEI,le(le({},s),{},{sei:{code:s.data.type,content:s.data.payload,dts:s.pts}}))})}}]),n}();function on(n){var a=le({retryCount:3,retryDelay:1e3,disconnectRetryCount:0,loadTimeout:1e4,maxReaderInterval:5e3,preloadTime:5,defaultVodLoadSize:1e7,isLive:!1,softDecode:!1,bufferBehind:10,maxJumpDistance:3,analyzeDuration:2e4,seamlesslyReload:!1,keepStatusAfterSwitch:!0,onlyVideo:!1,onlyAudio:!1,preferMMS:!1},n);return a.isLive&&a.preloadTime&&(a.maxLatency||(a.maxLatency=a.preloadTime*2),a.targetLatency||(a.targetLatency=a.preloadTime),(a.disconnectTime===null||a.disconnectTime===void 0)&&(a.disconnectTime=a.maxLatency)),a}function Kt(n,a){var e=0,t=n.length-1,r=0,i=0,s=t;for(a<n[0]&&(e=0,i=s+1);i<=s;)if(r=i+Math.floor((s-i)/2),r===t||a>=n[r]&&a<n[r+1]){e=r;break}else n[r]<a?i=r+1:s=r-1;return e}var ve=new _e("flv"),He=.1,ze=function(n){qt(e,n);var a=Qt(e);function e(t){var r;return ct(this,e),r=a.call(this),C(B(r),"media",null),C(B(r),"_loading",!1),C(B(r),"_opts",null),C(B(r),"_bufferService",null),C(B(r),"_gapService",null),C(B(r),"_stats",null),C(B(r),"_mediaLoader",null),C(B(r),"_maxChunkWaitTimer",null),C(B(r),"_tickTimer",null),C(B(r),"_tickInterval",500),C(B(r),"_urlSwitching",!1),C(B(r),"_seamlessSwitching",!1),C(B(r),"_disconnectRetryCount",0),C(B(r),"_preLoadEndPoint",0),C(B(r),"_keyframes",null),C(B(r),"_acceptRanges",!0),C(B(r),"_onProgress",function(){var i=J(M().mark(function s(o,u,l,f){var c,p,_,m,b,v,w,D,O;return M().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if(c=l.startTime,p=l.endTime,_=l.st,m=l.firstByteTime,r._loading=!u,r._firstProgressEmit){A.next=11;break}if(r.media){A.next=6;break}return(b=r._mediaLoader)===null||b===void 0||b.cancel(),A.abrupt("return");case 6:v=f.headers,r.emit(x.TTFB,{url:r._opts.url,responseUrl:f.url,elapsed:_?m-_:p-c}),r.emit(x.LOAD_RESPONSE_HEADERS,{headers:v}),r._acceptRanges=!!(v!=null&&v.get("Accept-Ranges"))||!!(v!=null&&v.get("Content-Range")),r._firstProgressEmit=!0;case 11:if(r._bufferService){A.next=13;break}return A.abrupt("return");case 13:return clearTimeout(r._maxChunkWaitTimer),r._bandwidthService.addChunkRecord(o?.byteLength,p-c),A.prev=15,A.next=18,r._bufferService.appendBuffer(o);case 18:(w=r._bufferService)===null||w===void 0||w.evictBuffer(r._opts.bufferBehind),A.next=31;break;case 21:if(A.prev=21,A.t0=A.catch(15),!(!r.isLive&&r._bufferService.isFull())){A.next=30;break}return A.next=26,r._mediaLoader.cancel();case 26:return r._loading=!1,D=r.bufferInfo().remaining,r._opts.preloadTime=parseInt(D)/2,A.abrupt("return");case 30:return A.abrupt("return",r._emitError(ce.create(A.t0)));case 31:if(r._urlSwitching&&(r._urlSwitching=!1,r.emit(x.SWITCH_URL_SUCCESS,{url:r._opts.url})),r._seamlessSwitching&&(r._seamlessSwitching=!1,r._tick()),!(u&&!r.media.seeking)){A.next=38;break}return r.emit(x.LOAD_COMPLETE),ve.debug("load done"),r.isLive&&r._disconnectRetryCount<=0&&r._end(),A.abrupt("return");case 38:if(r.isLive){A.next=40;break}return A.abrupt("return");case 40:O=r._opts.maxReaderInterval,O&&(clearTimeout(r._maxChunkWaitTimer),r._maxChunkWaitTimer=setTimeout(function(){if(r._disconnectRetryCount){r._disconnectRetryCount--,r.load();return}ve.debug("onMaxChunkWait",O),r._end()},O));case 42:case"end":return A.stop()}},s,null,[[15,21]])}));return function(s,o,u,l){return i.apply(this,arguments)}}()),C(B(r),"_onRetryError",function(i,s){ve.debug("load retry",i,s),r.emit(x.LOAD_RETRY,{error:ce.network(i),retryTime:s})}),C(B(r),"_end",function(){r._clear(),r._bufferService&&r._bufferService.endOfStream(),ve.debug("end stream")}),C(B(r),"_resetDisconnectCount",function(){r._disconnectRetryCount=r._opts.disconnectRetryCount}),C(B(r),"_tick",function(){clearTimeout(r._tickTimer);var i=B(r),s=i.media;if(s){r._tickTimer=setTimeout(r._tick,r._tickInterval);var o=ee.end(ee.get(s));if(!(o<He||!s.readyState)){var u=r._opts;if(br(s))r._gapService&&r._gapService.do(s,u.maxJumpDistance,r.isLive,3);else{if(!s.currentTime&&r._gapService){r._gapService.do(s,u.maxJumpDistance,r.isLive,3);return}u.isLive&&s.readyState===4&&o>u.disconnectTime&&r.disconnect()}}}}),C(B(r),"_onPlay",function(){var i,s,o=r._opts.softDecode||((i=r.media)===null||i===void 0||(s=i.buffered)===null||s===void 0?void 0:s.length);if(r.isLive){!r._loading&&o&&r.replay(void 0,!0);return}var u=r.bufferInfo();(u.start||u.nextStart)>He&&r._tick()}),C(B(r),"_onSeeking",J(M().mark(function i(){return M().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:!r.isLive&&r.seekable&&(r._preLoadEndPoint=-1,r._checkPreload());case 1:case"end":return o.stop()}},i)}))),C(B(r),"_onTimeupdate",function(){if(r.media){var i=r._opts,s=r.media.currentTime;if(i.isLive&&i.maxLatency&&i.targetLatency){var o=ee.end(ee.get(r.media)),u=o-s;u>=i.maxLatency&&(r.media.currentTime=o-i.targetLatency)}r._seiService.throw(s,!0),!(i.isLive||!r.seekable||r._loading)&&r._checkPreload()}}),C(B(r),"_onWaiting",function(){r.isLive&&!r._loading&&r._disconnectRetryCount&&(r._disconnectRetryCount--,r.load())}),C(B(r),"_onBufferUpdate",function(){if(!r._opts.isLive){var i=r.bufferInfo(),s=i.end,o=i.nextEnd;Math.abs((s||o)-r.media.duration)<1&&(r._end(),r.media.readyState<=2&&r._tick())}}),C(B(r),"_checkPreload",J(M().mark(function i(){var s,o,u,l,f,c,p,_,m,b;return M().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:if(s=r.bufferInfo(),o=s.remaining,u=o===void 0?0:o,l=r._opts,f=r._keyframes.filepositions,c=r._keyframes.times,p=r.media.currentTime,!(u<l.preloadTime)){w.next=19;break}if(_=Kt(r._keyframes.times,p+u+He),m=Kt(r._keyframes.times,p+u+r._opts.preloadTime),m===_&&(m=_+1),r._preLoadEndPoint!==m){w.next=11;break}return w.abrupt("return");case 11:if(b=f[_],b!=null){w.next=14;break}return w.abrupt("return");case 14:return w.next=16,r._mediaLoader.cancel();case 16:r._loadData(null,[b,f[m]]),r._preLoadEndPoint=m,r._bufferService.unContiguous(c[_]);case 19:case"end":return w.stop()}},i)}))),C(B(r),"_onFlvScriptData",function(i){var s,o,u,l,f=(s=i.data)===null||s===void 0||(o=s.onMetaData)===null||o===void 0?void 0:o.keyframes,c=(u=i.data)===null||u===void 0||(l=u.onMetaData)===null||l===void 0?void 0:l.duration;f&&(r._keyframes=f),!r._opts.isLive&&c&&r._bufferService.updateDuration(c)}),r._opts=on(t),r.media=r._opts.media||document.createElement("video"),r._opts.media=null,r._firstProgressEmit=!1,r._mediaLoader=new Tr(le(le({},r._opts.fetchOptions),{},{retry:r._opts.retryCount,retryDelay:r._opts.retryDelay,timeout:r._opts.loadTimeout,onRetryError:r._onRetryError,onProgress:r._onProgress,responseType:"arraybuffer"})),r._disconnectRetryCount=r._opts.disconnectRetryCount,r._bufferService=new sn(B(r),r._opts.softDecode?r.media:void 0,r._opts),r._seiService=new kr(B(r)),r._bandwidthService=new Or,r._stats=new Dr(B(r)),r._opts.softDecode||(r._gapService=new Ar),r.media.addEventListener("play",r._onPlay),r.media.addEventListener("seeking",r._onSeeking),r.media.addEventListener("timeupdate",r._onTimeupdate),r.media.addEventListener("progress",r._onBufferUpdate),r.media.addEventListener("waiting",r._onWaiting),r.on(x.FLV_SCRIPT_DATA,r._onFlvScriptData),r}return dt(e,[{key:"version",get:function(){return"3.0.16"}},{key:"isLive",get:function(){return this._opts.isLive}},{key:"baseDts",get:function(){var r;return(r=this._bufferService)===null||r===void 0?void 0:r.baseDts}},{key:"seekable",get:function(){return!!this._keyframes&&this._acceptRanges}},{key:"loader",get:function(){return this._mediaLoader}},{key:"blobUrl",get:function(){var r;return(r=this._bufferService)===null||r===void 0?void 0:r.blobUrl}},{key:"speedInfo",value:function(){return{speed:this._bandwidthService.getLatestSpeed(),avgSpeed:this._bandwidthService.getAvgSpeed()}}},{key:"getStats",value:function(){return this._stats.getStats()}},{key:"bufferInfo",value:function(){var r,i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:He;return ee.info(ee.get(this.media),(r=this.media)===null||r===void 0?void 0:r.currentTime,i)}},{key:"playbackQuality",value:function(){return Er(this.media)}},{key:"load",value:function(){var t=J(M().mark(function i(s){var o,u=arguments;return M().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(o=u.length>1&&u[1]!==void 0?u[1]:!1,this._bufferService){f.next=3;break}return f.abrupt("return");case 3:return f.next=5,this._reset(o);case 5:this._loadData(s,this._opts.isLive?[]:[0,this._opts.defaultVodLoadSize]),clearTimeout(this._tickTimer),this._tickTimer=setTimeout(this._tick,this._tickInterval);case 8:case"end":return f.stop()}},i,this)}));function r(i){return t.apply(this,arguments)}return r}()},{key:"replay",value:function(){var t=J(M().mark(function i(){var s=this,o,u,l=arguments;return M().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(o=l.length>0&&l[0]!==void 0?l[0]:this._opts.seamlesslyReload,u=l.length>1?l[1]:void 0,this.media){c.next=4;break}return c.abrupt("return");case 4:if(this._resetDisconnectCount(),!o){c.next=11;break}return c.next=8,this._clear();case 8:setTimeout(function(){s._loadData(s._opts.url),s._bufferService.seamlessSwitch(),s._seamlessSwitching=!0}),c.next=13;break;case 11:return c.next=13,this.load();case 13:return c.abrupt("return",this.media.play(!u).catch(function(){}));case 14:case"end":return c.stop()}},i,this)}));function r(){return t.apply(this,arguments)}return r}()},{key:"disconnect",value:function(){return ve.debug("disconnect!"),this._clear()}},{key:"switchURL",value:function(){var t=J(M().mark(function i(s,o){var u=this;return M().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(this._bufferService){f.next=2;break}return f.abrupt("return");case 2:if(this._resetDisconnectCount(),!(!o||!this._opts.isLive)){f.next=8;break}return f.next=6,this.load(s);case 6:return this._urlSwitching=!0,f.abrupt("return",this.media.play(!0).catch(function(){}));case 8:return f.next=10,this._clear();case 10:setTimeout(function(){u._loadData(s),u._bufferService.seamlessSwitch(),u._urlSwitching=!0,u._seamlessSwitching=!0});case 11:case"end":return f.stop()}},i,this)}));function r(i,s){return t.apply(this,arguments)}return r}()},{key:"destroy",value:function(){var t=J(M().mark(function i(){return M().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(this.media){o.next=2;break}return o.abrupt("return");case 2:return this.removeAllListeners(),this._seiService.reset(),this.media.removeEventListener("play",this._onPlay),this.media.removeEventListener("seeking",this._onSeeking),this.media.removeEventListener("timeupdate",this._onTimeupdate),this.media.removeEventListener("waiting",this._onWaiting),this.media.removeEventListener("progress",this._onBufferUpdate),o.next=11,Promise.all([this._clear(),this._bufferService.destroy()]);case 11:this.media=null,this._bufferService=null;case 13:case"end":return o.stop()}},i,this)}));function r(){return t.apply(this,arguments)}return r}()},{key:"_emitError",value:function(r){var i,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;ve.table(r),ve.error(r),ve.error((i=this.media)===null||i===void 0?void 0:i.error),this._urlSwitching&&(this._urlSwitching=!1,this._seamlessSwitching=!1,this.emit(x.SWITCH_URL_FAILED,r)),this.emit(x.ERROR,r),s&&(this._seiService.reset(),this._end())}},{key:"_reset",value:function(){var t=J(M().mark(function i(){var s,o=arguments;return M().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return s=o.length>0&&o[0]!==void 0?o[0]:!1,this._seiService.reset(),this._bandwidthService.reset(),this._stats.reset(),l.next=6,this._clear();case 6:return l.next=8,this._bufferService.reset(s);case 8:case"end":return l.stop()}},i,this)}));function r(){return t.apply(this,arguments)}return r}()},{key:"_loadData",value:function(){var t=J(M().mark(function i(s,o){var u;return M().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(s&&(this._opts.url=s),u=s=this._opts.url,s){f.next=4;break}throw new Error("Source url is missing");case 4:if(this._opts.preProcessUrl&&(u=this._opts.preProcessUrl(s).url),this._mediaLoader.finnalUrl=u,this.emit(x.LOAD_START,{url:u}),ve.debug("load data, loading:",this._loading,u),!this._loading){f.next=11;break}return f.next=11,this._mediaLoader.cancel();case 11:return this._loading=!0,f.prev=12,f.next=15,this._mediaLoader.load({url:u,range:o});case 15:f.next=21;break;case 17:return f.prev=17,f.t0=f.catch(12),this._loading=!1,f.abrupt("return",this._emitError(ce.network(f.t0)));case 21:case"end":return f.stop()}},i,this,[[12,17]])}));function r(i,s){return t.apply(this,arguments)}return r}()},{key:"_clear",value:function(){var t=J(M().mark(function i(){return M().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(!this._mediaLoader){o.next=3;break}return o.next=3,this._mediaLoader.cancel();case 3:clearTimeout(this._maxChunkWaitTimer),clearTimeout(this._tickTimer),this._loading=!1,this._firstProgressEmit=!1;case 7:case"end":return o.stop()}},i,this)}));function r(){return t.apply(this,arguments)}return r}()}],[{key:"isSupported",value:function(r){return!r||r==="video"||r==="audio"?Le.isSupported():typeof WebAssembly<"u"}},{key:"enableLogger",value:function(){_e.enable(),Ve.enable()}},{key:"disableLogger",value:function(){_e.disable(),Ve.disable()}}]),e}(er);try{localStorage.getItem("xgd")?ze.enableLogger():ze.disableLogger()}catch{}export{ze as Flv,ze as default};