lemon-mse 0.2.7 → 0.2.9

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