lemon-mse 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/xg-hls.mjs DELETED
@@ -1,8 +0,0 @@
1
- function Ur(i,a){var e=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(e!=null){var t,r,n,s,o=[],u=!0,l=!1;try{if(n=(e=e.call(i)).next,a===0){if(Object(e)!==e)return;u=!1}else for(;!(u=(t=n.call(e)).done)&&(o.push(t.value),o.length!==a);u=!0);}catch(c){l=!0,r=c}finally{try{if(!u&&e.return!=null&&(s=e.return(),Object(s)!==s))return}finally{if(l)throw r}}return o}}function Ht(i,a){var e=Object.keys(i);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(i);a&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),e.push.apply(e,t)}return e}function ee(i){for(var a=1;a<arguments.length;a++){var e=arguments[a]!=null?arguments[a]:{};a%2?Ht(Object(e),!0).forEach(function(t){E(i,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(e)):Ht(Object(e)).forEach(function(t){Object.defineProperty(i,t,Object.getOwnPropertyDescriptor(e,t))})}return i}function C(){C=function(){return i};var i={},a=Object.prototype,e=a.hasOwnProperty,t=Object.defineProperty||function(m,g,S){m[g]=S.value},r=typeof Symbol=="function"?Symbol:{},n=r.iterator||"@@iterator",s=r.asyncIterator||"@@asyncIterator",o=r.toStringTag||"@@toStringTag";function u(m,g,S){return Object.defineProperty(m,g,{value:S,enumerable:!0,configurable:!0,writable:!0}),m[g]}try{u({},"")}catch{u=function(g,S,O){return g[S]=O}}function l(m,g,S,O){var k=g&&g.prototype instanceof v?g:v,I=Object.create(k.prototype),V=new G(O||[]);return t(I,"_invoke",{value:T(m,S,V)}),I}function c(m,g,S){try{return{type:"normal",arg:m.call(g,S)}}catch(O){return{type:"throw",arg:O}}}i.wrap=l;var f={};function v(){}function h(){}function p(){}var y={};u(y,n,function(){return this});var d=Object.getPrototypeOf,_=d&&d(d(M([])));_&&_!==a&&e.call(_,n)&&(y=_);var b=p.prototype=v.prototype=Object.create(y);function w(m){["next","throw","return"].forEach(function(g){u(m,g,function(S){return this._invoke(g,S)})})}function D(m,g){function S(k,I,V,z){var K=c(m[k],m,I);if(K.type!=="throw"){var R=K.arg,te=R.value;return te&&typeof te=="object"&&e.call(te,"__await")?g.resolve(te.__await).then(function(U){S("next",U,V,z)},function(U){S("throw",U,V,z)}):g.resolve(te).then(function(U){R.value=U,V(R)},function(U){return S("throw",U,V,z)})}z(K.arg)}var O;t(this,"_invoke",{value:function(k,I){function V(){return new g(function(z,K){S(k,I,z,K)})}return O=O?O.then(V,V):V()}})}function T(m,g,S){var O="suspendedStart";return function(k,I){if(O==="executing")throw new Error("Generator is already running");if(O==="completed"){if(k==="throw")throw I;return q()}for(S.method=k,S.arg=I;;){var V=S.delegate;if(V){var z=F(V,S);if(z){if(z===f)continue;return z}}if(S.method==="next")S.sent=S._sent=S.arg;else if(S.method==="throw"){if(O==="suspendedStart")throw O="completed",S.arg;S.dispatchException(S.arg)}else S.method==="return"&&S.abrupt("return",S.arg);O="executing";var K=c(m,g,S);if(K.type==="normal"){if(O=S.done?"completed":"suspendedYield",K.arg===f)continue;return{value:K.arg,done:S.done}}K.type==="throw"&&(O="completed",S.method="throw",S.arg=K.arg)}}}function F(m,g){var S=g.method,O=m.iterator[S];if(O===void 0)return g.delegate=null,S==="throw"&&m.iterator.return&&(g.method="return",g.arg=void 0,F(m,g),g.method==="throw")||S!=="return"&&(g.method="throw",g.arg=new TypeError("The iterator does not provide a '"+S+"' method")),f;var k=c(O,m.iterator,g.arg);if(k.type==="throw")return g.method="throw",g.arg=k.arg,g.delegate=null,f;var I=k.arg;return I?I.done?(g[m.resultName]=I.value,g.next=m.nextLoc,g.method!=="return"&&(g.method="next",g.arg=void 0),g.delegate=null,f):I:(g.method="throw",g.arg=new TypeError("iterator result is not an object"),g.delegate=null,f)}function B(m){var g={tryLoc:m[0]};1 in m&&(g.catchLoc=m[1]),2 in m&&(g.finallyLoc=m[2],g.afterLoc=m[3]),this.tryEntries.push(g)}function N(m){var g=m.completion||{};g.type="normal",delete g.arg,m.completion=g}function G(m){this.tryEntries=[{tryLoc:"root"}],m.forEach(B,this),this.reset(!0)}function M(m){if(m){var g=m[n];if(g)return g.call(m);if(typeof m.next=="function")return m;if(!isNaN(m.length)){var S=-1,O=function k(){for(;++S<m.length;)if(e.call(m,S))return k.value=m[S],k.done=!1,k;return k.value=void 0,k.done=!0,k};return O.next=O}}return{next:q}}function q(){return{value:void 0,done:!0}}return h.prototype=p,t(b,"constructor",{value:p,configurable:!0}),t(p,"constructor",{value:h,configurable:!0}),h.displayName=u(p,o,"GeneratorFunction"),i.isGeneratorFunction=function(m){var g=typeof m=="function"&&m.constructor;return!!g&&(g===h||(g.displayName||g.name)==="GeneratorFunction")},i.mark=function(m){return Object.setPrototypeOf?Object.setPrototypeOf(m,p):(m.__proto__=p,u(m,o,"GeneratorFunction")),m.prototype=Object.create(b),m},i.awrap=function(m){return{__await:m}},w(D.prototype),u(D.prototype,s,function(){return this}),i.AsyncIterator=D,i.async=function(m,g,S,O,k){k===void 0&&(k=Promise);var I=new D(l(m,g,S,O),k);return i.isGeneratorFunction(g)?I:I.next().then(function(V){return V.done?V.value:I.next()})},w(b),u(b,o,"Generator"),u(b,n,function(){return this}),u(b,"toString",function(){return"[object Generator]"}),i.keys=function(m){var g=Object(m),S=[];for(var O in g)S.push(O);return S.reverse(),function k(){for(;S.length;){var I=S.pop();if(I in g)return k.value=I,k.done=!1,k}return k.done=!0,k}},i.values=M,G.prototype={constructor:G,reset:function(m){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(N),!m)for(var g in this)g.charAt(0)==="t"&&e.call(this,g)&&!isNaN(+g.slice(1))&&(this[g]=void 0)},stop:function(){this.done=!0;var m=this.tryEntries[0].completion;if(m.type==="throw")throw m.arg;return this.rval},dispatchException:function(m){if(this.done)throw m;var g=this;function S(K,R){return I.type="throw",I.arg=m,g.next=K,R&&(g.method="next",g.arg=void 0),!!R}for(var O=this.tryEntries.length-1;O>=0;--O){var k=this.tryEntries[O],I=k.completion;if(k.tryLoc==="root")return S("end");if(k.tryLoc<=this.prev){var V=e.call(k,"catchLoc"),z=e.call(k,"finallyLoc");if(V&&z){if(this.prev<k.catchLoc)return S(k.catchLoc,!0);if(this.prev<k.finallyLoc)return S(k.finallyLoc)}else if(V){if(this.prev<k.catchLoc)return S(k.catchLoc,!0)}else{if(!z)throw new Error("try statement without catch or finally");if(this.prev<k.finallyLoc)return S(k.finallyLoc)}}}},abrupt:function(m,g){for(var S=this.tryEntries.length-1;S>=0;--S){var O=this.tryEntries[S];if(O.tryLoc<=this.prev&&e.call(O,"finallyLoc")&&this.prev<O.finallyLoc){var k=O;break}}k&&(m==="break"||m==="continue")&&k.tryLoc<=g&&g<=k.finallyLoc&&(k=null);var I=k?k.completion:{};return I.type=m,I.arg=g,k?(this.method="next",this.next=k.finallyLoc,f):this.complete(I)},complete:function(m,g){if(m.type==="throw")throw m.arg;return m.type==="break"||m.type==="continue"?this.next=m.arg:m.type==="return"?(this.rval=this.arg=m.arg,this.method="return",this.next="end"):m.type==="normal"&&g&&(this.next=g),f},finish:function(m){for(var g=this.tryEntries.length-1;g>=0;--g){var S=this.tryEntries[g];if(S.finallyLoc===m)return this.complete(S.completion,S.afterLoc),N(S),f}},catch:function(m){for(var g=this.tryEntries.length-1;g>=0;--g){var S=this.tryEntries[g];if(S.tryLoc===m){var O=S.completion;if(O.type==="throw"){var k=O.arg;N(S)}return k}}throw new Error("illegal catch attempt")},delegateYield:function(m,g,S){return this.delegate={iterator:M(m),resultName:g,nextLoc:S},this.method==="next"&&(this.arg=void 0),f}},i}function yt(i){"@babel/helpers - typeof";return yt=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},yt(i)}function zt(i,a,e,t,r,n,s){try{var o=i[n](s),u=o.value}catch(l){e(l);return}o.done?a(u):Promise.resolve(u).then(t,r)}function Y(i){return function(){var a=this,e=arguments;return new Promise(function(t,r){var n=i.apply(a,e);function s(u){zt(n,t,r,s,o,"next",u)}function o(u){zt(n,t,r,s,o,"throw",u)}s(void 0)})}}function oe(i,a){if(!(i instanceof a))throw new TypeError("Cannot call a class as a function")}function $t(i,a){for(var e=0;e<a.length;e++){var t=a[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(i,Kt(t.key),t)}}function ue(i,a,e){return a&&$t(i.prototype,a),e&&$t(i,e),Object.defineProperty(i,"prototype",{writable:!1}),i}function E(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 _t(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&&St(i,a)}function Qe(i){return Qe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Qe(i)}function St(i,a){return St=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},St(i,a)}function xr(){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 W(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function Nr(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 W(i)}function bt(i){var a=xr();return function(){var t=Qe(i),r;if(a){var n=Qe(this).constructor;r=Reflect.construct(t,arguments,n)}else r=t.apply(this,arguments);return Nr(this,r)}}function we(i,a){return Gr(i)||Ur(i,a)||Wt(i,a)||zr()}function Fr(i){return Vr(i)||jr(i)||Wt(i)||Hr()}function Vr(i){if(Array.isArray(i))return Et(i)}function Gr(i){if(Array.isArray(i))return i}function jr(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function Wt(i,a){if(i){if(typeof i=="string")return Et(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 Et(i,a)}}function Et(i,a){(a==null||a>i.length)&&(a=i.length);for(var e=0,t=new Array(a);e<a;e++)t[e]=i[e];return t}function Hr(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
2
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function zr(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
3
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function $r(i,a){if(typeof i!="object"||i===null)return i;var e=i[Symbol.toPrimitive];if(e!==void 0){var t=e.call(i,a||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(i)}function Kt(i){var a=$r(i,"string");return typeof a=="symbol"?a:String(a)}function Yt(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var qt={exports:{}};(function(i){var a=Object.prototype.hasOwnProperty,e="~";function t(){}Object.create&&(t.prototype=Object.create(null),new t().__proto__||(e=!1));function r(u,l,c){this.fn=u,this.context=l,this.once=c||!1}function n(u,l,c,f,v){if(typeof c!="function")throw new TypeError("The listener must be a function");var h=new r(c,f||u,v),p=e?e+l:l;return u._events[p]?u._events[p].fn?u._events[p]=[u._events[p],h]:u._events[p].push(h):(u._events[p]=h,u._eventsCount++),u}function s(u,l){--u._eventsCount===0?u._events=new t:delete u._events[l]}function o(){this._events=new t,this._eventsCount=0}o.prototype.eventNames=function(){var l=[],c,f;if(this._eventsCount===0)return l;for(f in c=this._events)a.call(c,f)&&l.push(e?f.slice(1):f);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},o.prototype.listeners=function(l){var c=e?e+l:l,f=this._events[c];if(!f)return[];if(f.fn)return[f.fn];for(var v=0,h=f.length,p=new Array(h);v<h;v++)p[v]=f[v].fn;return p},o.prototype.listenerCount=function(l){var c=e?e+l:l,f=this._events[c];return f?f.fn?1:f.length:0},o.prototype.emit=function(l,c,f,v,h,p){var y=e?e+l:l;if(!this._events[y])return!1;var d=this._events[y],_=arguments.length,b,w;if(d.fn){switch(d.once&&this.removeListener(l,d.fn,void 0,!0),_){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,c),!0;case 3:return d.fn.call(d.context,c,f),!0;case 4:return d.fn.call(d.context,c,f,v),!0;case 5:return d.fn.call(d.context,c,f,v,h),!0;case 6:return d.fn.call(d.context,c,f,v,h,p),!0}for(w=1,b=new Array(_-1);w<_;w++)b[w-1]=arguments[w];d.fn.apply(d.context,b)}else{var D=d.length,T;for(w=0;w<D;w++)switch(d[w].once&&this.removeListener(l,d[w].fn,void 0,!0),_){case 1:d[w].fn.call(d[w].context);break;case 2:d[w].fn.call(d[w].context,c);break;case 3:d[w].fn.call(d[w].context,c,f);break;case 4:d[w].fn.call(d[w].context,c,f,v);break;default:if(!b)for(T=1,b=new Array(_-1);T<_;T++)b[T-1]=arguments[T];d[w].fn.apply(d[w].context,b)}}return!0},o.prototype.on=function(l,c,f){return n(this,l,c,f,!1)},o.prototype.once=function(l,c,f){return n(this,l,c,f,!0)},o.prototype.removeListener=function(l,c,f,v){var h=e?e+l:l;if(!this._events[h])return this;if(!c)return s(this,h),this;var p=this._events[h];if(p.fn)p.fn===c&&(!v||p.once)&&(!f||p.context===f)&&s(this,h);else{for(var y=0,d=[],_=p.length;y<_;y++)(p[y].fn!==c||v&&!p[y].once||f&&p[y].context!==f)&&d.push(p[y]);d.length?this._events[h]=d.length===1?d[0]:d:s(this,h)}return this},o.prototype.removeAllListeners=function(l){var c;return l?(c=e?e+l:l,this._events[c]&&s(this,c)):(this._events=new t,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=e,o.EventEmitter=o,i.exports=o})(qt);var Wr=qt.exports;const Kr=Yt(Wr);function Xt(i,a){var e=Object.keys(i);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(i);a&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),e.push.apply(e,t)}return e}function He(i){for(var a=1;a<arguments.length;a++){var e=arguments[a]!=null?arguments[a]:{};a%2?Xt(Object(e),!0).forEach(function(t){A(i,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(e)):Xt(Object(e)).forEach(function(t){Object.defineProperty(i,t,Object.getOwnPropertyDescriptor(e,t))})}return i}function se(){se=function(){return i};var i={},a=Object.prototype,e=a.hasOwnProperty,t=Object.defineProperty||function(m,g,S){m[g]=S.value},r=typeof Symbol=="function"?Symbol:{},n=r.iterator||"@@iterator",s=r.asyncIterator||"@@asyncIterator",o=r.toStringTag||"@@toStringTag";function u(m,g,S){return Object.defineProperty(m,g,{value:S,enumerable:!0,configurable:!0,writable:!0}),m[g]}try{u({},"")}catch{u=function(g,S,O){return g[S]=O}}function l(m,g,S,O){var k=g&&g.prototype instanceof v?g:v,I=Object.create(k.prototype),V=new G(O||[]);return t(I,"_invoke",{value:T(m,S,V)}),I}function c(m,g,S){try{return{type:"normal",arg:m.call(g,S)}}catch(O){return{type:"throw",arg:O}}}i.wrap=l;var f={};function v(){}function h(){}function p(){}var y={};u(y,n,function(){return this});var d=Object.getPrototypeOf,_=d&&d(d(M([])));_&&_!==a&&e.call(_,n)&&(y=_);var b=p.prototype=v.prototype=Object.create(y);function w(m){["next","throw","return"].forEach(function(g){u(m,g,function(S){return this._invoke(g,S)})})}function D(m,g){function S(k,I,V,z){var K=c(m[k],m,I);if(K.type!=="throw"){var R=K.arg,te=R.value;return te&&typeof te=="object"&&e.call(te,"__await")?g.resolve(te.__await).then(function(U){S("next",U,V,z)},function(U){S("throw",U,V,z)}):g.resolve(te).then(function(U){R.value=U,V(R)},function(U){return S("throw",U,V,z)})}z(K.arg)}var O;t(this,"_invoke",{value:function(k,I){function V(){return new g(function(z,K){S(k,I,z,K)})}return O=O?O.then(V,V):V()}})}function T(m,g,S){var O="suspendedStart";return function(k,I){if(O==="executing")throw new Error("Generator is already running");if(O==="completed"){if(k==="throw")throw I;return q()}for(S.method=k,S.arg=I;;){var V=S.delegate;if(V){var z=F(V,S);if(z){if(z===f)continue;return z}}if(S.method==="next")S.sent=S._sent=S.arg;else if(S.method==="throw"){if(O==="suspendedStart")throw O="completed",S.arg;S.dispatchException(S.arg)}else S.method==="return"&&S.abrupt("return",S.arg);O="executing";var K=c(m,g,S);if(K.type==="normal"){if(O=S.done?"completed":"suspendedYield",K.arg===f)continue;return{value:K.arg,done:S.done}}K.type==="throw"&&(O="completed",S.method="throw",S.arg=K.arg)}}}function F(m,g){var S=g.method,O=m.iterator[S];if(O===void 0)return g.delegate=null,S==="throw"&&m.iterator.return&&(g.method="return",g.arg=void 0,F(m,g),g.method==="throw")||S!=="return"&&(g.method="throw",g.arg=new TypeError("The iterator does not provide a '"+S+"' method")),f;var k=c(O,m.iterator,g.arg);if(k.type==="throw")return g.method="throw",g.arg=k.arg,g.delegate=null,f;var I=k.arg;return I?I.done?(g[m.resultName]=I.value,g.next=m.nextLoc,g.method!=="return"&&(g.method="next",g.arg=void 0),g.delegate=null,f):I:(g.method="throw",g.arg=new TypeError("iterator result is not an object"),g.delegate=null,f)}function B(m){var g={tryLoc:m[0]};1 in m&&(g.catchLoc=m[1]),2 in m&&(g.finallyLoc=m[2],g.afterLoc=m[3]),this.tryEntries.push(g)}function N(m){var g=m.completion||{};g.type="normal",delete g.arg,m.completion=g}function G(m){this.tryEntries=[{tryLoc:"root"}],m.forEach(B,this),this.reset(!0)}function M(m){if(m){var g=m[n];if(g)return g.call(m);if(typeof m.next=="function")return m;if(!isNaN(m.length)){var S=-1,O=function k(){for(;++S<m.length;)if(e.call(m,S))return k.value=m[S],k.done=!1,k;return k.value=void 0,k.done=!0,k};return O.next=O}}return{next:q}}function q(){return{value:void 0,done:!0}}return h.prototype=p,t(b,"constructor",{value:p,configurable:!0}),t(p,"constructor",{value:h,configurable:!0}),h.displayName=u(p,o,"GeneratorFunction"),i.isGeneratorFunction=function(m){var g=typeof m=="function"&&m.constructor;return!!g&&(g===h||(g.displayName||g.name)==="GeneratorFunction")},i.mark=function(m){return Object.setPrototypeOf?Object.setPrototypeOf(m,p):(m.__proto__=p,u(m,o,"GeneratorFunction")),m.prototype=Object.create(b),m},i.awrap=function(m){return{__await:m}},w(D.prototype),u(D.prototype,s,function(){return this}),i.AsyncIterator=D,i.async=function(m,g,S,O,k){k===void 0&&(k=Promise);var I=new D(l(m,g,S,O),k);return i.isGeneratorFunction(g)?I:I.next().then(function(V){return V.done?V.value:I.next()})},w(b),u(b,o,"Generator"),u(b,n,function(){return this}),u(b,"toString",function(){return"[object Generator]"}),i.keys=function(m){var g=Object(m),S=[];for(var O in g)S.push(O);return S.reverse(),function k(){for(;S.length;){var I=S.pop();if(I in g)return k.value=I,k.done=!1,k}return k.done=!0,k}},i.values=M,G.prototype={constructor:G,reset:function(m){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(N),!m)for(var g in this)g.charAt(0)==="t"&&e.call(this,g)&&!isNaN(+g.slice(1))&&(this[g]=void 0)},stop:function(){this.done=!0;var m=this.tryEntries[0].completion;if(m.type==="throw")throw m.arg;return this.rval},dispatchException:function(m){if(this.done)throw m;var g=this;function S(K,R){return I.type="throw",I.arg=m,g.next=K,R&&(g.method="next",g.arg=void 0),!!R}for(var O=this.tryEntries.length-1;O>=0;--O){var k=this.tryEntries[O],I=k.completion;if(k.tryLoc==="root")return S("end");if(k.tryLoc<=this.prev){var V=e.call(k,"catchLoc"),z=e.call(k,"finallyLoc");if(V&&z){if(this.prev<k.catchLoc)return S(k.catchLoc,!0);if(this.prev<k.finallyLoc)return S(k.finallyLoc)}else if(V){if(this.prev<k.catchLoc)return S(k.catchLoc,!0)}else{if(!z)throw new Error("try statement without catch or finally");if(this.prev<k.finallyLoc)return S(k.finallyLoc)}}}},abrupt:function(m,g){for(var S=this.tryEntries.length-1;S>=0;--S){var O=this.tryEntries[S];if(O.tryLoc<=this.prev&&e.call(O,"finallyLoc")&&this.prev<O.finallyLoc){var k=O;break}}k&&(m==="break"||m==="continue")&&k.tryLoc<=g&&g<=k.finallyLoc&&(k=null);var I=k?k.completion:{};return I.type=m,I.arg=g,k?(this.method="next",this.next=k.finallyLoc,f):this.complete(I)},complete:function(m,g){if(m.type==="throw")throw m.arg;return m.type==="break"||m.type==="continue"?this.next=m.arg:m.type==="return"?(this.rval=this.arg=m.arg,this.method="return",this.next="end"):m.type==="normal"&&g&&(this.next=g),f},finish:function(m){for(var g=this.tryEntries.length-1;g>=0;--g){var S=this.tryEntries[g];if(S.finallyLoc===m)return this.complete(S.completion,S.afterLoc),N(S),f}},catch:function(m){for(var g=this.tryEntries.length-1;g>=0;--g){var S=this.tryEntries[g];if(S.tryLoc===m){var O=S.completion;if(O.type==="throw"){var k=O.arg;N(S)}return k}}throw new Error("illegal catch attempt")},delegateYield:function(m,g,S){return this.delegate={iterator:M(m),resultName:g,nextLoc:S},this.method==="next"&&(this.arg=void 0),f}},i}function xe(i){"@babel/helpers - typeof";return xe=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},xe(i)}function Qt(i,a,e,t,r,n,s){try{var o=i[n](s),u=o.value}catch(l){e(l);return}o.done?a(u):Promise.resolve(u).then(t,r)}function Te(i){return function(){var a=this,e=arguments;return new Promise(function(t,r){var n=i.apply(a,e);function s(u){Qt(n,t,r,s,o,"next",u)}function o(u){Qt(n,t,r,s,o,"throw",u)}s(void 0)})}}function fe(i,a){if(!(i instanceof a))throw new TypeError("Cannot call a class as a function")}function Jt(i,a){for(var e=0;e<a.length;e++){var t=a[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(i,tr(t.key),t)}}function he(i,a,e){return a&&Jt(i.prototype,a),e&&Jt(i,e),Object.defineProperty(i,"prototype",{writable:!1}),i}function A(i,a,e){return a=tr(a),a in i?Object.defineProperty(i,a,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[a]=e,i}function ze(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 Ie(i){return Ie=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Ie(i)}function $e(i,a){return $e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},$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 Je(i,a,e){return Zt()?Je=Reflect.construct.bind():Je=function(r,n,s){var o=[null];o.push.apply(o,n);var u=Function.bind.apply(r,o),l=new u;return s&&$e(l,s.prototype),l},Je.apply(null,arguments)}function Yr(i){return Function.toString.call(i).indexOf("[native code]")!==-1}function Ze(i){var a=typeof Map=="function"?new Map:void 0;return Ze=function(t){if(t===null||!Yr(t))return t;if(typeof t!="function")throw new TypeError("Super expression must either be null or a function");if(typeof a<"u"){if(a.has(t))return a.get(t);a.set(t,r)}function r(){return Je(t,arguments,Ie(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),$e(r,t)},Ze(i)}function qr(i,a){if(i==null)return{};var e={},t=Object.keys(i),r,n;for(n=0;n<t.length;n++)r=t[n],!(a.indexOf(r)>=0)&&(e[r]=i[r]);return e}function Xr(i,a){if(i==null)return{};var e=qr(i,a),t,r;if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);for(r=0;r<n.length;r++)t=n[r],!(a.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(i,t)&&(e[t]=i[t])}return e}function x(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function Qr(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 x(i)}function We(i){var a=Zt();return function(){var t=Ie(i),r;if(a){var n=Ie(this).constructor;r=Reflect.construct(t,arguments,n)}else r=t.apply(this,arguments);return Qr(this,r)}}function Jr(i,a){for(;!Object.prototype.hasOwnProperty.call(i,a)&&(i=Ie(i),i!==null););return i}function et(){return typeof Reflect<"u"&&Reflect.get?et=Reflect.get.bind():et=function(a,e,t){var r=Jr(a,e);if(r){var n=Object.getOwnPropertyDescriptor(r,e);return n.get?n.get.call(arguments.length<3?a:t):n.value}},et.apply(this,arguments)}function Zr(i,a){if(i){if(typeof i=="string")return er(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 er(i,a)}}function er(i,a){(a==null||a>i.length)&&(a=i.length);for(var e=0,t=new Array(a);e<a;e++)t[e]=i[e];return t}function en(i,a){var e=typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(!e){if(Array.isArray(i)||(e=Zr(i))||a&&i&&typeof i.length=="number"){e&&(i=e);var t=0,r=function(){};return{s:r,n:function(){return t>=i.length?{done:!0}:{done:!1,value:i[t++]}},e:function(u){throw u},f:r}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
4
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var n=!0,s=!1,o;return{s:function(){e=e.call(i)},n:function(){var u=e.next();return n=u.done,u},e:function(u){s=!0,o=u},f:function(){try{!n&&e.return!=null&&e.return()}finally{if(s)throw o}}}}function tn(i,a){if(typeof i!="object"||i===null)return i;var e=i[Symbol.toPrimitive];if(e!==void 0){var t=e.call(i,a||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(i)}function tr(i){var a=tn(i,"string");return typeof a=="symbol"?a:String(a)}function Ne(){var i,a,e=new Promise(function(t,r){i=t,a=r});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 Fe(){try{return parseInt(performance.now(),10)}catch{return new Date().getTime()}}var ce=function(){function i(){fe(this,i)}return he(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,t){if(!e||!e.length)return[];for(var r=[],n=0,s=e.length;n<s;n++){var o=r.length;if(!o||!t)r.push([e.start(n),e.end(n)]);else{var u=r[o-1],l=u[1],c=e.start(n);if(c-l<=t){var f=e.end(n);f>l&&(u[1]=f)}else r.push([e.start(n),e.end(n)])}}return r}},{key:"totalLength",value:function(e){return!e||!e.length?0:e.reduce(function(t,r){return t+=r[1]-r[0]},0)}},{key:"info",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(!e||!e.length)return{start:0,end:0,buffers:[]};for(var n=0,s=0,o=0,u=0,l=0,c=0,f=0,v=i.buffers(e,r),h=0,p=v.length;h<p;h++){var y=v[h];if(t+r>=y[0]&&t<=y[1])n=y[0],s=y[1],o=h;else if(t+r<y[0]){u=y[0],l=y[1];break}else t+r>y[1]&&(c=y[0],f=y[1])}return{start:n,end:s,index:o,buffers:v,nextStart:u,nextEnd:l,prevStart:c,prevEnd:f,currentTime:t,behind:t-n,remaining:s?s-t:0,length:i.totalLength&&i.totalLength(v)}}}]),i}(),de,$={MANIFEST:"manifest",NETWORK:"network",NETWORK_TIMEOUT:"network_timeout",NETWORK_FORBIDDEN:"network_forbidden",NETWORK_NOTFOUND:"network_notfound",NETWROK_RANGE_NOT_SATISFIABLE:"network_range_not_satisfiable",DEMUX:"demux",REMUX:"remux",MEDIA:"media",DRM:"drm",OTHER:"other",RUNTIME:"runtime",SUB_TYPES:{FLV:"FLV",HLS:"HLS",MP4:"MP4",FMP4:"FMP4",MSE_ADD_SB:"MSE_ADD_SB",MSE_APPEND_BUFFER:"MSE_APPEND_BUFFER",MSE_OTHER:"MSE_OTHER",MSE_FULL:"MSE_FULL",OPTION:"OPTION",DASH:"DASH",LICENSE:"LICENSE",CUSTOM_LICENSE:"CUSTOM_LICENSE",MSE_HIJACK:"MSE_HIJACK",EME_HIJACK:"EME_HIJACK",SIDX:"SIDX",NO_CANPLAY_ERROR:"NO_CANPLAY_ERROR",BUFFERBREAK_ERROR:"BUFFERBREAK_ERROR",WAITING_TIMEOUT_ERROR:"WAITING_TIMEOUT_ERROR",MEDIA_ERR_ABORTED:"MEDIA_ERR_ABORTED",MEDIA_ERR_NETWORK:"MEDIA_ERR_NETWORK",MEDIA_ERR_DECODE:"MEDIA_ERR_DECODE",MEDIA_ERR_SRC_NOT_SUPPORTED:"MEDIA_ERR_SRC_NOT_SUPPORTED",MEDIA_ERR_CODEC_NOT_SUPPORTED:"MEDIA_ERR_CODEC_NOT_SUPPORTED",MEDIA_ERR_URL_EMPTY:"MEDIA_ERR_URL_EMPTY"}},wt=(de={},A(de,$.MANIFEST,{HLS:1100,DASH:1200}),A(de,$.NETWORK,2100),A(de,$.NETWORK_TIMEOUT,2101),A(de,$.NETWORK_FORBIDDEN,2103),A(de,$.NETWORK_NOTFOUND,2104),A(de,$.NETWROK_RANGE_NOT_SATISFIABLE,2116),A(de,$.DEMUX,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400,SIDX:3410}),A(de,$.REMUX,{FMP4:4100,MP4:4200}),A(de,$.MEDIA,{MEDIA_ERR_ABORTED:5101,MEDIA_ERR_NETWORK:5102,MEDIA_ERR_DECODE:5103,MEDIA_ERR_SRC_NOT_SUPPORTED:5104,MEDIA_ERR_CODEC_NOT_SUPPORTED:5105,MEDIA_ERR_URL_EMPTY:5106,MSE_ADD_SB:5200,MSE_APPEND_BUFFER:5201,MSE_OTHER:5202,MSE_FULL:5203,MSE_HIJACK:5204,EME_HIJACK:5301}),A(de,$.DRM,{LICENSE:7100,CUSTOM_LICENSE:7200}),A(de,$.OTHER,8e3),A(de,$.RUNTIME,{NO_CANPLAY_ERROR:9001,BUFFERBREAK_ERROR:9002,WAITING_TIMEOUT_ERROR:9003}),de),re=function(i){ze(e,i);var a=We(e);function e(t,r,n,s,o){var u;return fe(this,e),u=a.call(this,o||n?.message),u.errorType=t===$.NETWORK_TIMEOUT?$.NETWORK:t,u.originError=n,u.ext=s,u.errorCode=wt[t][r]||wt[t],u.errorMessage=u.message,u.errorCode||(u.errorType=$.OTHER,u.errorCode=wt[u.errorType]),u}return he(e,null,[{key:"create",value:function(r,n,s,o,u){return r instanceof e?r:(r instanceof Error&&(s=r,r=""),r||(r=$.OTHER),new e(r,n,s,o,u))}},{key:"network",value:function(r){var n;return new e(r!=null&&r.isTimeout?$.NETWORK_TIMEOUT:$.NETWORK,null,r instanceof Error?r:null,{url:r?.url,response:r?.response,httpCode:r==null||(n=r.response)===null||n===void 0?void 0:n.status})}}]),e}(Ze(Error)),rn=typeof window<"u",tt={DEBUG:1,LOG:2,WARN:3,ERROR:4},nn=200*1024,sn=["Boolean","Number","String","Undefined","Null","Date","Object"],be=function(){function i(a,e){fe(this,i),this.name=a||"",this._prefix="[".concat(this.name,"]"),this.logCacheLevel=e?.logCacheLevel||3,this.logMaxSize=e?.logMaxSize||nn,this.logSize=0,this.logTextArray=[]}return he(i,[{key:"debug",value:function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];this.logCache.apply(this,[tt.DEBUG].concat(r)),!i.disabled&&(e=console).debug.apply(e,[this._prefix,Ke()].concat(r))}},{key:"log",value:function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];this.logCache.apply(this,[tt.LOG].concat(r)),!i.disabled&&(e=console).log.apply(e,[this._prefix,Ke()].concat(r))}},{key:"warn",value:function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];this.logCache.apply(this,[tt.WARN].concat(r)),!i.disabled&&(e=console).warn.apply(e,[this._prefix,Ke()].concat(r))}},{key:"error",value:function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];this.logCache.apply(this,[tt.ERROR].concat(r)),!i.disabled&&(e=console).error.apply(e,[this._prefix,Ke()].concat(r))}},{key:"logCache",value:function(e){if(!(e<this.logCacheLevel)){var t="";try{for(var r=arguments.length,n=new Array(r>1?r-1:0),s=1;s<r;s++)n[s-1]=arguments[s];var o=n.map(function(l){return rr(l)});t=this._prefix+Ke()+JSON.stringify(o)}catch{return}if(e>=this.logCacheLevel&&(this.logSize+=t.length,this.logTextArray.push(t)),this.logSize>this.logMaxSize){var u=this.logTextArray.shift();this.logSize-=u.length}}}},{key:"getLogCache",value:function(){var e=this.logTextArray.join(`
5
- `);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}();A(be,"disabled",!0);function Ke(){return new Date().toLocaleString()}function an(i){if(xe(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 rr(i,a,e){e||(e=1),a||(a=2);var t={};if(!i||xe(i)!=="object")return i;var r=Object.prototype.toString.call(i).slice(8,-1);if(!sn.includes(r))return r;if(!(e>a)){for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e===a?t[n]=an(i[n]):xe(i[n])==="object"?t[n]=rr(i[n],a,e+1):t[n]=i[n]);return t}}function nr(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;try{return rn?i&&typeof ManagedMediaSource<"u"?ManagedMediaSource:window.MediaSource:null}catch{}}function Tt(i){return/ManagedMediaSource/gi.test(Object.prototype.toString.call(i))}var rt={APPEND:"appendBuffer",REMOVE:"removeBuffer",UPDATE_DURATION:"updateDuration"},ve=function(){function i(a,e){var t=this;fe(this,i),A(this,"media",null),A(this,"mediaSource",null),A(this,"_openPromise",Ne()),A(this,"_queue",Object.create(null)),A(this,"_sourceBuffer",Object.create(null)),A(this,"_mseFullFlag",{}),A(this,"_st",0),A(this,"_opst",0),A(this,"_logger",null),A(this,"_config",null),A(this,"_url",null),A(this,"_onStartStreaming",function(){t._logger.debug("startstreaming")}),A(this,"_onEndStreaming",function(){t._logger.debug("endstreaming")}),A(this,"_onSBUpdateEnd",function(r){var n=t._queue[r];if(n){var s=n[0];if(s?.opName!==rt.UPDATE_DURATION&&n.shift(),s){var o=Fe()-t._opst;t._logger.debug("UpdateEnd",s.opName,o,s.context),s.promise.resolve({name:s.opName,context:s.context,costtime:o}),t._startQueue(r)}}}),A(this,"_onSBUpdateError",function(r,n){var s=t._queue[r];if(s){var o=s[0];o&&(t._logger.error("UpdateError",r,o.opName,o.context),o.promise.reject(new re($.MEDIA,$.SUB_TYPES.MSE_APPEND_BUFFER,n)))}}),this._config=Object.assign(i.getDefaultConfig(),e),a&&this.bindMedia(a),this._logger=new be("MSE"),this._config.openLog&&be.enable()}return he(i,[{key:"isOpened",get:function(){var e;return((e=this.mediaSource)===null||e===void 0?void 0:e.readyState)==="open"}},{key:"url",get:function(){return this._url}},{key:"duration",get:function(){var e;return((e=this.mediaSource)===null||e===void 0?void 0:e.duration)||-1}},{key:"isEnded",get:function(){return this.mediaSource?this.mediaSource.readyState==="ended":!1}},{key:"streaming",get:function(){return Tt(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 t=this,r=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(t.bufferEnd(s)||0,n)}catch{}}),e<n)return Promise.resolve()}return this._enqueueBlockingOp(function(){if(t.isEnded){t._logger.debug("setDuration but ended");return}t.mediaSource&&(t.mediaSource.duration=e,t._logger.debug("setDuration",e))},rt.UPDATE_DURATION,{isReduceDuration:r})}},{key:"open",value:function(){var e=this;if(this._openPromise.used&&!this.isOpened&&this.mediaSource){var t=this.mediaSource,r=function n(){var s=Fe()-e._st;e._logger.debug("sourceopen",s),t.removeEventListener("sourceopen",n),e._openPromise.resolve({costtime:s})};t.addEventListener("sourceopen",r),this._openPromise=Ne()}return this._openPromise}},{key:"bindMedia",value:function(){var a=Te(se().mark(function t(r){var n=this,s,o,u,l;return se().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=nr(this._config.preferMMS),!(!r||!s)){f.next=6;break}throw new Error("Param media or MediaSource does not exist");case 6:return this.media=r,o=this.mediaSource=new s,u=Tt(o),this._st=Fe(),l=function v(){var h=Fe()-n._st;n._logger.debug("sourceopen"),o.removeEventListener("sourceopen",v),URL.revokeObjectURL(r.src),n._openPromise.resolve({costtime:h})},o.addEventListener("sourceopen",l),u&&(o.addEventListener("startstreaming",this._onStartStreaming),o.addEventListener("endstreaming",this._onEndStreaming)),this._url=URL.createObjectURL(o),r.src=this._url,r.disableRemotePlayback=u,f.abrupt("return",this._openPromise);case 17:case"end":return f.stop()}},t,this)}));function e(t){return a.apply(this,arguments)}return e}()},{key:"unbindMedia",value:function(){var a=Te(se().mark(function t(){var r=this,n,s,o;return se().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=r._queue[c];f&&f.forEach(function(v){var h,p;return(h=v.promise)===null||h===void 0||(p=h.resolve)===null||p===void 0?void 0:p.call(h)})}),s=!!this.media&&this.media.readyState>=1,o=n.readyState==="open",s&&o)try{n.endOfStream()}catch{}Object.keys(this._sourceBuffer).forEach(function(c){try{n.removeSourceBuffer(r._sourceBuffer[c])}catch{}}),Tt(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=Ne(),this._queue=Object.create(null),this._sourceBuffer=Object.create(null);case 8:case"end":return l.stop()}},t,this)}));function e(){return a.apply(this,arguments)}return e}()},{key:"createSource",value:function(e,t){if(!(this._sourceBuffer[e]||!this.mediaSource)){var r;try{r=this._sourceBuffer[e]=this.mediaSource.addSourceBuffer(t)}catch(n){throw new re($.MEDIA,$.SUB_TYPES.MSE_ADD_SB,n)}r.mimeType=t,r.addEventListener("updateend",this._onSBUpdateEnd.bind(this,e)),r.addEventListener("error",this._onSBUpdateError.bind(this,e))}}},{key:"changeType",value:function(e,t){var r=this,n=this._sourceBuffer[e];return!this.mediaSource||!n||n.mimeType===t?Promise.resolve():typeof n.changeType!="function"?Promise.reject():this._enqueueOp(e,function(){n.changeType(t),n.mimeType=t,r._onSBUpdateEnd(e)},"changeType",{mimeType:t})}},{key:"createOrChangeSource",value:function(e,t){return this.createSource(e,t),this.changeType(e,t)}},{key:"append",value:function(e,t,r){var n=this;return!t||!t.byteLength||!this._sourceBuffer[e]?Promise.resolve():this._enqueueOp(e,function(){var s;!n.mediaSource||n.media.error||(n._logger.debug("MSE APPEND START",r),n._opst=Fe(),(s=n._sourceBuffer[e])===null||s===void 0||s.appendBuffer(t))},rt.APPEND,r)}},{key:"remove",value:function(e,t,r,n){var s=this,o=!1;return this._mseFullFlag[e]&&(o=!0),this._enqueueOp(e,function(){if(!(!s.mediaSource||s.media.error)){var u=s._sourceBuffer[e];if(t>=r||!u){s._onSBUpdateEnd(e);return}s._opst=Fe(),s._logger.debug("MSE REMOVE START",e,t,r,n),u.remove(t,r)}},rt.REMOVE,n,o)}},{key:"clearBuffer",value:function(e,t){var r=this,n;return Object.keys(this._sourceBuffer).forEach(function(s){n=r.remove(s,e,t)}),n||Promise.resolve()}},{key:"clearAllBuffer",value:function(){var e=this,t;return Object.keys(this._sourceBuffer).forEach(function(r){var n=e._sourceBuffer[r];t=e.remove(r,0,ce.end(ce.get(n)))}),t}},{key:"clearOpQueues",value:function(e,t){var r;this._logger.debug("MSE clearOpQueue START");var n=this._queue[e];if(t&&n){this._queue[e]=[];return}if(!(!n||!n[e]||n.length<5)){var s=[];n.forEach(function(o){o.context&&o.context.isinit&&s.push(o)}),this._queue[e]=n.slice(0,2),s.length>0&&(r=this._queue[e]).push.apply(r,s)}}},{key:"endOfStream",value:function(e){var t=this;return!this.mediaSource||this.mediaSource.readyState!=="open"?Promise.resolve():this._enqueueBlockingOp(function(){var r=t.mediaSource;!r||r.readyState!=="open"||(t._logger.debug("MSE endOfStream START"),e?r.endOfStream(e):r.endOfStream())},"endOfStream")}},{key:"setLiveSeekableRange",value:function(e,t){var r=this.mediaSource;e<0||t<e||!(r!=null&&r.setLiveSeekableRange)||r.readyState!=="open"||r.setLiveSeekableRange(e,t)}},{key:"getSourceBuffer",value:function(e){return this._sourceBuffer[e]}},{key:"buffered",value:function(e){return ce.get(this._sourceBuffer[e])}},{key:"bufferStart",value:function(e){return ce.start(this.buffered(e))}},{key:"bufferEnd",value:function(e){return ce.end(this.buffered(e))}},{key:"_enqueueOp",value:function(e,t,r,n,s){var o=this;if(!this.mediaSource)return Promise.resolve();var u=this._queue[e]=this._queue[e]||[],l={exec:t,promise:Ne(),opName:r,context:n};return s?(u.splice(0,0,l),this._mseFullFlag[e]=!1,this._startQueue(e)):u.push(l),this.isOpened||this.isEnded?u.length===1&&this._startQueue(e):this._openPromise.then(function(){u.length===1&&o._startQueue(e)}),l.promise}},{key:"_enqueueBlockingOp",value:function(){var a=Te(se().mark(function t(r,n,s){var o=this,u,l;return se().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(u=Object.keys(this._sourceBuffer),u.length){f.next=5;break}return f.abrupt("return",r());case 5:return l=[],u.forEach(function(v){var h=o._queue[v],p=Ne();l.push(p),h.push({exec:function(){p.resolve()},promise:p,opName:n,context:s}),h.length===1&&o._startQueue(v)}),f.abrupt("return",Promise.all(l).then(function(){try{return r()}finally{u.forEach(function(v){var h=o._queue[v],p=o._sourceBuffer[v];h?.shift(),(!p||!p.updating)&&o._startQueue(v)})}}));case 8:case"end":return f.stop()}},t,this)}));function e(t,r,n){return a.apply(this,arguments)}return e}()},{key:"_startQueue",value:function(e){var t=this._queue[e];if(t){var r=t[0];if(r&&!this._mseFullFlag[e])try{r.exec()}catch(n){n&&n.message&&n.message.indexOf("SourceBuffer is full")>=0?(this._mseFullFlag[e]=!0,this._logger.error("[MSE error], context,",r.context," ,name,",r.opName,",err,SourceBuffer is full"),r.promise.reject(new re($.MEDIA,$.SUB_TYPES.MSE_FULL,n))):(this._logger.error(n),r.promise.reject(new re($.MEDIA,$.SUB_TYPES.MSE_OTHER,n)),t.shift(),this._startQueue(e))}}}},{key:"setTimeoffset",value:function(e,t,r){var n=this;return this._enqueueOp(e,function(){t<0&&(t+=.001),n._sourceBuffer[e].timestampOffset=t,n._onSBUpdateEnd(e)},"setTimeoffset",r)}},{key:"abort",value:function(e,t){var r=this;return this.isOpened?this._enqueueOp(e,function(){r._sourceBuffer[e].abort(),r._onSBUpdateEnd(e)},"abort",t):Promise.resolve()}}],[{key:"isSupported",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:'video/mp4; codecs="avc1.42E01E,mp4a.40.2"',t=nr();if(!t)return!1;try{return t.isTypeSupported(e)}catch(r){return this._logger.error(e,r),!1}}},{key:"getDefaultConfig",value:function(){return{openLog:!1,preferMMS:!1}}}]),i}();A(ve,"VIDEO","video"),A(ve,"AUDIO","audio");var Ce={FETCH:"fetch",XHR:"xhr"},Ye={ARRAY_BUFFER:"arraybuffer",TEXT:"text",JSON:"json"},Ee=function(i){ze(e,i);var a=We(e);function e(t,r,n,s){var o;return fe(this,e),o=a.call(this,s),A(x(o),"retryCount",0),A(x(o),"isTimeout",!1),A(x(o),"loaderType",Ce.FETCH),A(x(o),"startTime",0),A(x(o),"endTime",0),A(x(o),"options",{}),o.url=t,o.request=r,o.response=n,o}return he(e)}(Ze(Error)),ir=Object.prototype.toString;function on(i){return i!==null&&xe(i)==="object"}function sr(i){if(ir.call(i)!=="[object Object]")return!1;var a=Object.getPrototypeOf(i);return a===null||a===Object.prototype}function un(i){return ir.call(i)==="[object Date]"}function ar(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 or(i){return encodeURIComponent(i).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function ur(i,a){if(i){if(!a)return i;var e,t=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 un(s)?s=s.toISOString():on(s)&&(s=JSON.stringify(s)),"".concat(or(n),"=").concat(or(s))}).join("&")}).filter(Boolean).join("&");if(t){var r=i.indexOf("#");r!==-1&&(i=i.slice(0,r)),i+=(i.indexOf("?")===-1?"?":"&")+t}return i}}function kt(i,a,e,t,r,n,s,o,u,l,c){r=r!=null?parseFloat(r):null,t=parseInt(t||"0",10),Number.isNaN(t)&&(t=0);var f={range:u,vid:l,index:o,contentLength:t,age:r,startTime:n,firstByteTime:s,endTime:Date.now(),priOptions:c};return{data:i,done:a,options:f,response:e}}function At(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",ANALYZE_DURATION_EXCEEDED:"core.analyzedurationexceeded",REMOVE_BUFFER:"core.removebuffer",BUFFEREOS:"core.buffereos",KEYFRAME:"core.keyframe",METADATA_PARSED:"core.metadataparsed",SEI:"core.sei",SEI_IN_TIME:"core.seiintime",FLV_SCRIPT_DATA:"core.flvscriptdata",LOWDECODE:"core.lowdecode",SWITCH_URL_SUCCESS:"core.switchurlsuccess",SWITCH_URL_FAILED:"core.switchurlfailed",SPEED:"core.speed",HLS_MANIFEST_LOADED:"core.hlsmanifestloaded",HLS_LEVEL_LOADED:"core.hlslevelloaded",DEMUXED_TRACK:"core.demuxedtrack",STREAM_EXCEPTION:"core.streamexception",LARGE_AV_FIRST_FRAME_GAP_DETECT:"LARGE_AV_FIRST_FRAME_GAP_DETECT",LARGE_VIDEO_DTS_GAP_DETECT:"LARGE_VIDEO_DTS_GAP_DETECT",LARGE_AUDIO_DTS_GAP_DETECT:"LARGE_AUDIO_DTS_GAP_DETECT",AUDIO_GAP_DETECT:"AUDIO_GAP_DETECT",AUDIO_OVERLAP_DETECT:"AUDIO_OVERLAP_DETECT",MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT:"MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT",REAL_TIME_SPEED:"real_time_speed"},lr={exports:{}};(function(i){var a=Object.prototype.hasOwnProperty,e="~";function t(){}Object.create&&(t.prototype=Object.create(null),new t().__proto__||(e=!1));function r(u,l,c){this.fn=u,this.context=l,this.once=c||!1}function n(u,l,c,f,v){if(typeof c!="function")throw new TypeError("The listener must be a function");var h=new r(c,f||u,v),p=e?e+l:l;return u._events[p]?u._events[p].fn?u._events[p]=[u._events[p],h]:u._events[p].push(h):(u._events[p]=h,u._eventsCount++),u}function s(u,l){--u._eventsCount===0?u._events=new t:delete u._events[l]}function o(){this._events=new t,this._eventsCount=0}o.prototype.eventNames=function(){var l=[],c,f;if(this._eventsCount===0)return l;for(f in c=this._events)a.call(c,f)&&l.push(e?f.slice(1):f);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},o.prototype.listeners=function(l){var c=e?e+l:l,f=this._events[c];if(!f)return[];if(f.fn)return[f.fn];for(var v=0,h=f.length,p=new Array(h);v<h;v++)p[v]=f[v].fn;return p},o.prototype.listenerCount=function(l){var c=e?e+l:l,f=this._events[c];return f?f.fn?1:f.length:0},o.prototype.emit=function(l,c,f,v,h,p){var y=e?e+l:l;if(!this._events[y])return!1;var d=this._events[y],_=arguments.length,b,w;if(d.fn){switch(d.once&&this.removeListener(l,d.fn,void 0,!0),_){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,c),!0;case 3:return d.fn.call(d.context,c,f),!0;case 4:return d.fn.call(d.context,c,f,v),!0;case 5:return d.fn.call(d.context,c,f,v,h),!0;case 6:return d.fn.call(d.context,c,f,v,h,p),!0}for(w=1,b=new Array(_-1);w<_;w++)b[w-1]=arguments[w];d.fn.apply(d.context,b)}else{var D=d.length,T;for(w=0;w<D;w++)switch(d[w].once&&this.removeListener(l,d[w].fn,void 0,!0),_){case 1:d[w].fn.call(d[w].context);break;case 2:d[w].fn.call(d[w].context,c);break;case 3:d[w].fn.call(d[w].context,c,f);break;case 4:d[w].fn.call(d[w].context,c,f,v);break;default:if(!b)for(T=1,b=new Array(_-1);T<_;T++)b[T-1]=arguments[T];d[w].fn.apply(d[w].context,b)}}return!0},o.prototype.on=function(l,c,f){return n(this,l,c,f,!1)},o.prototype.once=function(l,c,f){return n(this,l,c,f,!0)},o.prototype.removeListener=function(l,c,f,v){var h=e?e+l:l;if(!this._events[h])return this;if(!c)return s(this,h),this;var p=this._events[h];if(p.fn)p.fn===c&&(!v||p.once)&&(!f||p.context===f)&&s(this,h);else{for(var y=0,d=[],_=p.length;y<_;y++)(p[y].fn!==c||v&&!p[y].once||f&&p[y].context!==f)&&d.push(p[y]);d.length?this._events[h]=d.length===1?d[0]:d:s(this,h)}return this},o.prototype.removeAllListeners=function(l){var c;return l?(c=e?e+l:l,this._events[c]&&s(this,c)):(this._events=new t,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=e,o.EventEmitter=o,i.exports=o})(lr);var ln=lr.exports;const Dt=Yt(ln);var cr=2*1024*1024,Ot=function(i){ze(e,i);var a=We(e);function e(){var t;return fe(this,e),t=a.call(this),A(x(t),"_abortController",null),A(x(t),"_timeoutTimer",null),A(x(t),"_reader",null),A(x(t),"_response",null),A(x(t),"_aborted",!1),A(x(t),"_index",-1),A(x(t),"_range",null),A(x(t),"_receivedLength",0),A(x(t),"_running",!1),A(x(t),"_logger",null),A(x(t),"_vid",""),A(x(t),"_onProcessMinLen",0),A(x(t),"_onCancel",null),A(x(t),"_priOptions",null),t}return he(e,[{key:"load",value:function(r){var n,s=this,o=r.url,u=r.vid,l=r.timeout,c=r.responseType,f=r.onProgress,v=r.index,h=r.onTimeout,p=r.onCancel,y=r.range,d=r.transformResponse,_=r.request,b=r.params,w=r.logger,D=r.method,T=r.headers,F=r.body,B=r.mode,N=r.credentials,G=r.cache,M=r.redirect,q=r.referrer,m=r.referrerPolicy,g=r.onProcessMinLen,S=r.priOptions;this._logger=w,this._aborted=!1,this._onProcessMinLen=g,this._onCancel=p,this._abortController=typeof AbortController<"u"&&new AbortController,this._running=!0,this._index=v,this._range=y||[0,0],this._vid=u||o,this._priOptions=S||{};var O={method:D,headers:T,body:F,mode:B,credentials:N,cache:G,redirect:M,referrer:q,referrerPolicy:m,signal:(n=this._abortController)===null||n===void 0?void 0:n.signal},k=!1;clearTimeout(this._timeoutTimer),o=ur(o,b);var I=ar(y);I&&(_?T=_.headers:T=O.headers=O.headers||(Headers?new Headers:{}),Headers&&T instanceof Headers?T.append("Range",I):T.Range=I),l&&(this._timeoutTimer=setTimeout(function(){if(k=!0,s.cancel(),h){var z=new Ee(o,O,null,"timeout");z.isTimeout=!0,h(z,{index:s._index,range:s._range,vid:s._vid,priOptions:s._priOptions})}},l));var V=Date.now();return this._logger.debug("[fetch load start], index,",v,",range,",y),new Promise(function(z,K){fetch(_||o,_?void 0:O).then(function(){var R=Te(se().mark(function te(U){var Oe,me,Le,Ue;return se().wrap(function(Z){for(;;)switch(Z.prev=Z.next){case 0:if(clearTimeout(s._timeoutTimer),s._response=U,!(s._aborted||!s._running)){Z.next=4;break}return Z.abrupt("return");case 4:if(d&&(U=d(U,o)||U),U.ok){Z.next=7;break}throw new Ee(o,O,U,"bad network response");case 7:if(Oe=Date.now(),c!==Ye.TEXT){Z.next=15;break}return Z.next=11,U.text();case 11:me=Z.sent,s._running=!1,Z.next=37;break;case 15:if(c!==Ye.JSON){Z.next=22;break}return Z.next=18,U.json();case 18:me=Z.sent,s._running=!1,Z.next=37;break;case 22:if(!f){Z.next=29;break}return s.resolve=z,s.reject=K,s._loadChunk(U,f,V,Oe),Z.abrupt("return");case 29:return Z.next=31,U.arrayBuffer();case 31:me=Z.sent,me=new Uint8Array(me),s._running=!1,Le=Date.now()-V,Ue=At(me.byteLength,Le),s.emit(X.REAL_TIME_SPEED,{speed:Ue,len:me.byteLength,time:Le,vid:s._vid,index:s._index,range:s._range,priOptions:s._priOptions});case 37:s._logger.debug("[fetch load end], index,",v,",range,",y),z(kt(me,!0,U,U.headers.get("Content-Length"),U.headers.get("age"),V,Oe,v,y,s._vid,s._priOptions));case 39:case"end":return Z.stop()}},te)}));return function(te){return R.apply(this,arguments)}}()).catch(function(R){var te;clearTimeout(s._timeoutTimer),s._running=!1,!(s._aborted&&!k)&&(R=R instanceof Ee?R:new Ee(o,O,null,(te=R)===null||te===void 0?void 0:te.message),R.startTime=V,R.endTime=Date.now(),R.isTimeout=k,R.options={index:s._index,range:s._range,vid:s._vid,priOptions:s._priOptions},K(R))})})}},{key:"cancel",value:function(){var t=Te(se().mark(function n(){return se().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(!this._aborted){o.next=2;break}return o.abrupt("return");case 2:if(this._aborted=!0,this._running=!1,!this._response){o.next=14;break}if(o.prev=5,!this._reader){o.next=9;break}return o.next=9,this._reader.cancel();case 9:o.next=13;break;case 11:o.prev=11,o.t0=o.catch(5);case 13:this._response=this._reader=null;case 14:if(this._abortController){try{this._abortController.abort()}catch{}this._abortController=null}this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions});case 16:case"end":return o.stop()}},n,this,[[5,11]])}));function r(){return t.apply(this,arguments)}return r}()},{key:"_loadChunk",value:function(r,n,s,o){var u=this;if(!r.body||!r.body.getReader){this._running=!1;var l=new Ee(r.url,"",r,"onProgress of bad response.body.getReader");l.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this.reject(l);return}this._onProcessMinLen>0&&(this._cache=new Uint8Array(cr),this._writeIdx=0);var c=this._reader=r.body.getReader(),f,v,h,p=function(){var y=Te(se().mark(function d(){var _,b,w,D,T,F,B,N;return se().wrap(function(M){for(;;)switch(M.prev=M.next){case 0:return v=Date.now(),M.prev=1,M.next=4,c.read();case 4:f=M.sent,h=Date.now(),M.next=13;break;case 8:return M.prev=8,M.t0=M.catch(1),h=Date.now(),u._aborted||(u._running=!1,M.t0.options={index:u._index,range:u._range,vid:u._vid,priOptions:u._priOptions},u.reject(M.t0)),M.abrupt("return");case 13:if(b=((_=u._range)===null||_===void 0?void 0:_.length)>0?u._range[0]:0,w=b+u._receivedLength,!u._aborted){M.next=19;break}return u._running=!1,n(void 0,!1,{range:[w,w],vid:u._vid,index:u._index,startTime:v,endTime:h,st:s,firstByteTime:o,priOptions:u._priOptions},r),M.abrupt("return");case 19:D=f.value?f.value.byteLength:0,u._receivedLength+=D,u._logger.debug("\u3010fetchLoader,onProgress call\u3011,task,",u._range,", start,",w,", end,",b+u._receivedLength,", done,",f.done),u._onProcessMinLen>0?u._writeIdx+D>=u._onProcessMinLen||f.done?(T=new Uint8Array(u._writeIdx+D),T.set(u._cache.slice(0,u._writeIdx),0),D>0&&T.set(f.value,u._writeIdx),u._writeIdx=0,u._logger.debug("\u3010fetchLoader,onProgress enough\u3011,done,",f.done,",len,",T.byteLength,", writeIdx,",u._writeIdx)):D>0&&u._writeIdx+D<cr?(u._cache.set(f.value,u._writeIdx),u._writeIdx+=D,u._logger.debug("\u3010fetchLoader,onProgress cache\u3011,len,",D,", writeIdx,",u._writeIdx)):D>0&&(F=new Uint8Array(u._writeIdx+D+2048),u._logger.debug("\u3010fetchLoader,onProgress extra start\u3011,size,",u._writeIdx+D+2048,", datalen,",D,", writeIdx,",u._writeIdx),F.set(u._cache.slice(0,u._writeIdx),0),D>0&&F.set(f.value,u._writeIdx),u._writeIdx+=D,delete u._cache,u._cache=F,u._logger.debug("\u3010fetchLoader,onProgress extra end\u3011,len,",D,", writeIdx,",u._writeIdx)):T=f.value,(T&&T.byteLength>0||f.done)&&n(T,f.done,{range:[u._range[0]+u._receivedLength-(T?T.byteLength:0),u._range[0]+u._receivedLength],vid:u._vid,index:u._index,startTime:v,endTime:h,st:s,firstByteTime:o,priOptions:u._priOptions},r),f.done?(B=Date.now()-s,N=At(u._receivedLength,B),u.emit(X.REAL_TIME_SPEED,{speed:N,len:u._receivedLength,time:B,vid:u._vid,index:u._index,range:u._range,priOptions:u._priOptions}),u._running=!1,u._logger.debug("[fetchLoader onProgress end],task,",u._range,",done,",f.done),u.resolve(kt(f,!0,r,r.headers.get("Content-Length"),r.headers.get("age"),s,o,u._index,u._range,u._vid,u._priOptions))):p();case 25:case"end":return M.stop()}},d,null,[[1,8]])}));return function(){return y.apply(this,arguments)}}();p()}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(r){this._running=r}}],[{key:"isSupported",value:function(){return typeof fetch<"u"}}]),e}(Dt);function cn(i){return He({loaderType:Ce.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:Ye.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 fn=function(i){ze(e,i);var a=We(e);function e(){var t;return fe(this,e),t=a.call(this),A(x(t),"_xhr",null),A(x(t),"_aborted",!1),A(x(t),"_timeoutTimer",null),A(x(t),"_range",null),A(x(t),"_receivedLength",0),A(x(t),"_url",null),A(x(t),"_onProgress",null),A(x(t),"_index",-1),A(x(t),"_headers",null),A(x(t),"_currentChunkSizeKB",384),A(x(t),"_timeout",null),A(x(t),"_xhr",null),A(x(t),"_withCredentials",null),A(x(t),"_startTime",-1),A(x(t),"_loadCompleteResolve",null),A(x(t),"_loadCompleteReject",null),A(x(t),"_runing",!1),A(x(t),"_logger",!1),A(x(t),"_vid",""),A(x(t),"_responseType",void 0),A(x(t),"_credentials",void 0),A(x(t),"_method",void 0),A(x(t),"_transformResponse",void 0),A(x(t),"_firstRtt",void 0),A(x(t),"_onCancel",null),A(x(t),"_priOptions",null),t}return he(e,[{key:"load",value:function(r){var n=this;clearTimeout(this._timeoutTimer),this._logger=r.logger,this._range=r.range,this._onProgress=r.onProgress,this._index=r.index,this._headers=r.headers,this._withCredentials=r.credentials==="include"||r.credentials==="same-origin",this._body=r.body||null,r.method&&(this._method=r.method),this._timeout=r.timeout||null,this._runing=!0,this._vid=r.vid||r.url,this._responseType=r.responseType,this._firstRtt=-1,this._onTimeout=r.onTimeout,this._onCancel=r.onCancel,this._request=r.request,this._priOptions=r.priOptions||{},this._logger.debug("\u3010xhrLoader task\u3011, range",this._range),this._url=ur(r.url,r.params);var s=Date.now();return new Promise(function(o,u){n._loadCompleteResolve=o,n._loadCompleteReject=u,n._startLoad()}).catch(function(o){if(clearTimeout(n._timeoutTimer),n._runing=!1,!n._aborted)throw o=o instanceof Ee?o:new Ee(n._url,n._request),o.startTime=s,o.endTime=Date.now(),o.options={index:n._index,vid:n._vid,priOptions:n._priOptions},o})}},{key:"_startLoad",value:function(){var r=null;if(this._responseType===Ye.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,o=this._range[1];n<this._range[1]-s&&(o=s+n),r=[s,o],this._logger.debug("[xhr_loader->],tast :",this._range,", SubRange, ",r)}else r=this._range,this._logger.debug("[xhr_loader->],tast :",this._range,", allRange, ",r);this._internalOpen(r)}},{key:"_internalOpen",value:function(r){var 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 h=new Ee(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));h.options={index:n._index,range:n._range,vid:n._vid,priOptions:n._priOptions},n._loadCompleteReject(h)},s.ontimeout=function(l){n.cancel();var c=new Ee(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 o=this._headers||{},u=ar(r);u&&(o.Range=u),o&&Object.keys(o).forEach(function(l){s.setRequestHeader(l,o[l])}),this._logger.debug("[xhr.send->] tast,",this._range,",load sub range, ",r),s.send(this._body)}catch(l){l.options={index:this._index,range:r,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(l)}}},{key:"_onReadyStatechange",value:function(r){var n=r.target;n.readyState===2&&this._firstRtt<0&&(this._firstRtt=Date.now())}},{key:"_onLoad",value:function(r){var n,s=r.target.status;if(s<200||s>299){var o=new Ee(this._url,null,He(He({},r.target.response),{},{status:s}),"bad response,status:"+s);return o.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(o)}var u=null,l=!1,c,f=((n=this._range)===null||n===void 0?void 0:n.length)>0?this._range[0]:0;if(this._responseType===Ye.ARRAY_BUFFER){var v,h=new Uint8Array(r.target.response);if(c=f+this._receivedLength,h&&h.byteLength>0){this._receivedLength+=h.byteLength;var p=Date.now()-this._startTime,y=At(this._receivedLength,p);this.emit(X.REAL_TIME_SPEED,{speed:y,len:this._receivedLength,time:p,vid:this._vid,index:this._index,range:[c,f+this._receivedLength],priOptions:this._priOptions})}u=h,((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,",h?h.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",l)}else l=!0,u=r.target.response;var d={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&&(d=this._transformResponse(d,this._url)||d),this._onProgress&&this._onProgress(u,l,{index:this._index,vid:this._vid,range:[c,f+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},d),l?(this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(kt(this._onProgress?null:u,l,d,d.headers["content-length"],d.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,et(Ie(e.prototype),"removeAllListeners",this).call(this),this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions}),this._xhr))return this._xhr.abort()}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(r){this._running=r}},{key:"_getHeaders",value:function(r){var n=r.getAllResponseHeaders().trim().split(`\r
6
- `),s={},o=en(n),u;try{for(o.s();!(u=o.n()).done;){var l=u.value,c=l.split(": ");s[c[0].toLowerCase()]=c.slice(1).join(": ")}}catch(f){o.e(f)}finally{o.f()}return s}}],[{key:"isSupported",value:function(){return typeof XMLHttpRequest<"u"}}]),e}(Dt),hn=["retry","retryDelay","onRetryError","transformError"],dn=function(){function i(a,e){fe(this,i),this.promise=Ne(),this.alive=!!e.onProgress,!e.logger&&(e.logger=new be("Loader")),this._loaderType=a,this._loader=a===Ce.FETCH&&typeof fetch<"u"?new Ot:new fn,this._config=e,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=e.retryCheckFunc,this._logger=e.logger}return he(i,[{key:"exec",value:function(){var e=this,t=this._config,r=t.retry,n=t.retryDelay,s=t.onRetryError,o=t.transformError,u=Xr(t,hn),l=function(){var c=Te(se().mark(function f(){var v,h,p;return se().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return d.prev=0,d.next=3,e._loader.load(u);case 3:v=d.sent,e.promise.resolve(v),d.next=27;break;case 7:if(d.prev=7,d.t0=d.catch(0),e._loader.running=!1,e._logger.debug("[task request catch err]",d.t0),!e._canceled){d.next=13;break}return d.abrupt("return");case 13:if(d.t0.loaderType=e._loaderType,d.t0.retryCount=e._retryCount,h=d.t0,o&&(h=o(h)||h),s&&e._retryCount>0&&s(h,e._retryCount,{index:u.index,vid:u.vid,range:u.range,priOptions:u.priOptions}),e._retryCount++,p=!0,e._retryCheckFunc&&(p=e._retryCheckFunc(d.t0)),!(p&&e._retryCount<=r)){d.next=26;break}return clearTimeout(e._retryTimer),e._logger.debug("[task request setTimeout],retry",e._retryCount,",retry range,",u.range),e._retryTimer=setTimeout(l,n),d.abrupt("return");case 26:e.promise.reject(h);case 27:case"end":return d.stop()}},f,null,[[0,7]])}));return function(){return c.apply(this,arguments)}}();return l(),this.promise}},{key:"cancel",value:function(){var a=Te(se().mark(function t(){return se().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()}},t,this)}));function e(){return a.apply(this,arguments)}return e}()},{key:"running",get:function(){return this._loader&&this._loader.running}},{key:"loader",get:function(){return this._loader}}]),i}();function vn(i){return i&&!i.paused&&!i.ended&&i.playbackRate!==0&&i.readyState!==0}function pn(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 nt(){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 t=new Uint8Array(a.reduce(function(n,s){return n+s.byteLength},0)),r=0;return a.forEach(function(n){t.set(n,r),r+=n.byteLength}),t}function mn(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return new Promise(function(a){return setTimeout(a,i)})}var Ve=function(i){ze(e,i);var a=We(e);function e(t){var r;return fe(this,e),r=a.call(this,t),A(x(r),"type",Ce.FETCH),A(x(r),"_queue",[]),A(x(r),"_alive",[]),A(x(r),"_currentTask",null),A(x(r),"_finnalUrl",""),A(x(r),"_config",void 0),r._config=cn(t),(r._config.loaderType===Ce.XHR||!Ot.isSupported())&&(r.type=Ce.XHR),r.log=t.logger,r}return he(e,[{key:"isFetch",value:function(){return this.type===Ce.FETCH}},{key:"load",value:function(r){var n=this,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};typeof r=="string"||!r?s.url=r||s.url||this._config.url:s=r,s=Object.assign({},this._config,s),s.params&&(s.params=Object.assign({},s.params)),s.headers&&sr(s.headers)&&(s.headers=Object.assign({},s.headers)),s.body&&sr(s.body)&&(s.body=Object.assign({},s.body)),s.transformRequest&&(s=s.transformRequest(s)||s),s.logger=this.log;var o=new dn(this.type,s);return o.loader.on(X.REAL_TIME_SPEED,function(u){n.emit(X.REAL_TIME_SPEED,u)}),this._queue.push(o),this._queue.length===1&&(!this._currentTask||!this._currentTask.running)&&this._processTask(),o.promise}},{key:"cancel",value:function(){var t=Te(se().mark(function n(){var s;return se().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return s=this._queue.map(function(l){return l.cancel()}).concat(this._alive.map(function(l){return l.cancel()})),this._currentTask&&s.push(this._currentTask.cancel()),this._queue=[],this._alive=[],u.next=6,Promise.all(s);case 6:return u.next=8,mn();case 8:case"end":return u.stop()}},n,this)}));function r(){return t.apply(this,arguments)}return r}()},{key:"_processTask",value:function(){var r=this;if(this._currentTask=this._queue.shift(),!!this._currentTask){this._currentTask.alive&&this._alive.push(this._currentTask);var n=this._currentTask.exec().catch(function(s){});n&&typeof n.finally=="function"&&n.finally(function(){var s,o;(s=r._currentTask)!==null&&s!==void 0&&s.alive&&((o=r._alive)===null||o===void 0?void 0:o.length)>0&&(r._alive=r._alive.filter(function(u){return u&&u!==r._currentTask})),r._processTask()})}}}],[{key:"isFetchSupport",value:function(){return Ot.isSupported()}}]),e}(Dt),gn=function(){function i(){fe(this,i),A(this,"_prevCurrentTime",0)}return he(i,[{key:"do",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3,r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;if(e){var s=e.currentTime,o=0;if(this._prevCurrentTime===s){var u=ce.info(ce.get(e),s);if(!u.buffers.length)return;r&&u.nextStart||u.nextStart&&u.nextStart-s<t?o=u.nextStart+.1:u.end&&u.end-s>n&&!e.seeking&&(o=s+.1)}this._prevCurrentTime=s,o&&s!==o&&(e.currentTime=o)}}}]),i}(),yn=function(){function i(a){var e=this;fe(this,i),A(this,"_seiSet",new Set),this.emitter=a,a.on(X.SEI,function(t){t&&e._seiSet.add(t)})}return he(i,[{key:"throw",value:function(e,t){var r=this;if(!(e==null||!this._seiSet.size)){var n=e-.2,s=e+.2,o=[];this._seiSet.forEach(function(u){u.time>=n&&u.time<=s&&o.push(u)}),o.forEach(function(u){r._seiSet.delete(u),r.emitter.emit(X.SEI_IN_TIME,u)}),t&&this._seiSet.forEach(function(u){u.time<e-5&&r._seiSet.delete(u)})}}},{key:"reset",value:function(){this._seiSet.clear()}}]),i}(),_n=function(){function i(){fe(this,i),A(this,"_chunkSpeeds",[]),A(this,"_speeds",[])}return he(i,[{key:"addRecord",value:function(e,t){!e||!t||(this._speeds.push(8e3*e/t),this._speeds=this._speeds.slice(-3))}},{key:"addChunkRecord",value:function(e,t){!e||!t||(this._chunkSpeeds.push(8e3*e/t),this._chunkSpeeds=this._chunkSpeeds.slice(-100))}},{key:"getAvgSpeed",value:function(){return!this._chunkSpeeds.length&&!this._speeds.length?0:this._speeds.length?this._speeds.reduce(function(e,t){return e+=t})/this._speeds.length:this._chunkSpeeds.reduce(function(e,t){return e+=t})/this._chunkSpeeds.length}},{key:"getLatestSpeed",value:function(){return!this._chunkSpeeds.length&&!this._speeds.length?0:this._speeds.length?this._speeds[this._speeds.length-1]:this._chunkSpeeds[this._chunkSpeeds.length-1]}},{key:"reset",value:function(){this._chunkSpeeds=[],this._speeds=[]}}]),i}(),fr=function(){function i(a){fe(this,i),A(this,"encodeType",""),A(this,"audioCodec",""),A(this,"videoCodec",""),A(this,"domain",""),A(this,"fps",0),A(this,"bitrate",0),A(this,"width",0),A(this,"height",0),A(this,"samplerate",0),A(this,"channelCount",0),A(this,"gop",0),A(this,"_bitsAccumulateSize",0),A(this,"_bitsAccumulateDuration",0),A(this,"_startGopId",-1),this._timescale=a}return he(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 t,r=e.data,n=r==null||(t=r.onMetaData)===null||t===void 0?void 0:t.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 t=e.fpsNum/e.fpsDen;t>0&&t<100&&(this.fps=t)}}},{key:"setAudioMeta",value:function(e){this.audioCodec=e.codec,this.samplerate=e.sampleRate,this.channelCount=e.channelCount}},{key:"setDomain",value:function(e){this.domain=e.split("/").slice(2,3)[0]}},{key:"updateBitrate",value:function(e){var t=this;if((!this.fps||this.fps>=100)&&e.length){var r=e.reduce(function(n,s){return n+=s.duration},0)/e.length;this.fps=Math.round(this._timescale/r)}e.forEach(function(n){t._startGopId===-1&&(t._startGopId=n.gopId),n.gopId===t._startGopId&&t.gop++,t._bitsAccumulateDuration+=n.duration/(t._timescale/1e3),t._bitsAccumulateSize+=n.units.reduce(function(s,o){return s+=o.length},0),t._bitsAccumulateDuration>=1e3&&(t.bitrate=t._bitsAccumulateSize*8,t._bitsAccumulateDuration=0,t._bitsAccumulateSize=0)})}}]),i}(),Sn=function(){function i(a){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1e3;fe(this,i),A(this,"_core",null),A(this,"_samples",[]),this._core=a,this._timescale=e,this._stats=new fr(e),this._bindEvents()}return he(i,[{key:"getStats",value:function(){var e,t,r,n,s,o,u,l=((e=this._core)===null||e===void 0?void 0:e.media)||{},c=l.currentTime,f=c===void 0?0:c,v=l.decodeFps,h=v===void 0?0:v;return He(He({},this._stats.getStats()),{},{downloadSpeed:((t=this._core)===null||t===void 0||(r=t.speedInfo)===null||r===void 0?void 0:r.call(t).speed)||0,avgSpeed:((n=this._core)===null||n===void 0||(s=n.speedInfo)===null||s===void 0?void 0:s.call(n).avgSpeed)||0,currentTime:f,bufferEnd:((o=this._core)===null||o===void 0||(u=o.bufferInfo())===null||u===void 0?void 0:u.remaining)||0,decodeFps:h})}},{key:"_bindEvents",value:function(){var e=this;this._core.on(X.DEMUXED_TRACK,function(t){var r=t.videoTrack;return e._stats.updateBitrate(r.samples)}),this._core.on(X.FLV_SCRIPT_DATA,function(t){e._stats.setFpsFromScriptData(t)}),this._core.on(X.METADATA_PARSED,function(t){t.type==="video"?e._stats.setVideoMeta(t.track):e._stats.setAudioMeta(t.track)}),this._core.on(X.TTFB,function(t){e._stats.setDomain(t.responseUrl)})}},{key:"reset",value:function(){this._samples=[],this._stats=new fr(this._timescale)}}]),i}();function bn(i,a){var e=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(e!=null){var t,r,n,s,o=[],u=!0,l=!1;try{if(n=(e=e.call(i)).next,a===0){if(Object(e)!==e)return;u=!1}else for(;!(u=(t=n.call(e)).done)&&(o.push(t.value),o.length!==a);u=!0);}catch(c){l=!0,r=c}finally{try{if(!u&&e.return!=null&&(s=e.return(),Object(s)!==s))return}finally{if(l)throw r}}return o}}function ne(i,a){if(!(i instanceof a))throw new TypeError("Cannot call a class as a function")}function hr(i,a){for(var e=0;e<a.length;e++){var t=a[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(i,vr(t.key),t)}}function ie(i,a,e){return a&&hr(i.prototype,a),e&&hr(i,e),Object.defineProperty(i,"prototype",{writable:!1}),i}function L(i,a,e){return a=vr(a),a in i?Object.defineProperty(i,a,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[a]=e,i}function En(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&&Lt(i,a)}function it(i){return it=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},it(i)}function Lt(i,a){return Lt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},Lt(i,a)}function wn(){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 Tn(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function kn(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 Tn(i)}function An(i){var a=wn();return function(){var t=it(i),r;if(a){var n=it(this).constructor;r=Reflect.construct(t,arguments,n)}else r=t.apply(this,arguments);return kn(this,r)}}function Dn(i,a){return Ln(i)||bn(i,a)||dr(i,a)||In()}function pe(i){return On(i)||Pn(i)||dr(i)||Rn()}function On(i){if(Array.isArray(i))return Pt(i)}function Ln(i){if(Array.isArray(i))return i}function Pn(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function dr(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,t=new Array(a);e<a;e++)t[e]=i[e];return t}function Rn(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
7
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function In(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
8
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Cn(i,a){if(typeof i!="object"||i===null)return i;var e=i[Symbol.toPrimitive];if(e!==void 0){var t=e.call(i,a||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(i)}function vr(i){var a=Cn(i,"string");return typeof a=="symbol"?a:String(a)}var Ge={VIDEO:"video",AUDIO:"audio",METADATA:"metadata"},Me={AVC:"avc",HEVC:"hevc"},st={AAC:"aac",G711PCMA:"g7110a",G711PCMU:"g7110m"},ge={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"},pr=function(){function i(){ne(this,i),L(this,"id",1),L(this,"type",Ge.VIDEO),L(this,"codecType",Me.AVC),L(this,"pid",-1),L(this,"hvcC",void 0),L(this,"codec",""),L(this,"timescale",0),L(this,"formatTimescale",0),L(this,"sequenceNumber",0),L(this,"baseMediaDecodeTime",0),L(this,"baseDts",0),L(this,"duration",0),L(this,"warnings",[]),L(this,"samples",[]),L(this,"pps",[]),L(this,"sps",[]),L(this,"vps",[]),L(this,"fpsNum",0),L(this,"fpsDen",0),L(this,"sarRatio",[]),L(this,"width",0),L(this,"height",0),L(this,"nalUnitSize",4),L(this,"present",!1),L(this,"isVideoEncryption",!1),L(this,"isAudioEncryption",!1),L(this,"isVideo",!0),L(this,"kid",null),L(this,"pssh",null),L(this,"ext",void 0)}return ie(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:"exist",value:function(){return!!(this.pps.length&&this.sps.length&&this.codec)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isVideoEncryption}}]),i}(),mr=function(){function i(){ne(this,i),L(this,"id",2),L(this,"type",Ge.AUDIO),L(this,"codecType",st.AAC),L(this,"pid",-1),L(this,"codec",""),L(this,"sequenceNumber",0),L(this,"sampleDuration",0),L(this,"timescale",0),L(this,"formatTimescale",0),L(this,"baseMediaDecodeTime",0),L(this,"duration",0),L(this,"warnings",[]),L(this,"samples",[]),L(this,"baseDts",0),L(this,"sampleSize",16),L(this,"sampleRate",0),L(this,"channelCount",0),L(this,"objectType",0),L(this,"sampleRateIndex",0),L(this,"config",[]),L(this,"present",!1),L(this,"isVideoEncryption",!1),L(this,"isAudioEncryption",!1),L(this,"kid",null),L(this,"ext",void 0)}return ie(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===st.AAC)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isAudioEncryption}}]),i}(),gr=function(){function i(a,e,t){ne(this,i),L(this,"flag",{}),L(this,"keyframe",!1),L(this,"gopId",0),L(this,"duration",0),L(this,"size",0),L(this,"units",[]),L(this,"chromaFormat",420),this.originPts=this.pts=a,this.originDts=this.dts=e,t&&(this.units=t)}return ie(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}(),at=ie(function i(a,e,t,r){ne(this,i),L(this,"duration",1024),L(this,"flag",{dependsOn:2,isNonSyncSample:0}),L(this,"keyframe",!0),this.originPts=this.pts=this.dts=a,this.data=e,this.size=e.byteLength,this.sampleOffset=r,t&&(this.duration=t)}),Mn=ie(function i(a,e){ne(this,i),L(this,"time",0),this.data=a,this.originPts=this.pts=e}),Bn=function(i){En(e,i);var a=An(e);function e(){return ne(this,e),a.apply(this,arguments)}return ie(e)}(Mn),yr=function(){function i(){ne(this,i),L(this,"id",3),L(this,"type",Ge.METADATA),L(this,"timescale",0),L(this,"flvScriptSamples",[]),L(this,"seiSamples",[])}return ie(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}(),ot=function(){function i(a){ne(this,i),this.name=a||"",this._prefix="[".concat(this.name,"]")}return ie(i,[{key:"warn",value:function(){var e;if(!i.disabled){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];(e=console).warn.apply(e,[this._prefix].concat(r))}}}],[{key:"enable",value:function(){i.disabled=!1}},{key:"disable",value:function(){i.disabled=!0}}]),i}();L(ot,"disabled",!0);var ut=typeof window<"u",Rt=ut&&navigator.userAgent.toLocaleLowerCase(),Un=ut&&/^((?!chrome|android).)*safari/.test(Rt),xn=ut&&Rt.includes("firefox"),Nn=ut&&Rt.includes("android"),ke=function(){function i(){ne(this,i)}return ie(i,null,[{key:"getRateIndexByRate",value:function(e){return i.FREQ.indexOf(e)}},{key:"parseADTS",value:function(e,t){for(var r=e.length,n=0;n+2<r&&!(e[n]===255&&(e[n+1]&246)===240);)n++;if(!(n>=r)){var s=n,o=[],u=(e[n+2]&60)>>>2,l=i.FREQ[u];if(!l)throw new Error("Invalid sampling index: ".concat(u));for(var c=((e[n+2]&192)>>>6)+1,f=(e[n+2]&1)<<2|(e[n+3]&192)>>>6,v=i._getConfig(u,f,c),h=v.config,p=v.codec,y,d,_=0,b=i.getFrameDuration(l);n+7<r;){if(e[n]!==255||(e[n+1]&246)!==240){n++;continue}if(d=(e[n+3]&3)<<11|e[n+4]<<3|(e[n+5]&224)>>5,r-n<d)break;y=(~e[n+1]&1)*2,o.push({pts:t+_*b,data:e.subarray(n+7+y,n+d)}),_++,n+=d}return{skip:s,remaining:n>=r?void 0:e.subarray(n),frames:o,samplingFrequencyIndex:u,sampleRate:l,objectType:c,channelCount:f,codec:p,config:h,originCodec:"mp4a.40.".concat(c)}}}},{key:"parseAudioSpecificConfig",value:function(e){if(e.length){var t=e[0]>>>3,r=(e[0]&7)<<1|e[1]>>>7,n=(e[1]&120)>>>3,s=i.FREQ[r];if(s){var o=i._getConfig(r,n,t),u=o.config,l=o.codec;return{samplingFrequencyIndex:r,sampleRate:s,objectType:t,channelCount:n,config:u,codec:l,originCodec:"mp4a.40.".concat(t)}}}}},{key:"getFrameDuration",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:9e4;return 1024*t/e}},{key:"_getConfig",value:function(e,t,r){var n=[],s,o;return xn?e>=6?(s=5,o=e-3):(s=2,o=e):Nn?(s=2,o=e):(s=r===2||r===5?r:5,o=e,e>=6?o=e-3:t===1&&(s=2,o=e)),n[0]=s<<3,n[0]|=(e&14)>>1,n[1]=(e&1)<<7,n[1]|=t<<3,s===5&&(n[1]|=(o&14)>>1,n[2]=(o&1)<<7,n[2]|=8,n[3]=0),{config:n,codec:"mp4a.40.".concat(s)}}},{key:"getSilentFrame",value:function(e,t){switch(e){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(t===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(t===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}}]),i}();L(ke,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]);function ye(){for(var i=arguments.length,a=new Array(i),e=0;e<i;e++)a[e]=arguments[e];a=a.filter(Boolean);var t=new Uint8Array(a.reduce(function(n,s){return n+s.byteLength},0)),r=0;return a.forEach(function(n){t.set(n,r),r+=n.byteLength}),t}var Fn=Math.pow(2,32);function J(i){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(i[a]<<8)+(i[a+1]||0)}function Vn(i){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(i[a]<<16)+(i[a+1]<<8)+(i[a+2]||0)}function P(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 Ae(i){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return P(i,a)*Fn+P(i,a+4)}function _r(i){for(var a="avc1.",e,t=0;t<3;t++)e=i[t].toString(16),e.length<2&&(e="0".concat(e)),a+=e;return a}function Sr(i){if(!Array.isArray(i)){for(var a=[],e="",t=0;t<i.length;t++)t%2&&(e=i[t-1]+i[t],a.push(parseInt(e,16)),e="");return a}return i.map(function(r){return parseInt(r,16)})}var De=function(){function i(){ne(this,i)}return ie(i,null,[{key:"parseAnnexB",value:function(e){for(var t=e.length,r=2,n=0;e[r]!==null&&e[r]!==void 0&&e[r]!==1;)r++;if(r++,n=r+2,n>=t)return[];for(var s=[];n<t;)switch(e[n]){case 0:if(e[n-1]!==0){n+=2;break}else if(e[n-2]!==0){n++;break}r!==n-2&&s.push(e.subarray(r,n-2));do n++;while(e[n]!==1&&n<t);r=n+1,n=r+2;break;case 1:if(e[n-1]!==0||e[n-2]!==0){n+=3;break}r!==n-2&&s.push(e.subarray(r,n-2)),r=n+1,n=r+2;break;default:n+=3;break}return r<t&&s.push(e.subarray(r)),s}},{key:"parseAvcC",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;if(!(e.length<4)){for(var r=e.length,n=[],s=0,o;s+t<r;)if(o=P(e,s),t===3&&(o>>>=8),s+=t,!!o){if(s+o>r)break;n.push(e.subarray(s,s+o)),s+=o}return n}}},{key:"parseSEI",value:function(e,t){for(var r=e.length,n=t?2:1,s=0,o=0,u="";e[n]===255;)s+=255,n++;for(s+=e[n++];e[n]===255;)o+=255,n++;if(o+=e[n++],s===5&&r>n+16)for(var l=0;l<16;l++)u+=e[n].toString(16),n++;return{payload:e.subarray(n,n+o),type:s,size:o,uuid:u}}},{key:"removeEPB",value:function(e){for(var t=e.byteLength,r=[],n=1;n<t-2;)e[n]===0&&e[n+1]===0&&e[n+2]===3?(r.push(n+2),n+=2):n++;if(!r.length)return e;var s=t-r.length,o=new Uint8Array(s),u=0;for(n=0;n<s;u++,n++)u===r[0]&&(u++,r.shift()),o[n]=e[u];return o}}]),i}(),It=function(){function i(a){if(ne(this,i),L(this,"_bytesAvailable",void 0),L(this,"_bitsAvailable",0),L(this,"_word",0),!a)throw new Error("ExpGolomb data params is required");this._data=a,this._bytesAvailable=a.byteLength,this._bytesAvailable&&this._loadWord()}return ie(i,[{key:"bitsAvailable",get:function(){return this._bitsAvailable}},{key:"_loadWord",value:function(){var e=this._data.byteLength-this._bytesAvailable,t=Math.min(4,this._bytesAvailable);if(t===0)throw new Error("No bytes available");var r=new Uint8Array(4);r.set(this._data.subarray(e,e+t)),this._word=new DataView(r.buffer).getUint32(0),this._bitsAvailable=t*8,this._bytesAvailable-=t}},{key:"skipBits",value:function(e){if(this._bitsAvailable>e)this._word<<=e,this._bitsAvailable-=e;else{e-=this._bitsAvailable;var t=Math.floor(e/8);e-=t*8,this._bytesAvailable-=t,this._loadWord(),this._word<<=e,this._bitsAvailable-=e}}},{key:"readBits",value:function(e){if(e>32)throw new Error("Cannot read more than 32 bits");var t=Math.min(this._bitsAvailable,e),r=this._word>>>32-t;return this._bitsAvailable-=t,this._bitsAvailable>0?this._word<<=t:this._bytesAvailable>0&&this._loadWord(),t=e-t,t>0&&this._bitsAvailable?r<<t|this.readBits(t):r}},{key:"skipLZ",value:function(){var e;for(e=0;e<this._bitsAvailable;++e)if(this._word&2147483648>>>e)return this._word<<=e,this._bitsAvailable-=e,e;return this._loadWord(),e+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var e=this.skipLZ();return this.readBits(e+1)-1}},{key:"readEG",value:function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}},{key:"readBool",value:function(){return this.readBits(1)===1}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"skipScalingList",value:function(e){for(var t=8,r=8,n,s=0;s<e;s++)r!==0&&(n=this.readEG(),r=(t+n+256)%256),t=r===0?t:r}}]),i}(),Gn=function(){function i(){ne(this,i)}return ie(i,null,[{key:"parseAVCDecoderConfigurationRecord",value:function(e){if(!(e.length<7)){for(var t=(e[4]&3)+1,r,n=[],s=[],o=6,u=e[5]&31,l,c=0;c<u;c++)if(l=e[o]<<8|e[o+1],o+=2,!!l){var f=e.subarray(o,o+l);o+=l,n.push(f),r||(r=i.parseSPS(De.removeEPB(f)))}var v=e[o];o++;for(var h,p=0;p<v;p++)h=e[o]<<8|e[o+1],o+=2,h&&(s.push(e.subarray(o,o+h)),o+=h);return{sps:r,spsArr:n,ppsArr:s,nalUnitSize:t}}}},{key:"parseSPS",value:function(e){var t=new It(e);t.readUByte();var r=t.readUByte(),n=t.readUByte(),s=t.readUByte();t.skipUEG();var o=420;if(r===100||r===110||r===122||r===244||r===44||r===83||r===86||r===118||r===128||r===138||r===144){var u=t.readUEG();if(u<=3&&(o=[0,420,422,444][u]),u===3&&t.skipBits(1),t.skipUEG(),t.skipUEG(),t.skipBits(1),t.readBool())for(var l=u!==3?8:12,c=0;c<l;c++)t.readBool()&&(c<6?t.skipScalingList(16):t.skipScalingList(64))}t.skipUEG();var f=t.readUEG();if(f===0)t.readUEG();else if(f===1){t.skipBits(1),t.skipUEG(),t.skipUEG();for(var v=t.readUEG(),h=0;h<v;h++)t.skipUEG()}t.skipUEG(),t.skipBits(1);var p=t.readUEG(),y=t.readUEG(),d=t.readBits(1);d===0&&t.skipBits(1),t.skipBits(1);var _=0,b=0,w=0,D=0;t.readBool()&&(_=t.readUEG(),b=t.readUEG(),w=t.readUEG(),D=t.readUEG());var T,F,B,N,G;if(t.readBool()){if(t.readBool()){var M=t.readUByte();switch(M){case 1:T=[1,1];break;case 2:T=[12,11];break;case 3:T=[10,11];break;case 4:T=[16,11];break;case 5:T=[40,33];break;case 6:T=[24,11];break;case 7:T=[20,11];break;case 8:T=[32,11];break;case 9:T=[80,33];break;case 10:T=[18,11];break;case 11:T=[15,11];break;case 12:T=[64,33];break;case 13:T=[160,99];break;case 14:T=[4,3];break;case 15:T=[3,2];break;case 16:T=[2,1];break;case 255:{T=[t.readUByte()<<8|t.readUByte(),t.readUByte()<<8|t.readUByte()];break}}}if(t.readBool()&&t.readBool(),t.readBool()&&(t.readBits(4),t.readBool()&&t.readBits(24)),t.readBool()&&(t.readUEG(),t.readUEG()),t.readBool()){var q=t.readBits(32),m=t.readBits(32);F=t.readBool(),B=m,N=q*2,G=B/N}}return{codec:_r(e.subarray(1,4)),profileIdc:r,profileCompatibility:n,levelIdc:s,chromaFormat:o,width:Math.ceil((p+1)*16-2*(_+b)),height:(2-d)*(y+1)*16-(d?2:4)*(w+D),sarRatio:T,fpsNum:B,fpsDen:N,fps:G,fixedFrame:F}}}]),i}(),br=function(){function i(){ne(this,i)}return ie(i,null,[{key:"parseHEVCDecoderConfigurationRecord",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!(e.length<23)){t=t||{};for(var r=(e[21]&3)+1,n,s,o=[],u=[],l=[],c=23,f=e[22],v,h,p,y=0;y<f;y++){v=e[c]&63,h=e[c+1]<<8|e[c+2],c+=3;for(var d=0;d<h;d++)if(p=e[c]<<8|e[c+1],c+=2,!!p){switch(v){case 32:{var _=e.subarray(c,c+p);n||(n=i.parseVPS(De.removeEPB(_),t)),l.push(_)}break;case 33:{var b=e.subarray(c,c+p);s||(s=i.parseSPS(De.removeEPB(b),t)),o.push(b)}break;case 34:u.push(e.subarray(c,c+p));break}c+=p}}return{hvcC:t,sps:s,spsArr:o,ppsArr:u,vpsArr:l,nalUnitSize:r}}}},{key:"parseVPS",value:function(e,t){t=t||{};var r=new It(e);r.readUByte(),r.readUByte(),r.readBits(12);var n=r.readBits(3);return t.numTemporalLayers=Math.max(t.numTemporalLayers||0,n+1),r.readBits(17),i._parseProfileTierLevel(r,n,t),t}},{key:"parseSPS",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};t=t||{};var r=new It(e);r.readUByte(),r.readUByte(),r.readBits(4);var n=r.readBits(3);t.numTemporalLayers=Math.max(n+1,t.numTemporalLayers||0),t.temporalIdNested=r.readBits(1),i._parseProfileTierLevel(r,n,t),r.readUEG();var s=t.chromaFormatIdc=r.readUEG(),o=420;s<=3&&(o=[0,420,422,444][s]);var u=0;s===3&&(u=r.readBits(1));var l=r.readUEG(),c=r.readUEG(),f=r.readBits(1),v,h,p,y;if(f===1&&(v=r.readUEG(),h=r.readUEG(),p=r.readUEG(),y=r.readUEG()),t.bitDepthLumaMinus8=r.readUEG(),t.bitDepthChromaMinus8=r.readUEG(),f===1){var d=(s===1||s===2)&&u===0?2:1,_=s===1&&u===0?2:1;l-=d*(h+v),c-=_*(y+p)}return{codec:"hev1.1.6.L93.B0",width:l,height:c,chromaFormat:o,hvcC:t}}},{key:"_parseProfileTierLevel",value:function(e,t,r){var n=r.generalTierFlag||0;r.generalProfileSpace=e.readBits(2),r.generalTierFlag=Math.max(e.readBits(1),n),r.generalProfileIdc=Math.max(e.readBits(5),r.generalProfileIdc||0),r.generalProfileCompatibilityFlags=e.readBits(32),r.generalConstraintIndicatorFlags=[e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8)];var s=e.readBits(8);n<r.generalTierFlag?r.generalLevelIdc=s:r.generalLevelIdc=Math.max(s,r.generalLevelIdc||0);var o=[],u=[];if(t>e.bitsAvailable)throw new Error("maxSubLayersMinus inavlid size ".concat(t));for(var l=0;l<t;l++)o[l]=e.readBits(1),u[l]=e.readBits(1);t>0&&e.readBits((8-t)*2);for(var c=0;c<t;c++)o[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)),u[c]!==0&&e.readBits(8)}}]),i}(),jn=9e4/2,Er=3,Ct=9e4,Mt=5*9e4,Bt=9e4,Hn=9e4/2,zn=function(){function i(a,e,t){ne(this,i),this.videoTrack=a,this.audioTrack=e,this.metadataTrack=t,this._baseDts=-1,this._baseDtsInited=!1,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=!1,this._videoTimestampBreak=!1,this._lastAudioExceptionGapDot=0,this._lastAudioExceptionOverlapDot=0,this._lastAudioExceptionLargeGapDot=0}return ie(i,[{key:"fix",value:function(){var e=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;t=Math.round(t*9e4);var s=this.videoTrack,o=this.audioTrack,u=s.samples,l=o.samples;if(!(!u.length&&!l.length)){var c=u[0],f=l[0],v=0;if(u.length&&l.length&&(v=c.dts-f.pts),this._baseDtsInited||this._calculateBaseDts(this.audioTrack,this.videoTrack),r&&(this._calculateBaseDts(this.audioTrack,this.videoTrack),this._baseDts-=t),!n){this._videoNextDts=v>0?t+v:t,this._audioNextPts=v>0?t:t-v;var h=c?c.dts-this._baseDts-this._videoNextDts:0,p=f?f.pts-this._baseDts-this._audioNextPts:0;Math.abs(h||p)>Bt&&(this._calculateBaseDts(this.audioTrack,this.videoTrack),this._baseDts-=t)}if(this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(o),this._fixVideo(s),this.metadataTrack.exist()){var y=this.metadataTrack.timescale;this.metadataTrack.seiSamples.forEach(function(d){d.pts=d.originPts-e._baseDts,d.time=Math.max(0,d.pts)/y})}s.samples.length&&(s.baseMediaDecodeTime=s.samples[0].dts),o.samples.length&&(o.baseMediaDecodeTime=o.samples[0].pts*o.timescale/9e4)}}},{key:"_fixVideo",value:function(e){var t=this,r=e.samples;if(r.length){if(r.forEach(function(B){B.dts-=t._baseDts,B.pts-=t._baseDts}),this._videoNextDts===void 0){var n=r[0];this._videoNextDts=n.dts}var s=r.length,o=0,u=r[0],l=r[1],c=this._videoNextDts-u.dts;if(Math.abs(c)>Hn){var f;if(e.warnings.push({type:ge.LARGE_VIDEO_GAP_BETWEEN_CHUNK,nextDts:this._videoNextDts/90,firstSampleDts:u.dts/90,nextSampleDts:(((f=r[1])===null||f===void 0?void 0:f.dts)||0)/90,sampleDuration:c/90}),u.dts+=c,u.pts+=c,l&&Math.abs(l.dts-u.dts)>Bt)this._videoTimestampBreak=!0,r.forEach(function(B,N){N!==0&&(B.dts+=c,B.pts+=c)});else for(var v=1;v<s-1;v++){var h,p=(h=r[v])===null||h===void 0?void 0:h.dts,y=r[v-1].dts;p&&p-y<0&&(r[v].dts+=c,r[v].pts+=c)}}var d;if(e.fpsNum&&e.fpsDen)d=e.timescale*(e.fpsDen/e.fpsNum);else{var _=e.samples[0],b=e.samples[1];d=s===1?9e3:Math.floor(b.dts-_.dts)}for(var w=0;w<s;w++){var D=r[w].dts,T=r[w+1];if(w<s-1?o=T.dts-D:r[w-1]?o=Math.min(D-r[w-1].dts,d):o=d,o>Bt||o<0){this._videoTimestampBreak=!0,o=this._audioTimestampBreak?d:Math.max(o,30*90);var F=this._audioNextPts||0;T&&T.dts>F&&(o=d),e.warnings.push({type:ge.LARGE_VIDEO_GAP,time:D/e.timescale,dts:D,originDts:r[w].originDts,nextDts:this._videoNextDts,sampleDuration:o,refSampleDuration:d})}r[w].duration=o,this._videoNextDts+=o}}}},{key:"_fixAudio",value:function(e){var t=this,r=e.samples;r.length&&(r.forEach(function(n){n.pts-=t._baseDts,n.dts=n.pts}),this._doFixAudioInternal(e,r,9e4))}},{key:"_calculateBaseDts",value:function(e,t){var r=e.samples,n=t.samples;if(!r.length&&!n.length)return!1;var s=1/0,o=1/0;r.length&&(e.baseDts=s=r[0].pts),n.length&&(t.baseDts=o=n[0].dts),this._baseDts=Math.min(s,o);var u=o-s;return Number.isFinite(u)&&Math.abs(u)>jn&&t.warnings.push({type:ge.LARGE_AV_SHIFT,videoBaseDts:o,audioBasePts:s,baseDts:this._baseDts,delta:u}),this._baseDtsInited=!0,!0}},{key:"_resetBaseDtsWhenStreamBreaked",value:function(){if(this._baseDtsInited&&this._videoTimestampBreak&&this._audioTimestampBreak){var e=this._calculateBaseDts(this.audioTrack,this.videoTrack);if(!e)return;this._baseDts-=Math.min(this._audioNextPts,this._videoNextDts),this._audioLastSample=null,this._videoLastSample=null,this._videoTimestampBreak=!1,this._audioTimestampBreak=!1}}},{key:"_doFixAudioInternal",value:function(e,t,r){e.sampleDuration||(e.sampleDuration=ke.getFrameDuration(e.timescale,r));var n=e.sampleDuration;if(this._audioNextPts===void 0){var s=t[0];this._audioNextPts=s.pts}for(var o=0;o<t.length;o++){var u=this._audioNextPts,l=t[o],c=l.pts-u;if(!this._audioTimestampBreak&&c>=Er*n&&c<=Ct&&!Un){var f=ke.getSilentFrame(e.codec,e.channelCount)||t[0].data.subarray(),v=Math.floor(c/n);Math.abs(l.pts-this._lastAudioExceptionGapDot)>Mt&&(this._lastAudioExceptionGapDot=l.pts),e.warnings.push({type:ge.AUDIO_FILLED,pts:l.pts,originPts:l.originPts,count:v,nextPts:u,refSampleDuration:n});for(var h=0;h<v;h++){var p=new at(Math.floor(u),f);p.originPts=Math.floor(this._baseDts+u),t.splice(o,0,p),this._audioNextPts+=n,o++}o--}else c<=-Er*n&&c>=-1*Ct?(Math.abs(l.pts-this._lastAudioExceptionOverlapDot)>Mt&&(this._lastAudioExceptionOverlapDot=l.pts,e.warnings.push({type:ge.AUDIO_DROPPED,pts:l.pts,originPts:l.originPts,nextPts:u,refSampleDuration:n})),t.splice(o,1),o--):(Math.abs(c)>=Ct&&(this._audioTimestampBreak=!0,Math.abs(l.pts-this._lastAudioExceptionLargeGapDot)>Mt&&(this._lastAudioExceptionLargeGapDot=l.pts,e.warnings.push({type:ge.LARGE_AUDIO_GAP,time:l.pts/1e3,pts:l.pts,originPts:l.originPts,nextPts:u,sampleDuration:c,refSampleDuration:n}))),l.dts=l.pts=u,this._audioNextPts+=n)}}}]),i}(),_e=new ot("TsDemuxer"),wr=function(){function i(a,e,t){ne(this,i),L(this,"_pmtId",-1),L(this,"_remainingPacketData",null),L(this,"_videoPesData",[]),L(this,"_audioPesData",[]),L(this,"_gopId",0),this.videoTrack=a||new pr,this.audioTrack=e||new mr,this.metadataTrack=t||new yr,this._fixer=new zn(this.videoTrack,this.audioTrack,this.metadataTrack)}return ie(i,[{key:"demux",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,n=this.audioTrack,s=this.videoTrack,o=this.metadataTrack;t&&(this._pmtId=-1,s.reset(),n.reset(),o.reset()),!r||t?(this._remainingPacketData=null,this._videoPesData=[],this._audioPesData=[]):(s.samples=[],n.samples=[],o.seiSamples=[],s.warnings=[],n.warnings=[],this._remainingPacketData&&(e=ye(this._remainingPacketData,e),this._remainingPacketData=null));var u=e.length,l=u%188;l&&(this._remainingPacketData=e.subarray(u-l),u-=l);for(var c=s.pid,f=n.pid,v=0;v<u;v+=188){if(e[v]!==71)throw new Error("TS packet did not start with 0x47");var h=!!(e[v+1]&64),p=((e[v+1]&31)<<8)+e[v+2],y=(e[v+3]&48)>>4,d=void 0;if(y>1){if(d=v+5+e[v+4],d===v+188)continue}else d=v+4;switch(p){case 0:h&&(d+=e[d]+1),this._pmtId=(e[d+10]&31)<<8|e[d+11];break;case this._pmtId:{h&&(d+=e[d]+1);var _=d+3+((e[d+1]&15)<<8|e[d+2])-4,b=(e[d+10]&15)<<8|e[d+11];for(d+=12+b;d<_;){var w=(e[d+1]&31)<<8|e[d+2];switch(e[d]){case 15:n.pid=f=w;break;case 27:if(c!==-1)break;s.codecType=Me.AVC,s.pid=c=w;break;case 36:if(c!==-1)break;s.codecType=Me.HEVC,s.pid=c=w;break;default:_e.warn("Unsupported stream. type: ".concat(e[d],", pid: ").concat(w))}d+=((e[d+3]&15)<<8|e[d+4])+5}}break;case c:h&&this._videoPesData.length&&this._parseVideoData(),this._videoPesData.push(e.subarray(d,v+188));break;case f:h&&this._audioPesData.length&&this._parseAudioData(),this._audioPesData.push(e.subarray(d,v+188));break;case 17:case 8191:break;default:_e.warn("Unknown pid: ".concat(p))}}return this._parseVideoData(),this._parseAudioData(),n.formatTimescale=s.formatTimescale=s.timescale=o.timescale=9e4,n.timescale=n.sampleRate||0,{videoTrack:s,audioTrack:n,metadataTrack:o}}},{key:"fix",value:function(e,t,r){return this._fixer.fix(e,t,r),{videoTrack:this.videoTrack,audioTrack:this.audioTrack,metadataTrack:this.metadataTrack}}},{key:"demuxAndFix",value:function(e,t,r,n){return this.demux(e,t,r),this.fix(n,t,r)}},{key:"_parseVideoData",value:function(){if(this._videoPesData.length){var e=i._parsePES(ye.apply(void 0,pe(this._videoPesData)));if(!e){_e.warn("Cannot parse video pes",this._videoPesData);return}var t=De.parseAnnexB(e.data);t?this._createVideoSample(t,e.pts,e.dts):_e.warn("Cannot parse avc units",e),this._videoPesData=[]}}},{key:"_createVideoSample",value:function(e,t,r){var n=this;if(e.length){var s=this.videoTrack,o=s.codecType===Me.HEVC,u=new gr(t,r);e.forEach(function(l){var c=o?l[0]>>>1&63:l[0]&31;switch(c){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!o&&c!==5||o&&c===5)break;u.setToKeyframe(),n._gopId++;break;case 6:case 39:case 40:if(!o&&c!==6||o&&c===6)break;n.metadataTrack.seiSamples.push(new Bn(De.parseSEI(De.removeEPB(l),o),t));return;case 32:if(!o)break;if(!s.vps.length){var f=br.parseVPS(De.removeEPB(l),s.hvcC);s.hvcC=s.hvcC||f,s.vps=[l]}break;case 7:case 33:if(!o&&c!==7||o&&c===7)break;if(!s.sps.length){var v=De.removeEPB(l),h=o?br.parseSPS(v,s.hvcC):Gn.parseSPS(v);s.sps=[l],s.hvcC=s.hvcC||h.hvcC,s.codec=h.codec,s.width=h.width,s.height=h.height,s.sarRatio=h.sarRatio,s.fpsNum=h.fpsNum,s.fpsDen=h.fpsDen}break;case 8:case 34:if(!o&&c!==8||o&&c===8)break;s.pps.length||(s.pps=[l]);break;case 9:case 35:break;case 38:if(o){for(var p=!1,y=2;y<l.byteLength;y++)if(l[y]===255){p=!0;break}if(!p)return}break}u.units.push(l)}),u.gopId=this._gopId,this._pushVideoSample(s,u)}}},{key:"_pushVideoSample",value:function(e,t){if(t.units.length)if(t.pts===null||t.pts===void 0){_e.warn("Video sample no pts",t);var r=e.samples[e.samples.length-1];r?(t.pts=r.pts,t.dts=r.dts):_e.warn("Drop video sample",t)}else e.samples.push(t)}},{key:"_parseAudioData",value:function(){if(this._audioPesData.length){var e=i._parsePES(ye.apply(void 0,pe(this._audioPesData)));if(!e){_e.warn("Cannot parse audio pes",this._audioPesData);return}this._parseAacData(e),this._audioPesData=[]}}},{key:"_parseAacData",value:function(e){var t=this.audioTrack,r=e.pts;if(r==null){if(_e.warn("AAC pes not pts",t),!t.samples.length||!t.sampleRate)return;r=t.samples[t.samples.length-1].pts+ke.getFrameDuration(t.sampleRate)}var n=ke.parseADTS(e.data,r);if(n){var s;t.codec=n.codec,t.channelCount=n.channelCount,t.sampleRate=n.sampleRate,t.objectType=n.objectType,t.sampleRateIndex=n.samplingFrequencyIndex,t.config=n.config,(s=t.samples).push.apply(s,pe(n.frames.map(function(o){return new at(o.pts,o.data)}))),n.skip&&_e.warn("Skip aac adts ".concat(n.skip," bits")),n.remaining&&_e.warn("Remaining aac adts ".concat(n.remaining," bits"))}else _e.warn("Cannot parse aac adts",e)}}],[{key:"probe",value:function(e){return e.length?e[0]===71&&e[188]===71&&e[376]===71:!1}},{key:"_parsePES",value:function(e){var t=e[8];if(!(t==null||e.length<t+9)){var r=e[0]<<16|e[1]<<8|e[2];if(r===1){var n=(e[4]<<8)+e[5];if(!(n&&n>e.length-6)){var s,o,u=e[7];return u&192&&(s=(e[9]&14)*536870912+(e[10]&255)*4194304+(e[11]&254)*16384+(e[12]&255)*128+(e[13]&254)/2,u&64?(o=(e[14]&14)*536870912+(e[15]&255)*4194304+(e[16]&254)*16384+(e[17]&255)*128+(e[18]&254)/2,s-o>60*9e4&&(s=o)):o=s),{data:e.subarray(9+t),pts:s,dts:o}}}}}}]),i}(),ae=function(){function i(){ne(this,i)}return ie(i,null,[{key:"findBox",value:function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,n=[];if(!e)return n;for(var s=0,o="",u=0;e.length>7;){if(s=P(e),o=String.fromCharCode.apply(null,e.subarray(4,8)),u=8,s===1?(s=Ae(e,8),u+=8):s||(s=e.length),!t[0]||o===t[0]){var l=e.subarray(0,s);if(t.length<2)n.push({start:r,size:s,headerSize:u,type:o,data:l});else return i.findBox(l.subarray(u),t.slice(1),r+u)}r+=s,e=e.subarray(s)}return n}},{key:"tfhd",value:function(e){return j(e,!0,function(t,r){t.trackId=P(r);var n=4,s=t.flags&255&1,o=t.flags&255&2,u=t.flags&255&8,l=t.flags&255&16,c=t.flags&255&32;s&&(n+=4,t.baseDataOffset=P(r,n),n+=4),o&&(t.sampleDescriptionIndex=P(r,n),n+=4),u&&(t.defaultSampleDuration=P(r,n),n+=4),l&&(t.defaultSampleSize=P(r,n),n+=4),c&&(t.defaultSampleFlags=P(r,n))})}},{key:"sidx",value:function(e){return j(e,!0,function(t,r){var n=0;t.reference_ID=P(r,n),n+=4,t.timescale=P(r,n),n+=4,t.version===0?(t.earliest_presentation_time=P(r,n),n+=4,t.first_offset=P(r,n),n+=4):(t.earliest_presentation_time=Ae(r,n),n+=8,t.first_offset=Ae(r,n),n+=8),n+=2,t.references=[];var s=J(r,n);n+=2;for(var o=0;o<s;o++){var u={};t.references.push(u);var l=P(r,n);n+=4,u.reference_type=l>>31&1,u.referenced_size=l&2147483647,u.subsegment_duration=P(r,n),n+=4,l=P(r,n),n+=4,u.starts_with_SAP=l>>31&1,u.SAP_type=l>>28&7,u.SAP_delta_time=l&268435455}})}},{key:"moov",value:function(e){return j(e,!1,function(t,r,n){t.mvhd=i.mvhd(i.findBox(r,["mvhd"],n)[0]),t.trak=i.findBox(r,["trak"],n).map(function(s){return i.trak(s)}),t.pssh=i.pssh(i.findBox(r,["pssh"],n)[0])})}},{key:"mvhd",value:function(e){return j(e,!0,function(t,r){var n=0;t.version===1?(t.timescale=P(r,16),t.duration=Ae(r,20),n+=28):(t.timescale=P(r,8),t.duration=P(r,12),n+=16),t.nextTrackId=P(r,n+76)})}},{key:"trak",value:function(e){return j(e,!1,function(t,r,n){t.tkhd=i.tkhd(i.findBox(r,["tkhd"],n)[0]),t.mdia=i.mdia(i.findBox(r,["mdia"],n)[0])})}},{key:"tkhd",value:function(e){return j(e,!0,function(t,r){var n=0;t.version===1?(t.trackId=P(r,16),t.duration=Ae(r,24),n+=32):(t.trackId=P(r,8),t.duration=P(r,16),n+=20),t.width=P(r,n+52),t.height=P(r,n+56)})}},{key:"mdia",value:function(e){return j(e,!1,function(t,r,n){t.mdhd=i.mdhd(i.findBox(r,["mdhd"],n)[0]),t.hdlr=i.hdlr(i.findBox(r,["hdlr"],n)[0]),t.minf=i.minf(i.findBox(r,["minf"],n)[0])})}},{key:"mdhd",value:function(e){return j(e,!0,function(t,r){var n=0;t.version===1?(t.timescale=P(r,16),t.duration=Ae(r,20),n+=28):(t.timescale=P(r,8),t.duration=P(r,12),n+=16);var s=J(r,n);t.language=String.fromCharCode((s>>10&31)+96,(s>>5&31)+96,(s&31)+96)})}},{key:"hdlr",value:function(e){return j(e,!0,function(t,r){t.version===0&&(t.handlerType=String.fromCharCode.apply(null,r.subarray(4,8)))})}},{key:"minf",value:function(e){return j(e,!1,function(t,r,n){t.vmhd=i.vmhd(i.findBox(r,["vmhd"],n)[0]),t.smhd=i.smhd(i.findBox(r,["smhd"],n)[0]),t.stbl=i.stbl(i.findBox(r,["stbl"],n)[0])})}},{key:"vmhd",value:function(e){return j(e,!0,function(t,r){t.graphicsmode=J(r),t.opcolor=[J(r,2),J(r,4),J(r,6)]})}},{key:"smhd",value:function(e){return j(e,!0,function(t,r){t.balance=J(r)})}},{key:"stbl",value:function(e){return j(e,!1,function(t,r,n){var s,o,u;t.stsd=i.stsd(i.findBox(r,["stsd"],n)[0]),t.stts=i.stts(i.findBox(r,["stts"],n)[0]),t.ctts=i.ctts(i.findBox(r,["ctts"],n)[0]),t.stsc=i.stsc(i.findBox(r,["stsc"],n)[0]),t.stsz=i.stsz(i.findBox(r,["stsz"],n)[0]),t.stco=i.stco(i.findBox(r,["stco"],n)[0]),t.stco||(t.co64=i.co64(i.findBox(r,["co64"],n)[0]),t.stco=t.co64);var l=(s=t.stsd.entries[0])===null||s===void 0||(o=s.sinf)===null||o===void 0||(u=o.schi)===null||u===void 0?void 0:u.tenc.default_IV_size;t.stss=i.stss(i.findBox(r,["stss"],n)[0]),t.senc=i.senc(i.findBox(r,["senc"],n)[0],l)})}},{key:"senc",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:8;return j(e,!0,function(r,n){var s=0,o=P(n,s);s+=4,r.samples=[];for(var u=0;u<o;u++){var l={};l.InitializationVector=[];for(var c=0;c<t;c++)l.InitializationVector[c]=n[s+c];if(s+=t,r.flags&2){l.subsamples=[];var f=J(n,s);s+=2;for(var v=0;v<f;v++){var h={};h.BytesOfClearData=J(n,s),s+=2,h.BytesOfProtectedData=P(n,s),s+=4,l.subsamples.push(h)}}r.samples.push(l)}})}},{key:"pssh",value:function(e){return j(e,!0,function(t,r){for(var n=[],s=[],o=0,u=0;u<16;u++)s.push(Ut(r[o+u]));if(o+=16,t.version>0){var l=P(r,o);o+=4;for(var c=0;c<(""+l).length;c++)for(var f=0;f<16;f++){var v=r[o];o+=1,n.push(Ut(v))}}var h=P(r,o);t.data_size=h,o+=4,t.kid=n,t.system_id=s,t.buffer=r})}},{key:"stsd",value:function(e){return j(e,!0,function(t,r,n){t.entryCount=P(r),t.entries=i.findBox(r.subarray(4),[],n+4).map(function(s){switch(s.type){case"avc1":case"avc2":case"avc3":case"avc4":return i.avc1(s);case"hvc1":case"hev1":return i.hvc1(s);case"mp4a":return i.mp4a(s);case"alaw":case"ulaw":return i.alaw(s);case"enca":return j(s,!1,function(o,u,l){o.channelCount=J(u,16),o.samplesize=J(u,18),o.sampleRate=P(u,24)/65536,u=u.subarray(28),o.sinf=i.sinf(i.findBox(u,["sinf"],l)[0]),o.esds=i.esds(i.findBox(u,["esds"],l)[0])});case"encv":return j(s,!1,function(o,u,l){o.width=J(u,24),o.height=J(u,26),o.horizresolution=P(u,28),o.vertresolution=P(u,32),u=u.subarray(78),o.sinf=i.sinf(i.findBox(u,["sinf"],l)[0]),o.avcC=i.avcC(i.findBox(u,["avcC"],l)[0]),o.hvcC=i.hvcC(i.findBox(u,["hvcC"],l)[0]),o.pasp=i.pasp(i.findBox(u,["pasp"],l)[0])})}}).filter(Boolean)})}},{key:"tenc",value:function(e){return j(e,!1,function(t,r){var n=6;t.default_IsEncrypted=r[n],n+=1,t.default_IV_size=r[n],n+=1,t.default_KID=[];for(var s=0;s<16;s++)t.default_KID.push(Ut(r[n])),n+=1})}},{key:"schi",value:function(e){return j(e,!1,function(t,r,n){t.tenc=i.tenc(i.findBox(r,["tenc"],n)[0])})}},{key:"sinf",value:function(e){return j(e,!1,function(t,r,n){t.schi=i.schi(i.findBox(r,["schi"],n)[0]),t.frma=i.frma(i.findBox(r,["frma"],n)[0])})}},{key:"frma",value:function(e){return j(e,!1,function(t,r){t.data_format="";for(var n=0;n<4;n++)t.data_format+=String.fromCharCode(r[n])})}},{key:"avc1",value:function(e){return j(e,!1,function(t,r,n){var s=kr(t,r),o=r.subarray(s);n+=s,t.avcC=i.avcC(i.findBox(o,["avcC"],n)[0]),t.pasp=i.pasp(i.findBox(o,["pasp"],n)[0])})}},{key:"avcC",value:function(e){return j(e,!1,function(t,r){t.configurationVersion=r[0],t.AVCProfileIndication=r[1],t.profileCompatibility=r[2],t.AVCLevelIndication=r[3],t.codec=_r([r[1],r[2],r[3]]),t.lengthSizeMinusOne=r[4]&3,t.spsLength=r[5]&31,t.sps=[];for(var n=6,s=0;s<t.spsLength;s++){var o=J(r,n);n+=2,t.sps.push(r.subarray(n,n+o)),n+=o}t.ppsLength=r[n],n+=1,t.pps=[];for(var u=0;u<t.ppsLength;u++){var l=J(r,n);n+=2,t.pps.push(r.subarray(n,n+=l)),n+=l}})}},{key:"hvc1",value:function(e){return j(e,!1,function(t,r,n){var s=kr(t,r),o=r.subarray(s);n+=s,t.hvcC=i.hvcC(i.findBox(o,["hvcC"],n)[0]),t.pasp=i.pasp(i.findBox(o,["pasp"],n)[0])})}},{key:"hvcC",value:function(e){return j(e,!1,function(t,r){t.data=e.data,t.codec="hev1.1.6.L93.B0",t.configurationVersion=r[0];var n=r[1];t.generalProfileSpace=n>>6,t.generalTierFlag=(n&32)>>5,t.generalProfileIdc=n&31,t.generalProfileCompatibility=P(r,2),t.generalConstraintIndicatorFlags=r.subarray(6,12),t.generalLevelIdc=r[12],t.avgFrameRate=J(r,19),t.numOfArrays=r[22],t.vps=[],t.sps=[],t.pps=[];for(var s=23,o=0,u=0,l=0,c=0;c<t.numOfArrays;c++){o=r[s]&63,u=J(r,s+1),s+=3;for(var f=[],v=0;v<u;v++)l=J(r,s),s+=2,f.push(r.subarray(s,s+l)),s+=l;if(o===32){var h;(h=t.vps).push.apply(h,f)}else if(o===33){var p;(p=t.sps).push.apply(p,f)}else if(o===34){var y;(y=t.pps).push.apply(y,f)}}})}},{key:"pasp",value:function(e){return j(e,!1,function(t,r){t.hSpacing=P(r),t.vSpacing=P(r,4)})}},{key:"mp4a",value:function(e){return j(e,!1,function(t,r,n){var s=Ar(t,r);t.esds=i.esds(i.findBox(r.subarray(s),["esds"],n+s)[0])})}},{key:"esds",value:function(e){return j(e,!0,function(t,r){t.codec="mp4a.";for(var n=0,s=0,o=0,u=0;r.length;){for(n=0,u=r[n],s=r[n+1],n+=2;s&128;)o=(s&127)<<7,s=r[n],n+=1;if(o+=s&127,u===3)r=r.subarray(n+3);else if(u===4)t.codec+=(r[n].toString(16)+".").padStart(3,"0"),r=r.subarray(n+13);else if(u===5){var l=t.config=r.subarray(n,n+o),c=(l[0]&248)>>3;c===31&&l.length>=2&&(c=32+((l[0]&7)<<3)+((l[1]&224)>>5)),t.objectType=c,t.codec+=c.toString(16),t.codec[t.codec.length-1]==="."&&(t.codec=t.codec.substring(0,t.codec.length-1));return}else{t.codec[t.codec.length-1]==="."&&(t.codec=t.codec.substring(0,t.codec.length-1));return}}})}},{key:"alaw",value:function(e){return j(e,!1,function(t,r){Ar(t,r)})}},{key:"stts",value:function(e){return j(e,!0,function(t,r){for(var n=P(r),s=[],o=4,u=0;u<n;u++)s.push({count:P(r,o),delta:P(r,o+4)}),o+=8;t.entryCount=n,t.entries=s})}},{key:"ctts",value:function(e){return j(e,!0,function(t,r){var n=P(r),s=[],o=4;if(t.version===1)for(var u=0;u<n;u++)s.push({count:P(r,o),offset:P(r,o+4)}),o+=8;else for(var l=0;l<n;l++)s.push({count:P(r,o),offset:-(~P(r,o+4)+1)}),o+=8;t.entryCount=n,t.entries=s})}},{key:"stsc",value:function(e){return j(e,!0,function(t,r){for(var n=P(r),s=[],o=4,u=0;u<n;u++)s.push({firstChunk:P(r,o),samplesPerChunk:P(r,o+4),sampleDescriptionIndex:P(r,o+8)}),o+=12;t.entryCount=n,t.entries=s})}},{key:"stsz",value:function(e){return j(e,!0,function(t,r){var n=P(r),s=P(r,4),o=[];if(!n)for(var u=8,l=0;l<s;l++)o.push(P(r,u)),u+=4;t.sampleSize=n,t.sampleCount=s,t.entrySizes=o})}},{key:"stco",value:function(e){return j(e,!0,function(t,r){for(var n=P(r),s=[],o=4,u=0;u<n;u++)s.push(P(r,o)),o+=4;t.entryCount=n,t.entries=s})}},{key:"co64",value:function(e){return j(e,!0,function(t,r){for(var n=P(r),s=[],o=4,u=0;u<n;u++)s.push(Ae(r,o)),o+=8;t.entryCount=n,t.entries=s})}},{key:"stss",value:function(e){return j(e,!0,function(t,r){for(var n=P(r),s=[],o=4,u=0;u<n;u++)s.push(P(r,o)),o+=4;t.entryCount=n,t.entries=s})}},{key:"moof",value:function(e){return j(e,!1,function(t,r,n){t.mfhd=i.mfhd(i.findBox(r,["mfhd"],n)[0]),t.traf=i.findBox(r,["traf"],n).map(function(s){return i.traf(s)})})}},{key:"mfhd",value:function(e){return j(e,!0,function(t,r){t.sequenceNumber=P(r)})}},{key:"traf",value:function(e){return j(e,!1,function(t,r,n){t.tfhd=i.tfhd(i.findBox(r,["tfhd"],n)[0]),t.tfdt=i.tfdt(i.findBox(r,["tfdt"],n)[0]),t.trun=i.trun(i.findBox(r,["trun"],n)[0])})}},{key:"trun",value:function(e){return j(e,!0,function(t,r){var n=t.version,s=t.flags,o=r.length,u=t.sampleCount=P(r),l=4;if(o>l&&s&1&&(t.dataOffset=-(~P(r,l)+1),l+=4),o>l&&s&4&&(t.firstSampleFlags=P(r,l),l+=4),t.samples=[],o>l)for(var c,f=0;f<u;f++)c={},s&256&&(c.duration=P(r,l),l+=4),s&512&&(c.size=P(r,l),l+=4),s&1024&&(c.flags=P(r,l),l+=4),s&2048&&(n?c.cts=-(~P(r,l+4)+1):c.cts=P(r,l),l+=4),t.samples.push(c)})}},{key:"tfdt",value:function(e){return j(e,!0,function(t,r){t.version===1?t.baseMediaDecodeTime=Ae(r):t.baseMediaDecodeTime=P(r)})}},{key:"probe",value:function(e){return!!i.findBox(e,["ftyp"])}},{key:"parseSampleFlags",value:function(e){return{isLeading:(e[0]&12)>>>2,dependsOn:e[0]&3,isDependedOn:(e[1]&192)>>>6,hasRedundancy:(e[1]&48)>>>4,paddingValue:(e[1]&14)>>>1,isNonSyncSample:e[1]&1,degradationPriority:e[2]<<8|e[3]}}},{key:"moovToTrack",value:function(e,t,r){var n,s,o=e.trak;if(!(!o||!o.length)){var u=o.find(function(gt){var Pe,Re;return((Pe=gt.mdia)===null||Pe===void 0||(Re=Pe.hdlr)===null||Re===void 0?void 0:Re.handlerType)==="vide"}),l=o.find(function(gt){var Pe,Re;return((Pe=gt.mdia)===null||Pe===void 0||(Re=Pe.hdlr)===null||Re===void 0?void 0:Re.handlerType)==="soun"});if(u&&t){var c,f,v,h,p,y,d,_=t,b=(c=u.tkhd)===null||c===void 0?void 0:c.trackId;b!=null&&(_.id=u.tkhd.trackId),_.tkhdDuration=u.tkhd.duration,_.mvhdDurtion=e.mvhd.duration,_.mvhdTimecale=e.mvhd.timescale,_.timescale=_.formatTimescale=u.mdia.mdhd.timescale,_.duration=u.mdia.mdhd.duration||_.mvhdDurtion/_.mvhdTimecale*_.timescale;var w=u.mdia.minf.stbl.stsd.entries[0];if(_.width=w.width,_.height=w.height,w.pasp&&(_.sarRatio=[w.pasp.hSpacing,w.pasp.vSpacing]),w.hvcC)_.codecType=Me.HEVC,_.codec=w.hvcC.codec,_.vps=w.hvcC.vps,_.sps=w.hvcC.sps,_.pps=w.hvcC.pps,_.hvcC=w.hvcC.data;else if(w.avcC)_.codec=w.avcC.codec,_.sps=w.avcC.sps,_.pps=w.avcC.pps;else throw new Error("unknown video stsd entry");if(_.present=!0,_.ext={},_.ext.stss=(f=u.mdia)===null||f===void 0||(v=f.minf)===null||v===void 0||(h=v.stbl)===null||h===void 0?void 0:h.stss,_.ext.ctts=(p=u.mdia)===null||p===void 0||(y=p.minf)===null||y===void 0||(d=y.stbl)===null||d===void 0?void 0:d.ctts,w&&w.type==="encv"){var D,T,F,B,N,G,M,q;_.isVideoEncryption=!0,w.default_KID=(D=w.sinf)===null||D===void 0||(T=D.schi)===null||T===void 0?void 0:T.tenc.default_KID,w.default_IsEncrypted=(F=w.sinf)===null||F===void 0||(B=F.schi)===null||B===void 0?void 0:B.tenc.default_IsEncrypted,w.default_IV_size=(N=w.sinf)===null||N===void 0||(G=N.schi)===null||G===void 0?void 0:G.tenc.default_IV_size,_.videoSenc=u.mdia.minf.stbl.senc&&u.mdia.minf.stbl.senc.samples,w.data_format=(M=w.sinf)===null||M===void 0||(q=M.frma)===null||q===void 0?void 0:q.data_format,_.useEME=e.useEME,_.kidValue=e.kidValue,_.pssh=e.pssh,_.encv=w}}if(l&&r){var m,g,S,O,k,I,V,z,K,R=r,te=(m=l.tkhd)===null||m===void 0?void 0:m.trackId;te!=null&&(R.id=l.tkhd.trackId),R.tkhdDuration=l.tkhd.duration,R.mvhdDurtion=e.mvhd.duration,R.mvhdTimecale=e.mvhd.timescale,R.timescale=R.formatTimescale=l.mdia.mdhd.timescale,R.duration=l.mdia.mdhd.duration||R.mvhdDurtion/R.mvhdTimecale*R.timescale;var U=l.mdia.minf.stbl.stsd.entries[0];switch(R.sampleSize=U.sampleSize,R.sampleRate=U.sampleRate,R.channelCount=U.channelCount,R.present=!0,U.type){case"alaw":R.codecType=R.codec=st.G711PCMA,R.sampleRate=8e3;break;case"ulaw":R.codecType=R.codec=st.G711PCMU,R.sampleRate=8e3;break;default:R.sampleDuration=ke.getFrameDuration(R.sampleRate,R.timescale),R.sampleRateIndex=ke.getRateIndexByRate(R.sampleRate),R.objectType=((n=U.esds)===null||n===void 0?void 0:n.objectType)||2,U.esds&&(R.config=Array.from(U.esds.config)),R.codec=((s=U.esds)===null||s===void 0?void 0:s.codec)||"mp4a.40.2";break}if(R.sampleDuration=ke.getFrameDuration(R.sampleRate,R.timescale),R.objectType=((g=U.esds)===null||g===void 0?void 0:g.objectType)||2,U.esds&&(U.esds.config?R.config=Array.from(U.esds.config):console.warn("esds config is null")),R.codec=((S=U.esds)===null||S===void 0?void 0:S.codec)||"mp4a.40.2",R.sampleRateIndex=ke.getRateIndexByRate(R.sampleRate),R.ext={},R.ext.stss=(O=l.mdia)===null||O===void 0||(k=O.minf)===null||k===void 0||(I=k.stbl)===null||I===void 0?void 0:I.stss,R.ext.ctts=(V=l.mdia)===null||V===void 0||(z=V.minf)===null||z===void 0||(K=z.stbl)===null||K===void 0?void 0:K.ctts,R.present=!0,U&&U.type==="enca"){var Oe,me,Le,Ue,Xe,Z,dt,vt;R.isAudioEncryption=!0,U.data_format=(Oe=U.sinf)===null||Oe===void 0||(me=Oe.frma)===null||me===void 0?void 0:me.data_format,U.default_KID=(Le=U.sinf)===null||Le===void 0||(Ue=Le.schi)===null||Ue===void 0?void 0:Ue.tenc.default_KID,U.default_IsEncrypted=(Xe=U.sinf)===null||Xe===void 0||(Z=Xe.schi)===null||Z===void 0?void 0:Z.tenc.default_IsEncrypted,U.default_IV_size=(dt=U.sinf)===null||dt===void 0||(vt=dt.schi)===null||vt===void 0?void 0:vt.tenc.default_IV_size,R.audioSenc=l.mdia.minf.stbl.senc&&l.mdia.minf.stbl.senc.samples,R.useEME=e.useEME,R.kidValue=e.kidValue,R.enca=U}}if(r&&(r.isVideoEncryption=t?t.isVideoEncryption:!1),t&&(t.isAudioEncryption=r?r.isAudioEncryption:!1),t!=null&&t.encv||r!=null&&r.enca){var pt,mt,Vt=t==null||(pt=t.encv)===null||pt===void 0?void 0:pt.default_KID,Gt=r==null||(mt=r.enca)===null||mt===void 0?void 0:mt.default_KID,jt=Vt||Gt?(Vt||Gt).join(""):null;t&&(t.kid=jt),r&&(r.kid=jt)}return t&&(t.flags=3841),r&&(r.flags=1793),{videoTrack:t,audioTrack:r}}}},{key:"evaluateDefaultDuration",value:function(e,t,r){var n,s=t==null||(n=t.samples)===null||n===void 0?void 0:n.length;if(!s)return 1024;var o=1024*s/t.timescale;return o*e.timescale/r}},{key:"moofToSamples",value:function(e,t,r){var n={};return e.mfhd&&(t&&(t.sequenceNumber=e.mfhd.sequenceNumber),r&&(r.sequenceNumber=e.mfhd.sequenceNumber)),e.traf.forEach(function(s){var o=s.tfhd,u=s.tfdt,l=s.trun;if(!(!o||!l)){u&&(t&&t.id===o.trackId&&(t.baseMediaDecodeTime=u.baseMediaDecodeTime),r&&r.id===o.trackId&&(r.baseMediaDecodeTime=u.baseMediaDecodeTime));var c=o.defaultSampleSize||0,f=o.defaultSampleDuration||i.evaluateDefaultDuration(t,r,l.samples.length||l.sampleCount),v=l.dataOffset||0,h=0,p=-1;if(!l.samples.length&&l.sampleCount){n[o.trackId]=[];for(var y=0;y<l.sampleCount;y++)n[o.trackId].push({offset:v,dts:h,duration:f,size:c}),h+=f,v+=c}else n[o.trackId]=l.samples.map(function(d,_){return d={offset:v,dts:h,pts:h+(d.cts||0),duration:d.duration||f,size:d.size||c,gopId:p,keyframe:_===0||d.flags!==null&&d.flags!==void 0&&(d.flags&65536)>>>0!==65536},d.keyframe&&(p++,d.gopId=p),h+=d.duration,v+=d.size,d})}}),n}},{key:"moovToSamples",value:function(e){var t=e.trak;if(!(!t||!t.length)){var r=t.find(function(M){var q,m;return((q=M.mdia)===null||q===void 0||(m=q.hdlr)===null||m===void 0?void 0:m.handlerType)==="vide"}),n=t.find(function(M){var q,m;return((q=M.mdia)===null||q===void 0||(m=q.hdlr)===null||m===void 0?void 0:m.handlerType)==="soun"});if(!(!r&&!n)){var s,o;if(r){var u,l,c=(u=r.mdia)===null||u===void 0||(l=u.minf)===null||l===void 0?void 0:l.stbl;if(!c)return;var f=c.stts,v=c.stsc,h=c.stsz,p=c.stco,y=c.stss,d=c.ctts;if(!f||!v||!h||!p||!y)return;s=Tr(f,v,h,p,d,y)}if(n){var _,b,w,D=(_=n.mdia)===null||_===void 0||(b=_.minf)===null||b===void 0?void 0:b.stbl;if(!D)return;var T=(w=n.mdia.mdhd)===null||w===void 0?void 0:w.timescale,F=D.stts,B=D.stsc,N=D.stsz,G=D.stco;if(!T||!F||!B||!N||!G)return;o=Tr(F,B,N,G)}return{videoSamples:s,audioSamples:o}}}}}]),i}();function Tr(i,a,e,t,r,n){var s=[],o=r?.entries,u=a.entries,l=t.entries,c=e.entrySizes,f=n?.entries,v;f&&(v={},f.forEach(function(B){v[B-1]=!0}));var h;o&&(h=[],o.forEach(function(B){for(var N=B.count,G=B.offset,M=0;M<N;M++)h.push(G)}));var p,y=-1,d=0,_=0,b=0,w=0,D=0,T=u[0].samplesPerChunk,F=u[1]?u[1].firstChunk-1:1/0;return i.entries.forEach(function(B){for(var N=B.count,G=B.delta,M=0;M<N;M++)p={dts:d,duration:G,size:c[_]||e.sampleSize,offset:l[b]+D,index:_},f&&(p.keyframe=v[_],p.keyframe&&y++,p.gopId=y),h&&_<h.length&&(p.pts=p.dts+h[_]),s.push(p),d+=G,_++,_<T?D+=p.size:(b++,D=0,b>=F&&(w++,F=u[w+1]?u[w+1].firstChunk-1:1/0),T+=u[w].samplesPerChunk)}),s}function kr(i,a){return i.dataReferenceIndex=J(a,6),i.width=J(a,24),i.height=J(a,26),i.horizresolution=P(a,28),i.vertresolution=P(a,32),i.frameCount=J(a,40),i.depth=J(a,74),78}function Ar(i,a){return i.dataReferenceIndex=J(a,6),i.channelCount=J(a,16),i.sampleSize=J(a,18),i.sampleRate=P(a,24)/65536,28}function j(i,a,e){if(i){if(i.size!==i.data.length)throw new Error("box ".concat(i.type," size !== data.length"));var t={start:i.start,size:i.size,headerSize:i.headerSize,type:i.type};return a&&(t.version=i.data[i.headerSize],t.flags=Vn(i.data,i.headerSize+1),t.headerSize+=4),e(t,i.data.subarray(t.headerSize),t.start+t.headerSize),t}}var $n=function(a,e,t){for(var r=String(t),n=e>>0,s=Math.ceil(n/r.length),o=[],u=String(a);s--;)o.push(r);return o.join("").substring(0,n-u.length)+u},Ut=function(){for(var a=[],e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.forEach(function(n){a.push($n(Number(n).toString(16),2,0))}),a[0]},Wn=function(){function i(a,e,t){ne(this,i),this.videoTrack=a||new pr,this.audioTrack=e||new mr,this.metadataTrack=t||new yr}return ie(i,[{key:"demux",value:function(e,t){var r=this.videoTrack,n=this.audioTrack,s=r.exist(),o=n.exist();if(r.samples=[],n.samples=[],t){if(!o){var u=ae.findBox(t,["moov"])[0];if(!u)throw new Error("cannot found moov box");ae.moovToTrack(ae.moov(u),null,n)}var l=ae.findBox(t,["moof"])[0];if(l){var c=ae.moofToSamples(ae.moof(l),null,n)[n.id],f=n.baseMediaDecodeTime;if(c){var v=l.start;c.map(function(D){D.offset+=v;var T=t.subarray(D.offset,D.offset+D.size);n.samples.push(new at(D.dts+f,T,D.duration))})}}}if(e){if(!s&&!o){var h=ae.findBox(e,["moov"])[0];if(!h)throw new Error("cannot found moov box");ae.moovToTrack(ae.moov(h),r,n)}var p=ae.findBox(e,["moof"])[0];if(p){var y=ae.moofToSamples(ae.moof(p),r,n),d=r.baseMediaDecodeTime,_=n.baseMediaDecodeTime,b=p.start,w;Object.keys(y).forEach(function(D){r.id==D?y[D].map(function(T){T.offset+=b;var F=new gr((T.pts||T.dts)+d,T.dts+d);F.duration=T.duration,F.gopId=T.gopId,T.keyframe&&F.setToKeyframe();var B=e.subarray(T.offset,T.offset+T.size);F.data=B;for(var N=0,G=B.length-1;N<G;)w=P(B,N),N+=4,F.units.push(B.subarray(N,N+w)),N+=w;r.samples.push(F)}):n.id==D&&y[D].map(function(T){T.offset+=b;var F=e.subarray(T.offset,T.offset+T.size);n.samples.push(new at(T.dts+_,F,T.duration))})})}}return{videoTrack:r,audioTrack:n,metadataTrack:this.metadataTrack}}},{key:"reset",value:function(){this.videoTrack.reset(),this.audioTrack.reset(),this.metadataTrack.reset()}}],[{key:"probe",value:function(e){return ae.probe(e)}}]),i}();function Kn(i){for(var a=0,e=arguments.length,t=new Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];t.forEach(function(o){a+=o.length});var n=new i(a),s=0;return t.forEach(function(o){n.set(o,s),s+=o.length}),n}var le=function(){function i(){ne(this,i),this.buffer=new Uint8Array(0)}return ie(i,[{key:"write",value:function(){for(var e=this,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];r.forEach(function(s){s?e.buffer=Kn(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}(),Dr=Math.pow(2,32)-1,H=function(){function i(){ne(this,i)}return ie(i,null,[{key:"box",value:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];r=r.filter(Boolean);var s=8+r.reduce(function(l,c){return l+c.byteLength},0),o=new Uint8Array(s);o[0]=s>>24&255,o[1]=s>>16&255,o[2]=s>>8&255,o[3]=s&255,o.set(e,4);var u=8;return r.forEach(function(l){o.set(l,u),u+=l.byteLength}),o}},{key:"ftyp",value:function(e){var t=e.find(function(r){return r.type===Ge.VIDEO&&r.codecType===Me.HEVC});return t?i.FTYPHEV1:i.FTYPAVC1}},{key:"initSegment",value:function(e){var t=i.ftyp(e),r=ye(t,i.moov(e));return r}},{key:"pssh",value:function(e){var t=new Uint8Array([1,0,0,0].concat([16,119,239,236,192,178,77,2,172,227,60,30,82,226,251,75],[0,0,0,1],Sr(e.kid),[0,0,0,0]));return i.box(i.types.pssh,t)}},{key:"moov",value:function(e){if(e[0].useEME&&(e[0].encv||e[0].enca)){e[0].pssh||(e[0].pssh={kid:e[0].kid});var t=this.pssh(e[0].pssh);return 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(pe(e.map(function(r){return i.trak(r)})),[t]))}else return i.box.apply(i,[i.types.moov,i.mvhd(e[0].mvhdDurtion||e[0].duration,e[0].mvhdTimecale||e[0].timescale)].concat(pe(e.map(function(r){return i.trak(r)})),[i.mvex(e)]))}},{key:"mvhd",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:9e4,r=i.box(i.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,t>>24&255,t>>16&255,t>>8&255,t&255,e>>24&255,e>>16&255,e>>8&255,e&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]));return r}},{key:"trak",value:function(e){var t=i.box(i.types.trak,i.tkhd(e.id,e.tkhdDuration||0,e.width,e.height),i.mdia(e));return t}},{key:"tkhd",value:function(e,t){var r=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,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>8&255,r&255,0,0,n>>8&255,n&255,0,0]));return s}},{key:"mdia",value:function(e){var t=i.box(i.types.mdia,i.mdhd(e.duration,e.timescale),i.hdlr(e.type),i.minf(e));return t}},{key:"mdhd",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:9e4,r=i.box(i.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,t>>24&255,t>>16&255,t>>8&255,t&255,e>>24&255,e>>16&255,e>>8&255,e&255,85,196,0,0]));return r}},{key:"hdlr",value:function(e){var t=i.box(i.types.hdlr,i.HDLR_TYPES[e]);return t}},{key:"minf",value:function(e){var t=i.box(i.types.minf,e.type===Ge.VIDEO?i.VMHD:i.SMHD,i.DINF,i.stbl(e));return t}},{key:"stbl",value:function(e){var t=[];e&&e.ext&&e.ext.stss&&t.push(i.stss(e.ext.stss.entries));var r=i.box(i.types.stbl,i.stsd(e),i.STTS,t[0],i.STSC,i.STSZ,i.STCO);return r}},{key:"stsd",value:function(e){var t;e.type==="audio"?e.useEME&&e.enca?t=i.enca(e):t=i.mp4a(e):e.useEME&&e.encv?t=i.encv(e):t=i.avc1hev1(e);var r=i.box(i.types.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),t);return r}},{key:"enca",value:function(e){var t=e.enca.channelCount,r=e.enca.sampleRate,n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,r>>8&255,r&255,0,0]),s=i.esds(e.config),o=i.sinf(e.enca);return i.box(i.types.enca,n,s,o)}},{key:"encv",value:function(e){var t,r,n=e.sps.length>0?e.sps[0]:[],s=e.pps.length>0?e.pps[0]:[],o=e.width,u=e.height,l=e.sarRatio[0],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,o>>8&255,o&255,u>>8&255,u&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),v=new Uint8Array((t=(r=[1,n[1],n[2],n[3],255,225,n.length>>>8&255,n.length&255]).concat.apply(r,pe(n)).concat([1,s.length>>>8&255,s.length&255])).concat.apply(t,pe(s))),h=new Uint8Array([0,0,88,57,0,15,200,192,0,4,86,72]),p=i.sinf(e.encv),y=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,h),p,i.box(i.types.pasp,y))}},{key:"schi",value:function(e){var t=new Uint8Array([]),r=i.tenc(e);return i.box(i.types.schi,t,r)}},{key:"tenc",value:function(e){var t=new Uint8Array([0,0,0,0,0,0,e.default_IsEncrypted&255,e.default_IV_size&255].concat(Sr(e.default_KID)));return i.box(i.types.tenc,t)}},{key:"sinf",value:function(e){var t=new Uint8Array([]),r=new Uint8Array([e.data_format.charCodeAt(0),e.data_format.charCodeAt(1),e.data_format.charCodeAt(2),e.data_format.charCodeAt(3)]),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,t,i.box(i.types.frma,r),i.box(i.types.schm,n),s)}},{key:"avc1hev1",value:function(e){var t=e.codecType===Me.HEVC,r=t?i.types.hvc1:i.types.avc1,n=t?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 t?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,[r].concat(s))}},{key:"avcC",value:function(e){var t,r,n=[],s=[],o;return e.sps.forEach(function(u){o=u.byteLength,n.push(o>>>8&255),n.push(o&255),n.push.apply(n,pe(u))}),e.pps.forEach(function(u){o=u.byteLength,s.push(o>>>8&255),s.push(o&255),s.push.apply(s,pe(u))}),i.box(i.types.avcC,new Uint8Array((t=(r=[1,n[3],n[4],n[5],255,224|e.sps.length]).concat.apply(r,n).concat([e.pps.length])).concat.apply(t,s)))}},{key:"hvcC",value:function(e){var t=e.hvcC;if(t instanceof ArrayBuffer||t instanceof Uint8Array)return t;var r=e.vps,n=e.sps,s=e.pps,o;if(t){var u=t.generalProfileCompatibilityFlags,l=t.generalConstraintIndicatorFlags,c=(r.length&&1)+(n.length&&1)+(s.length&&1);o=[1,t.generalProfileSpace<<6|t.generalTierFlag<<5|t.generalProfileIdc,u>>>24,u>>>16,u>>>8,u,l[0],l[1],l[2],l[3],l[4],l[5],t.generalLevelIdc,240,0,252,t.chromaFormatIdc|252,t.bitDepthLumaMinus8|248,t.bitDepthChromaMinus8|248,0,0,t.numTemporalLayers<<3|t.temporalIdNested<<2|3,c];var f=function(h){var p;o.push(h.length>>8,h.length),(p=o).push.apply(p,pe(h))};r.length&&(o.push(160,0,r.length),r.forEach(f)),n.length&&(o.push(161,0,n.length),n.forEach(f)),s.length&&(o.push(162,0,s.length),s.forEach(f))}else o=[1,1,96,0,0,0,144,0,0,0,0,0,93,240,0,252,253,248,248,0,0,15,3,160,0,1,0,24,64,1,12,1,255,255,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,153,152,9,161,0,1,0,45,66,1,1,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,160,2,128,128,45,22,89,153,164,147,43,154,128,128,128,130,0,0,3,0,2,0,0,3,0,50,16,162,0,1,0,7,68,1,193,114,180,98,64];return i.box(i.types.hvcC,new Uint8Array(o))}},{key:"pasp",value:function(e){var t=Dn(e,2),r=t[0],n=t[1];return i.box(i.types.pasp,new Uint8Array([r>>24,r>>16&255,r>>8&255,r&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 t=e.length,r=i.box(i.types.esds,new Uint8Array([0,0,0,0,3,23+t,0,0,0,4,15+t,64,21,0,6,0,0,0,218,192,0,0,218,192,5].concat([t]).concat(e).concat([6,1,2])));return r}},{key:"mvex",value:function(e){var t=i.box.apply(i,[i.types.mvex].concat(pe(e.map(function(r){return i.trex(r.id)}))));return t}},{key:"trex",value:function(e){var t=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 t}},{key:"trex1",value:function(e){var t=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 t}},{key:"trex2",value:function(e){var t=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 t}},{key:"moof",value:function(e){var t=i.box.apply(i,[i.types.moof,i.mfhd(e[0].samples?e[0].samples[0].gopId:0)].concat(pe(e.map(function(r){return i.traf(r)}))));return t}},{key:"mfhd",value:function(e){var t=i.box(i.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]));return t}},{key:"traf",value:function(e){var t=i.tfhd(e.id),r=i.tfdt(e,e.baseMediaDecodeTime),n=0,s;if(e.isVideo&&e.videoSenc&&(s=e.videoSenc,s.forEach(function(g){n=n+8,g.subsamples&&g.subsamples.length&&(n=n+2,n=n+g.subsamples.length*6)})),e.videoSencLength=n,!e.useEME||!e.isVideoEncryption&&!e.isAudioEncryption){var o=i.sdtp(e),u=76;return i.box(i.types.traf,t,r,o,i.trun(e.samples,o.byteLength+u))}else if(e.isVideoEncryption)if(e.isVideo){var l=i.saiz(e),c=i.saio(e),f=i.trun1(e),v=i.senc(e),h=i.box(i.types.traf,t,r,l,c,f,v);return h}else if(e.isAudioEncryption){var d=i.sbgp(),_=i.saiz(e),b=i.saio(e),w=i.senc(e),D=i.trun1(e),T=i.box(i.types.traf,t,r,d,_,b,w,D);return T}else{var p=i.sbgp(),y=i.trun1(e);return i.box(i.types.traf,t,r,p,y)}else if(e.isVideo){var F=i.trun1(e);return i.box(i.types.traf,t,r,F)}else{var B=i.sbgp(),N=i.saiz(e),G=i.saio(e),M=i.senc(e),q=i.trun1(e),m=i.box(i.types.traf,t,r,B,N,G,M,q);return m}}},{key:"sdtp",value:function(e){var t=new le;return e.samples.forEach(function(r){t.write(new Uint8Array(e.isVideo?[r.keyframe?32:16]:[16]))}),i.box(i.types.sdtp,this.extension(0,0),t.buffer)}},{key:"trun1",value:function(e){var t=new le,r=le.writeUint32(e.samples.length),n=null;if(e.isVideo){var s=e.videoSencLength;n=le.writeUint32(e.samples.length*16+s+149),!e.isVideoEncryption&&e.isAudioEncryption&&(n=le.writeUint32(e.samples.length*16+92))}else{var o=e.samples.length*12+124;e.isAudioEncryption&&(o=e.samples.length*12+8*e.audioSenc.length+177),n=le.writeUint32(o)}return e.samples.forEach(function(u){t.write(le.writeUint32(u.duration)),t.write(le.writeUint32(u.size)),t.write(le.writeUint32(u.keyframe?33554432:65536)),e.isVideo&&t.write(le.writeUint32(u.cts?u.cts:0))}),i.box(i.types.trun,this.extension(0,e.flags),r,n,t.buffer)}},{key:"senc",value:function(e){var t=new le,r=e.samples.length,n=e.isVideo?16:8,s=e.isVideo?2:0,o=[],u=0;return e.isVideo?(o=e.videoSenc,u=e.videoSencLength):o=e.audioSenc,u=u||n*r,t.write(le.writeUint32(16+u),i.types.senc,this.extension(0,s)),t.write(le.writeUint32(r)),o.forEach(function(l){for(var c=0;c<l.InitializationVector.length;c++)t.write(new Uint8Array([l.InitializationVector[c]]));l.subsamples&&l.subsamples.length&&(t.write(le.writeUint16(l.subsamples.length)),l.subsamples.forEach(function(f){t.write(le.writeUint16(f.BytesOfClearData)),t.write(le.writeUint32(f.BytesOfProtectedData))}))}),t.buffer}},{key:"saio",value:function(e){var t=e.samples.length*12+141;!e.isVideo&&e.isAudioEncryption&&(t=149);var r=new Uint8Array([1,0,0,0,0,0,0,1,0,0,0,0,t>>24&255,t>>16&255,t>>8&255,t&255]);return i.box(i.types.saio,r)}},{key:"saiz",value:function(e){var t=e.samples.length,r=new Uint8Array([0,0,0,0,16,t>>24&255,t>>16&255,t>>8&255,t&255]);return i.box(i.types.saiz,r)}},{key:"sbgp",value:function(){var e=new Uint8Array([114,111,108,108,0,0,0,1,0,0,1,25,0,0,0,1]);return i.box(i.types.sbgp,this.extension(0,0),e)}},{key:"extension",value:function(e,t){return new Uint8Array([e,t>>16&255,t>>8&255,t&255])}},{key:"tfhd",value:function(e){return 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,t){var r=Math.floor(t/(Dr+1)),n=Math.floor(t%(Dr+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,r>>24,r>>16&255,r>>8&255,r&255,n>>24,n>>16&255,n>>8&255,n&255]))}},{key:"trun",value:function(e,t){var r=e.length,n=12+16*r;t+=8+n;var s=new Uint8Array(n);s.set([0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,r&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0);for(var o=0;o<r;o++){var u=e[o],l=u.duration,c=u.size,f=u.flag,v=f===void 0?{}:f,h=u.cts,p=h===void 0?0:h;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,p>>>24&255,p>>>16&255,p>>>8&255,p&255],12+16*o)}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(pe(e.map(function(t){return i.trackMP4(t)}))))}},{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===Ge.VIDEO?i.VMHD:i.SMHD,i.DINF,i.stblMP4(e))}},{key:"stblMP4",value:function(e){var t=e.ext,r=[i.stsd(e),i.stts(t.stts),i.stsc(t.stsc),i.stsz(t.stsz),i.stco(t.stco)];return t.stss.length&&r.push(i.stss(t.stss)),t.ctts.length&&r.push(i.ctts(t.ctts)),i.box.apply(i,[i.types.stbl].concat(r))}},{key:"stts",value:function(e){var t=e.length,r=new Uint8Array(8*t),n=0;return e.forEach(function(s){var o=s.value,u=s.count;r.set([u>>24,u>>16&255,u>>8&255,u&255,o>>24,o>>16&255,o>>8&255,o&255],n),n+=8}),i.box(i.types.stts,ye(new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]),r))}},{key:"stsc",value:function(e){var t=e.length,r=new Uint8Array(12*t),n=0;return e.forEach(function(s){var o=s.firstChunk,u=s.samplesPerChunk,l=s.sampleDescIndex;r.set([o>>24,o>>16&255,o>>8&255,o&255,u>>24,u>>16&255,u>>8&255,u&255,l>>24,l>>16&255,l>>8&255,l&255],n),n+=12}),i.box(i.types.stsc,ye(new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]),r))}},{key:"stsz",value:function(e){var t=e.length,r=new Uint8Array(4*t),n=0;return e.forEach(function(s){r.set([s>>24,s>>16&255,s>>8&255,s&255],n),n+=4}),i.box(i.types.stsz,ye(new Uint8Array([0,0,0,0,0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]),r))}},{key:"stco",value:function(e){var t=e.length,r=new Uint8Array(4*t),n=0;return e.forEach(function(s){r.set([s>>24,s>>16&255,s>>8&255,s&255],n),n+=4}),i.box(i.types.stco,ye(new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]),r))}},{key:"stss",value:function(e){var t=e.length,r=new Uint8Array(4*t),n=0;return e.forEach(function(s){r.set([s>>24,s>>16&255,s>>8&255,s&255],n),n+=4}),i.box(i.types.stss,ye(new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]),r))}},{key:"ctts",value:function(e){var t=e.length,r=new Uint8Array(8*t),n=0;return e.forEach(function(s){var o=s.value,u=s.count;r.set([u>>24,u>>16&255,u>>8&255,u&255,o>>24,o>>16&255,o>>8&255,o&255],n),n+=8}),i.box(i.types.ctts,ye(new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]),r))}},{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 t=e.timescale,r=e.samples[0].duration,n=r*e.samples.length,s=e.samples[0].sampleOffset*r,o=8;e.samples.forEach(function(v){o+=v.size});var u=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,u=o+141+e.samples.length*16+l,e.useEME&&e.isAudioEncryption&&!e.isVideoEncryption&&(u=o+e.samples.length*16+84)}else u=o+116+e.samples.length*12,e.useEME&&e.isAudioEncryption&&(u=o+169+e.samples.length*12+8*e.audioSenc.length);var f=new Uint8Array([0,0,0,0,0,0,0,e.id&255,t>>24&255,t>>16&255,t>>8&255,t&255,s>>24&255,s>>16&255,s>>8&255,s&255,0,0,0,0,0,0,0,1,0,u>>16&255,u>>8&255,u&255,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 t=i.box(i.types.mdat,e);return t}}]),i}();L(H,"types",["avc1","avcC","hvc1","hvcC","dinf","dref","esds","ftyp","hdlr","mdat","mdhd","mdia","mfhd","minf","moof","moov","mp4a","mvex","mvhd","pasp","stbl","stco","stsc","stsd","stsz","stts","tfdt","tfhd","traf","trak","trex","tkhd","vmhd","smhd","ctts","stss","styp","pssh","sidx","sbgp","saiz","saio","senc","trun","encv","enca","sinf","btrt","frma","tenc","schm","schi","mehd","fiel","sdtp"].reduce(function(i,a){return i[a]=[a.charCodeAt(0),a.charCodeAt(1),a.charCodeAt(2),a.charCodeAt(3)],i},Object.create(null))),L(H,"HDLR_TYPES",{video:new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),audio:new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0])}),L(H,"FTYPAVC1",H.box(H.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]))),L(H,"FTYPHEV1",H.box(H.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49]))),L(H,"DINF",H.box(H.types.dinf,H.box(H.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])))),L(H,"VMHD",H.box(H.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]))),L(H,"SMHD",H.box(H.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0]))),L(H,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0])),L(H,"STTS",H.box(H.types.stts,H.StblTable)),L(H,"STSC",H.box(H.types.stsc,H.StblTable)),L(H,"STSZ",H.box(H.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]))),L(H,"STCO",H.box(H.types.stco,H.StblTable));var Or=function(){function i(a,e){ne(this,i),this.name=a||"",this._prefix="[".concat(this.name,"]"),i.disabled=e}return ie(i,[{key:"debug",value:function(){var e;if(!i.disabled){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];(e=console).debug.apply(e,[this._prefix].concat(r))}}},{key:"log",value:function(){var e;if(!i.disabled){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];(e=console).log.apply(e,[this._prefix].concat(r))}}},{key:"warn",value:function(){var e;if(!i.disabled){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];(e=console).warn.apply(e,[this._prefix].concat(r))}}},{key:"error",value:function(){var e;if(!i.disabled){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];(e=console).error.apply(e,[this._prefix].concat(r))}}},{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}();L(Or,"disabled",!0);var Yn=function(){function i(a,e,t){ne(this,i),this.videoTrack=a,this.audioTrack=e;var r=/Chrome\/([^.]+)/.exec(navigator.userAgent);this.forceFirstIDR=r&&Number(r[1])<50,this.log=new Or("FMP4Remuxer",t&&t.openLog?!t.openLog:!0)}return ie(i,[{key:"remux",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=this.videoTrack,n=this.audioTrack,s=r.exist(),o=n.exist(),u,l,c,f=[];e&&(t&&t.initMerge?(s&&f.push(this.videoTrack),o&&f.push(this.audioTrack),c=H.initSegment(f)):(s&&(u=H.initSegment([this.videoTrack])),o&&(l=H.initSegment([this.audioTrack]))));var v,h;return s&&r.hasSample()&&(v=this._remuxVideo()),o&&n.hasSample()&&(h=this._remuxAudio()),r.samples=[],n.samples=[],{initSegment:c,videoInitSegment:u,audioInitSegment:l,videoSegment:v,audioSegment:h}}},{key:"_remuxVideo",value:function(){var e=this.videoTrack;this.forceFirstIDR&&(e.samples[0].flag={dependsOn:2,isNonSyncSample:0});var t=e.samples,r=0;t.forEach(function(p){r+=p.units.reduce(function(y,d){return y+d.byteLength},0),r+=p.units.length*4});for(var n=new Uint8Array(r),s=new DataView(n.buffer),o=function(y,d){d=t[u];var _=0;d.units.forEach(function(b){s.setUint32(y,b.byteLength),y+=4,n.set(b,y),y+=b.byteLength,_+=4+b.byteLength}),d.size=_,c=y,f=d},u=0,l=t.length,c=0,f;u<l;u++)o(c,f);var v=H.mdat(n),h=H.moof([e]);return ye(h,v)}},{key:"_remuxAudio",value:function(){var e=this.audioTrack,t=new Uint8Array(e.samples.reduce(function(s,o){return s+o.size},0));e.samples.reduce(function(s,o){return t.set(o.data,s),s+o.size},0);var r=H.mdat(t),n=H.moof([e]);return ye(n,r)}},{key:"reset",value:function(){this.videoTrack.reset(),this.audioTrack.reset()}}]),i}(),qn=function(){function i(){oe(this,i);var a=window.crypto||window.msCrypto;this.subtle=a&&(a.subtle||a.webkitSubtle),this.externalDecryptor=null}return ue(i,[{key:"destroy",value:function(){var e;(e=this.externalDecryptor)!==null&&e!==void 0&&e.destroy&&this.externalDecryptor.destroy()}},{key:"decrypt",value:function(e,t){if(!(!e&&!t)){var r=[];return e&&(r[0]=this._decryptSegment(e)),t&&(r[1]=this._decryptSegment(t)),Promise.all(r)}}},{key:"_decryptSegment",value:function(){var a=Y(C().mark(function t(r){var n;return C().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(n=r.data,!r.key){o.next=5;break}return o.next=4,this._decryptData(r.data,r.key,r.keyIv);case 4:n=o.sent;case 5:if(r.map){o.next=7;break}return o.abrupt("return",n);case 7:return o.abrupt("return",nt(r.map,n));case 8:case"end":return o.stop()}},t,this)}));function e(t){return a.apply(this,arguments)}return e}()},{key:"_decryptData",value:function(){var a=Y(C().mark(function t(r,n,s){var o;return C().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(!this.externalDecryptor){l.next=6;break}return l.next=3,this.externalDecryptor.decrypt(r,n,s);case 3:return l.abrupt("return",l.sent);case 6:if(this.subtle){l.next=8;break}throw new Error("crypto is not defined");case 8:return l.next=10,this.subtle.importKey("raw",n,{name:"AES-CBC"},!1,["encrypt","decrypt"]);case 10:return o=l.sent,l.t0=Uint8Array,l.next=14,this.subtle.decrypt({name:"AES-CBC",iv:s},o,r);case 14:return l.t1=l.sent,l.abrupt("return",new l.t0(l.t1));case 16:case"end":return l.stop()}},t,this)}));function e(t,r,n){return a.apply(this,arguments)}return e}()}]),i}(),Q=ee(ee({},X),{},{STREAM_PARSED:"core.streamparsed",NO_AUDIO_TRACK:"core.noaudiotrack",SUBTITLE_SEGMENTS:"core.subtitlesegments",SUBTITLE_PLAYLIST:"core.subtitleplaylist",SEI_PAYLOAD_TIME:"core.seipayloadtime",APPEND_COST:"core.appendcost"}),lt=new be("Transmuxer"),Lr=function(){function i(a,e,t){oe(this,i),E(this,"_initSegmentId",""),this.hls=a,this._demuxer=e?new Wn:new wr,this._isMP4=e,t&&(this._remuxer=new Yn(this._demuxer.videoTrack,this._demuxer.audioTrack))}return ue(i,[{key:"transmux",value:function(e,t,r,n,s,o){var u=this._demuxer;try{this._isMP4?u.demux(e,t):u.demuxAndFix(nt(e,t),r,n,s)}catch(D){throw new re($.DEMUX,$.SUB_TYPES.HLS,D)}var l=u.videoTrack,c=u.audioTrack,f=u.metadataTrack,v="".concat(l.codec,"/").concat(l.width,"/").concat(l.height,"/").concat(c.codec,"/").concat(c.config);if(v!==this._initSegmentId&&(this._initSegmentId=v,o=!0),this._fireEvents(l,c,f,r||o),this.hls.emit(Q.DEMUXED_TRACK,{videoTrack:l,audioTrack:c}),this._remuxer)try{var h=this._remuxer.remux(o),p=h.videoInitSegment,y=h.videoSegment,d=h.audioInitSegment,_=h.audioSegment,b=nt(p,y),w=nt(d,_);return[b?{codec:l.codec,data:b}:void 0,w?{codec:c.codec,data:w}:void 0]}catch(D){throw new re($.REMUX,$.SUB_TYPES.FMP4,D)}else return[l,c]}},{key:"_fireEvents",value:function(e,t,r,n){var s=this;lt.debug(e.samples,t.samples),n&&(e.exist()&&this.hls.emit(Q.METADATA_PARSED,{type:"video",track:e,meta:{codec:e.codec,timescale:e.timescale,width:e.width,height:e.height,sarRatio:e.sarRatio,baseDts:e.baseDts}}),t.exist()&&this.hls.emit(Q.METADATA_PARSED,{type:"audio",track:t,meta:{codec:t.codec,channelCount:t.channelCount,sampleRate:t.sampleRate,timescale:t.timescale,baseDts:t.baseDts}}),lt.debug("discontinuity",e,t)),e.warnings.forEach(function(o){var u;switch(o.type){case ge.LARGE_AV_SHIFT:u=Q.LARGE_AV_FIRST_FRAME_GAP_DETECT;break;case ge.LARGE_VIDEO_GAP:u=Q.LARGE_VIDEO_DTS_GAP_DETECT;break;case ge.LARGE_VIDEO_GAP_BETWEEN_CHUNK:u=Q.MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT;break}u&&s.hls.emit(Q.STREAM_EXCEPTION,ee(ee({},o),{},{type:u})),lt.warn("video exception",o)}),t.warnings.forEach(function(o){var u;switch(o.type){case ge.LARGE_AUDIO_GAP:u=Q.LARGE_AUDIO_DTS_GAP_DETECT;break;case ge.AUDIO_FILLED:u=Q.AUDIO_GAP_DETECT;break;case ge.AUDIO_DROPPED:u=Q.AUDIO_OVERLAP_DETECT;break}u&&s.hls.emit(Q.STREAM_EXCEPTION,ee(ee({},o),{},{type:u})),lt.warn("audio exception",o)}),e.samples.forEach(function(o){o.keyframe&&s.hls.emit(Q.KEYFRAME,{pts:o.pts})}),r.seiSamples.forEach(function(o){s.hls.emit(Q.SEI,ee(ee({},o),{},{originPts:o.originPts/90,sei:{code:o.data.type,content:o.data.payload,dts:o.pts}}))})}}]),i}(),Pr=new be("BufferService"),Xn=function(){function i(a){oe(this,i),E(this,"_decryptor",new qn),E(this,"_transmuxer",null),E(this,"_mse",null),E(this,"_softVideo",null),E(this,"_sourceCreated",!1),E(this,"_needInitSegment",!0),E(this,"_directAppend",!1),this.hls=a,a.config.softDecode?this._softVideo=a.media:(this._mse=new ve(null,{preferMMS:a.config.preferMMS}),a.config.url&&this._mse.bindMedia(a.media)),a.config.decryptor&&(this._decryptor.externalDecryptor=a.config.decryptor)}return ue(i,[{key:"baseDts",get:function(){var e,t,r;return(e=this._transmuxer)===null||e===void 0||(t=e._demuxer)===null||t===void 0||(r=t._fixer)===null||r===void 0?void 0:r._baseDts}},{key:"nbSb",get:function(){var e;return(e=this._mse)!==null&&e!==void 0&&e._sourceBuffer?Object.keys(this._mse._sourceBuffer).length:0}},{key:"msIsOpend",get:function(){var e;return(e=this._mse)===null||e===void 0?void 0:e.isOpened}},{key:"msStreaming",get:function(){var e;return(e=this._mse)===null||e===void 0?void 0:e.streaming}},{key:"updateDuration",value:function(){var a=Y(C().mark(function t(r){return C().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(Pr.debug("update duration",r),!this._mse){s.next=9;break}if(this._mse.isOpened){s.next=5;break}return s.next=5,this._mse.open();case 5:return s.next=7,this._mse.updateDuration(r);case 7:s.next=10;break;case 9:this._softVideo&&(this._softVideo.duration=r);case 10:case"end":return s.stop()}},t,this)}));function e(t){return a.apply(this,arguments)}return e}()},{key:"createSource",value:function(e,t,r,n){if(!this._sourceCreated){var s=e||t;if(s){if(wr.probe(s))this._transmuxer||(this._transmuxer=new Lr(this.hls,!1,!this._softVideo));else if(ae.probe(s))if(this._softVideo)this._transmuxer||(this._transmuxer=new Lr(this.hls,!0));else{this._directAppend=!0;var o=!1;e&&!r&&ae.findBox(e,["moov","trak"]).forEach(function(u){var l=ae.findBox(u.data,["trak","mdia","minf","stbl","stsd"])[0];if(l){var c=ae.stsd(l).entries[0];if(c){if(c.hvcC)r=c.hvcC.codec||"hev1.1.6.L93.B0";else if(c.avcC)r=c.avcC.codec;else if(c.sampleRate||c.esds){var f;n=((f=c.esds)===null||f===void 0?void 0:f.codec)||"mp4a.40.2",o=!0}}}}),t&&!n&&ae.findBox(t,["moov","trak","mdia","minf","stbl","stsd"]).forEach(function(u){var l=ae.stsd(u).entries[0];l&&l.esds&&(n=l.esds.codec)}),e&&!r&&(r="avc1.42e01e"),t&&!n&&(n="mp4a.40.2"),o&&(r+=", ".concat(n),n=""),this._createMseSource(r,n)}else throw new re($.OTHER,null,null,null,"unsupported stream");this._softVideo&&(this._sourceCreated=!0)}}}},{key:"appendBuffer",value:function(){var a=Y(C().mark(function t(r,n,s,o,u,l,c){var f,v,h,p,y,d,_,b,w;return C().wrap(function(T){for(;;)switch(T.prev=T.next){case 0:if(!(!(s!=null&&s.length)&&!(o!=null&&o.length))){T.next=2;break}return T.abrupt("return");case 2:if(!this._directAppend){T.next=7;break}return f=[],s&&f.push(this._mse.append(ve.VIDEO,s)),o&&f.push(this._mse.append(ve.AUDIO,o)),T.abrupt("return",Promise.all(f));case 7:if(v=this._needInitSegment||u,h=this._transmuxer.transmux(s,o,u,l,c,this._needInitSegment||u),p=we(h,2),y=p[0],d=p[1],o&&n&&n?.setTrackExist(!1,!0),o&&r&&r?.setTrackExist(!0,!1),n||r?.setTrackExist(!!y,!!d),y&&!d&&this.hls.emit(Q.NO_AUDIO_TRACK),!this._softVideo){T.next=18;break}this._softVideo.appendBuffer(y,d),this._needInitSegment=!1,T.next=28;break;case 18:if(!this._mse){T.next=28;break}return _=!this._sourceCreated,_&&this._createMseSource(y?.codec,d?.codec),this._needInitSegment=!1,b=this._mse,w=[],v&&!_&&this._handleCodecChange(y,d),y&&w.push(b.append(ve.VIDEO,y.data)),d&&w.push(b.append(ve.AUDIO,d.data)),T.abrupt("return",Promise.all(w));case 28:case"end":return T.stop()}},t,this)}));function e(t,r,n,s,o,u,l){return a.apply(this,arguments)}return e}()},{key:"removeBuffer",value:function(){var a=Y(C().mark(function t(){var r=this,n,s,o,u=arguments;return C().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=u.length>0&&u[0]!==void 0?u[0]:0,s=u.length>1&&u[1]!==void 0?u[1]:1/0,o=this.hls.media,!(!this._mse||!o||n<0||s<n||n>=this._mse.duration)){c.next=5;break}return c.abrupt("return");case 5:return c.abrupt("return",this._mse.clearBuffer(n,s).then(function(){return r.hls.emit(X.REMOVE_BUFFER,{start:n,end:s,removeEnd:s})}));case 6:case"end":return c.stop()}},t,this)}));function e(){return a.apply(this,arguments)}return e}()},{key:"evictBuffer",value:function(){var a=Y(C().mark(function t(r){var n,s,o,u;return C().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=this.hls.media,!(!this._mse||!n||!r||r<0)){c.next=3;break}return c.abrupt("return");case 3:if(s=n.currentTime,o=s-r,!(o<=0)){c.next=7;break}return c.abrupt("return");case 7:if(u=ce.start(ce.get(n)),!(u+1>=o)){c.next=10;break}return c.abrupt("return");case 10:return c.abrupt("return",this.removeBuffer(0,o));case 11:case"end":return c.stop()}},t,this)}));function e(t){return a.apply(this,arguments)}return e}()},{key:"clearAllBuffer",value:function(){var a=Y(C().mark(function t(){return C().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._mse){n.next=2;break}return n.abrupt("return",this._mse.clearAllBuffer());case 2:case"end":return n.stop()}},t,this)}));function e(){return a.apply(this,arguments)}return e}()},{key:"decryptBuffer",value:function(e,t){return this._decryptor.decrypt(e,t)}},{key:"reset",value:function(){var a=Y(C().mark(function t(){var r,n=arguments;return C().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(r=n.length>0&&n[0]!==void 0?n[0]:!1,!(this._mse&&!r)){o.next=8;break}return this._transmuxer=null,this._sourceCreated=!1,o.next=6,this._mse.unbindMedia();case 6:return o.next=8,this._mse.bindMedia(this.hls.media);case 8:this._needInitSegment=!0,this._directAppend=!1;case 10:case"end":return o.stop()}},t,this)}));function e(){return a.apply(this,arguments)}return e}()},{key:"endOfStream",value:function(){var a=Y(C().mark(function t(){return C().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._mse){n.next=5;break}if(!this._sourceCreated){n.next=5;break}return n.next=4,this._mse.endOfStream();case 4:this.hls.emit(X.BUFFEREOS);case 5:this._softVideo&&this._softVideo.endOfStream();case 6:case"end":return n.stop()}},t,this)}));function e(){return a.apply(this,arguments)}return e}()},{key:"setLiveSeekableRange",value:function(){var a=Y(C().mark(function t(r,n){return C().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:this._mse&&this._mse.setLiveSeekableRange(r,n);case 1:case"end":return o.stop()}},t,this)}));function e(t,r){return a.apply(this,arguments)}return e}()},{key:"destroy",value:function(){var a=Y(C().mark(function t(){var r;return C().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if((r=this._decryptor)===null||r===void 0||r.destroy(),!this._mse){s.next=4;break}return s.next=4,this._mse.unbindMedia();case 4:this._decryptor=null,this._mse=null,this._softVideo=null;case 7:case"end":return s.stop()}},t,this)}));function e(){return a.apply(this,arguments)}return e}()},{key:"_createMseSource",value:function(e,t){Pr.debug("create mse source, videoCodec=".concat(e,", audioCodec=").concat(t));var r=this._mse;r&&(e&&(r.createSource(ve.VIDEO,"video/mp4;codecs=".concat(e)),this._sourceCreated=!0),t&&(r.createSource(ve.AUDIO,"audio/mp4;codecs=".concat(t)),this._sourceCreated=!0),this.hls.emit(X.SOURCEBUFFER_CREATED))}},{key:"_handleCodecChange",value:function(e,t){var r=this._mse,n=[{type:ve.VIDEO,codecs:e?.codec},{type:ve.AUDIO,codecs:t?.codec}];n.filter(function(s){return!!s.codecs}).forEach(function(s){var o=s.type,u=s.codecs,l=r.getSourceBuffer(o);if(l){var c=u.split(",")[0];new RegExp(c,"ig").test(l.mimeType)||r.changeType(o,"".concat(o,"/mp4;codecs=").concat(u))}})}},{key:"seamlessSwitch",value:function(){this._needInitSegment=!0}},{key:"isFull",value:function(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ve.VIDEO;return(e=this._mse)===null||e===void 0?void 0:e.isFull(t)}}]),i}();function Qn(i){var a=i?.media||document.createElement("video");return ee(ee({maxPlaylistSize:50,retryCount:3,retryDelay:1e3,pollRetryCount:2,loadTimeout:1e4,manifestLoadTimeout:1e4,preloadTime:30,softDecode:!1,bufferBehind:10,maxJumpDistance:3,startTime:0,useLowLatency:!0,targetLatency:10,maxLatency:20,allowedStreamTrackChange:!0,seiInTime:!1,manifestList:[],minSegmentsStartPlay:3,preferMMS:!1,preferMMSStreaming:!1},i),{},{media:a})}var Jn=ue(function i(){oe(this,i),E(this,"version",0),E(this,"streams",[]),E(this,"isMaster",!0)}),Rr={Audio:"AUDIO",Video:"VIDEO",SubTitle:"SUBTITLE",ClosedCaptions:"CLOSED-CAPTIONS"},ct={CLEAR_KEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed",PLAYREADY:"com.microsoft.playready"},xt=ue(function i(){oe(this,i),E(this,"id",0),E(this,"url",""),E(this,"default",!1),E(this,"autoSelect",!1),E(this,"forced",!1),E(this,"group",""),E(this,"name",""),E(this,"lang",""),E(this,"segments",[]),E(this,"endSN",0)}),Zn=function(i){_t(e,i);var a=bt(e);function e(){var t;oe(this,e);for(var r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];return t=a.call.apply(a,[this].concat(n)),E(W(t),"mediaType",Rr.Audio),E(W(t),"channels",0),t}return ue(e)}(xt),ei=function(i){_t(e,i);var a=bt(e);function e(){var t;oe(this,e);for(var r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];return t=a.call.apply(a,[this].concat(n)),E(W(t),"mediaType",Rr.SubTitle),t}return ue(e)}(xt),ti=ue(function i(){oe(this,i),E(this,"id",0),E(this,"bitrate",0),E(this,"width",0),E(this,"height",0),E(this,"name",""),E(this,"url",""),E(this,"audioCodec",""),E(this,"videoCodec",""),E(this,"textCodec",""),E(this,"audioGroup",""),E(this,"audioStreams",[]),E(this,"subtitleStreams",[]),E(this,"closedCaptionsStream",[])}),ri=ue(function i(){oe(this,i),E(this,"version",0),E(this,"url",""),E(this,"type",""),E(this,"startCC",0),E(this,"endCC",0),E(this,"startSN",0),E(this,"endSN",0),E(this,"totalDuration",0),E(this,"targetDuration",0),E(this,"partTargetDuration",0),E(this,"canSkipUntil",0),E(this,"canSkipDateRanges",!1),E(this,"skippedSegments",0),E(this,"canBlockReload",!1),E(this,"partHoldBack",0),E(this,"live",!0),E(this,"lowLatency",!1),E(this,"endPartIndex",0),E(this,"segments",[])}),ft=function(){function i(){oe(this,i),E(this,"sn",0),E(this,"cc",0),E(this,"url",""),E(this,"title",""),E(this,"start",0),E(this,"duration",0),E(this,"dataTime",""),E(this,"key",null),E(this,"byteRange",null),E(this,"isInitSegment",!1),E(this,"initSegment",null),E(this,"isLast",!1),E(this,"hasAudio",!1),E(this,"hasVideo",!1),E(this,"independent",!1),E(this,"partIndex",0)}return ue(i,[{key:"end",get:function(){return this.start+this.duration}},{key:"setTrackExist",value:function(e,t){this.hasVideo=e,this.hasAudio=t}},{key:"setByteRange",value:function(e,t){this.byteRange=[0];var r=e.split("@");r.length===1&&t&&t.byteRange?(this.byteRange[0]=t.byteRange[1]||0,this.byteRange[0]&&(this.byteRange[0]+=1)):this.byteRange[0]=parseInt(r[1]),this.byteRange[1]=this.byteRange[0]+parseInt(r[0])-1}}]),i}(),ni=function(){function i(a){oe(this,i),E(this,"method",""),E(this,"url",""),E(this,"iv",null),E(this,"keyFormat",""),E(this,"keyFormatVersions",""),a instanceof i&&(this.method=a.method,this.url=a.url,this.keyFormat=a.keyFormat,this.keyFormatVersions=a.keyFormatVersions,a.iv&&(this.iv=new Uint8Array(a.iv)))}return ue(i,[{key:"clone",value:function(e){var t=new i(this);return e!=null&&t.setIVFromSN(e),t}},{key:"setIVFromSN",value:function(e){if(!this.iv&&this.method==="AES-128"&&typeof e=="number"&&this.url){this.iv=new Uint8Array(16);for(var t=12;t<16;t++)this.iv[t]=e>>8*(15-t)&255}}},{key:"isSegmentEncrypted",value:function(){var e=this.method;return e==="AES-128"}},{key:"isValidKeySystem",value:function(){var e=[ct.CLEAR_KEY,ct.FAIRPLAY,ct.WIDEVINE,ct.PLAYREADY].indexOf(this.keyFormat)>-1;if(!e)return!1;var t=["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)>-1;return!!t}},{key:"isSupported",value:function(){return this.method?this.isSegmentEncrypted()?!0:!!this.isValidKeySystem():!1}}]),i}(),ii=/^#(EXT[^:]*)(?::(.*))?$/,Ir=/([^=]+)=(?:"([^"]*)"|([^",]*))(?:,|$)/g,si=/^(?:[a-zA-Z0-9+\-.]+:)?\/\//,ai=/^((?:[a-zA-Z0-9+\-.]+:)?\/\/[^/?#]*)?([^?#]*\/)?/;function oi(i){return i.split(/[\r\n]/).map(function(a){return a.trim()}).filter(Boolean)}function Cr(i){var a=i.match(ii);if(!(!a||!a[1]))return[a[1].replace("EXT-X-",""),a[2]]}function Be(i){for(var a={},e=Ir.exec(i);e;)a[e[1]]=e[2]||e[3],e=Ir.exec(i);return a}function je(i,a){if(!a||!i||si.test(i))return i;var e=ai.exec(a);return e?i[0]==="/"?e[1]+i:e[1]+e[2]+i:i}var ui={audio:[/^mp4a/,/^vorbis$/,/^opus$/,/^flac$/,/^[ae]c-3$/],video:[/^avc/,/^hev/,/^hvc/,/^vp0?[89]/,/^av1$/],text:[/^vtt$/,/^wvtt/,/^stpp/]};function Nt(i,a){var e=ui[i];if(!(!e||!a||!a.length)){for(var t=0;t<e.length;t++)for(var r=0;r<a.length;r++)if(e[t].test(a[r]))return a[r]}}function li(i,a){for(var e=new Jn,t=0,r,n=[],s=[];r=i[t++];){var o=Cr(r);if(o){var u=we(o,2),l=u[0],c=u[1];if(l==="VERSION")e.version=parseInt(c);else if(l==="MEDIA"&&c){var f=Be(c),v=void 0;switch(f.TYPE){case"AUDIO":v=new Zn;break;case"SUBTITLES":v=new ei;break;default:v=new xt}v.url=je(f.URI,a),v.default=f.DEFAULT==="YES",v.autoSelect=f.AUTOSELECT==="YES",v.group=f["GROUP-ID"],v.name=f.NAME,v.lang=f.LANGUAGE,f.CHANNELS&&(v.channels=Number(f.CHANNELS.split("/")[0]),Number.isNaN(v.channels)&&(v.channels=0)),f.TYPE==="AUDIO"&&f.URI&&n.push(v),f.TYPE==="SUBTITLES"&&s.push(v)}else if(l==="STREAM-INF"&&c){var h=new ti,p=Be(c);if(h.bitrate=parseInt(p["AVERAGE-BANDWIDTH"]||p.BANDWIDTH),h.name=p.NAME,h.url=je(i[t++],a),p.RESOLUTION){var y=p.RESOLUTION.split("x"),d=we(y,2),_=d[0],b=d[1];h.width=parseInt(_),h.height=parseInt(b)}if(p.CODECS){var w=p.CODECS.split(/[ ,]+/).filter(Boolean);h.videoCodec=Nt("video",w),h.audioCodec=Nt("audio",w),h.textCodec=Nt("text",w)}h.audioGroup=p.AUDIO,h.subtitleGroup=p.SUBTITLES,e.streams.push(h)}}}return e.streams.forEach(function(D,T){D.id=T}),n.length&&(n.forEach(function(D,T){D.id=T}),e.streams.forEach(function(D){D.audioGroup&&(D.audioStreams=n.filter(function(T){return T.group===D.audioGroup}))})),s.length&&(s.forEach(function(D,T){D.id=T}),e.streams.forEach(function(D){D.subtitleGroup&&(D.subtitleStreams=s.filter(function(T){return T.group===D.subtitleGroup}))})),e}function ci(i,a,e){var t=new ri;t.url=a;for(var r=new ft,n=null,s=null,o=0,u=0,l=0,c=0,f,v=!1,h=0;(f=i[c++])&&!v;){if(f[0]!=="#"){if(t.lowLatency){u++;continue}r.sn=u,r.cc=l,r.url=je(f,a),s&&(r.key=s.clone(u)),n&&(r.initSegment=n),t.segments.push(r),r=new ft,u++;continue}var p=Cr(f);if(p){var y=we(p,2),d=y[0],_=y[1];switch(d){case"VERSION":t.version=parseInt(_);break;case"PLAYLIST-TYPE":t.type=_?.toUpperCase();break;case"TARGETDURATION":t.targetDuration=parseFloat(_);break;case"PART-INF":{e&&(t.lowLatency=!0);var b=Be(_);b["PART-TARGET"]&&(t.partTargetDuration=parseFloat(b["PART-TARGET"]))}break;case"SERVER-CONTROL":{var w=Be(_);t.canBlockReload=w["CAN-BLOCK-RELOAD"]==="YES",t.partHoldBack=parseFloat(w["PART-HOLD-BACK"]||0),t.canSkipUntil=parseFloat(w["CAN-SKIP-UNTIL"]||0),t.canSkipDateRanges=w["CAN-SKIP-DATERANGES"]==="YES"}break;case"ENDLIST":{var D=t.segments[t.segments.length-1];D&&(D.isLast=!0),t.live=!1,v=!0}break;case"MEDIA-SEQUENCE":u=t.startSN=parseInt(_);break;case"DISCONTINUITY-SEQUENCE":l=t.startCC=parseInt(_);break;case"DISCONTINUITY":l++;break;case"BYTERANGE":r.setByteRange(_,t.segments[t.segments.length-1]);break;case"PART":{if(!t.lowLatency)break;var T=Be(_);r.duration=parseFloat(T.DURATION),r.independent=T.INDEPENDENT==="YES",r.sn=u,r.cc=l,r.partIndex=h,r.start=o,r.duration=parseFloat(T.DURATION),o+=r.duration,r.url=je(T.URI,a),s&&(r.key=s.clone(u)),n&&(r.initSegment=n),t.segments.push(r),r=new ft,h++}break;case"PRELOAD-HINT":break;case"PROGRAM-DATE-TIME":r.dataTime=_;break;case"EXTINF":{if(t.lowLatency){h=0;break}var F=_.split(","),B=we(F,2),N=B[0],G=B[1];r.start=o,r.duration=parseFloat(N),o+=r.duration,r.title=G}break;case"KEY":{var M=Be(_);if(M.METHOD==="NONE"){s=null;break}if(s=new ni,s.method=M.METHOD,s.url=/^blob:/.test(M.URI)?M.URI:je(M.URI,a),s.keyFormat=M.KEYFORMAT||"identity",s.keyFormatVersions=M.KEYFORMATVERSIONS,!s.isSupported())throw new Error("encrypt ".concat(M.METHOD,"/").concat(M.KEYFORMAT," is not supported"));if(M.IV){var q=M.IV.slice(2);q=(q.length&1?"0":"")+q,s.iv=new Uint8Array(q.length/2);for(var m=0,g=q.length/2;m<g;m++)s.iv[m]=parseInt(q.slice(m*2,m*2+2),16)}}break;case"MAP":{var S=Be(_);r.url=je(S.URI,a),S.BYTERANGE&&r.setByteRange(S.BYTERANGE),r.isInitSegment=!0,r.sn=0,s&&(r.key=s.clone(0)),n=r,r=new ft}break}}}t.segments=t.segments.filter(function(k){return k.duration!==0});var O=t.segments[t.segments.length-1];return O&&(t.endSN=O.sn,t.endPartIndex=O.partIndex),t.totalDuration=o,t.endCC=l,t}var ht=function(){function i(){oe(this,i)}return ue(i,null,[{key:"parse",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0;if(!e.includes("#EXTM3U"))throw new Error("Invalid m3u8 file");var n=oi(e);return i.isMediaPlaylist(e)?ci(n,t,r):li(n,t)}},{key:"isMediaPlaylist",value:function(e){return e.includes("#EXTINF:")||e.includes("#EXT-X-TARGETDURATION:")}}]),i}(),fi=function(){function i(a){var e=this;oe(this,i),E(this,"_emitOnLoaded",function(u,l){var c=u.response,f=u.options,v=f||{},h=v.firstByteTime,p=v.startTime,y=v.endTime,d=v.contentLength,_=y-p;e.hls.emit(X.SPEED,{time:_,byteLength:d,url:l}),e.hls.emit(X.LOAD_COMPLETE,{url:l,elapsed:_||0}),e.hls.emit(X.TTFB,{url:l,responseUrl:c.url,elapsed:h-p}),e.hls.emit(X.LOAD_RESPONSE_HEADERS,{headers:c.headers,url:l})}),E(this,"_onLoaderRetry",function(u,l){e.hls.emit(Q.LOAD_RETRY,{error:re.network(u),retryTime:l})}),this.hls=a,this._timer=null,this._useLowLatency=a.config.useLowLatency;var t=this.hls.config,r=t.retryCount,n=t.retryDelay,s=t.manifestLoadTimeout,o=t.fetchOptions;this._loader=new Ve(ee(ee({},o),{},{responseType:"text",retry:r,retryDelay:n,timeout:s,onRetryError:this._onLoaderRetry})),this._audioLoader=new Ve(ee(ee({},o),{},{responseType:"text",retry:r,retryDelay:n,timeout:s,onRetryError:this._onLoaderRetry})),this._subtitleLoader=new Ve(ee(ee({},o),{},{responseType:"text",retry:r,retryDelay:n,timeout:s,onRetryError:this._onLoaderRetry}))}return ue(i,[{key:"load",value:function(){var a=Y(C().mark(function t(r,n,s){var o,u,l,c,f,v,h,p,y,d,_,b,w,D,T,F,B,N,G,M;return C().wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return o=[this._loader.load(r)],n&&o.push(this._audioLoader.load(n)),s&&o.push(this._subtitleLoader.load(s)),m.prev=3,m.next=6,Promise.all(o);case 6:if(p=m.sent,y=we(p,3),d=y[0],_=y[1],b=y[2],d){m.next=13;break}return m.abrupt("return",[]);case 13:this._emitOnLoaded(d,r),u=d.data,f=d.response.url||r,n?(l=_?.data,c=b?.data,v=(_==null||(w=_.response)===null||w===void 0?void 0:w.url)||n,h=(b==null||(D=b.response)===null||D===void 0?void 0:D.url)||s,l&&this._emitOnLoaded(_,n),c&&this._emitOnLoaded(b,s)):(c=_?.data,h=(_==null||(T=_.response)===null||T===void 0?void 0:T.url)||s,c&&this._emitOnLoaded(_,s)),m.next=22;break;case 19:throw m.prev=19,m.t0=m.catch(3),re.network(m.t0);case 22:if(F=this.hls.config.onPreM3U8Parse,m.prev=23,F&&(u=F(u)||u,l&&(l=F(l,!0)||l),c&&(c=F(c,!0)||c)),B=ht.parse(u,f,this._useLowLatency),!(((M=B)===null||M===void 0?void 0:M.live)===!1&&B.segments&&!B.segments.length)){m.next=28;break}throw new Error("empty segments list");case 28:l&&(N=ht.parse(l,v,this._useLowLatency)),c&&(G=ht.parse(c,h,this._useLowLatency)),m.next=35;break;case 32:throw m.prev=32,m.t1=m.catch(23),new re($.MANIFEST,$.SUB_TYPES.HLS,m.t1);case 35:return B&&(B.isMaster?this.hls.emit(Q.HLS_MANIFEST_LOADED,{playlist:B}):this.hls.emit(Q.HLS_LEVEL_LOADED,{playlist:B})),m.abrupt("return",[B,N,G]);case 37:case"end":return m.stop()}},t,this,[[3,19],[23,32]])}));function e(t,r,n){return a.apply(this,arguments)}return e}()},{key:"parseText",value:function(e,t){var r=this.hls.config.onPreM3U8Parse,n;try{var s;if(r&&(e=r(e)||e),n=ht.parse(e,t,this._useLowLatency),((s=n)===null||s===void 0?void 0:s.live)===!1&&n.segments&&!n.segments.length)throw new Error("empty segments list")}catch(o){throw new re($.MANIFEST,$.SUB_TYPES.HLS,o)}return n&&(n.isMaster?this.hls.emit(Q.HLS_MANIFEST_LOADED,{playlist:n}):this.hls.emit(Q.HLS_LEVEL_LOADED,{playlist:n})),[n]}},{key:"poll",value:function(e,t,r,n,s,o){var u=this;clearTimeout(this._timer),o=o||3e3;var l=this.hls.config.pollRetryCount,c=function(){var f=Y(C().mark(function v(){var h;return C().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return clearTimeout(u._timer),y.prev=1,y.next=4,u.load(e,t,r);case 4:if(h=y.sent,h[0]){y.next=7;break}return y.abrupt("return");case 7:l=u.hls.config.pollRetryCount,n(h[0],h[1],h[2]),y.next=15;break;case 11:y.prev=11,y.t0=y.catch(1),l--,l<=0&&s(y.t0);case 15:u._timer=setTimeout(c,o);case 16:case"end":return y.stop()}},v,null,[[1,11]])}));return function(){return f.apply(this,arguments)}}();this._timer=setTimeout(c,o)}},{key:"stopPoll",value:function(){return clearTimeout(this._timer),this.cancel()}},{key:"cancel",value:function(){return Promise.all([this._loader.cancel(),this._audioLoader.cancel()])}}]),i}();function Mr(i,a,e){return a>e&&(e=a),Math.min(Math.max(i,a),e)}var Ft=new be("playlist"),Br=function(){function i(a,e,t){oe(this,i),E(this,"live",void 0),E(this,"id",0),E(this,"bitrate",0),E(this,"width",0),E(this,"height",0),E(this,"name",""),E(this,"url",""),E(this,"audioCodec",""),E(this,"videoCodec",""),E(this,"textCodec",""),E(this,"startCC",0),E(this,"endCC",0),E(this,"startSN",0),E(this,"endSN",-1),E(this,"totalDuration",0),E(this,"targetDuration",0),E(this,"partTargetDuration",0),E(this,"canSkipUntil",0),E(this,"canSkipDateRanges",!1),E(this,"skippedSegments",0),E(this,"canBlockReload",!1),E(this,"partHoldBack",0),E(this,"lowLatency",!1),E(this,"endPartIndex",0),E(this,"snDiff",null),E(this,"segments",[]),E(this,"audioStreams",[]),E(this,"subtitleStreams",[]),E(this,"closedCaptions",[]),E(this,"currentAudioStream",null),E(this,"currentSubtitleStream",null),this.update(this._setLLPlaybackPoint(a),e,t)}return ue(i,[{key:"lastSegment",get:function(){return this.segments.length?this.segments[this.segments.length-1]:null}},{key:"segmentDuration",get:function(){var e;return this.targetDuration||((e=this.segments[0])===null||e===void 0?void 0:e.duration)||0}},{key:"liveEdge",get:function(){return this.endTime}},{key:"endTime",get:function(){var e;return((e=this.lastSegment)===null||e===void 0?void 0:e.end)||0}},{key:"currentSubtitleEndSn",get:function(){var e;return((e=this.currentSubtitleStream)===null||e===void 0?void 0:e.endSN)||0}},{key:"clearOldSegment",value:function(e,t){return this.currentAudioStream&&this._clearSegments(e,t),this._clearSegments(e,t)}},{key:"getAudioSegment",value:function(e){if(!(!e||!this.currentAudioStream)){var t=e.sn-this.snDiff;return this.currentAudioStream.segments.find(function(r){return r.sn===t})}}},{key:"update",value:function(e,t){this.url=e.url,Array.isArray(e.segments)?((this.live===null||this.live===void 0)&&(this.live=e.live),this._updateSegments(e,this),this.startCC=e.startCC,this.endCC=e.endCC,this.startSN=e.startSN,this.endSN=e.endSN||-1,this.totalDuration=e.totalDuration,this.targetDuration=e.targetDuration,this.live=e.live,this.lowLatency=e.lowLatency,this.canBlockReload=e.canBlockReload,this.canSkipDateRanges=e.canSkipDateRanges,this.canSkipUntil=e.canSkipUntil,this.partHoldBack=e.partHoldBack,this.partTargetDuration=e.partTargetDuration,this.skippedSegments=e.skippedSegments,this.endPartIndex=e.endPartIndex,t&&this.currentAudioStream&&Array.isArray(t.segments)&&(this._updateSegments(t,this.currentAudioStream),(this.snDiff===null||this.snDiff===void 0)&&e.segments.length&&t.segments.length&&(this.snDiff=e.segments[0].sn-t.segments[0].sn))):(this.id=e.id,this.bitrate=e.bitrate,this.width=e.width,this.height=e.height,this.name=e.name,this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.textCodec=e.textCodec,this.audioStreams=e.audioStreams,this.subtitleStreams=e.subtitleStreams,!this.currentAudioStream&&this.audioStreams.length&&(this.currentAudioStream=this.audioStreams.find(function(r){return r.default})||this.audioStreams[0]),!this.currentSubtitleStream&&this.subtitleStreams.length&&(this.currentSubtitleStream=this.subtitleStreams.find(function(r){return r.default})||this.subtitleStreams[0]))}},{key:"updateSubtitle",value:function(e){var t=this;if(e&&this.currentSubtitleStream&&Array.isArray(e.segments)){var r=this._updateSegments(e,this.currentSubtitleStream),n=this.currentSubtitleStream.segments;if(n.length>100&&(this.currentSubtitleStream.segments=n.slice(100)),!!r)return r.map(function(s){return{sn:s.sn,url:s.url,duration:s.duration,start:s.start,end:s.end,lang:t.currentSubtitleStream.lang}})}}},{key:"switchSubtitle",value:function(e){var t=this.subtitleStreams.find(function(n){return n.lang===e}),r=this.currentSubtitleStream;t&&(this.currentSubtitleStream=t,r.segments=[])}},{key:"_setLLPlaybackPoint",value:function(e){if(!e.lowLatency||!e.segments.length)return e;for(var t=e.totalDuration-e.partHoldBack,r=e.segments,n=0,s=0,o=r.length;s<o;s++)r[s].start<=t&&r[s].independent&&(n=s);var u=r.slice(n),l=0;return u.forEach(function(c){c.start=l,l=c.end}),e.segments=u,e.totalDuration=l,e.startSN=u[0].sn,e.startCC=u[0].cc,Ft.log("set ll-hls playback point: SN=".concat(e.startSN," partIndex=").concat(u[0].partIndex,", duration=").concat(l)),e}},{key:"_clearSegments",value:function(e,t){for(var r=0,n=this.segments,s=0,o=n.length;s<o;s++)if(n[s].end>=e){r=s;break}return r>t&&(r=t),r&&(this.segments=this.segments.slice(r),this.currentAudioStream&&(this.currentAudioStream.segments=this.currentAudioStream.segments.slice(r))),t-r}},{key:"_updateSegments",value:function(e,t){var r=t.segments;if(this.live){var n,s=e.lowLatency,o=r[r.length-1],u=(n=o?.sn)!==null&&n!==void 0?n:-1,l=o?.partIndex||0,c=u<e.endSN&&e.segments.length;if(s&&(c=c||l<e.endPartIndex),c){Ft.log("update segments: endSN:".concat(u,", partIndex:").concat(l," --> endSN:").concat(e.endSN,", partIndex:").concat(e.endPartIndex));var f=e.segments.findIndex(function(d){return d.sn===u&&d.partIndex===l}),v=f<0?e.segments:e.segments.slice(f+1);if(r.length&&v.length){var h=o.end,p=h;v.forEach(function(d){d.start=h,h=d.end}),Ft.log("liveEdge: ".concat(p," -> ").concat(h));var y=o?.cc||-1;y>v[0].cc&&v.forEach(function(d){return d.cc+=y})}return t.endSN=e.endSN,t.segments=r.concat(v),v}}else t.segments=e.segments}}]),i}(),hi=function(){function i(a){oe(this,i),E(this,"streams",[]),E(this,"currentStream",null),E(this,"dvrWindow",0),E(this,"_segmentPointer",-1),this.hls=a}return ue(i,[{key:"lowLatency",get:function(){var e;return(e=this.currentStream)===null||e===void 0?void 0:e.lowLatency}},{key:"lastSegment",get:function(){var e;return(e=this.currentStream)===null||e===void 0?void 0:e.lastSegment}},{key:"currentSegment",get:function(){var e;return(e=this.currentSegments)===null||e===void 0?void 0:e[this._segmentPointer]}},{key:"nextSegment",get:function(){var e;return(e=this.currentSegments)===null||e===void 0?void 0:e[this._segmentPointer+1]}},{key:"currentSegments",get:function(){var e;return(e=this.currentStream)===null||e===void 0?void 0:e.segments}},{key:"currentSubtitleEndSn",get:function(){var e;return(e=this.currentStream)===null||e===void 0?void 0:e.currentSubtitleEndSn}},{key:"liveEdge",get:function(){var e;return(e=this.currentStream)===null||e===void 0?void 0:e.liveEdge}},{key:"totalDuration",get:function(){var e;return((e=this.currentStream)===null||e===void 0?void 0:e.totalDuration)||0}},{key:"seekRange",get:function(){var e=this.currentSegments;if(!(!e||!e.length))return[e[0].start,e[e.length-1].end]}},{key:"nbSegments",get:function(){var e;return((e=this.currentSegments)===null||e===void 0?void 0:e.length)||0}},{key:"isEmpty",get:function(){var e;return!((e=this.currentSegments)!==null&&e!==void 0&&e.length)}},{key:"isLive",get:function(){var e;return(e=this.currentStream)===null||e===void 0?void 0:e.live}},{key:"hadSegmentLoaded",get:function(){return this._segmentPointer!==-1}},{key:"hasSubtitle",get:function(){var e;return!!((e=this.currentStream)!==null&&e!==void 0&&e.currentSubtitleStream)}},{key:"getAudioSegment",value:function(e){var t;return(t=this.currentStream)===null||t===void 0?void 0:t.getAudioSegment(e)}},{key:"moveSegmentPointer",value:function(e){var t;e==null&&(e=this._segmentPointer+1),this._segmentPointer=Mr(e,-1,(t=this.currentSegments)===null||t===void 0?void 0:t.length)}},{key:"reset",value:function(){this.streams=[],this.currentStream=null,this.dvrWindow=0,this._segmentPointer=-1}},{key:"getSegmentByIndex",value:function(e){var t;return(t=this.currentSegments)===null||t===void 0?void 0:t[e]}},{key:"setNextSegmentByIndex",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;this._segmentPointer=e-1}},{key:"findSegmentIndexByTime",value:function(e){var t=this.currentSegments;if(t){for(var r=0,n=t.length,s;r<n;r++)if(s=t[r],e>=s.start&&e<s.end)return r;var o=t[t.length-1];if(Math.abs(e-o?.end)<.2)return t.length-1}}},{key:"upsertPlaylist",value:function(e,t,r){var n=this;if(e){if(e.isMaster)this.streams.length=e.streams.length,e.streams.filter(function(l){return l.url}).forEach(function(l,c){n.streams[c]?n.streams[c].update(l):n.streams[c]=new Br(l)}),this.currentStream=this.streams[0];else if(Array.isArray(e.segments)){var s=this.currentStream;if(s){s.update(e,t,r);var o=s.updateSubtitle(r);o&&this.hls.emit(Q.SUBTITLE_SEGMENTS,{list:o})}else this.reset(),this.currentStream=this.streams[0]=new Br(e,t,r)}var u=this.currentStream;u&&this.hls.isLive&&!this.dvrWindow&&(this.dvrWindow=this.currentSegments.reduce(function(l,c){return l+=c.duration,l},0))}}},{key:"switchSubtitle",value:function(e){var t;(t=this.currentStream)===null||t===void 0||t.switchSubtitle(e)}},{key:"clearOldSegment",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:50,t=this.currentStream;if(!(!this.dvrWindow||!t)){var r=t.endTime-this.dvrWindow;if(!(r<=0)){var n=t.segments;n.length<=e||(this._segmentPointer=t.clearOldSegment(r,this._segmentPointer))}}}},{key:"checkSegmentTrackChange",value:function(e,t){var r=this.findSegmentIndexByTime(e),n=this.getSegmentByIndex(r);if(n&&!(!n.hasAudio&&!n.hasVideo)){if(t!==2&&n.hasAudio&&n.hasVideo)return n;if(!(n.end-e>.3)){var s=this.getSegmentByIndex(r+1);if(s&&!(!s.hasAudio&&!s.hasVideo)&&(s.hasAudio!==n.hasAudio||s.hasVideo!==n.hasVideo))return s}}}}]),i}(),di=function(){function i(a){var e=this;oe(this,i),E(this,"error",null),E(this,"_emitOnLoaded",function(u,l){var c=u.data,f=u.response,v=u.options,h=v||{},p=h.firstByteTime,y=h.startTime,d=h.endTime,_=h.contentLength,b=d-y;e._bandwidthService.addRecord(_||c.byteLength,b),e.hls.emit(X.SPEED,{time:b,byteLength:_,url:l}),e.hls.emit(X.LOAD_COMPLETE,{url:l,elapsed:b||0}),e.hls.emit(X.TTFB,{url:l,responseUrl:f.url,elapsed:p-y}),e.hls.emit(X.LOAD_RESPONSE_HEADERS,{headers:f.headers,url:l})}),E(this,"_onLoaderRetry",function(u,l){e.hls.emit(X.LOAD_RETRY,{error:re.network(u),retryTime:l})}),this.hls=a,this._bandwidthService=new _n,this._mapCache={},this._keyCache={};var t=this.hls.config,r=t.retryCount,n=t.retryDelay,s=t.loadTimeout,o=t.fetchOptions;this._segmentLoader=new Ve(ee(ee({},o),{},{responseType:"arraybuffer",retry:r,retryDelay:n,timeout:s,onRetryError:this._onLoaderRetry})),this._audioSegmentLoader=new Ve(ee(ee({},o),{},{responseType:"arraybuffer",retry:r,retryDelay:n,timeout:s,onRetryError:this._onLoaderRetry})),this._keyLoader=new Ve(ee(ee({},o),{},{responseType:"arraybuffer",retry:r,retryDelay:n,timeout:s,onRetryError:this._onLoaderRetry}))}return ue(i,[{key:"speedInfo",value:function(){return{speed:this._bandwidthService.getLatestSpeed(),avgSpeed:this._bandwidthService.getAvgSpeed()}}},{key:"load",value:function(e,t,r){var n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:r,s=[];return e&&(s[0]=this.loadVideoSegment(e,r)),t&&(s[1]=this.loadAudioSegment(t,n)),Promise.all(s)}},{key:"loadVideoSegment",value:function(e,t){return this._loadSegment(this._segmentLoader,e,t)}},{key:"loadAudioSegment",value:function(e,t){return this._loadSegment(this._audioSegmentLoader,e,t)}},{key:"_loadSegment",value:function(){var a=Y(C().mark(function t(r,n,s){var o=this,u,l,c,f,v,h,p,y,d,_,b,w,D,T,F;return C().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:return p=[],this.hls.emit(X.LOAD_START,{url:n.url}),p[0]=r.load(n.url),s&&n.initSegment&&(d=n.initSegment.url,l=this._mapCache[d],l||(this.hls.emit(X.LOAD_START,{url:d}),p[1]=r.load(d).then(function(G){if(G){var M=Object.keys(o._mapCache);M>30&&(o._mapCache={}),l=o._mapCache[d]=G.data,o._emitOnLoaded(G,d)}})),_=(y=n.initSegment.key)===null||y===void 0?void 0:y.url,_&&(h=n.initSegment.key.iv,v=this._keyCache[_],v||(this.hls.emit(X.LOAD_START,{url:_}),p[2]=this._keyLoader.load(_).then(function(G){G&&(v=o._keyCache[_]=G.data,o._emitOnLoaded(G,_))})))),b=(u=n.key)===null||u===void 0?void 0:u.url,b&&n.key.isSegmentEncrypted()&&(f=n.key.iv,c=this._keyCache[b],c||(this.hls.emit(X.LOAD_START,{url:b}),p[3]=this._keyLoader.load(b).then(function(G){G&&(c=o._keyCache[b]=G.data,o._emitOnLoaded(G,b))}))),N.next=8,Promise.all(p);case 8:if(w=N.sent,D=we(w,1),T=D[0],T){N.next=13;break}return N.abrupt("return");case 13:return F=T.data,this._emitOnLoaded(T,n.url),N.abrupt("return",{data:F,map:l,key:c,mapKey:v,keyIv:f,mapKeyIv:h});case 16:case"end":return N.stop()}},t,this)}));function e(t,r,n){return a.apply(this,arguments)}return e}()},{key:"reset",value:function(){this.error=null,this._mapCache={},this._keyCache={},this._bandwidthService.reset()}},{key:"cancel",value:function(){var a=Y(C().mark(function t(){return C().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,Promise.all([this._keyLoader.cancel(),this._segmentLoader.cancel(),this._audioSegmentLoader.cancel()]);case 2:case"end":return n.stop()}},t,this)}));function e(){return a.apply(this,arguments)}return e}()}]),i}(),Se=new be("hls"),qe=function(i){_t(e,i);var a=bt(e);function e(t){var r;return oe(this,e),r=a.call(this),E(W(r),"version",e.version),E(W(r),"media",null),E(W(r),"config",null),E(W(r),"_manifestLoader",null),E(W(r),"_segmentLoader",null),E(W(r),"_playlist",null),E(W(r),"_bufferService",null),E(W(r),"_gapService",null),E(W(r),"_seiService",null),E(W(r),"_stats",null),E(W(r),"_prevSegSn",null),E(W(r),"_prevSegCc",null),E(W(r),"_tickTimer",null),E(W(r),"_tickInterval",500),E(W(r),"_segmentProcessing",!1),E(W(r),"_reloadOnPlay",!1),E(W(r),"_switchUrlOpts",null),E(W(r),"_isProcessQuotaExceeded",!1),E(W(r),"_loadSegment",Y(C().mark(function n(){var s,o,u,l,c;return C().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:if(!(r._segmentProcessing||!r.media)){v.next=2;break}return v.abrupt("return");case 2:if(s=r._playlist.nextSegment,o=W(r),u=o.config,s){v.next=6;break}return v.abrupt("return");case 6:if(r.isLive){v.next=16;break}if(l=r.bufferInfo(),r.media.paused&&!r.media.currentTime&&(l=r.bufferInfo(l.nextStart||.5)),c=Math.abs(l.end-r.media.duration)<.1,!(l.remaining>=u.preloadTime||c)){v.next=13;break}return c&&r._bufferService.msIsOpend&&r._bufferService.endOfStream(),v.abrupt("return");case 13:if(!(u.preferMMSStreaming&&!r._bufferService.msStreaming)){v.next=15;break}return v.abrupt("return");case 15:!r._urlSwitching&&r._prevSegSn!==s.sn-1&&l.end&&Math.abs(s.start-l.end)>1&&r._playlist.setNextSegmentByIndex(r._playlist.findSegmentIndexByTime(l.end+.1));case 16:return v.abrupt("return",r._loadSegmentDirect());case 17:case"end":return v.stop()}},n)}))),E(W(r),"_onPlay",Y(C().mark(function n(){return C().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(!(r.media.seeking&&r.media.currentTime===0)){o.next=3;break}return Se.debug("replay currentTime 0, return"),o.abrupt("return");case 3:if(clearTimeout(r._disconnectTimer),!r._reloadOnPlay){o.next=9;break}r._reloadOnPlay=!1,r.replay(!0),o.next=12;break;case 9:return o.next=11,r._loadSegment();case 11:r._startTick();case 12:case"end":return o.stop()}},n)}))),E(W(r),"_onPause",function(){if(r.isLive){if(!r._reloadOnPlay){var n=r.config.disconnectTime;if(n==null&&(n=r._playlist.dvrWindow),!Number.isFinite(n))return;clearTimeout(r._disconnectTimer),r._disconnectTimer=setTimeout(function(){r._reloadOnPlay=!0,r._clear()},n||0)}}else r._stopTick()}),E(W(r),"_onSeeking",Y(C().mark(function n(){var s,o,u,l,c,f,v;return C().wrap(function(p){for(;;)switch(p.prev=p.next){case 0:if(r.media){p.next=2;break}return p.abrupt("return");case 2:if(r._onCheckQuotaExceeded(),s=r.media.currentTime,o=r._playlist.seekRange,!o){p.next=10;break}if(u=Mr(s,o[0],r.isLive?o[1]:r.media.duration),!(u>=0&&Math.abs(s-u)>=.1)){p.next=10;break}return r.media.currentTime=u,p.abrupt("return");case 10:if(l=r._playlist.currentSegment,c=ce.info(ce.get(r.media),s,.1),!l){p.next=15;break}if(!(c.end&&Math.abs(c.end-l.end)<.2)){p.next=15;break}return p.abrupt("return");case 15:if(f=r._playlist.findSegmentIndexByTime(s),v=r._playlist.getSegmentByIndex(f),!(f==null||!v||r._segmentProcessing&&v===r._playlist.nextSegment)){p.next=19;break}return p.abrupt("return");case 19:return Se.debug("seek to",s,v),r._playlist.setNextSegmentByIndex(f),r._stopTick(),p.next=24,r._segmentLoader.cancel();case 24:if(r._segmentProcessing=!1,!(!c.end||r.isLive)){p.next=28;break}return p.next=28,r._loadSegmentDirect(!0);case 28:r._startTick();case 29:case"end":return p.stop()}},n)}))),E(W(r),"_onTimeupdate",function(){if(r.media){var n=r.config;if(n.isLive&&n.maxLatency&&n.targetLatency&&r.media){var s=r._playlist.liveEdge;if(!s)return;var o=s-r.media.currentTime;o>=n.maxLatency&&(Se.debug("latency jump, currentTime:".concat(r.media.currentTime,", liveEdge:").concat(s,", latency=").concat(o)),r.media.currentTime=s-n.targetLatency)}if(n.seiInTime){var u;(u=r._seiService)===null||u===void 0||u.throw(r.media.currentTime)}r.config.allowedStreamTrackChange&&!r.config.softDecode&&r._checkStreamTrackChange(r.media.currentTime)}}),E(W(r),"_tick",function(){if(r.media){r._startTick();var n=r.media,s=ce.get(n),o=r._segmentLoader.error;if(r._onCheckQuotaExceeded(),r._isProcessQuotaExceeded&&(r._bufferService.isFull()||(r._isProcessQuotaExceeded=!1,r._segmentProcessing=!1)),o){var u=.5;(!n.readyState||r.bufferInfo(u).remaining<1)&&(o.fatal=!0,r._emitError(re.network(o)));return}ce.end(s)<.1||!n.readyState||(vn(n)?(r._loadSegment(),r._gapService&&r._gapService.do(n,r.config.maxJumpDistance,r.isLive)):n.readyState<2&&r._gapService&&r._gapService.do(n,r.config.maxJumpDistance,n.currentTime?r.isLive:!0))}}),r.config=t=Qn(t),r.media=r.config.media,r._manifestLoader=new fi(W(r)),r._segmentLoader=new di(W(r)),r._playlist=new hi(W(r)),r._bufferService=new Xn(W(r)),t.seiInTime&&(r._seiService=new yn(W(r))),t.softDecode||(r._gapService=new gn),r._stats=new Sn(W(r),9e4),r.media.addEventListener("play",r._onPlay),r.media.addEventListener("pause",r._onPause),r.media.addEventListener("seeking",r._onSeeking),r.media.addEventListener("timeupdate",r._onTimeupdate),r}return ue(e,[{key:"isLive",get:function(){return this._playlist.isLive}},{key:"streams",get:function(){return this._playlist.streams}},{key:"currentStream",get:function(){return this._playlist.currentStream}},{key:"hasSubtitle",get:function(){return this._playlist.hasSubtitle}},{key:"baseDts",get:function(){var r;return(r=this._bufferService)===null||r===void 0?void 0:r.baseDts}},{key:"speedInfo",value:function(){return this._segmentLoader.speedInfo()}},{key:"bufferInfo",value:function(){var r,n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:.1;return ce.info(ce.get(this.media),(r=this.media)===null||r===void 0?void 0:r.currentTime,n)}},{key:"getStats",value:function(){return this._stats.getStats()}},{key:"playbackQuality",value:function(){return pn(this.media)}},{key:"load",value:function(){var t=Y(C().mark(function n(s){var o,u=arguments;return C().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return o=u.length>1&&u[1]!==void 0?u[1]:!1,s&&(this.config.url=s),s=this.config.url,c.next=5,this._reset(o);case 5:return c.next=7,this._loadData(s);case 7:this._startTick();case 8:case"end":return c.stop()}},n,this)}));function r(n){return t.apply(this,arguments)}return r}()},{key:"_loadData",value:function(){var t=Y(C().mark(function n(s){var o,u,l,c,f,v,h,p,y,d;return C().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:try{s&&(s=s.trim())}catch{}if(s){b.next=3;break}throw this._emitError(new re($.OTHER,$.SUB_TYPES.OPTION,null,null,"m3u8 url is missing"));case 3:return b.next=5,this._loadM3U8(s);case 5:if(o=b.sent,u=this._playlist.currentStream,!this._urlSwitching){b.next=17;break}if(u.bitrate===0&&(l=this._switchUrlOpts)!==null&&l!==void 0&&l.bitrate&&(u.bitrate=(c=this._switchUrlOpts)===null||c===void 0?void 0:c.bitrate),f=this._getSeamlessSwitchPoint(),this.config.startTime=f,v=this._playlist.findSegmentIndexByTime(f),h=this._playlist.getSegmentByIndex(v+1),!h){b.next=17;break}return p=h.start,b.next=17,this._bufferService.removeBuffer(p);case 17:if(o){b.next=19;break}return b.abrupt("return");case 19:if(!this.isLive){b.next=30;break}if(this._bufferService.setLiveSeekableRange(0,4294967295),Se.log("totalDuration first time got:",this._playlist.totalDuration),Se.log("nb segments got:",this._playlist.nbSegments),this.config.targetLatency<this._playlist.totalDuration&&(this.config.targetLatency=this._playlist.totalDuration,this.config.maxLatency=1.5*this.config.targetLatency),o.isMaster||this._pollM3U8(s),!(this._playlist.nbSegments<this.config.minSegmentsStartPlay)){b.next=27;break}return b.abrupt("return");case 27:return b.next=29,this._loadSegment();case 29:return b.abrupt("return");case 30:return b.next=32,this._bufferService.updateDuration(u.totalDuration);case 32:return y=this.config.startTime,y&&((d=this._switchUrlOpts)!==null&&d!==void 0&&d.seamless||(this.media.currentTime=y),this._playlist.setNextSegmentByIndex(this._playlist.findSegmentIndexByTime(y)||0)),b.next=36,this._loadSegment();case 36:case"end":return b.stop()}},n,this)}));function r(n){return t.apply(this,arguments)}return r}()},{key:"replay",value:function(){var t=Y(C().mark(function n(s){return C().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.config.startTime=0,u.next=3,this.load();case 3:return this._reloadOnPlay=!1,u.abrupt("return",this.media.play(!s));case 5:case"end":return u.stop()}},n,this)}));function r(n){return t.apply(this,arguments)}return r}()},{key:"switchURL",value:function(){var t=Y(C().mark(function n(s){var o,u,l,c,f,v,h,p=arguments;return C().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:o=p.length>1&&p[1]!==void 0?p[1]:{},u={seamless:!1,startTime:0,bitrate:0},d.t0=yt(o),d.next=d.t0==="number"?5:d.t0==="boolean"?7:d.t0==="object"?9:11;break;case 5:return o={startTime:o},d.abrupt("break",12);case 7:return o={seamless:o},d.abrupt("break",12);case 9:for(l in o)(o[l]===void 0||o[l]===null)&&delete o[l];return d.abrupt("break",12);case 11:throw"unsupported switchURL args: ".concat(o);case 12:if(o=Object.assign({},u,o),c=o,f=c.seamless,v=c.startTime,this.config.url=s,this.config.startTime=v,this._switchUrlOpts=o,f){d.next=38;break}if(d.prev=18,!this.config.softDecode){d.next=23;break}d.t1=this.load(s),d.next=26;break;case 23:return d.next=25,this.load(s);case 25:d.t1=d.sent;case 26:h=d.t1,d.next=33;break;case 29:throw d.prev=29,d.t2=d.catch(18),this.emit(Q.SWITCH_URL_FAILED,d.t2),d.t2;case 33:return this._reloadOnPlay=!1,h&&this.emit(Q.SWITCH_URL_SUCCESS,{url:s}),d.abrupt("return",this.media.play(!0));case 38:return this._urlSwitching=!0,this._prevSegSn=null,this._prevSegCc=null,this._playlist.reset(),this._bufferService.seamlessSwitch(),d.next=45,this._clear();case 45:return d.next=47,this._loadData(s);case 47:this._startTick();case 48:this._switchUrlOpts=null;case 49:case"end":return d.stop()}},n,this,[[18,29]])}));function r(n){return t.apply(this,arguments)}return r}()},{key:"switchStream",value:function(){var t=Y(C().mark(function n(s){var o,u,l,c,f,v=arguments;return C().wrap(function(p){for(;;)switch(p.prev=p.next){case 0:if(o=v.length>1&&v[1]!==void 0?v[1]:!0,u=this.currentStream,l=this.streams,!(!u||u.id===s||!l||l.length<2)){p.next=5;break}return p.abrupt("return");case 5:if(c=l.find(function(y){return y.id===s}),c){p.next=8;break}return p.abrupt("return");case 8:return p.prev=8,p.next=11,this._clear();case 11:if(!o){p.next=14;break}return p.next=14,this._bufferService.clearAllBuffer();case 14:p.next=19;break;case 16:throw p.prev=16,p.t0=p.catch(8),this._emitError(re.create(p.t0));case 19:if(u.currentAudioStream&&c.audioStreams.length>2&&(f=u.currentAudioStream.id,c.currentAudioStream=c.audioStreams.find(function(y){return y.id===f})||c.currentAudioStream),this._playlist.currentStream=c,p.prev=21,!(this.isLive||!c.segments.length)){p.next=25;break}return p.next=25,this._refreshM3U8();case 25:return this._playlist.setNextSegmentByIndex(this._playlist.findSegmentIndexByTime(this.media.currentTime)||0),this._prevSegCc=null,p.next=29,this._loadSegmentDirect();case 29:p.next=35;break;case 31:throw p.prev=31,p.t1=p.catch(21),this._playlist.currentStream=u,p.t1;case 35:return this._startTick(),p.abrupt("return",c);case 37:case"end":return p.stop()}},n,this,[[8,16],[21,31]])}));function r(n){return t.apply(this,arguments)}return r}()},{key:"switchAudioStream",value:function(){var t=Y(C().mark(function n(s){var o,u,l,c,f=arguments;return C().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(o=f.length>1&&f[1]!==void 0?f[1]:!0,u=this.currentStream,u){h.next=4;break}return h.abrupt("return");case 4:if(l=u.currentAudioStream,!(!l||l.id===s||u.audioStreams.length<2)){h.next=7;break}return h.abrupt("return");case 7:if(c=u.audioStreams.find(function(p){return p.id===s}),c){h.next=10;break}return h.abrupt("return");case 10:return h.prev=10,h.next=13,this._clear();case 13:if(!o){h.next=16;break}return h.next=16,this._bufferService.clearAllBuffer();case 16:h.next=21;break;case 18:throw h.prev=18,h.t0=h.catch(10),this._emitError(re.create(h.t0));case 21:if(u.currentAudioStream=c,h.prev=22,!(this.isLive||!c.segments.length)){h.next=26;break}return h.next=26,this._refreshM3U8();case 26:return this._playlist.setNextSegmentByIndex(this._playlist.findSegmentIndexByTime(this.media.currentTime)||0),this._prevSegCc=null,h.next=30,this._loadSegmentDirect();case 30:h.next=36;break;case 32:throw h.prev=32,h.t1=h.catch(22),u.currentAudioStream=l,h.t1;case 36:return this._startTick(),h.abrupt("return",c);case 38:case"end":return h.stop()}},n,this,[[10,18],[22,32]])}));function r(n){return t.apply(this,arguments)}return r}()},{key:"switchSubtitleStream",value:function(){var t=Y(C().mark(function n(s){return C().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this._playlist.switchSubtitle(s),u.next=3,this._manifestLoader.stopPoll();case 3:return u.next=5,this._refreshM3U8();case 5:case"end":return u.stop()}},n,this)}));function r(n){return t.apply(this,arguments)}return r}()},{key:"destroy",value:function(){var t=Y(C().mark(function n(){var s;return C().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._playlist.reset(),this._segmentLoader.reset(),(s=this._seiService)===null||s===void 0||s.reset(),this.media.removeEventListener("play",this._onPlay),this.media.removeEventListener("pause",this._onPause),this.media.removeEventListener("seeking",this._onSeeking),this.media.removeEventListener("timeupdate",this._onTimeupdate),u.next=12,Promise.all([this._clear(),this._bufferService.destroy()]);case 12:this.media=null;case 13:case"end":return u.stop()}},n,this)}));function r(){return t.apply(this,arguments)}return r}()},{key:"_loadM3U8",value:function(){var t=Y(C().mark(function n(s){var o,u,l,c,f,v,h;return C().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(y.prev=0,c=(u=this.config.manifestList)===null||u===void 0||(l=u.filter(function(d){return d.url===s})[0])===null||l===void 0?void 0:l.manifest,!c){y.next=6;break}y.t0=this._manifestLoader.parseText(c,s),y.next=9;break;case 6:return y.next=8,this._manifestLoader.load(s);case 8:y.t0=y.sent;case 9:f=y.t0,v=we(f,1),o=v[0],y.next=17;break;case 14:throw y.prev=14,y.t1=y.catch(0),this._emitError(re.create(y.t1));case 17:if(o){y.next=19;break}return y.abrupt("return");case 19:if(this._playlist.upsertPlaylist(o),!o.isMaster){y.next=24;break}return(h=this._playlist.currentStream.subtitleStreams)!==null&&h!==void 0&&h.length&&this.emit(Q.SUBTITLE_PLAYLIST,{list:this._playlist.currentStream.subtitleStreams}),y.next=24,this._refreshM3U8();case 24:return this.emit(Q.STREAM_PARSED),y.abrupt("return",o);case 26:case"end":return y.stop()}},n,this,[[0,14]])}));function r(n){return t.apply(this,arguments)}return r}()},{key:"_refreshM3U8",value:function(){var r,n,s=this,o=this._playlist.currentStream;if(!o||!o.url)throw this._emitError(re.create(null,null,new Error("m3u8 url is not defined")));var u=o.url,l=(r=o.currentAudioStream)===null||r===void 0?void 0:r.url,c=(n=o.currentSubtitleStream)===null||n===void 0?void 0:n.url;return this._manifestLoader.load(u,l,c).then(function(f){var v=we(f,3),h=v[0],p=v[1],y=v[2];h&&(s._playlist.upsertPlaylist(h,p,y),s.isLive&&s._pollM3U8(u,l,c))}).catch(function(f){throw s._emitError(re.create(f))})}},{key:"_pollM3U8",value:function(r,n,s){var o=this,u=this._playlist.isEmpty,l;if(this._playlist.lowLatency)l=(this._playlist.currentStream.partTargetDuration*2||0)*1e3;else{var c;l=(((c=this._playlist.lastSegment)===null||c===void 0?void 0:c.duration)||0)*1e3}this._manifestLoader.poll(r,n,s,function(f,v,h){o._playlist.upsertPlaylist(f,v,h),o._playlist.clearOldSegment();var p=f&&u&&!o._playlist.isEmpty;(p||!o._playlist.hadSegmentLoaded&&o._playlist.nbSegments>=o.config.minSegmentsStartPlay)&&o._loadSegment(),u&&(u=o._playlist.isEmpty)},function(f){o._emitError(re.create(f))},l)}},{key:"_loadSegmentDirect",value:function(){var t=Y(C().mark(function n(s){var o,u,l;return C().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(o=this._playlist.nextSegment,o){f.next=3;break}return f.abrupt("return");case 3:return u=!1,l=null,f.prev=5,this._segmentProcessing=!0,Se.log("load segment, sn:".concat(o.sn,", partIndex:").concat(o.partIndex)),f.next=10,this._reqAndBufferSegment(o,this._playlist.getAudioSegment(o));case 10:u=f.sent,f.next=16;break;case 13:f.prev=13,f.t0=f.catch(5),l=f.t0;case 16:return f.prev=16,this._segmentProcessing=!1,f.finish(16);case 19:if(!l){f.next=26;break}if(!this._bufferService.isFull()){f.next=25;break}return Se.log("load segment, sn:".concat(o.sn,", partIndex:").concat(o.partIndex)),this._segmentProcessing=!0,this._isProcessQuotaExceeded=!0,f.abrupt("return",!1);case 25:return f.abrupt("return",this._emitError(re.create(l)));case 26:return u&&(this._urlSwitching&&(this._urlSwitching=!1,this.emit(Q.SWITCH_URL_SUCCESS,{url:this.config.url})),this._playlist.moveSegmentPointer(),o.isLast?this._end():s||this._loadSegment()),f.abrupt("return",u);case 28:case"end":return f.stop()}},n,this,[[5,13,16,19]])}));function r(n){return t.apply(this,arguments)}return r}()},{key:"_reqAndBufferSegment",value:function(){var t=Y(C().mark(function n(s,o){var u,l,c,f,v,h,p,y,d;return C().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return l=s?s.cc:o.cc,c=this._prevSegCc!==l,f=[],b.prev=3,b.next=6,this._segmentLoader.load(s,o,c);case 6:f=b.sent,b.next=14;break;case 9:throw b.prev=9,b.t0=b.catch(3),b.t0.fatal=!1,this._segmentLoader.error=b.t0,b.t0;case 14:if(f[0]){b.next=16;break}return b.abrupt("return");case 16:return b.next=18,(u=this._bufferService).decryptBuffer.apply(u,Fr(f));case 18:if(v=b.sent,v){b.next=21;break}return b.abrupt("return");case 21:return h=s?s.sn:o.sn,p=s?s.start:o.start,y=this._playlist.currentStream,this._bufferService.createSource(v[0],v[1],y?.videoCodec,y?.audioCodec),d=Date.now(),b.next=28,this._bufferService.appendBuffer(s,o,v[0],v[1],c,this._prevSegSn===h-1,p);case 28:return this.emit(Q.APPEND_COST,{elapsed:Date.now()-d,url:s.url}),b.next=31,this._bufferService.evictBuffer(this.config.bufferBehind);case 31:return this._prevSegCc=l,this._prevSegSn=h,b.abrupt("return",!0);case 34:case"end":return b.stop()}},n,this,[[3,9]])}));function r(n,s){return t.apply(this,arguments)}return r}()},{key:"_onCheckQuotaExceeded",value:function(){var t=Y(C().mark(function n(){var s,o,u,l,c,f;return C().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:s=this.media.currentTime,o=this.media.buffered,u=!1,l=0;case 4:if(!(l<o.length)){h.next=11;break}if(!(o.start(0)>=s&&s<o.end(l))){h.next=8;break}return u=!0,h.abrupt("break",11);case 8:l++,h.next=4;break;case 11:if(!this._bufferService.isFull()){h.next=17;break}if(c=u?this.config.bufferBehind:5,f=this.media.currentTime,!(f-c>0)){h.next=17;break}return h.next=17,this._bufferService.removeBuffer(0,f-c);case 17:case"end":return h.stop()}},n,this)}));function r(){return t.apply(this,arguments)}return r}()},{key:"_checkStreamTrackChange",value:function(r){var n=this._playlist.checkSegmentTrackChange(r,this._bufferService.nbSb);n&&this.switchURL(this.config.url,n.start+.2)}},{key:"_clear",value:function(){var t=Y(C().mark(function n(){return C().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return clearTimeout(this._disconnectTimer),this._stopTick(),o.next=4,Promise.all([this._segmentLoader.cancel(),this._manifestLoader.stopPoll()]);case 4:this._segmentProcessing=!1;case 5:case"end":return o.stop()}},n,this)}));function r(){return t.apply(this,arguments)}return r}()},{key:"_reset",value:function(){var t=Y(C().mark(function n(){var s,o,u=arguments;return C().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return o=u.length>0&&u[0]!==void 0?u[0]:!1,this._reloadOnPlay=!1,this._prevSegSn=null,this._prevSegCc=null,this._switchUrlOpts=null,this._playlist.reset(),this._segmentLoader.reset(),(s=this._seiService)===null||s===void 0||s.reset(),this._stats.reset(),c.next=11,this._clear();case 11:return c.abrupt("return",this._bufferService.reset(o));case 12:case"end":return c.stop()}},n,this)}));function r(){return t.apply(this,arguments)}return r}()},{key:"_end",value:function(){this._clear(),this._bufferService.endOfStream(),(this.media.readyState<=2||this.media.buffered.length>1)&&this._startTick()}},{key:"_stopTick",value:function(){this._tickTimer&&clearTimeout(this._tickTimer),this._tickTimer=null}},{key:"_startTick",value:function(){this._stopTick(),this._tickTimer=setTimeout(this._tick,this._tickInterval)}},{key:"_emitError",value:function(r){var n,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(((n=r.originError)===null||n===void 0?void 0:n.fatal)===!1)Se.warn(r);else{var o,u,l;Se.table(r),Se.error(r),Se.error((o=this.media)===null||o===void 0?void 0:o.error),(u=this.media)!==null&&u!==void 0&&u.readyState&&this.media.pause(),this._stopTick(),this._urlSwitching&&(this._urlSwitching=!1,this.emit(Q.SWITCH_URL_FAILED,r)),this.emit(Q.ERROR,r),s&&this._end(),(l=this._seiService)===null||l===void 0||l.reset()}return r}},{key:"_getSeamlessSwitchPoint",value:function(){var r=this.media,n=r.currentTime;if(!r.paused){var s,o=this._playlist.findSegmentIndexByTime(r.currentTime),u=this._playlist.getSegmentByIndex(o),l=(s=this._stats)===null||s===void 0?void 0:s.getStats().downloadSpeed;if(l&&u){var c=u.duration*this._playlist.currentStream.bitrate/l+1;n+=c}else n+=5}return n}}],[{key:"isSupported",value:function(r){return!r||r==="video"||r==="audio"?ve.isSupported():typeof WebAssembly<"u"}},{key:"enableLogger",value:function(){be.enable(),ot.enable()}},{key:"disableLogger",value:function(){be.disable(),ot.disable()}}]),e}(Kr);E(qe,"version","3.0.16");try{localStorage.getItem("xgd")?qe.enableLogger():qe.disableLogger()}catch{}export{qe as Hls,qe as default};