@mux/playback-core 0.10.0 → 0.11.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.
@@ -1,30 +1,30 @@
1
- (()=>{var Lt=Object.create;var tt=Object.defineProperty;var Ot=Object.getOwnPropertyDescriptor;var Rt=Object.getOwnPropertyNames;var Pt=Object.getPrototypeOf,bt=Object.prototype.hasOwnProperty;var It=N=>tt(N,"__esModule",{value:!0});var mt=(N,I)=>()=>(I||N((I={exports:{}}).exports,I),I.exports);var Mt=(N,I,c)=>{if(I&&typeof I=="object"||typeof I=="function")for(let R of Rt(I))!bt.call(N,R)&&R!=="default"&&tt(N,R,{get:()=>I[R],enumerable:!(c=Ot(I,R))||c.enumerable});return N},Ve=N=>Mt(It(tt(N!=null?Lt(Pt(N)):{},"default",N&&N.__esModule&&"default"in N?{get:()=>N.default,enumerable:!0}:{value:N,enumerable:!0})),N);var pt=mt((Ye,rt)=>{(function(){var N=!1;(function(I,c){typeof Ye=="object"&&typeof rt=="object"?rt.exports=c():typeof N=="function"&&N.amd?N("mux",[],c):typeof Ye=="object"?Ye.mux=c():I.mux=c()})(typeof self!="undefined"?self:this,function(){return function(I){function c(y){if(R[y])return R[y].exports;var x=R[y]={i:y,l:!1,exports:{}};return I[y].call(x.exports,x,x.exports,c),x.l=!0,x.exports}var R={};return c.m=I,c.c=R,c.d=function(y,x,b){c.o(y,x)||Object.defineProperty(y,x,{configurable:!1,enumerable:!0,get:b})},c.n=function(y){var x=y&&y.__esModule?function(){return y.default}:function(){return y};return c.d(x,"a",x),x},c.o=function(y,x){return Object.prototype.hasOwnProperty.call(y,x)},c.p="",c(c.s=18)}([function(I,c,R){(function(y){var x;x=typeof window!="undefined"?window:y!==void 0?y:typeof self!="undefined"?self:{},I.exports=x}).call(c,R(20))},function(I,c){function R(C,U,w){switch(w.length){case 0:return C.call(U);case 1:return C.call(U,w[0]);case 2:return C.call(U,w[0],w[1]);case 3:return C.call(U,w[0],w[1],w[2])}return C.apply(U,w)}function y(C,U){for(var w=-1,k=Array(C);++w<C;)k[w]=U(w);return k}function x(C,U){var w=F(C)||v(C)?y(C.length,String):[],k=w.length,j=!!k;for(var K in C)!U&&!o.call(C,K)||j&&(K=="length"||g(K,k))||w.push(K);return w}function b(C,U,w){var k=C[U];o.call(C,U)&&S(k,w)&&(w!==void 0||U in C)||(C[U]=w)}function T(C){if(!D(C))return O(C);var U=[];for(var w in Object(C))o.call(C,w)&&w!="constructor"&&U.push(w);return U}function L(C,U){return U=P(U===void 0?C.length-1:U,0),function(){for(var w=arguments,k=-1,j=P(w.length-U,0),K=Array(j);++k<j;)K[k]=w[U+k];k=-1;for(var G=Array(U+1);++k<U;)G[k]=w[k];return G[U]=K,R(C,this,G)}}function _(C,U,w,k){w||(w={});for(var j=-1,K=U.length;++j<K;){var G=U[j],Y=k?k(w[G],C[G],G,w,C):void 0;b(w,G,Y===void 0?C[G]:Y)}return w}function g(C,U){return!!(U=U==null?n:U)&&(typeof C=="number"||f.test(C))&&C>-1&&C%1==0&&C<U}function A(C,U,w){if(!t(w))return!1;var k=typeof U;return!!(k=="number"?p(w)&&g(U,w.length):k=="string"&&U in w)&&S(w[U],C)}function D(C){var U=C&&C.constructor;return C===(typeof U=="function"&&U.prototype||l)}function S(C,U){return C===U||C!==C&&U!==U}function v(C){return s(C)&&o.call(C,"callee")&&(!m.call(C,"callee")||E.call(C)==h)}function p(C){return C!=null&&i(C.length)&&!e(C)}function s(C){return r(C)&&p(C)}function e(C){var U=t(C)?E.call(C):"";return U==d||U==u}function i(C){return typeof C=="number"&&C>-1&&C%1==0&&C<=n}function t(C){var U=typeof C;return!!C&&(U=="object"||U=="function")}function r(C){return!!C&&typeof C=="object"}function a(C){return p(C)?x(C):T(C)}var n=9007199254740991,h="[object Arguments]",d="[object Function]",u="[object GeneratorFunction]",f=/^(?:0|[1-9]\d*)$/,l=Object.prototype,o=l.hasOwnProperty,E=l.toString,m=l.propertyIsEnumerable,O=function(C,U){return function(w){return C(U(w))}}(Object.keys,Object),P=Math.max,M=!m.call({valueOf:1},"valueOf"),F=Array.isArray,B=function(C){return L(function(U,w){var k=-1,j=w.length,K=j>1?w[j-1]:void 0,G=j>2?w[2]:void 0;for(K=C.length>3&&typeof K=="function"?(j--,K):void 0,G&&A(w[0],w[1],G)&&(K=j<3?void 0:K,j=1),U=Object(U);++k<j;){var Y=w[k];Y&&C(U,Y,k,K)}return U})}(function(C,U){if(M||D(U)||p(U))return void _(U,a(U),C);for(var w in U)o.call(U,w)&&b(C,w,U[w])});I.exports=B},function(I,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y=R(0),x=function(T){return T&&T.__esModule?T:{default:T}}(y),b={};b.now=function(){var T=x.default.performance,L=T&&T.timing;return L&&typeof L.navigationStart=="number"&&typeof T.now=="function"?L.navigationStart+T.now():Date.now()},c.default=b},function(I,c,R){"use strict";function y(x,b,T){T=T===void 0?1:T,x[b]=x[b]||0,x[b]+=T}Object.defineProperty(c,"__esModule",{value:!0}),c.default=y},function(I,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y=R(21),x=function(T){return T&&T.__esModule?T:{default:T}}(y),b=x.default.methodFactory;x.default.methodFactory=function(T,L,_){var g=b(T,L,_);return function(){for(var A=["[mux]"],D=0;D<arguments.length;D++)A.push(arguments[D]);g.apply(void 0,A)}},x.default.setLevel(x.default.getLevel()),c.default=x.default},function(I,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y=function(T){return b(T)[0]},x=function(T){return b(T)[1]},b=function(T){if(typeof T!="string"||T==="")return["localhost"];var L=/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,_=T.match(L)||[],g=_[4],A=void 0;return g&&(A=(g.match(/[^\.]+\.[^\.]+$/)||[])[0]),[g,A]};c.extractHostnameAndDomain=b,c.extractHostname=y,c.extractDomain=x},function(I,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(b){var T=16*Math.random()|0;return(b==="x"?T:3&T|8).toString(16)})},x=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)};c.generateUUID=y,c.generateShortID=x},function(I,c,R){"use strict";function y(b){b=b||"";var T={};return b.trim().split(/[\r\n]+/).forEach(function(L){if(L){var _=L.split(": "),g=_.shift();g&&(x.indexOf(g.toLowerCase())>=0||g.toLowerCase().indexOf("x-litix-")===0)&&(T[g]=_.join(": "))}}),T}Object.defineProperty(c,"__esModule",{value:!0}),c.default=y;var x=["x-cdn","content-type"]},function(I,c,R){"use strict";var y=SyntaxError,x=Function,b=TypeError,T=function(o){try{return x('"use strict"; return ('+o+").constructor;")()}catch{}},L=Object.getOwnPropertyDescriptor;if(L)try{L({},"")}catch{L=null}var _=function(){throw new b},g=L?function(){try{return arguments.callee,_}catch{try{return L(arguments,"callee").get}catch{return _}}}():_,A=R(43)(),D=Object.getPrototypeOf||function(o){return o.__proto__},S={},v=typeof Uint8Array=="undefined"?void 0:D(Uint8Array),p={"%AggregateError%":typeof AggregateError=="undefined"?void 0:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer=="undefined"?void 0:ArrayBuffer,"%ArrayIteratorPrototype%":A?D([][Symbol.iterator]()):void 0,"%AsyncFromSyncIteratorPrototype%":void 0,"%AsyncFunction%":S,"%AsyncGenerator%":S,"%AsyncGeneratorFunction%":S,"%AsyncIteratorPrototype%":S,"%Atomics%":typeof Atomics=="undefined"?void 0:Atomics,"%BigInt%":typeof BigInt=="undefined"?void 0:BigInt,"%Boolean%":Boolean,"%DataView%":typeof DataView=="undefined"?void 0:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array=="undefined"?void 0:Float32Array,"%Float64Array%":typeof Float64Array=="undefined"?void 0:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry=="undefined"?void 0:FinalizationRegistry,"%Function%":x,"%GeneratorFunction%":S,"%Int8Array%":typeof Int8Array=="undefined"?void 0:Int8Array,"%Int16Array%":typeof Int16Array=="undefined"?void 0:Int16Array,"%Int32Array%":typeof Int32Array=="undefined"?void 0:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":A?D(D([][Symbol.iterator]())):void 0,"%JSON%":typeof JSON=="object"?JSON:void 0,"%Map%":typeof Map=="undefined"?void 0:Map,"%MapIteratorPrototype%":typeof Map!="undefined"&&A?D(new Map()[Symbol.iterator]()):void 0,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise=="undefined"?void 0:Promise,"%Proxy%":typeof Proxy=="undefined"?void 0:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect=="undefined"?void 0:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set=="undefined"?void 0:Set,"%SetIteratorPrototype%":typeof Set!="undefined"&&A?D(new Set()[Symbol.iterator]()):void 0,"%SharedArrayBuffer%":typeof SharedArrayBuffer=="undefined"?void 0:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":A?D(""[Symbol.iterator]()):void 0,"%Symbol%":A?Symbol:void 0,"%SyntaxError%":y,"%ThrowTypeError%":g,"%TypedArray%":v,"%TypeError%":b,"%Uint8Array%":typeof Uint8Array=="undefined"?void 0:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray=="undefined"?void 0:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array=="undefined"?void 0:Uint16Array,"%Uint32Array%":typeof Uint32Array=="undefined"?void 0:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap=="undefined"?void 0:WeakMap,"%WeakRef%":typeof WeakRef=="undefined"?void 0:WeakRef,"%WeakSet%":typeof WeakSet=="undefined"?void 0:WeakSet},s=function o(E){var m;if(E==="%AsyncFunction%")m=T("async function () {}");else if(E==="%GeneratorFunction%")m=T("function* () {}");else if(E==="%AsyncGeneratorFunction%")m=T("async function* () {}");else if(E==="%AsyncGenerator%"){var O=o("%AsyncGeneratorFunction%");O&&(m=O.prototype)}else if(E==="%AsyncIteratorPrototype%"){var P=o("%AsyncGenerator%");P&&(m=D(P.prototype))}return p[E]=m,m},e={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},i=R(9),t=R(46),r=i.call(Function.call,Array.prototype.concat),a=i.call(Function.apply,Array.prototype.splice),n=i.call(Function.call,String.prototype.replace),h=i.call(Function.call,String.prototype.slice),d=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,u=/\\(\\)?/g,f=function(o){var E=h(o,0,1),m=h(o,-1);if(E==="%"&&m!=="%")throw new y("invalid intrinsic syntax, expected closing `%`");if(m==="%"&&E!=="%")throw new y("invalid intrinsic syntax, expected opening `%`");var O=[];return n(o,d,function(P,M,F,B){O[O.length]=F?n(B,u,"$1"):M||P}),O},l=function(o,E){var m,O=o;if(t(e,O)&&(m=e[O],O="%"+m[0]+"%"),t(p,O)){var P=p[O];if(P===S&&(P=s(O)),P===void 0&&!E)throw new b("intrinsic "+o+" exists, but is not available. Please file an issue!");return{alias:m,name:O,value:P}}throw new y("intrinsic "+o+" does not exist!")};I.exports=function(o,E){if(typeof o!="string"||o.length===0)throw new b("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof E!="boolean")throw new b('"allowMissing" argument must be a boolean');var m=f(o),O=m.length>0?m[0]:"",P=l("%"+O+"%",E),M=P.name,F=P.value,B=!1,C=P.alias;C&&(O=C[0],a(m,r([0,1],C)));for(var U=1,w=!0;U<m.length;U+=1){var k=m[U],j=h(k,0,1),K=h(k,-1);if((j==='"'||j==="'"||j==="`"||K==='"'||K==="'"||K==="`")&&j!==K)throw new y("property names with quotes must have matching quotes");if(k!=="constructor"&&w||(B=!0),O+="."+k,M="%"+O+"%",t(p,M))F=p[M];else if(F!=null){if(!(k in F)){if(!E)throw new b("base intrinsic for "+o+" exists, but the property is not available.");return}if(L&&U+1>=m.length){var G=L(F,k);w=!!G,F=w&&"get"in G&&!("originalValue"in G.get)?G.get:F[k]}else w=t(F,k),F=F[k];w&&!B&&(p[M]=F)}}return F}},function(I,c,R){"use strict";var y=R(45);I.exports=Function.prototype.bind||y},function(I,c,R){"use strict";var y=String.prototype.replace,x=/%20/g,b={RFC1738:"RFC1738",RFC3986:"RFC3986"};I.exports={default:b.RFC3986,formatters:{RFC1738:function(T){return y.call(T,x,"+")},RFC3986:function(T){return String(T)}},RFC1738:b.RFC1738,RFC3986:b.RFC3986}},function(I,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0}),c.findMediaElement=c.getMuxPlayerId=void 0;var y=R(6),x=function(T){return T&&T.nodeName!==void 0?(T.muxId||(T.muxId=T.id||(0,y.generateShortID)()),T.muxId):T},b=function(T){var L=void 0;return T&&T.nodeName!==void 0?(L=T,T=x(L)):L=document.querySelector(T),[L,T,L&&L.nodeName?L.nodeName.toLowerCase():""]};c.getMuxPlayerId=x,c.findMediaElement=b},function(I,c,R){"use strict";function y(){return(b.default.doNotTrack||b.default.navigator&&(b.default.navigator.doNotTrack||b.default.navigator.msDoNotTrack))==="1"}Object.defineProperty(c,"__esModule",{value:!0}),c.default=y;var x=R(0),b=function(T){return T&&T.__esModule?T:{default:T}}(x)},function(I,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y=R(0),x=function(T){return T&&T.__esModule?T:{default:T}}(y),b={};b.exists=function(){var T=x.default.performance;return(T&&T.timing)!==void 0},b.domContentLoadedEventEnd=function(){var T=x.default.performance,L=T&&T.timing;return L&&L.domContentLoadedEventEnd},b.navigationStart=function(){var T=x.default.performance,L=T&&T.timing;return L&&L.navigationStart},c.default=b},function(I,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y=function(x){var b={};for(var T in x){var L=x[T];L["DATA-ID"].search("io.litix.data.")!==-1&&(b[L["DATA-ID"].replace("io.litix.data.","")]=L.VALUE)}return b};c.default=y},function(I,c,R){"use strict";var y=R(41),x=R(51),b=R(10);I.exports={formats:b,parse:x,stringify:y}},function(I,c,R){"use strict";var y=R(10),x=Object.prototype.hasOwnProperty,b=Array.isArray,T=function(){for(var t=[],r=0;r<256;++r)t.push("%"+((r<16?"0":"")+r.toString(16)).toUpperCase());return t}(),L=function(t){for(;t.length>1;){var r=t.pop(),a=r.obj[r.prop];if(b(a)){for(var n=[],h=0;h<a.length;++h)a[h]!==void 0&&n.push(a[h]);r.obj[r.prop]=n}}},_=function(t,r){for(var a=r&&r.plainObjects?Object.create(null):{},n=0;n<t.length;++n)t[n]!==void 0&&(a[n]=t[n]);return a},g=function t(r,a,n){if(!a)return r;if(typeof a!="object"){if(b(r))r.push(a);else{if(!r||typeof r!="object")return[r,a];(n&&(n.plainObjects||n.allowPrototypes)||!x.call(Object.prototype,a))&&(r[a]=!0)}return r}if(!r||typeof r!="object")return[r].concat(a);var h=r;return b(r)&&!b(a)&&(h=_(r,n)),b(r)&&b(a)?(a.forEach(function(d,u){if(x.call(r,u)){var f=r[u];f&&typeof f=="object"&&d&&typeof d=="object"?r[u]=t(f,d,n):r.push(d)}else r[u]=d}),r):Object.keys(a).reduce(function(d,u){var f=a[u];return x.call(d,u)?d[u]=t(d[u],f,n):d[u]=f,d},h)},A=function(t,r){return Object.keys(r).reduce(function(a,n){return a[n]=r[n],a},t)},D=function(t,r,a){var n=t.replace(/\+/g," ");if(a==="iso-8859-1")return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch{return n}},S=function(t,r,a,n,h){if(t.length===0)return t;var d=t;if(typeof t=="symbol"?d=Symbol.prototype.toString.call(t):typeof t!="string"&&(d=String(t)),a==="iso-8859-1")return escape(d).replace(/%u[0-9a-f]{4}/gi,function(o){return"%26%23"+parseInt(o.slice(2),16)+"%3B"});for(var u="",f=0;f<d.length;++f){var l=d.charCodeAt(f);l===45||l===46||l===95||l===126||l>=48&&l<=57||l>=65&&l<=90||l>=97&&l<=122||h===y.RFC1738&&(l===40||l===41)?u+=d.charAt(f):l<128?u+=T[l]:l<2048?u+=T[192|l>>6]+T[128|63&l]:l<55296||l>=57344?u+=T[224|l>>12]+T[128|l>>6&63]+T[128|63&l]:(f+=1,l=65536+((1023&l)<<10|1023&d.charCodeAt(f)),u+=T[240|l>>18]+T[128|l>>12&63]+T[128|l>>6&63]+T[128|63&l])}return u},v=function(t){for(var r=[{obj:{o:t},prop:"o"}],a=[],n=0;n<r.length;++n)for(var h=r[n],d=h.obj[h.prop],u=Object.keys(d),f=0;f<u.length;++f){var l=u[f],o=d[l];typeof o=="object"&&o!==null&&a.indexOf(o)===-1&&(r.push({obj:d,prop:l}),a.push(o))}return L(r),t},p=function(t){return Object.prototype.toString.call(t)==="[object RegExp]"},s=function(t){return!(!t||typeof t!="object")&&!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},e=function(t,r){return[].concat(t,r)},i=function(t,r){if(b(t)){for(var a=[],n=0;n<t.length;n+=1)a.push(r(t[n]));return a}return r(t)};I.exports={arrayToObject:_,assign:A,combine:e,compact:v,decode:D,encode:S,isBuffer:s,isRegExp:p,maybeMap:i,merge:g}},function(I,c,R){"use strict";function y(p){return p&&p.__esModule?p:{default:p}}function x(p){var s={};for(var e in p)p.hasOwnProperty(e)&&(s[p[e]]=e);return s}function b(p){var s={},e={};return Object.keys(p).forEach(function(i){var t=!1;if(p.hasOwnProperty(i)&&p[i]!==void 0){var r=i.split("_"),a=r[0],n=D[a];n||(L.default.info("Data key word `"+r[0]+"` not expected in "+i),n=a+"_"),r.splice(1).forEach(function(h){h==="url"&&(t=!0),v[h]?n+=v[h]:Number(h)&&Math.floor(Number(h))===Number(h)?n+=h:(L.default.info("Data key word `"+h+"` not expected in "+i),n+="_"+h+"_")}),t?e[n]=p[i]:s[n]=p[i]}}),(0,g.default)(s,e)}Object.defineProperty(c,"__esModule",{value:!0}),c.default=b;var T=R(4),L=y(T),_=R(1),g=y(_),A={a:"env",b:"beacon",c:"custom",d:"ad",e:"event",f:"experiment",i:"internal",m:"mux",n:"response",p:"player",q:"request",r:"retry",s:"session",t:"timestamp",u:"viewer",v:"video",w:"page",x:"view",y:"sub"},D=x(A),S={ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",ca:"cached",cb:"cancel",cd:"code",cg:"category",ch:"changed",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ep:"experiments",fi:"first",fm:"family",ft:"format",fq:"frequency",fr:"frame",fs:"fullscreen",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"},v=x(S)},function(I,c,R){"use strict";I.exports=R(19).default},function(I,c,R){"use strict";function y(u){return u&&u.__esModule?u:{default:u}}Object.defineProperty(c,"__esModule",{value:!0});var x=function(){function u(f,l){var o=[],E=!0,m=!1,O=void 0;try{for(var P,M=f[Symbol.iterator]();!(E=(P=M.next()).done)&&(o.push(P.value),!l||o.length!==l);E=!0);}catch(F){m=!0,O=F}finally{try{!E&&M.return&&M.return()}finally{if(m)throw O}}return o}return function(f,l){if(Array.isArray(f))return f;if(Symbol.iterator in Object(f))return u(f,l);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),b=R(0),T=y(b),L=R(11),_=R(4),g=y(_),A=R(12),D=y(A),S=R(2),v=y(S),p=R(22),s=y(p),e=R(58),i=y(e),t=R(59),r=y(t),a=R(64),n=y(a),h={},d=function u(f){var l=arguments;typeof f=="string"?u.hasOwnProperty(f)?T.default.setTimeout(function(){l=Array.prototype.splice.call(l,1),u[f].apply(null,l)},0):g.default.warn("`"+f+"` is an unknown task"):typeof f=="function"?T.default.setTimeout(function(){f(u)},0):g.default.warn("`"+f+"` is invalid.")};d.loaded=v.default.now(),d.NAME="mux-embed",d.VERSION="4.8.0",d.API_VERSION="2.1",d.PLAYER_TRACKED=!1,d.monitor=function(u,f){return(0,i.default)(d,u,f)},d.destroyMonitor=function(u){var f=(0,L.findMediaElement)(u),l=x(f,1),o=l[0];o&&o.mux&&typeof o.mux.destroy=="function"?o.mux.destroy():g.default.error("A video element monitor for `"+u+"` has not been initialized via `mux.monitor`.")},d.addHLSJS=function(u,f){var l=(0,L.getMuxPlayerId)(u);h[l]?h[l].addHLSJS(f):g.default.error("A monitor for `"+l+"` has not been initialized.")},d.addDashJS=function(u,f){var l=(0,L.getMuxPlayerId)(u);h[l]?h[l].addDashJS(f):g.default.error("A monitor for `"+l+"` has not been initialized.")},d.removeHLSJS=function(u){var f=(0,L.getMuxPlayerId)(u);h[f]?h[f].removeHLSJS():g.default.error("A monitor for `"+f+"` has not been initialized.")},d.removeDashJS=function(u){var f=(0,L.getMuxPlayerId)(u);h[f]?h[f].removeDashJS():g.default.error("A monitor for `"+f+"` has not been initialized.")},d.init=function(u,f){(0,D.default)()&&f&&f.respectDoNotTrack&&g.default.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var l=(0,L.getMuxPlayerId)(u);h[l]=new s.default(d,l,f)},d.emit=function(u,f,l){var o=(0,L.getMuxPlayerId)(u);h[o]?(h[o].emit(f,l),f==="destroy"&&delete h[o]):g.default.error("A monitor for `"+o+"` has not been initialized.")},T.default!==void 0&&typeof T.default.addEventListener=="function"&&T.default.addEventListener("pagehide",function(u){u.persisted||(d.WINDOW_UNLOADING=!0)},!1),d.checkDoNotTrack=D.default,d.log=g.default,d.utils=r.default,d.events=n.default,c.default=d},function(I,c){var R;R=function(){return this}();try{R=R||Function("return this")()||(0,eval)("this")}catch{typeof window=="object"&&(R=window)}I.exports=R},function(I,c,R){var y,x;(function(b,T){"use strict";y=T,(x=typeof y=="function"?y.call(c,R,c,I):y)!==void 0&&(I.exports=x)})(0,function(){"use strict";function b(r,a){var n=r[a];if(typeof n.bind=="function")return n.bind(r);try{return Function.prototype.bind.call(n,r)}catch{return function(){return Function.prototype.apply.apply(n,[r,arguments])}}}function T(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function L(r){return r==="debug"&&(r="log"),typeof console!==v&&(r==="trace"&&p?T:console[r]!==void 0?b(console,r):console.log!==void 0?b(console,"log"):S)}function _(r,a){for(var n=0;n<s.length;n++){var h=s[n];this[h]=n<r?S:this.methodFactory(h,r,a)}this.log=this.debug}function g(r,a,n){return function(){typeof console!==v&&(_.call(this,a,n),this[r].apply(this,arguments))}}function A(r,a,n){return L(r)||g.apply(this,arguments)}function D(r,a,n){function h(m){var O=(s[m]||"silent").toUpperCase();if(typeof window!==v&&o){try{return void(window.localStorage[o]=O)}catch{}try{window.document.cookie=encodeURIComponent(o)+"="+O+";"}catch{}}}function d(){var m;if(typeof window!==v&&o){try{m=window.localStorage[o]}catch{}if(typeof m===v)try{var O=window.document.cookie,P=O.indexOf(encodeURIComponent(o)+"=");P!==-1&&(m=/^([^;]+)/.exec(O.slice(P))[1])}catch{}return l.levels[m]===void 0&&(m=void 0),m}}function u(){if(typeof window!==v&&o){try{return void window.localStorage.removeItem(o)}catch{}try{window.document.cookie=encodeURIComponent(o)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}var f,l=this;a=a==null?"WARN":a;var o="loglevel";typeof r=="string"?o+=":"+r:typeof r=="symbol"&&(o=void 0),l.name=r,l.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},l.methodFactory=n||A,l.getLevel=function(){return f},l.setLevel=function(m,O){if(typeof m=="string"&&l.levels[m.toUpperCase()]!==void 0&&(m=l.levels[m.toUpperCase()]),!(typeof m=="number"&&m>=0&&m<=l.levels.SILENT))throw"log.setLevel() called with invalid level: "+m;if(f=m,O!==!1&&h(m),_.call(l,m,r),typeof console===v&&m<l.levels.SILENT)return"No console available for logging"},l.setDefaultLevel=function(m){a=m,d()||l.setLevel(m,!1)},l.resetLevel=function(){l.setLevel(a,!1),u()},l.enableAll=function(m){l.setLevel(l.levels.TRACE,m)},l.disableAll=function(m){l.setLevel(l.levels.SILENT,m)};var E=d();E==null&&(E=a),l.setLevel(E,!1)}var S=function(){},v="undefined",p=typeof window!==v&&typeof window.navigator!==v&&/Trident\/|MSIE /.test(window.navigator.userAgent),s=["trace","debug","info","warn","error"],e=new D,i={};e.getLogger=function(r){if(typeof r!="symbol"&&typeof r!="string"||r==="")throw new TypeError("You must supply a name when creating a logger.");var a=i[r];return a||(a=i[r]=new D(r,e.getLevel(),e.methodFactory)),a};var t=typeof window!==v?window.log:void 0;return e.noConflict=function(){return typeof window!==v&&window.log===e&&(window.log=t),e},e.getLoggers=function(){return i},e.default=e,e})},function(I,c,R){"use strict";function y(J){return J&&J.__esModule?J:{default:J}}Object.defineProperty(c,"__esModule",{value:!0});var x=function(){function J($,Q){var se=[],he=!0,ue=!1,fe=void 0;try{for(var ge,Ee=$[Symbol.iterator]();!(he=(ge=Ee.next()).done)&&(se.push(ge.value),!Q||se.length!==Q);he=!0);}catch(oe){ue=!0,fe=oe}finally{try{!he&&Ee.return&&Ee.return()}finally{if(ue)throw fe}}return se}return function($,Q){if(Array.isArray($))return $;if(Symbol.iterator in Object($))return J($,Q);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),b=R(4),T=y(b),L=R(1),_=y(L),g=R(6),A=R(5),D=R(0),S=y(D),v=R(13),p=y(v),s=R(3),e=y(s),i=R(23),t=R(24),r=R(25),a=y(r),n=R(26),h=y(n),d=R(27),u=y(d),f=R(28),l=y(f),o=R(29),E=y(o),m=R(30),O=y(m),P=R(31),M=y(P),F=R(32),B=y(F),C=R(33),U=y(C),w=R(34),k=y(w),j=R(35),K=y(j),G=R(36),Y=y(G),V=R(37),Z=y(V),z=R(38),ie=y(z),X=R(39),ee=y(X),ce=R(57),ae=y(ce),ve=["viewstart","ended","loadstart","pause","play","playing","ratechange","waiting","adplay","adpause","adended","aderror","adplaying","adrequest","adresponse","adbreakstart","adbreakend","adfirstquartile","admidpoint","adthirdquartile","rebufferstart","rebufferend","seeked","error","hb","requestcompleted","requestfailed","requestcanceled","renditionchange"],q=function(J,$,Q){var se=this;this.DOM_CONTENT_LOADED_EVENT_END=p.default.domContentLoadedEventEnd(),this.NAVIGATION_START=p.default.navigationStart();var he={debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(oe){return oe}};this.mux=J,this.id=$,Q=(0,_.default)(he,Q),Q.data=Q.data||{},Q.data.property_key&&(Q.data.env_key=Q.data.property_key,delete Q.data.property_key),T.default.setLevel(Q.debug?"debug":"warn"),this.getPlayheadTime=Q.getPlayheadTime,this.getStateData=Q.getStateData||function(){},this.getAdData=Q.getAdData||function(){},this.minimumRebufferDuration=Q.minimumRebufferDuration,this.sustainedRebufferThreshold=Q.sustainedRebufferThreshold,this.playbackHeartbeatTime=Q.playbackHeartbeatTime,this.disableRebufferTracking=Q.disableRebufferTracking,this.disableRebufferTracking&&this.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."),this.errorTranslator=Q.errorTranslator,this.playbackEventDispatcher=new ee.default(J,Q.data.env_key,Q),this.data={player_instance_id:(0,g.generateUUID)(),mux_sample_rate:Q.sampleRate,beacon_domain:Q.beaconCollectionDomain?Q.beaconCollectionDomain:Q.beaconDomain},this.data.view_sequence_number=1,this.data.player_sequence_number=1,this.oldEmit=this.emit,this.emit=function(oe,le){le=(0,_.default)({viewer_time:this.mux.utils.now()},le),this.oldEmit(oe,le)};var ue=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(this);this.on("viewinit",function(oe,le){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),(0,_.default)(this.data,le),this._initializeViewData(),this.one("play",ue),this.one("adbreakstart",ue)});var fe=function(oe){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",oe)}.bind(this);if(this.on("videochange",function(oe,le){fe(le)}),this.on("programchange",function(oe,le){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),fe((0,_.default)(le,{view_program_changed:!0})),ue(),this.emit("play"),this.emit("playing")}),this.on("fragmentchange",function(oe,le){this.currentFragmentPDT=le.currentFragmentPDT,this.currentFragmentStart=le.currentFragmentStart}),this.on("destroy",this.destroy),S.default!==void 0&&typeof S.default.addEventListener=="function"&&typeof S.default.removeEventListener=="function"){var ge=function(oe){oe.persisted||se.destroy()};S.default.addEventListener("pagehide",ge,!1),this.on("destroy",function(){S.default.removeEventListener("pagehide",ge)})}this.on("playerready",function(oe,le){(0,_.default)(this.data,le)}),ve.forEach(function(oe){se.on(oe,function(le,Te){oe.indexOf("ad")!==0&&this._updateStateData(),(0,_.default)(this.data,Te),this._sanitizeData()}),se.on("after"+oe,function(){(oe!=="error"||this.viewErrored)&&this.send(oe)})}),this.on("viewend",function(oe,le){(0,_.default)(se.data,le)});var Ee=function(oe){var le=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=le-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time};this.one("playerready",Ee),u.default.apply(this),ie.default.apply(this),K.default.apply(this),O.default.apply(this),h.default.apply(this),k.default.apply(this),l.default.apply(this),E.default.apply(this),Y.default.apply(this),M.default.apply(this),B.default.apply(this),U.default.apply(this),Z.default.apply(this),ae.default.apply(this),Q.hlsjs&&this.addHLSJS(Q),Q.dashjs&&this.addDashJS(Q),this.emit("viewinit",Q.data)};(0,_.default)(q.prototype,a.default.prototype),(0,_.default)(q.prototype,O.default.prototype),(0,_.default)(q.prototype,K.default.prototype),(0,_.default)(q.prototype,h.default.prototype),(0,_.default)(q.prototype,l.default.prototype),(0,_.default)(q.prototype,E.default.prototype),(0,_.default)(q.prototype,Y.default.prototype),(0,_.default)(q.prototype,B.default.prototype),(0,_.default)(q.prototype,U.default.prototype),q.prototype.destroy=function(){this._destroyed||(this._destroyed=!0,this.data.view_start!==void 0&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),S.default.clearTimeout(this._heartBeatTimeout))},q.prototype.send=function(J){var $=(0,_.default)({},this.data),Q=["player_program_time","player_manifest_newest_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"];if($.video_source_is_live===void 0&&($.player_source_duration===1/0||$.video_source_duration===1/0?$.video_source_is_live=!0:($.player_source_duration>0||$.video_source_duration>0)&&($.video_source_is_live=!1)),$.video_source_is_live||Q.forEach(function(ge){$[ge]=void 0}),$.video_source_url=$.video_source_url||$.player_source_url,$.video_source_url){var se=(0,A.extractHostnameAndDomain)($.video_source_url),he=x(se,2),ue=he[0],fe=he[1];$.video_source_domain=fe,$.video_source_hostname=ue}delete $.ad_request_id,this.playbackEventDispatcher.send(J,$),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()},q.prototype._updateStateData=function(){(0,_.default)(this.data,this.getStateData()),this._updatePlayheadTime(),this._sanitizeData()},q.prototype._sanitizeData=function(){var J=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function($){var Q=parseInt(J.data[$],10);J.data[$]=isNaN(Q)?void 0:Q}),["player_source_url","video_source_url"].forEach(function($){if(J.data[$]){var Q=J.data[$].toLowerCase();Q.indexOf("data:")!==0&&Q.indexOf("blob:")!==0||(J.data[$]="MSE style URL")}})},q.prototype._resetVideoData=function(J,$){var Q=this;Object.keys(this.data).forEach(function(se){se.indexOf("video_")===0&&delete Q.data[se]})},q.prototype._resetViewData=function(){var J=this;Object.keys(this.data).forEach(function($){$.indexOf("view_")===0&&delete J.data[$]}),this.data.view_sequence_number=1},q.prototype._resetErrorData=function(J,$){delete this.data.player_error_code,delete this.data.player_error_message},q.prototype._initializeViewData=function(){var J=this,$=this.data.view_id=(0,g.generateUUID)(),Q=function(){$===J.data.view_id&&(0,e.default)(J.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",Q):Q()},q.prototype._restartHeartBeat=function(){var J=this;S.default.clearTimeout(this._heartBeatTimeout),this.viewErrored||(this._heartBeatTimeout=S.default.setTimeout(function(){J.data.player_is_paused||J.emit("hb")},1e4))},q.prototype.addHLSJS=function(J){return J.hlsjs?this.hlsjs?void this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=J.hlsjs,void(0,i.monitorHlsJs)(this.mux,this.id,J.hlsjs,{},J.Hls||S.default.Hls)):void this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")},q.prototype.removeHLSJS=function(){this.hlsjs&&((0,i.stopMonitoringHlsJs)(this.hlsjs),this.hlsjs=void 0)},q.prototype.addDashJS=function(J){return J.dashjs?this.dashjs?void this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=J.dashjs,void(0,t.monitorDashJS)(this.mux,this.id,J.dashjs)):void this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")},q.prototype.removeDashJS=function(){this.dashjs&&((0,t.stopMonitoringDashJS)(this.dashjs),this.dashjs=void 0)},c.default=q},function(I,c,R){"use strict";function y(s){return s&&s.__esModule?s:{default:s}}Object.defineProperty(c,"__esModule",{value:!0}),c.stopMonitoringHlsJs=c.monitorHlsJs=void 0;var x=R(7),b=y(x),T=R(13),L=y(T),_=R(5),g=R(14),A=y(g),D=function(s){if(!s)return{};var e=L.default.navigationStart(),i=s.loading,t=i?i.start:s.trequest,r=i?i.first:s.tfirst,a=i?i.end:s.tload;return{bytesLoaded:s.total,requestStart:Math.round(e+t),responseStart:Math.round(e+r),responseEnd:Math.round(e+a)}},S=function(s){if(s&&typeof s.getAllResponseHeaders=="function")return(0,b.default)(s.getAllResponseHeaders())},v=function(s,e,i){var t=(arguments.length>3&&arguments[3]!==void 0&&arguments[3],arguments[4]),r=s.log,a=s.utils.secondsToMs,n=function(P){var M=parseInt(t.version),F=void 0;return M===1&&P.programDateTime!==null&&(F=P.programDateTime),M===0&&P.pdt!==null&&(F=P.pdt),F};if(!L.default.exists())return void r.warn("performance timing not supported. Not tracking HLS.js.");var h=function(P,M){return s.emit(e,P,M)},d=function(P,M){var F=M.levels,B=M.audioTracks,C=M.url,U=M.stats,w=M.networkDetails,k=M.sessionData,j={},K={},G={};G=(0,A.default)(k),F.forEach(function(X,ee){j[ee]={width:X.width,height:X.height,bitrate:X.bitrate,attrs:X.attrs}}),B.forEach(function(X,ee){K[ee]={name:X.name,language:X.lang,bitrate:X.bitrate}});var Y=D(U),V=Y.bytesLoaded,Z=Y.requestStart,z=Y.responseStart,ie=Y.responseEnd;G.request_event_type=P,G.request_bytes_loaded=V,G.request_start=Z,G.request_response_start=z,G.request_response_end=ie,G.request_type="manifest",G.request_hostname=(0,_.extractHostname)(C),G.request_response_headers=S(w),G.request_rendition_lists={media:j,audio:K,video:{}},h("requestcompleted",G)};i.on(t.Events.MANIFEST_LOADED,d);var u=function(P,M){var F=M.details,B=M.level,C=M.networkDetails,U=M.stats,w=D(U),k=w.bytesLoaded,j=w.requestStart,K=w.responseStart,G=w.responseEnd,Y=F.fragments[F.fragments.length-1],V=n(Y)+a(Y.duration);h("requestcompleted",{request_event_type:P,request_bytes_loaded:k,request_start:j,request_response_start:K,request_response_end:G,request_current_level:B,request_type:"manifest",request_hostname:(0,_.extractHostname)(F.url),request_response_headers:S(C),video_holdback:F.holdBack&&a(F.holdBack),video_part_holdback:F.partHoldBack&&a(F.partHoldBack),video_part_target_duration:F.partTarget&&a(F.partTarget),video_target_duration:F.targetduration&&a(F.targetduration),video_source_is_live:F.live,player_manifest_newest_program_time:isNaN(V)?void 0:V})};i.on(t.Events.LEVEL_LOADED,u);var f=function(P,M){var F=M.details,B=M.networkDetails,C=M.stats,U=D(C),w=U.bytesLoaded,k=U.requestStart,j=U.responseStart,K=U.responseEnd;h("requestcompleted",{request_event_type:P,request_bytes_loaded:w,request_start:k,request_response_start:j,request_response_end:K,request_type:"manifest",request_hostname:(0,_.extractHostname)(F.url),request_response_headers:S(B)})};i.on(t.Events.AUDIO_TRACK_LOADED,f);var l=function(P,M){var F=M.stats,B=M.networkDetails,C=M.frag,U=D(F),w=U.bytesLoaded,k=U.requestStart,j=U.responseStart,K=U.responseEnd,G={request_event_type:P,request_bytes_loaded:w,request_start:k,request_response_start:j,request_response_end:K,request_hostname:B?(0,_.extractHostname)(B.responseURL):void 0,request_response_headers:S(B),request_media_duration:C.duration};C.type==="main"?(G.request_type="media",G.request_current_level=C.level,G.request_video_width=(i.levels[C.level]||{}).width,G.request_video_height=(i.levels[C.level]||{}).height):G.request_type=C.type,h("requestcompleted",G)};i.on(t.Events.FRAG_LOADED,l);var o=function(P,M){var F=M.frag,B=F.start,C=n(F),U={currentFragmentPDT:C,currentFragmentStart:a(B)};h("fragmentchange",U)};i.on(t.Events.FRAG_CHANGED,o);var E=function(P,M){var F=M.type,B=M.details,C=M.response,U=M.fatal,w=M.context,k=M.frag;if(B===t.ErrorDetails.MANIFEST_LOAD_ERROR||B===t.ErrorDetails.MANIFEST_LOAD_TIMEOUT||B===t.ErrorDetails.FRAG_LOAD_ERROR||B===t.ErrorDetails.FRAG_LOAD_TIMEOUT||B===t.ErrorDetails.LEVEL_LOAD_ERROR||B===t.ErrorDetails.LEVEL_LOAD_TIMEOUT){var j=k&&k.url||w&&w.url||"";h("requestfailed",{request_error:B,request_url:j,request_hostname:(0,_.extractHostname)(j),request_type:B===t.ErrorDetails.FRAG_LOAD_ERROR||B===t.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:C&&C.code,request_error_text:C&&C.text})}U&&h("error",{player_error_code:F,player_error_message:B})};i.on(t.Events.ERROR,E);var m=function(P,M){var F=M.frag,B=F&&F._url||"";h("requestcanceled",{request_cancel:P,request_url:B,request_type:"media",request_hostname:(0,_.extractHostname)(B)})};i.on(t.Events.FRAG_LOAD_EMERGENCY_ABORTED,m);var O=function(P,M){var F=M.level,B=i.levels[F];if(B&&B.attrs&&B.attrs.BANDWIDTH){var C=B.attrs.BANDWIDTH;C?h("renditionchange",{video_source_bitrate:C,video_source_width:B.width,video_source_height:B.height}):r.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};i.on(t.Events.LEVEL_SWITCHED,O),i._stopMuxMonitor=function(){i.off(t.Events.MANIFEST_LOADED,d),i.off(t.Events.LEVEL_LOADED,u),i.off(t.Events.AUDIO_TRACK_LOADED,f),i.off(t.Events.FRAG_LOADED,l),i.off(t.Events.FRAG_CHANGED,o),i.off(t.Events.ERROR,E),i.off(t.Events.FRAG_LOAD_EMERGENCY_ABORTED,m),i.off(t.Events.LEVEL_SWITCHED,O),i.off(t.Events.DESTROYING,i._stopMuxMonitor),delete i._stopMuxMonitor},i.on(t.Events.DESTROYING,i._stopMuxMonitor)},p=function(s){s&&typeof s._stopMuxMonitor=="function"&&s._stopMuxMonitor()};c.monitorHlsJs=v,c.stopMonitoringHlsJs=p},function(I,c,R){"use strict";function y(v){return v&&v.__esModule?v:{default:v}}Object.defineProperty(c,"__esModule",{value:!0}),c.stopMonitoringDashJS=c.monitorDashJS=void 0;var x=R(0),b=y(x),T=R(7),L=y(T),_=R(5),g=function(v,p){if(!v||typeof v.getRequests!="function")return{};var s=v.getRequests({state:"executed"});if(s.length===0)return{};var e=s[s.length-1],i=(0,_.extractHostname)(e.url),t=e.bytesLoaded,r=new Date(e.requestStartDate).getTime(),a=new Date(e.firstByteDate).getTime(),n=new Date(e.requestEndDate).getTime(),h=isNaN(e.duration)?0:e.duration,d=typeof p.getMetricsFor=="function"?p.getMetricsFor(e.mediaType).HttpList:p.getDashMetrics().getHttpRequests(e.mediaType),u=void 0;return d.length>0&&(u=(0,L.default)(d[d.length-1]._responseHeaders||"")),{requestStart:r,requestResponseStart:a,requestResponseEnd:n,requestBytesLoaded:t,requestResponseHeaders:u,requestMediaDuration:h,requestHostname:i}},A=function(v,p){var s=p.getQualityFor(v),e=p.getCurrentTrackFor(v),i=e.bitrateList;return i?{currentLevel:s,renditionWidth:i[s].width||null,renditionHeight:i[s].height||null,renditionBitrate:i[s].bandwidth}:{}},D=function(v,p,s){var e=(arguments.length>3&&arguments[3]!==void 0&&arguments[3],v.log);if(!s||!s.on)return void e.warn("Invalid dash.js player reference. Monitoring blocked.");var i=function(l,o){return v.emit(p,l,o)},t=function(l){var o=l.type,E=l.data,m=E||{},O=m.url;i("requestcompleted",{request_event_type:o,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:(0,_.extractHostname)(O)})};s.on("manifestLoaded",t);var r={},a=function(l){var o=l.type,E=l.fragmentModel,m=l.chunk,O=m||{},P=O.mediaInfo,M=P||{},F=M.type,B=M.bitrateList;B=B||[];var C={};B.forEach(function(V,Z){C[Z]={},C[Z].width=V.width,C[Z].height=V.height,C[Z].bitrate=V.bandwidth,C[Z].attrs={}}),F==="video"?r.video=C:F==="audio"?r.audio=C:r.media=C;var U=g(E,s),w=U.requestStart,k=U.requestResponseStart,j=U.requestResponseEnd,K=U.requestResponseHeaders,G=U.requestMediaDuration,Y=U.requestHostname;i("requestcompleted",{request_event_type:o,request_start:w,request_response_start:k,request_response_end:j,request_bytes_loaded:-1,request_type:F+"_init",request_response_headers:K,request_hostname:Y,request_media_duration:G,request_rendition_lists:r})};s.on("initFragmentLoaded",a);var n=function(l){var o=l.type,E=l.fragmentModel,m=l.chunk,O=m||{},P=O.mediaInfo,M=O.start,F=P||{},B=F.type,C=g(E,s),U=C.requestStart,w=C.requestResponseStart,k=C.requestResponseEnd,j=C.requestBytesLoaded,K=C.requestResponseHeaders,G=C.requestMediaDuration,Y=C.requestHostname,V=A(B,s),Z=V.currentLevel,z=V.renditionWidth,ie=V.renditionHeight,X=V.renditionBitrate;i("requestcompleted",{request_event_type:o,request_start:U,request_response_start:w,request_response_end:k,request_bytes_loaded:j,request_type:B,request_response_headers:K,request_hostname:Y,request_media_start_time:M,request_media_duration:G,request_current_level:Z,request_labeled_bitrate:X,request_video_width:z,request_video_height:ie})};s.on("mediaFragmentLoaded",n);var h={video:void 0,audio:void 0,totalBitrate:void 0},d=function(){if(h.video&&typeof h.video.bitrate=="number"){if(!h.video.width||!h.video.height)return void e.warn("have bitrate info for video but missing width/height");var l=h.video.bitrate;return h.audio&&typeof h.audio.bitrate=="number"&&(l+=h.audio.bitrate),l!==h.totalBitrate?(h.totalBitrate=l,{video_source_bitrate:l,video_source_height:h.video.height,video_source_width:h.video.width}):void 0}},u=function(l,o,E){if(typeof l.newQuality!="number")return void e.warn("missing evt.newQuality in qualityChangeRendered event",l);var m=l.mediaType;if(m==="audio"||m==="video"){var O=s.getBitrateInfoListFor(m).find(function(M){return M.qualityIndex===l.newQuality});if(!O||typeof O.bitrate!="number")return void e.warn("missing bitrate info for "+m);h[m]=O;var P=d();P&&i("renditionchange",P)}};s.on("qualityChangeRendered",u);var f=function(l){var o=l.error,E=l.event;E=E||{};var m=E.request||{},O=b.default.event&&b.default.event.currentTarget||{};i("requestfailed",{request_error:o+"_"+E.id+"_"+m.type,request_url:E.url,request_hostname:(0,_.extractHostname)(E.url),request_type:m.mediaType,request_error_code:O.status,request_error_type:O.statusText})};s.on("error",f),s._stopMuxMonitor=function(){s.off("manifestLoaded",t),s.off("initFragmentLoaded",a),s.off("mediaFragmentLoaded",n),s.off("qualityChangeRendered",u),s.off("error",f),delete s._stopMuxMonitor}},S=function(v){v&&typeof v._stopMuxMonitor=="function"&&v._stopMuxMonitor()};c.monitorDashJS=D,c.stopMonitoringDashJS=S},function(I,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y=function(){},x=0;y.prototype.on=function(b,T,L){return T._eventEmitterGuid=T._eventEmitterGuid||++x,this._listeners=this._listeners||{},this._listeners[b]=this._listeners[b]||[],L&&(T=T.bind(L)),this._listeners[b].push(T),T},y.prototype.off=function(b,T){var L=this._listeners&&this._listeners[b];L&&L.forEach(function(_,g){_._eventEmitterGuid===T._eventEmitterGuid&&L.splice(g,1)})},y.prototype.one=function(b,T,L){var _=this;T._eventEmitterGuid=T._eventEmitterGuid||++x;var g=function A(){_.off(b,A),T.apply(L||this,arguments)};g._eventEmitterGuid=T._eventEmitterGuid,this.on(b,g)},y.prototype.emit=function(b,T){var L=this;if(this._listeners){T=T||{};var _=this._listeners["before*"]||[],g=this._listeners[b]||[],A=this._listeners["after"+b]||[],D=function(S,v){S=S.slice(),S.forEach(function(p){p.call(L,{type:b},v)})};D(_,T),D(g,T),D(A,T)}},c.default=y},function(I,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y=R(0),x=function(T){return T&&T.__esModule?T:{default:T}}(y),b=function(){this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,this.on("playing",function(){this._playheadShouldBeProgressing=!0}),this.on("play",this._startPlaybackHeartbeatInterval),this.on("playing",this._startPlaybackHeartbeatInterval),this.on("adbreakstart",this._startPlaybackHeartbeatInterval),this.on("adplay",this._startPlaybackHeartbeatInterval),this.on("adplaying",this._startPlaybackHeartbeatInterval),this.on("seeking",this._startPlaybackHeartbeatInterval),this.on("devicewake",this._startPlaybackHeartbeatInterval),this.on("viewstart",this._startPlaybackHeartbeatInterval),this.on("rebufferstart",this._startPlaybackHeartbeatInterval),this.on("pause",this._stopPlaybackHeartbeatInterval),this.on("ended",this._stopPlaybackHeartbeatInterval),this.on("viewend",this._stopPlaybackHeartbeatInterval),this.on("error",this._stopPlaybackHeartbeatInterval),this.on("aderror",this._stopPlaybackHeartbeatInterval),this.on("adpause",this._stopPlaybackHeartbeatInterval),this.on("adended",this._stopPlaybackHeartbeatInterval),this.on("adbreakend",this._stopPlaybackHeartbeatInterval),this.on("seeked",function(){this.data.player_is_paused?this._stopPlaybackHeartbeatInterval():this._startPlaybackHeartbeatInterval()}),this.on("timeupdate",function(){this._playbackHeartbeatInterval!==null&&this.emit("playbackheartbeat")}),this.on("devicesleep",function(T,L){this._playbackHeartbeatInterval!==null&&(x.default.clearInterval(this._playbackHeartbeatInterval),this.emit("playbackheartbeatend",{viewer_time:L.viewer_time}),this._playbackHeartbeatInterval=null)})};b.prototype._startPlaybackHeartbeatInterval=function(){var T=this;this._playbackHeartbeatInterval===null&&(this.emit("playbackheartbeat"),this._playbackHeartbeatInterval=x.default.setInterval(function(){T.emit("playbackheartbeat")},this.playbackHeartbeatTime))},b.prototype._stopPlaybackHeartbeatInterval=function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(x.default.clearInterval(this._playbackHeartbeatInterval),this.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)},c.default=b},function(I,c,R){"use strict";function y(){var x=this;this.on("viewinit",function(){x.viewErrored=!1}),this.on("error",function(){try{var b=x.errorTranslator({player_error_code:x.data.player_error_code,player_error_message:x.data.player_error_message});b?(x.data.player_error_code=b.player_error_code,x.data.player_error_message=b.player_error_message,x.viewErrored=!0):(delete x.data.player_error_code,delete x.data.player_error_message)}catch(T){x.mux.log.warn("Exception in error translator callback.",T),x.viewErrored=!0}})}Object.defineProperty(c,"__esModule",{value:!0}),c.default=y},function(I,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y=R(3),x=function(T){return T&&T.__esModule?T:{default:T}}(y),b=function(){this._watchTimeTrackerLastCheckedTime=null,this.on("playbackheartbeat",this._updateWatchTime),this.on("playbackheartbeatend",this._clearWatchTimeState)};b.prototype._updateWatchTime=function(T,L){var _=L.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=_),(0,x.default)(this.data,"view_watch_time",_-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=_},b.prototype._clearWatchTimeState=function(T,L){this._updateWatchTime(T,L),this._watchTimeTrackerLastCheckedTime=null},c.default=b},function(I,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y=R(3),x=function(T){return T&&T.__esModule?T:{default:T}}(y),b=function(){this._playbackTimeTrackerLastPlayheadPosition=-1,this.on("playbackheartbeat",this._updatePlaybackTime),this.on("playbackheartbeatend",this._clearPlaybackTimeState),this.on("seeking",this._clearPlaybackTimeState)};b.prototype._updatePlaybackTime=function(){var T=this.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&T>this._playbackTimeTrackerLastPlayheadPosition){var L=T-this._playbackTimeTrackerLastPlayheadPosition;L<=1e3&&(0,x.default)(this.data,"view_content_playback_time",L)}this._playbackTimeTrackerLastPlayheadPosition=T},b.prototype._clearPlaybackTimeState=function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1},c.default=b},function(I,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y=function(){this.on("playbackheartbeat",this._updatePlayheadTime),this.on("playbackheartbeatend",this._updatePlayheadTime),this.on("timeupdate",this._updatePlayheadTime),this.on("destroy",function(){this.off("timeupdate",this._updatePlayheadTime)})};y.prototype._updateMaxPlayheadPosition=function(){this.data.view_max_playhead_position=this.data.view_max_playhead_position===void 0?this.data.player_playhead_time:Math.max(this.data.view_max_playhead_position,this.data.player_playhead_time)},y.prototype._updatePlayheadTime=function(x,b){var T=this,L=function(){T.currentFragmentPDT&&T.currentFragmentStart&&(T.data.player_program_time=T.currentFragmentPDT+T.data.player_playhead_time-T.currentFragmentStart)};if(b&&b.player_playhead_time)this.data.player_playhead_time=b.player_playhead_time,L(),this._updateMaxPlayheadPosition();else if(this.getPlayheadTime){var _=this.getPlayheadTime();_!==void 0&&(this.data.player_playhead_time=_,L(),this._updateMaxPlayheadPosition())}},c.default=y},function(I,c,R){"use strict";function y(){var T=this;if(!this.disableRebufferTracking){var L=void 0,_=function(){if(L){var g=T.data.viewer_time-L;(0,b.default)(T.data,"view_rebuffer_duration",g),L=T.data.viewer_time}T.data.view_watch_time>=0&&T.data.view_rebuffer_count>0&&(T.data.view_rebuffer_frequency=T.data.view_rebuffer_count/T.data.view_watch_time,T.data.view_rebuffer_percentage=T.data.view_rebuffer_duration/T.data.view_watch_time)};this.on("playbackheartbeat",function(){return _()}),this.on("rebufferstart",function(){L||((0,b.default)(T.data,"view_rebuffer_count",1),L=T.data.viewer_time,T.one("rebufferend",function(){_(),L=void 0}))})}}Object.defineProperty(c,"__esModule",{value:!0}),c.default=y;var x=R(3),b=function(T){return T&&T.__esModule?T:{default:T}}(x)},function(I,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y=R(2),x=function(T){return T&&T.__esModule?T:{default:T}}(y),b=function(){this.disableRebufferTracking||this.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,this.on("playbackheartbeat",this._checkIfRebuffering),this.on("playbackheartbeatend",this._cleanupRebufferTracker),this.on("seeking",function(){this._cleanupRebufferTracker(null,{viewer_time:x.default.now()})}))};b.prototype._checkIfRebuffering=function(T,L){return this.isSeeking||this.isAdBreak||!this._playheadShouldBeProgressing?void this._cleanupRebufferTracker(T,L):this._lastCheckedTime===null?void this._prepareRebufferTrackerState(L.viewer_time):this._lastPlayheadTime!==this.data.player_playhead_time?void this._cleanupRebufferTracker(T,L,!0):(L.viewer_time-this._lastPlayheadTimeUpdatedTime>=this.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),void(this._lastCheckedTime=L.viewer_time))},b.prototype._clearRebufferTrackerState=function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null},b.prototype._prepareRebufferTrackerState=function(T){this._lastCheckedTime=T,this._lastPlayheadTime=this.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=T},b.prototype._cleanupRebufferTracker=function(T,L){var _=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.emit("rebufferend",{viewer_time:L.viewer_time});else{if(this._lastCheckedTime===null)return;var g=this.data.player_playhead_time-this._lastPlayheadTime,A=L.viewer_time-this._lastPlayheadTimeUpdatedTime;g>0&&A-g>this.minimumRebufferDuration&&(this.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+A-g}))}_?this._prepareRebufferTrackerState(L.viewer_time):this._clearRebufferTrackerState()},c.default=b},function(I,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y=R(2),x=function(T){return T&&T.__esModule?T:{default:T}}(y),b=function(){this.on("viewinit",function(){var T=this.data,L=T.view_id;if(!T.view_program_changed){var _=function(g,A){var D=A.viewer_time;g.type==="playing"&&this.data.view_time_to_first_frame===void 0?this.calculateTimeToFirstFrame(D||x.default.now(),L):g.type!=="adplaying"||this.data.view_time_to_first_frame!==void 0&&!this.inPrerollPosition()||this.calculateTimeToFirstFrame(D||x.default.now(),L)};this.one("playing",_),this.one("adplaying",_),this.one("viewend",function(){this.off("playing",_),this.off("adplaying",_)})}})};b.prototype.calculateTimeToFirstFrame=function(T,L){L===this.data.view_id&&(this._updateWatchTime(null,{viewer_time:T}),this.data.view_time_to_first_frame=this.data.view_watch_time,(this.data.player_autoplay_on||this.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.data.view_aggregate_startup_time=this.data.view_start+this.data.view_watch_time-this.NAVIGATION_START))},c.default=b},function(I,c,R){"use strict";function y(){var T=this;this.on("viewinit",function(){this._lastPlayheadPosition=-1});var L=["pause","rebufferstart","seeking","error","adbreakstart","hb"],_=["playing","hb"];L.forEach(function(g){T.on(g,function(){if(this._lastPlayheadPosition>=0&&this.data.player_playhead_time>=0&&this._lastPlayerWidth>=0&&this._lastSourceWidth>0&&this._lastPlayerHeight>=0&&this._lastSourceHeight>0){var A=this.data.player_playhead_time-this._lastPlayheadPosition;if(A<0)return void(this._lastPlayheadPosition=-1);var D=Math.min(this._lastPlayerWidth/this._lastSourceWidth,this._lastPlayerHeight/this._lastSourceHeight),S=Math.max(0,D-1),v=Math.max(0,1-D);this.data.view_max_upscale_percentage=Math.max(this.data.view_max_upscale_percentage||0,S),this.data.view_max_downscale_percentage=Math.max(this.data.view_max_downscale_percentage||0,v),(0,b.default)(this.data,"view_total_content_playback_time",A),(0,b.default)(this.data,"view_total_upscaling",S*A),(0,b.default)(this.data,"view_total_downscaling",v*A)}this._lastPlayheadPosition=-1})}),_.forEach(function(g){T.on(g,function(){this._lastPlayheadPosition=this.data.player_playhead_time,this._lastPlayerWidth=this.data.player_width,this._lastPlayerHeight=this.data.player_height,this._lastSourceWidth=this.data.video_source_width,this._lastSourceHeight=this.data.video_source_height})})}Object.defineProperty(c,"__esModule",{value:!0}),c.default=y;var x=R(3),b=function(T){return T&&T.__esModule?T:{default:T}}(x)},function(I,c,R){"use strict";function y(D){return D&&D.__esModule?D:{default:D}}function x(){this.isSeeking=!1,this.on("seeking",function(D,S){(0,A.default)(this.data,S),this._lastSeekingTime=T.default.now(),this.isSeeking===!1&&(this.isSeeking=!0,this.send("seeking"))}),this.on("seeked",function(){this.isSeeking=!1;var D=this._lastSeekingTime||T.default.now(),S=T.default.now()-D;(0,_.default)(this.data,"view_seek_count",1),(0,_.default)(this.data,"view_seek_duration",S);var v=this.data.view_max_seek_time||0;this.data.view_max_seek_time=Math.max(v,S)}),this.on("viewend",function(){this.isSeeking=!1})}Object.defineProperty(c,"__esModule",{value:!0}),c.default=x;var b=R(2),T=y(b),L=R(3),_=y(L),g=R(1),A=y(g)},function(I,c,R){"use strict";function y(v){return v&&v.__esModule?v:{default:v}}Object.defineProperty(c,"__esModule",{value:!0});var x=function(){function v(p,s){var e=[],i=!0,t=!1,r=void 0;try{for(var a,n=p[Symbol.iterator]();!(i=(a=n.next()).done)&&(e.push(a.value),!s||e.length!==s);i=!0);}catch(h){t=!0,r=h}finally{try{!i&&n.return&&n.return()}finally{if(t)throw r}}return e}return function(p,s){if(Array.isArray(p))return p;if(Symbol.iterator in Object(p))return v(p,s);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),b=R(3),T=y(b),L=R(5),_=R(1),g=y(_),A=function(v,p){v.push(p),v.sort(function(s,e){return s.viewer_time-e.viewer_time})},D=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],S=function(){var v=this;this.on("viewinit",function(){this.isAdBreak=!1,this._currentAdRequestNumber=0,this._currentAdResponseNumber=0,this._adRequests=[],this._adResponses=[],this._adHasPlayed=!1,this._wouldBeNewAdPlay=!0,this._prerollPlayTime=void 0}),D.forEach(function(s){return v.on(s,v._updateAdData)});var p=function(){v.isAdBreak=!1};this.on("adbreakstart",function(){this.isAdBreak=!0}),this.on("play",p),this.on("playing",p),this.on("viewend",p),this.on("adrequest",function(s,e){e=(0,g.default)({ad_request_id:"generatedAdRequestId"+this._currentAdRequestNumber++},e),A(this._adRequests,e),(0,T.default)(this.data,"view_ad_request_count"),this.inPrerollPosition()&&(this.data.view_preroll_requested=!0,this._adHasPlayed||(0,T.default)(this.data,"view_preroll_request_count"))}),this.on("adresponse",function(s,e){e=(0,g.default)({ad_request_id:"generatedAdRequestId"+this._currentAdResponseNumber++},e),A(this._adResponses,e);var i=this.findAdRequest(e.ad_request_id);i&&(0,T.default)(this.data,"view_ad_request_time",Math.max(0,e.viewer_time-i.viewer_time))}),this.on("adplay",function(s,e){this._adHasPlayed=!0,this._wouldBeNewAdPlay&&(this._wouldBeNewAdPlay=!1,(0,T.default)(this.data,"view_ad_played_count")),this.inPrerollPosition()&&!this.data.view_preroll_played&&(this.data.view_preroll_played=!0,this._adRequests.length>0&&(this.data.view_preroll_request_time=Math.max(0,e.viewer_time-this._adRequests[0].viewer_time)),this.data.view_start&&(this.data.view_startup_preroll_request_time=Math.max(0,e.viewer_time-this.data.view_start)),this._prerollPlayTime=e.viewer_time)}),this.on("adplaying",function(s,e){this.inPrerollPosition()&&this.data.view_preroll_load_time===void 0&&this._prerollPlayTime!==void 0&&(this.data.view_preroll_load_time=e.viewer_time-this._prerollPlayTime,this.data.view_startup_preroll_load_time=e.viewer_time-this._prerollPlayTime)}),this.on("adended",function(){this._wouldBeNewAdPlay=!0}),this.on("aderror",function(){this._wouldBeNewAdPlay=!0})};S.prototype.inPrerollPosition=function(){return this.data.view_content_playback_time===void 0||this.data.view_content_playback_time<=1e3},S.prototype.findAdRequest=function(v){for(var p=0;p<this._adRequests.length;p++)if(this._adRequests[p].ad_request_id===v)return this._adRequests[p]},S.prototype._updateAdData=function(v,p){if(this.inPrerollPosition()){if(!this.data.view_preroll_ad_tag_hostname&&p.ad_tag_url){var s=(0,L.extractHostnameAndDomain)(p.ad_tag_url),e=x(s,2),i=e[0],t=e[1];this.data.view_preroll_ad_tag_domain=t,this.data.view_preroll_ad_tag_hostname=i}if(!this.data.view_preroll_ad_asset_hostname&&p.ad_asset_url){var r=(0,L.extractHostnameAndDomain)(p.ad_asset_url),a=x(r,2),n=a[0],h=a[1];this.data.view_preroll_ad_asset_domain=h,this.data.view_preroll_ad_asset_hostname=n}}},c.default=S},function(I,c,R){"use strict";function y(g){return g&&g.__esModule?g:{default:g}}function x(){var g=this,A=void 0,D=void 0,S=function(){g.disableRebufferTracking||((0,_.default)(g.data,"view_waiting_rebuffer_count",1),A=T.default.now(),D=window.setInterval(function(){if(A){var i=T.default.now();(0,_.default)(g.data,"view_waiting_rebuffer_duration",i-A),A=i}},250))},v=function(){g.disableRebufferTracking||A&&((0,_.default)(g.data,"view_waiting_rebuffer_duration",T.default.now()-A),A=!1,window.clearInterval(D))},p=!1,s=function(){p=!0},e=function(){p=!1,v()};this.on("waiting",function(){p&&S()}),this.on("playing",function(){v(),s()}),this.on("pause",e),this.on("seeking",e)}Object.defineProperty(c,"__esModule",{value:!0}),c.default=x;var b=R(2),T=y(b),L=R(3),_=y(L)},function(I,c,R){"use strict";function y(D){return D&&D.__esModule?D:{default:D}}function x(){var D=this;this.one("playbackheartbeat",g),this.on("playbackheartbeatend",function(){D.off("before*",A),D.one("playbackheartbeat",g)})}Object.defineProperty(c,"__esModule",{value:!0}),c.default=x;var b=R(1),T=y(b),L=R(2),_=y(L),g=function(){this.lastWallClockTime=_.default.now(),this.on("before*",A)},A=function(D){var S=_.default.now(),v=this.lastWallClockTime;this.lastWallClockTime=S,S-v>3e4&&(this.emit("devicesleep",{viewer_time:v}),(0,T.default)(this.data,{viewer_time:v}),this.send("devicesleep"),this.emit("devicewake",{viewer_time:S}),(0,T.default)(this.data,{viewer_time:S}),this.send("devicewake"))}},function(I,c,R){"use strict";function y(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(c,"__esModule",{value:!0});var x=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o){return typeof o}:function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},b=R(0),T=y(b),L=R(40),_=R(4),g=y(_),A=R(53),D=y(A),S=R(12),v=y(S),p=R(54),s=y(p),e=R(17),i=y(e),t=R(55),r=y(t),a=R(1),n=y(a),h=["env_key","view_id","view_sequence_number","player_sequence_number","beacon_domain","player_playhead_time","viewer_time","mux_api_version","event","video_id","player_instance_id"],d=["viewstart","error","ended","viewend"],u=function(o,E){var m=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.mux=o,this.envKey=E,this.eventQueue=new r.default((0,D.default)(E,m)),this.previousBeaconData=null,this.lastEventTime=null,this.sampleRate=m.sampleRate,this.disableCookies=m.disableCookies,this.respectDoNotTrack=m.respectDoNotTrack;var O=m.platform||{};this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:O.name,viewer_application_version:O.version,viewer_application_engine:O.layout,viewer_device_name:O.product,viewer_device_category:"",viewer_device_manufacturer:O.manufacturer,viewer_os_family:O.os&&O.os.family,viewer_os_architecture:O.os&&O.os.architecture,viewer_os_version:O.os&&O.os.version};var P=(0,s.default)();P&&(this.pageLevelData=(0,n.default)(this.pageLevelData,{viewer_connection_type:P})),T.default!==void 0&&T.default.location&&T.default.location.href&&(this.pageLevelData.page_url=T.default.location.href),this.viewerData=this.disableCookies?{}:(0,L.getAndUpdateViewerData)()};u.prototype.send=function(o,E){if(o){if(this.respectDoNotTrack&&(0,v.default)())return g.default.info("Not sending `"+o+"` because Do Not Track is enabled");if(!E||(E===void 0?"undefined":x(E))!=="object")return g.default.error("A data object was expected in send() but was not provided");var m=this.disableCookies?{}:(0,L.getAndUpdateSessionData)(),O={};(0,n.default)(O,this.pageLevelData),(0,n.default)(O,E),(0,n.default)(O,m),(0,n.default)(O,this.viewerData),O.event=o,O.env_key=this.envKey,O.user_id&&(O.viewer_user_id=O.user_id,delete O.user_id);var P=O.mux_sample_number>=this.sampleRate,M=this._deduplicateBeaconData(o,O),F=(0,i.default)(M);if(this.lastEventTime=this.mux.utils.now(),P)return g.default.info("Not sending event due to sample rate restriction",o,O,F);if(this.envKey||g.default.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",o,O,F),!this.rateLimited){if(g.default.info("Sending event",o,O,F),this.rateLimited=!this.eventQueue.queueEvent(o,F),this.mux.WINDOW_UNLOADING&&o==="viewend")this.eventQueue.destroy(!0);else if((d.indexOf(o)>=0||this.mux.WINDOW_VISIBLE===!1&&o==="hb")&&this.eventQueue.flushEvents(),this.rateLimited)return O.event="eventrateexceeded",F=(0,i.default)(O),this.eventQueue.queueEvent(O.event,F),g.default.error("Beaconing disabled due to rate limit.")}}},u.prototype.destroy=function(){this.eventQueue.destroy(!1)};var f=function(o,E,m,O){return!(!o||E.indexOf("request_")!==0)&&(E==="request_response_headers"||(m===void 0?"undefined":x(m))!=="object"||(O===void 0?"undefined":x(O))!=="object"||Object.keys(m||{}).length!==Object.keys(O||{}).length)},l=function(o,E){return o==="renditionchange"&&E.indexOf("video_source_")===0};u.prototype._deduplicateBeaconData=function(o,E){var m=this,O={},P=E.view_id;if(!P||o==="viewstart"||o==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)O=(0,n.default)({},E),P&&(this.previousBeaconData=O),P&&o==="viewend"&&(this.previousBeaconData=null);else{var M=o.indexOf("request")===0;Object.keys(E).forEach(function(F){var B=E[F];(B!==m.previousBeaconData[F]||h.indexOf(F)>-1||f(M,F,B,m.previousBeaconData[F])||l(o,F))&&(O[F]=B,m.previousBeaconData[F]=B)})}return O},c.default=u},function(I,c,R){"use strict";function y(s){return s&&s.__esModule?s:{default:s}}Object.defineProperty(c,"__esModule",{value:!0}),c.getAndUpdateSessionData=c.getAndUpdateViewerData=void 0;var x=R(15),b=y(x),T=R(52),L=y(T),_=R(6),g=R(2),A=y(g),D=function(){var s=void 0;try{s=b.default.parse(L.default.get("muxData")||"")}catch{s={}}return s},S=function(s){try{L.default.set("muxData",b.default.stringify(s),{expires:7300})}catch{}},v=function(){var s=D();return s.mux_viewer_id=s.mux_viewer_id||(0,_.generateUUID)(),s.msn=s.msn||Math.random(),S(s),{mux_viewer_id:s.mux_viewer_id,mux_sample_number:s.msn}},p=function(){var s=D(),e=A.default.now();return s.session_start&&(s.sst=s.session_start,delete s.session_start),s.session_id&&(s.sid=s.session_id,delete s.session_id),s.session_expires&&(s.sex=s.session_expires,delete s.session_expires),(!s.sex||s.sex<e)&&(s.sid=(0,_.generateUUID)(),s.sst=e),s.sex=e+15e5,S(s),{session_id:s.sid,session_start:s.sst,session_expires:s.sex}};c.getAndUpdateViewerData=v,c.getAndUpdateSessionData=p},function(I,c,R){"use strict";var y=R(42),x=R(16),b=R(10),T=Object.prototype.hasOwnProperty,L={brackets:function(r){return r+"[]"},comma:"comma",indices:function(r,a){return r+"["+a+"]"},repeat:function(r){return r}},_=Array.isArray,g=String.prototype.split,A=Array.prototype.push,D=function(r,a){A.apply(r,_(a)?a:[a])},S=Date.prototype.toISOString,v=b.default,p={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:x.encode,encodeValuesOnly:!1,format:v,formatter:b.formatters[v],indices:!1,serializeDate:function(r){return S.call(r)},skipNulls:!1,strictNullHandling:!1},s=function(r){return typeof r=="string"||typeof r=="number"||typeof r=="boolean"||typeof r=="symbol"||typeof r=="bigint"},e={},i=function r(a,n,h,d,u,f,l,o,E,m,O,P,M,F,B){for(var C=a,U=B,w=0,k=!1;(U=U.get(e))!==void 0&&!k;){var j=U.get(a);if(w+=1,j!==void 0){if(j===w)throw new RangeError("Cyclic object value");k=!0}U.get(e)===void 0&&(w=0)}if(typeof l=="function"?C=l(n,C):C instanceof Date?C=m(C):h==="comma"&&_(C)&&(C=x.maybeMap(C,function(q){return q instanceof Date?m(q):q})),C===null){if(d)return f&&!M?f(n,p.encoder,F,"key",O):n;C=""}if(s(C)||x.isBuffer(C)){if(f){var K=M?n:f(n,p.encoder,F,"key",O);if(h==="comma"&&M){for(var G=g.call(String(C),","),Y="",V=0;V<G.length;++V)Y+=(V===0?"":",")+P(f(G[V],p.encoder,F,"value",O));return[P(K)+"="+Y]}return[P(K)+"="+P(f(C,p.encoder,F,"value",O))]}return[P(n)+"="+P(String(C))]}var Z=[];if(C===void 0)return Z;var z;if(h==="comma"&&_(C))z=[{value:C.length>0?C.join(",")||null:void 0}];else if(_(l))z=l;else{var ie=Object.keys(C);z=o?ie.sort(o):ie}for(var X=0;X<z.length;++X){var ee=z[X],ce=typeof ee=="object"&&ee.value!==void 0?ee.value:C[ee];if(!u||ce!==null){var ae=_(C)?typeof h=="function"?h(n,ee):n:n+(E?"."+ee:"["+ee+"]");B.set(a,w);var ve=y();ve.set(e,B),D(Z,r(ce,ae,h,d,u,f,l,o,E,m,O,P,M,F,ve))}}return Z},t=function(r){if(!r)return p;if(r.encoder!==null&&r.encoder!==void 0&&typeof r.encoder!="function")throw new TypeError("Encoder has to be a function.");var a=r.charset||p.charset;if(r.charset!==void 0&&r.charset!=="utf-8"&&r.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=b.default;if(r.format!==void 0){if(!T.call(b.formatters,r.format))throw new TypeError("Unknown format option provided.");n=r.format}var h=b.formatters[n],d=p.filter;return(typeof r.filter=="function"||_(r.filter))&&(d=r.filter),{addQueryPrefix:typeof r.addQueryPrefix=="boolean"?r.addQueryPrefix:p.addQueryPrefix,allowDots:r.allowDots===void 0?p.allowDots:!!r.allowDots,charset:a,charsetSentinel:typeof r.charsetSentinel=="boolean"?r.charsetSentinel:p.charsetSentinel,delimiter:r.delimiter===void 0?p.delimiter:r.delimiter,encode:typeof r.encode=="boolean"?r.encode:p.encode,encoder:typeof r.encoder=="function"?r.encoder:p.encoder,encodeValuesOnly:typeof r.encodeValuesOnly=="boolean"?r.encodeValuesOnly:p.encodeValuesOnly,filter:d,format:n,formatter:h,serializeDate:typeof r.serializeDate=="function"?r.serializeDate:p.serializeDate,skipNulls:typeof r.skipNulls=="boolean"?r.skipNulls:p.skipNulls,sort:typeof r.sort=="function"?r.sort:null,strictNullHandling:typeof r.strictNullHandling=="boolean"?r.strictNullHandling:p.strictNullHandling}};I.exports=function(r,a){var n,h,d=r,u=t(a);typeof u.filter=="function"?(h=u.filter,d=h("",d)):_(u.filter)&&(h=u.filter,n=h);var f=[];if(typeof d!="object"||d===null)return"";var l;l=a&&a.arrayFormat in L?a.arrayFormat:a&&"indices"in a?a.indices?"indices":"repeat":"indices";var o=L[l];n||(n=Object.keys(d)),u.sort&&n.sort(u.sort);for(var E=y(),m=0;m<n.length;++m){var O=n[m];u.skipNulls&&d[O]===null||D(f,i(d[O],O,o,u.strictNullHandling,u.skipNulls,u.encode?u.encoder:null,u.filter,u.sort,u.allowDots,u.serializeDate,u.format,u.formatter,u.encodeValuesOnly,u.charset,E))}var P=f.join(u.delimiter),M=u.addQueryPrefix===!0?"?":"";return u.charsetSentinel&&(u.charset==="iso-8859-1"?M+="utf8=%26%2310003%3B&":M+="utf8=%E2%9C%93&"),P.length>0?M+P:""}},function(I,c,R){"use strict";var y=R(8),x=R(47),b=R(49),T=y("%TypeError%"),L=y("%WeakMap%",!0),_=y("%Map%",!0),g=x("WeakMap.prototype.get",!0),A=x("WeakMap.prototype.set",!0),D=x("WeakMap.prototype.has",!0),S=x("Map.prototype.get",!0),v=x("Map.prototype.set",!0),p=x("Map.prototype.has",!0),s=function(r,a){for(var n,h=r;(n=h.next)!==null;h=n)if(n.key===a)return h.next=n.next,n.next=r.next,r.next=n,n},e=function(r,a){var n=s(r,a);return n&&n.value},i=function(r,a,n){var h=s(r,a);h?h.value=n:r.next={key:a,next:r.next,value:n}},t=function(r,a){return!!s(r,a)};I.exports=function(){var r,a,n,h={assert:function(d){if(!h.has(d))throw new T("Side channel does not contain "+b(d))},get:function(d){if(L&&d&&(typeof d=="object"||typeof d=="function")){if(r)return g(r,d)}else if(_){if(a)return S(a,d)}else if(n)return e(n,d)},has:function(d){if(L&&d&&(typeof d=="object"||typeof d=="function")){if(r)return D(r,d)}else if(_){if(a)return p(a,d)}else if(n)return t(n,d);return!1},set:function(d,u){L&&d&&(typeof d=="object"||typeof d=="function")?(r||(r=new L),A(r,d,u)):_?(a||(a=new _),v(a,d,u)):(n||(n={key:{},next:null}),i(n,d,u))}};return h}},function(I,c,R){"use strict";var y=typeof Symbol!="undefined"&&Symbol,x=R(44);I.exports=function(){return typeof y=="function"&&typeof Symbol=="function"&&typeof y("foo")=="symbol"&&typeof Symbol("bar")=="symbol"&&x()}},function(I,c,R){"use strict";I.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var y={},x=Symbol("test"),b=Object(x);if(typeof x=="string"||Object.prototype.toString.call(x)!=="[object Symbol]"||Object.prototype.toString.call(b)!=="[object Symbol]")return!1;y[x]=42;for(x in y)return!1;if(typeof Object.keys=="function"&&Object.keys(y).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(y).length!==0)return!1;var T=Object.getOwnPropertySymbols(y);if(T.length!==1||T[0]!==x||!Object.prototype.propertyIsEnumerable.call(y,x))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var L=Object.getOwnPropertyDescriptor(y,x);if(L.value!==42||L.enumerable!==!0)return!1}return!0}},function(I,c,R){"use strict";var y=Array.prototype.slice,x=Object.prototype.toString;I.exports=function(b){var T=this;if(typeof T!="function"||x.call(T)!=="[object Function]")throw new TypeError("Function.prototype.bind called on incompatible "+T);for(var L,_=y.call(arguments,1),g=function(){if(this instanceof L){var p=T.apply(this,_.concat(y.call(arguments)));return Object(p)===p?p:this}return T.apply(b,_.concat(y.call(arguments)))},A=Math.max(0,T.length-_.length),D=[],S=0;S<A;S++)D.push("$"+S);if(L=Function("binder","return function ("+D.join(",")+"){ return binder.apply(this,arguments); }")(g),T.prototype){var v=function(){};v.prototype=T.prototype,L.prototype=new v,v.prototype=null}return L}},function(I,c,R){"use strict";var y=R(9);I.exports=y.call(Function.call,Object.prototype.hasOwnProperty)},function(I,c,R){"use strict";var y=R(8),x=R(48),b=x(y("String.prototype.indexOf"));I.exports=function(T,L){var _=y(T,!!L);return typeof _=="function"&&b(T,".prototype.")>-1?x(_):_}},function(I,c,R){"use strict";var y=R(9),x=R(8),b=x("%Function.prototype.apply%"),T=x("%Function.prototype.call%"),L=x("%Reflect.apply%",!0)||y.call(T,b),_=x("%Object.getOwnPropertyDescriptor%",!0),g=x("%Object.defineProperty%",!0),A=x("%Math.max%");if(g)try{g({},"a",{value:1})}catch{g=null}I.exports=function(S){var v=L(y,T,arguments);return _&&g&&_(v,"length").configurable&&g(v,"length",{value:1+A(0,S.length-(arguments.length-1))}),v};var D=function(){return L(y,b,arguments)};g?g(I.exports,"apply",{value:D}):I.exports.apply=D},function(I,c,R){function y(W,H){if(W===1/0||W===-1/0||W!==W||W&&W>-1e3&&W<1e3||se.call(/e/,H))return H;var re=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof W=="number"){var ne=W<0?-ge(-W):ge(W);if(ne!==W){var me=String(ne),pe=q.call(H,me.length+1);return J.call(me,re,"$&_")+"."+J.call(J.call(pe,/([0-9]{3})/g,"$&_"),/_$/,"")}}return J.call(H,re,"$&_")}function x(W,H,re){var ne=(re.quoteStyle||H)==="double"?'"':"'";return ne+W+ne}function b(W){return J.call(String(W),/"/g,"&quot;")}function T(W){return!(e(W)!=="[object Array]"||de&&typeof W=="object"&&de in W)}function L(W){return!(e(W)!=="[object Date]"||de&&typeof W=="object"&&de in W)}function _(W){return!(e(W)!=="[object RegExp]"||de&&typeof W=="object"&&de in W)}function g(W){return!(e(W)!=="[object Error]"||de&&typeof W=="object"&&de in W)}function A(W){return!(e(W)!=="[object String]"||de&&typeof W=="object"&&de in W)}function D(W){return!(e(W)!=="[object Number]"||de&&typeof W=="object"&&de in W)}function S(W){return!(e(W)!=="[object Boolean]"||de&&typeof W=="object"&&de in W)}function v(W){if(Te)return W&&typeof W=="object"&&W instanceof Symbol;if(typeof W=="symbol")return!0;if(!W||typeof W!="object"||!le)return!1;try{return le.call(W),!0}catch{}return!1}function p(W){if(!W||typeof W!="object"||!Ee)return!1;try{return Ee.call(W),!0}catch{}return!1}function s(W,H){return Oe.call(W,H)}function e(W){return ce.call(W)}function i(W){if(W.name)return W.name;var H=ve.call(ae.call(W),/^function\s*([\w$]+)/);return H?H[1]:null}function t(W,H){if(W.indexOf)return W.indexOf(H);for(var re=0,ne=W.length;re<ne;re++)if(W[re]===H)return re;return-1}function r(W){if(!U||!W||typeof W!="object")return!1;try{U.call(W);try{K.call(W)}catch{return!0}return W instanceof Map}catch{}return!1}function a(W){if(!V||!W||typeof W!="object")return!1;try{V.call(W,V);try{z.call(W,z)}catch{return!0}return W instanceof WeakMap}catch{}return!1}function n(W){if(!X||!W||typeof W!="object")return!1;try{return X.call(W),!0}catch{}return!1}function h(W){if(!K||!W||typeof W!="object")return!1;try{K.call(W);try{U.call(W)}catch{return!0}return W instanceof Set}catch{}return!1}function d(W){if(!z||!W||typeof W!="object")return!1;try{z.call(W,z);try{V.call(W,V)}catch{return!0}return W instanceof WeakSet}catch{}return!1}function u(W){return!(!W||typeof W!="object")&&(typeof HTMLElement!="undefined"&&W instanceof HTMLElement||typeof W.nodeName=="string"&&typeof W.getAttribute=="function")}function f(W,H){if(W.length>H.maxStringLength){var re=W.length-H.maxStringLength,ne="... "+re+" more character"+(re>1?"s":"");return f(q.call(W,0,H.maxStringLength),H)+ne}return x(J.call(J.call(W,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,l),"single",H)}function l(W){var H=W.charCodeAt(0),re={8:"b",9:"t",10:"n",12:"f",13:"r"}[H];return re?"\\"+re:"\\x"+(H<16?"0":"")+$.call(H.toString(16))}function o(W){return"Object("+W+")"}function E(W){return W+" { ? }"}function m(W,H,re,ne){return W+" ("+H+") {"+(ne?M(re,ne):ue.call(re,", "))+"}"}function O(W){for(var H=0;H<W.length;H++)if(t(W[H],`
2
- `)>=0)return!1;return!0}function P(W,H){var re;if(W.indent===" ")re=" ";else{if(!(typeof W.indent=="number"&&W.indent>0))return null;re=ue.call(Array(W.indent+1)," ")}return{base:re,prev:ue.call(Array(H+1),re)}}function M(W,H){if(W.length===0)return"";var re=`
3
- `+H.prev+H.base;return re+ue.call(W,","+re)+`
4
- `+H.prev}function F(W,H){var re=T(W),ne=[];if(re){ne.length=W.length;for(var me=0;me<W.length;me++)ne[me]=s(W,me)?H(W[me],W):""}var pe,te=typeof oe=="function"?oe(W):[];if(Te){pe={};for(var Ae=0;Ae<te.length;Ae++)pe["$"+te[Ae]]=te[Ae]}for(var xe in W)s(W,xe)&&(re&&String(Number(xe))===xe&&xe<W.length||Te&&pe["$"+xe]instanceof Symbol||(se.call(/[^\w$]/,xe)?ne.push(H(xe,W)+": "+H(W[xe],W)):ne.push(xe+": "+H(W[xe],W))));if(typeof oe=="function")for(var Re=0;Re<te.length;Re++)De.call(W,te[Re])&&ne.push("["+H(te[Re])+"]: "+H(W[te[Re]],W));return ne}var B=typeof Map=="function"&&Map.prototype,C=Object.getOwnPropertyDescriptor&&B?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,U=B&&C&&typeof C.get=="function"?C.get:null,w=B&&Map.prototype.forEach,k=typeof Set=="function"&&Set.prototype,j=Object.getOwnPropertyDescriptor&&k?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,K=k&&j&&typeof j.get=="function"?j.get:null,G=k&&Set.prototype.forEach,Y=typeof WeakMap=="function"&&WeakMap.prototype,V=Y?WeakMap.prototype.has:null,Z=typeof WeakSet=="function"&&WeakSet.prototype,z=Z?WeakSet.prototype.has:null,ie=typeof WeakRef=="function"&&WeakRef.prototype,X=ie?WeakRef.prototype.deref:null,ee=Boolean.prototype.valueOf,ce=Object.prototype.toString,ae=Function.prototype.toString,ve=String.prototype.match,q=String.prototype.slice,J=String.prototype.replace,$=String.prototype.toUpperCase,Q=String.prototype.toLowerCase,se=RegExp.prototype.test,he=Array.prototype.concat,ue=Array.prototype.join,fe=Array.prototype.slice,ge=Math.floor,Ee=typeof BigInt=="function"?BigInt.prototype.valueOf:null,oe=Object.getOwnPropertySymbols,le=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Te=typeof Symbol=="function"&&typeof Symbol.iterator=="object",de=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Te?"object":"symbol")?Symbol.toStringTag:null,De=Object.prototype.propertyIsEnumerable,ye=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(W){return W.__proto__}:null),Se=R(50).custom,Le=Se&&v(Se)?Se:null;I.exports=function W(H,re,ne,me){function pe(Ce,Ge,Dt){if(Ge&&(me=fe.call(me),me.push(Ge)),Dt){var gt={depth:te.depth};return s(te,"quoteStyle")&&(gt.quoteStyle=te.quoteStyle),W(Ce,gt,ne+1,me)}return W(Ce,te,ne+1,me)}var te=re||{};if(s(te,"quoteStyle")&&te.quoteStyle!=="single"&&te.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(s(te,"maxStringLength")&&(typeof te.maxStringLength=="number"?te.maxStringLength<0&&te.maxStringLength!==1/0:te.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var Ae=!s(te,"customInspect")||te.customInspect;if(typeof Ae!="boolean"&&Ae!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(s(te,"indent")&&te.indent!==null&&te.indent!==" "&&!(parseInt(te.indent,10)===te.indent&&te.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(s(te,"numericSeparator")&&typeof te.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var xe=te.numericSeparator;if(H===void 0)return"undefined";if(H===null)return"null";if(typeof H=="boolean")return H?"true":"false";if(typeof H=="string")return f(H,te);if(typeof H=="number"){if(H===0)return 1/0/H>0?"0":"-0";var Re=String(H);return xe?y(H,Re):Re}if(typeof H=="bigint"){var we=String(H)+"n";return xe?y(H,we):we}var je=te.depth===void 0?5:te.depth;if(ne===void 0&&(ne=0),ne>=je&&je>0&&typeof H=="object")return T(H)?"[Array]":"[Object]";var Pe=P(te,ne);if(me===void 0)me=[];else if(t(me,H)>=0)return"[Circular]";if(typeof H=="function"){var We=i(H),Ie=F(H,pe);return"[Function"+(We?": "+We:" (anonymous)")+"]"+(Ie.length>0?" { "+ue.call(Ie,", ")+" }":"")}if(v(H)){var ke=Te?J.call(String(H),/^(Symbol\(.*\))_[^)]*$/,"$1"):le.call(H);return typeof H!="object"||Te?ke:o(ke)}if(u(H)){for(var Me="<"+Q.call(String(H.nodeName)),Ne=H.attributes||[],He=0;He<Ne.length;He++)Me+=" "+Ne[He].name+"="+x(b(Ne[He].value),"double",te);return Me+=">",H.childNodes&&H.childNodes.length&&(Me+="..."),Me+="</"+Q.call(String(H.nodeName))+">"}if(T(H)){if(H.length===0)return"[]";var Je=F(H,pe);return Pe&&!O(Je)?"["+M(Je,Pe)+"]":"[ "+ue.call(Je,", ")+" ]"}if(g(H)){var $e=F(H,pe);return"cause"in H&&!De.call(H,"cause")?"{ ["+String(H)+"] "+ue.call(he.call("[cause]: "+pe(H.cause),$e),", ")+" }":$e.length===0?"["+String(H)+"]":"{ ["+String(H)+"] "+ue.call($e,", ")+" }"}if(typeof H=="object"&&Ae){if(Le&&typeof H[Le]=="function")return H[Le]();if(Ae!=="symbol"&&typeof H.inspect=="function")return H.inspect()}if(r(H)){var dt=[];return w.call(H,function(Ce,Ge){dt.push(pe(Ge,H,!0)+" => "+pe(Ce,H))}),m("Map",U.call(H),dt,Pe)}if(h(H)){var ct=[];return G.call(H,function(Ce){ct.push(pe(Ce,H))}),m("Set",K.call(H),ct,Pe)}if(a(H))return E("WeakMap");if(d(H))return E("WeakSet");if(n(H))return E("WeakRef");if(D(H))return o(pe(Number(H)));if(p(H))return o(pe(Ee.call(H)));if(S(H))return o(ee.call(H));if(A(H))return o(pe(String(H)));if(!L(H)&&!_(H)){var Ze=F(H,pe),ht=ye?ye(H)===Object.prototype:H instanceof Object||H.constructor===Object,qe=H instanceof Object?"":"null prototype",vt=!ht&&de&&Object(H)===H&&de in H?q.call(e(H),8,-1):qe?"Object":"",At=ht||typeof H.constructor!="function"?"":H.constructor.name?H.constructor.name+" ":"",et=At+(vt||qe?"["+ue.call(he.call([],vt||[],qe||[]),": ")+"] ":"");return Ze.length===0?et+"{}":Pe?et+"{"+M(Ze,Pe)+"}":et+"{ "+ue.call(Ze,", ")+" }"}return String(H)};var Oe=Object.prototype.hasOwnProperty||function(W){return W in this}},function(I,c){},function(I,c,R){"use strict";var y=R(16),x=Object.prototype.hasOwnProperty,b=Array.isArray,T={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:y.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},L=function(v){return v.replace(/&#(\d+);/g,function(p,s){return String.fromCharCode(parseInt(s,10))})},_=function(v,p){return v&&typeof v=="string"&&p.comma&&v.indexOf(",")>-1?v.split(","):v},g=function(v,p){var s,e={},i=p.ignoreQueryPrefix?v.replace(/^\?/,""):v,t=p.parameterLimit===1/0?void 0:p.parameterLimit,r=i.split(p.delimiter,t),a=-1,n=p.charset;if(p.charsetSentinel)for(s=0;s<r.length;++s)r[s].indexOf("utf8=")===0&&(r[s]==="utf8=%E2%9C%93"?n="utf-8":r[s]==="utf8=%26%2310003%3B"&&(n="iso-8859-1"),a=s,s=r.length);for(s=0;s<r.length;++s)if(s!==a){var h,d,u=r[s],f=u.indexOf("]="),l=f===-1?u.indexOf("="):f+1;l===-1?(h=p.decoder(u,T.decoder,n,"key"),d=p.strictNullHandling?null:""):(h=p.decoder(u.slice(0,l),T.decoder,n,"key"),d=y.maybeMap(_(u.slice(l+1),p),function(o){return p.decoder(o,T.decoder,n,"value")})),d&&p.interpretNumericEntities&&n==="iso-8859-1"&&(d=L(d)),u.indexOf("[]=")>-1&&(d=b(d)?[d]:d),x.call(e,h)?e[h]=y.combine(e[h],d):e[h]=d}return e},A=function(v,p,s,e){for(var i=e?p:_(p,s),t=v.length-1;t>=0;--t){var r,a=v[t];if(a==="[]"&&s.parseArrays)r=[].concat(i);else{r=s.plainObjects?Object.create(null):{};var n=a.charAt(0)==="["&&a.charAt(a.length-1)==="]"?a.slice(1,-1):a,h=parseInt(n,10);s.parseArrays||n!==""?!isNaN(h)&&a!==n&&String(h)===n&&h>=0&&s.parseArrays&&h<=s.arrayLimit?(r=[],r[h]=i):n!=="__proto__"&&(r[n]=i):r={0:i}}i=r}return i},D=function(v,p,s,e){if(v){var i=s.allowDots?v.replace(/\.([^.[]+)/g,"[$1]"):v,t=/(\[[^[\]]*])/,r=/(\[[^[\]]*])/g,a=s.depth>0&&t.exec(i),n=a?i.slice(0,a.index):i,h=[];if(n){if(!s.plainObjects&&x.call(Object.prototype,n)&&!s.allowPrototypes)return;h.push(n)}for(var d=0;s.depth>0&&(a=r.exec(i))!==null&&d<s.depth;){if(d+=1,!s.plainObjects&&x.call(Object.prototype,a[1].slice(1,-1))&&!s.allowPrototypes)return;h.push(a[1])}return a&&h.push("["+i.slice(a.index)+"]"),A(h,p,s,e)}},S=function(v){if(!v)return T;if(v.decoder!==null&&v.decoder!==void 0&&typeof v.decoder!="function")throw new TypeError("Decoder has to be a function.");if(v.charset!==void 0&&v.charset!=="utf-8"&&v.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var p=v.charset===void 0?T.charset:v.charset;return{allowDots:v.allowDots===void 0?T.allowDots:!!v.allowDots,allowPrototypes:typeof v.allowPrototypes=="boolean"?v.allowPrototypes:T.allowPrototypes,allowSparse:typeof v.allowSparse=="boolean"?v.allowSparse:T.allowSparse,arrayLimit:typeof v.arrayLimit=="number"?v.arrayLimit:T.arrayLimit,charset:p,charsetSentinel:typeof v.charsetSentinel=="boolean"?v.charsetSentinel:T.charsetSentinel,comma:typeof v.comma=="boolean"?v.comma:T.comma,decoder:typeof v.decoder=="function"?v.decoder:T.decoder,delimiter:typeof v.delimiter=="string"||y.isRegExp(v.delimiter)?v.delimiter:T.delimiter,depth:typeof v.depth=="number"||v.depth===!1?+v.depth:T.depth,ignoreQueryPrefix:v.ignoreQueryPrefix===!0,interpretNumericEntities:typeof v.interpretNumericEntities=="boolean"?v.interpretNumericEntities:T.interpretNumericEntities,parameterLimit:typeof v.parameterLimit=="number"?v.parameterLimit:T.parameterLimit,parseArrays:v.parseArrays!==!1,plainObjects:typeof v.plainObjects=="boolean"?v.plainObjects:T.plainObjects,strictNullHandling:typeof v.strictNullHandling=="boolean"?v.strictNullHandling:T.strictNullHandling}};I.exports=function(v,p){var s=S(p);if(v===""||v===null||v===void 0)return s.plainObjects?Object.create(null):{};for(var e=typeof v=="string"?g(v,s):v,i=s.plainObjects?Object.create(null):{},t=Object.keys(e),r=0;r<t.length;++r){var a=t[r],n=D(a,e[a],s,typeof v=="string");i=y.merge(i,n,s)}return s.allowSparse===!0?i:y.compact(i)}},function(I,c,R){"use strict";var y,x,b=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(T){return typeof T}:function(T){return T&&typeof Symbol=="function"&&T.constructor===Symbol&&T!==Symbol.prototype?"symbol":typeof T};(function(T){var L=!1;if(y=T,(x=typeof y=="function"?y.call(c,R,c,I):y)!==void 0&&(I.exports=x),L=!0,b(c)==="object"&&(I.exports=T(),L=!0),!L){var _=window.Cookies,g=window.Cookies=T();g.noConflict=function(){return window.Cookies=_,g}}})(function(){function T(_){function g(A,D,S){var v;if(typeof document!="undefined"){if(arguments.length>1){if(S=L({path:"/"},g.defaults,S),typeof S.expires=="number"){var p=new Date;p.setMilliseconds(p.getMilliseconds()+864e5*S.expires),S.expires=p}try{v=JSON.stringify(D),/^[\{\[]/.test(v)&&(D=v)}catch{}return D=_.write?_.write(D,A):encodeURIComponent(String(D)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),A=encodeURIComponent(String(A)),A=A.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),A=A.replace(/[\(\)]/g,escape),document.cookie=[A,"=",D,S.expires?"; expires="+S.expires.toUTCString():"",S.path?"; path="+S.path:"",S.domain?"; domain="+S.domain:"",S.secure?"; secure":""].join("")}A||(v={});for(var s=document.cookie?document.cookie.split("; "):[],e=/(%[0-9A-Z]{2})+/g,i=0;i<s.length;i++){var t=s[i].split("="),r=t.slice(1).join("=");r.charAt(0)==='"'&&(r=r.slice(1,-1));try{var a=t[0].replace(e,decodeURIComponent);if(r=_.read?_.read(r,a):_(r,a)||r.replace(e,decodeURIComponent),this.json)try{r=JSON.parse(r)}catch{}if(A===a){v=r;break}A||(v[a]=r)}catch{}}return v}}return g.set=g,g.get=function(A){return g.call(g,A)},g.getJSON=function(){return g.apply({json:!0},[].slice.call(arguments))},g.defaults={},g.remove=function(A,D){g(A,"",L(D,{expires:-1}))},g.withConverter=T,g}var L=function(){for(var _=0,g={};_<arguments.length;_++){var A=arguments[_];for(var D in A)g[D]=A[D]}return g};return T(function(){})})},function(I,c,R){"use strict";function y(x,b){var T=b.beaconCollectionDomain,L=b.beaconDomain;if(T)return"https://"+T;x=x||"inferred";var _=L||"litix.io";return x.match(/^[a-z0-9]+$/)?"https://"+x+"."+_:"https://img.litix.io/a.gif"}Object.defineProperty(c,"__esModule",{value:!0}),c.default=y},function(I,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y=R(0),x=function(L){return L&&L.__esModule?L:{default:L}}(y),b=function(){var L=void 0;switch(T()){case"cellular":L="cellular";break;case"ethernet":L="wired";break;case"wifi":L="wifi";break;case void 0:break;default:L="other"}return L},T=function(){var L=x.default.navigator,_=L&&(L.connection||L.mozConnection||L.webkitConnection);return _&&_.type};c.default=b},function(I,c,R){"use strict";function y(r){return r&&r.__esModule?r:{default:r}}Object.defineProperty(c,"__esModule",{value:!0});var x=R(0),b=y(x),T=R(4),L=y(T),_=R(56),g=y(_),A=R(1),D=y(A),S=R(17),v=y(S),p=R(2),s=y(p),e=!!b.default.XMLHttpRequest&&"withCredentials"in new b.default.XMLHttpRequest,i={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4},t=function(r,a){this._beaconUrl=r||"https://img.litix.io",this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=(0,D.default)({},i,a)};t.prototype.queueEvent=function(r,a){var n=(0,D.default)({},a);return e?(this._eventQueue.length<=this._options.maxQueueLength||r==="eventrateexceeded")&&(this._eventQueue.push(n),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength):(g.default.send(this._beaconUrl,n),!0)},t.prototype.flushEvents=function(){e&&(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},t.prototype.destroy=function(){var r=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,r?this._clearBeaconQueue():this.flushEvents(),b.default.clearTimeout(this._sendTimeout)},t.prototype._clearBeaconQueue=function(){var r=b.default.navigator,a=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,n=this._eventQueue.slice(a);a>0&&(0,D.default)(n[n.length-1],(0,v.default)({mux_view_message:"event queue truncated"}));var h=this._createPayload(n);if(r.sendBeacon)r.sendBeacon(this._beaconUrl,h);else if(b.default.XMLHttpRequest){var d=new b.default.XMLHttpRequest;d.open("POST",this._beaconUrl),d.setRequestHeader("Content-Type","application/json"),d.send(h)}else g.default.send(this._beaconUrl,n[n.length-1])},t.prototype._sendBeaconQueue=function(){var r=this;if(b.default.XMLHttpRequest&&!this._postInFlight){var a=new b.default.XMLHttpRequest,n=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0,a.onreadystatechange=function(){a.readyState===4&&(a.status!==200?(r._eventQueue=n.concat(r._eventQueue),r._failureCount+=1,L.default.info("Error sending beacon: "+a.status),L.default.info(a.responseText)):r._failureCount=0,r._roundTripTime=s.default.now()-d,r._postInFlight=!1)},a.open("POST",this._beaconUrl),a.setRequestHeader("Content-Type","application/json");var h=this._createPayload(n),d=s.default.now();a.send(h)}},t.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var r=Math.pow(2,this._failureCount-1);return(1+(r*=Math.random()))*this._options.baseTimeBetweenBeacons},t.prototype._startBeaconSending=function(){var r=this;b.default.clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=b.default.setTimeout(function(){r._eventQueue.length&&r._sendBeaconQueue(),r._startBeaconSending()},this._getNextBeaconTime()))},t.prototype._createPayload=function(r){var a={transmission_timestamp:Math.round(s.default.now())};return this._roundTripTime&&(a.rtt_ms=Math.round(this._roundTripTime)),JSON.stringify({metadata:a,events:r})},c.default=t},function(I,c,R){"use strict";function y(g){return g&&g.__esModule?g:{default:g}}Object.defineProperty(c,"__esModule",{value:!0});var x=R(15),b=y(x),T=R(0),L=y(T),_={};_.send=function(g,A){function D(){S.src=p+(v?"&rc="+v:"")}var S=new Image,v=0,p=g+"?"+b.default.stringify(A);return S.addEventListener("error",function(){v>3||L.default.setTimeout(function(){v++,D()},5e3*v)}),D(),S},c.default=_},function(I,c,R){"use strict";function y(){function x(p,s){var e=s.request_start,i=s.request_response_start,t=s.request_response_end,r=s.request_bytes_loaded;A++;var a=void 0,n=void 0;if(i?(a=i-e,n=t-i):n=t-e,n>0&&r>0){var h=r/n*8e3;D++,_+=r,g+=n,this.data.view_min_request_throughput=Math.min(this.data.view_min_request_throughput||1/0,h),this.data.view_average_request_throughput=_/g*8e3,this.data.view_request_count=A,a>0&&(L+=a,this.data.view_max_request_latency=Math.max(this.data.view_max_request_latency||0,a),this.data.view_average_request_latency=L/D)}}function b(p,s){A++,S++,this.data.view_request_count=A,this.data.view_request_failed_count=S}function T(p,s){A++,v++,this.data.view_request_count=A,this.data.view_request_canceled_count=v}var L=0,_=0,g=0,A=0,D=0,S=0,v=0;this.on("requestcompleted",x),this.on("requestfailed",b),this.on("requestcanceled",T)}Object.defineProperty(c,"__esModule",{value:!0}),c.default=y},function(I,c,R){"use strict";function y(D,S,v){var p=(0,_.findMediaElement)(S),s=b(p,3),e=s[0],i=s[1],t=s[2],r=D.log,a=D.utils.getComputedStyle,n=D.utils.secondsToMs,h={automaticErrorTracking:!0};if(!e)return r.error("No element was found with the `"+i+"` query selector.");if(t!=="video"&&t!=="audio")return r.error("The element of `"+i+"` was not a media element.");v=(0,L.default)(h,v),v.data=(0,L.default)({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:"4.8.0"},v.data),v.getPlayheadTime=function(){return n(e.currentTime)},v.getStateData=function(){var u=this.hlsjs&&this.hlsjs.url,f=this.dashjs&&x(this.dashjs.getSource==="function")&&this.dashjs.getSource();return{player_is_paused:e.paused,player_playhead_time:n(e.currentTime),player_width:parseInt(a(e,"width")),player_height:parseInt(a(e,"height")),player_autoplay_on:e.autoplay,player_preload_on:e.preload,video_poster_url:e.poster,video_source_url:u||f||e.currentSrc,video_source_duration:n(e.duration),video_source_height:e.videoHeight,video_source_width:e.videoWidth}},e.mux=e.mux||{},e.mux.deleted=!1,e.mux.emit=function(u,f){D.emit(i,u,f)};var d=function(){r.error("The monitor for this video element has already been destroyed.")};e.mux.destroy=function(){Object.keys(e.mux.listeners).forEach(function(u){e.removeEventListener(u,e.mux.listeners[u],!1)}),delete e.mux.listeners,e.mux.destroy=d,e.mux.swapElement=d,e.mux.emit=d,e.mux.addHLSJS=d,e.mux.addDashJS=d,e.mux.removeHLSJS=d,e.mux.removeDashJS=d,e.mux.deleted=!0,D.emit(i,"destroy")},e.mux.swapElement=function(u){var f=(0,_.findMediaElement)(u),l=b(f,3),o=l[0],E=l[1],m=l[2];return o?m!=="video"&&m!=="audio"?D.log.error("The element of `"+E+"` was not a media element."):(o.muxId=e.muxId,delete e.muxId,o.mux=o.mux||{},o.mux.listeners=(0,L.default)({},e.mux.listeners),delete e.mux.listeners,Object.keys(o.mux.listeners).forEach(function(O){e.removeEventListener(O,o.mux.listeners[O],!1),o.addEventListener(O,o.mux.listeners[O],!1)}),o.mux.swapElement=e.mux.swapElement,o.mux.destroy=e.mux.destroy,delete e.mux,void(e=o)):D.log.error("No element was found with the `"+E+"` query selector.")},e.mux.addHLSJS=function(u){D.addHLSJS(i,u)},e.mux.addDashJS=function(u){D.addDashJS(i,u)},e.mux.removeHLSJS=function(){D.removeHLSJS(i)},e.mux.removeDashJS=function(){D.removeDashJS(i)},D.init(i,v),D.emit(i,"playerready"),e.paused||(D.emit(i,"play"),e.readyState>2&&D.emit(i,"playing")),e.mux.listeners={},g.forEach(function(u){(u!=="error"||v.automaticErrorTracking)&&(e.mux.listeners[u]=function(){var f={};if(u==="error"){if(!e.error||e.error.code===1)return;f.player_error_code=e.error.code,f.player_error_message=A[e.error.code]||e.error.message}D.emit(i,u,f)},e.addEventListener(u,e.mux.listeners[u],!1))})}Object.defineProperty(c,"__esModule",{value:!0});var x=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(D){return typeof D}:function(D){return D&&typeof Symbol=="function"&&D.constructor===Symbol&&D!==Symbol.prototype?"symbol":typeof D},b=function(){function D(S,v){var p=[],s=!0,e=!1,i=void 0;try{for(var t,r=S[Symbol.iterator]();!(s=(t=r.next()).done)&&(p.push(t.value),!v||p.length!==v);s=!0);}catch(a){e=!0,i=a}finally{try{!s&&r.return&&r.return()}finally{if(e)throw i}}return p}return function(S,v){if(Array.isArray(S))return S;if(Symbol.iterator in Object(S))return D(S,v);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();c.default=y;var T=R(1),L=function(D){return D&&D.__esModule?D:{default:D}}(T),_=R(11),g=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],A={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"}},function(I,c,R){"use strict";function y(h){return h&&h.__esModule?h:{default:h}}Object.defineProperty(c,"__esModule",{value:!0});var x=R(60),b=y(x),T=R(3),L=y(T),_=R(61),g=y(_),A=R(62),D=y(A),S=R(1),v=y(S),p=R(7),s=y(p),e=R(5),i=R(2),t=y(i),r=R(63),a=y(r),n={};n.safeCall=b.default,n.safeIncrement=L.default,n.getComputedStyle=g.default,n.secondsToMs=D.default,n.assign=v.default,n.headersStringToObject=s.default,n.extractHostnameAndDomain=e.extractHostnameAndDomain,n.extractHostname=e.extractHostname,n.now=t.default.now,n.manifestParser=a.default,c.default=n},function(I,c,R){"use strict";function y(T,L,_,g){var A=g;if(T&&typeof T[L]=="function")try{A=T[L].apply(T,_)}catch(D){b.default.info("safeCall error",D)}return A}Object.defineProperty(c,"__esModule",{value:!0}),c.default=y;var x=R(4),b=function(T){return T&&T.__esModule?T:{default:T}}(x)},function(I,c,R){"use strict";function y(L,_){if(L&&_&&b.default&&typeof b.default.getComputedStyle=="function"){var g=void 0;return T&&T.has(L)&&(g=T.get(L)),g||(g=b.default.getComputedStyle(L,null),T&&T.set(L,g)),g.getPropertyValue(_)}}Object.defineProperty(c,"__esModule",{value:!0}),c.default=y;var x=R(0),b=function(L){return L&&L.__esModule?L:{default:L}}(x),T=void 0;b.default&&b.default.WeakMap&&(T=new WeakMap)},function(I,c,R){"use strict";function y(x){return Math.floor(1e3*x)}Object.defineProperty(c,"__esModule",{value:!0}),c.default=y},function(I,c,R){"use strict";function y(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(c,"__esModule",{value:!0});var x=R(1),b=y(x),T=R(14),L=y(T),_={TARGET_DURATION:"#EXT-X-TARGETDURATION",PART_INF:"#EXT-X-PART-INF",SERVER_CONTROL:"#EXT-X-SERVER-CONTROL",INF:"#EXTINF",PROGRAM_DATE_TIME:"#EXT-X-PROGRAM-DATE-TIME",VERSION:"#EXT-X-VERSION",SESSION_DATA:"#EXT-X-SESSION-DATA"},g=function(t){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(t),this.manifest};g.prototype.process=function(t){var r=void 0;for(this.buffer+=t,r=this.buffer.indexOf(`
5
- `);r>-1;r=this.buffer.indexOf(`
6
- `))this.processLine(this.buffer.substring(0,r)),this.buffer=this.buffer.substring(r+1)},g.prototype.processLine=function(t){var r=t.indexOf(":"),a=e(t,r),n=a[0],h=a.length===2?S(a[1]):void 0;if(n[0]!=="#")this.currentUri.uri=n,this.manifest.segments.push(this.currentUri),!this.manifest.targetDuration||"duration"in this.currentUri||(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(n){case _.TARGET_DURATION:if(!isFinite(h)||h<0)return;this.manifest.targetDuration=h,this.setHoldBack();break;case _.PART_INF:A(this.manifest,a),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case _.SERVER_CONTROL:A(this.manifest,a),this.setHoldBack();break;case _.INF:h===0?this.currentUri.duration=.01:h>0&&(this.currentUri.duration=h);break;case _.PROGRAM_DATE_TIME:var d=h,u=new Date(d);this.manifest.dateTimeString||(this.manifest.dateTimeString=d,this.manifest.dateTimeObject=u),this.currentUri.dateTimeString=d,this.currentUri.dateTimeObject=u;break;case _.VERSION:A(this.manifest,a);break;case _.SESSION_DATA:var f=i(a[1]),l=(0,L.default)(f);(0,b.default)(this.manifest.sessionData,l)}},g.prototype.setHoldBack=function(){var t=this.manifest,r=t.serverControl,a=t.targetDuration,n=t.partTargetDuration;if(r){var h="holdBack",d="partHoldBack",u=a&&3*a,f=n&&2*n;a&&!r.hasOwnProperty(h)&&(r[h]=u),u&&r[h]<u&&(r[h]=u),n&&!r.hasOwnProperty(d)&&(r[d]=3*n),n&&r[d]<f&&(r[d]=f)}};var A=function(t,r){var a=D(r[0].replace("#EXT-X-","")),n=void 0;s(r[1])?(n={},n=(0,b.default)(p(r[1]),n)):n=S(r[1]),t[a]=n},D=function(t){return t.toLowerCase().replace(/-(\w)/g,function(r){return r[1].toUpperCase()})},S=function(t){if(t.toLowerCase()==="yes"||t.toLowerCase()==="no")return t.toLowerCase()==="yes";var r=t.indexOf(":")!==-1?t:parseFloat(t);return isNaN(r)?t:r},v=function(t){var r={},a=t.split("=");return a.length>1&&(r[D(a[0])]=S(a[1])),r},p=function(t){for(var r=t.split(","),a={},n=0;r.length>n;n++){var h=r[n],d=v(h);a=(0,b.default)(d,a)}return a},s=function(t){return t.indexOf("=")>-1},e=function(t,r){return r===-1?[t]:[t.substring(0,r),t.substring(r+1)]},i=function(t){var r={};if(t){var a=t.search(",");return[t.slice(0,a),t.slice(a+1)].forEach(function(n,h){for(var d=n.replace(/['"]+/g,"").split("="),u=0;u<d.length;u++)d[u]==="DATA-ID"&&(r["DATA-ID"]=d[1-u]),d[u]==="VALUE"&&(r.VALUE=d[1-u])}),{data:r}}};c.default=g},function(I,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y={PLAYER_READY:"playerready",VIEW_INIT:"viewinit",VIDEO_CHANGE:"videochange",PLAY:"play",PAUSE:"pause",PLAYING:"playing",TIME_UPDATE:"timeupdate",SEEKING:"seeking",SEEKED:"seeked",REBUFFER_START:"rebufferstart",REBUFFER_END:"rebufferend",ERROR:"error",ENDED:"ended",RENDITION_CHANGE:"renditionchange",ORIENTATION_CHANGE:"orientationchange",AD_REQUEST:"adrequest",AD_RESPONSE:"adresponse",AD_BREAK_START:"adbreakstart",AD_PLAY:"adplay",AD_PLAYING:"adplaying",AD_PAUSE:"adpause",AD_FIRST_QUARTILE:"adfirstquartile",AD_MID_POINT:"admidpoint",AD_THIRD_QUARTILE:"adthirdquartile",AD_ENDED:"adended",AD_BREAK_END:"adbreakend",AD_ERROR:"aderror",REQUEST_COMPLETED:"requestcompleted",REQUEST_FAILED:"requestfailed",REQUEST_CANCELLED:"requestcanceled"};c.default=y}])})})()});var Xe=mt((Ke,it)=>{typeof window!="undefined"&&function(I,c){typeof Ke=="object"&&typeof it=="object"?it.exports=c():typeof define=="function"&&define.amd?define([],c):typeof Ke=="object"?Ke.Hls=c():I.Hls=c()}(Ke,function(){return function(N){var I={};function c(R){if(I[R])return I[R].exports;var y=I[R]={i:R,l:!1,exports:{}};return N[R].call(y.exports,y,y.exports,c),y.l=!0,y.exports}return c.m=N,c.c=I,c.d=function(R,y,x){c.o(R,y)||Object.defineProperty(R,y,{enumerable:!0,get:x})},c.r=function(R){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(R,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(R,"__esModule",{value:!0})},c.t=function(R,y){if(y&1&&(R=c(R)),y&8||y&4&&typeof R=="object"&&R&&R.__esModule)return R;var x=Object.create(null);if(c.r(x),Object.defineProperty(x,"default",{enumerable:!0,value:R}),y&2&&typeof R!="string")for(var b in R)c.d(x,b,function(T){return R[T]}.bind(null,b));return x},c.n=function(R){var y=R&&R.__esModule?function(){return R.default}:function(){return R};return c.d(y,"a",y),y},c.o=function(R,y){return Object.prototype.hasOwnProperty.call(R,y)},c.p="/dist/",c(c.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(N,I,c){"use strict";var R=Object.prototype.hasOwnProperty,y="~";function x(){}Object.create&&(x.prototype=Object.create(null),new x().__proto__||(y=!1));function b(g,A,D){this.fn=g,this.context=A,this.once=D||!1}function T(g,A,D,S,v){if(typeof D!="function")throw new TypeError("The listener must be a function");var p=new b(D,S||g,v),s=y?y+A:A;return g._events[s]?g._events[s].fn?g._events[s]=[g._events[s],p]:g._events[s].push(p):(g._events[s]=p,g._eventsCount++),g}function L(g,A){--g._eventsCount==0?g._events=new x:delete g._events[A]}function _(){this._events=new x,this._eventsCount=0}_.prototype.eventNames=function(){var A=[],D,S;if(this._eventsCount===0)return A;for(S in D=this._events)R.call(D,S)&&A.push(y?S.slice(1):S);return Object.getOwnPropertySymbols?A.concat(Object.getOwnPropertySymbols(D)):A},_.prototype.listeners=function(A){var D=y?y+A:A,S=this._events[D];if(!S)return[];if(S.fn)return[S.fn];for(var v=0,p=S.length,s=new Array(p);v<p;v++)s[v]=S[v].fn;return s},_.prototype.listenerCount=function(A){var D=y?y+A:A,S=this._events[D];return S?S.fn?1:S.length:0},_.prototype.emit=function(A,D,S,v,p,s){var e=y?y+A:A;if(!this._events[e])return!1;var i=this._events[e],t=arguments.length,r,a;if(i.fn){switch(i.once&&this.removeListener(A,i.fn,void 0,!0),t){case 1:return i.fn.call(i.context),!0;case 2:return i.fn.call(i.context,D),!0;case 3:return i.fn.call(i.context,D,S),!0;case 4:return i.fn.call(i.context,D,S,v),!0;case 5:return i.fn.call(i.context,D,S,v,p),!0;case 6:return i.fn.call(i.context,D,S,v,p,s),!0}for(a=1,r=new Array(t-1);a<t;a++)r[a-1]=arguments[a];i.fn.apply(i.context,r)}else{var n=i.length,h;for(a=0;a<n;a++)switch(i[a].once&&this.removeListener(A,i[a].fn,void 0,!0),t){case 1:i[a].fn.call(i[a].context);break;case 2:i[a].fn.call(i[a].context,D);break;case 3:i[a].fn.call(i[a].context,D,S);break;case 4:i[a].fn.call(i[a].context,D,S,v);break;default:if(!r)for(h=1,r=new Array(t-1);h<t;h++)r[h-1]=arguments[h];i[a].fn.apply(i[a].context,r)}}return!0},_.prototype.on=function(A,D,S){return T(this,A,D,S,!1)},_.prototype.once=function(A,D,S){return T(this,A,D,S,!0)},_.prototype.removeListener=function(A,D,S,v){var p=y?y+A:A;if(!this._events[p])return this;if(!D)return L(this,p),this;var s=this._events[p];if(s.fn)s.fn===D&&(!v||s.once)&&(!S||s.context===S)&&L(this,p);else{for(var e=0,i=[],t=s.length;e<t;e++)(s[e].fn!==D||v&&!s[e].once||S&&s[e].context!==S)&&i.push(s[e]);i.length?this._events[p]=i.length===1?i[0]:i:L(this,p)}return this},_.prototype.removeAllListeners=function(A){var D;return A?(D=y?y+A:A,this._events[D]&&L(this,D)):(this._events=new x,this._eventsCount=0),this},_.prototype.off=_.prototype.removeListener,_.prototype.addListener=_.prototype.on,_.prefixed=y,_.EventEmitter=_,N.exports=_},"./node_modules/url-toolkit/src/url-toolkit.js":function(N,I,c){(function(R){var y=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,x=/^([^\/?#]*)([^]*)$/,b=/(?:\/|^)\.(?=\/)/g,T=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,L={buildAbsoluteURL:function(_,g,A){if(A=A||{},_=_.trim(),g=g.trim(),!g){if(!A.alwaysNormalize)return _;var D=L.parseURL(_);if(!D)throw new Error("Error trying to parse base URL.");return D.path=L.normalizePath(D.path),L.buildURLFromParts(D)}var S=L.parseURL(g);if(!S)throw new Error("Error trying to parse relative URL.");if(S.scheme)return A.alwaysNormalize?(S.path=L.normalizePath(S.path),L.buildURLFromParts(S)):g;var v=L.parseURL(_);if(!v)throw new Error("Error trying to parse base URL.");if(!v.netLoc&&v.path&&v.path[0]!=="/"){var p=x.exec(v.path);v.netLoc=p[1],v.path=p[2]}v.netLoc&&!v.path&&(v.path="/");var s={scheme:v.scheme,netLoc:S.netLoc,path:null,params:S.params,query:S.query,fragment:S.fragment};if(!S.netLoc&&(s.netLoc=v.netLoc,S.path[0]!=="/"))if(!S.path)s.path=v.path,S.params||(s.params=v.params,S.query||(s.query=v.query));else{var e=v.path,i=e.substring(0,e.lastIndexOf("/")+1)+S.path;s.path=L.normalizePath(i)}return s.path===null&&(s.path=A.alwaysNormalize?L.normalizePath(S.path):S.path),L.buildURLFromParts(s)},parseURL:function(_){var g=y.exec(_);return g?{scheme:g[1]||"",netLoc:g[2]||"",path:g[3]||"",params:g[4]||"",query:g[5]||"",fragment:g[6]||""}:null},normalizePath:function(_){for(_=_.split("").reverse().join("").replace(b,"");_.length!==(_=_.replace(T,"")).length;);return _.split("").reverse().join("")},buildURLFromParts:function(_){return _.scheme+_.netLoc+_.path+_.params+_.query+_.fragment}};N.exports=L})(this)},"./node_modules/webworkify-webpack/index.js":function(N,I,c){function R(A){var D={};function S(p){if(D[p])return D[p].exports;var s=D[p]={i:p,l:!1,exports:{}};return A[p].call(s.exports,s,s.exports,S),s.l=!0,s.exports}S.m=A,S.c=D,S.i=function(p){return p},S.d=function(p,s,e){S.o(p,s)||Object.defineProperty(p,s,{configurable:!1,enumerable:!0,get:e})},S.r=function(p){Object.defineProperty(p,"__esModule",{value:!0})},S.n=function(p){var s=p&&p.__esModule?function(){return p.default}:function(){return p};return S.d(s,"a",s),s},S.o=function(p,s){return Object.prototype.hasOwnProperty.call(p,s)},S.p="/",S.oe=function(p){throw console.error(p),p};var v=S(S.s=ENTRY_MODULE);return v.default||v}var y="[\\.|\\-|\\+|\\w|/|@]+",x="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+y+").*?\\)";function b(A){return(A+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function T(A){return!isNaN(1*A)}function L(A,D,S){var v={};v[S]=[];var p=D.toString(),s=p.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!s)return v;for(var e=s[1],i=new RegExp("(\\\\n|\\W)"+b(e)+x,"g"),t;t=i.exec(p);)t[3]!=="dll-reference"&&v[S].push(t[3]);for(i=new RegExp("\\("+b(e)+'\\("(dll-reference\\s('+y+'))"\\)\\)'+x,"g");t=i.exec(p);)A[t[2]]||(v[S].push(t[1]),A[t[2]]=c(t[1]).m),v[t[2]]=v[t[2]]||[],v[t[2]].push(t[4]);for(var r=Object.keys(v),a=0;a<r.length;a++)for(var n=0;n<v[r[a]].length;n++)T(v[r[a]][n])&&(v[r[a]][n]=1*v[r[a]][n]);return v}function _(A){var D=Object.keys(A);return D.reduce(function(S,v){return S||A[v].length>0},!1)}function g(A,D){for(var S={main:[D]},v={main:[]},p={main:{}};_(S);)for(var s=Object.keys(S),e=0;e<s.length;e++){var i=s[e],t=S[i],r=t.pop();if(p[i]=p[i]||{},!(p[i][r]||!A[i][r])){p[i][r]=!0,v[i]=v[i]||[],v[i].push(r);for(var a=L(A,A[i][r],i),n=Object.keys(a),h=0;h<n.length;h++)S[n[h]]=S[n[h]]||[],S[n[h]]=S[n[h]].concat(a[n[h]])}}return v}N.exports=function(A,D){D=D||{};var S={main:c.m},v=D.all?{main:Object.keys(S.main)}:g(S,A),p="";Object.keys(v).filter(function(r){return r!=="main"}).forEach(function(r){for(var a=0;v[r][a];)a++;v[r].push(a),S[r][a]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",p=p+"var "+r+" = ("+R.toString().replace("ENTRY_MODULE",JSON.stringify(a))+")({"+v[r].map(function(n){return""+JSON.stringify(n)+": "+S[r][n].toString()}).join(",")+`});
7
- `}),p=p+"new (("+R.toString().replace("ENTRY_MODULE",JSON.stringify(A))+")({"+v.main.map(function(r){return""+JSON.stringify(r)+": "+S.main[r].toString()}).join(",")+"}))(self);";var s=new window.Blob([p],{type:"text/javascript"});if(D.bare)return s;var e=window.URL||window.webkitURL||window.mozURL||window.msURL,i=e.createObjectURL(s),t=new window.Worker(i);return t.objectURL=i,t}},"./src/config.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"hlsDefaultConfig",function(){return h}),c.d(I,"mergeConfig",function(){return u}),c.d(I,"enableStreamingMode",function(){return f});var R=c("./src/controller/abr-controller.ts"),y=c("./src/controller/audio-stream-controller.ts"),x=c("./src/controller/audio-track-controller.ts"),b=c("./src/controller/subtitle-stream-controller.ts"),T=c("./src/controller/subtitle-track-controller.ts"),L=c("./src/controller/buffer-controller.ts"),_=c("./src/controller/timeline-controller.ts"),g=c("./src/controller/cap-level-controller.ts"),A=c("./src/controller/fps-controller.ts"),D=c("./src/controller/eme-controller.ts"),S=c("./src/controller/cmcd-controller.ts"),v=c("./src/utils/xhr-loader.ts"),p=c("./src/utils/fetch-loader.ts"),s=c("./src/utils/cues.ts"),e=c("./src/utils/mediakeys-helper.ts"),i=c("./src/utils/logger.ts");function t(){return t=Object.assign||function(l){for(var o=1;o<arguments.length;o++){var E=arguments[o];for(var m in E)Object.prototype.hasOwnProperty.call(E,m)&&(l[m]=E[m])}return l},t.apply(this,arguments)}function r(l,o){var E=Object.keys(l);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(l);o&&(m=m.filter(function(O){return Object.getOwnPropertyDescriptor(l,O).enumerable})),E.push.apply(E,m)}return E}function a(l){for(var o=1;o<arguments.length;o++){var E=arguments[o]!=null?arguments[o]:{};o%2?r(Object(E),!0).forEach(function(m){n(l,m,E[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(E)):r(Object(E)).forEach(function(m){Object.defineProperty(l,m,Object.getOwnPropertyDescriptor(E,m))})}return l}function n(l,o,E){return o in l?Object.defineProperty(l,o,{value:E,enumerable:!0,configurable:!0,writable:!0}):l[o]=E,l}var h=a(a({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:v.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:R.default,bufferController:L.default,capLevelController:g.default,fpsController:A.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:e.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},d()),{},{subtitleStreamController:b.SubtitleStreamController,subtitleTrackController:T.default,timelineController:_.TimelineController,audioStreamController:y.default,audioTrackController:x.default,emeController:D.default,cmcdController:S.default});function d(){return{cueHandler:s.default,enableCEA708Captions:!0,enableWebVTT:!0,enableIMSC1:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function u(l,o){if((o.liveSyncDurationCount||o.liveMaxLatencyDurationCount)&&(o.liveSyncDuration||o.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(o.liveMaxLatencyDurationCount!==void 0&&(o.liveSyncDurationCount===void 0||o.liveMaxLatencyDurationCount<=o.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(o.liveMaxLatencyDuration!==void 0&&(o.liveSyncDuration===void 0||o.liveMaxLatencyDuration<=o.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return t({},l,o)}function f(l){var o=l.loader;if(o!==p.default&&o!==v.default)i.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),l.progressive=!1;else{var E=Object(p.fetchSupported)();E&&(l.loader=p.default,l.progressive=!0,l.enableSoftwareAES=!0,i.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(N,I,c){"use strict";c.r(I);var R=c("./src/polyfills/number.ts"),y=c("./src/utils/ewma-bandwidth-estimator.ts"),x=c("./src/events.ts"),b=c("./src/utils/buffer-helper.ts"),T=c("./src/errors.ts"),L=c("./src/types/loader.ts"),_=c("./src/utils/logger.ts");function g(S,v){for(var p=0;p<v.length;p++){var s=v[p];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(S,s.key,s)}}function A(S,v,p){return v&&g(S.prototype,v),p&&g(S,p),S}var D=function(){function S(p){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=p;var s=p.config;this.bwEstimator=new y.default(s.abrEwmaSlowVoD,s.abrEwmaFastVoD,s.abrEwmaDefaultEstimate),this.registerListeners()}var v=S.prototype;return v.registerListeners=function(){var s=this.hls;s.on(x.Events.FRAG_LOADING,this.onFragLoading,this),s.on(x.Events.FRAG_LOADED,this.onFragLoaded,this),s.on(x.Events.FRAG_BUFFERED,this.onFragBuffered,this),s.on(x.Events.LEVEL_LOADED,this.onLevelLoaded,this),s.on(x.Events.ERROR,this.onError,this)},v.unregisterListeners=function(){var s=this.hls;s.off(x.Events.FRAG_LOADING,this.onFragLoading,this),s.off(x.Events.FRAG_LOADED,this.onFragLoaded,this),s.off(x.Events.FRAG_BUFFERED,this.onFragBuffered,this),s.off(x.Events.LEVEL_LOADED,this.onLevelLoaded,this),s.off(x.Events.ERROR,this.onError,this)},v.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},v.onFragLoading=function(s,e){var i=e.frag;if(i.type===L.PlaylistLevelType.MAIN&&!this.timer){var t;this.fragCurrent=i,this.partCurrent=(t=e.part)!=null?t:null,this.timer=self.setInterval(this.onCheck,100)}},v.onLevelLoaded=function(s,e){var i=this.hls.config;e.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD)},v._abandonRulesCheck=function(){var s=this.fragCurrent,e=this.partCurrent,i=this.hls,t=i.autoLevelEnabled,r=i.config,a=i.media;if(!(!s||!a)){var n=e?e.stats:s.stats,h=e?e.duration:s.duration;if(n.aborted){_.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!(!t||a.paused||!a.playbackRate||!a.readyState)){var d=performance.now()-n.loading.start,u=Math.abs(a.playbackRate);if(!(d<=500*h/u)){var f=i.levels,l=i.minAutoLevel,o=f[s.level],E=n.total||Math.max(n.loaded,Math.round(h*o.maxBitrate/8)),m=Math.max(1,n.bwEstimate?n.bwEstimate/8:n.loaded*1e3/d),O=(E-n.loaded)/m,P=a.currentTime,M=(b.BufferHelper.bufferInfo(a,P,r.maxBufferHole).end-P)/u;if(!(M>=2*h/u||O<=M)){var F=Number.POSITIVE_INFINITY,B;for(B=s.level-1;B>l;B--){var C=f[B].maxBitrate;if(F=h*C/(8*.8*m),F<M)break}if(!(F>=O)){var U=this.bwEstimator.getEstimate();_.logger.warn("Fragment "+s.sn+(e?" part "+e.index:"")+" of level "+s.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+B+`
1
+ "use strict";(()=>{var wt=Object.create;var pt=Object.defineProperty;var Ut=Object.getOwnPropertyDescriptor;var Bt=Object.getOwnPropertyNames;var kt=Object.getPrototypeOf,Nt=Object.prototype.hasOwnProperty;var yt=(K,P)=>()=>(P||K((P={exports:{}}).exports,P),P.exports);var Kt=(K,P,h,R)=>{if(P&&typeof P=="object"||typeof P=="function")for(let p of Bt(P))!Nt.call(K,p)&&p!==h&&pt(K,p,{get:()=>P[p],enumerable:!(R=Ut(P,p))||R.enumerable});return K};var tt=(K,P,h)=>(h=K!=null?wt(kt(K)):{},Kt(P||!K||!K.__esModule?pt(h,"default",{value:K,enumerable:!0}):h,K));var Et=yt((rt,at)=>{(function(){var K=!1;(function(P,h){typeof rt=="object"&&typeof at=="object"?at.exports=h():typeof K=="function"&&K.amd?K("mux",[],h):typeof rt=="object"?rt.mux=h():P.mux=h()})(typeof self!="undefined"?self:this,function(){return function(P){function h(p){if(R[p])return R[p].exports;var S=R[p]={i:p,l:!1,exports:{}};return P[p].call(S.exports,S,S.exports,h),S.l=!0,S.exports}var R={};return h.m=P,h.c=R,h.d=function(p,S,I){h.o(p,S)||Object.defineProperty(p,S,{configurable:!1,enumerable:!0,get:I})},h.n=function(p){var S=p&&p.__esModule?function(){return p.default}:function(){return p};return h.d(S,"a",S),S},h.o=function(p,S){return Object.prototype.hasOwnProperty.call(p,S)},h.p="",h(h.s=18)}([function(P,h,R){(function(p){var S;S=typeof window!="undefined"?window:p!==void 0?p:typeof self!="undefined"?self:{},P.exports=S}).call(h,R(20))},function(P,h){function R(C,U,B){switch(B.length){case 0:return C.call(U);case 1:return C.call(U,B[0]);case 2:return C.call(U,B[0],B[1]);case 3:return C.call(U,B[0],B[1],B[2])}return C.apply(U,B)}function p(C,U){for(var B=-1,N=Array(C);++B<C;)N[B]=U(B);return N}function S(C,U){var B=F(C)||g(C)?p(C.length,String):[],N=B.length,k=!!N;for(var j in C)!U&&!o.call(C,j)||k&&(j=="length"||y(j,N))||B.push(j);return B}function I(C,U,B){var N=C[U];o.call(C,U)&&T(N,B)&&(B!==void 0||U in C)||(C[U]=B)}function x(C){if(!_(C))return O(C);var U=[];for(var B in Object(C))o.call(C,B)&&B!="constructor"&&U.push(B);return U}function L(C,U){return U=b(U===void 0?C.length-1:U,0),function(){for(var B=arguments,N=-1,k=b(B.length-U,0),j=Array(k);++N<k;)j[N]=B[U+N];N=-1;for(var H=Array(U+1);++N<U;)H[N]=B[N];return H[U]=j,R(C,this,H)}}function A(C,U,B,N){B||(B={});for(var k=-1,j=U.length;++k<j;){var H=U[k],V=N?N(B[H],C[H],H,B,C):void 0;I(B,H,V===void 0?C[H]:V)}return B}function y(C,U){return!!(U=U==null?t:U)&&(typeof C=="number"||c.test(C))&&C>-1&&C%1==0&&C<U}function D(C,U,B){if(!u(B))return!1;var N=typeof U;return!!(N=="number"?E(B)&&y(U,B.length):N=="string"&&U in B)&&T(B[U],C)}function _(C){var U=C&&C.constructor;return C===(typeof U=="function"&&U.prototype||f)}function T(C,U){return C===U||C!==C&&U!==U}function g(C){return a(C)&&o.call(C,"callee")&&(!m.call(C,"callee")||v.call(C)==l)}function E(C){return C!=null&&s(C.length)&&!e(C)}function a(C){return n(C)&&E(C)}function e(C){var U=u(C)?v.call(C):"";return U==d||U==r}function s(C){return typeof C=="number"&&C>-1&&C%1==0&&C<=t}function u(C){var U=typeof C;return!!C&&(U=="object"||U=="function")}function n(C){return!!C&&typeof C=="object"}function i(C){return E(C)?S(C):x(C)}var t=9007199254740991,l="[object Arguments]",d="[object Function]",r="[object GeneratorFunction]",c=/^(?:0|[1-9]\d*)$/,f=Object.prototype,o=f.hasOwnProperty,v=f.toString,m=f.propertyIsEnumerable,O=function(C,U){return function(B){return C(U(B))}}(Object.keys,Object),b=Math.max,M=!m.call({valueOf:1},"valueOf"),F=Array.isArray,w=function(C){return L(function(U,B){var N=-1,k=B.length,j=k>1?B[k-1]:void 0,H=k>2?B[2]:void 0;for(j=C.length>3&&typeof j=="function"?(k--,j):void 0,H&&D(B[0],B[1],H)&&(j=k<3?void 0:j,k=1),U=Object(U);++N<k;){var V=B[N];V&&C(U,V,N,j)}return U})}(function(C,U){if(M||_(U)||E(U))return void A(U,i(U),C);for(var B in U)o.call(U,B)&&I(C,B,U[B])});P.exports=w},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=R(0),S=function(x){return x&&x.__esModule?x:{default:x}}(p),I={};I.now=function(){var x=S.default.performance,L=x&&x.timing;return L&&typeof L.navigationStart=="number"&&typeof x.now=="function"?L.navigationStart+x.now():Date.now()},h.default=I},function(P,h,R){"use strict";function p(S,I,x){x=x===void 0?1:x,S[I]=S[I]||0,S[I]+=x}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=R(21),S=function(x){return x&&x.__esModule?x:{default:x}}(p),I=S.default.methodFactory;S.default.methodFactory=function(x,L,A){var y=I(x,L,A);return function(){for(var D=["[mux]"],_=0;_<arguments.length;_++)D.push(arguments[_]);y.apply(void 0,D)}},S.default.setLevel(S.default.getLevel()),h.default=S.default},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=function(x){return I(x)[0]},S=function(x){return I(x)[1]},I=function(x){if(typeof x!="string"||x==="")return["localhost"];var L=/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,A=x.match(L)||[],y=A[4],D=void 0;return y&&(D=(y.match(/[^\.]+\.[^\.]+$/)||[])[0]),[y,D]};h.extractHostnameAndDomain=I,h.extractHostname=p,h.extractDomain=S},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(I){var x=16*Math.random()|0;return(I==="x"?x:3&x|8).toString(16)})},S=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)};h.generateUUID=p,h.generateShortID=S},function(P,h,R){"use strict";function p(I){I=I||"";var x={};return I.trim().split(/[\r\n]+/).forEach(function(L){if(L){var A=L.split(": "),y=A.shift();y&&(S.indexOf(y.toLowerCase())>=0||y.toLowerCase().indexOf("x-litix-")===0)&&(x[y]=A.join(": "))}}),x}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p;var S=["x-cdn","content-type"]},function(P,h,R){"use strict";var p=SyntaxError,S=Function,I=TypeError,x=function(o){try{return S('"use strict"; return ('+o+").constructor;")()}catch{}},L=Object.getOwnPropertyDescriptor;if(L)try{L({},"")}catch{L=null}var A=function(){throw new I},y=L?function(){try{return arguments.callee,A}catch{try{return L(arguments,"callee").get}catch{return A}}}():A,D=R(43)(),_=Object.getPrototypeOf||function(o){return o.__proto__},T={},g=typeof Uint8Array=="undefined"?void 0:_(Uint8Array),E={"%AggregateError%":typeof AggregateError=="undefined"?void 0:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer=="undefined"?void 0:ArrayBuffer,"%ArrayIteratorPrototype%":D?_([][Symbol.iterator]()):void 0,"%AsyncFromSyncIteratorPrototype%":void 0,"%AsyncFunction%":T,"%AsyncGenerator%":T,"%AsyncGeneratorFunction%":T,"%AsyncIteratorPrototype%":T,"%Atomics%":typeof Atomics=="undefined"?void 0:Atomics,"%BigInt%":typeof BigInt=="undefined"?void 0:BigInt,"%Boolean%":Boolean,"%DataView%":typeof DataView=="undefined"?void 0:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array=="undefined"?void 0:Float32Array,"%Float64Array%":typeof Float64Array=="undefined"?void 0:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry=="undefined"?void 0:FinalizationRegistry,"%Function%":S,"%GeneratorFunction%":T,"%Int8Array%":typeof Int8Array=="undefined"?void 0:Int8Array,"%Int16Array%":typeof Int16Array=="undefined"?void 0:Int16Array,"%Int32Array%":typeof Int32Array=="undefined"?void 0:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":D?_(_([][Symbol.iterator]())):void 0,"%JSON%":typeof JSON=="object"?JSON:void 0,"%Map%":typeof Map=="undefined"?void 0:Map,"%MapIteratorPrototype%":typeof Map!="undefined"&&D?_(new Map()[Symbol.iterator]()):void 0,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise=="undefined"?void 0:Promise,"%Proxy%":typeof Proxy=="undefined"?void 0:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect=="undefined"?void 0:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set=="undefined"?void 0:Set,"%SetIteratorPrototype%":typeof Set!="undefined"&&D?_(new Set()[Symbol.iterator]()):void 0,"%SharedArrayBuffer%":typeof SharedArrayBuffer=="undefined"?void 0:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":D?_(""[Symbol.iterator]()):void 0,"%Symbol%":D?Symbol:void 0,"%SyntaxError%":p,"%ThrowTypeError%":y,"%TypedArray%":g,"%TypeError%":I,"%Uint8Array%":typeof Uint8Array=="undefined"?void 0:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray=="undefined"?void 0:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array=="undefined"?void 0:Uint16Array,"%Uint32Array%":typeof Uint32Array=="undefined"?void 0:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap=="undefined"?void 0:WeakMap,"%WeakRef%":typeof WeakRef=="undefined"?void 0:WeakRef,"%WeakSet%":typeof WeakSet=="undefined"?void 0:WeakSet},a=function o(v){var m;if(v==="%AsyncFunction%")m=x("async function () {}");else if(v==="%GeneratorFunction%")m=x("function* () {}");else if(v==="%AsyncGeneratorFunction%")m=x("async function* () {}");else if(v==="%AsyncGenerator%"){var O=o("%AsyncGeneratorFunction%");O&&(m=O.prototype)}else if(v==="%AsyncIteratorPrototype%"){var b=o("%AsyncGenerator%");b&&(m=_(b.prototype))}return E[v]=m,m},e={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},s=R(9),u=R(46),n=s.call(Function.call,Array.prototype.concat),i=s.call(Function.apply,Array.prototype.splice),t=s.call(Function.call,String.prototype.replace),l=s.call(Function.call,String.prototype.slice),d=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,r=/\\(\\)?/g,c=function(o){var v=l(o,0,1),m=l(o,-1);if(v==="%"&&m!=="%")throw new p("invalid intrinsic syntax, expected closing `%`");if(m==="%"&&v!=="%")throw new p("invalid intrinsic syntax, expected opening `%`");var O=[];return t(o,d,function(b,M,F,w){O[O.length]=F?t(w,r,"$1"):M||b}),O},f=function(o,v){var m,O=o;if(u(e,O)&&(m=e[O],O="%"+m[0]+"%"),u(E,O)){var b=E[O];if(b===T&&(b=a(O)),b===void 0&&!v)throw new I("intrinsic "+o+" exists, but is not available. Please file an issue!");return{alias:m,name:O,value:b}}throw new p("intrinsic "+o+" does not exist!")};P.exports=function(o,v){if(typeof o!="string"||o.length===0)throw new I("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof v!="boolean")throw new I('"allowMissing" argument must be a boolean');var m=c(o),O=m.length>0?m[0]:"",b=f("%"+O+"%",v),M=b.name,F=b.value,w=!1,C=b.alias;C&&(O=C[0],i(m,n([0,1],C)));for(var U=1,B=!0;U<m.length;U+=1){var N=m[U],k=l(N,0,1),j=l(N,-1);if((k==='"'||k==="'"||k==="`"||j==='"'||j==="'"||j==="`")&&k!==j)throw new p("property names with quotes must have matching quotes");if(N!=="constructor"&&B||(w=!0),O+="."+N,M="%"+O+"%",u(E,M))F=E[M];else if(F!=null){if(!(N in F)){if(!v)throw new I("base intrinsic for "+o+" exists, but the property is not available.");return}if(L&&U+1>=m.length){var H=L(F,N);B=!!H,F=B&&"get"in H&&!("originalValue"in H.get)?H.get:F[N]}else B=u(F,N),F=F[N];B&&!w&&(E[M]=F)}}return F}},function(P,h,R){"use strict";var p=R(45);P.exports=Function.prototype.bind||p},function(P,h,R){"use strict";var p=String.prototype.replace,S=/%20/g,I={RFC1738:"RFC1738",RFC3986:"RFC3986"};P.exports={default:I.RFC3986,formatters:{RFC1738:function(x){return p.call(x,S,"+")},RFC3986:function(x){return String(x)}},RFC1738:I.RFC1738,RFC3986:I.RFC3986}},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0}),h.findMediaElement=h.getMuxPlayerId=void 0;var p=R(6),S=function(x){return x&&x.nodeName!==void 0?(x.muxId||(x.muxId=x.id||(0,p.generateShortID)()),x.muxId):x},I=function(x){var L=void 0;return x&&x.nodeName!==void 0?(L=x,x=S(L)):L=document.querySelector(x),[L,x,L&&L.nodeName?L.nodeName.toLowerCase():""]};h.getMuxPlayerId=S,h.findMediaElement=I},function(P,h,R){"use strict";function p(){return(I.default.doNotTrack||I.default.navigator&&(I.default.navigator.doNotTrack||I.default.navigator.msDoNotTrack))==="1"}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p;var S=R(0),I=function(x){return x&&x.__esModule?x:{default:x}}(S)},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=R(0),S=function(x){return x&&x.__esModule?x:{default:x}}(p),I={};I.exists=function(){var x=S.default.performance;return(x&&x.timing)!==void 0},I.domContentLoadedEventEnd=function(){var x=S.default.performance,L=x&&x.timing;return L&&L.domContentLoadedEventEnd},I.navigationStart=function(){var x=S.default.performance,L=x&&x.timing;return L&&L.navigationStart},h.default=I},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=function(S){var I={};for(var x in S){var L=S[x];L["DATA-ID"].search("io.litix.data.")!==-1&&(I[L["DATA-ID"].replace("io.litix.data.","")]=L.VALUE)}return I};h.default=p},function(P,h,R){"use strict";var p=R(41),S=R(51),I=R(10);P.exports={formats:I,parse:S,stringify:p}},function(P,h,R){"use strict";var p=R(10),S=Object.prototype.hasOwnProperty,I=Array.isArray,x=function(){for(var u=[],n=0;n<256;++n)u.push("%"+((n<16?"0":"")+n.toString(16)).toUpperCase());return u}(),L=function(u){for(;u.length>1;){var n=u.pop(),i=n.obj[n.prop];if(I(i)){for(var t=[],l=0;l<i.length;++l)i[l]!==void 0&&t.push(i[l]);n.obj[n.prop]=t}}},A=function(u,n){for(var i=n&&n.plainObjects?Object.create(null):{},t=0;t<u.length;++t)u[t]!==void 0&&(i[t]=u[t]);return i},y=function u(n,i,t){if(!i)return n;if(typeof i!="object"){if(I(n))n.push(i);else{if(!n||typeof n!="object")return[n,i];(t&&(t.plainObjects||t.allowPrototypes)||!S.call(Object.prototype,i))&&(n[i]=!0)}return n}if(!n||typeof n!="object")return[n].concat(i);var l=n;return I(n)&&!I(i)&&(l=A(n,t)),I(n)&&I(i)?(i.forEach(function(d,r){if(S.call(n,r)){var c=n[r];c&&typeof c=="object"&&d&&typeof d=="object"?n[r]=u(c,d,t):n.push(d)}else n[r]=d}),n):Object.keys(i).reduce(function(d,r){var c=i[r];return S.call(d,r)?d[r]=u(d[r],c,t):d[r]=c,d},l)},D=function(u,n){return Object.keys(n).reduce(function(i,t){return i[t]=n[t],i},u)},_=function(u,n,i){var t=u.replace(/\+/g," ");if(i==="iso-8859-1")return t.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(t)}catch{return t}},T=function(u,n,i,t,l){if(u.length===0)return u;var d=u;if(typeof u=="symbol"?d=Symbol.prototype.toString.call(u):typeof u!="string"&&(d=String(u)),i==="iso-8859-1")return escape(d).replace(/%u[0-9a-f]{4}/gi,function(o){return"%26%23"+parseInt(o.slice(2),16)+"%3B"});for(var r="",c=0;c<d.length;++c){var f=d.charCodeAt(c);f===45||f===46||f===95||f===126||f>=48&&f<=57||f>=65&&f<=90||f>=97&&f<=122||l===p.RFC1738&&(f===40||f===41)?r+=d.charAt(c):f<128?r+=x[f]:f<2048?r+=x[192|f>>6]+x[128|63&f]:f<55296||f>=57344?r+=x[224|f>>12]+x[128|f>>6&63]+x[128|63&f]:(c+=1,f=65536+((1023&f)<<10|1023&d.charCodeAt(c)),r+=x[240|f>>18]+x[128|f>>12&63]+x[128|f>>6&63]+x[128|63&f])}return r},g=function(u){for(var n=[{obj:{o:u},prop:"o"}],i=[],t=0;t<n.length;++t)for(var l=n[t],d=l.obj[l.prop],r=Object.keys(d),c=0;c<r.length;++c){var f=r[c],o=d[f];typeof o=="object"&&o!==null&&i.indexOf(o)===-1&&(n.push({obj:d,prop:f}),i.push(o))}return L(n),u},E=function(u){return Object.prototype.toString.call(u)==="[object RegExp]"},a=function(u){return!(!u||typeof u!="object")&&!!(u.constructor&&u.constructor.isBuffer&&u.constructor.isBuffer(u))},e=function(u,n){return[].concat(u,n)},s=function(u,n){if(I(u)){for(var i=[],t=0;t<u.length;t+=1)i.push(n(u[t]));return i}return n(u)};P.exports={arrayToObject:A,assign:D,combine:e,compact:g,decode:_,encode:T,isBuffer:a,isRegExp:E,maybeMap:s,merge:y}},function(P,h,R){"use strict";function p(E){return E&&E.__esModule?E:{default:E}}function S(E){var a={};for(var e in E)E.hasOwnProperty(e)&&(a[E[e]]=e);return a}function I(E){var a={},e={};return Object.keys(E).forEach(function(s){var u=!1;if(E.hasOwnProperty(s)&&E[s]!==void 0){var n=s.split("_"),i=n[0],t=_[i];t||(L.default.info("Data key word `"+n[0]+"` not expected in "+s),t=i+"_"),n.splice(1).forEach(function(l){l==="url"&&(u=!0),g[l]?t+=g[l]:Number(l)&&Math.floor(Number(l))===Number(l)?t+=l:(L.default.info("Data key word `"+l+"` not expected in "+s),t+="_"+l+"_")}),u?e[t]=E[s]:a[t]=E[s]}}),(0,y.default)(a,e)}Object.defineProperty(h,"__esModule",{value:!0}),h.default=I;var x=R(4),L=p(x),A=R(1),y=p(A),D={a:"env",b:"beacon",c:"custom",d:"ad",e:"event",f:"experiment",i:"internal",m:"mux",n:"response",p:"player",q:"request",r:"retry",s:"session",t:"timestamp",u:"viewer",v:"video",w:"page",x:"view",y:"sub"},_=S(D),T={ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",ca:"cached",cb:"cancel",cd:"code",cg:"category",ch:"changed",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ep:"experiments",fi:"first",fm:"family",ft:"format",fq:"frequency",fr:"frame",fs:"fullscreen",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"},g=S(T)},function(P,h,R){"use strict";P.exports=R(19).default},function(P,h,R){"use strict";function p(r){return r&&r.__esModule?r:{default:r}}Object.defineProperty(h,"__esModule",{value:!0});var S=function(){function r(c,f){var o=[],v=!0,m=!1,O=void 0;try{for(var b,M=c[Symbol.iterator]();!(v=(b=M.next()).done)&&(o.push(b.value),!f||o.length!==f);v=!0);}catch(F){m=!0,O=F}finally{try{!v&&M.return&&M.return()}finally{if(m)throw O}}return o}return function(c,f){if(Array.isArray(c))return c;if(Symbol.iterator in Object(c))return r(c,f);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),I=R(0),x=p(I),L=R(11),A=R(4),y=p(A),D=R(12),_=p(D),T=R(2),g=p(T),E=R(22),a=p(E),e=R(58),s=p(e),u=R(59),n=p(u),i=R(64),t=p(i),l={},d=function r(c){var f=arguments;typeof c=="string"?r.hasOwnProperty(c)?x.default.setTimeout(function(){f=Array.prototype.splice.call(f,1),r[c].apply(null,f)},0):y.default.warn("`"+c+"` is an unknown task"):typeof c=="function"?x.default.setTimeout(function(){c(r)},0):y.default.warn("`"+c+"` is invalid.")};d.loaded=g.default.now(),d.NAME="mux-embed",d.VERSION="4.8.0",d.API_VERSION="2.1",d.PLAYER_TRACKED=!1,d.monitor=function(r,c){return(0,s.default)(d,r,c)},d.destroyMonitor=function(r){var c=(0,L.findMediaElement)(r),f=S(c,1),o=f[0];o&&o.mux&&typeof o.mux.destroy=="function"?o.mux.destroy():y.default.error("A video element monitor for `"+r+"` has not been initialized via `mux.monitor`.")},d.addHLSJS=function(r,c){var f=(0,L.getMuxPlayerId)(r);l[f]?l[f].addHLSJS(c):y.default.error("A monitor for `"+f+"` has not been initialized.")},d.addDashJS=function(r,c){var f=(0,L.getMuxPlayerId)(r);l[f]?l[f].addDashJS(c):y.default.error("A monitor for `"+f+"` has not been initialized.")},d.removeHLSJS=function(r){var c=(0,L.getMuxPlayerId)(r);l[c]?l[c].removeHLSJS():y.default.error("A monitor for `"+c+"` has not been initialized.")},d.removeDashJS=function(r){var c=(0,L.getMuxPlayerId)(r);l[c]?l[c].removeDashJS():y.default.error("A monitor for `"+c+"` has not been initialized.")},d.init=function(r,c){(0,_.default)()&&c&&c.respectDoNotTrack&&y.default.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var f=(0,L.getMuxPlayerId)(r);l[f]=new a.default(d,f,c)},d.emit=function(r,c,f){var o=(0,L.getMuxPlayerId)(r);l[o]?(l[o].emit(c,f),c==="destroy"&&delete l[o]):y.default.error("A monitor for `"+o+"` has not been initialized.")},x.default!==void 0&&typeof x.default.addEventListener=="function"&&x.default.addEventListener("pagehide",function(r){r.persisted||(d.WINDOW_UNLOADING=!0)},!1),d.checkDoNotTrack=_.default,d.log=y.default,d.utils=n.default,d.events=t.default,h.default=d},function(P,h){var R;R=function(){return this}();try{R=R||Function("return this")()||(0,eval)("this")}catch{typeof window=="object"&&(R=window)}P.exports=R},function(P,h,R){var p,S;(function(I,x){"use strict";p=x,(S=typeof p=="function"?p.call(h,R,h,P):p)!==void 0&&(P.exports=S)})(0,function(){"use strict";function I(n,i){var t=n[i];if(typeof t.bind=="function")return t.bind(n);try{return Function.prototype.bind.call(t,n)}catch{return function(){return Function.prototype.apply.apply(t,[n,arguments])}}}function x(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function L(n){return n==="debug"&&(n="log"),typeof console!==g&&(n==="trace"&&E?x:console[n]!==void 0?I(console,n):console.log!==void 0?I(console,"log"):T)}function A(n,i){for(var t=0;t<a.length;t++){var l=a[t];this[l]=t<n?T:this.methodFactory(l,n,i)}this.log=this.debug}function y(n,i,t){return function(){typeof console!==g&&(A.call(this,i,t),this[n].apply(this,arguments))}}function D(n,i,t){return L(n)||y.apply(this,arguments)}function _(n,i,t){function l(m){var O=(a[m]||"silent").toUpperCase();if(typeof window!==g&&o){try{return void(window.localStorage[o]=O)}catch{}try{window.document.cookie=encodeURIComponent(o)+"="+O+";"}catch{}}}function d(){var m;if(typeof window!==g&&o){try{m=window.localStorage[o]}catch{}if(typeof m===g)try{var O=window.document.cookie,b=O.indexOf(encodeURIComponent(o)+"=");b!==-1&&(m=/^([^;]+)/.exec(O.slice(b))[1])}catch{}return f.levels[m]===void 0&&(m=void 0),m}}function r(){if(typeof window!==g&&o){try{return void window.localStorage.removeItem(o)}catch{}try{window.document.cookie=encodeURIComponent(o)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}var c,f=this;i=i==null?"WARN":i;var o="loglevel";typeof n=="string"?o+=":"+n:typeof n=="symbol"&&(o=void 0),f.name=n,f.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},f.methodFactory=t||D,f.getLevel=function(){return c},f.setLevel=function(m,O){if(typeof m=="string"&&f.levels[m.toUpperCase()]!==void 0&&(m=f.levels[m.toUpperCase()]),!(typeof m=="number"&&m>=0&&m<=f.levels.SILENT))throw"log.setLevel() called with invalid level: "+m;if(c=m,O!==!1&&l(m),A.call(f,m,n),typeof console===g&&m<f.levels.SILENT)return"No console available for logging"},f.setDefaultLevel=function(m){i=m,d()||f.setLevel(m,!1)},f.resetLevel=function(){f.setLevel(i,!1),r()},f.enableAll=function(m){f.setLevel(f.levels.TRACE,m)},f.disableAll=function(m){f.setLevel(f.levels.SILENT,m)};var v=d();v==null&&(v=i),f.setLevel(v,!1)}var T=function(){},g="undefined",E=typeof window!==g&&typeof window.navigator!==g&&/Trident\/|MSIE /.test(window.navigator.userAgent),a=["trace","debug","info","warn","error"],e=new _,s={};e.getLogger=function(n){if(typeof n!="symbol"&&typeof n!="string"||n==="")throw new TypeError("You must supply a name when creating a logger.");var i=s[n];return i||(i=s[n]=new _(n,e.getLevel(),e.methodFactory)),i};var u=typeof window!==g?window.log:void 0;return e.noConflict=function(){return typeof window!==g&&window.log===e&&(window.log=u),e},e.getLoggers=function(){return s},e.default=e,e})},function(P,h,R){"use strict";function p(ee){return ee&&ee.__esModule?ee:{default:ee}}Object.defineProperty(h,"__esModule",{value:!0});var S=function(){function ee($,Z){var ue=[],he=!0,se=!1,me=void 0;try{for(var pe,Ee=$[Symbol.iterator]();!(he=(pe=Ee.next()).done)&&(ue.push(pe.value),!Z||ue.length!==Z);he=!0);}catch(ae){se=!0,me=ae}finally{try{!he&&Ee.return&&Ee.return()}finally{if(se)throw me}}return ue}return function($,Z){if(Array.isArray($))return $;if(Symbol.iterator in Object($))return ee($,Z);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),I=R(4),x=p(I),L=R(1),A=p(L),y=R(6),D=R(5),_=R(0),T=p(_),g=R(13),E=p(g),a=R(3),e=p(a),s=R(23),u=R(24),n=R(25),i=p(n),t=R(26),l=p(t),d=R(27),r=p(d),c=R(28),f=p(c),o=R(29),v=p(o),m=R(30),O=p(m),b=R(31),M=p(b),F=R(32),w=p(F),C=R(33),U=p(C),B=R(34),N=p(B),k=R(35),j=p(k),H=R(36),V=p(H),Y=R(37),Q=p(Y),J=R(38),z=p(J),q=R(39),re=p(q),X=R(57),le=p(X),ne=["viewstart","ended","loadstart","pause","play","playing","ratechange","waiting","adplay","adpause","adended","aderror","adplaying","adrequest","adresponse","adbreakstart","adbreakend","adfirstquartile","admidpoint","adthirdquartile","rebufferstart","rebufferend","seeked","error","hb","requestcompleted","requestfailed","requestcanceled","renditionchange"],te=function(ee,$,Z){var ue=this;this.DOM_CONTENT_LOADED_EVENT_END=E.default.domContentLoadedEventEnd(),this.NAVIGATION_START=E.default.navigationStart();var he={debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(ae){return ae}};this.mux=ee,this.id=$,Z=(0,A.default)(he,Z),Z.data=Z.data||{},Z.data.property_key&&(Z.data.env_key=Z.data.property_key,delete Z.data.property_key),x.default.setLevel(Z.debug?"debug":"warn"),this.getPlayheadTime=Z.getPlayheadTime,this.getStateData=Z.getStateData||function(){},this.getAdData=Z.getAdData||function(){},this.minimumRebufferDuration=Z.minimumRebufferDuration,this.sustainedRebufferThreshold=Z.sustainedRebufferThreshold,this.playbackHeartbeatTime=Z.playbackHeartbeatTime,this.disableRebufferTracking=Z.disableRebufferTracking,this.disableRebufferTracking&&this.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."),this.errorTranslator=Z.errorTranslator,this.playbackEventDispatcher=new re.default(ee,Z.data.env_key,Z),this.data={player_instance_id:(0,y.generateUUID)(),mux_sample_rate:Z.sampleRate,beacon_domain:Z.beaconCollectionDomain?Z.beaconCollectionDomain:Z.beaconDomain},this.data.view_sequence_number=1,this.data.player_sequence_number=1,this.oldEmit=this.emit,this.emit=function(ae,fe){fe=(0,A.default)({viewer_time:this.mux.utils.now()},fe),this.oldEmit(ae,fe)};var se=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(this);this.on("viewinit",function(ae,fe){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),(0,A.default)(this.data,fe),this._initializeViewData(),this.one("play",se),this.one("adbreakstart",se)});var me=function(ae){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",ae)}.bind(this);if(this.on("videochange",function(ae,fe){me(fe)}),this.on("programchange",function(ae,fe){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),me((0,A.default)(fe,{view_program_changed:!0})),se(),this.emit("play"),this.emit("playing")}),this.on("fragmentchange",function(ae,fe){this.currentFragmentPDT=fe.currentFragmentPDT,this.currentFragmentStart=fe.currentFragmentStart}),this.on("destroy",this.destroy),T.default!==void 0&&typeof T.default.addEventListener=="function"&&typeof T.default.removeEventListener=="function"){var pe=function(ae){ae.persisted||ue.destroy()};T.default.addEventListener("pagehide",pe,!1),this.on("destroy",function(){T.default.removeEventListener("pagehide",pe)})}this.on("playerready",function(ae,fe){(0,A.default)(this.data,fe)}),ne.forEach(function(ae){ue.on(ae,function(fe,ge){ae.indexOf("ad")!==0&&this._updateStateData(),(0,A.default)(this.data,ge),this._sanitizeData()}),ue.on("after"+ae,function(){(ae!=="error"||this.viewErrored)&&this.send(ae)})}),this.on("viewend",function(ae,fe){(0,A.default)(ue.data,fe)});var Ee=function(ae){var fe=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=fe-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time};this.one("playerready",Ee),r.default.apply(this),z.default.apply(this),j.default.apply(this),O.default.apply(this),l.default.apply(this),N.default.apply(this),f.default.apply(this),v.default.apply(this),V.default.apply(this),M.default.apply(this),w.default.apply(this),U.default.apply(this),Q.default.apply(this),le.default.apply(this),Z.hlsjs&&this.addHLSJS(Z),Z.dashjs&&this.addDashJS(Z),this.emit("viewinit",Z.data)};(0,A.default)(te.prototype,i.default.prototype),(0,A.default)(te.prototype,O.default.prototype),(0,A.default)(te.prototype,j.default.prototype),(0,A.default)(te.prototype,l.default.prototype),(0,A.default)(te.prototype,f.default.prototype),(0,A.default)(te.prototype,v.default.prototype),(0,A.default)(te.prototype,V.default.prototype),(0,A.default)(te.prototype,w.default.prototype),(0,A.default)(te.prototype,U.default.prototype),te.prototype.destroy=function(){this._destroyed||(this._destroyed=!0,this.data.view_start!==void 0&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),T.default.clearTimeout(this._heartBeatTimeout))},te.prototype.send=function(ee){var $=(0,A.default)({},this.data),Z=["player_program_time","player_manifest_newest_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"];if($.video_source_is_live===void 0&&($.player_source_duration===1/0||$.video_source_duration===1/0?$.video_source_is_live=!0:($.player_source_duration>0||$.video_source_duration>0)&&($.video_source_is_live=!1)),$.video_source_is_live||Z.forEach(function(pe){$[pe]=void 0}),$.video_source_url=$.video_source_url||$.player_source_url,$.video_source_url){var ue=(0,D.extractHostnameAndDomain)($.video_source_url),he=S(ue,2),se=he[0],me=he[1];$.video_source_domain=me,$.video_source_hostname=se}delete $.ad_request_id,this.playbackEventDispatcher.send(ee,$),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()},te.prototype._updateStateData=function(){(0,A.default)(this.data,this.getStateData()),this._updatePlayheadTime(),this._sanitizeData()},te.prototype._sanitizeData=function(){var ee=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function($){var Z=parseInt(ee.data[$],10);ee.data[$]=isNaN(Z)?void 0:Z}),["player_source_url","video_source_url"].forEach(function($){if(ee.data[$]){var Z=ee.data[$].toLowerCase();Z.indexOf("data:")!==0&&Z.indexOf("blob:")!==0||(ee.data[$]="MSE style URL")}})},te.prototype._resetVideoData=function(ee,$){var Z=this;Object.keys(this.data).forEach(function(ue){ue.indexOf("video_")===0&&delete Z.data[ue]})},te.prototype._resetViewData=function(){var ee=this;Object.keys(this.data).forEach(function($){$.indexOf("view_")===0&&delete ee.data[$]}),this.data.view_sequence_number=1},te.prototype._resetErrorData=function(ee,$){delete this.data.player_error_code,delete this.data.player_error_message},te.prototype._initializeViewData=function(){var ee=this,$=this.data.view_id=(0,y.generateUUID)(),Z=function(){$===ee.data.view_id&&(0,e.default)(ee.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",Z):Z()},te.prototype._restartHeartBeat=function(){var ee=this;T.default.clearTimeout(this._heartBeatTimeout),this.viewErrored||(this._heartBeatTimeout=T.default.setTimeout(function(){ee.data.player_is_paused||ee.emit("hb")},1e4))},te.prototype.addHLSJS=function(ee){return ee.hlsjs?this.hlsjs?void this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=ee.hlsjs,void(0,s.monitorHlsJs)(this.mux,this.id,ee.hlsjs,{},ee.Hls||T.default.Hls)):void this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")},te.prototype.removeHLSJS=function(){this.hlsjs&&((0,s.stopMonitoringHlsJs)(this.hlsjs),this.hlsjs=void 0)},te.prototype.addDashJS=function(ee){return ee.dashjs?this.dashjs?void this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=ee.dashjs,void(0,u.monitorDashJS)(this.mux,this.id,ee.dashjs)):void this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")},te.prototype.removeDashJS=function(){this.dashjs&&((0,u.stopMonitoringDashJS)(this.dashjs),this.dashjs=void 0)},h.default=te},function(P,h,R){"use strict";function p(a){return a&&a.__esModule?a:{default:a}}Object.defineProperty(h,"__esModule",{value:!0}),h.stopMonitoringHlsJs=h.monitorHlsJs=void 0;var S=R(7),I=p(S),x=R(13),L=p(x),A=R(5),y=R(14),D=p(y),_=function(a){if(!a)return{};var e=L.default.navigationStart(),s=a.loading,u=s?s.start:a.trequest,n=s?s.first:a.tfirst,i=s?s.end:a.tload;return{bytesLoaded:a.total,requestStart:Math.round(e+u),responseStart:Math.round(e+n),responseEnd:Math.round(e+i)}},T=function(a){if(a&&typeof a.getAllResponseHeaders=="function")return(0,I.default)(a.getAllResponseHeaders())},g=function(a,e,s){var u=(arguments.length>3&&arguments[3]!==void 0&&arguments[3],arguments[4]),n=a.log,i=a.utils.secondsToMs,t=function(b){var M=parseInt(u.version),F=void 0;return M===1&&b.programDateTime!==null&&(F=b.programDateTime),M===0&&b.pdt!==null&&(F=b.pdt),F};if(!L.default.exists())return void n.warn("performance timing not supported. Not tracking HLS.js.");var l=function(b,M){return a.emit(e,b,M)},d=function(b,M){var F=M.levels,w=M.audioTracks,C=M.url,U=M.stats,B=M.networkDetails,N=M.sessionData,k={},j={},H={};H=(0,D.default)(N),F.forEach(function(q,re){k[re]={width:q.width,height:q.height,bitrate:q.bitrate,attrs:q.attrs}}),w.forEach(function(q,re){j[re]={name:q.name,language:q.lang,bitrate:q.bitrate}});var V=_(U),Y=V.bytesLoaded,Q=V.requestStart,J=V.responseStart,z=V.responseEnd;H.request_event_type=b,H.request_bytes_loaded=Y,H.request_start=Q,H.request_response_start=J,H.request_response_end=z,H.request_type="manifest",H.request_hostname=(0,A.extractHostname)(C),H.request_response_headers=T(B),H.request_rendition_lists={media:k,audio:j,video:{}},l("requestcompleted",H)};s.on(u.Events.MANIFEST_LOADED,d);var r=function(b,M){var F=M.details,w=M.level,C=M.networkDetails,U=M.stats,B=_(U),N=B.bytesLoaded,k=B.requestStart,j=B.responseStart,H=B.responseEnd,V=F.fragments[F.fragments.length-1],Y=t(V)+i(V.duration);l("requestcompleted",{request_event_type:b,request_bytes_loaded:N,request_start:k,request_response_start:j,request_response_end:H,request_current_level:w,request_type:"manifest",request_hostname:(0,A.extractHostname)(F.url),request_response_headers:T(C),video_holdback:F.holdBack&&i(F.holdBack),video_part_holdback:F.partHoldBack&&i(F.partHoldBack),video_part_target_duration:F.partTarget&&i(F.partTarget),video_target_duration:F.targetduration&&i(F.targetduration),video_source_is_live:F.live,player_manifest_newest_program_time:isNaN(Y)?void 0:Y})};s.on(u.Events.LEVEL_LOADED,r);var c=function(b,M){var F=M.details,w=M.networkDetails,C=M.stats,U=_(C),B=U.bytesLoaded,N=U.requestStart,k=U.responseStart,j=U.responseEnd;l("requestcompleted",{request_event_type:b,request_bytes_loaded:B,request_start:N,request_response_start:k,request_response_end:j,request_type:"manifest",request_hostname:(0,A.extractHostname)(F.url),request_response_headers:T(w)})};s.on(u.Events.AUDIO_TRACK_LOADED,c);var f=function(b,M){var F=M.stats,w=M.networkDetails,C=M.frag,U=_(F),B=U.bytesLoaded,N=U.requestStart,k=U.responseStart,j=U.responseEnd,H={request_event_type:b,request_bytes_loaded:B,request_start:N,request_response_start:k,request_response_end:j,request_hostname:w?(0,A.extractHostname)(w.responseURL):void 0,request_response_headers:T(w),request_media_duration:C.duration};C.type==="main"?(H.request_type="media",H.request_current_level=C.level,H.request_video_width=(s.levels[C.level]||{}).width,H.request_video_height=(s.levels[C.level]||{}).height):H.request_type=C.type,l("requestcompleted",H)};s.on(u.Events.FRAG_LOADED,f);var o=function(b,M){var F=M.frag,w=F.start,C=t(F),U={currentFragmentPDT:C,currentFragmentStart:i(w)};l("fragmentchange",U)};s.on(u.Events.FRAG_CHANGED,o);var v=function(b,M){var F=M.type,w=M.details,C=M.response,U=M.fatal,B=M.context,N=M.frag;if(w===u.ErrorDetails.MANIFEST_LOAD_ERROR||w===u.ErrorDetails.MANIFEST_LOAD_TIMEOUT||w===u.ErrorDetails.FRAG_LOAD_ERROR||w===u.ErrorDetails.FRAG_LOAD_TIMEOUT||w===u.ErrorDetails.LEVEL_LOAD_ERROR||w===u.ErrorDetails.LEVEL_LOAD_TIMEOUT){var k=N&&N.url||B&&B.url||"";l("requestfailed",{request_error:w,request_url:k,request_hostname:(0,A.extractHostname)(k),request_type:w===u.ErrorDetails.FRAG_LOAD_ERROR||w===u.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:C&&C.code,request_error_text:C&&C.text})}U&&l("error",{player_error_code:F,player_error_message:w})};s.on(u.Events.ERROR,v);var m=function(b,M){var F=M.frag,w=F&&F._url||"";l("requestcanceled",{request_cancel:b,request_url:w,request_type:"media",request_hostname:(0,A.extractHostname)(w)})};s.on(u.Events.FRAG_LOAD_EMERGENCY_ABORTED,m);var O=function(b,M){var F=M.level,w=s.levels[F];if(w&&w.attrs&&w.attrs.BANDWIDTH){var C=w.attrs.BANDWIDTH;C?l("renditionchange",{video_source_bitrate:C,video_source_width:w.width,video_source_height:w.height}):n.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};s.on(u.Events.LEVEL_SWITCHED,O),s._stopMuxMonitor=function(){s.off(u.Events.MANIFEST_LOADED,d),s.off(u.Events.LEVEL_LOADED,r),s.off(u.Events.AUDIO_TRACK_LOADED,c),s.off(u.Events.FRAG_LOADED,f),s.off(u.Events.FRAG_CHANGED,o),s.off(u.Events.ERROR,v),s.off(u.Events.FRAG_LOAD_EMERGENCY_ABORTED,m),s.off(u.Events.LEVEL_SWITCHED,O),s.off(u.Events.DESTROYING,s._stopMuxMonitor),delete s._stopMuxMonitor},s.on(u.Events.DESTROYING,s._stopMuxMonitor)},E=function(a){a&&typeof a._stopMuxMonitor=="function"&&a._stopMuxMonitor()};h.monitorHlsJs=g,h.stopMonitoringHlsJs=E},function(P,h,R){"use strict";function p(g){return g&&g.__esModule?g:{default:g}}Object.defineProperty(h,"__esModule",{value:!0}),h.stopMonitoringDashJS=h.monitorDashJS=void 0;var S=R(0),I=p(S),x=R(7),L=p(x),A=R(5),y=function(g,E){if(!g||typeof g.getRequests!="function")return{};var a=g.getRequests({state:"executed"});if(a.length===0)return{};var e=a[a.length-1],s=(0,A.extractHostname)(e.url),u=e.bytesLoaded,n=new Date(e.requestStartDate).getTime(),i=new Date(e.firstByteDate).getTime(),t=new Date(e.requestEndDate).getTime(),l=isNaN(e.duration)?0:e.duration,d=typeof E.getMetricsFor=="function"?E.getMetricsFor(e.mediaType).HttpList:E.getDashMetrics().getHttpRequests(e.mediaType),r=void 0;return d.length>0&&(r=(0,L.default)(d[d.length-1]._responseHeaders||"")),{requestStart:n,requestResponseStart:i,requestResponseEnd:t,requestBytesLoaded:u,requestResponseHeaders:r,requestMediaDuration:l,requestHostname:s}},D=function(g,E){var a=E.getQualityFor(g),e=E.getCurrentTrackFor(g),s=e.bitrateList;return s?{currentLevel:a,renditionWidth:s[a].width||null,renditionHeight:s[a].height||null,renditionBitrate:s[a].bandwidth}:{}},_=function(g,E,a){var e=(arguments.length>3&&arguments[3]!==void 0&&arguments[3],g.log);if(!a||!a.on)return void e.warn("Invalid dash.js player reference. Monitoring blocked.");var s=function(f,o){return g.emit(E,f,o)},u=function(f){var o=f.type,v=f.data,m=v||{},O=m.url;s("requestcompleted",{request_event_type:o,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:(0,A.extractHostname)(O)})};a.on("manifestLoaded",u);var n={},i=function(f){var o=f.type,v=f.fragmentModel,m=f.chunk,O=m||{},b=O.mediaInfo,M=b||{},F=M.type,w=M.bitrateList;w=w||[];var C={};w.forEach(function(Y,Q){C[Q]={},C[Q].width=Y.width,C[Q].height=Y.height,C[Q].bitrate=Y.bandwidth,C[Q].attrs={}}),F==="video"?n.video=C:F==="audio"?n.audio=C:n.media=C;var U=y(v,a),B=U.requestStart,N=U.requestResponseStart,k=U.requestResponseEnd,j=U.requestResponseHeaders,H=U.requestMediaDuration,V=U.requestHostname;s("requestcompleted",{request_event_type:o,request_start:B,request_response_start:N,request_response_end:k,request_bytes_loaded:-1,request_type:F+"_init",request_response_headers:j,request_hostname:V,request_media_duration:H,request_rendition_lists:n})};a.on("initFragmentLoaded",i);var t=function(f){var o=f.type,v=f.fragmentModel,m=f.chunk,O=m||{},b=O.mediaInfo,M=O.start,F=b||{},w=F.type,C=y(v,a),U=C.requestStart,B=C.requestResponseStart,N=C.requestResponseEnd,k=C.requestBytesLoaded,j=C.requestResponseHeaders,H=C.requestMediaDuration,V=C.requestHostname,Y=D(w,a),Q=Y.currentLevel,J=Y.renditionWidth,z=Y.renditionHeight,q=Y.renditionBitrate;s("requestcompleted",{request_event_type:o,request_start:U,request_response_start:B,request_response_end:N,request_bytes_loaded:k,request_type:w,request_response_headers:j,request_hostname:V,request_media_start_time:M,request_media_duration:H,request_current_level:Q,request_labeled_bitrate:q,request_video_width:J,request_video_height:z})};a.on("mediaFragmentLoaded",t);var l={video:void 0,audio:void 0,totalBitrate:void 0},d=function(){if(l.video&&typeof l.video.bitrate=="number"){if(!l.video.width||!l.video.height)return void e.warn("have bitrate info for video but missing width/height");var f=l.video.bitrate;return l.audio&&typeof l.audio.bitrate=="number"&&(f+=l.audio.bitrate),f!==l.totalBitrate?(l.totalBitrate=f,{video_source_bitrate:f,video_source_height:l.video.height,video_source_width:l.video.width}):void 0}},r=function(f,o,v){if(typeof f.newQuality!="number")return void e.warn("missing evt.newQuality in qualityChangeRendered event",f);var m=f.mediaType;if(m==="audio"||m==="video"){var O=a.getBitrateInfoListFor(m).find(function(M){return M.qualityIndex===f.newQuality});if(!O||typeof O.bitrate!="number")return void e.warn("missing bitrate info for "+m);l[m]=O;var b=d();b&&s("renditionchange",b)}};a.on("qualityChangeRendered",r);var c=function(f){var o=f.error,v=f.event;v=v||{};var m=v.request||{},O=I.default.event&&I.default.event.currentTarget||{};s("requestfailed",{request_error:o+"_"+v.id+"_"+m.type,request_url:v.url,request_hostname:(0,A.extractHostname)(v.url),request_type:m.mediaType,request_error_code:O.status,request_error_type:O.statusText})};a.on("error",c),a._stopMuxMonitor=function(){a.off("manifestLoaded",u),a.off("initFragmentLoaded",i),a.off("mediaFragmentLoaded",t),a.off("qualityChangeRendered",r),a.off("error",c),delete a._stopMuxMonitor}},T=function(g){g&&typeof g._stopMuxMonitor=="function"&&g._stopMuxMonitor()};h.monitorDashJS=_,h.stopMonitoringDashJS=T},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=function(){},S=0;p.prototype.on=function(I,x,L){return x._eventEmitterGuid=x._eventEmitterGuid||++S,this._listeners=this._listeners||{},this._listeners[I]=this._listeners[I]||[],L&&(x=x.bind(L)),this._listeners[I].push(x),x},p.prototype.off=function(I,x){var L=this._listeners&&this._listeners[I];L&&L.forEach(function(A,y){A._eventEmitterGuid===x._eventEmitterGuid&&L.splice(y,1)})},p.prototype.one=function(I,x,L){var A=this;x._eventEmitterGuid=x._eventEmitterGuid||++S;var y=function D(){A.off(I,D),x.apply(L||this,arguments)};y._eventEmitterGuid=x._eventEmitterGuid,this.on(I,y)},p.prototype.emit=function(I,x){var L=this;if(this._listeners){x=x||{};var A=this._listeners["before*"]||[],y=this._listeners[I]||[],D=this._listeners["after"+I]||[],_=function(T,g){T=T.slice(),T.forEach(function(E){E.call(L,{type:I},g)})};_(A,x),_(y,x),_(D,x)}},h.default=p},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=R(0),S=function(x){return x&&x.__esModule?x:{default:x}}(p),I=function(){this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,this.on("playing",function(){this._playheadShouldBeProgressing=!0}),this.on("play",this._startPlaybackHeartbeatInterval),this.on("playing",this._startPlaybackHeartbeatInterval),this.on("adbreakstart",this._startPlaybackHeartbeatInterval),this.on("adplay",this._startPlaybackHeartbeatInterval),this.on("adplaying",this._startPlaybackHeartbeatInterval),this.on("seeking",this._startPlaybackHeartbeatInterval),this.on("devicewake",this._startPlaybackHeartbeatInterval),this.on("viewstart",this._startPlaybackHeartbeatInterval),this.on("rebufferstart",this._startPlaybackHeartbeatInterval),this.on("pause",this._stopPlaybackHeartbeatInterval),this.on("ended",this._stopPlaybackHeartbeatInterval),this.on("viewend",this._stopPlaybackHeartbeatInterval),this.on("error",this._stopPlaybackHeartbeatInterval),this.on("aderror",this._stopPlaybackHeartbeatInterval),this.on("adpause",this._stopPlaybackHeartbeatInterval),this.on("adended",this._stopPlaybackHeartbeatInterval),this.on("adbreakend",this._stopPlaybackHeartbeatInterval),this.on("seeked",function(){this.data.player_is_paused?this._stopPlaybackHeartbeatInterval():this._startPlaybackHeartbeatInterval()}),this.on("timeupdate",function(){this._playbackHeartbeatInterval!==null&&this.emit("playbackheartbeat")}),this.on("devicesleep",function(x,L){this._playbackHeartbeatInterval!==null&&(S.default.clearInterval(this._playbackHeartbeatInterval),this.emit("playbackheartbeatend",{viewer_time:L.viewer_time}),this._playbackHeartbeatInterval=null)})};I.prototype._startPlaybackHeartbeatInterval=function(){var x=this;this._playbackHeartbeatInterval===null&&(this.emit("playbackheartbeat"),this._playbackHeartbeatInterval=S.default.setInterval(function(){x.emit("playbackheartbeat")},this.playbackHeartbeatTime))},I.prototype._stopPlaybackHeartbeatInterval=function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(S.default.clearInterval(this._playbackHeartbeatInterval),this.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)},h.default=I},function(P,h,R){"use strict";function p(){var S=this;this.on("viewinit",function(){S.viewErrored=!1}),this.on("error",function(){try{var I=S.errorTranslator({player_error_code:S.data.player_error_code,player_error_message:S.data.player_error_message});I?(S.data.player_error_code=I.player_error_code,S.data.player_error_message=I.player_error_message,S.viewErrored=!0):(delete S.data.player_error_code,delete S.data.player_error_message)}catch(x){S.mux.log.warn("Exception in error translator callback.",x),S.viewErrored=!0}})}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=R(3),S=function(x){return x&&x.__esModule?x:{default:x}}(p),I=function(){this._watchTimeTrackerLastCheckedTime=null,this.on("playbackheartbeat",this._updateWatchTime),this.on("playbackheartbeatend",this._clearWatchTimeState)};I.prototype._updateWatchTime=function(x,L){var A=L.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=A),(0,S.default)(this.data,"view_watch_time",A-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=A},I.prototype._clearWatchTimeState=function(x,L){this._updateWatchTime(x,L),this._watchTimeTrackerLastCheckedTime=null},h.default=I},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=R(3),S=function(x){return x&&x.__esModule?x:{default:x}}(p),I=function(){this._playbackTimeTrackerLastPlayheadPosition=-1,this.on("playbackheartbeat",this._updatePlaybackTime),this.on("playbackheartbeatend",this._clearPlaybackTimeState),this.on("seeking",this._clearPlaybackTimeState)};I.prototype._updatePlaybackTime=function(){var x=this.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&x>this._playbackTimeTrackerLastPlayheadPosition){var L=x-this._playbackTimeTrackerLastPlayheadPosition;L<=1e3&&(0,S.default)(this.data,"view_content_playback_time",L)}this._playbackTimeTrackerLastPlayheadPosition=x},I.prototype._clearPlaybackTimeState=function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1},h.default=I},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=function(){this.on("playbackheartbeat",this._updatePlayheadTime),this.on("playbackheartbeatend",this._updatePlayheadTime),this.on("timeupdate",this._updatePlayheadTime),this.on("destroy",function(){this.off("timeupdate",this._updatePlayheadTime)})};p.prototype._updateMaxPlayheadPosition=function(){this.data.view_max_playhead_position=this.data.view_max_playhead_position===void 0?this.data.player_playhead_time:Math.max(this.data.view_max_playhead_position,this.data.player_playhead_time)},p.prototype._updatePlayheadTime=function(S,I){var x=this,L=function(){x.currentFragmentPDT&&x.currentFragmentStart&&(x.data.player_program_time=x.currentFragmentPDT+x.data.player_playhead_time-x.currentFragmentStart)};if(I&&I.player_playhead_time)this.data.player_playhead_time=I.player_playhead_time,L(),this._updateMaxPlayheadPosition();else if(this.getPlayheadTime){var A=this.getPlayheadTime();A!==void 0&&(this.data.player_playhead_time=A,L(),this._updateMaxPlayheadPosition())}},h.default=p},function(P,h,R){"use strict";function p(){var x=this;if(!this.disableRebufferTracking){var L=void 0,A=function(){if(L){var y=x.data.viewer_time-L;(0,I.default)(x.data,"view_rebuffer_duration",y),L=x.data.viewer_time}x.data.view_watch_time>=0&&x.data.view_rebuffer_count>0&&(x.data.view_rebuffer_frequency=x.data.view_rebuffer_count/x.data.view_watch_time,x.data.view_rebuffer_percentage=x.data.view_rebuffer_duration/x.data.view_watch_time)};this.on("playbackheartbeat",function(){return A()}),this.on("rebufferstart",function(){L||((0,I.default)(x.data,"view_rebuffer_count",1),L=x.data.viewer_time,x.one("rebufferend",function(){A(),L=void 0}))})}}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p;var S=R(3),I=function(x){return x&&x.__esModule?x:{default:x}}(S)},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=R(2),S=function(x){return x&&x.__esModule?x:{default:x}}(p),I=function(){this.disableRebufferTracking||this.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,this.on("playbackheartbeat",this._checkIfRebuffering),this.on("playbackheartbeatend",this._cleanupRebufferTracker),this.on("seeking",function(){this._cleanupRebufferTracker(null,{viewer_time:S.default.now()})}))};I.prototype._checkIfRebuffering=function(x,L){return this.isSeeking||this.isAdBreak||!this._playheadShouldBeProgressing?void this._cleanupRebufferTracker(x,L):this._lastCheckedTime===null?void this._prepareRebufferTrackerState(L.viewer_time):this._lastPlayheadTime!==this.data.player_playhead_time?void this._cleanupRebufferTracker(x,L,!0):(L.viewer_time-this._lastPlayheadTimeUpdatedTime>=this.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),void(this._lastCheckedTime=L.viewer_time))},I.prototype._clearRebufferTrackerState=function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null},I.prototype._prepareRebufferTrackerState=function(x){this._lastCheckedTime=x,this._lastPlayheadTime=this.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=x},I.prototype._cleanupRebufferTracker=function(x,L){var A=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.emit("rebufferend",{viewer_time:L.viewer_time});else{if(this._lastCheckedTime===null)return;var y=this.data.player_playhead_time-this._lastPlayheadTime,D=L.viewer_time-this._lastPlayheadTimeUpdatedTime;y>0&&D-y>this.minimumRebufferDuration&&(this.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+D-y}))}A?this._prepareRebufferTrackerState(L.viewer_time):this._clearRebufferTrackerState()},h.default=I},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=R(2),S=function(x){return x&&x.__esModule?x:{default:x}}(p),I=function(){this.on("viewinit",function(){var x=this.data,L=x.view_id;if(!x.view_program_changed){var A=function(y,D){var _=D.viewer_time;y.type==="playing"&&this.data.view_time_to_first_frame===void 0?this.calculateTimeToFirstFrame(_||S.default.now(),L):y.type!=="adplaying"||this.data.view_time_to_first_frame!==void 0&&!this.inPrerollPosition()||this.calculateTimeToFirstFrame(_||S.default.now(),L)};this.one("playing",A),this.one("adplaying",A),this.one("viewend",function(){this.off("playing",A),this.off("adplaying",A)})}})};I.prototype.calculateTimeToFirstFrame=function(x,L){L===this.data.view_id&&(this._updateWatchTime(null,{viewer_time:x}),this.data.view_time_to_first_frame=this.data.view_watch_time,(this.data.player_autoplay_on||this.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.data.view_aggregate_startup_time=this.data.view_start+this.data.view_watch_time-this.NAVIGATION_START))},h.default=I},function(P,h,R){"use strict";function p(){var x=this;this.on("viewinit",function(){this._lastPlayheadPosition=-1});var L=["pause","rebufferstart","seeking","error","adbreakstart","hb"],A=["playing","hb"];L.forEach(function(y){x.on(y,function(){if(this._lastPlayheadPosition>=0&&this.data.player_playhead_time>=0&&this._lastPlayerWidth>=0&&this._lastSourceWidth>0&&this._lastPlayerHeight>=0&&this._lastSourceHeight>0){var D=this.data.player_playhead_time-this._lastPlayheadPosition;if(D<0)return void(this._lastPlayheadPosition=-1);var _=Math.min(this._lastPlayerWidth/this._lastSourceWidth,this._lastPlayerHeight/this._lastSourceHeight),T=Math.max(0,_-1),g=Math.max(0,1-_);this.data.view_max_upscale_percentage=Math.max(this.data.view_max_upscale_percentage||0,T),this.data.view_max_downscale_percentage=Math.max(this.data.view_max_downscale_percentage||0,g),(0,I.default)(this.data,"view_total_content_playback_time",D),(0,I.default)(this.data,"view_total_upscaling",T*D),(0,I.default)(this.data,"view_total_downscaling",g*D)}this._lastPlayheadPosition=-1})}),A.forEach(function(y){x.on(y,function(){this._lastPlayheadPosition=this.data.player_playhead_time,this._lastPlayerWidth=this.data.player_width,this._lastPlayerHeight=this.data.player_height,this._lastSourceWidth=this.data.video_source_width,this._lastSourceHeight=this.data.video_source_height})})}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p;var S=R(3),I=function(x){return x&&x.__esModule?x:{default:x}}(S)},function(P,h,R){"use strict";function p(_){return _&&_.__esModule?_:{default:_}}function S(){this.isSeeking=!1,this.on("seeking",function(_,T){(0,D.default)(this.data,T),this._lastSeekingTime=x.default.now(),this.isSeeking===!1&&(this.isSeeking=!0,this.send("seeking"))}),this.on("seeked",function(){this.isSeeking=!1;var _=this._lastSeekingTime||x.default.now(),T=x.default.now()-_;(0,A.default)(this.data,"view_seek_count",1),(0,A.default)(this.data,"view_seek_duration",T);var g=this.data.view_max_seek_time||0;this.data.view_max_seek_time=Math.max(g,T)}),this.on("viewend",function(){this.isSeeking=!1})}Object.defineProperty(h,"__esModule",{value:!0}),h.default=S;var I=R(2),x=p(I),L=R(3),A=p(L),y=R(1),D=p(y)},function(P,h,R){"use strict";function p(g){return g&&g.__esModule?g:{default:g}}Object.defineProperty(h,"__esModule",{value:!0});var S=function(){function g(E,a){var e=[],s=!0,u=!1,n=void 0;try{for(var i,t=E[Symbol.iterator]();!(s=(i=t.next()).done)&&(e.push(i.value),!a||e.length!==a);s=!0);}catch(l){u=!0,n=l}finally{try{!s&&t.return&&t.return()}finally{if(u)throw n}}return e}return function(E,a){if(Array.isArray(E))return E;if(Symbol.iterator in Object(E))return g(E,a);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),I=R(3),x=p(I),L=R(5),A=R(1),y=p(A),D=function(g,E){g.push(E),g.sort(function(a,e){return a.viewer_time-e.viewer_time})},_=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],T=function(){var g=this;this.on("viewinit",function(){this.isAdBreak=!1,this._currentAdRequestNumber=0,this._currentAdResponseNumber=0,this._adRequests=[],this._adResponses=[],this._adHasPlayed=!1,this._wouldBeNewAdPlay=!0,this._prerollPlayTime=void 0}),_.forEach(function(a){return g.on(a,g._updateAdData)});var E=function(){g.isAdBreak=!1};this.on("adbreakstart",function(){this.isAdBreak=!0}),this.on("play",E),this.on("playing",E),this.on("viewend",E),this.on("adrequest",function(a,e){e=(0,y.default)({ad_request_id:"generatedAdRequestId"+this._currentAdRequestNumber++},e),D(this._adRequests,e),(0,x.default)(this.data,"view_ad_request_count"),this.inPrerollPosition()&&(this.data.view_preroll_requested=!0,this._adHasPlayed||(0,x.default)(this.data,"view_preroll_request_count"))}),this.on("adresponse",function(a,e){e=(0,y.default)({ad_request_id:"generatedAdRequestId"+this._currentAdResponseNumber++},e),D(this._adResponses,e);var s=this.findAdRequest(e.ad_request_id);s&&(0,x.default)(this.data,"view_ad_request_time",Math.max(0,e.viewer_time-s.viewer_time))}),this.on("adplay",function(a,e){this._adHasPlayed=!0,this._wouldBeNewAdPlay&&(this._wouldBeNewAdPlay=!1,(0,x.default)(this.data,"view_ad_played_count")),this.inPrerollPosition()&&!this.data.view_preroll_played&&(this.data.view_preroll_played=!0,this._adRequests.length>0&&(this.data.view_preroll_request_time=Math.max(0,e.viewer_time-this._adRequests[0].viewer_time)),this.data.view_start&&(this.data.view_startup_preroll_request_time=Math.max(0,e.viewer_time-this.data.view_start)),this._prerollPlayTime=e.viewer_time)}),this.on("adplaying",function(a,e){this.inPrerollPosition()&&this.data.view_preroll_load_time===void 0&&this._prerollPlayTime!==void 0&&(this.data.view_preroll_load_time=e.viewer_time-this._prerollPlayTime,this.data.view_startup_preroll_load_time=e.viewer_time-this._prerollPlayTime)}),this.on("adended",function(){this._wouldBeNewAdPlay=!0}),this.on("aderror",function(){this._wouldBeNewAdPlay=!0})};T.prototype.inPrerollPosition=function(){return this.data.view_content_playback_time===void 0||this.data.view_content_playback_time<=1e3},T.prototype.findAdRequest=function(g){for(var E=0;E<this._adRequests.length;E++)if(this._adRequests[E].ad_request_id===g)return this._adRequests[E]},T.prototype._updateAdData=function(g,E){if(this.inPrerollPosition()){if(!this.data.view_preroll_ad_tag_hostname&&E.ad_tag_url){var a=(0,L.extractHostnameAndDomain)(E.ad_tag_url),e=S(a,2),s=e[0],u=e[1];this.data.view_preroll_ad_tag_domain=u,this.data.view_preroll_ad_tag_hostname=s}if(!this.data.view_preroll_ad_asset_hostname&&E.ad_asset_url){var n=(0,L.extractHostnameAndDomain)(E.ad_asset_url),i=S(n,2),t=i[0],l=i[1];this.data.view_preroll_ad_asset_domain=l,this.data.view_preroll_ad_asset_hostname=t}}},h.default=T},function(P,h,R){"use strict";function p(y){return y&&y.__esModule?y:{default:y}}function S(){var y=this,D=void 0,_=void 0,T=function(){y.disableRebufferTracking||((0,A.default)(y.data,"view_waiting_rebuffer_count",1),D=x.default.now(),_=window.setInterval(function(){if(D){var s=x.default.now();(0,A.default)(y.data,"view_waiting_rebuffer_duration",s-D),D=s}},250))},g=function(){y.disableRebufferTracking||D&&((0,A.default)(y.data,"view_waiting_rebuffer_duration",x.default.now()-D),D=!1,window.clearInterval(_))},E=!1,a=function(){E=!0},e=function(){E=!1,g()};this.on("waiting",function(){E&&T()}),this.on("playing",function(){g(),a()}),this.on("pause",e),this.on("seeking",e)}Object.defineProperty(h,"__esModule",{value:!0}),h.default=S;var I=R(2),x=p(I),L=R(3),A=p(L)},function(P,h,R){"use strict";function p(_){return _&&_.__esModule?_:{default:_}}function S(){var _=this;this.one("playbackheartbeat",y),this.on("playbackheartbeatend",function(){_.off("before*",D),_.one("playbackheartbeat",y)})}Object.defineProperty(h,"__esModule",{value:!0}),h.default=S;var I=R(1),x=p(I),L=R(2),A=p(L),y=function(){this.lastWallClockTime=A.default.now(),this.on("before*",D)},D=function(_){var T=A.default.now(),g=this.lastWallClockTime;this.lastWallClockTime=T,T-g>3e4&&(this.emit("devicesleep",{viewer_time:g}),(0,x.default)(this.data,{viewer_time:g}),this.send("devicesleep"),this.emit("devicewake",{viewer_time:T}),(0,x.default)(this.data,{viewer_time:T}),this.send("devicewake"))}},function(P,h,R){"use strict";function p(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(h,"__esModule",{value:!0});var S=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o){return typeof o}:function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},I=R(0),x=p(I),L=R(40),A=R(4),y=p(A),D=R(53),_=p(D),T=R(12),g=p(T),E=R(54),a=p(E),e=R(17),s=p(e),u=R(55),n=p(u),i=R(1),t=p(i),l=["env_key","view_id","view_sequence_number","player_sequence_number","beacon_domain","player_playhead_time","viewer_time","mux_api_version","event","video_id","player_instance_id"],d=["viewstart","error","ended","viewend"],r=function(o,v){var m=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.mux=o,this.envKey=v,this.eventQueue=new n.default((0,_.default)(v,m)),this.previousBeaconData=null,this.lastEventTime=null,this.sampleRate=m.sampleRate,this.disableCookies=m.disableCookies,this.respectDoNotTrack=m.respectDoNotTrack;var O=m.platform||{};this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:O.name,viewer_application_version:O.version,viewer_application_engine:O.layout,viewer_device_name:O.product,viewer_device_category:"",viewer_device_manufacturer:O.manufacturer,viewer_os_family:O.os&&O.os.family,viewer_os_architecture:O.os&&O.os.architecture,viewer_os_version:O.os&&O.os.version};var b=(0,a.default)();b&&(this.pageLevelData=(0,t.default)(this.pageLevelData,{viewer_connection_type:b})),x.default!==void 0&&x.default.location&&x.default.location.href&&(this.pageLevelData.page_url=x.default.location.href),this.viewerData=this.disableCookies?{}:(0,L.getAndUpdateViewerData)()};r.prototype.send=function(o,v){if(o){if(this.respectDoNotTrack&&(0,g.default)())return y.default.info("Not sending `"+o+"` because Do Not Track is enabled");if(!v||(v===void 0?"undefined":S(v))!=="object")return y.default.error("A data object was expected in send() but was not provided");var m=this.disableCookies?{}:(0,L.getAndUpdateSessionData)(),O={};(0,t.default)(O,this.pageLevelData),(0,t.default)(O,v),(0,t.default)(O,m),(0,t.default)(O,this.viewerData),O.event=o,O.env_key=this.envKey,O.user_id&&(O.viewer_user_id=O.user_id,delete O.user_id);var b=O.mux_sample_number>=this.sampleRate,M=this._deduplicateBeaconData(o,O),F=(0,s.default)(M);if(this.lastEventTime=this.mux.utils.now(),b)return y.default.info("Not sending event due to sample rate restriction",o,O,F);if(this.envKey||y.default.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",o,O,F),!this.rateLimited){if(y.default.info("Sending event",o,O,F),this.rateLimited=!this.eventQueue.queueEvent(o,F),this.mux.WINDOW_UNLOADING&&o==="viewend")this.eventQueue.destroy(!0);else if((d.indexOf(o)>=0||this.mux.WINDOW_VISIBLE===!1&&o==="hb")&&this.eventQueue.flushEvents(),this.rateLimited)return O.event="eventrateexceeded",F=(0,s.default)(O),this.eventQueue.queueEvent(O.event,F),y.default.error("Beaconing disabled due to rate limit.")}}},r.prototype.destroy=function(){this.eventQueue.destroy(!1)};var c=function(o,v,m,O){return!(!o||v.indexOf("request_")!==0)&&(v==="request_response_headers"||(m===void 0?"undefined":S(m))!=="object"||(O===void 0?"undefined":S(O))!=="object"||Object.keys(m||{}).length!==Object.keys(O||{}).length)},f=function(o,v){return o==="renditionchange"&&v.indexOf("video_source_")===0};r.prototype._deduplicateBeaconData=function(o,v){var m=this,O={},b=v.view_id;if(!b||o==="viewstart"||o==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)O=(0,t.default)({},v),b&&(this.previousBeaconData=O),b&&o==="viewend"&&(this.previousBeaconData=null);else{var M=o.indexOf("request")===0;Object.keys(v).forEach(function(F){var w=v[F];(w!==m.previousBeaconData[F]||l.indexOf(F)>-1||c(M,F,w,m.previousBeaconData[F])||f(o,F))&&(O[F]=w,m.previousBeaconData[F]=w)})}return O},h.default=r},function(P,h,R){"use strict";function p(a){return a&&a.__esModule?a:{default:a}}Object.defineProperty(h,"__esModule",{value:!0}),h.getAndUpdateSessionData=h.getAndUpdateViewerData=void 0;var S=R(15),I=p(S),x=R(52),L=p(x),A=R(6),y=R(2),D=p(y),_=function(){var a=void 0;try{a=I.default.parse(L.default.get("muxData")||"")}catch{a={}}return a},T=function(a){try{L.default.set("muxData",I.default.stringify(a),{expires:7300})}catch{}},g=function(){var a=_();return a.mux_viewer_id=a.mux_viewer_id||(0,A.generateUUID)(),a.msn=a.msn||Math.random(),T(a),{mux_viewer_id:a.mux_viewer_id,mux_sample_number:a.msn}},E=function(){var a=_(),e=D.default.now();return a.session_start&&(a.sst=a.session_start,delete a.session_start),a.session_id&&(a.sid=a.session_id,delete a.session_id),a.session_expires&&(a.sex=a.session_expires,delete a.session_expires),(!a.sex||a.sex<e)&&(a.sid=(0,A.generateUUID)(),a.sst=e),a.sex=e+15e5,T(a),{session_id:a.sid,session_start:a.sst,session_expires:a.sex}};h.getAndUpdateViewerData=g,h.getAndUpdateSessionData=E},function(P,h,R){"use strict";var p=R(42),S=R(16),I=R(10),x=Object.prototype.hasOwnProperty,L={brackets:function(n){return n+"[]"},comma:"comma",indices:function(n,i){return n+"["+i+"]"},repeat:function(n){return n}},A=Array.isArray,y=String.prototype.split,D=Array.prototype.push,_=function(n,i){D.apply(n,A(i)?i:[i])},T=Date.prototype.toISOString,g=I.default,E={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:S.encode,encodeValuesOnly:!1,format:g,formatter:I.formatters[g],indices:!1,serializeDate:function(n){return T.call(n)},skipNulls:!1,strictNullHandling:!1},a=function(n){return typeof n=="string"||typeof n=="number"||typeof n=="boolean"||typeof n=="symbol"||typeof n=="bigint"},e={},s=function n(i,t,l,d,r,c,f,o,v,m,O,b,M,F,w){for(var C=i,U=w,B=0,N=!1;(U=U.get(e))!==void 0&&!N;){var k=U.get(i);if(B+=1,k!==void 0){if(k===B)throw new RangeError("Cyclic object value");N=!0}U.get(e)===void 0&&(B=0)}if(typeof f=="function"?C=f(t,C):C instanceof Date?C=m(C):l==="comma"&&A(C)&&(C=S.maybeMap(C,function(te){return te instanceof Date?m(te):te})),C===null){if(d)return c&&!M?c(t,E.encoder,F,"key",O):t;C=""}if(a(C)||S.isBuffer(C)){if(c){var j=M?t:c(t,E.encoder,F,"key",O);if(l==="comma"&&M){for(var H=y.call(String(C),","),V="",Y=0;Y<H.length;++Y)V+=(Y===0?"":",")+b(c(H[Y],E.encoder,F,"value",O));return[b(j)+"="+V]}return[b(j)+"="+b(c(C,E.encoder,F,"value",O))]}return[b(t)+"="+b(String(C))]}var Q=[];if(C===void 0)return Q;var J;if(l==="comma"&&A(C))J=[{value:C.length>0?C.join(",")||null:void 0}];else if(A(f))J=f;else{var z=Object.keys(C);J=o?z.sort(o):z}for(var q=0;q<J.length;++q){var re=J[q],X=typeof re=="object"&&re.value!==void 0?re.value:C[re];if(!r||X!==null){var le=A(C)?typeof l=="function"?l(t,re):t:t+(v?"."+re:"["+re+"]");w.set(i,B);var ne=p();ne.set(e,w),_(Q,n(X,le,l,d,r,c,f,o,v,m,O,b,M,F,ne))}}return Q},u=function(n){if(!n)return E;if(n.encoder!==null&&n.encoder!==void 0&&typeof n.encoder!="function")throw new TypeError("Encoder has to be a function.");var i=n.charset||E.charset;if(n.charset!==void 0&&n.charset!=="utf-8"&&n.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=I.default;if(n.format!==void 0){if(!x.call(I.formatters,n.format))throw new TypeError("Unknown format option provided.");t=n.format}var l=I.formatters[t],d=E.filter;return(typeof n.filter=="function"||A(n.filter))&&(d=n.filter),{addQueryPrefix:typeof n.addQueryPrefix=="boolean"?n.addQueryPrefix:E.addQueryPrefix,allowDots:n.allowDots===void 0?E.allowDots:!!n.allowDots,charset:i,charsetSentinel:typeof n.charsetSentinel=="boolean"?n.charsetSentinel:E.charsetSentinel,delimiter:n.delimiter===void 0?E.delimiter:n.delimiter,encode:typeof n.encode=="boolean"?n.encode:E.encode,encoder:typeof n.encoder=="function"?n.encoder:E.encoder,encodeValuesOnly:typeof n.encodeValuesOnly=="boolean"?n.encodeValuesOnly:E.encodeValuesOnly,filter:d,format:t,formatter:l,serializeDate:typeof n.serializeDate=="function"?n.serializeDate:E.serializeDate,skipNulls:typeof n.skipNulls=="boolean"?n.skipNulls:E.skipNulls,sort:typeof n.sort=="function"?n.sort:null,strictNullHandling:typeof n.strictNullHandling=="boolean"?n.strictNullHandling:E.strictNullHandling}};P.exports=function(n,i){var t,l,d=n,r=u(i);typeof r.filter=="function"?(l=r.filter,d=l("",d)):A(r.filter)&&(l=r.filter,t=l);var c=[];if(typeof d!="object"||d===null)return"";var f;f=i&&i.arrayFormat in L?i.arrayFormat:i&&"indices"in i?i.indices?"indices":"repeat":"indices";var o=L[f];t||(t=Object.keys(d)),r.sort&&t.sort(r.sort);for(var v=p(),m=0;m<t.length;++m){var O=t[m];r.skipNulls&&d[O]===null||_(c,s(d[O],O,o,r.strictNullHandling,r.skipNulls,r.encode?r.encoder:null,r.filter,r.sort,r.allowDots,r.serializeDate,r.format,r.formatter,r.encodeValuesOnly,r.charset,v))}var b=c.join(r.delimiter),M=r.addQueryPrefix===!0?"?":"";return r.charsetSentinel&&(r.charset==="iso-8859-1"?M+="utf8=%26%2310003%3B&":M+="utf8=%E2%9C%93&"),b.length>0?M+b:""}},function(P,h,R){"use strict";var p=R(8),S=R(47),I=R(49),x=p("%TypeError%"),L=p("%WeakMap%",!0),A=p("%Map%",!0),y=S("WeakMap.prototype.get",!0),D=S("WeakMap.prototype.set",!0),_=S("WeakMap.prototype.has",!0),T=S("Map.prototype.get",!0),g=S("Map.prototype.set",!0),E=S("Map.prototype.has",!0),a=function(n,i){for(var t,l=n;(t=l.next)!==null;l=t)if(t.key===i)return l.next=t.next,t.next=n.next,n.next=t,t},e=function(n,i){var t=a(n,i);return t&&t.value},s=function(n,i,t){var l=a(n,i);l?l.value=t:n.next={key:i,next:n.next,value:t}},u=function(n,i){return!!a(n,i)};P.exports=function(){var n,i,t,l={assert:function(d){if(!l.has(d))throw new x("Side channel does not contain "+I(d))},get:function(d){if(L&&d&&(typeof d=="object"||typeof d=="function")){if(n)return y(n,d)}else if(A){if(i)return T(i,d)}else if(t)return e(t,d)},has:function(d){if(L&&d&&(typeof d=="object"||typeof d=="function")){if(n)return _(n,d)}else if(A){if(i)return E(i,d)}else if(t)return u(t,d);return!1},set:function(d,r){L&&d&&(typeof d=="object"||typeof d=="function")?(n||(n=new L),D(n,d,r)):A?(i||(i=new A),g(i,d,r)):(t||(t={key:{},next:null}),s(t,d,r))}};return l}},function(P,h,R){"use strict";var p=typeof Symbol!="undefined"&&Symbol,S=R(44);P.exports=function(){return typeof p=="function"&&typeof Symbol=="function"&&typeof p("foo")=="symbol"&&typeof Symbol("bar")=="symbol"&&S()}},function(P,h,R){"use strict";P.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var p={},S=Symbol("test"),I=Object(S);if(typeof S=="string"||Object.prototype.toString.call(S)!=="[object Symbol]"||Object.prototype.toString.call(I)!=="[object Symbol]")return!1;p[S]=42;for(S in p)return!1;if(typeof Object.keys=="function"&&Object.keys(p).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(p).length!==0)return!1;var x=Object.getOwnPropertySymbols(p);if(x.length!==1||x[0]!==S||!Object.prototype.propertyIsEnumerable.call(p,S))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var L=Object.getOwnPropertyDescriptor(p,S);if(L.value!==42||L.enumerable!==!0)return!1}return!0}},function(P,h,R){"use strict";var p=Array.prototype.slice,S=Object.prototype.toString;P.exports=function(I){var x=this;if(typeof x!="function"||S.call(x)!=="[object Function]")throw new TypeError("Function.prototype.bind called on incompatible "+x);for(var L,A=p.call(arguments,1),y=function(){if(this instanceof L){var E=x.apply(this,A.concat(p.call(arguments)));return Object(E)===E?E:this}return x.apply(I,A.concat(p.call(arguments)))},D=Math.max(0,x.length-A.length),_=[],T=0;T<D;T++)_.push("$"+T);if(L=Function("binder","return function ("+_.join(",")+"){ return binder.apply(this,arguments); }")(y),x.prototype){var g=function(){};g.prototype=x.prototype,L.prototype=new g,g.prototype=null}return L}},function(P,h,R){"use strict";var p=R(9);P.exports=p.call(Function.call,Object.prototype.hasOwnProperty)},function(P,h,R){"use strict";var p=R(8),S=R(48),I=S(p("String.prototype.indexOf"));P.exports=function(x,L){var A=p(x,!!L);return typeof A=="function"&&I(x,".prototype.")>-1?S(A):A}},function(P,h,R){"use strict";var p=R(9),S=R(8),I=S("%Function.prototype.apply%"),x=S("%Function.prototype.call%"),L=S("%Reflect.apply%",!0)||p.call(x,I),A=S("%Object.getOwnPropertyDescriptor%",!0),y=S("%Object.defineProperty%",!0),D=S("%Math.max%");if(y)try{y({},"a",{value:1})}catch{y=null}P.exports=function(T){var g=L(p,x,arguments);return A&&y&&A(g,"length").configurable&&y(g,"length",{value:1+D(0,T.length-(arguments.length-1))}),g};var _=function(){return L(p,I,arguments)};y?y(P.exports,"apply",{value:_}):P.exports.apply=_},function(P,h,R){function p(W,G){if(W===1/0||W===-1/0||W!==W||W&&W>-1e3&&W<1e3||ue.call(/e/,G))return G;var oe=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof W=="number"){var de=W<0?-pe(-W):pe(W);if(de!==W){var ce=String(de),Se=te.call(G,ce.length+1);return ee.call(ce,oe,"$&_")+"."+ee.call(ee.call(Se,/([0-9]{3})/g,"$&_"),/_$/,"")}}return ee.call(G,oe,"$&_")}function S(W,G,oe){var de=(oe.quoteStyle||G)==="double"?'"':"'";return de+W+de}function I(W){return ee.call(String(W),/"/g,"&quot;")}function x(W){return!(e(W)!=="[object Array]"||ve&&typeof W=="object"&&ve in W)}function L(W){return!(e(W)!=="[object Date]"||ve&&typeof W=="object"&&ve in W)}function A(W){return!(e(W)!=="[object RegExp]"||ve&&typeof W=="object"&&ve in W)}function y(W){return!(e(W)!=="[object Error]"||ve&&typeof W=="object"&&ve in W)}function D(W){return!(e(W)!=="[object String]"||ve&&typeof W=="object"&&ve in W)}function _(W){return!(e(W)!=="[object Number]"||ve&&typeof W=="object"&&ve in W)}function T(W){return!(e(W)!=="[object Boolean]"||ve&&typeof W=="object"&&ve in W)}function g(W){if(ge)return W&&typeof W=="object"&&W instanceof Symbol;if(typeof W=="symbol")return!0;if(!W||typeof W!="object"||!fe)return!1;try{return fe.call(W),!0}catch{}return!1}function E(W){if(!W||typeof W!="object"||!Ee)return!1;try{return Ee.call(W),!0}catch{}return!1}function a(W,G){return ye.call(W,G)}function e(W){return X.call(W)}function s(W){if(W.name)return W.name;var G=ne.call(le.call(W),/^function\s*([\w$]+)/);return G?G[1]:null}function u(W,G){if(W.indexOf)return W.indexOf(G);for(var oe=0,de=W.length;oe<de;oe++)if(W[oe]===G)return oe;return-1}function n(W){if(!U||!W||typeof W!="object")return!1;try{U.call(W);try{j.call(W)}catch{return!0}return W instanceof Map}catch{}return!1}function i(W){if(!Y||!W||typeof W!="object")return!1;try{Y.call(W,Y);try{J.call(W,J)}catch{return!0}return W instanceof WeakMap}catch{}return!1}function t(W){if(!q||!W||typeof W!="object")return!1;try{return q.call(W),!0}catch{}return!1}function l(W){if(!j||!W||typeof W!="object")return!1;try{j.call(W);try{U.call(W)}catch{return!0}return W instanceof Set}catch{}return!1}function d(W){if(!J||!W||typeof W!="object")return!1;try{J.call(W,J);try{Y.call(W,Y)}catch{return!0}return W instanceof WeakSet}catch{}return!1}function r(W){return!(!W||typeof W!="object")&&(typeof HTMLElement!="undefined"&&W instanceof HTMLElement||typeof W.nodeName=="string"&&typeof W.getAttribute=="function")}function c(W,G){if(W.length>G.maxStringLength){var oe=W.length-G.maxStringLength,de="... "+oe+" more character"+(oe>1?"s":"");return c(te.call(W,0,G.maxStringLength),G)+de}return S(ee.call(ee.call(W,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,f),"single",G)}function f(W){var G=W.charCodeAt(0),oe={8:"b",9:"t",10:"n",12:"f",13:"r"}[G];return oe?"\\"+oe:"\\x"+(G<16?"0":"")+$.call(G.toString(16))}function o(W){return"Object("+W+")"}function v(W){return W+" { ? }"}function m(W,G,oe,de){return W+" ("+G+") {"+(de?M(oe,de):se.call(oe,", "))+"}"}function O(W){for(var G=0;G<W.length;G++)if(u(W[G],`
2
+ `)>=0)return!1;return!0}function b(W,G){var oe;if(W.indent===" ")oe=" ";else{if(!(typeof W.indent=="number"&&W.indent>0))return null;oe=se.call(Array(W.indent+1)," ")}return{base:oe,prev:se.call(Array(G+1),oe)}}function M(W,G){if(W.length===0)return"";var oe=`
3
+ `+G.prev+G.base;return oe+se.call(W,","+oe)+`
4
+ `+G.prev}function F(W,G){var oe=x(W),de=[];if(oe){de.length=W.length;for(var ce=0;ce<W.length;ce++)de[ce]=a(W,ce)?G(W[ce],W):""}var Se,ie=typeof ae=="function"?ae(W):[];if(ge){Se={};for(var Ae=0;Ae<ie.length;Ae++)Se["$"+ie[Ae]]=ie[Ae]}for(var De in W)a(W,De)&&(oe&&String(Number(De))===De&&De<W.length||ge&&Se["$"+De]instanceof Symbol||(ue.call(/[^\w$]/,De)?de.push(G(De,W)+": "+G(W[De],W)):de.push(De+": "+G(W[De],W))));if(typeof ae=="function")for(var Le=0;Le<ie.length;Le++)Te.call(W,ie[Le])&&de.push("["+G(ie[Le])+"]: "+G(W[ie[Le]],W));return de}var w=typeof Map=="function"&&Map.prototype,C=Object.getOwnPropertyDescriptor&&w?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,U=w&&C&&typeof C.get=="function"?C.get:null,B=w&&Map.prototype.forEach,N=typeof Set=="function"&&Set.prototype,k=Object.getOwnPropertyDescriptor&&N?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,j=N&&k&&typeof k.get=="function"?k.get:null,H=N&&Set.prototype.forEach,V=typeof WeakMap=="function"&&WeakMap.prototype,Y=V?WeakMap.prototype.has:null,Q=typeof WeakSet=="function"&&WeakSet.prototype,J=Q?WeakSet.prototype.has:null,z=typeof WeakRef=="function"&&WeakRef.prototype,q=z?WeakRef.prototype.deref:null,re=Boolean.prototype.valueOf,X=Object.prototype.toString,le=Function.prototype.toString,ne=String.prototype.match,te=String.prototype.slice,ee=String.prototype.replace,$=String.prototype.toUpperCase,Z=String.prototype.toLowerCase,ue=RegExp.prototype.test,he=Array.prototype.concat,se=Array.prototype.join,me=Array.prototype.slice,pe=Math.floor,Ee=typeof BigInt=="function"?BigInt.prototype.valueOf:null,ae=Object.getOwnPropertySymbols,fe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,ge=typeof Symbol=="function"&&typeof Symbol.iterator=="object",ve=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===ge?"object":"symbol")?Symbol.toStringTag:null,Te=Object.prototype.propertyIsEnumerable,_e=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(W){return W.__proto__}:null),Oe=R(50).custom,xe=Oe&&g(Oe)?Oe:null;P.exports=function W(G,oe,de,ce){function Se(Ke,et,Ft){if(et&&(ce=me.call(ce),ce.push(et)),Ft){var mt={depth:ie.depth};return a(ie,"quoteStyle")&&(mt.quoteStyle=ie.quoteStyle),W(Ke,mt,de+1,ce)}return W(Ke,ie,de+1,ce)}var ie=oe||{};if(a(ie,"quoteStyle")&&ie.quoteStyle!=="single"&&ie.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(a(ie,"maxStringLength")&&(typeof ie.maxStringLength=="number"?ie.maxStringLength<0&&ie.maxStringLength!==1/0:ie.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var Ae=!a(ie,"customInspect")||ie.customInspect;if(typeof Ae!="boolean"&&Ae!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(a(ie,"indent")&&ie.indent!==null&&ie.indent!==" "&&!(parseInt(ie.indent,10)===ie.indent&&ie.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(a(ie,"numericSeparator")&&typeof ie.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var De=ie.numericSeparator;if(G===void 0)return"undefined";if(G===null)return"null";if(typeof G=="boolean")return G?"true":"false";if(typeof G=="string")return c(G,ie);if(typeof G=="number"){if(G===0)return 1/0/G>0?"0":"-0";var Le=String(G);return De?p(G,Le):Le}if(typeof G=="bigint"){var Ce=String(G)+"n";return De?p(G,Ce):Ce}var Pe=ie.depth===void 0?5:ie.depth;if(de===void 0&&(de=0),de>=Pe&&Pe>0&&typeof G=="object")return x(G)?"[Array]":"[Object]";var Ie=b(ie,de);if(ce===void 0)ce=[];else if(u(ce,G)>=0)return"[Circular]";if(typeof G=="function"){var Ve=s(G),Be=F(G,Se);return"[Function"+(Ve?": "+Ve:" (anonymous)")+"]"+(Be.length>0?" { "+se.call(Be,", ")+" }":"")}if(g(G)){var Re=ge?ee.call(String(G),/^(Symbol\(.*\))_[^)]*$/,"$1"):fe.call(G);return typeof G!="object"||ge?Re:o(Re)}if(r(G)){for(var Fe="<"+Z.call(String(G.nodeName)),ke=G.attributes||[],Ne=0;Ne<ke.length;Ne++)Fe+=" "+ke[Ne].name+"="+S(I(ke[Ne].value),"double",ie);return Fe+=">",G.childNodes&&G.childNodes.length&&(Fe+="..."),Fe+="</"+Z.call(String(G.nodeName))+">"}if(x(G)){if(G.length===0)return"[]";var Ye=F(G,Se);return Ie&&!O(Ye)?"["+M(Ye,Ie)+"]":"[ "+se.call(Ye,", ")+" ]"}if(y(G)){var ze=F(G,Se);return"cause"in G&&!Te.call(G,"cause")?"{ ["+String(G)+"] "+se.call(he.call("[cause]: "+Se(G.cause),ze),", ")+" }":ze.length===0?"["+String(G)+"]":"{ ["+String(G)+"] "+se.call(ze,", ")+" }"}if(typeof G=="object"&&Ae){if(xe&&typeof G[xe]=="function")return G[xe]();if(Ae!=="symbol"&&typeof G.inspect=="function")return G.inspect()}if(n(G)){var $e=[];return B.call(G,function(Ke,et){$e.push(Se(et,G,!0)+" => "+Se(Ke,G))}),m("Map",U.call(G),$e,Ie)}if(l(G)){var Ze=[];return H.call(G,function(Ke){Ze.push(Se(Ke,G))}),m("Set",j.call(G),Ze,Ie)}if(i(G))return v("WeakMap");if(d(G))return v("WeakSet");if(t(G))return v("WeakRef");if(_(G))return o(Se(Number(G)));if(E(G))return o(Se(Ee.call(G)));if(T(G))return o(re.call(G));if(D(G))return o(Se(String(G)));if(!L(G)&&!A(G)){var we=F(G,Se),Xe=_e?_e(G)===Object.prototype:G instanceof Object||G.constructor===Object,Qe=G instanceof Object?"":"null prototype",qe=!Xe&&ve&&Object(G)===G&&ve in G?te.call(e(G),8,-1):Qe?"Object":"",Ct=Xe||typeof G.constructor!="function"?"":G.constructor.name?G.constructor.name+" ":"",nt=Ct+(qe||Qe?"["+se.call(he.call([],qe||[],Qe||[]),": ")+"] ":"");return we.length===0?nt+"{}":Ie?nt+"{"+M(we,Ie)+"}":nt+"{ "+se.call(we,", ")+" }"}return String(G)};var ye=Object.prototype.hasOwnProperty||function(W){return W in this}},function(P,h){},function(P,h,R){"use strict";var p=R(16),S=Object.prototype.hasOwnProperty,I=Array.isArray,x={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:p.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},L=function(g){return g.replace(/&#(\d+);/g,function(E,a){return String.fromCharCode(parseInt(a,10))})},A=function(g,E){return g&&typeof g=="string"&&E.comma&&g.indexOf(",")>-1?g.split(","):g},y=function(g,E){var a,e={},s=E.ignoreQueryPrefix?g.replace(/^\?/,""):g,u=E.parameterLimit===1/0?void 0:E.parameterLimit,n=s.split(E.delimiter,u),i=-1,t=E.charset;if(E.charsetSentinel)for(a=0;a<n.length;++a)n[a].indexOf("utf8=")===0&&(n[a]==="utf8=%E2%9C%93"?t="utf-8":n[a]==="utf8=%26%2310003%3B"&&(t="iso-8859-1"),i=a,a=n.length);for(a=0;a<n.length;++a)if(a!==i){var l,d,r=n[a],c=r.indexOf("]="),f=c===-1?r.indexOf("="):c+1;f===-1?(l=E.decoder(r,x.decoder,t,"key"),d=E.strictNullHandling?null:""):(l=E.decoder(r.slice(0,f),x.decoder,t,"key"),d=p.maybeMap(A(r.slice(f+1),E),function(o){return E.decoder(o,x.decoder,t,"value")})),d&&E.interpretNumericEntities&&t==="iso-8859-1"&&(d=L(d)),r.indexOf("[]=")>-1&&(d=I(d)?[d]:d),S.call(e,l)?e[l]=p.combine(e[l],d):e[l]=d}return e},D=function(g,E,a,e){for(var s=e?E:A(E,a),u=g.length-1;u>=0;--u){var n,i=g[u];if(i==="[]"&&a.parseArrays)n=[].concat(s);else{n=a.plainObjects?Object.create(null):{};var t=i.charAt(0)==="["&&i.charAt(i.length-1)==="]"?i.slice(1,-1):i,l=parseInt(t,10);a.parseArrays||t!==""?!isNaN(l)&&i!==t&&String(l)===t&&l>=0&&a.parseArrays&&l<=a.arrayLimit?(n=[],n[l]=s):t!=="__proto__"&&(n[t]=s):n={0:s}}s=n}return s},_=function(g,E,a,e){if(g){var s=a.allowDots?g.replace(/\.([^.[]+)/g,"[$1]"):g,u=/(\[[^[\]]*])/,n=/(\[[^[\]]*])/g,i=a.depth>0&&u.exec(s),t=i?s.slice(0,i.index):s,l=[];if(t){if(!a.plainObjects&&S.call(Object.prototype,t)&&!a.allowPrototypes)return;l.push(t)}for(var d=0;a.depth>0&&(i=n.exec(s))!==null&&d<a.depth;){if(d+=1,!a.plainObjects&&S.call(Object.prototype,i[1].slice(1,-1))&&!a.allowPrototypes)return;l.push(i[1])}return i&&l.push("["+s.slice(i.index)+"]"),D(l,E,a,e)}},T=function(g){if(!g)return x;if(g.decoder!==null&&g.decoder!==void 0&&typeof g.decoder!="function")throw new TypeError("Decoder has to be a function.");if(g.charset!==void 0&&g.charset!=="utf-8"&&g.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var E=g.charset===void 0?x.charset:g.charset;return{allowDots:g.allowDots===void 0?x.allowDots:!!g.allowDots,allowPrototypes:typeof g.allowPrototypes=="boolean"?g.allowPrototypes:x.allowPrototypes,allowSparse:typeof g.allowSparse=="boolean"?g.allowSparse:x.allowSparse,arrayLimit:typeof g.arrayLimit=="number"?g.arrayLimit:x.arrayLimit,charset:E,charsetSentinel:typeof g.charsetSentinel=="boolean"?g.charsetSentinel:x.charsetSentinel,comma:typeof g.comma=="boolean"?g.comma:x.comma,decoder:typeof g.decoder=="function"?g.decoder:x.decoder,delimiter:typeof g.delimiter=="string"||p.isRegExp(g.delimiter)?g.delimiter:x.delimiter,depth:typeof g.depth=="number"||g.depth===!1?+g.depth:x.depth,ignoreQueryPrefix:g.ignoreQueryPrefix===!0,interpretNumericEntities:typeof g.interpretNumericEntities=="boolean"?g.interpretNumericEntities:x.interpretNumericEntities,parameterLimit:typeof g.parameterLimit=="number"?g.parameterLimit:x.parameterLimit,parseArrays:g.parseArrays!==!1,plainObjects:typeof g.plainObjects=="boolean"?g.plainObjects:x.plainObjects,strictNullHandling:typeof g.strictNullHandling=="boolean"?g.strictNullHandling:x.strictNullHandling}};P.exports=function(g,E){var a=T(E);if(g===""||g===null||g===void 0)return a.plainObjects?Object.create(null):{};for(var e=typeof g=="string"?y(g,a):g,s=a.plainObjects?Object.create(null):{},u=Object.keys(e),n=0;n<u.length;++n){var i=u[n],t=_(i,e[i],a,typeof g=="string");s=p.merge(s,t,a)}return a.allowSparse===!0?s:p.compact(s)}},function(P,h,R){"use strict";var p,S,I=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(x){return typeof x}:function(x){return x&&typeof Symbol=="function"&&x.constructor===Symbol&&x!==Symbol.prototype?"symbol":typeof x};(function(x){var L=!1;if(p=x,(S=typeof p=="function"?p.call(h,R,h,P):p)!==void 0&&(P.exports=S),L=!0,I(h)==="object"&&(P.exports=x(),L=!0),!L){var A=window.Cookies,y=window.Cookies=x();y.noConflict=function(){return window.Cookies=A,y}}})(function(){function x(A){function y(D,_,T){var g;if(typeof document!="undefined"){if(arguments.length>1){if(T=L({path:"/"},y.defaults,T),typeof T.expires=="number"){var E=new Date;E.setMilliseconds(E.getMilliseconds()+864e5*T.expires),T.expires=E}try{g=JSON.stringify(_),/^[\{\[]/.test(g)&&(_=g)}catch{}return _=A.write?A.write(_,D):encodeURIComponent(String(_)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),D=encodeURIComponent(String(D)),D=D.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),D=D.replace(/[\(\)]/g,escape),document.cookie=[D,"=",_,T.expires?"; expires="+T.expires.toUTCString():"",T.path?"; path="+T.path:"",T.domain?"; domain="+T.domain:"",T.secure?"; secure":""].join("")}D||(g={});for(var a=document.cookie?document.cookie.split("; "):[],e=/(%[0-9A-Z]{2})+/g,s=0;s<a.length;s++){var u=a[s].split("="),n=u.slice(1).join("=");n.charAt(0)==='"'&&(n=n.slice(1,-1));try{var i=u[0].replace(e,decodeURIComponent);if(n=A.read?A.read(n,i):A(n,i)||n.replace(e,decodeURIComponent),this.json)try{n=JSON.parse(n)}catch{}if(D===i){g=n;break}D||(g[i]=n)}catch{}}return g}}return y.set=y,y.get=function(D){return y.call(y,D)},y.getJSON=function(){return y.apply({json:!0},[].slice.call(arguments))},y.defaults={},y.remove=function(D,_){y(D,"",L(_,{expires:-1}))},y.withConverter=x,y}var L=function(){for(var A=0,y={};A<arguments.length;A++){var D=arguments[A];for(var _ in D)y[_]=D[_]}return y};return x(function(){})})},function(P,h,R){"use strict";function p(S,I){var x=I.beaconCollectionDomain,L=I.beaconDomain;if(x)return"https://"+x;S=S||"inferred";var A=L||"litix.io";return S.match(/^[a-z0-9]+$/)?"https://"+S+"."+A:"https://img.litix.io/a.gif"}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=R(0),S=function(L){return L&&L.__esModule?L:{default:L}}(p),I=function(){var L=void 0;switch(x()){case"cellular":L="cellular";break;case"ethernet":L="wired";break;case"wifi":L="wifi";break;case void 0:break;default:L="other"}return L},x=function(){var L=S.default.navigator,A=L&&(L.connection||L.mozConnection||L.webkitConnection);return A&&A.type};h.default=I},function(P,h,R){"use strict";function p(n){return n&&n.__esModule?n:{default:n}}Object.defineProperty(h,"__esModule",{value:!0});var S=R(0),I=p(S),x=R(4),L=p(x),A=R(56),y=p(A),D=R(1),_=p(D),T=R(17),g=p(T),E=R(2),a=p(E),e=!!I.default.XMLHttpRequest&&"withCredentials"in new I.default.XMLHttpRequest,s={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4},u=function(n,i){this._beaconUrl=n||"https://img.litix.io",this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=(0,_.default)({},s,i)};u.prototype.queueEvent=function(n,i){var t=(0,_.default)({},i);return e?(this._eventQueue.length<=this._options.maxQueueLength||n==="eventrateexceeded")&&(this._eventQueue.push(t),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength):(y.default.send(this._beaconUrl,t),!0)},u.prototype.flushEvents=function(){e&&(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},u.prototype.destroy=function(){var n=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,n?this._clearBeaconQueue():this.flushEvents(),I.default.clearTimeout(this._sendTimeout)},u.prototype._clearBeaconQueue=function(){var n=I.default.navigator,i=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,t=this._eventQueue.slice(i);i>0&&(0,_.default)(t[t.length-1],(0,g.default)({mux_view_message:"event queue truncated"}));var l=this._createPayload(t);if(n.sendBeacon)n.sendBeacon(this._beaconUrl,l);else if(I.default.XMLHttpRequest){var d=new I.default.XMLHttpRequest;d.open("POST",this._beaconUrl),d.setRequestHeader("Content-Type","application/json"),d.send(l)}else y.default.send(this._beaconUrl,t[t.length-1])},u.prototype._sendBeaconQueue=function(){var n=this;if(I.default.XMLHttpRequest&&!this._postInFlight){var i=new I.default.XMLHttpRequest,t=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0,i.onreadystatechange=function(){i.readyState===4&&(i.status!==200?(n._eventQueue=t.concat(n._eventQueue),n._failureCount+=1,L.default.info("Error sending beacon: "+i.status),L.default.info(i.responseText)):n._failureCount=0,n._roundTripTime=a.default.now()-d,n._postInFlight=!1)},i.open("POST",this._beaconUrl),i.setRequestHeader("Content-Type","application/json");var l=this._createPayload(t),d=a.default.now();i.send(l)}},u.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var n=Math.pow(2,this._failureCount-1);return(1+(n*=Math.random()))*this._options.baseTimeBetweenBeacons},u.prototype._startBeaconSending=function(){var n=this;I.default.clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=I.default.setTimeout(function(){n._eventQueue.length&&n._sendBeaconQueue(),n._startBeaconSending()},this._getNextBeaconTime()))},u.prototype._createPayload=function(n){var i={transmission_timestamp:Math.round(a.default.now())};return this._roundTripTime&&(i.rtt_ms=Math.round(this._roundTripTime)),JSON.stringify({metadata:i,events:n})},h.default=u},function(P,h,R){"use strict";function p(y){return y&&y.__esModule?y:{default:y}}Object.defineProperty(h,"__esModule",{value:!0});var S=R(15),I=p(S),x=R(0),L=p(x),A={};A.send=function(y,D){function _(){T.src=E+(g?"&rc="+g:"")}var T=new Image,g=0,E=y+"?"+I.default.stringify(D);return T.addEventListener("error",function(){g>3||L.default.setTimeout(function(){g++,_()},5e3*g)}),_(),T},h.default=A},function(P,h,R){"use strict";function p(){function S(E,a){var e=a.request_start,s=a.request_response_start,u=a.request_response_end,n=a.request_bytes_loaded;D++;var i=void 0,t=void 0;if(s?(i=s-e,t=u-s):t=u-e,t>0&&n>0){var l=n/t*8e3;_++,A+=n,y+=t,this.data.view_min_request_throughput=Math.min(this.data.view_min_request_throughput||1/0,l),this.data.view_average_request_throughput=A/y*8e3,this.data.view_request_count=D,i>0&&(L+=i,this.data.view_max_request_latency=Math.max(this.data.view_max_request_latency||0,i),this.data.view_average_request_latency=L/_)}}function I(E,a){D++,T++,this.data.view_request_count=D,this.data.view_request_failed_count=T}function x(E,a){D++,g++,this.data.view_request_count=D,this.data.view_request_canceled_count=g}var L=0,A=0,y=0,D=0,_=0,T=0,g=0;this.on("requestcompleted",S),this.on("requestfailed",I),this.on("requestcanceled",x)}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p},function(P,h,R){"use strict";function p(_,T,g){var E=(0,A.findMediaElement)(T),a=I(E,3),e=a[0],s=a[1],u=a[2],n=_.log,i=_.utils.getComputedStyle,t=_.utils.secondsToMs,l={automaticErrorTracking:!0};if(!e)return n.error("No element was found with the `"+s+"` query selector.");if(u!=="video"&&u!=="audio")return n.error("The element of `"+s+"` was not a media element.");g=(0,L.default)(l,g),g.data=(0,L.default)({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:"4.8.0"},g.data),g.getPlayheadTime=function(){return t(e.currentTime)},g.getStateData=function(){var r=this.hlsjs&&this.hlsjs.url,c=this.dashjs&&S(this.dashjs.getSource==="function")&&this.dashjs.getSource();return{player_is_paused:e.paused,player_playhead_time:t(e.currentTime),player_width:parseInt(i(e,"width")),player_height:parseInt(i(e,"height")),player_autoplay_on:e.autoplay,player_preload_on:e.preload,video_poster_url:e.poster,video_source_url:r||c||e.currentSrc,video_source_duration:t(e.duration),video_source_height:e.videoHeight,video_source_width:e.videoWidth}},e.mux=e.mux||{},e.mux.deleted=!1,e.mux.emit=function(r,c){_.emit(s,r,c)};var d=function(){n.error("The monitor for this video element has already been destroyed.")};e.mux.destroy=function(){Object.keys(e.mux.listeners).forEach(function(r){e.removeEventListener(r,e.mux.listeners[r],!1)}),delete e.mux.listeners,e.mux.destroy=d,e.mux.swapElement=d,e.mux.emit=d,e.mux.addHLSJS=d,e.mux.addDashJS=d,e.mux.removeHLSJS=d,e.mux.removeDashJS=d,e.mux.deleted=!0,_.emit(s,"destroy")},e.mux.swapElement=function(r){var c=(0,A.findMediaElement)(r),f=I(c,3),o=f[0],v=f[1],m=f[2];return o?m!=="video"&&m!=="audio"?_.log.error("The element of `"+v+"` was not a media element."):(o.muxId=e.muxId,delete e.muxId,o.mux=o.mux||{},o.mux.listeners=(0,L.default)({},e.mux.listeners),delete e.mux.listeners,Object.keys(o.mux.listeners).forEach(function(O){e.removeEventListener(O,o.mux.listeners[O],!1),o.addEventListener(O,o.mux.listeners[O],!1)}),o.mux.swapElement=e.mux.swapElement,o.mux.destroy=e.mux.destroy,delete e.mux,void(e=o)):_.log.error("No element was found with the `"+v+"` query selector.")},e.mux.addHLSJS=function(r){_.addHLSJS(s,r)},e.mux.addDashJS=function(r){_.addDashJS(s,r)},e.mux.removeHLSJS=function(){_.removeHLSJS(s)},e.mux.removeDashJS=function(){_.removeDashJS(s)},_.init(s,g),_.emit(s,"playerready"),e.paused||(_.emit(s,"play"),e.readyState>2&&_.emit(s,"playing")),e.mux.listeners={},y.forEach(function(r){(r!=="error"||g.automaticErrorTracking)&&(e.mux.listeners[r]=function(){var c={};if(r==="error"){if(!e.error||e.error.code===1)return;c.player_error_code=e.error.code,c.player_error_message=D[e.error.code]||e.error.message}_.emit(s,r,c)},e.addEventListener(r,e.mux.listeners[r],!1))})}Object.defineProperty(h,"__esModule",{value:!0});var S=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(_){return typeof _}:function(_){return _&&typeof Symbol=="function"&&_.constructor===Symbol&&_!==Symbol.prototype?"symbol":typeof _},I=function(){function _(T,g){var E=[],a=!0,e=!1,s=void 0;try{for(var u,n=T[Symbol.iterator]();!(a=(u=n.next()).done)&&(E.push(u.value),!g||E.length!==g);a=!0);}catch(i){e=!0,s=i}finally{try{!a&&n.return&&n.return()}finally{if(e)throw s}}return E}return function(T,g){if(Array.isArray(T))return T;if(Symbol.iterator in Object(T))return _(T,g);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();h.default=p;var x=R(1),L=function(_){return _&&_.__esModule?_:{default:_}}(x),A=R(11),y=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],D={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"}},function(P,h,R){"use strict";function p(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(h,"__esModule",{value:!0});var S=R(60),I=p(S),x=R(3),L=p(x),A=R(61),y=p(A),D=R(62),_=p(D),T=R(1),g=p(T),E=R(7),a=p(E),e=R(5),s=R(2),u=p(s),n=R(63),i=p(n),t={};t.safeCall=I.default,t.safeIncrement=L.default,t.getComputedStyle=y.default,t.secondsToMs=_.default,t.assign=g.default,t.headersStringToObject=a.default,t.extractHostnameAndDomain=e.extractHostnameAndDomain,t.extractHostname=e.extractHostname,t.now=u.default.now,t.manifestParser=i.default,h.default=t},function(P,h,R){"use strict";function p(x,L,A,y){var D=y;if(x&&typeof x[L]=="function")try{D=x[L].apply(x,A)}catch(_){I.default.info("safeCall error",_)}return D}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p;var S=R(4),I=function(x){return x&&x.__esModule?x:{default:x}}(S)},function(P,h,R){"use strict";function p(L,A){if(L&&A&&I.default&&typeof I.default.getComputedStyle=="function"){var y=void 0;return x&&x.has(L)&&(y=x.get(L)),y||(y=I.default.getComputedStyle(L,null),x&&x.set(L,y)),y.getPropertyValue(A)}}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p;var S=R(0),I=function(L){return L&&L.__esModule?L:{default:L}}(S),x=void 0;I.default&&I.default.WeakMap&&(x=new WeakMap)},function(P,h,R){"use strict";function p(S){return Math.floor(1e3*S)}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p},function(P,h,R){"use strict";function p(u){return u&&u.__esModule?u:{default:u}}Object.defineProperty(h,"__esModule",{value:!0});var S=R(1),I=p(S),x=R(14),L=p(x),A={TARGET_DURATION:"#EXT-X-TARGETDURATION",PART_INF:"#EXT-X-PART-INF",SERVER_CONTROL:"#EXT-X-SERVER-CONTROL",INF:"#EXTINF",PROGRAM_DATE_TIME:"#EXT-X-PROGRAM-DATE-TIME",VERSION:"#EXT-X-VERSION",SESSION_DATA:"#EXT-X-SESSION-DATA"},y=function(u){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(u),this.manifest};y.prototype.process=function(u){var n=void 0;for(this.buffer+=u,n=this.buffer.indexOf(`
5
+ `);n>-1;n=this.buffer.indexOf(`
6
+ `))this.processLine(this.buffer.substring(0,n)),this.buffer=this.buffer.substring(n+1)},y.prototype.processLine=function(u){var n=u.indexOf(":"),i=e(u,n),t=i[0],l=i.length===2?T(i[1]):void 0;if(t[0]!=="#")this.currentUri.uri=t,this.manifest.segments.push(this.currentUri),!this.manifest.targetDuration||"duration"in this.currentUri||(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(t){case A.TARGET_DURATION:if(!isFinite(l)||l<0)return;this.manifest.targetDuration=l,this.setHoldBack();break;case A.PART_INF:D(this.manifest,i),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case A.SERVER_CONTROL:D(this.manifest,i),this.setHoldBack();break;case A.INF:l===0?this.currentUri.duration=.01:l>0&&(this.currentUri.duration=l);break;case A.PROGRAM_DATE_TIME:var d=l,r=new Date(d);this.manifest.dateTimeString||(this.manifest.dateTimeString=d,this.manifest.dateTimeObject=r),this.currentUri.dateTimeString=d,this.currentUri.dateTimeObject=r;break;case A.VERSION:D(this.manifest,i);break;case A.SESSION_DATA:var c=s(i[1]),f=(0,L.default)(c);(0,I.default)(this.manifest.sessionData,f)}},y.prototype.setHoldBack=function(){var u=this.manifest,n=u.serverControl,i=u.targetDuration,t=u.partTargetDuration;if(n){var l="holdBack",d="partHoldBack",r=i&&3*i,c=t&&2*t;i&&!n.hasOwnProperty(l)&&(n[l]=r),r&&n[l]<r&&(n[l]=r),t&&!n.hasOwnProperty(d)&&(n[d]=3*t),t&&n[d]<c&&(n[d]=c)}};var D=function(u,n){var i=_(n[0].replace("#EXT-X-","")),t=void 0;a(n[1])?(t={},t=(0,I.default)(E(n[1]),t)):t=T(n[1]),u[i]=t},_=function(u){return u.toLowerCase().replace(/-(\w)/g,function(n){return n[1].toUpperCase()})},T=function(u){if(u.toLowerCase()==="yes"||u.toLowerCase()==="no")return u.toLowerCase()==="yes";var n=u.indexOf(":")!==-1?u:parseFloat(u);return isNaN(n)?u:n},g=function(u){var n={},i=u.split("=");return i.length>1&&(n[_(i[0])]=T(i[1])),n},E=function(u){for(var n=u.split(","),i={},t=0;n.length>t;t++){var l=n[t],d=g(l);i=(0,I.default)(d,i)}return i},a=function(u){return u.indexOf("=")>-1},e=function(u,n){return n===-1?[u]:[u.substring(0,n),u.substring(n+1)]},s=function(u){var n={};if(u){var i=u.search(",");return[u.slice(0,i),u.slice(i+1)].forEach(function(t,l){for(var d=t.replace(/['"]+/g,"").split("="),r=0;r<d.length;r++)d[r]==="DATA-ID"&&(n["DATA-ID"]=d[1-r]),d[r]==="VALUE"&&(n.VALUE=d[1-r])}),{data:n}}};h.default=y},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p={PLAYER_READY:"playerready",VIEW_INIT:"viewinit",VIDEO_CHANGE:"videochange",PLAY:"play",PAUSE:"pause",PLAYING:"playing",TIME_UPDATE:"timeupdate",SEEKING:"seeking",SEEKED:"seeked",REBUFFER_START:"rebufferstart",REBUFFER_END:"rebufferend",ERROR:"error",ENDED:"ended",RENDITION_CHANGE:"renditionchange",ORIENTATION_CHANGE:"orientationchange",AD_REQUEST:"adrequest",AD_RESPONSE:"adresponse",AD_BREAK_START:"adbreakstart",AD_PLAY:"adplay",AD_PLAYING:"adplaying",AD_PAUSE:"adpause",AD_FIRST_QUARTILE:"adfirstquartile",AD_MID_POINT:"admidpoint",AD_THIRD_QUARTILE:"adthirdquartile",AD_ENDED:"adended",AD_BREAK_END:"adbreakend",AD_ERROR:"aderror",REQUEST_COMPLETED:"requestcompleted",REQUEST_FAILED:"requestfailed",REQUEST_CANCELLED:"requestcanceled"};h.default=p}])})})()});var it=yt((Je,st)=>{typeof window!="undefined"&&function(P,h){typeof Je=="object"&&typeof st=="object"?st.exports=h():typeof define=="function"&&define.amd?define([],h):typeof Je=="object"?Je.Hls=h():P.Hls=h()}(Je,function(){return function(K){var P={};function h(R){if(P[R])return P[R].exports;var p=P[R]={i:R,l:!1,exports:{}};return K[R].call(p.exports,p,p.exports,h),p.l=!0,p.exports}return h.m=K,h.c=P,h.d=function(R,p,S){h.o(R,p)||Object.defineProperty(R,p,{enumerable:!0,get:S})},h.r=function(R){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(R,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(R,"__esModule",{value:!0})},h.t=function(R,p){if(p&1&&(R=h(R)),p&8||p&4&&typeof R=="object"&&R&&R.__esModule)return R;var S=Object.create(null);if(h.r(S),Object.defineProperty(S,"default",{enumerable:!0,value:R}),p&2&&typeof R!="string")for(var I in R)h.d(S,I,function(x){return R[x]}.bind(null,I));return S},h.n=function(R){var p=R&&R.__esModule?function(){return R.default}:function(){return R};return h.d(p,"a",p),p},h.o=function(R,p){return Object.prototype.hasOwnProperty.call(R,p)},h.p="/dist/",h(h.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(K,P,h){"use strict";var R=Object.prototype.hasOwnProperty,p="~";function S(){}Object.create&&(S.prototype=Object.create(null),new S().__proto__||(p=!1));function I(y,D,_){this.fn=y,this.context=D,this.once=_||!1}function x(y,D,_,T,g){if(typeof _!="function")throw new TypeError("The listener must be a function");var E=new I(_,T||y,g),a=p?p+D:D;return y._events[a]?y._events[a].fn?y._events[a]=[y._events[a],E]:y._events[a].push(E):(y._events[a]=E,y._eventsCount++),y}function L(y,D){--y._eventsCount===0?y._events=new S:delete y._events[D]}function A(){this._events=new S,this._eventsCount=0}A.prototype.eventNames=function(){var D=[],_,T;if(this._eventsCount===0)return D;for(T in _=this._events)R.call(_,T)&&D.push(p?T.slice(1):T);return Object.getOwnPropertySymbols?D.concat(Object.getOwnPropertySymbols(_)):D},A.prototype.listeners=function(D){var _=p?p+D:D,T=this._events[_];if(!T)return[];if(T.fn)return[T.fn];for(var g=0,E=T.length,a=new Array(E);g<E;g++)a[g]=T[g].fn;return a},A.prototype.listenerCount=function(D){var _=p?p+D:D,T=this._events[_];return T?T.fn?1:T.length:0},A.prototype.emit=function(D,_,T,g,E,a){var e=p?p+D:D;if(!this._events[e])return!1;var s=this._events[e],u=arguments.length,n,i;if(s.fn){switch(s.once&&this.removeListener(D,s.fn,void 0,!0),u){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,_),!0;case 3:return s.fn.call(s.context,_,T),!0;case 4:return s.fn.call(s.context,_,T,g),!0;case 5:return s.fn.call(s.context,_,T,g,E),!0;case 6:return s.fn.call(s.context,_,T,g,E,a),!0}for(i=1,n=new Array(u-1);i<u;i++)n[i-1]=arguments[i];s.fn.apply(s.context,n)}else{var t=s.length,l;for(i=0;i<t;i++)switch(s[i].once&&this.removeListener(D,s[i].fn,void 0,!0),u){case 1:s[i].fn.call(s[i].context);break;case 2:s[i].fn.call(s[i].context,_);break;case 3:s[i].fn.call(s[i].context,_,T);break;case 4:s[i].fn.call(s[i].context,_,T,g);break;default:if(!n)for(l=1,n=new Array(u-1);l<u;l++)n[l-1]=arguments[l];s[i].fn.apply(s[i].context,n)}}return!0},A.prototype.on=function(D,_,T){return x(this,D,_,T,!1)},A.prototype.once=function(D,_,T){return x(this,D,_,T,!0)},A.prototype.removeListener=function(D,_,T,g){var E=p?p+D:D;if(!this._events[E])return this;if(!_)return L(this,E),this;var a=this._events[E];if(a.fn)a.fn===_&&(!g||a.once)&&(!T||a.context===T)&&L(this,E);else{for(var e=0,s=[],u=a.length;e<u;e++)(a[e].fn!==_||g&&!a[e].once||T&&a[e].context!==T)&&s.push(a[e]);s.length?this._events[E]=s.length===1?s[0]:s:L(this,E)}return this},A.prototype.removeAllListeners=function(D){var _;return D?(_=p?p+D:D,this._events[_]&&L(this,_)):(this._events=new S,this._eventsCount=0),this},A.prototype.off=A.prototype.removeListener,A.prototype.addListener=A.prototype.on,A.prefixed=p,A.EventEmitter=A,K.exports=A},"./node_modules/url-toolkit/src/url-toolkit.js":function(K,P,h){(function(R){var p=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,S=/^(?=([^\/?#]*))\1([^]*)$/,I=/(?:\/|^)\.(?=\/)/g,x=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,L={buildAbsoluteURL:function(A,y,D){if(D=D||{},A=A.trim(),y=y.trim(),!y){if(!D.alwaysNormalize)return A;var _=L.parseURL(A);if(!_)throw new Error("Error trying to parse base URL.");return _.path=L.normalizePath(_.path),L.buildURLFromParts(_)}var T=L.parseURL(y);if(!T)throw new Error("Error trying to parse relative URL.");if(T.scheme)return D.alwaysNormalize?(T.path=L.normalizePath(T.path),L.buildURLFromParts(T)):y;var g=L.parseURL(A);if(!g)throw new Error("Error trying to parse base URL.");if(!g.netLoc&&g.path&&g.path[0]!=="/"){var E=S.exec(g.path);g.netLoc=E[1],g.path=E[2]}g.netLoc&&!g.path&&(g.path="/");var a={scheme:g.scheme,netLoc:T.netLoc,path:null,params:T.params,query:T.query,fragment:T.fragment};if(!T.netLoc&&(a.netLoc=g.netLoc,T.path[0]!=="/"))if(!T.path)a.path=g.path,T.params||(a.params=g.params,T.query||(a.query=g.query));else{var e=g.path,s=e.substring(0,e.lastIndexOf("/")+1)+T.path;a.path=L.normalizePath(s)}return a.path===null&&(a.path=D.alwaysNormalize?L.normalizePath(T.path):T.path),L.buildURLFromParts(a)},parseURL:function(A){var y=p.exec(A);return y?{scheme:y[1]||"",netLoc:y[2]||"",path:y[3]||"",params:y[4]||"",query:y[5]||"",fragment:y[6]||""}:null},normalizePath:function(A){for(A=A.split("").reverse().join("").replace(I,"");A.length!==(A=A.replace(x,"")).length;);return A.split("").reverse().join("")},buildURLFromParts:function(A){return A.scheme+A.netLoc+A.path+A.params+A.query+A.fragment}};K.exports=L})(this)},"./node_modules/webworkify-webpack/index.js":function(K,P,h){function R(D){var _={};function T(E){if(_[E])return _[E].exports;var a=_[E]={i:E,l:!1,exports:{}};return D[E].call(a.exports,a,a.exports,T),a.l=!0,a.exports}T.m=D,T.c=_,T.i=function(E){return E},T.d=function(E,a,e){T.o(E,a)||Object.defineProperty(E,a,{configurable:!1,enumerable:!0,get:e})},T.r=function(E){Object.defineProperty(E,"__esModule",{value:!0})},T.n=function(E){var a=E&&E.__esModule?function(){return E.default}:function(){return E};return T.d(a,"a",a),a},T.o=function(E,a){return Object.prototype.hasOwnProperty.call(E,a)},T.p="/",T.oe=function(E){throw console.error(E),E};var g=T(T.s=ENTRY_MODULE);return g.default||g}var p="[\\.|\\-|\\+|\\w|/|@]+",S="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+p+").*?\\)";function I(D){return(D+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function x(D){return!isNaN(1*D)}function L(D,_,T){var g={};g[T]=[];var E=_.toString(),a=E.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!a)return g;for(var e=a[1],s=new RegExp("(\\\\n|\\W)"+I(e)+S,"g"),u;u=s.exec(E);)u[3]!=="dll-reference"&&g[T].push(u[3]);for(s=new RegExp("\\("+I(e)+'\\("(dll-reference\\s('+p+'))"\\)\\)'+S,"g");u=s.exec(E);)D[u[2]]||(g[T].push(u[1]),D[u[2]]=h(u[1]).m),g[u[2]]=g[u[2]]||[],g[u[2]].push(u[4]);for(var n=Object.keys(g),i=0;i<n.length;i++)for(var t=0;t<g[n[i]].length;t++)x(g[n[i]][t])&&(g[n[i]][t]=1*g[n[i]][t]);return g}function A(D){var _=Object.keys(D);return _.reduce(function(T,g){return T||D[g].length>0},!1)}function y(D,_){for(var T={main:[_]},g={main:[]},E={main:{}};A(T);)for(var a=Object.keys(T),e=0;e<a.length;e++){var s=a[e],u=T[s],n=u.pop();if(E[s]=E[s]||{},!(E[s][n]||!D[s][n])){E[s][n]=!0,g[s]=g[s]||[],g[s].push(n);for(var i=L(D,D[s][n],s),t=Object.keys(i),l=0;l<t.length;l++)T[t[l]]=T[t[l]]||[],T[t[l]]=T[t[l]].concat(i[t[l]])}}return g}K.exports=function(D,_){_=_||{};var T={main:h.m},g=_.all?{main:Object.keys(T.main)}:y(T,D),E="";Object.keys(g).filter(function(n){return n!=="main"}).forEach(function(n){for(var i=0;g[n][i];)i++;g[n].push(i),T[n][i]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",E=E+"var "+n+" = ("+R.toString().replace("ENTRY_MODULE",JSON.stringify(i))+")({"+g[n].map(function(t){return""+JSON.stringify(t)+": "+T[n][t].toString()}).join(",")+`});
7
+ `}),E=E+"new (("+R.toString().replace("ENTRY_MODULE",JSON.stringify(D))+")({"+g.main.map(function(n){return""+JSON.stringify(n)+": "+T.main[n].toString()}).join(",")+"}))(self);";var a=new window.Blob([E],{type:"text/javascript"});if(_.bare)return a;var e=window.URL||window.webkitURL||window.mozURL||window.msURL,s=e.createObjectURL(a),u=new window.Worker(s);return u.objectURL=s,u}},"./src/config.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"hlsDefaultConfig",function(){return l}),h.d(P,"mergeConfig",function(){return r}),h.d(P,"enableStreamingMode",function(){return c});var R=h("./src/controller/abr-controller.ts"),p=h("./src/controller/audio-stream-controller.ts"),S=h("./src/controller/audio-track-controller.ts"),I=h("./src/controller/subtitle-stream-controller.ts"),x=h("./src/controller/subtitle-track-controller.ts"),L=h("./src/controller/buffer-controller.ts"),A=h("./src/controller/timeline-controller.ts"),y=h("./src/controller/cap-level-controller.ts"),D=h("./src/controller/fps-controller.ts"),_=h("./src/controller/eme-controller.ts"),T=h("./src/controller/cmcd-controller.ts"),g=h("./src/utils/xhr-loader.ts"),E=h("./src/utils/fetch-loader.ts"),a=h("./src/utils/cues.ts"),e=h("./src/utils/mediakeys-helper.ts"),s=h("./src/utils/logger.ts");function u(){return u=Object.assign?Object.assign.bind():function(f){for(var o=1;o<arguments.length;o++){var v=arguments[o];for(var m in v)Object.prototype.hasOwnProperty.call(v,m)&&(f[m]=v[m])}return f},u.apply(this,arguments)}function n(f,o){var v=Object.keys(f);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(f);o&&(m=m.filter(function(O){return Object.getOwnPropertyDescriptor(f,O).enumerable})),v.push.apply(v,m)}return v}function i(f){for(var o=1;o<arguments.length;o++){var v=arguments[o]!=null?arguments[o]:{};o%2?n(Object(v),!0).forEach(function(m){t(f,m,v[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(f,Object.getOwnPropertyDescriptors(v)):n(Object(v)).forEach(function(m){Object.defineProperty(f,m,Object.getOwnPropertyDescriptor(v,m))})}return f}function t(f,o,v){return o in f?Object.defineProperty(f,o,{value:v,enumerable:!0,configurable:!0,writable:!0}):f[o]=v,f}var l=i(i({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:g.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:R.default,bufferController:L.default,capLevelController:y.default,fpsController:D.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:e.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},d()),{},{subtitleStreamController:I.SubtitleStreamController,subtitleTrackController:x.default,timelineController:A.TimelineController,audioStreamController:p.default,audioTrackController:S.default,emeController:_.default,cmcdController:T.default});function d(){return{cueHandler:a.default,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function r(f,o){if((o.liveSyncDurationCount||o.liveMaxLatencyDurationCount)&&(o.liveSyncDuration||o.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(o.liveMaxLatencyDurationCount!==void 0&&(o.liveSyncDurationCount===void 0||o.liveMaxLatencyDurationCount<=o.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(o.liveMaxLatencyDuration!==void 0&&(o.liveSyncDuration===void 0||o.liveMaxLatencyDuration<=o.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return u({},f,o)}function c(f){var o=f.loader;if(o!==E.default&&o!==g.default)s.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),f.progressive=!1;else{var v=Object(E.fetchSupported)();v&&(f.loader=E.default,f.progressive=!0,f.enableSoftwareAES=!0,s.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/polyfills/number.ts"),p=h("./src/utils/ewma-bandwidth-estimator.ts"),S=h("./src/events.ts"),I=h("./src/utils/buffer-helper.ts"),x=h("./src/errors.ts"),L=h("./src/types/loader.ts"),A=h("./src/utils/logger.ts");function y(T,g){for(var E=0;E<g.length;E++){var a=g[E];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(T,a.key,a)}}function D(T,g,E){return g&&y(T.prototype,g),E&&y(T,E),Object.defineProperty(T,"prototype",{writable:!1}),T}var _=function(){function T(E){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=E;var a=E.config;this.bwEstimator=new p.default(a.abrEwmaSlowVoD,a.abrEwmaFastVoD,a.abrEwmaDefaultEstimate),this.registerListeners()}var g=T.prototype;return g.registerListeners=function(){var a=this.hls;a.on(S.Events.FRAG_LOADING,this.onFragLoading,this),a.on(S.Events.FRAG_LOADED,this.onFragLoaded,this),a.on(S.Events.FRAG_BUFFERED,this.onFragBuffered,this),a.on(S.Events.LEVEL_LOADED,this.onLevelLoaded,this),a.on(S.Events.ERROR,this.onError,this)},g.unregisterListeners=function(){var a=this.hls;a.off(S.Events.FRAG_LOADING,this.onFragLoading,this),a.off(S.Events.FRAG_LOADED,this.onFragLoaded,this),a.off(S.Events.FRAG_BUFFERED,this.onFragBuffered,this),a.off(S.Events.LEVEL_LOADED,this.onLevelLoaded,this),a.off(S.Events.ERROR,this.onError,this)},g.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},g.onFragLoading=function(a,e){var s=e.frag;if(s.type===L.PlaylistLevelType.MAIN&&!this.timer){var u;this.fragCurrent=s,this.partCurrent=(u=e.part)!=null?u:null,this.timer=self.setInterval(this.onCheck,100)}},g.onLevelLoaded=function(a,e){var s=this.hls.config;e.details.live?this.bwEstimator.update(s.abrEwmaSlowLive,s.abrEwmaFastLive):this.bwEstimator.update(s.abrEwmaSlowVoD,s.abrEwmaFastVoD)},g._abandonRulesCheck=function(){var a=this.fragCurrent,e=this.partCurrent,s=this.hls,u=s.autoLevelEnabled,n=s.config,i=s.media;if(!(!a||!i)){var t=e?e.stats:a.stats,l=e?e.duration:a.duration;if(t.aborted){A.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!(!u||i.paused||!i.playbackRate||!i.readyState)){var d=performance.now()-t.loading.start,r=Math.abs(i.playbackRate);if(!(d<=500*l/r)){var c=s.levels,f=s.minAutoLevel,o=c[a.level],v=t.total||Math.max(t.loaded,Math.round(l*o.maxBitrate/8)),m=Math.max(1,t.bwEstimate?t.bwEstimate/8:t.loaded*1e3/d),O=(v-t.loaded)/m,b=i.currentTime,M=(I.BufferHelper.bufferInfo(i,b,n.maxBufferHole).end-b)/r;if(!(M>=2*l/r||O<=M)){var F=Number.POSITIVE_INFINITY,w;for(w=a.level-1;w>f;w--){var C=c[w].maxBitrate;if(F=l*C/(8*.8*m),F<M)break}if(!(F>=O)){var U=this.bwEstimator.getEstimate();A.logger.warn("Fragment "+a.sn+(e?" part "+e.index:"")+" of level "+a.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+w+`
8
8
  Current BW estimate: `+(Object(R.isFiniteNumber)(U)?(U/1024).toFixed(3):"Unknown")+` Kb/s
9
9
  Estimated load time for current fragment: `+O.toFixed(3)+` s
10
10
  Estimated load time for the next fragment: `+F.toFixed(3)+` s
11
- Time to underbuffer: `+M.toFixed(3)+" s"),i.nextLoadLevel=B,this.bwEstimator.sample(d,n.loaded),this.clearTimer(),s.loader&&(this.fragCurrent=this.partCurrent=null,s.loader.abort()),i.trigger(x.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:s,part:e,stats:n})}}}}}},v.onFragLoaded=function(s,e){var i=e.frag,t=e.part;if(i.type===L.PlaylistLevelType.MAIN&&Object(R.isFiniteNumber)(i.sn)){var r=t?t.stats:i.stats,a=t?t.duration:i.duration;if(this.clearTimer(),this.lastLoadedFragLevel=i.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var n=this.hls.levels[i.level],h=(n.loaded?n.loaded.bytes:0)+r.loaded,d=(n.loaded?n.loaded.duration:0)+a;n.loaded={bytes:h,duration:d},n.realBitrate=Math.round(8*h/d)}if(i.bitrateTest){var u={stats:r,frag:i,part:t,id:i.type};this.onFragBuffered(x.Events.FRAG_BUFFERED,u),i.bitrateTest=!1}}},v.onFragBuffered=function(s,e){var i=e.frag,t=e.part,r=t?t.stats:i.stats;if(!r.aborted&&!(i.type!==L.PlaylistLevelType.MAIN||i.sn==="initSegment")){var a=r.parsing.end-r.loading.start;this.bwEstimator.sample(a,r.loaded),r.bwEstimate=this.bwEstimator.getEstimate(),i.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}},v.onError=function(s,e){switch(e.details){case T.ErrorDetails.FRAG_LOAD_ERROR:case T.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},v.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},v.getNextABRAutoLevel=function(){var s=this.fragCurrent,e=this.partCurrent,i=this.hls,t=i.maxAutoLevel,r=i.config,a=i.minAutoLevel,n=i.media,h=e?e.duration:s?s.duration:0,d=n?n.currentTime:0,u=n&&n.playbackRate!==0?Math.abs(n.playbackRate):1,f=this.bwEstimator?this.bwEstimator.getEstimate():r.abrEwmaDefaultEstimate,l=(b.BufferHelper.bufferInfo(n,d,r.maxBufferHole).end-d)/u,o=this.findBestLevel(f,a,t,l,r.abrBandWidthFactor,r.abrBandWidthUpFactor);if(o>=0)return o;_.logger.trace((l?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var E=h?Math.min(h,r.maxStarvationDelay):r.maxStarvationDelay,m=r.abrBandWidthFactor,O=r.abrBandWidthUpFactor;if(!l){var P=this.bitrateTestDelay;if(P){var M=h?Math.min(h,r.maxLoadingDelay):r.maxLoadingDelay;E=M-P,_.logger.trace("bitrate test took "+Math.round(1e3*P)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*E)+" ms"),m=O=1}}return o=this.findBestLevel(f,a,t,l+E,m,O),Math.max(o,0)},v.findBestLevel=function(s,e,i,t,r,a){for(var n,h=this.fragCurrent,d=this.partCurrent,u=this.lastLoadedFragLevel,f=this.hls.levels,l=f[u],o=!!(l!=null&&(n=l.details)!==null&&n!==void 0&&n.live),E=l==null?void 0:l.codecSet,m=d?d.duration:h?h.duration:0,O=i;O>=e;O--){var P=f[O];if(!(!P||E&&P.codecSet!==E)){var M=P.details,F=(d?M==null?void 0:M.partTarget:M==null?void 0:M.averagetargetduration)||m,B=void 0;O<=u?B=r*s:B=a*s;var C=f[O].maxBitrate,U=C*F/B;if(_.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+O+"/"+Math.round(B)+"/"+C+"/"+F+"/"+t+"/"+U),B>C&&(!U||o&&!this.bitrateTestDelay||U<t))return O}}return-1},A(S,[{key:"nextAutoLevel",get:function(){var s=this._nextAutoLevel,e=this.bwEstimator;if(s!==-1&&(!e||!e.canEstimate()))return s;var i=this.getNextABRAutoLevel();return s!==-1&&(i=Math.min(s,i)),i},set:function(s){this._nextAutoLevel=s}}]),S}();I.default=D},"./src/controller/audio-stream-controller.ts":function(N,I,c){"use strict";c.r(I);var R=c("./src/polyfills/number.ts"),y=c("./src/controller/base-stream-controller.ts"),x=c("./src/events.ts"),b=c("./src/utils/buffer-helper.ts"),T=c("./src/controller/fragment-tracker.ts"),L=c("./src/types/level.ts"),_=c("./src/types/loader.ts"),g=c("./src/loader/fragment.ts"),A=c("./src/demux/chunk-cache.ts"),D=c("./src/demux/transmuxer-interface.ts"),S=c("./src/types/transmuxer.ts"),v=c("./src/controller/fragment-finders.ts"),p=c("./src/utils/discontinuities.ts"),s=c("./src/errors.ts"),e=c("./src/utils/logger.ts");function i(){return i=Object.assign||function(h){for(var d=1;d<arguments.length;d++){var u=arguments[d];for(var f in u)Object.prototype.hasOwnProperty.call(u,f)&&(h[f]=u[f])}return h},i.apply(this,arguments)}function t(h,d){h.prototype=Object.create(d.prototype),h.prototype.constructor=h,r(h,d)}function r(h,d){return r=Object.setPrototypeOf||function(f,l){return f.__proto__=l,f},r(h,d)}var a=100,n=function(h){t(d,h);function d(f,l){var o;return o=h.call(this,f,l,"[audio-stream-controller]")||this,o.videoBuffer=null,o.videoTrackCC=-1,o.waitingVideoCC=-1,o.audioSwitch=!1,o.trackId=-1,o.waitingData=null,o.mainDetails=null,o.bufferFlushed=!1,o._registerListeners(),o}var u=d.prototype;return u.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},u._registerListeners=function(){var l=this.hls;l.on(x.Events.MEDIA_ATTACHED,this.onMediaAttached,this),l.on(x.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.on(x.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.on(x.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.on(x.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),l.on(x.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),l.on(x.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),l.on(x.Events.ERROR,this.onError,this),l.on(x.Events.BUFFER_RESET,this.onBufferReset,this),l.on(x.Events.BUFFER_CREATED,this.onBufferCreated,this),l.on(x.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),l.on(x.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),l.on(x.Events.FRAG_BUFFERED,this.onFragBuffered,this)},u._unregisterListeners=function(){var l=this.hls;l.off(x.Events.MEDIA_ATTACHED,this.onMediaAttached,this),l.off(x.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.off(x.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.off(x.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.off(x.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),l.off(x.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),l.off(x.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),l.off(x.Events.ERROR,this.onError,this),l.off(x.Events.BUFFER_RESET,this.onBufferReset,this),l.off(x.Events.BUFFER_CREATED,this.onBufferCreated,this),l.off(x.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),l.off(x.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),l.off(x.Events.FRAG_BUFFERED,this.onFragBuffered,this)},u.onInitPtsFound=function(l,o){var E=o.frag,m=o.id,O=o.initPTS;if(m==="main"){var P=E.cc;this.initPTS[E.cc]=O,this.log("InitPTS for cc: "+P+" found from main: "+O),this.videoTrackCC=P,this.state===y.State.WAITING_INIT_PTS&&this.tick()}},u.startLoad=function(l){if(!this.levels){this.startPosition=l,this.state=y.State.STOPPED;return}var o=this.lastCurrentTime;this.stopLoad(),this.setInterval(a),this.fragLoadError=0,o>0&&l===-1?(this.log("Override startPosition with lastCurrentTime @"+o.toFixed(3)),this.state=y.State.IDLE):(this.loadedmetadata=!1,this.state=y.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=l,this.tick()},u.doTick=function(){switch(this.state){case y.State.IDLE:this.doTickIdle();break;case y.State.WAITING_TRACK:{var l,o=this.levels,E=this.trackId,m=o==null||(l=o[E])===null||l===void 0?void 0:l.details;if(m){if(this.waitForCdnTuneIn(m))break;this.state=y.State.WAITING_INIT_PTS}break}case y.State.FRAG_LOADING_WAITING_RETRY:{var O,P=performance.now(),M=this.retryDate;(!M||P>=M||(O=this.media)!==null&&O!==void 0&&O.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=y.State.IDLE);break}case y.State.WAITING_INIT_PTS:{var F=this.waitingData;if(F){var B=F.frag,C=F.part,U=F.cache,w=F.complete;if(this.initPTS[B.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=y.State.FRAG_LOADING;var k=U.flush(),j={frag:B,part:C,payload:k,networkDetails:null};this._handleFragmentLoadProgress(j),w&&h.prototype._handleFragmentLoadComplete.call(this,j)}else if(this.videoTrackCC!==this.waitingVideoCC)e.logger.log("Waiting fragment cc ("+B.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var K=this.getLoadPosition(),G=b.BufferHelper.bufferInfo(this.mediaBuffer,K,this.config.maxBufferHole),Y=Object(v.fragmentWithinToleranceTest)(G.end,this.config.maxFragLookUpTolerance,B);Y<0&&(e.logger.log("Waiting fragment cc ("+B.cc+") @ "+B.start+" cancelled because another fragment at "+G.end+" is needed"),this.clearWaitingFragment())}}else this.state=y.State.IDLE}}this.onTickEnd()},u.clearWaitingFragment=function(){var l=this.waitingData;l&&(this.fragmentTracker.removeFragment(l.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=y.State.IDLE)},u.onTickEnd=function(){var l=this.media;if(!(!l||!l.readyState)){var o=this.mediaBuffer?this.mediaBuffer:l,E=o.buffered;!this.loadedmetadata&&E.length&&(this.loadedmetadata=!0),this.lastCurrentTime=l.currentTime}},u.doTickIdle=function(){var l,o,E=this.hls,m=this.levels,O=this.media,P=this.trackId,M=E.config;if(!(!m||!m[P])&&!(!O&&(this.startFragRequested||!M.startFragPrefetch))){var F=m[P],B=F.details;if(!B||B.live&&this.levelLastLoaded!==P||this.waitForCdnTuneIn(B)){this.state=y.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,g.ElementaryStreamTypes.AUDIO,_.PlaylistLevelType.AUDIO));var C=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,_.PlaylistLevelType.AUDIO);if(C!==null){var U=C.len,w=this.getMaxBufferLength(),k=this.audioSwitch;if(!(U>=w&&!k)){if(!k&&this._streamEnded(C,B)){E.trigger(x.Events.BUFFER_EOS,{type:"audio"}),this.state=y.State.ENDED;return}var j=B.fragments,K=j[0].start,G=C.end;if(k){var Y=this.getLoadPosition();G=Y,B.PTSKnown&&Y<K&&(C.end>K||C.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),O.currentTime=K+.05)}var V=this.getNextFragment(G,B);if(!V){this.bufferFlushed=!0;return}((l=V.decryptdata)===null||l===void 0?void 0:l.keyFormat)==="identity"&&!((o=V.decryptdata)!==null&&o!==void 0&&o.key)?this.loadKey(V,B):this.loadFragment(V,B,G)}}}},u.getMaxBufferLength=function(){var l=h.prototype.getMaxBufferLength.call(this),o=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,_.PlaylistLevelType.MAIN);return o===null?l:Math.max(l,o.len)},u.onMediaDetaching=function(){this.videoBuffer=null,h.prototype.onMediaDetaching.call(this)},u.onAudioTracksUpdated=function(l,o){var E=o.audioTracks;this.resetTransmuxer(),this.levels=E.map(function(m){return new L.Level(m)})},u.onAudioTrackSwitching=function(l,o){var E=!!o.url;this.trackId=o.id;var m=this.fragCurrent;m!=null&&m.loader&&m.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),E?this.setInterval(a):this.resetTransmuxer(),E?(this.audioSwitch=!0,this.state=y.State.IDLE):this.state=y.State.STOPPED,this.tick()},u.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},u.onLevelLoaded=function(l,o){this.mainDetails=o.details},u.onAudioTrackLoaded=function(l,o){var E,m=this.levels,O=o.details,P=o.id;if(!m){this.warn("Audio tracks were reset while loading level "+P);return}this.log("Track "+P+" loaded ["+O.startSN+","+O.endSN+"],duration:"+O.totalduration);var M=m[P],F=0;if(O.live||(E=M.details)!==null&&E!==void 0&&E.live){var B=this.mainDetails;if(O.fragments[0]||(O.deltaUpdateFailed=!0),O.deltaUpdateFailed||!B)return;!M.details&&O.hasProgramDateTime&&B.hasProgramDateTime?(Object(p.alignMediaPlaylistByPDT)(O,B),F=O.fragments[0].start):F=this.alignPlaylists(O,M.details)}M.details=O,this.levelLastLoaded=P,!this.startFragRequested&&(this.mainDetails||!O.live)&&this.setStartPosition(M.details,F),this.state===y.State.WAITING_TRACK&&!this.waitForCdnTuneIn(O)&&(this.state=y.State.IDLE),this.tick()},u._handleFragmentLoadProgress=function(l){var o,E=l.frag,m=l.part,O=l.payload,P=this.config,M=this.trackId,F=this.levels;if(!F){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+E.sn+" of level "+E.level+" will not be buffered");return}var B=F[M];console.assert(B,"Audio track is defined on fragment load progress");var C=B.details;console.assert(C,"Audio track details are defined on fragment load progress");var U=P.defaultAudioCodec||B.audioCodec||"mp4a.40.2",w=this.transmuxer;w||(w=this.transmuxer=new D.default(this.hls,_.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var k=this.initPTS[E.cc],j=(o=E.initSegment)===null||o===void 0?void 0:o.data;if(k!==void 0){var K=!1,G=m?m.index:-1,Y=G!==-1,V=new S.ChunkMetadata(E.level,E.sn,E.stats.chunkCount,O.byteLength,G,Y);w.push(O,j,U,"",E,m,C.totalduration,K,V,k)}else{e.logger.log("Unknown video PTS for cc "+E.cc+", waiting for video PTS before demuxing audio frag "+E.sn+" of ["+C.startSN+" ,"+C.endSN+"],track "+M);var Z=this.waitingData=this.waitingData||{frag:E,part:m,cache:new A.default,complete:!1},z=Z.cache;z.push(new Uint8Array(O)),this.waitingVideoCC=this.videoTrackCC,this.state=y.State.WAITING_INIT_PTS}},u._handleFragmentLoadComplete=function(l){if(this.waitingData){this.waitingData.complete=!0;return}h.prototype._handleFragmentLoadComplete.call(this,l)},u.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},u.onBufferCreated=function(l,o){var E=o.tracks.audio;E&&(this.mediaBuffer=E.buffer),o.tracks.video&&(this.videoBuffer=o.tracks.video.buffer)},u.onFragBuffered=function(l,o){var E=o.frag,m=o.part;if(E.type===_.PlaylistLevelType.AUDIO){if(this.fragContextChanged(E)){this.warn("Fragment "+E.sn+(m?" p: "+m.index:"")+" of level "+E.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}E.sn!=="initSegment"&&(this.fragPrevious=E,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(x.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(E,m)}},u.onError=function(l,o){switch(o.details){case s.ErrorDetails.FRAG_LOAD_ERROR:case s.ErrorDetails.FRAG_LOAD_TIMEOUT:case s.ErrorDetails.KEY_LOAD_ERROR:case s.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_.PlaylistLevelType.AUDIO,o);break;case s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==y.State.ERROR&&this.state!==y.State.STOPPED&&(this.state=o.fatal?y.State.ERROR:y.State.IDLE,this.warn(o.details+" while loading frag, switching to "+this.state+" state"));break;case s.ErrorDetails.BUFFER_FULL_ERROR:if(o.parent==="audio"&&(this.state===y.State.PARSING||this.state===y.State.PARSED)){var E=!0,m=this.getFwdBufferInfo(this.mediaBuffer,_.PlaylistLevelType.AUDIO);m&&m.len>.5&&(E=!this.reduceMaxBufferLength(m.len)),E&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,h.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},u.onBufferFlushed=function(l,o){var E=o.type;E===g.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},u._handleTransmuxComplete=function(l){var o,E="audio",m=this.hls,O=l.remuxResult,P=l.chunkMeta,M=this.getCurrentContext(P);if(!M){this.warn("The loading context changed while buffering fragment "+P.sn+" of level "+P.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(P.level);return}var F=M.frag,B=M.part,C=O.audio,U=O.text,w=O.id3,k=O.initSegment;if(!this.fragContextChanged(F)){if(this.state=y.State.PARSING,this.audioSwitch&&C&&this.completeAudioSwitch(),k!=null&&k.tracks&&(this._bufferInitSegment(k.tracks,F,P),m.trigger(x.Events.FRAG_PARSING_INIT_SEGMENT,{frag:F,id:E,tracks:k.tracks})),C){var j=C.startPTS,K=C.endPTS,G=C.startDTS,Y=C.endDTS;B&&(B.elementaryStreams[g.ElementaryStreamTypes.AUDIO]={startPTS:j,endPTS:K,startDTS:G,endDTS:Y}),F.setElementaryStreamInfo(g.ElementaryStreamTypes.AUDIO,j,K,G,Y),this.bufferFragmentData(C,F,B,P)}if(w!=null&&(o=w.samples)!==null&&o!==void 0&&o.length){var V=i({frag:F,id:E},w);m.trigger(x.Events.FRAG_PARSING_METADATA,V)}if(U){var Z=i({frag:F,id:E},U);m.trigger(x.Events.FRAG_PARSING_USERDATA,Z)}}},u._bufferInitSegment=function(l,o,E){if(this.state===y.State.PARSING){l.video&&delete l.video;var m=l.audio;if(!!m){m.levelCodec=m.codec,m.id="audio",this.log("Init audio buffer, container:"+m.container+", codecs[parsed]=["+m.codec+"]"),this.hls.trigger(x.Events.BUFFER_CODECS,l);var O=m.initSegment;if(O!=null&&O.byteLength){var P={type:"audio",frag:o,part:null,chunkMeta:E,parent:o.type,data:O};this.hls.trigger(x.Events.BUFFER_APPENDING,P)}this.tick()}}},u.loadFragment=function(l,o,E){var m=this.fragmentTracker.getState(l);this.fragCurrent=l,(this.audioSwitch||m===T.FragmentState.NOT_LOADED||m===T.FragmentState.PARTIAL)&&(l.sn==="initSegment"?this._loadInitSegment(l):o.live&&!Object(R.isFiniteNumber)(this.initPTS[l.cc])?(this.log("Waiting for video PTS in continuity counter "+l.cc+" of live stream before loading audio fragment "+l.sn+" of level "+this.trackId),this.state=y.State.WAITING_INIT_PTS):(this.startFragRequested=!0,h.prototype.loadFragment.call(this,l,o,E)))},u.completeAudioSwitch=function(){var l=this.hls,o=this.media,E=this.trackId;o&&(this.log("Switching audio track : flushing all audio"),h.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,l.trigger(x.Events.AUDIO_TRACK_SWITCHED,{id:E})},d}(y.default);I.default=n},"./src/controller/audio-track-controller.ts":function(N,I,c){"use strict";c.r(I);var R=c("./src/events.ts"),y=c("./src/errors.ts"),x=c("./src/controller/base-playlist-controller.ts"),b=c("./src/types/loader.ts");function T(D,S){for(var v=0;v<S.length;v++){var p=S[v];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(D,p.key,p)}}function L(D,S,v){return S&&T(D.prototype,S),v&&T(D,v),D}function _(D,S){D.prototype=Object.create(S.prototype),D.prototype.constructor=D,g(D,S)}function g(D,S){return g=Object.setPrototypeOf||function(p,s){return p.__proto__=s,p},g(D,S)}var A=function(D){_(S,D);function S(p){var s;return s=D.call(this,p,"[audio-track-controller]")||this,s.tracks=[],s.groupId=null,s.tracksInGroup=[],s.trackId=-1,s.trackName="",s.selectDefaultTrack=!0,s.registerListeners(),s}var v=S.prototype;return v.registerListeners=function(){var s=this.hls;s.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),s.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),s.on(R.Events.LEVEL_LOADING,this.onLevelLoading,this),s.on(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),s.on(R.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),s.on(R.Events.ERROR,this.onError,this)},v.unregisterListeners=function(){var s=this.hls;s.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),s.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),s.off(R.Events.LEVEL_LOADING,this.onLevelLoading,this),s.off(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),s.off(R.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),s.off(R.Events.ERROR,this.onError,this)},v.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,D.prototype.destroy.call(this)},v.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},v.onManifestParsed=function(s,e){this.tracks=e.audioTracks||[]},v.onAudioTrackLoaded=function(s,e){var i=e.id,t=e.details,r=this.tracksInGroup[i];if(!r){this.warn("Invalid audio track id "+i);return}var a=r.details;r.details=e.details,this.log("audioTrack "+i+" loaded ["+t.startSN+"-"+t.endSN+"]"),i===this.trackId&&(this.retryCount=0,this.playlistLoaded(i,e,a))},v.onLevelLoading=function(s,e){this.switchLevel(e.level)},v.onLevelSwitching=function(s,e){this.switchLevel(e.level)},v.switchLevel=function(s){var e=this.hls.levels[s];if(!!(e!=null&&e.audioGroupIds)){var i=e.audioGroupIds[e.urlId];if(this.groupId!==i){this.groupId=i;var t=this.tracks.filter(function(a){return!i||a.groupId===i});this.selectDefaultTrack&&!t.some(function(a){return a.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=t;var r={audioTracks:t};this.log("Updating audio tracks, "+t.length+' track(s) found in "'+i+'" group-id'),this.hls.trigger(R.Events.AUDIO_TRACKS_UPDATED,r),this.selectInitialTrack()}}},v.onError=function(s,e){D.prototype.onError.call(this,s,e),!(e.fatal||!e.context)&&e.context.type===b.PlaylistContextType.AUDIO_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.retryLoadingOrFail(e)},v.setAudioTrack=function(s){var e=this.tracksInGroup;if(s<0||s>=e.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var i=e[this.trackId];this.log("Now switching to audio-track index "+s);var t=e[s],r=t.id,a=t.groupId,n=a===void 0?"":a,h=t.name,d=t.type,u=t.url;if(this.trackId=s,this.trackName=h,this.selectDefaultTrack=!1,this.hls.trigger(R.Events.AUDIO_TRACK_SWITCHING,{id:r,groupId:n,name:h,type:d,url:u}),!(t.details&&!t.details.live)){var f=this.switchParams(t.url,i==null?void 0:i.details);this.loadPlaylist(f)}},v.selectInitialTrack=function(){var s=this.tracksInGroup;console.assert(s.length,"Initial audio track should be selected when tracks are known");var e=this.trackName,i=this.findTrackId(e)||this.findTrackId();i!==-1?this.setAudioTrack(i):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(R.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},v.findTrackId=function(s){for(var e=this.tracksInGroup,i=0;i<e.length;i++){var t=e[i];if((!this.selectDefaultTrack||t.default)&&(!s||s===t.name))return t.id}return-1},v.loadPlaylist=function(s){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var i=e.id,t=e.groupId,r=e.url;if(s)try{r=s.addDirectives(r)}catch(a){this.warn("Could not construct new URL with HLS Delivery Directives: "+a)}this.log("loading audio-track playlist for id: "+i),this.clearTimer(),this.hls.trigger(R.Events.AUDIO_TRACK_LOADING,{url:r,id:i,groupId:t,deliveryDirectives:s||null})}},L(S,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(s){this.selectDefaultTrack=!1,this.setAudioTrack(s)}}]),S}(x.default);I.default=A},"./src/controller/base-playlist-controller.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"default",function(){return L});var R=c("./src/polyfills/number.ts"),y=c("./src/types/level.ts"),x=c("./src/controller/level-helper.ts"),b=c("./src/utils/logger.ts"),T=c("./src/errors.ts"),L=function(){function _(A,D){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=b.logger.log.bind(b.logger,D+":"),this.warn=b.logger.warn.bind(b.logger,D+":"),this.hls=A}var g=_.prototype;return g.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},g.onError=function(D,S){S.fatal&&S.type===T.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},g.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},g.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},g.stopLoad=function(){this.canLoad=!1,this.clearTimer()},g.switchParams=function(D,S){var v=S==null?void 0:S.renditionReports;if(v)for(var p=0;p<v.length;p++){var s=v[p],e=""+s.URI;if(e===D.substr(-e.length)){var i=parseInt(s["LAST-MSN"]),t=parseInt(s["LAST-PART"]);if(S&&this.hls.config.lowLatencyMode){var r=Math.min(S.age-S.partTarget,S.targetduration);t!==void 0&&r>S.partTarget&&(t+=1)}if(Object(R.isFiniteNumber)(i))return new y.HlsUrlParameters(i,Object(R.isFiniteNumber)(t)?t:void 0,y.HlsSkip.No)}}},g.loadPlaylist=function(D){},g.shouldLoadTrack=function(D){return this.canLoad&&D&&!!D.url&&(!D.details||D.details.live)},g.playlistLoaded=function(D,S,v){var p=this,s=S.details,e=S.stats,i=e.loading.end?Math.max(0,self.performance.now()-e.loading.end):0;if(s.advancedDateTime=Date.now()-i,s.live||v!=null&&v.live){if(s.reloaded(v),v&&this.log("live playlist "+D+" "+(s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:"MISSED")),v&&s.fragments.length>0&&Object(x.mergeDetails)(v,s),!this.canLoad||!s.live)return;var t,r=void 0,a=void 0;if(s.canBlockReload&&s.endSN&&s.advanced){var n=this.hls.config.lowLatencyMode,h=s.lastPartSn,d=s.endSN,u=s.lastPartIndex,f=u!==-1,l=h===d,o=n?0:u;f?(r=l?d+1:h,a=l?o:u+1):r=d+1;var E=s.age,m=E+s.ageHeader,O=Math.min(m-s.partTarget,s.targetduration*1.5);if(O>0){if(v&&O>v.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+v.tuneInGoal+" to: "+O+" with playlist age: "+s.age),O=0;else{var P=Math.floor(O/s.targetduration);if(r+=P,a!==void 0){var M=Math.round(O%s.targetduration/s.partTarget);a+=M}this.log("CDN Tune-in age: "+s.ageHeader+"s last advanced "+E.toFixed(2)+"s goal: "+O+" skip sn "+P+" to part "+a)}s.tuneInGoal=O}if(t=this.getDeliveryDirectives(s,S.deliveryDirectives,r,a),n||!l){this.loadPlaylist(t);return}}else t=this.getDeliveryDirectives(s,S.deliveryDirectives,r,a);var F=Object(x.computeReloadInterval)(s,e);r!==void 0&&s.canBlockReload&&(F-=s.partTarget||1),this.log("reload live playlist "+D+" in "+Math.round(F)+" ms"),this.timer=self.setTimeout(function(){return p.loadPlaylist(t)},F)}else this.clearTimer()},g.getDeliveryDirectives=function(D,S,v,p){var s=Object(y.getSkipValue)(D,v);return S!=null&&S.skip&&D.deltaUpdateFailed&&(v=S.msn,p=S.part,s=y.HlsSkip.No),new y.HlsUrlParameters(v,p,s)},g.retryLoadingOrFail=function(D){var S=this,v=this.hls.config,p=this.retryCount<v.levelLoadingMaxRetry;if(p){var s;if(this.retryCount++,D.details.indexOf("LoadTimeOut")>-1&&(s=D.context)!==null&&s!==void 0&&s.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+D.details+'"'),this.loadPlaylist();else{var e=Math.min(Math.pow(2,this.retryCount)*v.levelLoadingRetryDelay,v.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return S.loadPlaylist()},e),this.warn("retry playlist loading #"+this.retryCount+" in "+e+' ms after "'+D.details+'"')}}else this.warn('cannot recover from error "'+D.details+'"'),this.clearTimer(),D.fatal=!0;return p},_}()},"./src/controller/base-stream-controller.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"State",function(){return d}),c.d(I,"default",function(){return u});var R=c("./src/polyfills/number.ts"),y=c("./src/task-loop.ts"),x=c("./src/controller/fragment-tracker.ts"),b=c("./src/utils/buffer-helper.ts"),T=c("./src/utils/logger.ts"),L=c("./src/events.ts"),_=c("./src/errors.ts"),g=c("./src/types/transmuxer.ts"),A=c("./src/utils/mp4-tools.ts"),D=c("./src/utils/discontinuities.ts"),S=c("./src/controller/fragment-finders.ts"),v=c("./src/controller/level-helper.ts"),p=c("./src/loader/fragment-loader.ts"),s=c("./src/crypt/decrypter.ts"),e=c("./src/utils/time-ranges.ts"),i=c("./src/types/loader.ts");function t(f,l){for(var o=0;o<l.length;o++){var E=l[o];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(f,E.key,E)}}function r(f,l,o){return l&&t(f.prototype,l),o&&t(f,o),f}function a(f){if(f===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return f}function n(f,l){f.prototype=Object.create(l.prototype),f.prototype.constructor=f,h(f,l)}function h(f,l){return h=Object.setPrototypeOf||function(E,m){return E.__proto__=m,E},h(f,l)}var d={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",BACKTRACKING:"BACKTRACKING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},u=function(f){n(l,f);function l(E,m,O){var P;return P=f.call(this)||this,P.hls=void 0,P.fragPrevious=null,P.fragCurrent=null,P.fragmentTracker=void 0,P.transmuxer=null,P._state=d.STOPPED,P.media=void 0,P.mediaBuffer=void 0,P.config=void 0,P.bitrateTest=!1,P.lastCurrentTime=0,P.nextLoadPosition=0,P.startPosition=0,P.loadedmetadata=!1,P.fragLoadError=0,P.retryDate=0,P.levels=null,P.fragmentLoader=void 0,P.levelLastLoaded=null,P.startFragRequested=!1,P.decrypter=void 0,P.initPTS=[],P.onvseeking=null,P.onvended=null,P.logPrefix="",P.log=void 0,P.warn=void 0,P.logPrefix=O,P.log=T.logger.log.bind(T.logger,O+":"),P.warn=T.logger.warn.bind(T.logger,O+":"),P.hls=E,P.fragmentLoader=new p.default(E.config),P.fragmentTracker=m,P.config=E.config,P.decrypter=new s.default(E,E.config),E.on(L.Events.KEY_LOADED,P.onKeyLoaded,a(P)),P}var o=l.prototype;return o.doTick=function(){this.onTickEnd()},o.onTickEnd=function(){},o.startLoad=function(m){},o.stopLoad=function(){this.fragmentLoader.abort();var m=this.fragCurrent;m&&this.fragmentTracker.removeFragment(m),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=d.STOPPED},o._streamEnded=function(m,O){var P=this.fragCurrent,M=this.fragmentTracker;if(!O.live&&P&&P.sn>=O.endSN&&!m.nextStart){var F=O.partList;if(F!=null&&F.length){var B=F[F.length-1],C=b.BufferHelper.isBuffered(this.media,B.start+B.duration/2);return C}var U=M.getState(P);return U===x.FragmentState.PARTIAL||U===x.FragmentState.OK}return!1},o.onMediaAttached=function(m,O){var P=this.media=this.mediaBuffer=O.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),P.addEventListener("seeking",this.onvseeking),P.addEventListener("ended",this.onvended);var M=this.config;this.levels&&M.autoStartLoad&&this.state===d.STOPPED&&this.startLoad(M.startPosition)},o.onMediaDetaching=function(){var m=this.media;m!=null&&m.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),m&&(m.removeEventListener("seeking",this.onvseeking),m.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},o.onMediaSeeking=function(){var m=this.config,O=this.fragCurrent,P=this.media,M=this.mediaBuffer,F=this.state,B=P?P.currentTime:0,C=b.BufferHelper.bufferInfo(M||P,B,m.maxBufferHole);if(this.log("media seeking to "+(Object(R.isFiniteNumber)(B)?B.toFixed(3):B)+", state: "+F),F===d.ENDED)this.resetLoadingState();else if(O&&!C.len){var U=m.maxFragLookUpTolerance,w=O.start-U,k=O.start+O.duration+U,j=B>k;(B<w||j)&&(j&&O.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),O.loader.abort()),this.resetLoadingState())}P&&(this.lastCurrentTime=B),!this.loadedmetadata&&!C.len&&(this.nextLoadPosition=this.startPosition=B),this.tickImmediate()},o.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},o.onKeyLoaded=function(m,O){if(!(this.state!==d.KEY_LOADING||O.frag!==this.fragCurrent||!this.levels)){this.state=d.IDLE;var P=this.levels[O.frag.level].details;P&&this.loadFragment(O.frag,P,O.frag.start)}},o.onHandlerDestroying=function(){this.stopLoad(),f.prototype.onHandlerDestroying.call(this)},o.onHandlerDestroyed=function(){this.state=d.STOPPED,this.hls.off(L.Events.KEY_LOADED,this.onKeyLoaded,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,f.prototype.onHandlerDestroyed.call(this)},o.loadKey=function(m,O){this.log("Loading key for "+m.sn+" of ["+O.startSN+"-"+O.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+m.level),this.state=d.KEY_LOADING,this.fragCurrent=m,this.hls.trigger(L.Events.KEY_LOADING,{frag:m})},o.loadFragment=function(m,O,P){this._loadFragForPlayback(m,O,P)},o._loadFragForPlayback=function(m,O,P){var M=this,F=function(C){if(M.fragContextChanged(m)){M.warn("Fragment "+m.sn+(C.part?" p: "+C.part.index:"")+" of level "+m.level+" was dropped during download."),M.fragmentTracker.removeFragment(m);return}m.stats.chunkCount++,M._handleFragmentLoadProgress(C)};this._doFragLoad(m,O,P,F).then(function(B){if(!!B){M.fragLoadError=0;var C=M.state;if(M.fragContextChanged(m)){(C===d.FRAG_LOADING||C===d.BACKTRACKING||!M.fragCurrent&&C===d.PARSING)&&(M.fragmentTracker.removeFragment(m),M.state=d.IDLE);return}if("payload"in B&&(M.log("Loaded fragment "+m.sn+" of level "+m.level),M.hls.trigger(L.Events.FRAG_LOADED,B),M.state===d.BACKTRACKING)){M.fragmentTracker.backtrack(m,B),M.resetFragmentLoading(m);return}M._handleFragmentLoadComplete(B)}}).catch(function(B){M.warn(B),M.resetFragmentLoading(m)})},o.flushMainBuffer=function(m,O,P){if(P===void 0&&(P=null),!!(m-O)){var M={startOffset:m,endOffset:O,type:P};this.fragLoadError=0,this.hls.trigger(L.Events.BUFFER_FLUSHING,M)}},o._loadInitSegment=function(m){var O=this;this._doFragLoad(m).then(function(P){if(!P||O.fragContextChanged(m)||!O.levels)throw new Error("init load aborted");return P}).then(function(P){var M=O.hls,F=P.payload,B=m.decryptdata;if(F&&F.byteLength>0&&B&&B.key&&B.iv&&B.method==="AES-128"){var C=self.performance.now();return O.decrypter.webCryptoDecrypt(new Uint8Array(F),B.key.buffer,B.iv.buffer).then(function(U){var w=self.performance.now();return M.trigger(L.Events.FRAG_DECRYPTED,{frag:m,payload:U,stats:{tstart:C,tdecrypt:w}}),P.payload=U,P})}return P}).then(function(P){var M=O.fragCurrent,F=O.hls,B=O.levels;if(!B)throw new Error("init load aborted, missing levels");var C=B[m.level].details;console.assert(C,"Level details are defined when init segment is loaded");var U=m.stats;O.state=d.IDLE,O.fragLoadError=0,m.data=new Uint8Array(P.payload),U.parsing.start=U.buffering.start=self.performance.now(),U.parsing.end=U.buffering.end=self.performance.now(),P.frag===M&&F.trigger(L.Events.FRAG_BUFFERED,{stats:U,frag:M,part:null,id:m.type}),O.tick()}).catch(function(P){O.warn(P),O.resetFragmentLoading(m)})},o.fragContextChanged=function(m){var O=this.fragCurrent;return!m||!O||m.level!==O.level||m.sn!==O.sn||m.urlId!==O.urlId},o.fragBufferedComplete=function(m,O){var P=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+m.type+" sn: "+m.sn+(O?" part: "+O.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+m.level+" "+e.default.toString(b.BufferHelper.getBuffered(P))),this.state=d.IDLE,this.tick()},o._handleFragmentLoadComplete=function(m){var O=this.transmuxer;if(!!O){var P=m.frag,M=m.part,F=m.partsLoaded,B=!F||F.length===0||F.some(function(U){return!U}),C=new g.ChunkMetadata(P.level,P.sn,P.stats.chunkCount+1,0,M?M.index:-1,!B);O.flush(C)}},o._handleFragmentLoadProgress=function(m){},o._doFragLoad=function(m,O,P,M){var F=this;if(P===void 0&&(P=null),!this.levels)throw new Error("frag load aborted, missing levels");if(P=Math.max(m.start,P||0),this.config.lowLatencyMode&&O){var B=O.partList;if(B&&M){P>m.end&&O.fragmentHint&&(m=O.fragmentHint);var C=this.getNextPart(B,m,P);if(C>-1){var U=B[C];return this.log("Loading part sn: "+m.sn+" p: "+U.index+" cc: "+m.cc+" of playlist ["+O.startSN+"-"+O.endSN+"] parts [0-"+C+"-"+(B.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+m.level+", target: "+parseFloat(P.toFixed(3))),this.nextLoadPosition=U.start+U.duration,this.state=d.FRAG_LOADING,this.hls.trigger(L.Events.FRAG_LOADING,{frag:m,part:B[C],targetBufferTime:P}),this.doFragPartsLoad(m,B,C,M).catch(function(w){return F.handleFragLoadError(w)})}else if(!m.url||this.loadedEndOfParts(B,P))return Promise.resolve(null)}}return this.log("Loading fragment "+m.sn+" cc: "+m.cc+" "+(O?"of ["+O.startSN+"-"+O.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+m.level+", target: "+parseFloat(P.toFixed(3))),Object(R.isFiniteNumber)(m.sn)&&!this.bitrateTest&&(this.nextLoadPosition=m.start+m.duration),this.state=d.FRAG_LOADING,this.hls.trigger(L.Events.FRAG_LOADING,{frag:m,targetBufferTime:P}),this.fragmentLoader.load(m,M).catch(function(w){return F.handleFragLoadError(w)})},o.doFragPartsLoad=function(m,O,P,M){var F=this;return new Promise(function(B,C){var U=[],w=function k(j){var K=O[j];F.fragmentLoader.loadPart(m,K,M).then(function(G){U[K.index]=G;var Y=G.part;F.hls.trigger(L.Events.FRAG_LOADED,G);var V=O[j+1];if(V&&V.fragment===m)k(j+1);else return B({frag:m,part:Y,partsLoaded:U})}).catch(C)};w(P)})},o.handleFragLoadError=function(m){var O=m.data;return O&&O.details===_.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(O.frag,O.part):this.hls.trigger(L.Events.ERROR,O),null},o._handleTransmuxerFlush=function(m){var O=this.getCurrentContext(m);if(!O||this.state!==d.PARSING){this.fragCurrent||(this.state=d.IDLE);return}var P=O.frag,M=O.part,F=O.level,B=self.performance.now();P.stats.parsing.end=B,M&&(M.stats.parsing.end=B),this.updateLevelTiming(P,M,F,m.partial)},o.getCurrentContext=function(m){var O=this.levels,P=m.level,M=m.sn,F=m.part;if(!O||!O[P])return this.warn("Levels object was unset while buffering fragment "+M+" of level "+P+". The current chunk will not be buffered."),null;var B=O[P],C=F>-1?Object(v.getPartWith)(B,M,F):null,U=C?C.fragment:Object(v.getFragmentWithSN)(B,M,this.fragCurrent);return U?{frag:U,part:C,level:B}:null},o.bufferFragmentData=function(m,O,P,M){if(!(!m||this.state!==d.PARSING)){var F=m.data1,B=m.data2,C=F;if(F&&B&&(C=Object(A.appendUint8Array)(F,B)),!(!C||!C.length)){var U={type:m.type,frag:O,part:P,chunkMeta:M,parent:O.type,data:C};this.hls.trigger(L.Events.BUFFER_APPENDING,U),m.dropped&&m.independent&&!P&&this.flushBufferGap(O)}}},o.flushBufferGap=function(m){var O=this.media;if(!!O){if(!b.BufferHelper.isBuffered(O,O.currentTime)){this.flushMainBuffer(0,m.start);return}var P=O.currentTime,M=b.BufferHelper.bufferInfo(O,P,0),F=m.duration,B=Math.min(this.config.maxFragLookUpTolerance*2,F*.25),C=Math.max(Math.min(m.start-B,M.end-B),P+B);m.start-C>B&&this.flushMainBuffer(C,m.start)}},o.getFwdBufferInfo=function(m,O){var P=this.config,M=this.getLoadPosition();if(!Object(R.isFiniteNumber)(M))return null;var F=b.BufferHelper.bufferInfo(m,M,P.maxBufferHole);if(F.len===0&&F.nextStart!==void 0){var B=this.fragmentTracker.getBufferedFrag(M,O);if(B&&F.nextStart<B.end)return b.BufferHelper.bufferInfo(m,M,Math.max(F.nextStart,P.maxBufferHole))}return F},o.getMaxBufferLength=function(m){var O=this.config,P;return m?P=Math.max(8*O.maxBufferSize/m,O.maxBufferLength):P=O.maxBufferLength,Math.min(P,O.maxMaxBufferLength)},o.reduceMaxBufferLength=function(m){var O=this.config,P=m||O.maxBufferLength;return O.maxMaxBufferLength>=P?(O.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+O.maxMaxBufferLength+"s"),!0):!1},o.getNextFragment=function(m,O){var P,M,F=O.fragments,B=F.length;if(!B)return null;var C=this.config,U=F[0].start,w;if(O.live){var k=C.initialLiveManifestSize;if(B<k)return this.warn("Not enough fragments to start playback (have: "+B+", need: "+k+")"),null;!O.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(w=this.getInitialLiveFragment(O,F),this.startPosition=w?this.hls.liveSyncPosition||w.start:m)}else m<=U&&(w=F[0]);if(!w){var j=C.lowLatencyMode?O.partEnd:O.fragmentEnd;w=this.getFragmentAtPosition(m,j,O)}return(P=w)!==null&&P!==void 0&&P.initSegment&&!((M=w)!==null&&M!==void 0&&M.initSegment.data)&&!this.bitrateTest&&(w=w.initSegment),w},o.getNextPart=function(m,O,P){for(var M=-1,F=!1,B=!0,C=0,U=m.length;C<U;C++){var w=m[C];if(B=B&&!w.independent,M>-1&&P<w.start)break;var k=w.loaded;!k&&(F||w.independent||B)&&w.fragment===O&&(M=C),F=k}return M},o.loadedEndOfParts=function(m,O){var P=m[m.length-1];return P&&O>P.start&&P.loaded},o.getInitialLiveFragment=function(m,O){var P=this.fragPrevious,M=null;if(P){if(m.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+P.programDateTime),M=Object(S.findFragmentByPDT)(O,P.endProgramDateTime,this.config.maxFragLookUpTolerance)),!M){var F=P.sn+1;if(F>=m.startSN&&F<=m.endSN){var B=O[F-m.startSN];P.cc===B.cc&&(M=B,this.log("Live playlist, switching playlist, load frag with next SN: "+M.sn))}M||(M=Object(S.findFragWithCC)(O,P.cc),M&&this.log("Live playlist, switching playlist, load frag with same CC: "+M.sn))}}else{var C=this.hls.liveSyncPosition;C!==null&&(M=this.getFragmentAtPosition(C,this.bitrateTest?m.fragmentEnd:m.edge,m))}return M},o.getFragmentAtPosition=function(m,O,P){var M=this.config,F=this.fragPrevious,B=P.fragments,C=P.endSN,U=P.fragmentHint,w=M.maxFragLookUpTolerance,k=!!(M.lowLatencyMode&&P.partList&&U);k&&U&&!this.bitrateTest&&(B=B.concat(U),C=U.sn);var j;if(m<O){var K=m>O-w?0:w;j=Object(S.findFragmentByPTS)(F,B,m,K)}else j=B[B.length-1];if(j){var G=j.sn-P.startSN,Y=F&&j.level===F.level,V=B[G+1],Z=this.fragmentTracker.getState(j);if(Z===x.FragmentState.BACKTRACKED){j=null;for(var z=G;B[z]&&this.fragmentTracker.getState(B[z])===x.FragmentState.BACKTRACKED;)F?j=B[z--]:j=B[--z];j||(j=V)}else F&&j.sn===F.sn&&!k&&Y&&(j.sn<C&&this.fragmentTracker.getState(V)!==x.FragmentState.OK?(this.log("SN "+j.sn+" just loaded, load next one: "+V.sn),j=V):j=null)}return j},o.synchronizeToLiveEdge=function(m){var O=this.config,P=this.media;if(!!P){var M=this.hls.liveSyncPosition,F=P.currentTime,B=m.fragments[0].start,C=m.edge,U=F>=B-O.maxFragLookUpTolerance&&F<=C;if(M!==null&&P.duration>M&&(F<M||!U)){var w=O.liveMaxLatencyDuration!==void 0?O.liveMaxLatencyDuration:O.liveMaxLatencyDurationCount*m.targetduration;(!U&&P.readyState<4||F<C-w)&&(this.loadedmetadata||(this.nextLoadPosition=M),P.readyState&&(this.warn("Playback: "+F.toFixed(3)+" is located too far from the end of live sliding playlist: "+C+", reset currentTime to : "+M.toFixed(3)),P.currentTime=M))}}},o.alignPlaylists=function(m,O){var P=this.levels,M=this.levelLastLoaded,F=this.fragPrevious,B=M!==null?P[M]:null,C=m.fragments.length;if(!C)return this.warn("No fragments in live playlist"),0;var U=m.fragments[0].start,w=!O,k=m.alignedSliding&&Object(R.isFiniteNumber)(U);if(w||!k&&!U){Object(D.alignStream)(F,B,m);var j=m.fragments[0].start;return this.log("Live playlist sliding: "+j.toFixed(2)+" start-sn: "+(O?O.startSN:"na")+"->"+m.startSN+" prev-sn: "+(F?F.sn:"na")+" fragments: "+C),j}return U},o.waitForCdnTuneIn=function(m){var O=3;return m.live&&m.canBlockReload&&m.tuneInGoal>Math.max(m.partHoldBack,m.partTarget*O)},o.setStartPosition=function(m,O){var P=this.startPosition;if(P<O&&(P=-1),P===-1||this.lastCurrentTime===-1){var M=m.startTimeOffset;Object(R.isFiniteNumber)(M)?(P=O+M,M<0&&(P+=m.totalduration),P=Math.min(Math.max(O,P),O+m.totalduration),this.log("Start time offset "+M+" found in playlist, adjust startPosition to "+P),this.startPosition=P):m.live?P=this.hls.liveSyncPosition||O:this.startPosition=P=0,this.lastCurrentTime=P}this.nextLoadPosition=P},o.getLoadPosition=function(){var m=this.media,O=0;return this.loadedmetadata&&m?O=m.currentTime:this.nextLoadPosition&&(O=this.nextLoadPosition),O},o.handleFragLoadAborted=function(m,O){this.transmuxer&&m.sn!=="initSegment"&&m.stats.aborted&&(this.warn("Fragment "+m.sn+(O?" part"+O.index:"")+" of level "+m.level+" was aborted"),this.resetFragmentLoading(m))},o.resetFragmentLoading=function(m){(!this.fragCurrent||!this.fragContextChanged(m))&&(this.state=d.IDLE)},o.onFragmentOrKeyLoadError=function(m,O){if(!O.fatal){var P=O.frag;if(!(!P||P.type!==m)){var M=this.fragCurrent;console.assert(M&&P.sn===M.sn&&P.level===M.level&&P.urlId===M.urlId,"Frag load error must match current frag to retry");var F=this.config;if(this.fragLoadError+1<=F.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(P.level))return;var B=Math.min(Math.pow(2,this.fragLoadError)*F.fragLoadingRetryDelay,F.fragLoadingMaxRetryTimeout);this.warn("Fragment "+P.sn+" of "+m+" "+P.level+" failed to load, retrying in "+B+"ms"),this.retryDate=self.performance.now()+B,this.fragLoadError++,this.state=d.FRAG_LOADING_WAITING_RETRY}else O.levelRetry?(m===i.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=d.IDLE):(T.logger.error(O.details+" reaches max retry, redispatch as fatal ..."),O.fatal=!0,this.hls.stopLoad(),this.state=d.ERROR)}}},o.afterBufferFlushed=function(m,O,P){if(!!m){var M=b.BufferHelper.getBuffered(m);this.fragmentTracker.detectEvictedFragments(O,M,P),this.state===d.ENDED&&this.resetLoadingState()}},o.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=d.IDLE},o.resetLiveStartWhenNotLoaded=function(m){if(!this.loadedmetadata){this.startFragRequested=!1;var O=this.levels?this.levels[m].details:null;if(O!=null&&O.live)return this.startPosition=-1,this.setStartPosition(O,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},o.updateLevelTiming=function(m,O,P,M){var F=this,B=P.details;console.assert(!!B,"level.details must be defined");var C=Object.keys(m.elementaryStreams).reduce(function(U,w){var k=m.elementaryStreams[w];if(k){var j=k.endPTS-k.startPTS;if(j<=0)return F.warn("Could not parse fragment "+m.sn+" "+w+" duration reliably ("+j+") resetting transmuxer to fallback to playlist timing"),F.resetTransmuxer(),U||!1;var K=M?0:Object(v.updateFragPTSDTS)(B,m,k.startPTS,k.endPTS,k.startDTS,k.endDTS);return F.hls.trigger(L.Events.LEVEL_PTS_UPDATED,{details:B,level:P,drift:K,type:w,frag:m,start:k.startPTS,end:k.endPTS}),!0}return U},!1);C?(this.state=d.PARSED,this.hls.trigger(L.Events.FRAG_PARSED,{frag:m,part:O})):this.resetLoadingState()},o.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},r(l,[{key:"state",get:function(){return this._state},set:function(m){var O=this._state;O!==m&&(this._state=m,this.log(O+"->"+m))}}]),l}(y.default)},"./src/controller/buffer-controller.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"default",function(){return S});var R=c("./src/polyfills/number.ts"),y=c("./src/events.ts"),x=c("./src/utils/logger.ts"),b=c("./src/errors.ts"),T=c("./src/utils/buffer-helper.ts"),L=c("./src/utils/mediasource-helper.ts"),_=c("./src/loader/fragment.ts"),g=c("./src/controller/buffer-operation-queue.ts"),A=Object(L.getMediaSource)(),D=/([ha]vc.)(?:\.[^.,]+)+/,S=function(){function v(s){var e=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var i=e.hls,t=e.media,r=e.mediaSource;x.logger.log("[buffer-controller]: Media source opened"),t&&(e.updateMediaElementDuration(),i.trigger(y.Events.MEDIA_ATTACHED,{media:t})),r&&r.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){x.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){x.logger.log("[buffer-controller]: Media source ended")},this.hls=s,this._initSourceBuffer(),this.registerListeners()}var p=v.prototype;return p.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},p.destroy=function(){this.unregisterListeners(),this.details=null},p.registerListeners=function(){var e=this.hls;e.on(y.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(y.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.Events.BUFFER_RESET,this.onBufferReset,this),e.on(y.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(y.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(y.Events.BUFFER_EOS,this.onBufferEos,this),e.on(y.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(y.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(y.Events.FRAG_PARSED,this.onFragParsed,this),e.on(y.Events.FRAG_CHANGED,this.onFragChanged,this)},p.unregisterListeners=function(){var e=this.hls;e.off(y.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(y.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.Events.BUFFER_RESET,this.onBufferReset,this),e.off(y.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(y.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(y.Events.BUFFER_EOS,this.onBufferEos,this),e.off(y.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(y.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(y.Events.FRAG_PARSED,this.onFragParsed,this),e.off(y.Events.FRAG_CHANGED,this.onFragChanged,this)},p._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new g.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},p.onManifestParsed=function(e,i){var t=2;(i.audio&&!i.video||!i.altAudio)&&(t=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=t,this.details=null,x.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},p.onMediaAttaching=function(e,i){var t=this.media=i.media;if(t&&A){var r=this.mediaSource=new A;r.addEventListener("sourceopen",this._onMediaSourceOpen),r.addEventListener("sourceended",this._onMediaSourceEnded),r.addEventListener("sourceclose",this._onMediaSourceClose),t.src=self.URL.createObjectURL(r),this._objectUrl=t.src}},p.onMediaDetaching=function(){var e=this.media,i=this.mediaSource,t=this._objectUrl;if(i){if(x.logger.log("[buffer-controller]: media source detaching"),i.readyState==="open")try{i.endOfStream()}catch(r){x.logger.warn("[buffer-controller]: onMediaDetaching: "+r.message+" while calling endOfStream")}this.onBufferReset(),i.removeEventListener("sourceopen",this._onMediaSourceOpen),i.removeEventListener("sourceended",this._onMediaSourceEnded),i.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(t&&self.URL.revokeObjectURL(t),e.src===t?(e.removeAttribute("src"),e.load()):x.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(y.Events.MEDIA_DETACHED,void 0)},p.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(i){var t=e.sourceBuffer[i];try{t&&(e.removeBufferListeners(i),e.mediaSource&&e.mediaSource.removeSourceBuffer(t),e.sourceBuffer[i]=void 0)}catch(r){x.logger.warn("[buffer-controller]: Failed to reset the "+i+" buffer",r)}}),this._initSourceBuffer()},p.onBufferCodecs=function(e,i){var t=this,r=this.getSourceBufferTypes().length;Object.keys(i).forEach(function(a){if(r){var n=t.tracks[a];if(n&&typeof n.buffer.changeType=="function"){var h=i[a],d=h.codec,u=h.levelCodec,f=h.container,l=(n.levelCodec||n.codec).replace(D,"$1"),o=(u||d).replace(D,"$1");if(l!==o){var E=f+";codecs="+(u||d);t.appendChangeType(a,E)}}}else t.pendingTracks[a]=i[a]}),!r&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},p.appendChangeType=function(e,i){var t=this,r=this.operationQueue,a={execute:function(){var h=t.sourceBuffer[e];h&&(x.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+i),h.changeType(i)),r.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(h){x.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",h)}};r.append(a,e)},p.onBufferAppending=function(e,i){var t=this,r=this.hls,a=this.operationQueue,n=this.tracks,h=i.data,d=i.type,u=i.frag,f=i.part,l=i.chunkMeta,o=l.buffering[d],E=self.performance.now();o.start=E;var m=u.stats.buffering,O=f?f.stats.buffering:null;m.start===0&&(m.start=E),O&&O.start===0&&(O.start=E);var P=n.audio,M=d==="audio"&&l.id===1&&(P==null?void 0:P.container)==="audio/mpeg",F={execute:function(){if(o.executeStart=self.performance.now(),M){var C=t.sourceBuffer[d];if(C){var U=u.start-C.timestampOffset;Math.abs(U)>=.1&&(x.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+u.start+" (delta: "+U+") sn: "+u.sn+")"),C.timestampOffset=u.start)}}t.appendExecutor(h,d)},onStart:function(){},onComplete:function(){var C=self.performance.now();o.executeEnd=o.end=C,m.first===0&&(m.first=C),O&&O.first===0&&(O.first=C);var U=t.sourceBuffer,w={};for(var k in U)w[k]=T.BufferHelper.getBuffered(U[k]);t.appendError=0,t.hls.trigger(y.Events.BUFFER_APPENDED,{type:d,frag:u,part:f,chunkMeta:l,parent:u.type,timeRanges:w})},onError:function(C){x.logger.error("[buffer-controller]: Error encountered while trying to append to the "+d+" SourceBuffer",C);var U={type:b.ErrorTypes.MEDIA_ERROR,parent:u.type,details:b.ErrorDetails.BUFFER_APPEND_ERROR,err:C,fatal:!1};C.code===DOMException.QUOTA_EXCEEDED_ERR?U.details=b.ErrorDetails.BUFFER_FULL_ERROR:(t.appendError++,U.details=b.ErrorDetails.BUFFER_APPEND_ERROR,t.appendError>r.config.appendErrorMaxRetry&&(x.logger.error("[buffer-controller]: Failed "+r.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),U.fatal=!0)),r.trigger(y.Events.ERROR,U)}};a.append(F,d)},p.onBufferFlushing=function(e,i){var t=this,r=this.operationQueue,a=function(h){return{execute:t.removeExecutor.bind(t,h,i.startOffset,i.endOffset),onStart:function(){},onComplete:function(){t.hls.trigger(y.Events.BUFFER_FLUSHED,{type:h})},onError:function(u){x.logger.warn("[buffer-controller]: Failed to remove from "+h+" SourceBuffer",u)}}};i.type?r.append(a(i.type),i.type):this.getSourceBufferTypes().forEach(function(n){r.append(a(n),n)})},p.onFragParsed=function(e,i){var t=this,r=i.frag,a=i.part,n=[],h=a?a.elementaryStreams:r.elementaryStreams;h[_.ElementaryStreamTypes.AUDIOVIDEO]?n.push("audiovideo"):(h[_.ElementaryStreamTypes.AUDIO]&&n.push("audio"),h[_.ElementaryStreamTypes.VIDEO]&&n.push("video"));var d=function(){var f=self.performance.now();r.stats.buffering.end=f,a&&(a.stats.buffering.end=f);var l=a?a.stats:r.stats;t.hls.trigger(y.Events.FRAG_BUFFERED,{frag:r,part:a,stats:l,id:r.type})};n.length===0&&x.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+r.type+" level: "+r.level+" sn: "+r.sn),this.blockBuffers(d,n)},p.onFragChanged=function(e,i){this.flushBackBuffer()},p.onBufferEos=function(e,i){var t=this,r=this.getSourceBufferTypes().reduce(function(a,n){var h=t.sourceBuffer[n];return(!i.type||i.type===n)&&h&&!h.ended&&(h.ended=!0,x.logger.log("[buffer-controller]: "+n+" sourceBuffer now EOS")),a&&!!(!h||h.ended)},!0);r&&this.blockBuffers(function(){var a=t.mediaSource;!a||a.readyState!=="open"||a.endOfStream()})},p.onLevelUpdated=function(e,i){var t=i.details;!t.fragments.length||(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},p.flushBackBuffer=function(){var e=this.hls,i=this.details,t=this.media,r=this.sourceBuffer;if(!(!t||i===null)){var a=this.getSourceBufferTypes();if(!!a.length){var n=i.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(!(!Object(R.isFiniteNumber)(n)||n<0)){var h=t.currentTime,d=i.levelTargetDuration,u=Math.max(n,d),f=Math.floor(h/d)*d-u;a.forEach(function(l){var o=r[l];if(o){var E=T.BufferHelper.getBuffered(o);E.length>0&&f>E.start(0)&&(e.trigger(y.Events.BACK_BUFFER_REACHED,{bufferEnd:f}),i.live&&e.trigger(y.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:f}),e.trigger(y.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:f,type:l}))}})}}}},p.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var e=this.details,i=this.hls,t=this.media,r=this.mediaSource,a=e.fragments[0].start+e.totalduration,n=t.duration,h=Object(R.isFiniteNumber)(r.duration)?r.duration:0;e.live&&i.config.liveDurationInfinity?(x.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),r.duration=1/0,this.updateSeekableRange(e)):(a>h&&a>n||!Object(R.isFiniteNumber)(n))&&(x.logger.log("[buffer-controller]: Updating Media Source duration to "+a.toFixed(3)),r.duration=a)}},p.updateSeekableRange=function(e){var i=this.mediaSource,t=e.fragments,r=t.length;if(r&&e.live&&i!==null&&i!==void 0&&i.setLiveSeekableRange){var a=Math.max(0,t[0].start),n=Math.max(a,a+e.totalduration);i.setLiveSeekableRange(a,n)}},p.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,i=this.operationQueue,t=this.pendingTracks,r=Object.keys(t).length;if(r&&!e||r===2){this.createSourceBuffers(t),this.pendingTracks={};var a=this.getSourceBufferTypes();if(a.length===0){this.hls.trigger(y.Events.ERROR,{type:b.ErrorTypes.MEDIA_ERROR,details:b.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}a.forEach(function(n){i.executeNext(n)})}},p.createSourceBuffers=function(e){var i=this.sourceBuffer,t=this.mediaSource;if(!t)throw Error("createSourceBuffers called when mediaSource was null");var r=0;for(var a in e)if(!i[a]){var n=e[a];if(!n)throw Error("source buffer exists for track "+a+", however track does not");var h=n.levelCodec||n.codec,d=n.container+";codecs="+h;x.logger.log("[buffer-controller]: creating sourceBuffer("+d+")");try{var u=i[a]=t.addSourceBuffer(d),f=a;this.addBufferListener(f,"updatestart",this._onSBUpdateStart),this.addBufferListener(f,"updateend",this._onSBUpdateEnd),this.addBufferListener(f,"error",this._onSBUpdateError),this.tracks[a]={buffer:u,codec:h,container:n.container,levelCodec:n.levelCodec,id:n.id},r++}catch(l){x.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+l.message),this.hls.trigger(y.Events.ERROR,{type:b.ErrorTypes.MEDIA_ERROR,details:b.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:l,mimeType:d})}}r&&this.hls.trigger(y.Events.BUFFER_CREATED,{tracks:this.tracks})},p._onSBUpdateStart=function(e){var i=this.operationQueue,t=i.current(e);t.onStart()},p._onSBUpdateEnd=function(e){var i=this.operationQueue,t=i.current(e);t.onComplete(),i.shiftAndExecuteNext(e)},p._onSBUpdateError=function(e,i){x.logger.error("[buffer-controller]: "+e+" SourceBuffer error",i),this.hls.trigger(y.Events.ERROR,{type:b.ErrorTypes.MEDIA_ERROR,details:b.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var t=this.operationQueue.current(e);t&&t.onError(i)},p.removeExecutor=function(e,i,t){var r=this.media,a=this.mediaSource,n=this.operationQueue,h=this.sourceBuffer,d=h[e];if(!r||!a||!d){x.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),n.shiftAndExecuteNext(e);return}var u=Object(R.isFiniteNumber)(r.duration)?r.duration:1/0,f=Object(R.isFiniteNumber)(a.duration)?a.duration:1/0,l=Math.max(0,i),o=Math.min(t,u,f);o>l?(x.logger.log("[buffer-controller]: Removing ["+l+","+o+"] from the "+e+" SourceBuffer"),console.assert(!d.updating,e+" sourceBuffer must not be updating"),d.remove(l,o)):n.shiftAndExecuteNext(e)},p.appendExecutor=function(e,i){var t=this.operationQueue,r=this.sourceBuffer,a=r[i];if(!a){x.logger.warn("[buffer-controller]: Attempting to append to the "+i+" SourceBuffer, but it does not exist"),t.shiftAndExecuteNext(i);return}a.ended=!1,console.assert(!a.updating,i+" sourceBuffer must not be updating"),a.appendBuffer(e)},p.blockBuffers=function(e,i){var t=this;if(i===void 0&&(i=this.getSourceBufferTypes()),!i.length){x.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(e);return}var r=this.operationQueue,a=i.map(function(n){return r.appendBlocker(n)});Promise.all(a).then(function(){e(),i.forEach(function(n){var h=t.sourceBuffer[n];(!h||!h.updating)&&r.shiftAndExecuteNext(n)})})},p.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},p.addBufferListener=function(e,i,t){var r=this.sourceBuffer[e];if(!!r){var a=t.bind(this,e);this.listeners[e].push({event:i,listener:a}),r.addEventListener(i,a)}},p.removeBufferListeners=function(e){var i=this.sourceBuffer[e];!i||this.listeners[e].forEach(function(t){i.removeEventListener(t.event,t.listener)})},v}()},"./src/controller/buffer-operation-queue.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"default",function(){return y});var R=c("./src/utils/logger.ts"),y=function(){function x(T){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=T}var b=x.prototype;return b.append=function(L,_){var g=this.queues[_];g.push(L),g.length===1&&this.buffers[_]&&this.executeNext(_)},b.insertAbort=function(L,_){var g=this.queues[_];g.unshift(L),this.executeNext(_)},b.appendBlocker=function(L){var _,g=new Promise(function(D){_=D}),A={execute:_,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(A,L),g},b.executeNext=function(L){var _=this.buffers,g=this.queues,A=_[L],D=g[L];if(D.length){var S=D[0];try{S.execute()}catch(v){R.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),S.onError(v),(!A||!A.updating)&&(D.shift(),this.executeNext(L))}}},b.shiftAndExecuteNext=function(L){this.queues[L].shift(),this.executeNext(L)},b.current=function(L){return this.queues[L][0]},x}()},"./src/controller/cap-level-controller.ts":function(N,I,c){"use strict";c.r(I);var R=c("./src/events.ts");function y(T,L){for(var _=0;_<L.length;_++){var g=L[_];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(T,g.key,g)}}function x(T,L,_){return L&&y(T.prototype,L),_&&y(T,_),T}var b=function(){function T(_){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=_,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var L=T.prototype;return L.setStreamController=function(g){this.streamController=g},L.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},L.registerListeners=function(){var g=this.hls;g.on(R.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),g.on(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),g.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),g.on(R.Events.BUFFER_CODECS,this.onBufferCodecs,this),g.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},L.unregisterListener=function(){var g=this.hls;g.off(R.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),g.off(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),g.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),g.off(R.Events.BUFFER_CODECS,this.onBufferCodecs,this),g.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},L.onFpsDropLevelCapping=function(g,A){T.isLevelAllowed(A.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(A.droppedLevel)},L.onMediaAttaching=function(g,A){this.media=A.media instanceof HTMLVideoElement?A.media:null},L.onManifestParsed=function(g,A){var D=this.hls;this.restrictedLevels=[],this.firstLevel=A.firstLevel,D.config.capLevelToPlayerSize&&A.video&&this.startCapping()},L.onBufferCodecs=function(g,A){var D=this.hls;D.config.capLevelToPlayerSize&&A.video&&this.startCapping()},L.onMediaDetaching=function(){this.stopCapping()},L.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var g=this.hls.levels;if(g.length){var A=this.hls;A.autoLevelCapping=this.getMaxLevel(g.length-1),A.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=A.autoLevelCapping}}},L.getMaxLevel=function(g){var A=this,D=this.hls.levels;if(!D.length)return-1;var S=D.filter(function(v,p){return T.isLevelAllowed(p,A.restrictedLevels)&&p<=g});return this.clientRect=null,T.getMaxLevelByMediaSize(S,this.mediaWidth,this.mediaHeight)},L.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},L.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},L.getDimensions=function(){if(this.clientRect)return this.clientRect;var g=this.media,A={width:0,height:0};if(g){var D=g.getBoundingClientRect();A.width=D.width,A.height=D.height,!A.width&&!A.height&&(A.width=D.right-D.left||g.width||0,A.height=D.bottom-D.top||g.height||0)}return this.clientRect=A,A},T.isLevelAllowed=function(g,A){return A===void 0&&(A=[]),A.indexOf(g)===-1},T.getMaxLevelByMediaSize=function(g,A,D){if(!g||!g.length)return-1;for(var S=function(i,t){return t?i.width!==t.width||i.height!==t.height:!0},v=g.length-1,p=0;p<g.length;p+=1){var s=g[p];if((s.width>=A||s.height>=D)&&S(s,g[p+1])){v=p;break}}return v},x(T,[{key:"mediaWidth",get:function(){return this.getDimensions().width*T.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*T.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var g=1;try{g=self.devicePixelRatio}catch{}return g}}]),T}();I.default=b},"./src/controller/cmcd-controller.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"default",function(){return S});var R=c("./src/events.ts"),y=c("./src/types/cmcd.ts"),x=c("./src/utils/buffer-helper.ts"),b=c("./src/utils/logger.ts");function T(v,p){for(var s=0;s<p.length;s++){var e=p[s];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(v,e.key,e)}}function L(v,p,s){return p&&T(v.prototype,p),s&&T(v,s),v}function _(v,p){var s=typeof Symbol!="undefined"&&v[Symbol.iterator]||v["@@iterator"];if(s)return(s=s.call(v)).next.bind(s);if(Array.isArray(v)||(s=g(v))||p&&v&&typeof v.length=="number"){s&&(v=s);var e=0;return function(){return e>=v.length?{done:!0}:{done:!1,value:v[e++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
12
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function g(v,p){if(!!v){if(typeof v=="string")return A(v,p);var s=Object.prototype.toString.call(v).slice(8,-1);if(s==="Object"&&v.constructor&&(s=v.constructor.name),s==="Map"||s==="Set")return Array.from(v);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return A(v,p)}}function A(v,p){(p==null||p>v.length)&&(p=v.length);for(var s=0,e=new Array(p);s<p;s++)e[s]=v[s];return e}function D(){return D=Object.assign||function(v){for(var p=1;p<arguments.length;p++){var s=arguments[p];for(var e in s)Object.prototype.hasOwnProperty.call(s,e)&&(v[e]=s[e])}return v},D.apply(this,arguments)}var S=function(){function v(s){var e=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){e.initialized&&(e.starved=!0),e.buffering=!0},this.onPlaying=function(){e.initialized||(e.initialized=!0),e.buffering=!1},this.applyPlaylistData=function(r){try{e.apply(r,{ot:y.CMCDObjectType.MANIFEST,su:!e.initialized})}catch(a){b.logger.warn("Could not generate manifest CMCD data.",a)}},this.applyFragmentData=function(r){try{var a=r.frag,n=e.hls.levels[a.level],h=e.getObjectType(a),d={d:a.duration*1e3,ot:h};(h===y.CMCDObjectType.VIDEO||h===y.CMCDObjectType.AUDIO||h==y.CMCDObjectType.MUXED)&&(d.br=n.bitrate/1e3,d.tb=e.getTopBandwidth(h)/1e3,d.bl=e.getBufferLength(h)),e.apply(r,d)}catch(u){b.logger.warn("Could not generate segment CMCD data.",u)}},this.hls=s;var i=this.config=s.config,t=i.cmcd;t!=null&&(i.pLoader=this.createPlaylistLoader(),i.fLoader=this.createFragmentLoader(),this.sid=t.sessionId||v.uuid(),this.cid=t.contentId,this.useHeaders=t.useHeaders===!0,this.registerListeners())}var p=v.prototype;return p.registerListeners=function(){var e=this.hls;e.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(R.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(R.Events.BUFFER_CREATED,this.onBufferCreated,this)},p.unregisterListeners=function(){var e=this.hls;e.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(R.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(R.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},p.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},p.onMediaAttached=function(e,i){this.media=i.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},p.onMediaDetached=function(){!this.media||(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},p.onBufferCreated=function(e,i){var t,r;this.audioBuffer=(t=i.tracks.audio)===null||t===void 0?void 0:t.buffer,this.videoBuffer=(r=i.tracks.video)===null||r===void 0?void 0:r.buffer},p.createData=function(){var e;return{v:y.CMCDVersion,sf:y.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)===null||e===void 0?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},p.apply=function(e,i){i===void 0&&(i={}),D(i,this.createData());var t=i.ot===y.CMCDObjectType.INIT||i.ot===y.CMCDObjectType.VIDEO||i.ot===y.CMCDObjectType.MUXED;if(this.starved&&t&&(i.bs=!0,i.su=!0,this.starved=!1),i.su==null&&(i.su=this.buffering),this.useHeaders){var r=v.toHeaders(i);if(!Object.keys(r).length)return;e.headers||(e.headers={}),D(e.headers,r)}else{var a=v.toQuery(i);if(!a)return;e.url=v.appendQueryToUri(e.url,a)}},p.getObjectType=function(e){var i=e.type;if(i==="subtitle")return y.CMCDObjectType.TIMED_TEXT;if(e.sn==="initSegment")return y.CMCDObjectType.INIT;if(i==="audio")return y.CMCDObjectType.AUDIO;if(i==="main")return this.hls.audioTracks.length?y.CMCDObjectType.VIDEO:y.CMCDObjectType.MUXED},p.getTopBandwidth=function(e){var i=0,t,r=this.hls;if(e===y.CMCDObjectType.AUDIO)t=r.audioTracks;else{var a=r.maxAutoLevel,n=a>-1?a+1:r.levels.length;t=r.levels.slice(0,n)}for(var h=_(t),d;!(d=h()).done;){var u=d.value;u.bitrate>i&&(i=u.bitrate)}return i>0?i:NaN},p.getBufferLength=function(e){var i=this.hls.media,t=e===y.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!t||!i)return NaN;var r=x.BufferHelper.bufferInfo(t,i.currentTime,this.config.maxBufferHole);return r.len*1e3},p.createPlaylistLoader=function(){var e=this.config.pLoader,i=this.applyPlaylistData,t=e||this.config.loader;return function(){function r(n){this.loader=void 0,this.loader=new t(n)}var a=r.prototype;return a.destroy=function(){this.loader.destroy()},a.abort=function(){this.loader.abort()},a.load=function(h,d,u){i(h),this.loader.load(h,d,u)},L(r,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),r}()},p.createFragmentLoader=function(){var e=this.config.fLoader,i=this.applyFragmentData,t=e||this.config.loader;return function(){function r(n){this.loader=void 0,this.loader=new t(n)}var a=r.prototype;return a.destroy=function(){this.loader.destroy()},a.abort=function(){this.loader.abort()},a.load=function(h,d,u){i(h),this.loader.load(h,d,u)},L(r,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),r}()},v.uuid=function(){var e=URL.createObjectURL(new Blob),i=e.toString();return URL.revokeObjectURL(e),i.substr(i.lastIndexOf("/")+1)},v.serialize=function(e){for(var i=[],t=function(M){return!Number.isNaN(M)&&M!=null&&M!==""&&M!==!1},r=function(M){return Math.round(M)},a=function(M){return r(M/100)*100},n=function(M){return encodeURIComponent(M)},h={br:r,d:r,bl:a,dl:a,mtp:a,nor:n,rtp:a,tb:r},d=Object.keys(e||{}).sort(),u=_(d),f;!(f=u()).done;){var l=f.value,o=e[l];if(!!t(o)&&!(l==="v"&&o===1)&&!(l=="pr"&&o===1)){var E=h[l];E&&(o=E(o));var m=typeof o,O=void 0;l==="ot"||l==="sf"||l==="st"?O=l+"="+o:m==="boolean"?O=l:m==="number"?O=l+"="+o:O=l+"="+JSON.stringify(o),i.push(O)}}return i.join(",")},v.toHeaders=function(e){for(var i=Object.keys(e),t={},r=["Object","Request","Session","Status"],a=[{},{},{},{}],n={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},h=0,d=i;h<d.length;h++){var u=d[h],f=n[u]!=null?n[u]:1;a[f][u]=e[u]}for(var l=0;l<a.length;l++){var o=v.serialize(a[l]);o&&(t["CMCD-"+r[l]]=o)}return t},v.toQuery=function(e){return"CMCD="+encodeURIComponent(v.serialize(e))},v.appendQueryToUri=function(e,i){if(!i)return e;var t=e.includes("?")?"&":"?";return""+e+t+i},v}()},"./src/controller/eme-controller.ts":function(N,I,c){"use strict";c.r(I);var R=c("./src/events.ts"),y=c("./src/errors.ts"),x=c("./src/utils/logger.ts"),b=c("./src/utils/mediakeys-helper.ts");function T(S,v){for(var p=0;p<v.length;p++){var s=v[p];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(S,s.key,s)}}function L(S,v,p){return v&&T(S.prototype,v),p&&T(S,p),S}var _=3,g=function(v,p,s){var e={audioCapabilities:[],videoCapabilities:[]};return v.forEach(function(i){e.audioCapabilities.push({contentType:'audio/mp4; codecs="'+i+'"',robustness:s.audioRobustness||""})}),p.forEach(function(i){e.videoCapabilities.push({contentType:'video/mp4; codecs="'+i+'"',robustness:s.videoRobustness||""})}),[e]},A=function(v,p,s,e){switch(v){case b.KeySystems.WIDEVINE:return g(p,s,e);default:throw new Error("Unknown key-system: "+v)}},D=function(){function S(p){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=p,this._config=p.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var v=S.prototype;return v.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},v._registerListeners=function(){this.hls.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(R.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this)},v._unregisterListeners=function(){this.hls.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(R.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this)},v.getLicenseServerUrl=function(s){switch(s){case b.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+s+'"')},v._attemptKeySystemAccess=function(s,e,i){var t=this,r=A(s,e,i,this._drmSystemOptions);x.logger.log("Requesting encrypted media key-system access");var a=this.requestMediaKeySystemAccess(s,r);this.mediaKeysPromise=a.then(function(n){return t._onMediaKeySystemAccessObtained(s,n)}),a.catch(function(n){x.logger.error('Failed to obtain key-system "'+s+'" access:',n)})},v._onMediaKeySystemAccessObtained=function(s,e){var i=this;x.logger.log('Access for key-system "'+s+'" obtained');var t={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:e,mediaKeySystemDomain:s};this._mediaKeysList.push(t);var r=Promise.resolve().then(function(){return e.createMediaKeys()}).then(function(a){return t.mediaKeys=a,x.logger.log('Media-keys created for key-system "'+s+'"'),i._onMediaKeysCreated(),a});return r.catch(function(a){x.logger.error("Failed to create media-keys:",a)}),r},v._onMediaKeysCreated=function(){var s=this;this._mediaKeysList.forEach(function(e){e.mediaKeysSession||(e.mediaKeysSession=e.mediaKeys.createSession(),s._onNewMediaKeySession(e.mediaKeysSession))})},v._onNewMediaKeySession=function(s){var e=this;x.logger.log("New key-system session "+s.sessionId),s.addEventListener("message",function(i){e._onKeySessionMessage(s,i.message)},!1)},v._onKeySessionMessage=function(s,e){x.logger.log("Got EME message event, creating license request"),this._requestLicense(e,function(i){x.logger.log("Received license data (length: "+(i&&i.byteLength)+"), updating key-session"),s.update(i)})},v.onMediaEncrypted=function(s){var e=this;if(x.logger.log('Media is encrypted using "'+s.initDataType+'" init data type'),!this.mediaKeysPromise){x.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(R.Events.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var i=function(r){!e._media||(e._attemptSetMediaKeys(r),e._generateRequestWithPreferredKeySession(s.initDataType,s.initData))};this.mediaKeysPromise.then(i).catch(i)},v._attemptSetMediaKeys=function(s){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var e=this._mediaKeysList[0];if(!e||!e.mediaKeys){x.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(R.Events.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}x.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}},v._generateRequestWithPreferredKeySession=function(s,e){var i=this,t=this._mediaKeysList[0];if(!t){x.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(R.Events.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(t.mediaKeysSessionInitialized){x.logger.warn("Key-Session already initialized but requested again");return}var r=t.mediaKeysSession;if(!r){x.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(R.Events.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!e){x.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(R.Events.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}x.logger.log('Generating key-session request for "'+s+'" init data type'),t.mediaKeysSessionInitialized=!0,r.generateRequest(s,e).then(function(){x.logger.debug("Key-session generation succeeded")}).catch(function(a){x.logger.error("Error generating key-session request:",a),i.hls.trigger(R.Events.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},v._createLicenseXhr=function(s,e,i){var t=new XMLHttpRequest;t.responseType="arraybuffer",t.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,t,s,e,i);var r=this._licenseXhrSetup;if(r)try{r.call(this.hls,t,s),r=void 0}catch(a){x.logger.error(a)}try{t.readyState||t.open("POST",s,!0),r&&r.call(this.hls,t,s)}catch(a){throw new Error("issue setting up KeySystem license XHR "+a)}return t},v._onLicenseRequestReadyStageChange=function(s,e,i,t){switch(s.readyState){case 4:if(s.status===200){this._requestLicenseFailureCount=0,x.logger.log("License request succeeded");var r=s.response,a=this._licenseResponseCallback;if(a)try{r=a.call(this.hls,s,e)}catch(h){x.logger.error(h)}t(r)}else{if(x.logger.error("License Request XHR failed ("+e+"). Status: "+s.status+" ("+s.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>_){this.hls.trigger(R.Events.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var n=_-this._requestLicenseFailureCount+1;x.logger.warn("Retrying license request, "+n+" attempts left"),this._requestLicense(i,t)}break}},v._generateLicenseRequestChallenge=function(s,e){switch(s.mediaKeySystemDomain){case b.KeySystems.WIDEVINE:return e}throw new Error("unsupported key-system: "+s.mediaKeySystemDomain)},v._requestLicense=function(s,e){x.logger.log("Requesting content license for key-system");var i=this._mediaKeysList[0];if(!i){x.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(R.Events.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var t=this.getLicenseServerUrl(i.mediaKeySystemDomain),r=this._createLicenseXhr(t,s,e);x.logger.log("Sending license request to URL: "+t);var a=this._generateLicenseRequestChallenge(i,s);r.send(a)}catch(n){x.logger.error("Failure requesting DRM license: "+n),this.hls.trigger(R.Events.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},v.onMediaAttached=function(s,e){if(!!this._emeEnabled){var i=e.media;this._media=i,i.addEventListener("encrypted",this._onMediaEncrypted)}},v.onMediaDetached=function(){var s=this._media,e=this._mediaKeysList;!s||(s.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(e.map(function(i){if(i.mediaKeysSession)return i.mediaKeysSession.close().catch(function(){})})).then(function(){return s.setMediaKeys(null)}).catch(function(){}))},v.onManifestParsed=function(s,e){if(!!this._emeEnabled){var i=e.levels.map(function(r){return r.audioCodec}).filter(function(r){return!!r}),t=e.levels.map(function(r){return r.videoCodec}).filter(function(r){return!!r});this._attemptKeySystemAccess(b.KeySystems.WIDEVINE,i,t)}},L(S,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),S}();I.default=D},"./src/controller/fps-controller.ts":function(N,I,c){"use strict";c.r(I);var R=c("./src/events.ts"),y=c("./src/utils/logger.ts"),x=function(){function b(L){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=L,this.registerListeners()}var T=b.prototype;return T.setStreamController=function(_){this.streamController=_},T.registerListeners=function(){this.hls.on(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},T.unregisterListeners=function(){this.hls.off(R.Events.MEDIA_ATTACHING,this.onMediaAttaching)},T.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},T.onMediaAttaching=function(_,g){var A=this.hls.config;if(A.capLevelOnFPSDrop){var D=g.media instanceof self.HTMLVideoElement?g.media:null;this.media=D,D&&typeof D.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),A.fpsDroppedMonitoringPeriod)}},T.checkFPS=function(_,g,A){var D=performance.now();if(g){if(this.lastTime){var S=D-this.lastTime,v=A-this.lastDroppedFrames,p=g-this.lastDecodedFrames,s=1e3*v/S,e=this.hls;if(e.trigger(R.Events.FPS_DROP,{currentDropped:v,currentDecoded:p,totalDroppedFrames:A}),s>0&&v>e.config.fpsDroppedMonitoringThreshold*p){var i=e.currentLevel;y.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+i),i>0&&(e.autoLevelCapping===-1||e.autoLevelCapping>=i)&&(i=i-1,e.trigger(R.Events.FPS_DROP_LEVEL_CAPPING,{level:i,droppedLevel:e.currentLevel}),e.autoLevelCapping=i,this.streamController.nextLevelSwitch())}}this.lastTime=D,this.lastDroppedFrames=A,this.lastDecodedFrames=g}},T.checkFPSInterval=function(){var _=this.media;if(_)if(this.isVideoPlaybackQualityAvailable){var g=_.getVideoPlaybackQuality();this.checkFPS(_,g.totalVideoFrames,g.droppedVideoFrames)}else this.checkFPS(_,_.webkitDecodedFrameCount,_.webkitDroppedFrameCount)},b}();I.default=x},"./src/controller/fragment-finders.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"findFragmentByPDT",function(){return x}),c.d(I,"findFragmentByPTS",function(){return b}),c.d(I,"fragmentWithinToleranceTest",function(){return T}),c.d(I,"pdtWithinToleranceTest",function(){return L}),c.d(I,"findFragWithCC",function(){return _});var R=c("./src/polyfills/number.ts"),y=c("./src/utils/binary-search.ts");function x(g,A,D){if(A===null||!Array.isArray(g)||!g.length||!Object(R.isFiniteNumber)(A))return null;var S=g[0].programDateTime;if(A<(S||0))return null;var v=g[g.length-1].endProgramDateTime;if(A>=(v||0))return null;D=D||0;for(var p=0;p<g.length;++p){var s=g[p];if(L(A,D,s))return s}return null}function b(g,A,D,S){D===void 0&&(D=0),S===void 0&&(S=0);var v=null;if(g?v=A[g.sn-A[0].sn+1]||null:D===0&&A[0].start===0&&(v=A[0]),v&&T(D,S,v)===0)return v;var p=y.default.search(A,T.bind(null,D,S));return p||v}function T(g,A,D){g===void 0&&(g=0),A===void 0&&(A=0);var S=Math.min(A,D.duration+(D.deltaPTS?D.deltaPTS:0));return D.start+D.duration-S<=g?1:D.start-S>g&&D.start?-1:0}function L(g,A,D){var S=Math.min(A,D.duration+(D.deltaPTS?D.deltaPTS:0))*1e3,v=D.endProgramDateTime||0;return v-S>g}function _(g,A){return y.default.search(g,function(D){return D.cc<A?1:D.cc>A?-1:0})}},"./src/controller/fragment-tracker.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"FragmentState",function(){return x}),c.d(I,"FragmentTracker",function(){return b});var R=c("./src/events.ts"),y=c("./src/types/loader.ts"),x;(function(_){_.NOT_LOADED="NOT_LOADED",_.BACKTRACKED="BACKTRACKED",_.APPENDING="APPENDING",_.PARTIAL="PARTIAL",_.OK="OK"})(x||(x={}));var b=function(){function _(A){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=A,this._registerListeners()}var g=_.prototype;return g._registerListeners=function(){var D=this.hls;D.on(R.Events.BUFFER_APPENDED,this.onBufferAppended,this),D.on(R.Events.FRAG_BUFFERED,this.onFragBuffered,this),D.on(R.Events.FRAG_LOADED,this.onFragLoaded,this)},g._unregisterListeners=function(){var D=this.hls;D.off(R.Events.BUFFER_APPENDED,this.onBufferAppended,this),D.off(R.Events.FRAG_BUFFERED,this.onFragBuffered,this),D.off(R.Events.FRAG_LOADED,this.onFragLoaded,this)},g.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},g.getAppendedFrag=function(D,S){if(S===y.PlaylistLevelType.MAIN){var v=this.activeFragment,p=this.activeParts;if(!v)return null;if(p)for(var s=p.length;s--;){var e=p[s],i=e?e.end:v.appendedPTS;if(e.start<=D&&i!==void 0&&D<=i)return s>9&&(this.activeParts=p.slice(s-9)),e}else if(v.start<=D&&v.appendedPTS!==void 0&&D<=v.appendedPTS)return v}return this.getBufferedFrag(D,S)},g.getBufferedFrag=function(D,S){for(var v=this.fragments,p=Object.keys(v),s=p.length;s--;){var e=v[p[s]];if((e==null?void 0:e.body.type)===S&&e.buffered){var i=e.body;if(i.start<=D&&D<=i.end)return i}}return null},g.detectEvictedFragments=function(D,S,v){var p=this;Object.keys(this.fragments).forEach(function(s){var e=p.fragments[s];if(!!e){if(!e.buffered){e.body.type===v&&p.removeFragment(e.body);return}var i=e.range[D];!i||i.time.some(function(t){var r=!p.isTimeBuffered(t.startPTS,t.endPTS,S);return r&&p.removeFragment(e.body),r})}})},g.detectPartialFragments=function(D){var S=this,v=this.timeRanges,p=D.frag,s=D.part;if(!(!v||p.sn==="initSegment")){var e=L(p),i=this.fragments[e];!i||(Object.keys(v).forEach(function(t){var r=p.elementaryStreams[t];if(!!r){var a=v[t],n=s!==null||r.partial===!0;i.range[t]=S.getBufferedTimes(p,s,n,a)}}),i.backtrack=i.loaded=null,Object.keys(i.range).length?i.buffered=!0:this.removeFragment(i.body))}},g.fragBuffered=function(D){var S=L(D),v=this.fragments[S];v&&(v.backtrack=v.loaded=null,v.buffered=!0)},g.getBufferedTimes=function(D,S,v,p){for(var s={time:[],partial:v},e=S?S.start:D.start,i=S?S.end:D.end,t=D.minEndPTS||i,r=D.maxStartPTS||e,a=0;a<p.length;a++){var n=p.start(a)-this.bufferPadding,h=p.end(a)+this.bufferPadding;if(r>=n&&t<=h){s.time.push({startPTS:Math.max(e,p.start(a)),endPTS:Math.min(i,p.end(a))});break}else if(e<h&&i>n)s.partial=!0,s.time.push({startPTS:Math.max(e,p.start(a)),endPTS:Math.min(i,p.end(a))});else if(i<=n)break}return s},g.getPartialFragment=function(D){var S=null,v,p,s,e=0,i=this.bufferPadding,t=this.fragments;return Object.keys(t).forEach(function(r){var a=t[r];!a||T(a)&&(p=a.body.start-i,s=a.body.end+i,D>=p&&D<=s&&(v=Math.min(D-p,s-D),e<=v&&(S=a.body,e=v)))}),S},g.getState=function(D){var S=L(D),v=this.fragments[S];return v?v.buffered?T(v)?x.PARTIAL:x.OK:v.backtrack?x.BACKTRACKED:x.APPENDING:x.NOT_LOADED},g.backtrack=function(D,S){var v=L(D),p=this.fragments[v];if(!p||p.backtrack)return null;var s=p.backtrack=S||p.loaded;return p.loaded=null,s},g.getBacktrackData=function(D){var S=L(D),v=this.fragments[S];if(v){var p,s=v.backtrack;if(s!=null&&(p=s.payload)!==null&&p!==void 0&&p.byteLength)return s;this.removeFragment(D)}return null},g.isTimeBuffered=function(D,S,v){for(var p,s,e=0;e<v.length;e++){if(p=v.start(e)-this.bufferPadding,s=v.end(e)+this.bufferPadding,D>=p&&S<=s)return!0;if(S<=p)return!1}return!1},g.onFragLoaded=function(D,S){var v=S.frag,p=S.part;if(!(v.sn==="initSegment"||v.bitrateTest||p)){var s=L(v);this.fragments[s]={body:v,loaded:S,backtrack:null,buffered:!1,range:Object.create(null)}}},g.onBufferAppended=function(D,S){var v=this,p=S.frag,s=S.part,e=S.timeRanges;if(p.type===y.PlaylistLevelType.MAIN)if(this.activeFragment=p,s){var i=this.activeParts;i||(this.activeParts=i=[]),i.push(s)}else this.activeParts=null;this.timeRanges=e,Object.keys(e).forEach(function(t){var r=e[t];if(v.detectEvictedFragments(t,r),!s)for(var a=0;a<r.length;a++)p.appendedPTS=Math.max(r.end(a),p.appendedPTS||0)})},g.onFragBuffered=function(D,S){this.detectPartialFragments(S)},g.hasFragment=function(D){var S=L(D);return!!this.fragments[S]},g.removeFragmentsInRange=function(D,S,v){var p=this;Object.keys(this.fragments).forEach(function(s){var e=p.fragments[s];if(!!e&&e.buffered){var i=e.body;i.type===v&&i.start<S&&i.end>D&&p.removeFragment(i)}})},g.removeFragment=function(D){var S=L(D);D.stats.loaded=0,D.clearElementaryStreamInfo(),delete this.fragments[S]},g.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},_}();function T(_){var g,A;return _.buffered&&(((g=_.range.video)===null||g===void 0?void 0:g.partial)||((A=_.range.audio)===null||A===void 0?void 0:A.partial))}function L(_){return _.type+"_"+_.level+"_"+_.urlId+"_"+_.sn}},"./src/controller/gap-controller.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"STALL_MINIMUM_DURATION_MS",function(){return T}),c.d(I,"MAX_START_GAP_JUMP",function(){return L}),c.d(I,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return _}),c.d(I,"SKIP_BUFFER_RANGE_START",function(){return g}),c.d(I,"default",function(){return A});var R=c("./src/utils/buffer-helper.ts"),y=c("./src/errors.ts"),x=c("./src/events.ts"),b=c("./src/utils/logger.ts"),T=250,L=2,_=.1,g=.05,A=function(){function D(v,p,s,e){this.config=void 0,this.media=void 0,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=v,this.media=p,this.fragmentTracker=s,this.hls=e}var S=D.prototype;return S.destroy=function(){this.hls=this.fragmentTracker=this.media=null},S.poll=function(p){var s=this.config,e=this.media,i=this.stalled,t=e.currentTime,r=e.seeking,a=this.seeking&&!r,n=!this.seeking&&r;if(this.seeking=r,t!==p){if(this.moved=!0,i!==null){if(this.stallReported){var h=self.performance.now()-i;b.logger.warn("playback not stuck anymore @"+t+", after "+Math.round(h)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((n||a)&&(this.stalled=null),!(e.paused||e.ended||e.playbackRate===0||!R.BufferHelper.getBuffered(e).length)){var d=R.BufferHelper.bufferInfo(e,t,0),u=d.len>0,f=d.nextStart||0;if(!(!u&&!f)){if(r){var l=d.len>L,o=!f||f-t>L&&!this.fragmentTracker.getPartialFragment(t);if(l||o)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var E,m=Math.max(f,d.start||0)-t,O=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,P=O==null||(E=O.details)===null||E===void 0?void 0:E.live,M=P?O.details.targetduration*2:L;if(m>0&&m<=M){this._trySkipBufferHole(null);return}}var F=self.performance.now();if(i===null){this.stalled=F;return}var B=F-i;!r&&B>=T&&this._reportStall(d.len);var C=R.BufferHelper.bufferInfo(e,t,s.maxBufferHole);this._tryFixBufferStall(C,B)}}},S._tryFixBufferStall=function(p,s){var e=this.config,i=this.fragmentTracker,t=this.media,r=t.currentTime,a=i.getPartialFragment(r);if(a){var n=this._trySkipBufferHole(a);if(n)return}p.len>e.maxBufferHole&&s>e.highBufferWatchdogPeriod*1e3&&(b.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},S._reportStall=function(p){var s=this.hls,e=this.media,i=this.stallReported;i||(this.stallReported=!0,b.logger.warn("Playback stalling at @"+e.currentTime+" due to low buffer (buffer="+p+")"),s.trigger(x.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:p}))},S._trySkipBufferHole=function(p){for(var s=this.config,e=this.hls,i=this.media,t=i.currentTime,r=0,a=R.BufferHelper.getBuffered(i),n=0;n<a.length;n++){var h=a.start(n);if(t+s.maxBufferHole>=r&&t<h){var d=Math.max(h+g,i.currentTime+_);return b.logger.warn("skipping hole, adjusting currentTime from "+t+" to "+d),this.moved=!0,this.stalled=null,i.currentTime=d,p&&e.trigger(x.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+t+" to "+d,frag:p}),d}r=a.end(n)}return 0},S._tryNudgeBuffer=function(){var p=this.config,s=this.hls,e=this.media,i=e.currentTime,t=(this.nudgeRetry||0)+1;if(this.nudgeRetry=t,t<p.nudgeMaxRetry){var r=i+t*p.nudgeOffset;b.logger.warn("Nudging 'currentTime' from "+i+" to "+r),e.currentTime=r,s.trigger(x.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else b.logger.error("Playhead still not moving while enough data buffered @"+i+" after "+p.nudgeMaxRetry+" nudges"),s.trigger(x.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},D}()},"./src/controller/id3-track-controller.ts":function(N,I,c){"use strict";c.r(I);var R=c("./src/events.ts"),y=c("./src/utils/texttrack-utils.ts"),x=c("./src/demux/id3.ts"),b=.25,T=function(){function L(g){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=g,this._registerListeners()}var _=L.prototype;return _.destroy=function(){this._unregisterListeners()},_._registerListeners=function(){var A=this.hls;A.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),A.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),A.on(R.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),A.on(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},_._unregisterListeners=function(){var A=this.hls;A.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),A.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),A.off(R.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),A.off(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},_.onMediaAttached=function(A,D){this.media=D.media},_.onMediaDetaching=function(){!this.id3Track||(Object(y.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null)},_.getID3Track=function(A){if(!!this.media){for(var D=0;D<A.length;D++){var S=A[D];if(S.kind==="metadata"&&S.label==="id3")return Object(y.sendAddTrackEvent)(S,this.media),S}return this.media.addTextTrack("metadata","id3")}},_.onFragParsingMetadata=function(A,D){if(!!this.media){var S=D.frag,v=D.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var p=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,s=0;s<v.length;s++){var e=x.getID3Frames(v[s].data);if(e){var i=v[s].pts,t=s<v.length-1?v[s+1].pts:S.end,r=t-i;r<=0&&(t=i+b);for(var a=0;a<e.length;a++){var n=e[a];if(!x.isTimeStampFrame(n)){var h=new p(i,t,"");h.value=n,this.id3Track.addCue(h)}}}}}},_.onBufferFlushing=function(A,D){var S=D.startOffset,v=D.endOffset,p=D.type;if(!p||p==="audio"){var s=this.id3Track;s&&Object(y.removeCuesInRange)(s,S,v)}},L}();I.default=T},"./src/controller/latency-controller.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"default",function(){return L});var R=c("./src/errors.ts"),y=c("./src/events.ts"),x=c("./src/utils/logger.ts");function b(_,g){for(var A=0;A<g.length;A++){var D=g[A];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(_,D.key,D)}}function T(_,g,A){return g&&b(_.prototype,g),A&&b(_,A),_}var L=function(){function _(A){var D=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return D.timeupdate()},this.hls=A,this.config=A.config,this.registerListeners()}var g=_.prototype;return g.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},g.registerListeners=function(){this.hls.on(y.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(y.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(y.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(y.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(y.Events.ERROR,this.onError,this)},g.unregisterListeners=function(){this.hls.off(y.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(y.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(y.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(y.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(y.Events.ERROR,this.onError)},g.onMediaAttached=function(D,S){this.media=S.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},g.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},g.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},g.onLevelUpdated=function(D,S){var v=S.details;this.levelDetails=v,v.advanced&&this.timeupdate(),!v.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},g.onError=function(D,S){S.details===R.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,x.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},g.timeupdate=function(){var D=this.media,S=this.levelDetails;if(!(!D||!S)){this.currentTime=D.currentTime;var v=this.computeLatency();if(v!==null){this._latency=v;var p=this.config,s=p.lowLatencyMode,e=p.maxLiveSyncPlaybackRate;if(!(!s||e===1)){var i=this.targetLatency;if(i!==null){var t=v-i,r=Math.min(this.maxLatency,i+S.targetduration),a=t<r;if(S.live&&a&&t>.05&&this.forwardBufferLength>1){var n=Math.min(2,Math.max(1,e)),h=Math.round(2/(1+Math.exp(-.75*t-this.edgeStalled))*20)/20;D.playbackRate=Math.min(n,Math.max(1,h))}else D.playbackRate!==1&&D.playbackRate!==0&&(D.playbackRate=1)}}}}},g.estimateLiveEdge=function(){var D=this.levelDetails;return D===null?null:D.edge+D.age},g.computeLatency=function(){var D=this.estimateLiveEdge();return D===null?null:D-this.currentTime},T(_,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var D=this.config,S=this.levelDetails;return D.liveMaxLatencyDuration!==void 0?D.liveMaxLatencyDuration:S?D.liveMaxLatencyDurationCount*S.targetduration:0}},{key:"targetLatency",get:function(){var D=this.levelDetails;if(D===null)return null;var S=D.holdBack,v=D.partHoldBack,p=D.targetduration,s=this.config,e=s.liveSyncDuration,i=s.liveSyncDurationCount,t=s.lowLatencyMode,r=this.hls.userConfig,a=t&&v||S;(r.liveSyncDuration||r.liveSyncDurationCount||a===0)&&(a=e!==void 0?e:i*p);var n=p,h=1;return a+Math.min(this.stallCount*h,n)}},{key:"liveSyncPosition",get:function(){var D=this.estimateLiveEdge(),S=this.targetLatency,v=this.levelDetails;if(D===null||S===null||v===null)return null;var p=v.edge,s=D-S-this.edgeStalled,e=p-v.totalduration,i=p-(this.config.lowLatencyMode&&v.partTarget||v.targetduration);return Math.min(Math.max(e,s),i)}},{key:"drift",get:function(){var D=this.levelDetails;return D===null?1:D.drift}},{key:"edgeStalled",get:function(){var D=this.levelDetails;if(D===null)return 0;var S=(this.config.lowLatencyMode&&D.partTarget||D.targetduration)*3;return Math.max(D.age-S,0)}},{key:"forwardBufferLength",get:function(){var D=this.media,S=this.levelDetails;if(!D||!S)return 0;var v=D.buffered.length;return v?D.buffered.end(v-1):S.edge-this.currentTime}}]),_}()},"./src/controller/level-controller.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"default",function(){return s});var R=c("./src/types/level.ts"),y=c("./src/events.ts"),x=c("./src/errors.ts"),b=c("./src/utils/codecs.ts"),T=c("./src/controller/level-helper.ts"),L=c("./src/controller/base-playlist-controller.ts"),_=c("./src/types/loader.ts");function g(){return g=Object.assign||function(e){for(var i=1;i<arguments.length;i++){var t=arguments[i];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},g.apply(this,arguments)}function A(e,i){for(var t=0;t<i.length;t++){var r=i[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function D(e,i,t){return i&&A(e.prototype,i),t&&A(e,t),e}function S(e,i){e.prototype=Object.create(i.prototype),e.prototype.constructor=e,v(e,i)}function v(e,i){return v=Object.setPrototypeOf||function(r,a){return r.__proto__=a,r},v(e,i)}var p=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),s=function(e){S(i,e);function i(r){var a;return a=e.call(this,r,"[level-controller]")||this,a._levels=[],a._firstLevel=-1,a._startLevel=void 0,a.currentLevelIndex=-1,a.manualLevelIndex=-1,a.onParsedComplete=void 0,a._registerListeners(),a}var t=i.prototype;return t._registerListeners=function(){var a=this.hls;a.on(y.Events.MANIFEST_LOADED,this.onManifestLoaded,this),a.on(y.Events.LEVEL_LOADED,this.onLevelLoaded,this),a.on(y.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),a.on(y.Events.FRAG_LOADED,this.onFragLoaded,this),a.on(y.Events.ERROR,this.onError,this)},t._unregisterListeners=function(){var a=this.hls;a.off(y.Events.MANIFEST_LOADED,this.onManifestLoaded,this),a.off(y.Events.LEVEL_LOADED,this.onLevelLoaded,this),a.off(y.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),a.off(y.Events.FRAG_LOADED,this.onFragLoaded,this),a.off(y.Events.ERROR,this.onError,this)},t.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,e.prototype.destroy.call(this)},t.startLoad=function(){var a=this._levels;a.forEach(function(n){n.loadError=0}),e.prototype.startLoad.call(this)},t.onManifestLoaded=function(a,n){var h=[],d=[],u=[],f,l={},o,E=!1,m=!1,O=!1;if(n.levels.forEach(function(B){var C=B.attrs;E=E||!!(B.width&&B.height),m=m||!!B.videoCodec,O=O||!!B.audioCodec,p&&B.audioCodec&&B.audioCodec.indexOf("mp4a.40.34")!==-1&&(B.audioCodec=void 0);var U=B.bitrate+"-"+B.attrs.RESOLUTION+"-"+B.attrs.CODECS;o=l[U],o?o.url.push(B.url):(o=new R.Level(B),l[U]=o,h.push(o)),C&&(C.AUDIO&&Object(T.addGroupId)(o,"audio",C.AUDIO),C.SUBTITLES&&Object(T.addGroupId)(o,"text",C.SUBTITLES))}),(E||m)&&O&&(h=h.filter(function(B){var C=B.videoCodec,U=B.width,w=B.height;return!!C||!!(U&&w)})),h=h.filter(function(B){var C=B.audioCodec,U=B.videoCodec;return(!C||Object(b.isCodecSupportedInMp4)(C,"audio"))&&(!U||Object(b.isCodecSupportedInMp4)(U,"video"))}),n.audioTracks&&(d=n.audioTracks.filter(function(B){return!B.audioCodec||Object(b.isCodecSupportedInMp4)(B.audioCodec,"audio")}),Object(T.assignTrackIdsByGroup)(d)),n.subtitles&&(u=n.subtitles,Object(T.assignTrackIdsByGroup)(u)),h.length>0){f=h[0].bitrate,h.sort(function(B,C){return B.bitrate-C.bitrate}),this._levels=h;for(var P=0;P<h.length;P++)if(h[P].bitrate===f){this._firstLevel=P,this.log("manifest loaded, "+h.length+" level(s) found, first bitrate: "+f);break}var M=O&&!m,F={levels:h,audioTracks:d,subtitleTracks:u,firstLevel:this._firstLevel,stats:n.stats,audio:O,video:m,altAudio:!M&&d.some(function(B){return!!B.url})};this.hls.trigger(y.Events.MANIFEST_PARSED,F),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(y.Events.ERROR,{type:x.ErrorTypes.MEDIA_ERROR,details:x.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:n.url,reason:"no level with compatible codecs found in manifest"})},t.onError=function(a,n){if(e.prototype.onError.call(this,a,n),!n.fatal){var h=n.context,d=this._levels[this.currentLevelIndex];if(h&&(h.type===_.PlaylistContextType.AUDIO_TRACK&&d.audioGroupIds&&h.groupId===d.audioGroupIds[d.urlId]||h.type===_.PlaylistContextType.SUBTITLE_TRACK&&d.textGroupIds&&h.groupId===d.textGroupIds[d.urlId])){this.redundantFailover(this.currentLevelIndex);return}var u=!1,f=!0,l;switch(n.details){case x.ErrorDetails.FRAG_LOAD_ERROR:case x.ErrorDetails.FRAG_LOAD_TIMEOUT:case x.ErrorDetails.KEY_LOAD_ERROR:case x.ErrorDetails.KEY_LOAD_TIMEOUT:if(n.frag){var o=this._levels[n.frag.level];o?(o.fragmentError++,o.fragmentError>this.hls.config.fragLoadingMaxRetry&&(l=n.frag.level)):l=n.frag.level}break;case x.ErrorDetails.LEVEL_LOAD_ERROR:case x.ErrorDetails.LEVEL_LOAD_TIMEOUT:h&&(h.deliveryDirectives&&(f=!1),l=h.level),u=!0;break;case x.ErrorDetails.REMUX_ALLOC_ERROR:l=n.level,u=!0;break}l!==void 0&&this.recoverLevel(n,l,u,f)}},t.recoverLevel=function(a,n,h,d){var u=a.details,f=this._levels[n];if(f.loadError++,h){var l=this.retryLoadingOrFail(a);if(l)a.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(d){var o=f.url.length;if(o>1&&f.loadError<o)a.levelRetry=!0,this.redundantFailover(n);else if(this.manualLevelIndex===-1){var E=n===0?this._levels.length-1:n-1;this.currentLevelIndex!==E&&this._levels[E].loadError===0&&(this.warn(u+": switch to "+E),a.levelRetry=!0,this.hls.nextAutoLevel=E)}}},t.redundantFailover=function(a){var n=this._levels[a],h=n.url.length;if(h>1){var d=(n.urlId+1)%h;this.warn("Switching to redundant URL-id "+d),this._levels.forEach(function(u){u.urlId=d}),this.level=a}},t.onFragLoaded=function(a,n){var h=n.frag;if(h!==void 0&&h.type===_.PlaylistLevelType.MAIN){var d=this._levels[h.level];d!==void 0&&(d.fragmentError=0,d.loadError=0)}},t.onLevelLoaded=function(a,n){var h,d=n.level,u=n.details,f=this._levels[d];if(!f){var l;this.warn("Invalid level index "+d),(l=n.deliveryDirectives)!==null&&l!==void 0&&l.skip&&(u.deltaUpdateFailed=!0);return}d===this.currentLevelIndex?(f.fragmentError===0&&(f.loadError=0,this.retryCount=0),this.playlistLoaded(d,n,f.details)):(h=n.deliveryDirectives)!==null&&h!==void 0&&h.skip&&(u.deltaUpdateFailed=!0)},t.onAudioTrackSwitched=function(a,n){var h=this.hls.levels[this.currentLevelIndex];if(!!h&&h.audioGroupIds){for(var d=-1,u=this.hls.audioTracks[n.id].groupId,f=0;f<h.audioGroupIds.length;f++)if(h.audioGroupIds[f]===u){d=f;break}d!==h.urlId&&(h.urlId=d,this.startLoad())}},t.loadPlaylist=function(a){var n=this.currentLevelIndex,h=this._levels[n];if(this.canLoad&&h&&h.url.length>0){var d=h.urlId,u=h.url[d];if(a)try{u=a.addDirectives(u)}catch(f){this.warn("Could not construct new URL with HLS Delivery Directives: "+f)}this.log("Attempt loading level index "+n+(a?" at sn "+a.msn+" part "+a.part:"")+" with URL-id "+d+" "+u),this.clearTimer(),this.hls.trigger(y.Events.LEVEL_LOADING,{url:u,level:n,id:d,deliveryDirectives:a||null})}},t.removeLevel=function(a,n){var h=function(f,l){return l!==n},d=this._levels.filter(function(u,f){return f!==a?!0:u.url.length>1&&n!==void 0?(u.url=u.url.filter(h),u.audioGroupIds&&(u.audioGroupIds=u.audioGroupIds.filter(h)),u.textGroupIds&&(u.textGroupIds=u.textGroupIds.filter(h)),u.urlId=0,!0):!1}).map(function(u,f){var l=u.details;return l!=null&&l.fragments&&l.fragments.forEach(function(o){o.level=f}),u});this._levels=d,this.hls.trigger(y.Events.LEVELS_UPDATED,{levels:d})},D(i,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(a){var n,h=this._levels;if(h.length!==0&&!(this.currentLevelIndex===a&&(n=h[a])!==null&&n!==void 0&&n.details)){if(a<0||a>=h.length){var d=a<0;if(this.hls.trigger(y.Events.ERROR,{type:x.ErrorTypes.OTHER_ERROR,details:x.ErrorDetails.LEVEL_SWITCH_ERROR,level:a,fatal:d,reason:"invalid level idx"}),d)return;a=Math.min(a,h.length-1)}this.clearTimer();var u=this.currentLevelIndex,f=h[u],l=h[a];this.log("switching to level "+a+" from "+u),this.currentLevelIndex=a;var o=g({},l,{level:a,maxBitrate:l.maxBitrate,uri:l.uri,urlId:l.urlId});delete o._urlId,this.hls.trigger(y.Events.LEVEL_SWITCHING,o);var E=l.details;if(!E||E.live){var m=this.switchParams(l.uri,f==null?void 0:f.details);this.loadPlaylist(m)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(a){this.manualLevelIndex=a,this._startLevel===void 0&&(this._startLevel=a),a!==-1&&(this.level=a)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(a){this._firstLevel=a}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var a=this.hls.config.startLevel;return a!==void 0?a:this._firstLevel}else return this._startLevel},set:function(a){this._startLevel=a}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(a){this.level=a,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=a)}}]),i}(L.default)},"./src/controller/level-helper.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"addGroupId",function(){return x}),c.d(I,"assignTrackIdsByGroup",function(){return b}),c.d(I,"updatePTS",function(){return T}),c.d(I,"updateFragPTSDTS",function(){return _}),c.d(I,"mergeDetails",function(){return g}),c.d(I,"mapPartIntersection",function(){return A}),c.d(I,"mapFragmentIntersection",function(){return D}),c.d(I,"adjustSliding",function(){return S}),c.d(I,"addSliding",function(){return v}),c.d(I,"computeReloadInterval",function(){return p}),c.d(I,"getFragmentWithSN",function(){return s}),c.d(I,"getPartWith",function(){return e});var R=c("./src/polyfills/number.ts"),y=c("./src/utils/logger.ts");function x(i,t,r){switch(t){case"audio":i.audioGroupIds||(i.audioGroupIds=[]),i.audioGroupIds.push(r);break;case"text":i.textGroupIds||(i.textGroupIds=[]),i.textGroupIds.push(r);break}}function b(i){var t={};i.forEach(function(r){var a=r.groupId||"";r.id=t[a]=t[a]||0,t[a]++})}function T(i,t,r){var a=i[t],n=i[r];L(a,n)}function L(i,t){var r=t.startPTS;if(Object(R.isFiniteNumber)(r)){var a=0,n;t.sn>i.sn?(a=r-i.start,n=i):(a=i.start-r,n=t),n.duration!==a&&(n.duration=a)}else if(t.sn>i.sn){var h=i.cc===t.cc;h&&i.minEndPTS?t.start=i.start+(i.minEndPTS-i.start):t.start=i.start+i.duration}else t.start=Math.max(i.start-t.duration,0)}function _(i,t,r,a,n,h){var d=a-r;d<=0&&(y.logger.warn("Fragment should have a positive duration",t),a=r+t.duration,h=n+t.duration);var u=r,f=a,l=t.startPTS,o=t.endPTS;if(Object(R.isFiniteNumber)(l)){var E=Math.abs(l-r);Object(R.isFiniteNumber)(t.deltaPTS)?t.deltaPTS=Math.max(E,t.deltaPTS):t.deltaPTS=E,u=Math.max(r,l),r=Math.min(r,l),n=Math.min(n,t.startDTS),f=Math.min(a,o),a=Math.max(a,o),h=Math.max(h,t.endDTS)}t.duration=a-r;var m=r-t.start;t.appendedPTS=a,t.start=t.startPTS=r,t.maxStartPTS=u,t.startDTS=n,t.endPTS=a,t.minEndPTS=f,t.endDTS=h;var O=t.sn;if(!i||O<i.startSN||O>i.endSN)return 0;var P,M=O-i.startSN,F=i.fragments;for(F[M]=t,P=M;P>0;P--)L(F[P],F[P-1]);for(P=M;P<F.length-1;P++)L(F[P],F[P+1]);return i.fragmentHint&&L(F[F.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,m}function g(i,t){for(var r=null,a=i.fragments,n=a.length-1;n>=0;n--){var h=a[n].initSegment;if(h){r=h;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;var d=0,u;if(D(i,t,function(P,M){P.relurl&&(d=P.cc-M.cc),Object(R.isFiniteNumber)(P.startPTS)&&Object(R.isFiniteNumber)(P.endPTS)&&(M.start=M.startPTS=P.startPTS,M.startDTS=P.startDTS,M.appendedPTS=P.appendedPTS,M.maxStartPTS=P.maxStartPTS,M.endPTS=P.endPTS,M.endDTS=P.endDTS,M.minEndPTS=P.minEndPTS,M.duration=P.endPTS-P.startPTS,M.duration&&(u=M),t.PTSKnown=t.alignedSliding=!0),M.elementaryStreams=P.elementaryStreams,M.loader=P.loader,M.stats=P.stats,M.urlId=P.urlId,P.initSegment&&(M.initSegment=P.initSegment,r=P.initSegment)}),r){var f=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments;f.forEach(function(P){var M;(!P.initSegment||P.initSegment.relurl===((M=r)===null||M===void 0?void 0:M.relurl))&&(P.initSegment=r)})}if(t.skippedSegments&&(t.deltaUpdateFailed=t.fragments.some(function(P){return!P}),t.deltaUpdateFailed)){y.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var l=t.skippedSegments;l--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}var o=t.fragments;if(d){y.logger.warn("discontinuity sliding from playlist, take drift into account");for(var E=0;E<o.length;E++)o[E].cc+=d}t.skippedSegments&&(t.startCC=t.fragments[0].cc),A(i.partList,t.partList,function(P,M){M.elementaryStreams=P.elementaryStreams,M.stats=P.stats}),u?_(t,u,u.startPTS,u.endPTS,u.startDTS,u.endDTS):S(i,t),o.length&&(t.totalduration=t.edge-o[0].start),t.driftStartTime=i.driftStartTime,t.driftStart=i.driftStart;var m=t.advancedDateTime;if(t.advanced&&m){var O=t.edge;t.driftStart||(t.driftStartTime=m,t.driftStart=O),t.driftEndTime=m,t.driftEnd=O}else t.driftEndTime=i.driftEndTime,t.driftEnd=i.driftEnd,t.advancedDateTime=i.advancedDateTime}function A(i,t,r){if(i&&t)for(var a=0,n=0,h=i.length;n<=h;n++){var d=i[n],u=t[n+a];d&&u&&d.index===u.index&&d.fragment.sn===u.fragment.sn?r(d,u):a--}}function D(i,t,r){for(var a=t.skippedSegments,n=Math.max(i.startSN,t.startSN)-t.startSN,h=(i.fragmentHint?1:0)+(a?t.endSN:Math.min(i.endSN,t.endSN))-t.startSN,d=t.startSN-i.startSN,u=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,f=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,l=n;l<=h;l++){var o=f[d+l],E=u[l];a&&!E&&l<a&&(E=t.fragments[l]=o),o&&E&&r(o,E)}}function S(i,t){var r=t.startSN+t.skippedSegments-i.startSN,a=i.fragments;r<0||r>=a.length||v(t,a[r].start)}function v(i,t){if(t){for(var r=i.fragments,a=i.skippedSegments;a<r.length;a++)r[a].start+=t;i.fragmentHint&&(i.fragmentHint.start+=t)}}function p(i,t){var r=1e3*i.levelTargetDuration,a=r/2,n=i.age,h=n>0&&n<r*3,d=t.loading.end-t.loading.start,u,f=i.availabilityDelay;if(i.updated===!1)if(h){var l=333*i.misses;u=Math.max(Math.min(a,d*2),l),i.availabilityDelay=(i.availabilityDelay||0)+u}else u=a;else h?(f=Math.min(f||r/2,n),i.availabilityDelay=f,u=f+r-n):u=r-d;return Math.round(u)}function s(i,t,r){if(!i||!i.details)return null;var a=i.details,n=a.fragments[t-a.startSN];return n||(n=a.fragmentHint,n&&n.sn===t)?n:t<a.startSN&&r&&r.sn===t?r:null}function e(i,t,r){if(!i||!i.details)return null;var a=i.details.partList;if(a)for(var n=a.length;n--;){var h=a[n];if(h.index===r&&h.fragment.sn===t)return h}return null}},"./src/controller/stream-controller.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"default",function(){return a});var R=c("./src/polyfills/number.ts"),y=c("./src/controller/base-stream-controller.ts"),x=c("./src/is-supported.ts"),b=c("./src/events.ts"),T=c("./src/utils/buffer-helper.ts"),L=c("./src/controller/fragment-tracker.ts"),_=c("./src/types/loader.ts"),g=c("./src/loader/fragment.ts"),A=c("./src/demux/transmuxer-interface.ts"),D=c("./src/types/transmuxer.ts"),S=c("./src/controller/gap-controller.ts"),v=c("./src/errors.ts"),p=c("./src/utils/logger.ts");function s(n,h){for(var d=0;d<h.length;d++){var u=h[d];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(n,u.key,u)}}function e(n,h,d){return h&&s(n.prototype,h),d&&s(n,d),n}function i(n,h){n.prototype=Object.create(h.prototype),n.prototype.constructor=n,t(n,h)}function t(n,h){return t=Object.setPrototypeOf||function(u,f){return u.__proto__=f,u},t(n,h)}var r=100,a=function(n){i(h,n);function h(u,f){var l;return l=n.call(this,u,f,"[stream-controller]")||this,l.audioCodecSwap=!1,l.gapController=null,l.level=-1,l._forceStartLoad=!1,l.altAudio=!1,l.audioOnly=!1,l.fragPlaying=null,l.onvplaying=null,l.onvseeked=null,l.fragLastKbps=0,l.stalled=!1,l.couldBacktrack=!1,l.audioCodecSwitch=!1,l.videoBuffer=null,l._registerListeners(),l}var d=h.prototype;return d._registerListeners=function(){var f=this.hls;f.on(b.Events.MEDIA_ATTACHED,this.onMediaAttached,this),f.on(b.Events.MEDIA_DETACHING,this.onMediaDetaching,this),f.on(b.Events.MANIFEST_LOADING,this.onManifestLoading,this),f.on(b.Events.MANIFEST_PARSED,this.onManifestParsed,this),f.on(b.Events.LEVEL_LOADING,this.onLevelLoading,this),f.on(b.Events.LEVEL_LOADED,this.onLevelLoaded,this),f.on(b.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),f.on(b.Events.ERROR,this.onError,this),f.on(b.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),f.on(b.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),f.on(b.Events.BUFFER_CREATED,this.onBufferCreated,this),f.on(b.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),f.on(b.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),f.on(b.Events.FRAG_BUFFERED,this.onFragBuffered,this)},d._unregisterListeners=function(){var f=this.hls;f.off(b.Events.MEDIA_ATTACHED,this.onMediaAttached,this),f.off(b.Events.MEDIA_DETACHING,this.onMediaDetaching,this),f.off(b.Events.MANIFEST_LOADING,this.onManifestLoading,this),f.off(b.Events.MANIFEST_PARSED,this.onManifestParsed,this),f.off(b.Events.LEVEL_LOADED,this.onLevelLoaded,this),f.off(b.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),f.off(b.Events.ERROR,this.onError,this),f.off(b.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),f.off(b.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),f.off(b.Events.BUFFER_CREATED,this.onBufferCreated,this),f.off(b.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),f.off(b.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),f.off(b.Events.FRAG_BUFFERED,this.onFragBuffered,this)},d.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},d.startLoad=function(f){if(this.levels){var l=this.lastCurrentTime,o=this.hls;if(this.stopLoad(),this.setInterval(r),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var E=o.startLevel;E===-1&&(o.config.testBandwidth?(E=0,this.bitrateTest=!0):E=o.nextAutoLevel),this.level=o.nextLoadLevel=E,this.loadedmetadata=!1}l>0&&f===-1&&(this.log("Override startPosition with lastCurrentTime @"+l.toFixed(3)),f=l),this.state=y.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=f,this.tick()}else this._forceStartLoad=!0,this.state=y.State.STOPPED},d.stopLoad=function(){this._forceStartLoad=!1,n.prototype.stopLoad.call(this)},d.doTick=function(){switch(this.state){case y.State.IDLE:this.doTickIdle();break;case y.State.WAITING_LEVEL:{var f,l=this.levels,o=this.level,E=l==null||(f=l[o])===null||f===void 0?void 0:f.details;if(E&&(!E.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(E))break;this.state=y.State.IDLE;break}break}case y.State.FRAG_LOADING_WAITING_RETRY:{var m,O=self.performance.now(),P=this.retryDate;(!P||O>=P||(m=this.media)!==null&&m!==void 0&&m.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=y.State.IDLE)}break;default:break}this.onTickEnd()},d.onTickEnd=function(){n.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},d.doTickIdle=function(){var f,l,o=this.hls,E=this.levelLastLoaded,m=this.levels,O=this.media,P=o.config,M=o.nextLoadLevel;if(!(E===null||!O&&(this.startFragRequested||!P.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!m||!m[M])){var F=m[M];this.level=o.nextLoadLevel=M;var B=F.details;if(!B||this.state===y.State.WAITING_LEVEL||B.live&&this.levelLastLoaded!==M){this.state=y.State.WAITING_LEVEL;return}var C=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:O,_.PlaylistLevelType.MAIN);if(C!==null){var U=C.len,w=this.getMaxBufferLength(F.maxBitrate);if(!(U>=w)){if(this._streamEnded(C,B)){var k={};this.altAudio&&(k.type="video"),this.hls.trigger(b.Events.BUFFER_EOS,k),this.state=y.State.ENDED;return}var j=C.end,K=this.getNextFragment(j,B);if(this.couldBacktrack&&!this.fragPrevious&&K&&K.sn!=="initSegment"){var G=K.sn-B.startSN;G>1&&(K=B.fragments[G-1],this.fragmentTracker.removeFragment(K))}if(K&&this.fragmentTracker.getState(K)===L.FragmentState.OK&&this.nextLoadPosition>j){var Y=this.audioOnly&&!this.altAudio?g.ElementaryStreamTypes.AUDIO:g.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(O,Y,_.PlaylistLevelType.MAIN),K=this.getNextFragment(this.nextLoadPosition,B)}!K||(K.initSegment&&!K.initSegment.data&&!this.bitrateTest&&(K=K.initSegment),((f=K.decryptdata)===null||f===void 0?void 0:f.keyFormat)==="identity"&&!((l=K.decryptdata)!==null&&l!==void 0&&l.key)?this.loadKey(K,B):this.loadFragment(K,B,j))}}}},d.loadFragment=function(f,l,o){var E,m=this.fragmentTracker.getState(f);if(this.fragCurrent=f,m===L.FragmentState.BACKTRACKED){var O=this.fragmentTracker.getBacktrackData(f);if(O){this._handleFragmentLoadProgress(O),this._handleFragmentLoadComplete(O);return}else m=L.FragmentState.NOT_LOADED}m===L.FragmentState.NOT_LOADED||m===L.FragmentState.PARTIAL?f.sn==="initSegment"?this._loadInitSegment(f):this.bitrateTest?(f.bitrateTest=!0,this.log("Fragment "+f.sn+" of level "+f.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(f)):(this.startFragRequested=!0,n.prototype.loadFragment.call(this,f,l,o)):m===L.FragmentState.APPENDING?this.reduceMaxBufferLength(f.duration)&&this.fragmentTracker.removeFragment(f):((E=this.media)===null||E===void 0?void 0:E.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},d.getAppendedFrag=function(f){var l=this.fragmentTracker.getAppendedFrag(f,_.PlaylistLevelType.MAIN);return l&&"fragment"in l?l.fragment:l},d.getBufferedFrag=function(f){return this.fragmentTracker.getBufferedFrag(f,_.PlaylistLevelType.MAIN)},d.followingBufferedFrag=function(f){return f?this.getBufferedFrag(f.end+.5):null},d.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},d.nextLevelSwitch=function(){var f=this.levels,l=this.media;if(l!=null&&l.readyState){var o,E=this.getAppendedFrag(l.currentTime);if(E&&E.start>1&&this.flushMainBuffer(0,E.start-1),!l.paused&&f){var m=this.hls.nextLoadLevel,O=f[m],P=this.fragLastKbps;P&&this.fragCurrent?o=this.fragCurrent.duration*O.maxBitrate/(1e3*P)+1:o=0}else o=0;var M=this.getBufferedFrag(l.currentTime+o);if(M){var F=this.followingBufferedFrag(M);if(F){this.abortCurrentFrag();var B=F.maxStartPTS?F.maxStartPTS:F.start,C=F.duration,U=Math.max(M.end,B+Math.min(Math.max(C-this.config.maxFragLookUpTolerance,C*.5),C*.75));this.flushMainBuffer(U,Number.POSITIVE_INFINITY)}}}},d.abortCurrentFrag=function(){var f=this.fragCurrent;this.fragCurrent=null,f!=null&&f.loader&&f.loader.abort(),this.state===y.State.KEY_LOADING&&(this.state=y.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},d.flushMainBuffer=function(f,l){n.prototype.flushMainBuffer.call(this,f,l,this.altAudio?"video":null)},d.onMediaAttached=function(f,l){n.prototype.onMediaAttached.call(this,f,l);var o=l.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),o.addEventListener("playing",this.onvplaying),o.addEventListener("seeked",this.onvseeked),this.gapController=new S.default(this.config,o,this.fragmentTracker,this.hls)},d.onMediaDetaching=function(){var f=this.media;f&&(f.removeEventListener("playing",this.onvplaying),f.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),n.prototype.onMediaDetaching.call(this)},d.onMediaPlaying=function(){this.tick()},d.onMediaSeeked=function(){var f=this.media,l=f?f.currentTime:null;Object(R.isFiniteNumber)(l)&&this.log("Media seeked to "+l.toFixed(3)),this.tick()},d.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(b.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},d.onManifestParsed=function(f,l){var o=!1,E=!1,m;l.levels.forEach(function(O){m=O.audioCodec,m&&(m.indexOf("mp4a.40.2")!==-1&&(o=!0),m.indexOf("mp4a.40.5")!==-1&&(E=!0))}),this.audioCodecSwitch=o&&E&&!Object(x.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=l.levels,this.startFragRequested=!1},d.onLevelLoading=function(f,l){var o=this.levels;if(!(!o||this.state!==y.State.IDLE)){var E=o[l.level];(!E.details||E.details.live&&this.levelLastLoaded!==l.level||this.waitForCdnTuneIn(E.details))&&(this.state=y.State.WAITING_LEVEL)}},d.onLevelLoaded=function(f,l){var o,E=this.levels,m=l.level,O=l.details,P=O.totalduration;if(!E){this.warn("Levels were reset while loading level "+m);return}this.log("Level "+m+" loaded ["+O.startSN+","+O.endSN+"], cc ["+O.startCC+", "+O.endCC+"] duration:"+P);var M=this.fragCurrent;M&&(this.state===y.State.FRAG_LOADING||this.state===y.State.FRAG_LOADING_WAITING_RETRY)&&M.level!==l.level&&M.loader&&(this.state=y.State.IDLE,M.loader.abort());var F=E[m],B=0;if(O.live||(o=F.details)!==null&&o!==void 0&&o.live){if(O.fragments[0]||(O.deltaUpdateFailed=!0),O.deltaUpdateFailed)return;B=this.alignPlaylists(O,F.details)}if(F.details=O,this.levelLastLoaded=m,this.hls.trigger(b.Events.LEVEL_UPDATED,{details:O,level:m}),this.state===y.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(O))return;this.state=y.State.IDLE}this.startFragRequested?O.live&&this.synchronizeToLiveEdge(O):this.setStartPosition(O,B),this.tick()},d._handleFragmentLoadProgress=function(f){var l,o=f.frag,E=f.part,m=f.payload,O=this.levels;if(!O){this.warn("Levels were reset while fragment load was in progress. Fragment "+o.sn+" of level "+o.level+" will not be buffered");return}var P=O[o.level],M=P.details;if(!M){this.warn("Dropping fragment "+o.sn+" of level "+o.level+" after level details were reset");return}var F=P.videoCodec,B=M.PTSKnown||!M.live,C=(l=o.initSegment)===null||l===void 0?void 0:l.data,U=this._getAudioCodec(P),w=this.transmuxer=this.transmuxer||new A.default(this.hls,_.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),k=E?E.index:-1,j=k!==-1,K=new D.ChunkMetadata(o.level,o.sn,o.stats.chunkCount,m.byteLength,k,j),G=this.initPTS[o.cc];w.push(m,C,U,F,o,E,M.totalduration,B,K,G)},d.onAudioTrackSwitching=function(f,l){var o=this.altAudio,E=!!l.url,m=l.id;if(!E){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var O=this.fragCurrent;O!=null&&O.loader&&(this.log("Switching to main audio track, cancel main fragment load"),O.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var P=this.hls;o&&P.trigger(b.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),P.trigger(b.Events.AUDIO_TRACK_SWITCHED,{id:m})}},d.onAudioTrackSwitched=function(f,l){var o=l.id,E=!!this.hls.audioTracks[o].url;if(E){var m=this.videoBuffer;m&&this.mediaBuffer!==m&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=m)}this.altAudio=E,this.tick()},d.onBufferCreated=function(f,l){var o=l.tracks,E,m,O=!1;for(var P in o){var M=o[P];if(M.id==="main"){if(m=P,E=M,P==="video"){var F=o[P];F&&(this.videoBuffer=F.buffer)}}else O=!0}O&&E?(this.log("Alternate track found, use "+m+".buffered to schedule main fragment loading"),this.mediaBuffer=E.buffer):this.mediaBuffer=this.media},d.onFragBuffered=function(f,l){var o=l.frag,E=l.part;if(!(o&&o.type!==_.PlaylistLevelType.MAIN)){if(this.fragContextChanged(o)){this.warn("Fragment "+o.sn+(E?" p: "+E.index:"")+" of level "+o.level+" finished buffering, but was aborted. state: "+this.state),this.state===y.State.PARSED&&(this.state=y.State.IDLE);return}var m=E?E.stats:o.stats;this.fragLastKbps=Math.round(8*m.total/(m.buffering.end-m.loading.first)),o.sn!=="initSegment"&&(this.fragPrevious=o),this.fragBufferedComplete(o,E)}},d.onError=function(f,l){switch(l.details){case v.ErrorDetails.FRAG_LOAD_ERROR:case v.ErrorDetails.FRAG_LOAD_TIMEOUT:case v.ErrorDetails.KEY_LOAD_ERROR:case v.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_.PlaylistLevelType.MAIN,l);break;case v.ErrorDetails.LEVEL_LOAD_ERROR:case v.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==y.State.ERROR&&(l.fatal?(this.warn(""+l.details),this.state=y.State.ERROR):!l.levelRetry&&this.state===y.State.WAITING_LEVEL&&(this.state=y.State.IDLE));break;case v.ErrorDetails.BUFFER_FULL_ERROR:if(l.parent==="main"&&(this.state===y.State.PARSING||this.state===y.State.PARSED)){var o=!0,E=this.getFwdBufferInfo(this.media,_.PlaylistLevelType.MAIN);E&&E.len>.5&&(o=!this.reduceMaxBufferLength(E.len)),o&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},d.checkBuffer=function(){var f=this.media,l=this.gapController;if(!(!f||!l||!f.readyState)){var o=T.BufferHelper.getBuffered(f);!this.loadedmetadata&&o.length?(this.loadedmetadata=!0,this.seekToStartPos()):l.poll(this.lastCurrentTime),this.lastCurrentTime=f.currentTime}},d.onFragLoadEmergencyAborted=function(){this.state=y.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},d.onBufferFlushed=function(f,l){var o=l.type;if(o!==g.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var E=(o===g.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(E,o,_.PlaylistLevelType.MAIN)}},d.onLevelsUpdated=function(f,l){this.levels=l.levels},d.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},d.seekToStartPos=function(){var f=this.media,l=f.currentTime,o=this.startPosition;if(o>=0&&l<o){if(f.seeking){p.logger.log("could not seek to "+o+", already seeking at "+l);return}var E=T.BufferHelper.getBuffered(f),m=E.length?E.start(0):0,O=m-o;O>0&&(O<this.config.maxBufferHole||O<this.config.maxFragLookUpTolerance)&&(p.logger.log("adjusting start position by "+O+" to match buffer start"),o+=O,this.startPosition=o),this.log("seek to target start position "+o+" from current time "+l),f.currentTime=o}},d._getAudioCodec=function(f){var l=this.config.defaultAudioCodec||f.audioCodec;return this.audioCodecSwap&&l&&(this.log("Swapping audio codec"),l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5"),l},d._loadBitrateTestFrag=function(f){var l=this;this._doFragLoad(f).then(function(o){var E=l.hls;if(!(!o||E.nextLoadLevel||l.fragContextChanged(f))){l.fragLoadError=0,l.state=y.State.IDLE,l.startFragRequested=!1,l.bitrateTest=!1;var m=f.stats;m.parsing.start=m.parsing.end=m.buffering.start=m.buffering.end=self.performance.now(),E.trigger(b.Events.FRAG_LOADED,o)}})},d._handleTransmuxComplete=function(f){var l,o="main",E=this.hls,m=f.remuxResult,O=f.chunkMeta,P=this.getCurrentContext(O);if(!P){this.warn("The loading context changed while buffering fragment "+O.sn+" of level "+O.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(O.level);return}var M=P.frag,F=P.part,B=P.level,C=m.video,U=m.text,w=m.id3,k=m.initSegment,j=this.altAudio?void 0:m.audio;if(!this.fragContextChanged(M)){if(this.state=y.State.PARSING,k){k.tracks&&(this._bufferInitSegment(B,k.tracks,M,O),E.trigger(b.Events.FRAG_PARSING_INIT_SEGMENT,{frag:M,id:o,tracks:k.tracks}));var K=k.initPTS,G=k.timescale;Object(R.isFiniteNumber)(K)&&(this.initPTS[M.cc]=K,E.trigger(b.Events.INIT_PTS_FOUND,{frag:M,id:o,initPTS:K,timescale:G}))}if(C&&m.independent!==!1){if(B.details){var Y=C.startPTS,V=C.endPTS,Z=C.startDTS,z=C.endDTS;if(F)F.elementaryStreams[C.type]={startPTS:Y,endPTS:V,startDTS:Z,endDTS:z};else if(C.firstKeyFrame&&C.independent&&(this.couldBacktrack=!0),C.dropped&&C.independent){var ie=this.getLoadPosition()+this.config.maxBufferHole;if(ie<Y){this.backtrack(M);return}M.setElementaryStreamInfo(C.type,M.start,V,M.start,z,!0)}M.setElementaryStreamInfo(C.type,Y,V,Z,z),this.bufferFragmentData(C,M,F,O)}}else if(m.independent===!1){this.backtrack(M);return}if(j){var X=j.startPTS,ee=j.endPTS,ce=j.startDTS,ae=j.endDTS;F&&(F.elementaryStreams[g.ElementaryStreamTypes.AUDIO]={startPTS:X,endPTS:ee,startDTS:ce,endDTS:ae}),M.setElementaryStreamInfo(g.ElementaryStreamTypes.AUDIO,X,ee,ce,ae),this.bufferFragmentData(j,M,F,O)}if(w!=null&&(l=w.samples)!==null&&l!==void 0&&l.length){var ve={frag:M,id:o,samples:w.samples};E.trigger(b.Events.FRAG_PARSING_METADATA,ve)}if(U){var q={frag:M,id:o,samples:U.samples};E.trigger(b.Events.FRAG_PARSING_USERDATA,q)}}},d._bufferInitSegment=function(f,l,o,E){var m=this;if(this.state===y.State.PARSING){this.audioOnly=!!l.audio&&!l.video,this.altAudio&&!this.audioOnly&&delete l.audio;var O=l.audio,P=l.video,M=l.audiovideo;if(O){var F=f.audioCodec,B=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(F&&(F.indexOf("mp4a.40.5")!==-1?F="mp4a.40.2":F="mp4a.40.5"),O.metadata.channelCount!==1&&B.indexOf("firefox")===-1&&(F="mp4a.40.5")),B.indexOf("android")!==-1&&O.container!=="audio/mpeg"&&(F="mp4a.40.2",this.log("Android: force audio codec to "+F)),f.audioCodec&&f.audioCodec!==F&&this.log('Swapping manifest audio codec "'+f.audioCodec+'" for "'+F+'"'),O.levelCodec=F,O.id="main",this.log("Init audio buffer, container:"+O.container+", codecs[selected/level/parsed]=["+(F||"")+"/"+(f.audioCodec||"")+"/"+O.codec+"]")}P&&(P.levelCodec=f.videoCodec,P.id="main",this.log("Init video buffer, container:"+P.container+", codecs[level/parsed]=["+(f.videoCodec||"")+"/"+P.codec+"]")),M&&this.log("Init audiovideo buffer, container:"+M.container+", codecs[level/parsed]=["+(f.attrs.CODECS||"")+"/"+M.codec+"]"),this.hls.trigger(b.Events.BUFFER_CODECS,l),Object.keys(l).forEach(function(C){var U=l[C],w=U.initSegment;w!=null&&w.byteLength&&m.hls.trigger(b.Events.BUFFER_APPENDING,{type:C,data:w,frag:o,part:null,chunkMeta:E,parent:o.type})}),this.tick()}},d.backtrack=function(f){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(f);var l=this.fragmentTracker.backtrack(f);this.fragPrevious=null,this.nextLoadPosition=f.start,l?this.resetFragmentLoading(f):this.state=y.State.BACKTRACKING},d.checkFragmentChanged=function(){var f=this.media,l=null;if(f&&f.readyState>1&&f.seeking===!1){var o=f.currentTime;if(T.BufferHelper.isBuffered(f,o)?l=this.getAppendedFrag(o):T.BufferHelper.isBuffered(f,o+.1)&&(l=this.getAppendedFrag(o+.1)),l){var E=this.fragPlaying,m=l.level;(!E||l.sn!==E.sn||E.level!==m||l.urlId!==E.urlId)&&(this.hls.trigger(b.Events.FRAG_CHANGED,{frag:l}),(!E||E.level!==m)&&this.hls.trigger(b.Events.LEVEL_SWITCHED,{level:m}),this.fragPlaying=l)}}},e(h,[{key:"nextLevel",get:function(){var f=this.nextBufferedFrag;return f?f.level:-1}},{key:"currentLevel",get:function(){var f=this.media;if(f){var l=this.getAppendedFrag(f.currentTime);if(l)return l.level}return-1}},{key:"nextBufferedFrag",get:function(){var f=this.media;if(f){var l=this.getAppendedFrag(f.currentTime);return this.followingBufferedFrag(l)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),h}(y.default)},"./src/controller/subtitle-stream-controller.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"SubtitleStreamController",function(){return e});var R=c("./src/events.ts"),y=c("./src/utils/buffer-helper.ts"),x=c("./src/controller/fragment-finders.ts"),b=c("./src/utils/discontinuities.ts"),T=c("./src/controller/level-helper.ts"),L=c("./src/controller/fragment-tracker.ts"),_=c("./src/controller/base-stream-controller.ts"),g=c("./src/types/loader.ts"),A=c("./src/types/level.ts");function D(i,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(i,a.key,a)}}function S(i,t,r){return t&&D(i.prototype,t),r&&D(i,r),i}function v(i,t){i.prototype=Object.create(t.prototype),i.prototype.constructor=i,p(i,t)}function p(i,t){return p=Object.setPrototypeOf||function(a,n){return a.__proto__=n,a},p(i,t)}var s=500,e=function(i){v(t,i);function t(a,n){var h;return h=i.call(this,a,n,"[subtitle-stream-controller]")||this,h.levels=[],h.currentTrackId=-1,h.tracksBuffered=[],h.mainDetails=null,h._registerListeners(),h}var r=t.prototype;return r.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},r._registerListeners=function(){var n=this.hls;n.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.on(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.on(R.Events.ERROR,this.onError,this),n.on(R.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),n.on(R.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),n.on(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),n.on(R.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),n.on(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},r._unregisterListeners=function(){var n=this.hls;n.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.off(R.Events.ERROR,this.onError,this),n.off(R.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),n.off(R.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),n.off(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),n.off(R.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),n.off(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},r.startLoad=function(){this.stopLoad(),this.state=_.State.IDLE,this.setInterval(s),this.tick()},r.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},r.onLevelLoaded=function(n,h){this.mainDetails=h.details},r.onSubtitleFragProcessed=function(n,h){var d=h.frag,u=h.success;if(this.fragPrevious=d,this.state=_.State.IDLE,!!u){var f=this.tracksBuffered[this.currentTrackId];if(!!f){for(var l,o=d.start,E=0;E<f.length;E++)if(o>=f[E].start&&o<=f[E].end){l=f[E];break}var m=d.start+d.duration;l?l.end=m:(l={start:o,end:m},f.push(l)),this.fragmentTracker.fragBuffered(d)}}},r.onBufferFlushing=function(n,h){var d=h.startOffset,u=h.endOffset;if(d===0&&u!==Number.POSITIVE_INFINITY){var f=this.currentTrackId,l=this.levels;if(!l.length||!l[f]||!l[f].details)return;var o=l[f].details,E=o.targetduration,m=u-E;if(m<=0)return;h.endOffsetSubtitles=Math.max(0,m),this.tracksBuffered.forEach(function(O){for(var P=0;P<O.length;){if(O[P].end<=m){O.shift();continue}else if(O[P].start<m)O[P].start=m;else break;P++}}),this.fragmentTracker.removeFragmentsInRange(d,m,g.PlaylistLevelType.SUBTITLE)}},r.onError=function(n,h){var d,u=h.frag;!u||u.type!==g.PlaylistLevelType.SUBTITLE||((d=this.fragCurrent)!==null&&d!==void 0&&d.loader&&this.fragCurrent.loader.abort(),this.state=_.State.IDLE)},r.onSubtitleTracksUpdated=function(n,h){var d=this,u=h.subtitleTracks;this.tracksBuffered=[],this.levels=u.map(function(f){return new A.Level(f)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(f){d.tracksBuffered[f.id]=[]}),this.mediaBuffer=null},r.onSubtitleTrackSwitch=function(n,h){if(this.currentTrackId=h.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var d=this.levels[this.currentTrackId];d!=null&&d.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,d&&this.setInterval(s)},r.onSubtitleTrackLoaded=function(n,h){var d,u=h.details,f=h.id,l=this.currentTrackId,o=this.levels;if(!!o.length){var E=o[l];if(!(f>=o.length||f!==l||!E)){if(this.mediaBuffer=this.mediaBufferTimeRanges,u.live||(d=E.details)!==null&&d!==void 0&&d.live){var m=this.mainDetails;if(u.deltaUpdateFailed||!m)return;var O=m.fragments[0];if(!E.details)u.hasProgramDateTime&&m.hasProgramDateTime?Object(b.alignMediaPlaylistByPDT)(u,m):O&&Object(T.addSliding)(u,O.start);else{var P=this.alignPlaylists(u,E.details);P===0&&O&&Object(T.addSliding)(u,O.start)}}if(E.details=u,this.levelLastLoaded=f,this.tick(),u.live&&!this.fragCurrent&&this.media&&this.state===_.State.IDLE){var M=Object(x.findFragmentByPTS)(null,u.fragments,this.media.currentTime,0);M||(this.warn("Subtitle playlist not aligned with playback"),E.details=void 0)}}}},r._handleFragmentLoadComplete=function(n){var h=n.frag,d=n.payload,u=h.decryptdata,f=this.hls;if(!this.fragContextChanged(h)&&d&&d.byteLength>0&&u&&u.key&&u.iv&&u.method==="AES-128"){var l=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(d),u.key.buffer,u.iv.buffer).then(function(o){var E=performance.now();f.trigger(R.Events.FRAG_DECRYPTED,{frag:h,payload:o,stats:{tstart:l,tdecrypt:E}})})}},r.doTick=function(){if(!this.media){this.state=_.State.IDLE;return}if(this.state===_.State.IDLE){var n,h=this.currentTrackId,d=this.levels;if(!d.length||!d[h]||!d[h].details)return;var u=d[h].details,f=u.targetduration,l=this.config,o=this.media,E=y.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,o.currentTime-f,l.maxBufferHole),m=E.end,O=E.len,P=this.getMaxBufferLength()+f;if(O>P)return;console.assert(u,"Subtitle track details are defined on idle subtitle stream controller tick");var M=u.fragments,F=M.length,B=u.edge,C,U=this.fragPrevious;if(m<B){var w=l.maxFragLookUpTolerance;C=Object(x.findFragmentByPTS)(U,M,m,w),!C&&U&&U.start<M[0].start&&(C=M[0])}else C=M[F-1];(n=C)!==null&&n!==void 0&&n.encrypted?this.loadKey(C,u):C&&this.fragmentTracker.getState(C)===L.FragmentState.NOT_LOADED&&this.loadFragment(C,u,m)}},r.loadFragment=function(n,h,d){this.fragCurrent=n,i.prototype.loadFragment.call(this,n,h,d)},S(t,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),t}(_.default)},"./src/controller/subtitle-track-controller.ts":function(N,I,c){"use strict";c.r(I);var R=c("./src/events.ts"),y=c("./src/utils/texttrack-utils.ts"),x=c("./src/controller/base-playlist-controller.ts"),b=c("./src/types/loader.ts");function T(S,v){for(var p=0;p<v.length;p++){var s=v[p];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(S,s.key,s)}}function L(S,v,p){return v&&T(S.prototype,v),p&&T(S,p),S}function _(S,v){S.prototype=Object.create(v.prototype),S.prototype.constructor=S,g(S,v)}function g(S,v){return g=Object.setPrototypeOf||function(s,e){return s.__proto__=e,s},g(S,v)}var A=function(S){_(v,S);function v(s){var e;return e=S.call(this,s,"[subtitle-track-controller]")||this,e.media=null,e.tracks=[],e.groupId=null,e.tracksInGroup=[],e.trackId=-1,e.selectDefaultTrack=!0,e.queuedDefaultTrack=-1,e.trackChangeListener=function(){return e.onTextTracksChanged()},e.asyncPollTrackChange=function(){return e.pollTrackChange(0)},e.useTextTrackPolling=!1,e.subtitlePollingInterval=-1,e.subtitleDisplay=!0,e.registerListeners(),e}var p=v.prototype;return p.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,S.prototype.destroy.call(this)},p.registerListeners=function(){var e=this.hls;e.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(R.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(R.Events.ERROR,this.onError,this)},p.unregisterListeners=function(){var e=this.hls;e.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(R.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(R.Events.ERROR,this.onError,this)},p.onMediaAttached=function(e,i){this.media=i.media,!!this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},p.pollTrackChange=function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)},p.onMediaDetaching=function(){if(!!this.media){self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var e=D(this.media.textTracks);e.forEach(function(i){Object(y.clearCurrentCues)(i)}),this.subtitleTrack=-1,this.media=null}},p.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},p.onManifestParsed=function(e,i){this.tracks=i.subtitleTracks},p.onSubtitleTrackLoaded=function(e,i){var t=i.id,r=i.details,a=this.trackId,n=this.tracksInGroup[a];if(!n){this.warn("Invalid subtitle track id "+t);return}var h=n.details;n.details=i.details,this.log("subtitle track "+t+" loaded ["+r.startSN+"-"+r.endSN+"]"),t===this.trackId&&(this.retryCount=0,this.playlistLoaded(t,i,h))},p.onLevelLoading=function(e,i){this.switchLevel(i.level)},p.onLevelSwitching=function(e,i){this.switchLevel(i.level)},p.switchLevel=function(e){var i=this.hls.levels[e];if(!!(i!=null&&i.textGroupIds)){var t=i.textGroupIds[i.urlId];if(this.groupId!==t){var r=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,a=this.tracks.filter(function(d){return!t||d.groupId===t});this.tracksInGroup=a;var n=this.findTrackId(r==null?void 0:r.name)||this.findTrackId();this.groupId=t;var h={subtitleTracks:a};this.log("Updating subtitle tracks, "+a.length+' track(s) found in "'+t+'" group-id'),this.hls.trigger(R.Events.SUBTITLE_TRACKS_UPDATED,h),n!==-1&&this.setSubtitleTrack(n,r)}}},p.findTrackId=function(e){for(var i=this.tracksInGroup,t=0;t<i.length;t++){var r=i[t];if((!this.selectDefaultTrack||r.default)&&(!e||e===r.name))return r.id}return-1},p.onError=function(e,i){S.prototype.onError.call(this,e,i),!(i.fatal||!i.context)&&i.context.type===b.PlaylistContextType.SUBTITLE_TRACK&&i.context.id===this.trackId&&i.context.groupId===this.groupId&&this.retryLoadingOrFail(i)},p.loadPlaylist=function(e){var i=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(i)){var t=i.id,r=i.groupId,a=i.url;if(e)try{a=e.addDirectives(a)}catch(n){this.warn("Could not construct new URL with HLS Delivery Directives: "+n)}this.log("Loading subtitle playlist for id "+t),this.hls.trigger(R.Events.SUBTITLE_TRACK_LOADING,{url:a,id:t,groupId:r,deliveryDirectives:e||null})}},p.toggleTrackModes=function(e){var i=this,t=this.media,r=this.subtitleDisplay,a=this.trackId;if(!!t){var n=D(t.textTracks),h=n.filter(function(f){return f.groupId===i.groupId});if(e===-1)[].slice.call(n).forEach(function(f){f.mode="disabled"});else{var d=h[a];d&&(d.mode="disabled")}var u=h[e];u&&(u.mode=r?"showing":"hidden")}},p.setSubtitleTrack=function(e,i){var t,r=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),!(this.trackId===e&&(e===-1||(t=r[e])!==null&&t!==void 0&&t.details)||e<-1||e>=r.length)){this.clearTimer();var a=r[e];if(this.log("Switching to subtitle track "+e),this.trackId=e,a){var n=a.id,h=a.groupId,d=h===void 0?"":h,u=a.name,f=a.type,l=a.url;this.hls.trigger(R.Events.SUBTITLE_TRACK_SWITCH,{id:n,groupId:d,name:u,type:f,url:l});var o=this.switchParams(a.url,i==null?void 0:i.details);this.loadPlaylist(o)}else this.hls.trigger(R.Events.SUBTITLE_TRACK_SWITCH,{id:e})}},p.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!(!this.media||!this.hls.config.renderTextTracksNatively)){for(var e=-1,i=D(this.media.textTracks),t=0;t<i.length;t++)if(i[t].mode==="hidden")e=t;else if(i[t].mode==="showing"){e=t;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}},L(v,[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1;var i=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,i)}}]),v}(x.default);function D(S){for(var v=[],p=0;p<S.length;p++){var s=S[p];s.kind==="subtitles"&&s.label&&v.push(S[p])}return v}I.default=A},"./src/controller/timeline-controller.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"TimelineController",function(){return D});var R=c("./src/polyfills/number.ts"),y=c("./src/events.ts"),x=c("./src/utils/cea-608-parser.ts"),b=c("./src/utils/output-filter.ts"),T=c("./src/utils/webvtt-parser.ts"),L=c("./src/utils/texttrack-utils.ts"),_=c("./src/utils/imsc1-ttml-parser.ts"),g=c("./src/types/loader.ts"),A=c("./src/utils/logger.ts"),D=function(){function s(i){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=p(),this.captionsProperties=void 0,this.hls=i,this.config=i.config,this.Cues=i.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var t=new b.default(this,"textTrack1"),r=new b.default(this,"textTrack2"),a=new b.default(this,"textTrack3"),n=new b.default(this,"textTrack4");this.cea608Parser1=new x.default(1,t,r),this.cea608Parser2=new x.default(3,a,n)}i.on(y.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),i.on(y.Events.MEDIA_DETACHING,this.onMediaDetaching,this),i.on(y.Events.MANIFEST_LOADING,this.onManifestLoading,this),i.on(y.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.on(y.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),i.on(y.Events.FRAG_LOADING,this.onFragLoading,this),i.on(y.Events.FRAG_LOADED,this.onFragLoaded,this),i.on(y.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),i.on(y.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),i.on(y.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),i.on(y.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),i.on(y.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var e=s.prototype;return e.destroy=function(){var t=this.hls;t.off(y.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(y.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(y.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(y.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(y.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(y.Events.FRAG_LOADING,this.onFragLoading,this),t.off(y.Events.FRAG_LOADED,this.onFragLoaded,this),t.off(y.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(y.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(y.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(y.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(y.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},e.addCues=function(t,r,a,n,h){for(var d=!1,u=h.length;u--;){var f=h[u],l=v(f[0],f[1],r,a);if(l>=0&&(f[0]=Math.min(f[0],r),f[1]=Math.max(f[1],a),d=!0,l/(a-r)>.5))return}if(d||h.push([r,a]),this.config.renderTextTracksNatively){var o=this.captionsTracks[t];this.Cues.newCue(o,r,a,n)}else{var E=this.Cues.newCue(null,r,a,n);this.hls.trigger(y.Events.CUES_PARSED,{type:"captions",cues:E,track:t})}},e.onInitPtsFound=function(t,r){var a=this,n=r.frag,h=r.id,d=r.initPTS,u=r.timescale,f=this.unparsedVttFrags;h==="main"&&(this.initPTS[n.cc]=d,this.timescale[n.cc]=u),f.length&&(this.unparsedVttFrags=[],f.forEach(function(l){a.onFragLoaded(y.Events.FRAG_LOADED,l)}))},e.getExistingTrack=function(t){var r=this.media;if(r)for(var a=0;a<r.textTracks.length;a++){var n=r.textTracks[a];if(n[t])return n}return null},e.createCaptionsTrack=function(t){this.config.renderTextTracksNatively?this.createNativeTrack(t):this.createNonNativeTrack(t)},e.createNativeTrack=function(t){if(!this.captionsTracks[t]){var r=this.captionsProperties,a=this.captionsTracks,n=this.media,h=r[t],d=h.label,u=h.languageCode,f=this.getExistingTrack(t);if(f)a[t]=f,Object(L.clearCurrentCues)(a[t]),Object(L.sendAddTrackEvent)(a[t],n);else{var l=this.createTextTrack("captions",d,u);l&&(l[t]=!0,a[t]=l)}}},e.createNonNativeTrack=function(t){if(!this.nonNativeCaptionsTracks[t]){var r=this.captionsProperties[t];if(!!r){var a=r.label,n={_id:t,label:a,kind:"captions",default:r.media?!!r.media.default:!1,closedCaptions:r.media};this.nonNativeCaptionsTracks[t]=n,this.hls.trigger(y.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[n]})}}},e.createTextTrack=function(t,r,a){var n=this.media;if(!!n)return n.addTextTrack(t,r,a)},e.onMediaAttaching=function(t,r){this.media=r.media,this._cleanTracks()},e.onMediaDetaching=function(){var t=this.captionsTracks;Object.keys(t).forEach(function(r){Object(L.clearCurrentCues)(t[r]),delete t[r]}),this.nonNativeCaptionsTracks={}},e.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=p(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},e._cleanTracks=function(){var t=this.media;if(!!t){var r=t.textTracks;if(r)for(var a=0;a<r.length;a++)Object(L.clearCurrentCues)(r[a])}},e.onSubtitleTracksUpdated=function(t,r){var a=this;this.textTracks=[];var n=r.subtitleTracks||[],h=n.some(function(l){return l.textCodec===_.IMSC1_CODEC});if(this.config.enableWebVTT||h&&this.config.enableIMSC1){var d=this.tracks&&n&&this.tracks.length===n.length;if(this.tracks=n||[],this.config.renderTextTracksNatively){var u=this.media?this.media.textTracks:[];this.tracks.forEach(function(l,o){var E;if(o<u.length){for(var m=null,O=0;O<u.length;O++)if(S(u[O],l)){m=u[O];break}m&&(E=m)}E?Object(L.clearCurrentCues)(E):(E=a.createTextTrack("subtitles",l.name,l.lang),E&&(E.mode="disabled")),E&&(E.groupId=l.groupId,a.textTracks.push(E))})}else if(!d&&this.tracks&&this.tracks.length){var f=this.tracks.map(function(l){return{label:l.name,kind:l.type.toLowerCase(),default:l.default,subtitleTrack:l}});this.hls.trigger(y.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:f})}}},e.onManifestLoaded=function(t,r){var a=this;this.config.enableCEA708Captions&&r.captions&&r.captions.forEach(function(n){var h=/(?:CC|SERVICE)([1-4])/.exec(n.instreamId);if(!!h){var d="textTrack"+h[1],u=a.captionsProperties[d];!u||(u.label=n.name,n.lang&&(u.languageCode=n.lang),u.media=n)}})},e.onFragLoading=function(t,r){var a=this.cea608Parser1,n=this.cea608Parser2,h=this.lastSn,d=this.lastPartIndex;if(!(!this.enabled||!(a&&n))&&r.frag.type===g.PlaylistLevelType.MAIN){var u,f,l=r.frag.sn,o=(u=r==null||(f=r.part)===null||f===void 0?void 0:f.index)!=null?u:-1;l===h+1||l===h&&o===d+1||(a.reset(),n.reset()),this.lastSn=l,this.lastPartIndex=o}},e.onFragLoaded=function(t,r){var a=r.frag,n=r.payload,h=this.initPTS,d=this.unparsedVttFrags;if(a.type===g.PlaylistLevelType.SUBTITLE)if(n.byteLength){if(!Object(R.isFiniteNumber)(h[a.cc])){d.push(r),h.length&&this.hls.trigger(y.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:a,error:new Error("Missing initial subtitle PTS")});return}var u=a.decryptdata,f="stats"in r;if(u==null||u.key==null||u.method!=="AES-128"||f){var l=this.tracks[a.level],o=this.vttCCs;o[a.cc]||(o[a.cc]={start:a.start,prevCC:this.prevCC,new:!0},this.prevCC=a.cc),l&&l.textCodec===_.IMSC1_CODEC?this._parseIMSC1(a,n):this._parseVTTs(a,n,o)}}else this.hls.trigger(y.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:a,error:new Error("Empty subtitle payload")})},e._parseIMSC1=function(t,r){var a=this,n=this.hls;Object(_.parseIMSC1)(r,this.initPTS[t.cc],this.timescale[t.cc],function(h){a._appendCues(h,t.level),n.trigger(y.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})},function(h){A.logger.log("Failed to parse IMSC1: "+h),n.trigger(y.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:h})})},e._parseVTTs=function(t,r,a){var n=this,h=this.hls;Object(T.parseWebVTT)(r,this.initPTS[t.cc],this.timescale[t.cc],a,t.cc,t.start,function(d){n._appendCues(d,t.level),h.trigger(y.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})},function(d){n._fallbackToIMSC1(t,r),A.logger.log("Failed to parse VTT cue: "+d),h.trigger(y.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:d})})},e._fallbackToIMSC1=function(t,r){var a=this,n=this.tracks[t.level];n.textCodec||Object(_.parseIMSC1)(r,this.initPTS[t.cc],this.timescale[t.cc],function(){n.textCodec=_.IMSC1_CODEC,a._parseIMSC1(t,r)},function(){n.textCodec="wvtt"})},e._appendCues=function(t,r){var a=this.hls;if(this.config.renderTextTracksNatively){var n=this.textTracks[r];if(n.mode==="disabled")return;t.forEach(function(u){return Object(L.addCueToTrack)(n,u)})}else{var h=this.tracks[r],d=h.default?"default":"subtitles"+r;a.trigger(y.Events.CUES_PARSED,{type:"subtitles",cues:t,track:d})}},e.onFragDecrypted=function(t,r){var a=r.frag;if(a.type===g.PlaylistLevelType.SUBTITLE){if(!Object(R.isFiniteNumber)(this.initPTS[a.cc])){this.unparsedVttFrags.push(r);return}this.onFragLoaded(y.Events.FRAG_LOADED,r)}},e.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},e.onFragParsingUserdata=function(t,r){var a=this.cea608Parser1,n=this.cea608Parser2;if(!(!this.enabled||!(a&&n)))for(var h=0;h<r.samples.length;h++){var d=r.samples[h].bytes;if(d){var u=this.extractCea608Data(d);a.addData(r.samples[h].pts,u[0]),n.addData(r.samples[h].pts,u[1])}}},e.onBufferFlushing=function(t,r){var a=r.startOffset,n=r.endOffset,h=r.endOffsetSubtitles,d=r.type,u=this.media;if(!(!u||u.currentTime<n)){if(!d||d==="video"){var f=this.captionsTracks;Object.keys(f).forEach(function(o){return Object(L.removeCuesInRange)(f[o],a,n)})}if(this.config.renderTextTracksNatively&&a===0&&h!==void 0){var l=this.textTracks;Object.keys(l).forEach(function(o){return Object(L.removeCuesInRange)(l[o],a,h)})}}},e.extractCea608Data=function(t){for(var r=t[0]&31,a=2,n=[[],[]],h=0;h<r;h++){var d=t[a++],u=127&t[a++],f=127&t[a++],l=(4&d)!=0,o=3&d;u===0&&f===0||l&&(o===0||o===1)&&(n[o].push(u),n[o].push(f))}return n},s}();function S(s,e){return s&&s.label===e.name&&!(s.textTrack1||s.textTrack2)}function v(s,e,i,t){return Math.min(e,t)-Math.max(s,i)}function p(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"default",function(){return R});var R=function(){function y(b,T){this.subtle=void 0,this.aesIV=void 0,this.subtle=b,this.aesIV=T}var x=y.prototype;return x.decrypt=function(T,L){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},L,T)},y}()},"./src/crypt/aes-decryptor.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"removePadding",function(){return y}),c.d(I,"default",function(){return x});var R=c("./src/utils/typed-array.ts");function y(b){var T=b.byteLength,L=T&&new DataView(b.buffer).getUint8(T-1);return L?Object(R.sliceUint8)(b,0,T-L):b}var x=function(){function b(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var T=b.prototype;return T.uint8ArrayToUint32Array_=function(_){for(var g=new DataView(_),A=new Uint32Array(4),D=0;D<4;D++)A[D]=g.getUint32(D*4);return A},T.initTable=function(){var _=this.sBox,g=this.invSBox,A=this.subMix,D=A[0],S=A[1],v=A[2],p=A[3],s=this.invSubMix,e=s[0],i=s[1],t=s[2],r=s[3],a=new Uint32Array(256),n=0,h=0,d=0;for(d=0;d<256;d++)d<128?a[d]=d<<1:a[d]=d<<1^283;for(d=0;d<256;d++){var u=h^h<<1^h<<2^h<<3^h<<4;u=u>>>8^u&255^99,_[n]=u,g[u]=n;var f=a[n],l=a[f],o=a[l],E=a[u]*257^u*16843008;D[n]=E<<24|E>>>8,S[n]=E<<16|E>>>16,v[n]=E<<8|E>>>24,p[n]=E,E=o*16843009^l*65537^f*257^n*16843008,e[u]=E<<24|E>>>8,i[u]=E<<16|E>>>16,t[u]=E<<8|E>>>24,r[u]=E,n?(n=f^a[a[a[o^f]]],h^=a[a[h]]):n=h=1}},T.expandKey=function(_){for(var g=this.uint8ArrayToUint32Array_(_),A=!0,D=0;D<g.length&&A;)A=g[D]===this.key[D],D++;if(!A){this.key=g;var S=this.keySize=g.length;if(S!==4&&S!==6&&S!==8)throw new Error("Invalid aes key size="+S);var v=this.ksRows=(S+6+1)*4,p,s,e=this.keySchedule=new Uint32Array(v),i=this.invKeySchedule=new Uint32Array(v),t=this.sBox,r=this.rcon,a=this.invSubMix,n=a[0],h=a[1],d=a[2],u=a[3],f,l;for(p=0;p<v;p++){if(p<S){f=e[p]=g[p];continue}l=f,p%S==0?(l=l<<8|l>>>24,l=t[l>>>24]<<24|t[l>>>16&255]<<16|t[l>>>8&255]<<8|t[l&255],l^=r[p/S|0]<<24):S>6&&p%S==4&&(l=t[l>>>24]<<24|t[l>>>16&255]<<16|t[l>>>8&255]<<8|t[l&255]),e[p]=f=(e[p-S]^l)>>>0}for(s=0;s<v;s++)p=v-s,s&3?l=e[p]:l=e[p-4],s<4||p<=4?i[s]=l:i[s]=n[t[l>>>24]]^h[t[l>>>16&255]]^d[t[l>>>8&255]]^u[t[l&255]],i[s]=i[s]>>>0}},T.networkToHostOrderSwap=function(_){return _<<24|(_&65280)<<8|(_&16711680)>>8|_>>>24},T.decrypt=function(_,g,A){for(var D=this.keySize+6,S=this.invKeySchedule,v=this.invSBox,p=this.invSubMix,s=p[0],e=p[1],i=p[2],t=p[3],r=this.uint8ArrayToUint32Array_(A),a=r[0],n=r[1],h=r[2],d=r[3],u=new Int32Array(_),f=new Int32Array(u.length),l,o,E,m,O,P,M,F,B,C,U,w,k,j,K=this.networkToHostOrderSwap;g<u.length;){for(B=K(u[g]),C=K(u[g+1]),U=K(u[g+2]),w=K(u[g+3]),O=B^S[0],P=w^S[1],M=U^S[2],F=C^S[3],k=4,j=1;j<D;j++)l=s[O>>>24]^e[P>>16&255]^i[M>>8&255]^t[F&255]^S[k],o=s[P>>>24]^e[M>>16&255]^i[F>>8&255]^t[O&255]^S[k+1],E=s[M>>>24]^e[F>>16&255]^i[O>>8&255]^t[P&255]^S[k+2],m=s[F>>>24]^e[O>>16&255]^i[P>>8&255]^t[M&255]^S[k+3],O=l,P=o,M=E,F=m,k=k+4;l=v[O>>>24]<<24^v[P>>16&255]<<16^v[M>>8&255]<<8^v[F&255]^S[k],o=v[P>>>24]<<24^v[M>>16&255]<<16^v[F>>8&255]<<8^v[O&255]^S[k+1],E=v[M>>>24]<<24^v[F>>16&255]<<16^v[O>>8&255]<<8^v[P&255]^S[k+2],m=v[F>>>24]<<24^v[O>>16&255]<<16^v[P>>8&255]<<8^v[M&255]^S[k+3],f[g]=K(l^a),f[g+1]=K(m^n),f[g+2]=K(E^h),f[g+3]=K(o^d),a=B,n=C,h=U,d=w,g=g+4}return f.buffer},b}()},"./src/crypt/decrypter.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"default",function(){return g});var R=c("./src/crypt/aes-crypto.ts"),y=c("./src/crypt/fast-aes-key.ts"),x=c("./src/crypt/aes-decryptor.ts"),b=c("./src/utils/logger.ts"),T=c("./src/utils/mp4-tools.ts"),L=c("./src/utils/typed-array.ts"),_=16,g=function(){function A(S,v,p){var s=p===void 0?{}:p,e=s.removePKCS7Padding,i=e===void 0?!0:e;if(this.logEnabled=!0,this.observer=void 0,this.config=void 0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.observer=S,this.config=v,this.removePKCS7Padding=i,i)try{var t=self.crypto;t&&(this.subtle=t.subtle||t.webkitSubtle)}catch{}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var D=A.prototype;return D.destroy=function(){this.observer=null},D.isSync=function(){return this.config.enableSoftwareAES},D.flush=function(){var v=this.currentResult;if(!v){this.reset();return}var p=new Uint8Array(v);return this.reset(),this.removePKCS7Padding?Object(x.removePadding)(p):p},D.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},D.decrypt=function(v,p,s,e){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(v),p,s);var i=this.flush();i&&e(i.buffer)}else this.webCryptoDecrypt(new Uint8Array(v),p,s).then(e)},D.softwareDecrypt=function(v,p,s){var e=this.currentIV,i=this.currentResult,t=this.remainderData;this.logOnce("JS AES decrypt"),t&&(v=Object(T.appendUint8Array)(t,v),this.remainderData=null);var r=this.getValidChunk(v);if(!r.length)return null;e&&(s=e);var a=this.softwareDecrypter;a||(a=this.softwareDecrypter=new x.default),a.expandKey(p);var n=i;return this.currentResult=a.decrypt(r.buffer,0,s),this.currentIV=Object(L.sliceUint8)(r,-16).buffer,n||null},D.webCryptoDecrypt=function(v,p,s){var e=this,i=this.subtle;return(this.key!==p||!this.fastAesKey)&&(this.key=p,this.fastAesKey=new y.default(i,p)),this.fastAesKey.expandKey().then(function(t){if(!i)return Promise.reject(new Error("web crypto not initialized"));var r=new R.default(i,s);return r.decrypt(v.buffer,t)}).catch(function(t){return e.onWebCryptoError(t,v,p,s)})},D.onWebCryptoError=function(v,p,s,e){return b.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",v),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(p,s,e)},D.getValidChunk=function(v){var p=v,s=v.length-v.length%_;return s!==v.length&&(p=Object(L.sliceUint8)(v,0,s),this.remainderData=Object(L.sliceUint8)(v,s)),p},D.logOnce=function(v){!this.logEnabled||(b.logger.log("[decrypter.ts]: "+v),this.logEnabled=!1)},A}()},"./src/crypt/fast-aes-key.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"default",function(){return R});var R=function(){function y(b,T){this.subtle=void 0,this.key=void 0,this.subtle=b,this.key=T}var x=y.prototype;return x.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},y}()},"./src/demux/aacdemuxer.ts":function(N,I,c){"use strict";c.r(I);var R=c("./src/demux/base-audio-demuxer.ts"),y=c("./src/demux/adts.ts"),x=c("./src/utils/logger.ts"),b=c("./src/demux/id3.ts");function T(g,A){g.prototype=Object.create(A.prototype),g.prototype.constructor=g,L(g,A)}function L(g,A){return L=Object.setPrototypeOf||function(S,v){return S.__proto__=v,S},L(g,A)}var _=function(g){T(A,g);function A(S,v){var p;return p=g.call(this)||this,p.observer=void 0,p.config=void 0,p.observer=S,p.config=v,p}var D=A.prototype;return D.resetInitSegment=function(v,p,s){g.prototype.resetInitSegment.call(this,v,p,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:v,duration:s,inputTimeScale:9e4,dropped:0}},A.probe=function(v){if(!v)return!1;for(var p=b.getID3Data(v,0)||[],s=p.length,e=v.length;s<e;s++)if(y.probe(v,s))return x.logger.log("ADTS sync word found !"),!0;return!1},D.canParse=function(v,p){return y.canParse(v,p)},D.appendFrame=function(v,p,s){y.initTrackConfig(v,this.observer,p,s,v.manifestCodec);var e=y.appendFrame(v,p,s,this.initPTS,this.frameIndex);if(e&&e.missing===0)return e},A}(R.default);_.minProbeByteLength=9,I.default=_},"./src/demux/adts.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"getAudioConfig",function(){return b}),c.d(I,"isHeaderPattern",function(){return T}),c.d(I,"getHeaderLength",function(){return L}),c.d(I,"getFullFrameLength",function(){return _}),c.d(I,"canGetFrameLength",function(){return g}),c.d(I,"isHeader",function(){return A}),c.d(I,"canParse",function(){return D}),c.d(I,"probe",function(){return S}),c.d(I,"initTrackConfig",function(){return v}),c.d(I,"getFrameDuration",function(){return p}),c.d(I,"parseFrameHeader",function(){return s}),c.d(I,"appendFrame",function(){return e});var R=c("./src/utils/logger.ts"),y=c("./src/errors.ts"),x=c("./src/events.ts");function b(i,t,r,a){var n,h,d,u,f=navigator.userAgent.toLowerCase(),l=a,o=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];n=((t[r+2]&192)>>>6)+1;var E=(t[r+2]&60)>>>2;if(E>o.length-1){i.trigger(x.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+E});return}return d=(t[r+2]&1)<<2,d|=(t[r+3]&192)>>>6,R.logger.log("manifest codec:"+a+", ADTS type:"+n+", samplingIndex:"+E),/firefox/i.test(f)?E>=6?(n=5,u=new Array(4),h=E-3):(n=2,u=new Array(2),h=E):f.indexOf("android")!==-1?(n=2,u=new Array(2),h=E):(n=5,u=new Array(4),a&&(a.indexOf("mp4a.40.29")!==-1||a.indexOf("mp4a.40.5")!==-1)||!a&&E>=6?h=E-3:((a&&a.indexOf("mp4a.40.2")!==-1&&(E>=6&&d===1||/vivaldi/i.test(f))||!a&&d===1)&&(n=2,u=new Array(2)),h=E)),u[0]=n<<3,u[0]|=(E&14)>>1,u[1]|=(E&1)<<7,u[1]|=d<<3,n===5&&(u[1]|=(h&14)>>1,u[2]=(h&1)<<7,u[2]|=2<<2,u[3]=0),{config:u,samplerate:o[E],channelCount:d,codec:"mp4a.40."+n,manifestCodec:l}}function T(i,t){return i[t]===255&&(i[t+1]&246)==240}function L(i,t){return i[t+1]&1?7:9}function _(i,t){return(i[t+3]&3)<<11|i[t+4]<<3|(i[t+5]&224)>>>5}function g(i,t){return t+5<i.length}function A(i,t){return t+1<i.length&&T(i,t)}function D(i,t){return g(i,t)&&T(i,t)&&_(i,t)<=i.length-t}function S(i,t){if(A(i,t)){var r=L(i,t);if(t+r>=i.length)return!1;var a=_(i,t);if(a<=r)return!1;var n=t+a;return n===i.length||A(i,n)}return!1}function v(i,t,r,a,n){if(!i.samplerate){var h=b(t,r,a,n);if(!h)return;i.config=h.config,i.samplerate=h.samplerate,i.channelCount=h.channelCount,i.codec=h.codec,i.manifestCodec=h.manifestCodec,R.logger.log("parsed codec:"+i.codec+", rate:"+h.samplerate+", channels:"+h.channelCount)}}function p(i){return 1024*9e4/i}function s(i,t,r,a,n){var h=L(i,t),d=_(i,t);if(d-=h,d>0){var u=r+a*n;return{headerLength:h,frameLength:d,stamp:u}}}function e(i,t,r,a,n){var h=p(i.samplerate),d=s(t,r,a,n,h);if(d){var u=d.frameLength,f=d.headerLength,l=d.stamp,o=f+u,E=Math.max(0,r+o-t.length),m;E?(m=new Uint8Array(o-f),m.set(t.subarray(r+f,t.length),0)):m=t.subarray(r+f,r+o);var O={unit:m,pts:l};return E||i.samples.push(O),{sample:O,length:o,missing:E}}}},"./src/demux/base-audio-demuxer.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"initPTSFn",function(){return _});var R=c("./src/polyfills/number.ts"),y=c("./src/demux/id3.ts"),x=c("./src/demux/dummy-demuxed-track.ts"),b=c("./src/utils/mp4-tools.ts"),T=c("./src/utils/typed-array.ts"),L=function(){function g(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var A=g.prototype;return A.resetInitSegment=function(S,v,p){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},A.resetTimeStamp=function(){},A.resetContiguity=function(){},A.canParse=function(S,v){return!1},A.appendFrame=function(S,v,p){},A.demux=function(S,v){this.cachedData&&(S=Object(b.appendUint8Array)(this.cachedData,S),this.cachedData=null);var p=y.getID3Data(S,0),s=p?p.length:0,e,i,t=this._audioTrack,r=this._id3Track,a=p?y.getTimeStamp(p):void 0,n=S.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=_(a,v)),p&&p.length>0&&r.samples.push({pts:this.initPTS,dts:this.initPTS,data:p}),i=this.initPTS;s<n;){if(this.canParse(S,s)){var h=this.appendFrame(t,S,s);h?(this.frameIndex++,i=h.sample.pts,s+=h.length,e=s):s=n}else y.canParse(S,s)?(p=y.getID3Data(S,s),r.samples.push({pts:i,dts:i,data:p}),s+=p.length,e=s):s++;if(s===n&&e!==n){var d=Object(T.sliceUint8)(S,e);this.cachedData?this.cachedData=Object(b.appendUint8Array)(this.cachedData,d):this.cachedData=d}}return{audioTrack:t,avcTrack:Object(x.dummyTrack)(),id3Track:r,textTrack:Object(x.dummyTrack)()}},A.demuxSampleAes=function(S,v,p){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},A.flush=function(S){var v=this.cachedData;return v&&(this.cachedData=null,this.demux(v,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(x.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(x.dummyTrack)()}},A.destroy=function(){},g}(),_=function(A,D){return Object(R.isFiniteNumber)(A)?A*90:D*9e4};I.default=L},"./src/demux/chunk-cache.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"default",function(){return R});var R=function(){function x(){this.chunks=[],this.dataLength=0}var b=x.prototype;return b.push=function(L){this.chunks.push(L),this.dataLength+=L.length},b.flush=function(){var L=this.chunks,_=this.dataLength,g;if(L.length)L.length===1?g=L[0]:g=y(L,_);else return new Uint8Array(0);return this.reset(),g},b.reset=function(){this.chunks.length=0,this.dataLength=0},x}();function y(x,b){for(var T=new Uint8Array(b),L=0,_=0;_<x.length;_++){var g=x[_];T.set(g,L),L+=g.length}return T}},"./src/demux/dummy-demuxed-track.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"dummyTrack",function(){return R});function R(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(N,I,c){"use strict";c.r(I);var R=c("./src/utils/logger.ts"),y=function(){function x(T){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=T,this.bytesAvailable=T.byteLength,this.word=0,this.bitsAvailable=0}var b=x.prototype;return b.loadWord=function(){var L=this.data,_=this.bytesAvailable,g=L.byteLength-_,A=new Uint8Array(4),D=Math.min(4,_);if(D===0)throw new Error("no bytes available");A.set(L.subarray(g,g+D)),this.word=new DataView(A.buffer).getUint32(0),this.bitsAvailable=D*8,this.bytesAvailable-=D},b.skipBits=function(L){var _;this.bitsAvailable>L?(this.word<<=L,this.bitsAvailable-=L):(L-=this.bitsAvailable,_=L>>3,L-=_>>3,this.bytesAvailable-=_,this.loadWord(),this.word<<=L,this.bitsAvailable-=L)},b.readBits=function(L){var _=Math.min(this.bitsAvailable,L),g=this.word>>>32-_;return L>32&&R.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=_,this.bitsAvailable>0?this.word<<=_:this.bytesAvailable>0&&this.loadWord(),_=L-_,_>0&&this.bitsAvailable?g<<_|this.readBits(_):g},b.skipLZ=function(){var L;for(L=0;L<this.bitsAvailable;++L)if((this.word&2147483648>>>L)!=0)return this.word<<=L,this.bitsAvailable-=L,L;return this.loadWord(),L+this.skipLZ()},b.skipUEG=function(){this.skipBits(1+this.skipLZ())},b.skipEG=function(){this.skipBits(1+this.skipLZ())},b.readUEG=function(){var L=this.skipLZ();return this.readBits(L+1)-1},b.readEG=function(){var L=this.readUEG();return 1&L?1+L>>>1:-1*(L>>>1)},b.readBoolean=function(){return this.readBits(1)===1},b.readUByte=function(){return this.readBits(8)},b.readUShort=function(){return this.readBits(16)},b.readUInt=function(){return this.readBits(32)},b.skipScalingList=function(L){for(var _=8,g=8,A,D=0;D<L;D++)g!==0&&(A=this.readEG(),g=(_+A+256)%256),_=g===0?_:g},b.readSPS=function(){var L=0,_=0,g=0,A=0,D,S,v,p=this.readUByte.bind(this),s=this.readBits.bind(this),e=this.readUEG.bind(this),i=this.readBoolean.bind(this),t=this.skipBits.bind(this),r=this.skipEG.bind(this),a=this.skipUEG.bind(this),n=this.skipScalingList.bind(this);p();var h=p();if(s(5),t(3),p(),a(),h===100||h===110||h===122||h===244||h===44||h===83||h===86||h===118||h===128){var d=e();if(d===3&&t(1),a(),a(),t(1),i())for(S=d!==3?8:12,v=0;v<S;v++)i()&&(v<6?n(16):n(64))}a();var u=e();if(u===0)e();else if(u===1)for(t(1),r(),r(),D=e(),v=0;v<D;v++)r();a(),t(1);var f=e(),l=e(),o=s(1);o===0&&t(1),t(1),i()&&(L=e(),_=e(),g=e(),A=e());var E=[1,1];if(i()&&i()){var m=p();switch(m){case 1:E=[1,1];break;case 2:E=[12,11];break;case 3:E=[10,11];break;case 4:E=[16,11];break;case 5:E=[40,33];break;case 6:E=[24,11];break;case 7:E=[20,11];break;case 8:E=[32,11];break;case 9:E=[80,33];break;case 10:E=[18,11];break;case 11:E=[15,11];break;case 12:E=[64,33];break;case 13:E=[160,99];break;case 14:E=[4,3];break;case 15:E=[3,2];break;case 16:E=[2,1];break;case 255:{E=[p()<<8|p(),p()<<8|p()];break}}}return{width:Math.ceil((f+1)*16-L*2-_*2),height:(2-o)*(l+1)*16-(o?2:4)*(g+A),pixelRatio:E}},b.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},x}();I.default=y},"./src/demux/id3.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"isHeader",function(){return R}),c.d(I,"isFooter",function(){return y}),c.d(I,"getID3Data",function(){return x}),c.d(I,"canParse",function(){return T}),c.d(I,"getTimeStamp",function(){return L}),c.d(I,"isTimeStampFrame",function(){return _}),c.d(I,"getID3Frames",function(){return A}),c.d(I,"decodeFrame",function(){return D}),c.d(I,"utf8ArrayToStr",function(){return e}),c.d(I,"testables",function(){return i});var R=function(n,h){return h+10<=n.length&&n[h]===73&&n[h+1]===68&&n[h+2]===51&&n[h+3]<255&&n[h+4]<255&&n[h+6]<128&&n[h+7]<128&&n[h+8]<128&&n[h+9]<128},y=function(n,h){return h+10<=n.length&&n[h]===51&&n[h+1]===68&&n[h+2]===73&&n[h+3]<255&&n[h+4]<255&&n[h+6]<128&&n[h+7]<128&&n[h+8]<128&&n[h+9]<128},x=function(n,h){for(var d=h,u=0;R(n,h);){u+=10;var f=b(n,h+6);u+=f,y(n,h+10)&&(u+=10),h+=u}if(u>0)return n.subarray(d,d+u)},b=function(n,h){var d=0;return d=(n[h]&127)<<21,d|=(n[h+1]&127)<<14,d|=(n[h+2]&127)<<7,d|=n[h+3]&127,d},T=function(n,h){return R(n,h)&&b(n,h+6)+10<=n.length-h},L=function(n){for(var h=A(n),d=0;d<h.length;d++){var u=h[d];if(_(u))return s(u)}},_=function(n){return n&&n.key==="PRIV"&&n.info==="com.apple.streaming.transportStreamTimestamp"},g=function(n){var h=String.fromCharCode(n[0],n[1],n[2],n[3]),d=b(n,4),u=10;return{type:h,size:d,data:n.subarray(u,u+d)}},A=function(n){for(var h=0,d=[];R(n,h);){var u=b(n,h+6);h+=10;for(var f=h+u;h+8<f;){var l=g(n.subarray(h)),o=D(l);o&&d.push(o),h+=l.size+10}y(n,h)&&(h+=10)}return d},D=function(n){return n.type==="PRIV"?S(n):n.type[0]==="W"?p(n):v(n)},S=function(n){if(!(n.size<2)){var h=e(n.data,!0),d=new Uint8Array(n.data.subarray(h.length+1));return{key:n.type,info:h,data:d.buffer}}},v=function(n){if(!(n.size<2)){if(n.type==="TXXX"){var h=1,d=e(n.data.subarray(h),!0);h+=d.length+1;var u=e(n.data.subarray(h));return{key:n.type,info:d,data:u}}var f=e(n.data.subarray(1));return{key:n.type,data:f}}},p=function(n){if(n.type==="WXXX"){if(n.size<2)return;var h=1,d=e(n.data.subarray(h),!0);h+=d.length+1;var u=e(n.data.subarray(h));return{key:n.type,info:d,data:u}}var f=e(n.data);return{key:n.type,data:f}},s=function(n){if(n.data.byteLength===8){var h=new Uint8Array(n.data),d=h[3]&1,u=(h[4]<<23)+(h[5]<<15)+(h[6]<<7)+h[7];return u/=45,d&&(u+=4772185884e-2),Math.round(u)}},e=function(n,h){h===void 0&&(h=!1);var d=r();if(d){var u=d.decode(n);if(h){var f=u.indexOf("\0");return f!==-1?u.substring(0,f):u}return u.replace(/\0/g,"")}for(var l=n.length,o,E,m,O="",P=0;P<l;){if(o=n[P++],o===0&&h)return O;if(o===0||o===3)continue;switch(o>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:O+=String.fromCharCode(o);break;case 12:case 13:E=n[P++],O+=String.fromCharCode((o&31)<<6|E&63);break;case 14:E=n[P++],m=n[P++],O+=String.fromCharCode((o&15)<<12|(E&63)<<6|(m&63)<<0);break;default:}}return O},i={decodeTextFrame:v},t;function r(){return!t&&typeof self.TextDecoder!="undefined"&&(t=new self.TextDecoder("utf-8")),t}},"./src/demux/mp3demuxer.ts":function(N,I,c){"use strict";c.r(I);var R=c("./src/demux/base-audio-demuxer.ts"),y=c("./src/demux/id3.ts"),x=c("./src/utils/logger.ts"),b=c("./src/demux/mpegaudio.ts");function T(g,A){g.prototype=Object.create(A.prototype),g.prototype.constructor=g,L(g,A)}function L(g,A){return L=Object.setPrototypeOf||function(S,v){return S.__proto__=v,S},L(g,A)}var _=function(g){T(A,g);function A(){return g.apply(this,arguments)||this}var D=A.prototype;return D.resetInitSegment=function(v,p,s){g.prototype.resetInitSegment.call(this,v,p,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:v,duration:s,inputTimeScale:9e4,dropped:0}},A.probe=function(v){if(!v)return!1;for(var p=y.getID3Data(v,0)||[],s=p.length,e=v.length;s<e;s++)if(b.probe(v,s))return x.logger.log("MPEG Audio sync word found !"),!0;return!1},D.canParse=function(v,p){return b.canParse(v,p)},D.appendFrame=function(v,p,s){if(this.initPTS!==null)return b.appendFrame(v,p,s,this.initPTS,this.frameIndex)},A}(R.default);_.minProbeByteLength=4,I.default=_},"./src/demux/mp4demuxer.ts":function(N,I,c){"use strict";c.r(I);var R=c("./src/utils/mp4-tools.ts"),y=c("./src/demux/dummy-demuxed-track.ts"),x=function(){function b(L,_){this.remainderData=null,this.config=void 0,this.config=_}var T=b.prototype;return T.resetTimeStamp=function(){},T.resetInitSegment=function(){},T.resetContiguity=function(){},b.probe=function(_){return Object(R.findBox)({data:_,start:0,end:Math.min(_.length,16384)},["moof"]).length>0},T.demux=function(_){var g=_,A=Object(y.dummyTrack)();if(this.config.progressive){this.remainderData&&(g=Object(R.appendUint8Array)(this.remainderData,_));var D=Object(R.segmentValidRange)(g);this.remainderData=D.remainder,A.samples=D.valid||new Uint8Array}else A.samples=g;return{audioTrack:Object(y.dummyTrack)(),avcTrack:A,id3Track:Object(y.dummyTrack)(),textTrack:Object(y.dummyTrack)()}},T.flush=function(){var _=Object(y.dummyTrack)();return _.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(y.dummyTrack)(),avcTrack:_,id3Track:Object(y.dummyTrack)(),textTrack:Object(y.dummyTrack)()}},T.demuxSampleAes=function(_,g,A){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},T.destroy=function(){},b}();x.minProbeByteLength=1024,I.default=x},"./src/demux/mpegaudio.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"appendFrame",function(){return L}),c.d(I,"parseHeader",function(){return _}),c.d(I,"isHeaderPattern",function(){return g}),c.d(I,"isHeader",function(){return A}),c.d(I,"canParse",function(){return D}),c.d(I,"probe",function(){return S});var R=null,y=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],x=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],b=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],T=[0,1,1,4];function L(v,p,s,e,i){if(!(s+24>p.length)){var t=_(p,s);if(t&&s+t.frameLength<=p.length){var r=t.samplesPerFrame*9e4/t.sampleRate,a=e+i*r,n={unit:p.subarray(s,s+t.frameLength),pts:a,dts:a};return v.config=[],v.channelCount=t.channelCount,v.samplerate=t.sampleRate,v.samples.push(n),{sample:n,length:t.frameLength,missing:0}}}}function _(v,p){var s=v[p+1]>>3&3,e=v[p+1]>>1&3,i=v[p+2]>>4&15,t=v[p+2]>>2&3;if(s!==1&&i!==0&&i!==15&&t!==3){var r=v[p+2]>>1&1,a=v[p+3]>>6,n=s===3?3-e:e===3?3:4,h=y[n*14+i-1]*1e3,d=s===3?0:s===2?1:2,u=x[d*3+t],f=a===3?1:2,l=b[s][e],o=T[e],E=l*8*o,m=Math.floor(l*h/u+r)*o;if(R===null){var O=navigator.userAgent||"",P=O.match(/Chrome\/(\d+)/i);R=P?parseInt(P[1]):0}var M=!!R&&R<=87;return M&&e===2&&h>=224e3&&a===0&&(v[p+3]=v[p+3]|128),{sampleRate:u,channelCount:f,frameLength:m,samplesPerFrame:E}}}function g(v,p){return v[p]===255&&(v[p+1]&224)==224&&(v[p+1]&6)!=0}function A(v,p){return p+1<v.length&&g(v,p)}function D(v,p){var s=4;return g(v,p)&&s<=v.length-p}function S(v,p){if(p+1<v.length&&g(v,p)){var s=4,e=_(v,p),i=s;e!=null&&e.frameLength&&(i=e.frameLength);var t=p+i;return t===v.length||A(v,t)}return!1}},"./src/demux/sample-aes.ts":function(N,I,c){"use strict";c.r(I);var R=c("./src/crypt/decrypter.ts"),y=c("./src/demux/tsdemuxer.ts"),x=function(){function b(L,_,g){this.keyData=void 0,this.decrypter=void 0,this.keyData=g,this.decrypter=new R.default(L,_,{removePKCS7Padding:!1})}var T=b.prototype;return T.decryptBuffer=function(_,g){this.decrypter.decrypt(_,this.keyData.key.buffer,this.keyData.iv.buffer,g)},T.decryptAacSample=function(_,g,A,D){var S=_[g].unit,v=S.subarray(16,S.length-S.length%16),p=v.buffer.slice(v.byteOffset,v.byteOffset+v.length),s=this;this.decryptBuffer(p,function(e){var i=new Uint8Array(e);S.set(i,16),D||s.decryptAacSamples(_,g+1,A)})},T.decryptAacSamples=function(_,g,A){for(;;g++){if(g>=_.length){A();return}if(!(_[g].unit.length<32)){var D=this.decrypter.isSync();if(this.decryptAacSample(_,g,A,D),!D)return}}},T.getAvcEncryptedData=function(_){for(var g=Math.floor((_.length-48)/160)*16+16,A=new Int8Array(g),D=0,S=32;S<_.length-16;S+=160,D+=16)A.set(_.subarray(S,S+16),D);return A},T.getAvcDecryptedUnit=function(_,g){for(var A=new Uint8Array(g),D=0,S=32;S<_.length-16;S+=160,D+=16)_.set(A.subarray(D,D+16),S);return _},T.decryptAvcSample=function(_,g,A,D,S,v){var p=Object(y.discardEPB)(S.data),s=this.getAvcEncryptedData(p),e=this;this.decryptBuffer(s.buffer,function(i){S.data=e.getAvcDecryptedUnit(p,i),v||e.decryptAvcSamples(_,g,A+1,D)})},T.decryptAvcSamples=function(_,g,A,D){if(_ instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;g++,A=0){if(g>=_.length){D();return}for(var S=_[g].units;!(A>=S.length);A++){var v=S[A];if(!(v.data.length<=48||v.type!==1&&v.type!==5)){var p=this.decrypter.isSync();if(this.decryptAvcSample(_,g,A,D,v,p),!p)return}}}},b}();I.default=x},"./src/demux/transmuxer-interface.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"default",function(){return S});var R=c("./node_modules/webworkify-webpack/index.js"),y=c.n(R),x=c("./src/events.ts"),b=c("./src/demux/transmuxer.ts"),T=c("./src/utils/logger.ts"),L=c("./src/errors.ts"),_=c("./src/utils/mediasource-helper.ts"),g=c("./node_modules/eventemitter3/index.js"),A=c.n(g),D=Object(_.getMediaSource)()||{isTypeSupported:function(){return!1}},S=function(){function v(s,e,i,t){var r=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=s,this.id=e,this.onTransmuxComplete=i,this.onFlush=t;var a=s.config,n=function(l,o){o=o||{},o.frag=r.frag,o.id=r.id,s.trigger(l,o)};this.observer=new g.EventEmitter,this.observer.on(x.Events.FRAG_DECRYPTED,n),this.observer.on(x.Events.ERROR,n);var h={mp4:D.isTypeSupported("video/mp4"),mpeg:D.isTypeSupported("audio/mpeg"),mp3:D.isTypeSupported('audio/mp4; codecs="mp3"')},d=navigator.vendor;if(a.enableWorker&&typeof Worker!="undefined"){T.logger.log("demuxing in webworker");var u;try{u=this.worker=R("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),u.addEventListener("message",this.onwmsg),u.onerror=function(f){s.trigger(x.Events.ERROR,{type:L.ErrorTypes.OTHER_ERROR,details:L.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(f.message+" ("+f.filename+":"+f.lineno+")")})},u.postMessage({cmd:"init",typeSupported:h,vendor:d,id:e,config:JSON.stringify(a)})}catch(f){T.logger.warn("Error in worker:",f),T.logger.error("Error while initializing DemuxerWorker, fallback to inline"),u&&self.URL.revokeObjectURL(u.objectURL),this.transmuxer=new b.default(this.observer,h,a,d,e),this.worker=null}}else this.transmuxer=new b.default(this.observer,h,a,d,e)}var p=v.prototype;return p.destroy=function(){var e=this.worker;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.worker=null;else{var i=this.transmuxer;i&&(i.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.observer=null},p.push=function(e,i,t,r,a,n,h,d,u,f){var l,o,E=this;u.transmuxing.start=self.performance.now();var m=this.transmuxer,O=this.worker,P=n?n.start:a.start,M=a.decryptdata,F=this.frag,B=!(F&&a.cc===F.cc),C=!(F&&u.level===F.level),U=F?u.sn-F.sn:-1,w=this.part?u.part-this.part.index:1,k=!C&&(U===1||U===0&&w===1),j=self.performance.now();(C||U||a.stats.parsing.start===0)&&(a.stats.parsing.start=j),n&&(w||!k)&&(n.stats.parsing.start=j);var K=!(F&&((l=a.initSegment)===null||l===void 0?void 0:l.url)===((o=F.initSegment)===null||o===void 0?void 0:o.url)),G=new b.TransmuxState(B,k,d,C,P,K);if(!k||B||K){T.logger.log("[transmuxer-interface, "+a.type+"]: Starting new transmux session for sn: "+u.sn+" p: "+u.part+" level: "+u.level+" id: "+u.id+`
13
- discontinuity: `+B+`
11
+ Time to underbuffer: `+M.toFixed(3)+" s"),s.nextLoadLevel=w,this.bwEstimator.sample(d,t.loaded),this.clearTimer(),a.loader&&(this.fragCurrent=this.partCurrent=null,a.loader.abort()),s.trigger(S.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:a,part:e,stats:t})}}}}}},g.onFragLoaded=function(a,e){var s=e.frag,u=e.part;if(s.type===L.PlaylistLevelType.MAIN&&Object(R.isFiniteNumber)(s.sn)){var n=u?u.stats:s.stats,i=u?u.duration:s.duration;if(this.clearTimer(),this.lastLoadedFragLevel=s.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var t=this.hls.levels[s.level],l=(t.loaded?t.loaded.bytes:0)+n.loaded,d=(t.loaded?t.loaded.duration:0)+i;t.loaded={bytes:l,duration:d},t.realBitrate=Math.round(8*l/d)}if(s.bitrateTest){var r={stats:n,frag:s,part:u,id:s.type};this.onFragBuffered(S.Events.FRAG_BUFFERED,r)}}},g.onFragBuffered=function(a,e){var s=e.frag,u=e.part,n=u?u.stats:s.stats;if(!n.aborted&&!(s.type!==L.PlaylistLevelType.MAIN||s.sn==="initSegment")){var i=n.parsing.end-n.loading.start;this.bwEstimator.sample(i,n.loaded),n.bwEstimate=this.bwEstimator.getEstimate(),s.bitrateTest?this.bitrateTestDelay=i/1e3:this.bitrateTestDelay=0}},g.onError=function(a,e){switch(e.details){case x.ErrorDetails.FRAG_LOAD_ERROR:case x.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},g.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},g.getNextABRAutoLevel=function(){var a=this.fragCurrent,e=this.partCurrent,s=this.hls,u=s.maxAutoLevel,n=s.config,i=s.minAutoLevel,t=s.media,l=e?e.duration:a?a.duration:0,d=t?t.currentTime:0,r=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,c=this.bwEstimator?this.bwEstimator.getEstimate():n.abrEwmaDefaultEstimate,f=(I.BufferHelper.bufferInfo(t,d,n.maxBufferHole).end-d)/r,o=this.findBestLevel(c,i,u,f,n.abrBandWidthFactor,n.abrBandWidthUpFactor);if(o>=0)return o;A.logger.trace((f?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var v=l?Math.min(l,n.maxStarvationDelay):n.maxStarvationDelay,m=n.abrBandWidthFactor,O=n.abrBandWidthUpFactor;if(!f){var b=this.bitrateTestDelay;if(b){var M=l?Math.min(l,n.maxLoadingDelay):n.maxLoadingDelay;v=M-b,A.logger.trace("bitrate test took "+Math.round(1e3*b)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*v)+" ms"),m=O=1}}return o=this.findBestLevel(c,i,u,f+v,m,O),Math.max(o,0)},g.findBestLevel=function(a,e,s,u,n,i){for(var t,l=this.fragCurrent,d=this.partCurrent,r=this.lastLoadedFragLevel,c=this.hls.levels,f=c[r],o=!!(f!=null&&(t=f.details)!==null&&t!==void 0&&t.live),v=f==null?void 0:f.codecSet,m=d?d.duration:l?l.duration:0,O=s;O>=e;O--){var b=c[O];if(!(!b||v&&b.codecSet!==v)){var M=b.details,F=(d?M==null?void 0:M.partTarget:M==null?void 0:M.averagetargetduration)||m,w=void 0;O<=r?w=n*a:w=i*a;var C=c[O].maxBitrate,U=C*F/w;if(A.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+O+"/"+Math.round(w)+"/"+C+"/"+F+"/"+u+"/"+U),w>C&&(!U||o&&!this.bitrateTestDelay||U<u))return O}}return-1},D(T,[{key:"nextAutoLevel",get:function(){var a=this._nextAutoLevel,e=this.bwEstimator;if(a!==-1&&!e.canEstimate())return a;var s=this.getNextABRAutoLevel();return a!==-1&&this.hls.levels[s].loadError?a:(a!==-1&&(s=Math.min(a,s)),s)},set:function(a){this._nextAutoLevel=a}}]),T}();P.default=_},"./src/controller/audio-stream-controller.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/polyfills/number.ts"),p=h("./src/controller/base-stream-controller.ts"),S=h("./src/events.ts"),I=h("./src/utils/buffer-helper.ts"),x=h("./src/controller/fragment-tracker.ts"),L=h("./src/types/level.ts"),A=h("./src/types/loader.ts"),y=h("./src/loader/fragment.ts"),D=h("./src/demux/chunk-cache.ts"),_=h("./src/demux/transmuxer-interface.ts"),T=h("./src/types/transmuxer.ts"),g=h("./src/controller/fragment-finders.ts"),E=h("./src/utils/discontinuities.ts"),a=h("./src/errors.ts");function e(){return e=Object.assign?Object.assign.bind():function(t){for(var l=1;l<arguments.length;l++){var d=arguments[l];for(var r in d)Object.prototype.hasOwnProperty.call(d,r)&&(t[r]=d[r])}return t},e.apply(this,arguments)}function s(t,l){t.prototype=Object.create(l.prototype),t.prototype.constructor=t,u(t,l)}function u(t,l){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,c){return r.__proto__=c,r},u(t,l)}var n=100,i=function(t){s(l,t);function l(r,c){var f;return f=t.call(this,r,c,"[audio-stream-controller]")||this,f.videoBuffer=null,f.videoTrackCC=-1,f.waitingVideoCC=-1,f.audioSwitch=!1,f.trackId=-1,f.waitingData=null,f.mainDetails=null,f.bufferFlushed=!1,f.cachedTrackLoadedData=null,f._registerListeners(),f}var d=l.prototype;return d.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},d._registerListeners=function(){var c=this.hls;c.on(S.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.on(S.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.on(S.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.on(S.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.on(S.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),c.on(S.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),c.on(S.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),c.on(S.Events.ERROR,this.onError,this),c.on(S.Events.BUFFER_RESET,this.onBufferReset,this),c.on(S.Events.BUFFER_CREATED,this.onBufferCreated,this),c.on(S.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),c.on(S.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),c.on(S.Events.FRAG_BUFFERED,this.onFragBuffered,this)},d._unregisterListeners=function(){var c=this.hls;c.off(S.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.off(S.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.off(S.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.off(S.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.off(S.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),c.off(S.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),c.off(S.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),c.off(S.Events.ERROR,this.onError,this),c.off(S.Events.BUFFER_RESET,this.onBufferReset,this),c.off(S.Events.BUFFER_CREATED,this.onBufferCreated,this),c.off(S.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),c.off(S.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),c.off(S.Events.FRAG_BUFFERED,this.onFragBuffered,this)},d.onInitPtsFound=function(c,f){var o=f.frag,v=f.id,m=f.initPTS;if(v==="main"){var O=o.cc;this.initPTS[o.cc]=m,this.log("InitPTS for cc: "+O+" found from main: "+m),this.videoTrackCC=O,this.state===p.State.WAITING_INIT_PTS&&this.tick()}},d.startLoad=function(c){if(!this.levels){this.startPosition=c,this.state=p.State.STOPPED;return}var f=this.lastCurrentTime;this.stopLoad(),this.setInterval(n),this.fragLoadError=0,f>0&&c===-1?(this.log("Override startPosition with lastCurrentTime @"+f.toFixed(3)),c=f,this.state=p.State.IDLE):(this.loadedmetadata=!1,this.state=p.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=c,this.tick()},d.doTick=function(){switch(this.state){case p.State.IDLE:this.doTickIdle();break;case p.State.WAITING_TRACK:{var c,f=this.levels,o=this.trackId,v=f==null||(c=f[o])===null||c===void 0?void 0:c.details;if(v){if(this.waitForCdnTuneIn(v))break;this.state=p.State.WAITING_INIT_PTS}break}case p.State.FRAG_LOADING_WAITING_RETRY:{var m,O=performance.now(),b=this.retryDate;(!b||O>=b||(m=this.media)!==null&&m!==void 0&&m.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=p.State.IDLE);break}case p.State.WAITING_INIT_PTS:{var M=this.waitingData;if(M){var F=M.frag,w=M.part,C=M.cache,U=M.complete;if(this.initPTS[F.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=p.State.FRAG_LOADING;var B=C.flush(),N={frag:F,part:w,payload:B,networkDetails:null};this._handleFragmentLoadProgress(N),U&&t.prototype._handleFragmentLoadComplete.call(this,N)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+F.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var k=this.getLoadPosition(),j=I.BufferHelper.bufferInfo(this.mediaBuffer,k,this.config.maxBufferHole),H=Object(g.fragmentWithinToleranceTest)(j.end,this.config.maxFragLookUpTolerance,F);H<0&&(this.log("Waiting fragment cc ("+F.cc+") @ "+F.start+" cancelled because another fragment at "+j.end+" is needed"),this.clearWaitingFragment())}}else this.state=p.State.IDLE}}this.onTickEnd()},d.clearWaitingFragment=function(){var c=this.waitingData;c&&(this.fragmentTracker.removeFragment(c.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=p.State.IDLE)},d.resetLoadingState=function(){this.clearWaitingFragment(),t.prototype.resetLoadingState.call(this)},d.onTickEnd=function(){var c=this.media;if(!(!c||!c.readyState)){var f=this.mediaBuffer?this.mediaBuffer:c,o=f.buffered;!this.loadedmetadata&&o.length&&(this.loadedmetadata=!0),this.lastCurrentTime=c.currentTime}},d.doTickIdle=function(){var c,f,o=this.hls,v=this.levels,m=this.media,O=this.trackId,b=o.config;if(!(!v||!v[O])&&!(!m&&(this.startFragRequested||!b.startFragPrefetch))){var M=v[O],F=M.details;if(!F||F.live&&this.levelLastLoaded!==O||this.waitForCdnTuneIn(F)){this.state=p.State.WAITING_TRACK;return}var w=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&w&&(this.bufferFlushed=!1,this.afterBufferFlushed(w,y.ElementaryStreamTypes.AUDIO,A.PlaylistLevelType.AUDIO));var C=this.getFwdBufferInfo(w,A.PlaylistLevelType.AUDIO);if(C!==null){var U=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,A.PlaylistLevelType.MAIN),B=C.len,N=this.getMaxBufferLength(U==null?void 0:U.len),k=this.audioSwitch;if(!(B>=N&&!k)){if(!k&&this._streamEnded(C,F)){o.trigger(S.Events.BUFFER_EOS,{type:"audio"}),this.state=p.State.ENDED;return}var j=F.fragments,H=j[0].start,V=C.end;if(k&&m){var Y=this.getLoadPosition();V=Y,F.PTSKnown&&Y<H&&(C.end>H||C.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),m.currentTime=H+.05)}if(!(U&&V>U.end+F.targetduration)&&!((!U||!U.len)&&C.len)){var Q=this.getNextFragment(V,F);if(!Q){this.bufferFlushed=!0;return}((c=Q.decryptdata)===null||c===void 0?void 0:c.keyFormat)==="identity"&&!((f=Q.decryptdata)!==null&&f!==void 0&&f.key)?this.loadKey(Q,F):this.loadFragment(Q,F,V)}}}}},d.getMaxBufferLength=function(c){var f=t.prototype.getMaxBufferLength.call(this);return c?Math.max(f,c):f},d.onMediaDetaching=function(){this.videoBuffer=null,t.prototype.onMediaDetaching.call(this)},d.onAudioTracksUpdated=function(c,f){var o=f.audioTracks;this.resetTransmuxer(),this.levels=o.map(function(v){return new L.Level(v)})},d.onAudioTrackSwitching=function(c,f){var o=!!f.url;this.trackId=f.id;var v=this.fragCurrent;v!=null&&v.loader&&v.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),o?this.setInterval(n):this.resetTransmuxer(),o?(this.audioSwitch=!0,this.state=p.State.IDLE):this.state=p.State.STOPPED,this.tick()},d.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},d.onLevelLoaded=function(c,f){this.mainDetails=f.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(S.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},d.onAudioTrackLoaded=function(c,f){var o;if(this.mainDetails==null){this.cachedTrackLoadedData=f;return}var v=this.levels,m=f.details,O=f.id;if(!v){this.warn("Audio tracks were reset while loading level "+O);return}this.log("Track "+O+" loaded ["+m.startSN+","+m.endSN+"],duration:"+m.totalduration);var b=v[O],M=0;if(m.live||(o=b.details)!==null&&o!==void 0&&o.live){var F=this.mainDetails;if(m.fragments[0]||(m.deltaUpdateFailed=!0),m.deltaUpdateFailed||!F)return;!b.details&&m.hasProgramDateTime&&F.hasProgramDateTime?(Object(E.alignMediaPlaylistByPDT)(m,F),M=m.fragments[0].start):M=this.alignPlaylists(m,b.details)}b.details=m,this.levelLastLoaded=O,!this.startFragRequested&&(this.mainDetails||!m.live)&&this.setStartPosition(b.details,M),this.state===p.State.WAITING_TRACK&&!this.waitForCdnTuneIn(m)&&(this.state=p.State.IDLE),this.tick()},d._handleFragmentLoadProgress=function(c){var f,o=c.frag,v=c.part,m=c.payload,O=this.config,b=this.trackId,M=this.levels;if(!M){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+o.sn+" of level "+o.level+" will not be buffered");return}var F=M[b];console.assert(F,"Audio track is defined on fragment load progress");var w=F.details;console.assert(w,"Audio track details are defined on fragment load progress");var C=O.defaultAudioCodec||F.audioCodec||"mp4a.40.2",U=this.transmuxer;U||(U=this.transmuxer=new _.default(this.hls,A.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var B=this.initPTS[o.cc],N=(f=o.initSegment)===null||f===void 0?void 0:f.data;if(B!==void 0){var k=!1,j=v?v.index:-1,H=j!==-1,V=new T.ChunkMetadata(o.level,o.sn,o.stats.chunkCount,m.byteLength,j,H);U.push(m,N,C,"",o,v,w.totalduration,k,V,B)}else{this.log("Unknown video PTS for cc "+o.cc+", waiting for video PTS before demuxing audio frag "+o.sn+" of ["+w.startSN+" ,"+w.endSN+"],track "+b);var Y=this.waitingData=this.waitingData||{frag:o,part:v,cache:new D.default,complete:!1},Q=Y.cache;Q.push(new Uint8Array(m)),this.waitingVideoCC=this.videoTrackCC,this.state=p.State.WAITING_INIT_PTS}},d._handleFragmentLoadComplete=function(c){if(this.waitingData){this.waitingData.complete=!0;return}t.prototype._handleFragmentLoadComplete.call(this,c)},d.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},d.onBufferCreated=function(c,f){var o=f.tracks.audio;o&&(this.mediaBuffer=o.buffer||null),f.tracks.video&&(this.videoBuffer=f.tracks.video.buffer||null)},d.onFragBuffered=function(c,f){var o=f.frag,v=f.part;if(o.type===A.PlaylistLevelType.AUDIO){if(this.fragContextChanged(o)){this.warn("Fragment "+o.sn+(v?" p: "+v.index:"")+" of level "+o.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}o.sn!=="initSegment"&&(this.fragPrevious=o,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(S.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(o,v)}},d.onError=function(c,f){switch(f.details){case a.ErrorDetails.FRAG_LOAD_ERROR:case a.ErrorDetails.FRAG_LOAD_TIMEOUT:case a.ErrorDetails.KEY_LOAD_ERROR:case a.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(A.PlaylistLevelType.AUDIO,f);break;case a.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case a.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==p.State.ERROR&&this.state!==p.State.STOPPED&&(this.state=f.fatal?p.State.ERROR:p.State.IDLE,this.warn(f.details+" while loading frag, switching to "+this.state+" state"));break;case a.ErrorDetails.BUFFER_FULL_ERROR:if(f.parent==="audio"&&(this.state===p.State.PARSING||this.state===p.State.PARSED)){var o=!0,v=this.getFwdBufferInfo(this.mediaBuffer,A.PlaylistLevelType.AUDIO);v&&v.len>.5&&(o=!this.reduceMaxBufferLength(v.len)),o&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},d.onBufferFlushed=function(c,f){var o=f.type;o===y.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},d._handleTransmuxComplete=function(c){var f,o="audio",v=this.hls,m=c.remuxResult,O=c.chunkMeta,b=this.getCurrentContext(O);if(!b){this.warn("The loading context changed while buffering fragment "+O.sn+" of level "+O.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(O.level);return}var M=b.frag,F=b.part,w=b.level.details,C=m.audio,U=m.text,B=m.id3,N=m.initSegment;if(!(this.fragContextChanged(M)||!w)){if(this.state=p.State.PARSING,this.audioSwitch&&C&&this.completeAudioSwitch(),N!=null&&N.tracks&&(this._bufferInitSegment(N.tracks,M,O),v.trigger(S.Events.FRAG_PARSING_INIT_SEGMENT,{frag:M,id:o,tracks:N.tracks})),C){var k=C.startPTS,j=C.endPTS,H=C.startDTS,V=C.endDTS;F&&(F.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:k,endPTS:j,startDTS:H,endDTS:V}),M.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,k,j,H,V),this.bufferFragmentData(C,M,F,O)}if(B!=null&&(f=B.samples)!==null&&f!==void 0&&f.length){var Y=e({id:o,frag:M,details:w},B);v.trigger(S.Events.FRAG_PARSING_METADATA,Y)}if(U){var Q=e({id:o,frag:M,details:w},U);v.trigger(S.Events.FRAG_PARSING_USERDATA,Q)}}},d._bufferInitSegment=function(c,f,o){if(this.state===p.State.PARSING){c.video&&delete c.video;var v=c.audio;if(!!v){v.levelCodec=v.codec,v.id="audio",this.log("Init audio buffer, container:"+v.container+", codecs[parsed]=["+v.codec+"]"),this.hls.trigger(S.Events.BUFFER_CODECS,c);var m=v.initSegment;if(m!=null&&m.byteLength){var O={type:"audio",frag:f,part:null,chunkMeta:o,parent:f.type,data:m};this.hls.trigger(S.Events.BUFFER_APPENDING,O)}this.tick()}}},d.loadFragment=function(c,f,o){var v=this.fragmentTracker.getState(c);this.fragCurrent=c,(this.audioSwitch||v===x.FragmentState.NOT_LOADED||v===x.FragmentState.PARTIAL)&&(c.sn==="initSegment"?this._loadInitSegment(c):f.live&&!Object(R.isFiniteNumber)(this.initPTS[c.cc])?(this.log("Waiting for video PTS in continuity counter "+c.cc+" of live stream before loading audio fragment "+c.sn+" of level "+this.trackId),this.state=p.State.WAITING_INIT_PTS):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,c,f,o)))},d.completeAudioSwitch=function(){var c=this.hls,f=this.media,o=this.trackId;f&&(this.log("Switching audio track : flushing all audio"),t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,c.trigger(S.Events.AUDIO_TRACK_SWITCHED,{id:o})},l}(p.default);P.default=i},"./src/controller/audio-track-controller.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/events.ts"),p=h("./src/errors.ts"),S=h("./src/controller/base-playlist-controller.ts"),I=h("./src/types/loader.ts");function x(_,T){for(var g=0;g<T.length;g++){var E=T[g];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(_,E.key,E)}}function L(_,T,g){return T&&x(_.prototype,T),g&&x(_,g),Object.defineProperty(_,"prototype",{writable:!1}),_}function A(_,T){_.prototype=Object.create(T.prototype),_.prototype.constructor=_,y(_,T)}function y(_,T){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(E,a){return E.__proto__=a,E},y(_,T)}var D=function(_){A(T,_);function T(E){var a;return a=_.call(this,E,"[audio-track-controller]")||this,a.tracks=[],a.groupId=null,a.tracksInGroup=[],a.trackId=-1,a.trackName="",a.selectDefaultTrack=!0,a.registerListeners(),a}var g=T.prototype;return g.registerListeners=function(){var a=this.hls;a.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.on(R.Events.LEVEL_LOADING,this.onLevelLoading,this),a.on(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),a.on(R.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),a.on(R.Events.ERROR,this.onError,this)},g.unregisterListeners=function(){var a=this.hls;a.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.off(R.Events.LEVEL_LOADING,this.onLevelLoading,this),a.off(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),a.off(R.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),a.off(R.Events.ERROR,this.onError,this)},g.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,_.prototype.destroy.call(this)},g.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},g.onManifestParsed=function(a,e){this.tracks=e.audioTracks||[]},g.onAudioTrackLoaded=function(a,e){var s=e.id,u=e.details,n=this.tracksInGroup[s];if(!n){this.warn("Invalid audio track id "+s);return}var i=n.details;n.details=e.details,this.log("audioTrack "+s+" loaded ["+u.startSN+"-"+u.endSN+"]"),s===this.trackId&&(this.retryCount=0,this.playlistLoaded(s,e,i))},g.onLevelLoading=function(a,e){this.switchLevel(e.level)},g.onLevelSwitching=function(a,e){this.switchLevel(e.level)},g.switchLevel=function(a){var e=this.hls.levels[a];if(!!(e!=null&&e.audioGroupIds)){var s=e.audioGroupIds[e.urlId];if(this.groupId!==s){this.groupId=s;var u=this.tracks.filter(function(i){return!s||i.groupId===s});this.selectDefaultTrack&&!u.some(function(i){return i.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=u;var n={audioTracks:u};this.log("Updating audio tracks, "+u.length+' track(s) found in "'+s+'" group-id'),this.hls.trigger(R.Events.AUDIO_TRACKS_UPDATED,n),this.selectInitialTrack()}}},g.onError=function(a,e){_.prototype.onError.call(this,a,e),!(e.fatal||!e.context)&&e.context.type===I.PlaylistContextType.AUDIO_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.retryLoadingOrFail(e)},g.setAudioTrack=function(a){var e=this.tracksInGroup;if(a<0||a>=e.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var s=e[this.trackId];this.log("Now switching to audio-track index "+a);var u=e[a],n=u.id,i=u.groupId,t=i===void 0?"":i,l=u.name,d=u.type,r=u.url;if(this.trackId=a,this.trackName=l,this.selectDefaultTrack=!1,this.hls.trigger(R.Events.AUDIO_TRACK_SWITCHING,{id:n,groupId:t,name:l,type:d,url:r}),!(u.details&&!u.details.live)){var c=this.switchParams(u.url,s==null?void 0:s.details);this.loadPlaylist(c)}},g.selectInitialTrack=function(){var a=this.tracksInGroup;console.assert(a.length,"Initial audio track should be selected when tracks are known");var e=this.trackName,s=this.findTrackId(e)||this.findTrackId();s!==-1?this.setAudioTrack(s):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},g.findTrackId=function(a){for(var e=this.tracksInGroup,s=0;s<e.length;s++){var u=e[s];if((!this.selectDefaultTrack||u.default)&&(!a||a===u.name))return u.id}return-1},g.loadPlaylist=function(a){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var s=e.id,u=e.groupId,n=e.url;if(a)try{n=a.addDirectives(n)}catch(i){this.warn("Could not construct new URL with HLS Delivery Directives: "+i)}this.log("loading audio-track playlist for id: "+s),this.clearTimer(),this.hls.trigger(R.Events.AUDIO_TRACK_LOADING,{url:n,id:s,groupId:u,deliveryDirectives:a||null})}},L(T,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(a){this.selectDefaultTrack=!1,this.setAudioTrack(a)}}]),T}(S.default);P.default=D},"./src/controller/base-playlist-controller.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return L});var R=h("./src/polyfills/number.ts"),p=h("./src/types/level.ts"),S=h("./src/controller/level-helper.ts"),I=h("./src/utils/logger.ts"),x=h("./src/errors.ts"),L=function(){function A(D,_){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=I.logger.log.bind(I.logger,_+":"),this.warn=I.logger.warn.bind(I.logger,_+":"),this.hls=D}var y=A.prototype;return y.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},y.onError=function(_,T){T.fatal&&T.type===x.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},y.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},y.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},y.stopLoad=function(){this.canLoad=!1,this.clearTimer()},y.switchParams=function(_,T){var g=T==null?void 0:T.renditionReports;if(g)for(var E=0;E<g.length;E++){var a=g[E],e=""+a.URI;if(e===_.slice(-e.length)){var s=parseInt(a["LAST-MSN"]),u=parseInt(a["LAST-PART"]);if(T&&this.hls.config.lowLatencyMode){var n=Math.min(T.age-T.partTarget,T.targetduration);u!==void 0&&n>T.partTarget&&(u+=1)}if(Object(R.isFiniteNumber)(s))return new p.HlsUrlParameters(s,Object(R.isFiniteNumber)(u)?u:void 0,p.HlsSkip.No)}}},y.loadPlaylist=function(_){},y.shouldLoadTrack=function(_){return this.canLoad&&_&&!!_.url&&(!_.details||_.details.live)},y.playlistLoaded=function(_,T,g){var E=this,a=T.details,e=T.stats,s=e.loading.end?Math.max(0,self.performance.now()-e.loading.end):0;if(a.advancedDateTime=Date.now()-s,a.live||g!=null&&g.live){if(a.reloaded(g),g&&this.log("live playlist "+_+" "+(a.advanced?"REFRESHED "+a.lastPartSn+"-"+a.lastPartIndex:"MISSED")),g&&a.fragments.length>0&&Object(S.mergeDetails)(g,a),!this.canLoad||!a.live)return;var u,n=void 0,i=void 0;if(a.canBlockReload&&a.endSN&&a.advanced){var t=this.hls.config.lowLatencyMode,l=a.lastPartSn,d=a.endSN,r=a.lastPartIndex,c=r!==-1,f=l===d,o=t?0:r;c?(n=f?d+1:l,i=f?o:r+1):n=d+1;var v=a.age,m=v+a.ageHeader,O=Math.min(m-a.partTarget,a.targetduration*1.5);if(O>0){if(g&&O>g.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+g.tuneInGoal+" to: "+O+" with playlist age: "+a.age),O=0;else{var b=Math.floor(O/a.targetduration);if(n+=b,i!==void 0){var M=Math.round(O%a.targetduration/a.partTarget);i+=M}this.log("CDN Tune-in age: "+a.ageHeader+"s last advanced "+v.toFixed(2)+"s goal: "+O+" skip sn "+b+" to part "+i)}a.tuneInGoal=O}if(u=this.getDeliveryDirectives(a,T.deliveryDirectives,n,i),t||!f){this.loadPlaylist(u);return}}else u=this.getDeliveryDirectives(a,T.deliveryDirectives,n,i);var F=Object(S.computeReloadInterval)(a,e);n!==void 0&&a.canBlockReload&&(F-=a.partTarget||1),this.log("reload live playlist "+_+" in "+Math.round(F)+" ms"),this.timer=self.setTimeout(function(){return E.loadPlaylist(u)},F)}else this.clearTimer()},y.getDeliveryDirectives=function(_,T,g,E){var a=Object(p.getSkipValue)(_,g);return T!=null&&T.skip&&_.deltaUpdateFailed&&(g=T.msn,E=T.part,a=p.HlsSkip.No),new p.HlsUrlParameters(g,E,a)},y.retryLoadingOrFail=function(_){var T=this,g=this.hls.config,E=this.retryCount<g.levelLoadingMaxRetry;if(E){var a;if(this.retryCount++,_.details.indexOf("LoadTimeOut")>-1&&(a=_.context)!==null&&a!==void 0&&a.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+_.details+'"'),this.loadPlaylist();else{var e=Math.min(Math.pow(2,this.retryCount)*g.levelLoadingRetryDelay,g.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return T.loadPlaylist()},e),this.warn("retry playlist loading #"+this.retryCount+" in "+e+' ms after "'+_.details+'"')}}else this.warn('cannot recover from error "'+_.details+'"'),this.clearTimer(),_.fatal=!0;return E},A}()},"./src/controller/base-stream-controller.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"State",function(){return d}),h.d(P,"default",function(){return r});var R=h("./src/polyfills/number.ts"),p=h("./src/task-loop.ts"),S=h("./src/controller/fragment-tracker.ts"),I=h("./src/utils/buffer-helper.ts"),x=h("./src/utils/logger.ts"),L=h("./src/events.ts"),A=h("./src/errors.ts"),y=h("./src/types/transmuxer.ts"),D=h("./src/utils/mp4-tools.ts"),_=h("./src/utils/discontinuities.ts"),T=h("./src/controller/fragment-finders.ts"),g=h("./src/controller/level-helper.ts"),E=h("./src/loader/fragment-loader.ts"),a=h("./src/crypt/decrypter.ts"),e=h("./src/utils/time-ranges.ts"),s=h("./src/types/loader.ts");function u(c,f){for(var o=0;o<f.length;o++){var v=f[o];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(c,v.key,v)}}function n(c,f,o){return f&&u(c.prototype,f),o&&u(c,o),Object.defineProperty(c,"prototype",{writable:!1}),c}function i(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function t(c,f){c.prototype=Object.create(f.prototype),c.prototype.constructor=c,l(c,f)}function l(c,f){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,m){return v.__proto__=m,v},l(c,f)}var d={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},r=function(c){t(f,c);function f(v,m,O){var b;return b=c.call(this)||this,b.hls=void 0,b.fragPrevious=null,b.fragCurrent=null,b.fragmentTracker=void 0,b.transmuxer=null,b._state=d.STOPPED,b.media=null,b.mediaBuffer=null,b.config=void 0,b.bitrateTest=!1,b.lastCurrentTime=0,b.nextLoadPosition=0,b.startPosition=0,b.loadedmetadata=!1,b.fragLoadError=0,b.retryDate=0,b.levels=null,b.fragmentLoader=void 0,b.levelLastLoaded=null,b.startFragRequested=!1,b.decrypter=void 0,b.initPTS=[],b.onvseeking=null,b.onvended=null,b.logPrefix="",b.log=void 0,b.warn=void 0,b.logPrefix=O,b.log=x.logger.log.bind(x.logger,O+":"),b.warn=x.logger.warn.bind(x.logger,O+":"),b.hls=v,b.fragmentLoader=new E.default(v.config),b.fragmentTracker=m,b.config=v.config,b.decrypter=new a.default(v,v.config),v.on(L.Events.KEY_LOADED,b.onKeyLoaded,i(b)),v.on(L.Events.LEVEL_SWITCHING,b.onLevelSwitching,i(b)),b}var o=f.prototype;return o.doTick=function(){this.onTickEnd()},o.onTickEnd=function(){},o.startLoad=function(m){},o.stopLoad=function(){this.fragmentLoader.abort();var m=this.fragCurrent;m&&this.fragmentTracker.removeFragment(m),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=d.STOPPED},o._streamEnded=function(m,O){var b=this.fragCurrent,M=this.fragmentTracker;if(!O.live&&b&&this.media&&b.sn>=O.endSN&&!m.nextStart){var F=O.partList;if(F!=null&&F.length){var w=F[F.length-1],C=I.BufferHelper.isBuffered(this.media,w.start+w.duration/2);return C}var U=M.getState(b);return U===S.FragmentState.PARTIAL||U===S.FragmentState.OK}return!1},o.onMediaAttached=function(m,O){var b=this.media=this.mediaBuffer=O.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),b.addEventListener("seeking",this.onvseeking),b.addEventListener("ended",this.onvended);var M=this.config;this.levels&&M.autoStartLoad&&this.state===d.STOPPED&&this.startLoad(M.startPosition)},o.onMediaDetaching=function(){var m=this.media;m!=null&&m.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),m&&this.onvseeking&&this.onvended&&(m.removeEventListener("seeking",this.onvseeking),m.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},o.onMediaSeeking=function(){var m=this.config,O=this.fragCurrent,b=this.media,M=this.mediaBuffer,F=this.state,w=b?b.currentTime:0,C=I.BufferHelper.bufferInfo(M||b,w,m.maxBufferHole);if(this.log("media seeking to "+(Object(R.isFiniteNumber)(w)?w.toFixed(3):w)+", state: "+F),F===d.ENDED)this.resetLoadingState();else if(O&&!C.len){var U=m.maxFragLookUpTolerance,B=O.start-U,N=O.start+O.duration+U,k=w>N;(w<B||k)&&(k&&O.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),O.loader.abort()),this.resetLoadingState())}b&&(this.lastCurrentTime=w),!this.loadedmetadata&&!C.len&&(this.nextLoadPosition=this.startPosition=w),this.tickImmediate()},o.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},o.onKeyLoaded=function(m,O){if(!(this.state!==d.KEY_LOADING||O.frag!==this.fragCurrent||!this.levels)){this.state=d.IDLE;var b=this.levels[O.frag.level].details;b&&this.loadFragment(O.frag,b,O.frag.start)}},o.onLevelSwitching=function(m,O){this.fragLoadError=0},o.onHandlerDestroying=function(){this.stopLoad(),c.prototype.onHandlerDestroying.call(this)},o.onHandlerDestroyed=function(){this.state=d.STOPPED,this.hls.off(L.Events.KEY_LOADED,this.onKeyLoaded,this),this.hls.off(L.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,c.prototype.onHandlerDestroyed.call(this)},o.loadKey=function(m,O){this.log("Loading key for "+m.sn+" of ["+O.startSN+"-"+O.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+m.level),this.state=d.KEY_LOADING,this.fragCurrent=m,this.hls.trigger(L.Events.KEY_LOADING,{frag:m})},o.loadFragment=function(m,O,b){this._loadFragForPlayback(m,O,b)},o._loadFragForPlayback=function(m,O,b){var M=this,F=function(C){if(M.fragContextChanged(m)){M.warn("Fragment "+m.sn+(C.part?" p: "+C.part.index:"")+" of level "+m.level+" was dropped during download."),M.fragmentTracker.removeFragment(m);return}m.stats.chunkCount++,M._handleFragmentLoadProgress(C)};this._doFragLoad(m,O,b,F).then(function(w){if(!!w){M.fragLoadError=0;var C=M.state;if(M.fragContextChanged(m)){(C===d.FRAG_LOADING||!M.fragCurrent&&C===d.PARSING)&&(M.fragmentTracker.removeFragment(m),M.state=d.IDLE);return}"payload"in w&&(M.log("Loaded fragment "+m.sn+" of level "+m.level),M.hls.trigger(L.Events.FRAG_LOADED,w)),M._handleFragmentLoadComplete(w)}}).catch(function(w){M.state===d.STOPPED||M.state===d.ERROR||(M.warn(w),M.resetFragmentLoading(m))})},o.flushMainBuffer=function(m,O,b){if(b===void 0&&(b=null),!!(m-O)){var M={startOffset:m,endOffset:O,type:b};this.fragLoadError=0,this.hls.trigger(L.Events.BUFFER_FLUSHING,M)}},o._loadInitSegment=function(m){var O=this;this._doFragLoad(m).then(function(b){if(!b||O.fragContextChanged(m)||!O.levels)throw new Error("init load aborted");return b}).then(function(b){var M=O.hls,F=b.payload,w=m.decryptdata;if(F&&F.byteLength>0&&w&&w.key&&w.iv&&w.method==="AES-128"){var C=self.performance.now();return O.decrypter.webCryptoDecrypt(new Uint8Array(F),w.key.buffer,w.iv.buffer).then(function(U){var B=self.performance.now();return M.trigger(L.Events.FRAG_DECRYPTED,{frag:m,payload:U,stats:{tstart:C,tdecrypt:B}}),b.payload=U,b})}return b}).then(function(b){var M=O.fragCurrent,F=O.hls,w=O.levels;if(!w)throw new Error("init load aborted, missing levels");var C=w[m.level].details;console.assert(C,"Level details are defined when init segment is loaded");var U=m.stats;O.state=d.IDLE,O.fragLoadError=0,m.data=new Uint8Array(b.payload),U.parsing.start=U.buffering.start=self.performance.now(),U.parsing.end=U.buffering.end=self.performance.now(),b.frag===M&&F.trigger(L.Events.FRAG_BUFFERED,{stats:U,frag:M,part:null,id:m.type}),O.tick()}).catch(function(b){O.state===d.STOPPED||O.state===d.ERROR||(O.warn(b),O.resetFragmentLoading(m))})},o.fragContextChanged=function(m){var O=this.fragCurrent;return!m||!O||m.level!==O.level||m.sn!==O.sn||m.urlId!==O.urlId},o.fragBufferedComplete=function(m,O){var b=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+m.type+" sn: "+m.sn+(O?" part: "+O.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+m.level+" "+(b?e.default.toString(I.BufferHelper.getBuffered(b)):"(detached)")),this.state=d.IDLE,b&&(!this.loadedmetadata&&b.buffered.length&&this.fragCurrent===this.fragPrevious&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},o.seekToStartPos=function(){},o._handleFragmentLoadComplete=function(m){var O=this.transmuxer;if(!!O){var b=m.frag,M=m.part,F=m.partsLoaded,w=!F||F.length===0||F.some(function(U){return!U}),C=new y.ChunkMetadata(b.level,b.sn,b.stats.chunkCount+1,0,M?M.index:-1,!w);O.flush(C)}},o._handleFragmentLoadProgress=function(m){},o._doFragLoad=function(m,O,b,M){var F=this;if(b===void 0&&(b=null),!this.levels)throw new Error("frag load aborted, missing levels");if(b=Math.max(m.start,b||0),this.config.lowLatencyMode&&O){var w=O.partList;if(w&&M){b>m.end&&O.fragmentHint&&(m=O.fragmentHint);var C=this.getNextPart(w,m,b);if(C>-1){var U=w[C];return this.log("Loading part sn: "+m.sn+" p: "+U.index+" cc: "+m.cc+" of playlist ["+O.startSN+"-"+O.endSN+"] parts [0-"+C+"-"+(w.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+m.level+", target: "+parseFloat(b.toFixed(3))),this.nextLoadPosition=U.start+U.duration,this.state=d.FRAG_LOADING,this.hls.trigger(L.Events.FRAG_LOADING,{frag:m,part:w[C],targetBufferTime:b}),this.doFragPartsLoad(m,w,C,M).catch(function(B){return F.handleFragLoadError(B)})}else if(!m.url||this.loadedEndOfParts(w,b))return Promise.resolve(null)}}return this.log("Loading fragment "+m.sn+" cc: "+m.cc+" "+(O?"of ["+O.startSN+"-"+O.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+m.level+", target: "+parseFloat(b.toFixed(3))),Object(R.isFiniteNumber)(m.sn)&&!this.bitrateTest&&(this.nextLoadPosition=m.start+m.duration),this.state=d.FRAG_LOADING,this.hls.trigger(L.Events.FRAG_LOADING,{frag:m,targetBufferTime:b}),this.fragmentLoader.load(m,M).catch(function(B){return F.handleFragLoadError(B)})},o.doFragPartsLoad=function(m,O,b,M){var F=this;return new Promise(function(w,C){var U=[],B=function N(k){var j=O[k];F.fragmentLoader.loadPart(m,j,M).then(function(H){U[j.index]=H;var V=H.part;F.hls.trigger(L.Events.FRAG_LOADED,H);var Y=O[k+1];if(Y&&Y.fragment===m)N(k+1);else return w({frag:m,part:V,partsLoaded:U})}).catch(C)};B(b)})},o.handleFragLoadError=function(m){var O=m.data;return O&&O.details===A.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(O.frag,O.part):this.hls.trigger(L.Events.ERROR,O),null},o._handleTransmuxerFlush=function(m){var O=this.getCurrentContext(m);if(!O||this.state!==d.PARSING){this.fragCurrent||(this.state=d.IDLE);return}var b=O.frag,M=O.part,F=O.level,w=self.performance.now();b.stats.parsing.end=w,M&&(M.stats.parsing.end=w),this.updateLevelTiming(b,M,F,m.partial)},o.getCurrentContext=function(m){var O=this.levels,b=m.level,M=m.sn,F=m.part;if(!O||!O[b])return this.warn("Levels object was unset while buffering fragment "+M+" of level "+b+". The current chunk will not be buffered."),null;var w=O[b],C=F>-1?Object(g.getPartWith)(w,M,F):null,U=C?C.fragment:Object(g.getFragmentWithSN)(w,M,this.fragCurrent);return U?{frag:U,part:C,level:w}:null},o.bufferFragmentData=function(m,O,b,M){if(!(!m||this.state!==d.PARSING)){var F=m.data1,w=m.data2,C=F;if(F&&w&&(C=Object(D.appendUint8Array)(F,w)),!(!C||!C.length)){var U={type:m.type,frag:O,part:b,chunkMeta:M,parent:O.type,data:C};this.hls.trigger(L.Events.BUFFER_APPENDING,U),m.dropped&&m.independent&&!b&&this.flushBufferGap(O)}}},o.flushBufferGap=function(m){var O=this.media;if(!!O){if(!I.BufferHelper.isBuffered(O,O.currentTime)){this.flushMainBuffer(0,m.start);return}var b=O.currentTime,M=I.BufferHelper.bufferInfo(O,b,0),F=m.duration,w=Math.min(this.config.maxFragLookUpTolerance*2,F*.25),C=Math.max(Math.min(m.start-w,M.end-w),b+w);m.start-C>w&&this.flushMainBuffer(C,m.start)}},o.getFwdBufferInfo=function(m,O){var b=this.config,M=this.getLoadPosition();if(!Object(R.isFiniteNumber)(M))return null;var F=I.BufferHelper.bufferInfo(m,M,b.maxBufferHole);if(F.len===0&&F.nextStart!==void 0){var w=this.fragmentTracker.getBufferedFrag(M,O);if(w&&F.nextStart<w.end)return I.BufferHelper.bufferInfo(m,M,Math.max(F.nextStart,b.maxBufferHole))}return F},o.getMaxBufferLength=function(m){var O=this.config,b;return m?b=Math.max(8*O.maxBufferSize/m,O.maxBufferLength):b=O.maxBufferLength,Math.min(b,O.maxMaxBufferLength)},o.reduceMaxBufferLength=function(m){var O=this.config,b=m||O.maxBufferLength;return O.maxMaxBufferLength>=b?(O.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+O.maxMaxBufferLength+"s"),!0):!1},o.getNextFragment=function(m,O){var b=O.fragments,M=b.length;if(!M)return null;var F=this.config,w=b[0].start,C;if(O.live){var U=F.initialLiveManifestSize;if(M<U)return this.warn("Not enough fragments to start playback (have: "+M+", need: "+U+")"),null;!O.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(C=this.getInitialLiveFragment(O,b),this.startPosition=C?this.hls.liveSyncPosition||C.start:m)}else m<=w&&(C=b[0]);if(!C){var B=F.lowLatencyMode?O.partEnd:O.fragmentEnd;C=this.getFragmentAtPosition(m,B,O)}return this.mapToInitFragWhenRequired(C)},o.mapToInitFragWhenRequired=function(m){return m!=null&&m.initSegment&&!(m!=null&&m.initSegment.data)&&!this.bitrateTest?m.initSegment:m},o.getNextPart=function(m,O,b){for(var M=-1,F=!1,w=!0,C=0,U=m.length;C<U;C++){var B=m[C];if(w=w&&!B.independent,M>-1&&b<B.start)break;var N=B.loaded;!N&&(F||B.independent||w)&&B.fragment===O&&(M=C),F=N}return M},o.loadedEndOfParts=function(m,O){var b=m[m.length-1];return b&&O>b.start&&b.loaded},o.getInitialLiveFragment=function(m,O){var b=this.fragPrevious,M=null;if(b){if(m.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+b.programDateTime),M=Object(T.findFragmentByPDT)(O,b.endProgramDateTime,this.config.maxFragLookUpTolerance)),!M){var F=b.sn+1;if(F>=m.startSN&&F<=m.endSN){var w=O[F-m.startSN];b.cc===w.cc&&(M=w,this.log("Live playlist, switching playlist, load frag with next SN: "+M.sn))}M||(M=Object(T.findFragWithCC)(O,b.cc),M&&this.log("Live playlist, switching playlist, load frag with same CC: "+M.sn))}}else{var C=this.hls.liveSyncPosition;C!==null&&(M=this.getFragmentAtPosition(C,this.bitrateTest?m.fragmentEnd:m.edge,m))}return M},o.getFragmentAtPosition=function(m,O,b){var M=this.config,F=this.fragPrevious,w=b.fragments,C=b.endSN,U=b.fragmentHint,B=M.maxFragLookUpTolerance,N=!!(M.lowLatencyMode&&b.partList&&U);N&&U&&!this.bitrateTest&&(w=w.concat(U),C=U.sn);var k;if(m<O){var j=m>O-B?0:B;k=Object(T.findFragmentByPTS)(F,w,m,j)}else k=w[w.length-1];if(k){var H=k.sn-b.startSN;if(F&&k.sn===F.sn&&!N){var V=F&&k.level===F.level;if(V){var Y=w[H+1];k.sn<C&&this.fragmentTracker.getState(Y)!==S.FragmentState.OK?(this.log("SN "+k.sn+" just loaded, load next one: "+Y.sn),k=Y):k=null}}}return k},o.synchronizeToLiveEdge=function(m){var O=this.config,b=this.media;if(!!b){var M=this.hls.liveSyncPosition,F=b.currentTime,w=m.fragments[0].start,C=m.edge,U=F>=w-O.maxFragLookUpTolerance&&F<=C;if(M!==null&&b.duration>M&&(F<M||!U)){var B=O.liveMaxLatencyDuration!==void 0?O.liveMaxLatencyDuration:O.liveMaxLatencyDurationCount*m.targetduration;(!U&&b.readyState<4||F<C-B)&&(this.loadedmetadata||(this.nextLoadPosition=M),b.readyState&&(this.warn("Playback: "+F.toFixed(3)+" is located too far from the end of live sliding playlist: "+C+", reset currentTime to : "+M.toFixed(3)),b.currentTime=M))}}},o.alignPlaylists=function(m,O){var b=this.levels,M=this.levelLastLoaded,F=this.fragPrevious,w=M!==null?b[M]:null,C=m.fragments.length;if(!C)return this.warn("No fragments in live playlist"),0;var U=m.fragments[0].start,B=!O,N=m.alignedSliding&&Object(R.isFiniteNumber)(U);if(B||!N&&!U){Object(_.alignStream)(F,w,m);var k=m.fragments[0].start;return this.log("Live playlist sliding: "+k.toFixed(2)+" start-sn: "+(O?O.startSN:"na")+"->"+m.startSN+" prev-sn: "+(F?F.sn:"na")+" fragments: "+C),k}return U},o.waitForCdnTuneIn=function(m){var O=3;return m.live&&m.canBlockReload&&m.partTarget&&m.tuneInGoal>Math.max(m.partHoldBack,m.partTarget*O)},o.setStartPosition=function(m,O){var b=this.startPosition;if(b<O&&(b=-1),b===-1||this.lastCurrentTime===-1){var M=m.startTimeOffset;Object(R.isFiniteNumber)(M)?(b=O+M,M<0&&(b+=m.totalduration),b=Math.min(Math.max(O,b),O+m.totalduration),this.log("Start time offset "+M+" found in playlist, adjust startPosition to "+b),this.startPosition=b):m.live?b=this.hls.liveSyncPosition||O:this.startPosition=b=0,this.lastCurrentTime=b}this.nextLoadPosition=b},o.getLoadPosition=function(){var m=this.media,O=0;return this.loadedmetadata&&m?O=m.currentTime:this.nextLoadPosition&&(O=this.nextLoadPosition),O},o.handleFragLoadAborted=function(m,O){this.transmuxer&&m.sn!=="initSegment"&&m.stats.aborted&&(this.warn("Fragment "+m.sn+(O?" part"+O.index:"")+" of level "+m.level+" was aborted"),this.resetFragmentLoading(m))},o.resetFragmentLoading=function(m){(!this.fragCurrent||!this.fragContextChanged(m)&&this.state!==d.FRAG_LOADING_WAITING_RETRY)&&(this.state=d.IDLE)},o.onFragmentOrKeyLoadError=function(m,O){if(!O.fatal){var b=O.frag;if(!(!b||b.type!==m)){var M=this.fragCurrent;console.assert(M&&b.sn===M.sn&&b.level===M.level&&b.urlId===M.urlId,"Frag load error must match current frag to retry");var F=this.config;if(this.fragLoadError+1<=F.fragLoadingMaxRetry){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var w=Math.min(Math.pow(2,this.fragLoadError)*F.fragLoadingRetryDelay,F.fragLoadingMaxRetryTimeout);this.warn("Fragment "+b.sn+" of "+m+" "+b.level+" failed to load, retrying in "+w+"ms"),this.retryDate=self.performance.now()+w,this.fragLoadError++,this.state=d.FRAG_LOADING_WAITING_RETRY}else O.levelRetry?(m===s.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=d.IDLE):(x.logger.error(O.details+" reaches max retry, redispatch as fatal ..."),O.fatal=!0,this.hls.stopLoad(),this.state=d.ERROR)}}},o.afterBufferFlushed=function(m,O,b){if(!!m){var M=I.BufferHelper.getBuffered(m);this.fragmentTracker.detectEvictedFragments(O,M,b),this.state===d.ENDED&&this.resetLoadingState()}},o.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=d.IDLE},o.resetStartWhenNotLoaded=function(m){if(!this.loadedmetadata){this.startFragRequested=!1;var O=this.levels?this.levels[m].details:null;O!=null&&O.live?(this.startPosition=-1,this.setStartPosition(O,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},o.updateLevelTiming=function(m,O,b,M){var F=this,w=b.details;console.assert(!!w,"level.details must be defined");var C=Object.keys(m.elementaryStreams).reduce(function(U,B){var N=m.elementaryStreams[B];if(N){var k=N.endPTS-N.startPTS;if(k<=0)return F.warn("Could not parse fragment "+m.sn+" "+B+" duration reliably ("+k+")"),U||!1;var j=M?0:Object(g.updateFragPTSDTS)(w,m,N.startPTS,N.endPTS,N.startDTS,N.endDTS);return F.hls.trigger(L.Events.LEVEL_PTS_UPDATED,{details:w,level:b,drift:j,type:B,frag:m,start:N.startPTS,end:N.endPTS}),!0}return U},!1);C||(this.warn("Found no media in fragment "+m.sn+" of level "+b.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=d.PARSED,this.hls.trigger(L.Events.FRAG_PARSED,{frag:m,part:O})},o.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},n(f,[{key:"state",get:function(){return this._state},set:function(m){var O=this._state;O!==m&&(this._state=m,this.log(O+"->"+m))}}]),f}(p.default)},"./src/controller/buffer-controller.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return T});var R=h("./src/polyfills/number.ts"),p=h("./src/events.ts"),S=h("./src/utils/logger.ts"),I=h("./src/errors.ts"),x=h("./src/utils/buffer-helper.ts"),L=h("./src/utils/mediasource-helper.ts"),A=h("./src/loader/fragment.ts"),y=h("./src/controller/buffer-operation-queue.ts"),D=Object(L.getMediaSource)(),_=/([ha]vc.)(?:\.[^.,]+)+/,T=function(){function g(a){var e=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var s=e.hls,u=e.media,n=e.mediaSource;S.logger.log("[buffer-controller]: Media source opened"),u&&(e.updateMediaElementDuration(),s.trigger(p.Events.MEDIA_ATTACHED,{media:u})),n&&n.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){S.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){S.logger.log("[buffer-controller]: Media source ended")},this.hls=a,this._initSourceBuffer(),this.registerListeners()}var E=g.prototype;return E.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},E.destroy=function(){this.unregisterListeners(),this.details=null},E.registerListeners=function(){var e=this.hls;e.on(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.Events.BUFFER_RESET,this.onBufferReset,this),e.on(p.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(p.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(p.Events.BUFFER_EOS,this.onBufferEos,this),e.on(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(p.Events.FRAG_PARSED,this.onFragParsed,this),e.on(p.Events.FRAG_CHANGED,this.onFragChanged,this)},E.unregisterListeners=function(){var e=this.hls;e.off(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.Events.BUFFER_RESET,this.onBufferReset,this),e.off(p.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(p.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(p.Events.BUFFER_EOS,this.onBufferEos,this),e.off(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(p.Events.FRAG_PARSED,this.onFragParsed,this),e.off(p.Events.FRAG_CHANGED,this.onFragChanged,this)},E._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new y.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},E.onManifestParsed=function(e,s){var u=2;(s.audio&&!s.video||!s.altAudio)&&(u=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=u,this.details=null,S.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},E.onMediaAttaching=function(e,s){var u=this.media=s.media;if(u&&D){var n=this.mediaSource=new D;n.addEventListener("sourceopen",this._onMediaSourceOpen),n.addEventListener("sourceended",this._onMediaSourceEnded),n.addEventListener("sourceclose",this._onMediaSourceClose),u.src=self.URL.createObjectURL(n),this._objectUrl=u.src}},E.onMediaDetaching=function(){var e=this.media,s=this.mediaSource,u=this._objectUrl;if(s){if(S.logger.log("[buffer-controller]: media source detaching"),s.readyState==="open")try{s.endOfStream()}catch(n){S.logger.warn("[buffer-controller]: onMediaDetaching: "+n.message+" while calling endOfStream")}this.onBufferReset(),s.removeEventListener("sourceopen",this._onMediaSourceOpen),s.removeEventListener("sourceended",this._onMediaSourceEnded),s.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(u&&self.URL.revokeObjectURL(u),e.src===u?(e.removeAttribute("src"),e.load()):S.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(p.Events.MEDIA_DETACHED,void 0)},E.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(s){var u=e.sourceBuffer[s];try{u&&(e.removeBufferListeners(s),e.mediaSource&&e.mediaSource.removeSourceBuffer(u),e.sourceBuffer[s]=void 0)}catch(n){S.logger.warn("[buffer-controller]: Failed to reset the "+s+" buffer",n)}}),this._initSourceBuffer()},E.onBufferCodecs=function(e,s){var u=this,n=this.getSourceBufferTypes().length;Object.keys(s).forEach(function(i){if(n){var t=u.tracks[i];if(t&&typeof t.buffer.changeType=="function"){var l=s[i],d=l.id,r=l.codec,c=l.levelCodec,f=l.container,o=l.metadata,v=(t.levelCodec||t.codec).replace(_,"$1"),m=(c||r).replace(_,"$1");if(v!==m){var O=f+";codecs="+(c||r);u.appendChangeType(i,O),S.logger.log("[buffer-controller]: switching codec "+v+" to "+m),u.tracks[i]={buffer:t.buffer,codec:r,container:f,levelCodec:c,metadata:o,id:d}}}}else u.pendingTracks[i]=s[i]}),!n&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},E.appendChangeType=function(e,s){var u=this,n=this.operationQueue,i={execute:function(){var l=u.sourceBuffer[e];l&&(S.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+s),l.changeType(s)),n.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(l){S.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",l)}};n.append(i,e)},E.onBufferAppending=function(e,s){var u=this,n=this.hls,i=this.operationQueue,t=this.tracks,l=s.data,d=s.type,r=s.frag,c=s.part,f=s.chunkMeta,o=f.buffering[d],v=self.performance.now();o.start=v;var m=r.stats.buffering,O=c?c.stats.buffering:null;m.start===0&&(m.start=v),O&&O.start===0&&(O.start=v);var b=t.audio,M=d==="audio"&&f.id===1&&(b==null?void 0:b.container)==="audio/mpeg",F={execute:function(){if(o.executeStart=self.performance.now(),M){var C=u.sourceBuffer[d];if(C){var U=r.start-C.timestampOffset;Math.abs(U)>=.1&&(S.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+r.start+" (delta: "+U+") sn: "+r.sn+")"),C.timestampOffset=r.start)}}u.appendExecutor(l,d)},onStart:function(){},onComplete:function(){var C=self.performance.now();o.executeEnd=o.end=C,m.first===0&&(m.first=C),O&&O.first===0&&(O.first=C);var U=u.sourceBuffer,B={};for(var N in U)B[N]=x.BufferHelper.getBuffered(U[N]);u.appendError=0,u.hls.trigger(p.Events.BUFFER_APPENDED,{type:d,frag:r,part:c,chunkMeta:f,parent:r.type,timeRanges:B})},onError:function(C){S.logger.error("[buffer-controller]: Error encountered while trying to append to the "+d+" SourceBuffer",C);var U={type:I.ErrorTypes.MEDIA_ERROR,parent:r.type,details:I.ErrorDetails.BUFFER_APPEND_ERROR,err:C,fatal:!1};C.code===DOMException.QUOTA_EXCEEDED_ERR?U.details=I.ErrorDetails.BUFFER_FULL_ERROR:(u.appendError++,U.details=I.ErrorDetails.BUFFER_APPEND_ERROR,u.appendError>n.config.appendErrorMaxRetry&&(S.logger.error("[buffer-controller]: Failed "+n.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),U.fatal=!0,n.stopLoad())),n.trigger(p.Events.ERROR,U)}};i.append(F,d)},E.onBufferFlushing=function(e,s){var u=this,n=this.operationQueue,i=function(l){return{execute:u.removeExecutor.bind(u,l,s.startOffset,s.endOffset),onStart:function(){},onComplete:function(){u.hls.trigger(p.Events.BUFFER_FLUSHED,{type:l})},onError:function(r){S.logger.warn("[buffer-controller]: Failed to remove from "+l+" SourceBuffer",r)}}};s.type?n.append(i(s.type),s.type):this.getSourceBufferTypes().forEach(function(t){n.append(i(t),t)})},E.onFragParsed=function(e,s){var u=this,n=s.frag,i=s.part,t=[],l=i?i.elementaryStreams:n.elementaryStreams;l[A.ElementaryStreamTypes.AUDIOVIDEO]?t.push("audiovideo"):(l[A.ElementaryStreamTypes.AUDIO]&&t.push("audio"),l[A.ElementaryStreamTypes.VIDEO]&&t.push("video"));var d=function(){var c=self.performance.now();n.stats.buffering.end=c,i&&(i.stats.buffering.end=c);var f=i?i.stats:n.stats;u.hls.trigger(p.Events.FRAG_BUFFERED,{frag:n,part:i,stats:f,id:n.type})};t.length===0&&S.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+n.type+" level: "+n.level+" sn: "+n.sn),this.blockBuffers(d,t)},E.onFragChanged=function(e,s){this.flushBackBuffer()},E.onBufferEos=function(e,s){var u=this,n=this.getSourceBufferTypes().reduce(function(i,t){var l=u.sourceBuffer[t];return(!s.type||s.type===t)&&l&&!l.ended&&(l.ended=!0,S.logger.log("[buffer-controller]: "+t+" sourceBuffer now EOS")),i&&!!(!l||l.ended)},!0);n&&this.blockBuffers(function(){var i=u.mediaSource;!i||i.readyState!=="open"||i.endOfStream()})},E.onLevelUpdated=function(e,s){var u=s.details;!u.fragments.length||(this.details=u,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},E.flushBackBuffer=function(){var e=this.hls,s=this.details,u=this.media,n=this.sourceBuffer;if(!(!u||s===null)){var i=this.getSourceBufferTypes();if(!!i.length){var t=s.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(!(!Object(R.isFiniteNumber)(t)||t<0)){var l=u.currentTime,d=s.levelTargetDuration,r=Math.max(t,d),c=Math.floor(l/d)*d-r;i.forEach(function(f){var o=n[f];if(o){var v=x.BufferHelper.getBuffered(o);v.length>0&&c>v.start(0)&&(e.trigger(p.Events.BACK_BUFFER_REACHED,{bufferEnd:c}),s.live&&e.trigger(p.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c}),e.trigger(p.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:f}))}})}}}},E.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var e=this.details,s=this.hls,u=this.media,n=this.mediaSource,i=e.fragments[0].start+e.totalduration,t=u.duration,l=Object(R.isFiniteNumber)(n.duration)?n.duration:0;e.live&&s.config.liveDurationInfinity?(S.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(e)):(i>l&&i>t||!Object(R.isFiniteNumber)(t))&&(S.logger.log("[buffer-controller]: Updating Media Source duration to "+i.toFixed(3)),n.duration=i)}},E.updateSeekableRange=function(e){var s=this.mediaSource,u=e.fragments,n=u.length;if(n&&e.live&&s!==null&&s!==void 0&&s.setLiveSeekableRange){var i=Math.max(0,u[0].start),t=Math.max(i,i+e.totalduration);s.setLiveSeekableRange(i,t)}},E.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,s=this.operationQueue,u=this.pendingTracks,n=Object.keys(u).length;if(n&&!e||n===2){this.createSourceBuffers(u),this.pendingTracks={};var i=this.getSourceBufferTypes();if(i.length===0){this.hls.trigger(p.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}i.forEach(function(t){s.executeNext(t)})}},E.createSourceBuffers=function(e){var s=this.sourceBuffer,u=this.mediaSource;if(!u)throw Error("createSourceBuffers called when mediaSource was null");var n=0;for(var i in e)if(!s[i]){var t=e[i];if(!t)throw Error("source buffer exists for track "+i+", however track does not");var l=t.levelCodec||t.codec,d=t.container+";codecs="+l;S.logger.log("[buffer-controller]: creating sourceBuffer("+d+")");try{var r=s[i]=u.addSourceBuffer(d),c=i;this.addBufferListener(c,"updatestart",this._onSBUpdateStart),this.addBufferListener(c,"updateend",this._onSBUpdateEnd),this.addBufferListener(c,"error",this._onSBUpdateError),this.tracks[i]={buffer:r,codec:l,container:t.container,levelCodec:t.levelCodec,metadata:t.metadata,id:t.id},n++}catch(f){S.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+f.message),this.hls.trigger(p.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:f,mimeType:d})}}n&&this.hls.trigger(p.Events.BUFFER_CREATED,{tracks:this.tracks})},E._onSBUpdateStart=function(e){var s=this.operationQueue,u=s.current(e);u.onStart()},E._onSBUpdateEnd=function(e){var s=this.operationQueue,u=s.current(e);u.onComplete(),s.shiftAndExecuteNext(e)},E._onSBUpdateError=function(e,s){S.logger.error("[buffer-controller]: "+e+" SourceBuffer error",s),this.hls.trigger(p.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var u=this.operationQueue.current(e);u&&u.onError(s)},E.removeExecutor=function(e,s,u){var n=this.media,i=this.mediaSource,t=this.operationQueue,l=this.sourceBuffer,d=l[e];if(!n||!i||!d){S.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),t.shiftAndExecuteNext(e);return}var r=Object(R.isFiniteNumber)(n.duration)?n.duration:1/0,c=Object(R.isFiniteNumber)(i.duration)?i.duration:1/0,f=Math.max(0,s),o=Math.min(u,r,c);o>f?(S.logger.log("[buffer-controller]: Removing ["+f+","+o+"] from the "+e+" SourceBuffer"),console.assert(!d.updating,e+" sourceBuffer must not be updating"),d.remove(f,o)):t.shiftAndExecuteNext(e)},E.appendExecutor=function(e,s){var u=this.operationQueue,n=this.sourceBuffer,i=n[s];if(!i){S.logger.warn("[buffer-controller]: Attempting to append to the "+s+" SourceBuffer, but it does not exist"),u.shiftAndExecuteNext(s);return}i.ended=!1,console.assert(!i.updating,s+" sourceBuffer must not be updating"),i.appendBuffer(e)},E.blockBuffers=function(e,s){var u=this;if(s===void 0&&(s=this.getSourceBufferTypes()),!s.length){S.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}var n=this.operationQueue,i=s.map(function(t){return n.appendBlocker(t)});Promise.all(i).then(function(){e(),s.forEach(function(t){var l=u.sourceBuffer[t];(!l||!l.updating)&&n.shiftAndExecuteNext(t)})})},E.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},E.addBufferListener=function(e,s,u){var n=this.sourceBuffer[e];if(!!n){var i=u.bind(this,e);this.listeners[e].push({event:s,listener:i}),n.addEventListener(s,i)}},E.removeBufferListeners=function(e){var s=this.sourceBuffer[e];!s||this.listeners[e].forEach(function(u){s.removeEventListener(u.event,u.listener)})},g}()},"./src/controller/buffer-operation-queue.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return p});var R=h("./src/utils/logger.ts"),p=function(){function S(x){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=x}var I=S.prototype;return I.append=function(L,A){var y=this.queues[A];y.push(L),y.length===1&&this.buffers[A]&&this.executeNext(A)},I.insertAbort=function(L,A){var y=this.queues[A];y.unshift(L),this.executeNext(A)},I.appendBlocker=function(L){var A,y=new Promise(function(_){A=_}),D={execute:A,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(D,L),y},I.executeNext=function(L){var A=this.buffers,y=this.queues,D=A[L],_=y[L];if(_.length){var T=_[0];try{T.execute()}catch(g){R.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),T.onError(g),(!D||!D.updating)&&(_.shift(),this.executeNext(L))}}},I.shiftAndExecuteNext=function(L){this.queues[L].shift(),this.executeNext(L)},I.current=function(L){return this.queues[L][0]},S}()},"./src/controller/cap-level-controller.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/events.ts");function p(x,L){for(var A=0;A<L.length;A++){var y=L[A];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(x,y.key,y)}}function S(x,L,A){return L&&p(x.prototype,L),A&&p(x,A),Object.defineProperty(x,"prototype",{writable:!1}),x}var I=function(){function x(A){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=A,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var L=x.prototype;return L.setStreamController=function(y){this.streamController=y},L.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},L.registerListeners=function(){var y=this.hls;y.on(R.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.on(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.on(R.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},L.unregisterListener=function(){var y=this.hls;y.off(R.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.off(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.off(R.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},L.onFpsDropLevelCapping=function(y,D){x.isLevelAllowed(D.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(D.droppedLevel)},L.onMediaAttaching=function(y,D){this.media=D.media instanceof HTMLVideoElement?D.media:null},L.onManifestParsed=function(y,D){var _=this.hls;this.restrictedLevels=[],this.firstLevel=D.firstLevel,_.config.capLevelToPlayerSize&&D.video&&this.startCapping()},L.onBufferCodecs=function(y,D){var _=this.hls;_.config.capLevelToPlayerSize&&D.video&&this.startCapping()},L.onMediaDetaching=function(){this.stopCapping()},L.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var y=this.hls.levels;if(y.length){var D=this.hls;D.autoLevelCapping=this.getMaxLevel(y.length-1),D.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=D.autoLevelCapping}}},L.getMaxLevel=function(y){var D=this,_=this.hls.levels;if(!_.length)return-1;var T=_.filter(function(g,E){return x.isLevelAllowed(E,D.restrictedLevels)&&E<=y});return this.clientRect=null,x.getMaxLevelByMediaSize(T,this.mediaWidth,this.mediaHeight)},L.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},L.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},L.getDimensions=function(){if(this.clientRect)return this.clientRect;var y=this.media,D={width:0,height:0};if(y){var _=y.getBoundingClientRect();D.width=_.width,D.height=_.height,!D.width&&!D.height&&(D.width=_.right-_.left||y.width||0,D.height=_.bottom-_.top||y.height||0)}return this.clientRect=D,D},x.isLevelAllowed=function(y,D){return D===void 0&&(D=[]),D.indexOf(y)===-1},x.getMaxLevelByMediaSize=function(y,D,_){if(!y||!y.length)return-1;for(var T=function(s,u){return u?s.width!==u.width||s.height!==u.height:!0},g=y.length-1,E=0;E<y.length;E+=1){var a=y[E];if((a.width>=D||a.height>=_)&&T(a,y[E+1])){g=E;break}}return g},S(x,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var y=1;if(!this.hls.config.ignoreDevicePixelRatio)try{y=self.devicePixelRatio}catch{}return y}}]),x}();P.default=I},"./src/controller/cmcd-controller.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return T});var R=h("./src/events.ts"),p=h("./src/types/cmcd.ts"),S=h("./src/utils/buffer-helper.ts"),I=h("./src/utils/logger.ts");function x(g,E){for(var a=0;a<E.length;a++){var e=E[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(g,e.key,e)}}function L(g,E,a){return E&&x(g.prototype,E),a&&x(g,a),Object.defineProperty(g,"prototype",{writable:!1}),g}function A(g,E){var a=typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(a)return(a=a.call(g)).next.bind(a);if(Array.isArray(g)||(a=y(g))||E&&g&&typeof g.length=="number"){a&&(g=a);var e=0;return function(){return e>=g.length?{done:!0}:{done:!1,value:g[e++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
12
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function y(g,E){if(!!g){if(typeof g=="string")return D(g,E);var a=Object.prototype.toString.call(g).slice(8,-1);if(a==="Object"&&g.constructor&&(a=g.constructor.name),a==="Map"||a==="Set")return Array.from(g);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return D(g,E)}}function D(g,E){(E==null||E>g.length)&&(E=g.length);for(var a=0,e=new Array(E);a<E;a++)e[a]=g[a];return e}function _(){return _=Object.assign?Object.assign.bind():function(g){for(var E=1;E<arguments.length;E++){var a=arguments[E];for(var e in a)Object.prototype.hasOwnProperty.call(a,e)&&(g[e]=a[e])}return g},_.apply(this,arguments)}var T=function(){function g(a){var e=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){e.initialized&&(e.starved=!0),e.buffering=!0},this.onPlaying=function(){e.initialized||(e.initialized=!0),e.buffering=!1},this.applyPlaylistData=function(n){try{e.apply(n,{ot:p.CMCDObjectType.MANIFEST,su:!e.initialized})}catch(i){I.logger.warn("Could not generate manifest CMCD data.",i)}},this.applyFragmentData=function(n){try{var i=n.frag,t=e.hls.levels[i.level],l=e.getObjectType(i),d={d:i.duration*1e3,ot:l};(l===p.CMCDObjectType.VIDEO||l===p.CMCDObjectType.AUDIO||l==p.CMCDObjectType.MUXED)&&(d.br=t.bitrate/1e3,d.tb=e.getTopBandwidth(l)/1e3,d.bl=e.getBufferLength(l)),e.apply(n,d)}catch(r){I.logger.warn("Could not generate segment CMCD data.",r)}},this.hls=a;var s=this.config=a.config,u=s.cmcd;u!=null&&(s.pLoader=this.createPlaylistLoader(),s.fLoader=this.createFragmentLoader(),this.sid=u.sessionId||g.uuid(),this.cid=u.contentId,this.useHeaders=u.useHeaders===!0,this.registerListeners())}var E=g.prototype;return E.registerListeners=function(){var e=this.hls;e.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(R.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(R.Events.BUFFER_CREATED,this.onBufferCreated,this)},E.unregisterListeners=function(){var e=this.hls;e.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(R.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(R.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},E.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},E.onMediaAttached=function(e,s){this.media=s.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},E.onMediaDetached=function(){!this.media||(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},E.onBufferCreated=function(e,s){var u,n;this.audioBuffer=(u=s.tracks.audio)===null||u===void 0?void 0:u.buffer,this.videoBuffer=(n=s.tracks.video)===null||n===void 0?void 0:n.buffer},E.createData=function(){var e;return{v:p.CMCDVersion,sf:p.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)===null||e===void 0?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},E.apply=function(e,s){s===void 0&&(s={}),_(s,this.createData());var u=s.ot===p.CMCDObjectType.INIT||s.ot===p.CMCDObjectType.VIDEO||s.ot===p.CMCDObjectType.MUXED;if(this.starved&&u&&(s.bs=!0,s.su=!0,this.starved=!1),s.su==null&&(s.su=this.buffering),this.useHeaders){var n=g.toHeaders(s);if(!Object.keys(n).length)return;e.headers||(e.headers={}),_(e.headers,n)}else{var i=g.toQuery(s);if(!i)return;e.url=g.appendQueryToUri(e.url,i)}},E.getObjectType=function(e){var s=e.type;if(s==="subtitle")return p.CMCDObjectType.TIMED_TEXT;if(e.sn==="initSegment")return p.CMCDObjectType.INIT;if(s==="audio")return p.CMCDObjectType.AUDIO;if(s==="main")return this.hls.audioTracks.length?p.CMCDObjectType.VIDEO:p.CMCDObjectType.MUXED},E.getTopBandwidth=function(e){var s=0,u,n=this.hls;if(e===p.CMCDObjectType.AUDIO)u=n.audioTracks;else{var i=n.maxAutoLevel,t=i>-1?i+1:n.levels.length;u=n.levels.slice(0,t)}for(var l=A(u),d;!(d=l()).done;){var r=d.value;r.bitrate>s&&(s=r.bitrate)}return s>0?s:NaN},E.getBufferLength=function(e){var s=this.hls.media,u=e===p.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!u||!s)return NaN;var n=S.BufferHelper.bufferInfo(u,s.currentTime,this.config.maxBufferHole);return n.len*1e3},E.createPlaylistLoader=function(){var e=this.config.pLoader,s=this.applyPlaylistData,u=e||this.config.loader;return function(){function n(t){this.loader=void 0,this.loader=new u(t)}var i=n.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(l,d,r){s(l),this.loader.load(l,d,r)},L(n,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),n}()},E.createFragmentLoader=function(){var e=this.config.fLoader,s=this.applyFragmentData,u=e||this.config.loader;return function(){function n(t){this.loader=void 0,this.loader=new u(t)}var i=n.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(l,d,r){s(l),this.loader.load(l,d,r)},L(n,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),n}()},g.uuid=function(){var e=URL.createObjectURL(new Blob),s=e.toString();return URL.revokeObjectURL(e),s.slice(s.lastIndexOf("/")+1)},g.serialize=function(e){for(var s=[],u=function(M){return!Number.isNaN(M)&&M!=null&&M!==""&&M!==!1},n=function(M){return Math.round(M)},i=function(M){return n(M/100)*100},t=function(M){return encodeURIComponent(M)},l={br:n,d:n,bl:i,dl:i,mtp:i,nor:t,rtp:i,tb:n},d=Object.keys(e||{}).sort(),r=A(d),c;!(c=r()).done;){var f=c.value,o=e[f];if(!!u(o)&&!(f==="v"&&o===1)&&!(f=="pr"&&o===1)){var v=l[f];v&&(o=v(o));var m=typeof o,O=void 0;f==="ot"||f==="sf"||f==="st"?O=f+"="+o:m==="boolean"?O=f:m==="number"?O=f+"="+o:O=f+"="+JSON.stringify(o),s.push(O)}}return s.join(",")},g.toHeaders=function(e){for(var s=Object.keys(e),u={},n=["Object","Request","Session","Status"],i=[{},{},{},{}],t={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},l=0,d=s;l<d.length;l++){var r=d[l],c=t[r]!=null?t[r]:1;i[c][r]=e[r]}for(var f=0;f<i.length;f++){var o=g.serialize(i[f]);o&&(u["CMCD-"+n[f]]=o)}return u},g.toQuery=function(e){return"CMCD="+encodeURIComponent(g.serialize(e))},g.appendQueryToUri=function(e,s){if(!s)return e;var u=e.includes("?")?"&":"?";return""+e+u+s},g}()},"./src/controller/eme-controller.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/events.ts"),p=h("./src/errors.ts"),S=h("./src/utils/logger.ts"),I=h("./src/utils/mediakeys-helper.ts");function x(T,g){for(var E=0;E<g.length;E++){var a=g[E];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(T,a.key,a)}}function L(T,g,E){return g&&x(T.prototype,g),E&&x(T,E),Object.defineProperty(T,"prototype",{writable:!1}),T}var A=3,y=function(g,E,a){var e={audioCapabilities:[],videoCapabilities:[]};return g.forEach(function(s){e.audioCapabilities.push({contentType:'audio/mp4; codecs="'+s+'"',robustness:a.audioRobustness||""})}),E.forEach(function(s){e.videoCapabilities.push({contentType:'video/mp4; codecs="'+s+'"',robustness:a.videoRobustness||""})}),[e]},D=function(g,E,a,e){switch(g){case I.KeySystems.WIDEVINE:return y(E,a,e);default:throw new Error("Unknown key-system: "+g)}},_=function(){function T(E){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=E,this._config=E.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var g=T.prototype;return g.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},g._registerListeners=function(){this.hls.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(R.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this)},g._unregisterListeners=function(){this.hls.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(R.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this)},g.getLicenseServerUrl=function(a){switch(a){case I.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+a+'"')},g._attemptKeySystemAccess=function(a,e,s){var u=this,n=D(a,e,s,this._drmSystemOptions);S.logger.log("Requesting encrypted media key-system access");var i=this.requestMediaKeySystemAccess(a,n);this.mediaKeysPromise=i.then(function(t){return u._onMediaKeySystemAccessObtained(a,t)}),i.catch(function(t){S.logger.error('Failed to obtain key-system "'+a+'" access:',t)})},g._onMediaKeySystemAccessObtained=function(a,e){var s=this;S.logger.log('Access for key-system "'+a+'" obtained');var u={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:e,mediaKeySystemDomain:a};this._mediaKeysList.push(u);var n=Promise.resolve().then(function(){return e.createMediaKeys()}).then(function(i){return u.mediaKeys=i,S.logger.log('Media-keys created for key-system "'+a+'"'),s._onMediaKeysCreated(),i});return n.catch(function(i){S.logger.error("Failed to create media-keys:",i)}),n},g._onMediaKeysCreated=function(){var a=this;this._mediaKeysList.forEach(function(e){e.mediaKeysSession||(e.mediaKeysSession=e.mediaKeys.createSession(),a._onNewMediaKeySession(e.mediaKeysSession))})},g._onNewMediaKeySession=function(a){var e=this;S.logger.log("New key-system session "+a.sessionId),a.addEventListener("message",function(s){e._onKeySessionMessage(a,s.message)},!1)},g._onKeySessionMessage=function(a,e){S.logger.log("Got EME message event, creating license request"),this._requestLicense(e,function(s){S.logger.log("Received license data (length: "+(s&&s.byteLength)+"), updating key-session"),a.update(s).catch(function(u){S.logger.warn("Updating key-session failed: "+u)})})},g.onMediaEncrypted=function(a){var e=this;if(S.logger.log('Media is encrypted using "'+a.initDataType+'" init data type'),!this.mediaKeysPromise){S.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var s=function(n){!e._media||(e._attemptSetMediaKeys(n),e._generateRequestWithPreferredKeySession(a.initDataType,a.initData))};this.mediaKeysPromise.then(s).catch(s)},g._attemptSetMediaKeys=function(a){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var e=this._mediaKeysList[0];if(!e||!e.mediaKeys){S.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}S.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}},g._generateRequestWithPreferredKeySession=function(a,e){var s=this,u=this._mediaKeysList[0];if(!u){S.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(u.mediaKeysSessionInitialized){S.logger.warn("Key-Session already initialized but requested again");return}var n=u.mediaKeysSession;if(!n){S.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!e){S.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}S.logger.log('Generating key-session request for "'+a+'" init data type'),u.mediaKeysSessionInitialized=!0,n.generateRequest(a,e).then(function(){S.logger.debug("Key-session generation succeeded")}).catch(function(i){S.logger.error("Error generating key-session request:",i),s.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},g._createLicenseXhr=function(a,e,s){var u=new XMLHttpRequest;u.responseType="arraybuffer",u.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,u,a,e,s);var n=this._licenseXhrSetup;if(n)try{n.call(this.hls,u,a),n=void 0}catch(i){S.logger.error(i)}try{u.readyState||u.open("POST",a,!0),n&&n.call(this.hls,u,a)}catch(i){throw new Error("issue setting up KeySystem license XHR "+i)}return u},g._onLicenseRequestReadyStageChange=function(a,e,s,u){switch(a.readyState){case 4:if(a.status===200){this._requestLicenseFailureCount=0,S.logger.log("License request succeeded");var n=a.response,i=this._licenseResponseCallback;if(i)try{n=i.call(this.hls,a,e)}catch(l){S.logger.error(l)}u(n)}else{if(S.logger.error("License Request XHR failed ("+e+"). Status: "+a.status+" ("+a.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>A){this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var t=A-this._requestLicenseFailureCount+1;S.logger.warn("Retrying license request, "+t+" attempts left"),this._requestLicense(s,u)}break}},g._generateLicenseRequestChallenge=function(a,e){switch(a.mediaKeySystemDomain){case I.KeySystems.WIDEVINE:return e}throw new Error("unsupported key-system: "+a.mediaKeySystemDomain)},g._requestLicense=function(a,e){S.logger.log("Requesting content license for key-system");var s=this._mediaKeysList[0];if(!s){S.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var u=this.getLicenseServerUrl(s.mediaKeySystemDomain),n=this._createLicenseXhr(u,a,e);S.logger.log("Sending license request to URL: "+u);var i=this._generateLicenseRequestChallenge(s,a);n.send(i)}catch(t){S.logger.error("Failure requesting DRM license: "+t),this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},g.onMediaAttached=function(a,e){if(!!this._emeEnabled){var s=e.media;this._media=s,s.addEventListener("encrypted",this._onMediaEncrypted)}},g.onMediaDetached=function(){var a=this._media,e=this._mediaKeysList;!a||(a.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(e.map(function(s){if(s.mediaKeysSession)return s.mediaKeysSession.close().catch(function(){})})).then(function(){return a.setMediaKeys(null)}).catch(function(){}))},g.onManifestParsed=function(a,e){if(!!this._emeEnabled){var s=e.levels.map(function(n){return n.audioCodec}).filter(function(n){return!!n}),u=e.levels.map(function(n){return n.videoCodec}).filter(function(n){return!!n});this._attemptKeySystemAccess(I.KeySystems.WIDEVINE,s,u)}},L(T,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),T}();P.default=_},"./src/controller/fps-controller.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/events.ts"),p=h("./src/utils/logger.ts"),S=function(){function I(L){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=L,this.registerListeners()}var x=I.prototype;return x.setStreamController=function(A){this.streamController=A},x.registerListeners=function(){this.hls.on(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},x.unregisterListeners=function(){this.hls.off(R.Events.MEDIA_ATTACHING,this.onMediaAttaching)},x.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},x.onMediaAttaching=function(A,y){var D=this.hls.config;if(D.capLevelOnFPSDrop){var _=y.media instanceof self.HTMLVideoElement?y.media:null;this.media=_,_&&typeof _.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),D.fpsDroppedMonitoringPeriod)}},x.checkFPS=function(A,y,D){var _=performance.now();if(y){if(this.lastTime){var T=_-this.lastTime,g=D-this.lastDroppedFrames,E=y-this.lastDecodedFrames,a=1e3*g/T,e=this.hls;if(e.trigger(R.Events.FPS_DROP,{currentDropped:g,currentDecoded:E,totalDroppedFrames:D}),a>0&&g>e.config.fpsDroppedMonitoringThreshold*E){var s=e.currentLevel;p.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+s),s>0&&(e.autoLevelCapping===-1||e.autoLevelCapping>=s)&&(s=s-1,e.trigger(R.Events.FPS_DROP_LEVEL_CAPPING,{level:s,droppedLevel:e.currentLevel}),e.autoLevelCapping=s,this.streamController.nextLevelSwitch())}}this.lastTime=_,this.lastDroppedFrames=D,this.lastDecodedFrames=y}},x.checkFPSInterval=function(){var A=this.media;if(A)if(this.isVideoPlaybackQualityAvailable){var y=A.getVideoPlaybackQuality();this.checkFPS(A,y.totalVideoFrames,y.droppedVideoFrames)}else this.checkFPS(A,A.webkitDecodedFrameCount,A.webkitDroppedFrameCount)},I}();P.default=S},"./src/controller/fragment-finders.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"findFragmentByPDT",function(){return S}),h.d(P,"findFragmentByPTS",function(){return I}),h.d(P,"fragmentWithinToleranceTest",function(){return x}),h.d(P,"pdtWithinToleranceTest",function(){return L}),h.d(P,"findFragWithCC",function(){return A});var R=h("./src/polyfills/number.ts"),p=h("./src/utils/binary-search.ts");function S(y,D,_){if(D===null||!Array.isArray(y)||!y.length||!Object(R.isFiniteNumber)(D))return null;var T=y[0].programDateTime;if(D<(T||0))return null;var g=y[y.length-1].endProgramDateTime;if(D>=(g||0))return null;_=_||0;for(var E=0;E<y.length;++E){var a=y[E];if(L(D,_,a))return a}return null}function I(y,D,_,T){_===void 0&&(_=0),T===void 0&&(T=0);var g=null;if(y?g=D[y.sn-D[0].sn+1]||null:_===0&&D[0].start===0&&(g=D[0]),g&&x(_,T,g)===0)return g;var E=p.default.search(D,x.bind(null,_,T));return E||g}function x(y,D,_){y===void 0&&(y=0),D===void 0&&(D=0);var T=Math.min(D,_.duration+(_.deltaPTS?_.deltaPTS:0));return _.start+_.duration-T<=y?1:_.start-T>y&&_.start?-1:0}function L(y,D,_){var T=Math.min(D,_.duration+(_.deltaPTS?_.deltaPTS:0))*1e3,g=_.endProgramDateTime||0;return g-T>y}function A(y,D){return p.default.search(y,function(_){return _.cc<D?1:_.cc>D?-1:0})}},"./src/controller/fragment-tracker.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"FragmentState",function(){return S}),h.d(P,"FragmentTracker",function(){return I});var R=h("./src/events.ts"),p=h("./src/types/loader.ts"),S;(function(A){A.NOT_LOADED="NOT_LOADED",A.APPENDING="APPENDING",A.PARTIAL="PARTIAL",A.OK="OK"})(S||(S={}));var I=function(){function A(D){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=D,this._registerListeners()}var y=A.prototype;return y._registerListeners=function(){var _=this.hls;_.on(R.Events.BUFFER_APPENDED,this.onBufferAppended,this),_.on(R.Events.FRAG_BUFFERED,this.onFragBuffered,this),_.on(R.Events.FRAG_LOADED,this.onFragLoaded,this)},y._unregisterListeners=function(){var _=this.hls;_.off(R.Events.BUFFER_APPENDED,this.onBufferAppended,this),_.off(R.Events.FRAG_BUFFERED,this.onFragBuffered,this),_.off(R.Events.FRAG_LOADED,this.onFragLoaded,this)},y.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},y.getAppendedFrag=function(_,T){if(T===p.PlaylistLevelType.MAIN){var g=this.activeFragment,E=this.activeParts;if(!g)return null;if(E)for(var a=E.length;a--;){var e=E[a],s=e?e.end:g.appendedPTS;if(e.start<=_&&s!==void 0&&_<=s)return a>9&&(this.activeParts=E.slice(a-9)),e}else if(g.start<=_&&g.appendedPTS!==void 0&&_<=g.appendedPTS)return g}return this.getBufferedFrag(_,T)},y.getBufferedFrag=function(_,T){for(var g=this.fragments,E=Object.keys(g),a=E.length;a--;){var e=g[E[a]];if((e==null?void 0:e.body.type)===T&&e.buffered){var s=e.body;if(s.start<=_&&_<=s.end)return s}}return null},y.detectEvictedFragments=function(_,T,g){var E=this;Object.keys(this.fragments).forEach(function(a){var e=E.fragments[a];if(!!e){if(!e.buffered){e.body.type===g&&E.removeFragment(e.body);return}var s=e.range[_];!s||s.time.some(function(u){var n=!E.isTimeBuffered(u.startPTS,u.endPTS,T);return n&&E.removeFragment(e.body),n})}})},y.detectPartialFragments=function(_){var T=this,g=this.timeRanges,E=_.frag,a=_.part;if(!(!g||E.sn==="initSegment")){var e=L(E),s=this.fragments[e];!s||(Object.keys(g).forEach(function(u){var n=E.elementaryStreams[u];if(!!n){var i=g[u],t=a!==null||n.partial===!0;s.range[u]=T.getBufferedTimes(E,a,t,i)}}),s.loaded=null,Object.keys(s.range).length?s.buffered=!0:this.removeFragment(s.body))}},y.fragBuffered=function(_){var T=L(_),g=this.fragments[T];g&&(g.loaded=null,g.buffered=!0)},y.getBufferedTimes=function(_,T,g,E){for(var a={time:[],partial:g},e=T?T.start:_.start,s=T?T.end:_.end,u=_.minEndPTS||s,n=_.maxStartPTS||e,i=0;i<E.length;i++){var t=E.start(i)-this.bufferPadding,l=E.end(i)+this.bufferPadding;if(n>=t&&u<=l){a.time.push({startPTS:Math.max(e,E.start(i)),endPTS:Math.min(s,E.end(i))});break}else if(e<l&&s>t)a.partial=!0,a.time.push({startPTS:Math.max(e,E.start(i)),endPTS:Math.min(s,E.end(i))});else if(s<=t)break}return a},y.getPartialFragment=function(_){var T=null,g,E,a,e=0,s=this.bufferPadding,u=this.fragments;return Object.keys(u).forEach(function(n){var i=u[n];!i||x(i)&&(E=i.body.start-s,a=i.body.end+s,_>=E&&_<=a&&(g=Math.min(_-E,a-_),e<=g&&(T=i.body,e=g)))}),T},y.getState=function(_){var T=L(_),g=this.fragments[T];return g?g.buffered?x(g)?S.PARTIAL:S.OK:S.APPENDING:S.NOT_LOADED},y.isTimeBuffered=function(_,T,g){for(var E,a,e=0;e<g.length;e++){if(E=g.start(e)-this.bufferPadding,a=g.end(e)+this.bufferPadding,_>=E&&T<=a)return!0;if(T<=E)return!1}return!1},y.onFragLoaded=function(_,T){var g=T.frag,E=T.part;if(!(g.sn==="initSegment"||g.bitrateTest||E)){var a=L(g);this.fragments[a]={body:g,loaded:T,buffered:!1,range:Object.create(null)}}},y.onBufferAppended=function(_,T){var g=this,E=T.frag,a=T.part,e=T.timeRanges;if(E.type===p.PlaylistLevelType.MAIN)if(this.activeFragment=E,a){var s=this.activeParts;s||(this.activeParts=s=[]),s.push(a)}else this.activeParts=null;this.timeRanges=e,Object.keys(e).forEach(function(u){var n=e[u];if(g.detectEvictedFragments(u,n),!a)for(var i=0;i<n.length;i++)E.appendedPTS=Math.max(n.end(i),E.appendedPTS||0)})},y.onFragBuffered=function(_,T){this.detectPartialFragments(T)},y.hasFragment=function(_){var T=L(_);return!!this.fragments[T]},y.removeFragmentsInRange=function(_,T,g){var E=this;Object.keys(this.fragments).forEach(function(a){var e=E.fragments[a];if(!!e&&e.buffered){var s=e.body;s.type===g&&s.start<T&&s.end>_&&E.removeFragment(s)}})},y.removeFragment=function(_){var T=L(_);_.stats.loaded=0,_.clearElementaryStreamInfo(),delete this.fragments[T]},y.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},A}();function x(A){var y,D;return A.buffered&&(((y=A.range.video)===null||y===void 0?void 0:y.partial)||((D=A.range.audio)===null||D===void 0?void 0:D.partial))}function L(A){return A.type+"_"+A.level+"_"+A.urlId+"_"+A.sn}},"./src/controller/gap-controller.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"STALL_MINIMUM_DURATION_MS",function(){return x}),h.d(P,"MAX_START_GAP_JUMP",function(){return L}),h.d(P,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return A}),h.d(P,"SKIP_BUFFER_RANGE_START",function(){return y}),h.d(P,"default",function(){return D});var R=h("./src/utils/buffer-helper.ts"),p=h("./src/errors.ts"),S=h("./src/events.ts"),I=h("./src/utils/logger.ts"),x=250,L=2,A=.1,y=.05,D=function(){function _(g,E,a,e){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=g,this.media=E,this.fragmentTracker=a,this.hls=e}var T=_.prototype;return T.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},T.poll=function(E,a){var e=this.config,s=this.media,u=this.stalled;if(s!==null){var n=s.currentTime,i=s.seeking,t=this.seeking&&!i,l=!this.seeking&&i;if(this.seeking=i,n!==E){if(this.moved=!0,u!==null){if(this.stallReported){var d=self.performance.now()-u;I.logger.warn("playback not stuck anymore @"+n+", after "+Math.round(d)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((l||t)&&(this.stalled=null),!(s.paused&&!i||s.ended||s.playbackRate===0||!R.BufferHelper.getBuffered(s).length)){var r=R.BufferHelper.bufferInfo(s,n,0),c=r.len>0,f=r.nextStart||0;if(!(!c&&!f)){if(i){var o=r.len>L,v=!f||a&&a.start<=n||f-n>L&&!this.fragmentTracker.getPartialFragment(n);if(o||v)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var m,O=Math.max(f,r.start||0)-n,b=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,M=b==null||(m=b.details)===null||m===void 0?void 0:m.live,F=M?b.details.targetduration*2:L;if(O>0&&O<=F){this._trySkipBufferHole(null);return}}var w=self.performance.now();if(u===null){this.stalled=w;return}var C=w-u;if(!(!i&&C>=x&&(this._reportStall(r),!this.media))){var U=R.BufferHelper.bufferInfo(s,n,e.maxBufferHole);this._tryFixBufferStall(U,C)}}}}},T._tryFixBufferStall=function(E,a){var e=this.config,s=this.fragmentTracker,u=this.media;if(u!==null){var n=u.currentTime,i=s.getPartialFragment(n);if(i){var t=this._trySkipBufferHole(i);if(t||!this.media)return}E.len>e.maxBufferHole&&a>e.highBufferWatchdogPeriod*1e3&&(I.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},T._reportStall=function(E){var a=this.hls,e=this.media,s=this.stallReported;!s&&e&&(this.stallReported=!0,I.logger.warn("Playback stalling at @"+e.currentTime+" due to low buffer ("+JSON.stringify(E)+")"),a.trigger(S.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:E.len}))},T._trySkipBufferHole=function(E){var a=this.config,e=this.hls,s=this.media;if(s===null)return 0;for(var u=s.currentTime,n=0,i=R.BufferHelper.getBuffered(s),t=0;t<i.length;t++){var l=i.start(t);if(u+a.maxBufferHole>=n&&u<l){var d=Math.max(l+y,s.currentTime+A);return I.logger.warn("skipping hole, adjusting currentTime from "+u+" to "+d),this.moved=!0,this.stalled=null,s.currentTime=d,E&&e.trigger(S.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+u+" to "+d,frag:E}),d}n=i.end(t)}return 0},T._tryNudgeBuffer=function(){var E=this.config,a=this.hls,e=this.media,s=this.nudgeRetry;if(e!==null){var u=e.currentTime;if(this.nudgeRetry++,s<E.nudgeMaxRetry){var n=u+(s+1)*E.nudgeOffset;I.logger.warn("Nudging 'currentTime' from "+u+" to "+n),e.currentTime=n,a.trigger(S.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else I.logger.error("Playhead still not moving while enough data buffered @"+u+" after "+E.nudgeMaxRetry+" nudges"),a.trigger(S.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},_}()},"./src/controller/id3-track-controller.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/polyfills/number.ts"),p=h("./src/events.ts"),S=h("./src/utils/texttrack-utils.ts"),I=h("./src/demux/id3.ts"),x=h("./src/loader/date-range.ts"),L=h("./src/types/demuxer.ts"),A=.25;function y(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}function D(g,E){return g.getTime()/1e3-E}function _(g){return Uint8Array.from(g.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var T=function(){function g(a){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=a,this._registerListeners()}var E=g.prototype;return E.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},E._registerListeners=function(){var e=this.hls;e.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},E._unregisterListeners=function(){var e=this.hls;e.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},E.onMediaAttached=function(e,s){this.media=s.media},E.onMediaDetaching=function(){!this.id3Track||(Object(S.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},E.onManifestLoading=function(){this.dateRangeCuesAppended={}},E.createTrack=function(e){var s=this.getID3Track(e.textTracks);return s.mode="hidden",s},E.getID3Track=function(e){if(!!this.media){for(var s=0;s<e.length;s++){var u=e[s];if(u.kind==="metadata"&&u.label==="id3")return Object(S.sendAddTrackEvent)(u,this.media),u}return this.media.addTextTrack("metadata","id3")}},E.onFragParsingMetadata=function(e,s){if(!!this.media){var u=this.hls.config,n=u.enableEmsgMetadataCues,i=u.enableID3MetadataCues;if(!(!n&&!i)){var t=s.frag,l=s.samples,d=s.details;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var r=d.edge||t.end,c=y(),f=!1,o={},v=0;v<l.length;v++){var m=l[v].type;if(!(m===L.MetadataSchema.emsg&&!n||!i)){var O=I.getID3Frames(l[v].data);if(O){var b=l[v].pts,M=r,F=M-b;F<=0&&(M=b+A);for(var w=0;w<O.length;w++){var C=O[w];if(!I.isTimeStampFrame(C)){var U=new c(b,M,"");U.value=C,m&&(U.type=m),this.id3Track.addCue(U),o[C.key]=null,f=!0}}}}}f&&this.updateId3CueEnds(o)}}},E.updateId3CueEnds=function(e){var s,u=(s=this.id3Track)===null||s===void 0?void 0:s.cues;if(u)for(var n=u.length;n--;){var i,t=u[n],l=(i=t.value)===null||i===void 0?void 0:i.key;if(l&&l in e){var d=e[l];d&&t.endTime!==d&&(t.endTime=d),e[l]=t.startTime}}},E.onBufferFlushing=function(e,s){var u=s.startOffset,n=s.endOffset,i=s.type,t=this.id3Track,l=this.hls;if(!!l){var d=l.config,r=d.enableEmsgMetadataCues,c=d.enableID3MetadataCues;if(t&&(r||c)){var f;i==="audio"?f=function(v){return v.type===L.MetadataSchema.audioId3&&c}:i==="video"?f=function(v){return v.type===L.MetadataSchema.emsg&&r}:f=function(v){return v.type===L.MetadataSchema.audioId3&&c||v.type===L.MetadataSchema.emsg&&r},Object(S.removeCuesInRange)(t,u,n,f)}}},E.onLevelUpdated=function(e,s){var u=this,n=s.details;if(!(!this.media||!n.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var i=this.dateRangeCuesAppended,t=this.id3Track,l=n.dateRanges,d=Object.keys(l);if(t)for(var r=Object.keys(i).filter(function(F){return!d.includes(F)}),c=function(w){var C=r[w];Object.keys(i[C].cues).forEach(function(U){t.removeCue(i[C].cues[U])}),delete i[C]},f=r.length;f--;)c(f);var o=n.fragments[n.fragments.length-1];if(!(d.length===0||!Object(R.isFiniteNumber)(o==null?void 0:o.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var v=o.programDateTime/1e3-o.start,m=n.edge||o.end,O=y(),b=function(w){var C=d[w],U=l[C],B=i[C],N=(B==null?void 0:B.cues)||{},k=(B==null?void 0:B.durationKnown)||!1,j=D(U.startDate,v),H=m,V=U.endDate;if(V)H=D(V,v),k=!0;else if(U.endOnNext&&!k){var Y=d.reduce(function(X,le){var ne=l[le];return ne.class===U.class&&ne.id!==le&&ne.startDate>U.startDate&&X.push(ne),X},[]).sort(function(X,le){return X.startDate.getTime()-le.startDate.getTime()})[0];Y&&(H=D(Y.startDate,v),k=!0)}for(var Q=Object.keys(U.attr),J=0;J<Q.length;J++){var z=Q[J];if(!(z===x.DateRangeAttribute.ID||z===x.DateRangeAttribute.CLASS||z===x.DateRangeAttribute.START_DATE||z===x.DateRangeAttribute.DURATION||z===x.DateRangeAttribute.END_DATE||z===x.DateRangeAttribute.END_ON_NEXT)){var q=N[z];if(q)k&&!B.durationKnown&&(q.endTime=H);else{var re=U.attr[z];q=new O(j,H,""),(z===x.DateRangeAttribute.SCTE35_OUT||z===x.DateRangeAttribute.SCTE35_IN)&&(re=_(re)),q.value={key:z,data:re},q.type=L.MetadataSchema.dateRange,u.id3Track.addCue(q),N[z]=q}}}i[C]={cues:N,dateRange:U,durationKnown:k}},M=0;M<d.length;M++)b(M)}}},g}();P.default=T},"./src/controller/latency-controller.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return L});var R=h("./src/errors.ts"),p=h("./src/events.ts"),S=h("./src/utils/logger.ts");function I(A,y){for(var D=0;D<y.length;D++){var _=y[D];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(A,_.key,_)}}function x(A,y,D){return y&&I(A.prototype,y),D&&I(A,D),Object.defineProperty(A,"prototype",{writable:!1}),A}var L=function(){function A(D){var _=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return _.timeupdate()},this.hls=D,this.config=D.config,this.registerListeners()}var y=A.prototype;return y.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},y.registerListeners=function(){this.hls.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(p.Events.ERROR,this.onError,this)},y.unregisterListeners=function(){this.hls.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(p.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(p.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(p.Events.ERROR,this.onError)},y.onMediaAttached=function(_,T){this.media=T.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},y.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},y.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},y.onLevelUpdated=function(_,T){var g=T.details;this.levelDetails=g,g.advanced&&this.timeupdate(),!g.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},y.onError=function(_,T){T.details===R.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,S.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},y.timeupdate=function(){var _=this.media,T=this.levelDetails;if(!(!_||!T)){this.currentTime=_.currentTime;var g=this.computeLatency();if(g!==null){this._latency=g;var E=this.config,a=E.lowLatencyMode,e=E.maxLiveSyncPlaybackRate;if(!(!a||e===1)){var s=this.targetLatency;if(s!==null){var u=g-s,n=Math.min(this.maxLatency,s+T.targetduration),i=u<n;if(T.live&&i&&u>.05&&this.forwardBufferLength>1){var t=Math.min(2,Math.max(1,e)),l=Math.round(2/(1+Math.exp(-.75*u-this.edgeStalled))*20)/20;_.playbackRate=Math.min(t,Math.max(1,l))}else _.playbackRate!==1&&_.playbackRate!==0&&(_.playbackRate=1)}}}}},y.estimateLiveEdge=function(){var _=this.levelDetails;return _===null?null:_.edge+_.age},y.computeLatency=function(){var _=this.estimateLiveEdge();return _===null?null:_-this.currentTime},x(A,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var _=this.config,T=this.levelDetails;return _.liveMaxLatencyDuration!==void 0?_.liveMaxLatencyDuration:T?_.liveMaxLatencyDurationCount*T.targetduration:0}},{key:"targetLatency",get:function(){var _=this.levelDetails;if(_===null)return null;var T=_.holdBack,g=_.partHoldBack,E=_.targetduration,a=this.config,e=a.liveSyncDuration,s=a.liveSyncDurationCount,u=a.lowLatencyMode,n=this.hls.userConfig,i=u&&g||T;(n.liveSyncDuration||n.liveSyncDurationCount||i===0)&&(i=e!==void 0?e:s*E);var t=E,l=1;return i+Math.min(this.stallCount*l,t)}},{key:"liveSyncPosition",get:function(){var _=this.estimateLiveEdge(),T=this.targetLatency,g=this.levelDetails;if(_===null||T===null||g===null)return null;var E=g.edge,a=_-T-this.edgeStalled,e=E-g.totalduration,s=E-(this.config.lowLatencyMode&&g.partTarget||g.targetduration);return Math.min(Math.max(e,a),s)}},{key:"drift",get:function(){var _=this.levelDetails;return _===null?1:_.drift}},{key:"edgeStalled",get:function(){var _=this.levelDetails;if(_===null)return 0;var T=(this.config.lowLatencyMode&&_.partTarget||_.targetduration)*3;return Math.max(_.age-T,0)}},{key:"forwardBufferLength",get:function(){var _=this.media,T=this.levelDetails;if(!_||!T)return 0;var g=_.buffered.length;return(g?_.buffered.end(g-1):T.edge)-this.currentTime}}]),A}()},"./src/controller/level-controller.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return a});var R=h("./src/types/level.ts"),p=h("./src/events.ts"),S=h("./src/errors.ts"),I=h("./src/utils/codecs.ts"),x=h("./src/controller/level-helper.ts"),L=h("./src/controller/base-playlist-controller.ts"),A=h("./src/types/loader.ts");function y(){return y=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var u=arguments[s];for(var n in u)Object.prototype.hasOwnProperty.call(u,n)&&(e[n]=u[n])}return e},y.apply(this,arguments)}function D(e,s){for(var u=0;u<s.length;u++){var n=s[u];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _(e,s,u){return s&&D(e.prototype,s),u&&D(e,u),Object.defineProperty(e,"prototype",{writable:!1}),e}function T(e,s){e.prototype=Object.create(s.prototype),e.prototype.constructor=e,g(e,s)}function g(e,s){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},g(e,s)}var E=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),a=function(e){T(s,e);function s(n){var i;return i=e.call(this,n,"[level-controller]")||this,i._levels=[],i._firstLevel=-1,i._startLevel=void 0,i.currentLevelIndex=-1,i.manualLevelIndex=-1,i.onParsedComplete=void 0,i._registerListeners(),i}var u=s.prototype;return u._registerListeners=function(){var i=this.hls;i.on(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.on(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.on(p.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.on(p.Events.FRAG_LOADED,this.onFragLoaded,this),i.on(p.Events.ERROR,this.onError,this)},u._unregisterListeners=function(){var i=this.hls;i.off(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.off(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.off(p.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.off(p.Events.FRAG_LOADED,this.onFragLoaded,this),i.off(p.Events.ERROR,this.onError,this)},u.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,e.prototype.destroy.call(this)},u.startLoad=function(){var i=this._levels;i.forEach(function(t){t.loadError=0}),e.prototype.startLoad.call(this)},u.onManifestLoaded=function(i,t){var l=[],d=[],r=[],c,f={},o,v=!1,m=!1,O=!1;if(t.levels.forEach(function(w){var C=w.attrs;v=v||!!(w.width&&w.height),m=m||!!w.videoCodec,O=O||!!w.audioCodec,E&&w.audioCodec&&w.audioCodec.indexOf("mp4a.40.34")!==-1&&(w.audioCodec=void 0);var U=w.bitrate+"-"+w.attrs.RESOLUTION+"-"+w.attrs.CODECS;o=f[U],o?o.url.push(w.url):(o=new R.Level(w),f[U]=o,l.push(o)),C&&(C.AUDIO&&Object(x.addGroupId)(o,"audio",C.AUDIO),C.SUBTITLES&&Object(x.addGroupId)(o,"text",C.SUBTITLES))}),(v||m)&&O&&(l=l.filter(function(w){var C=w.videoCodec,U=w.width,B=w.height;return!!C||!!(U&&B)})),l=l.filter(function(w){var C=w.audioCodec,U=w.videoCodec;return(!C||Object(I.isCodecSupportedInMp4)(C,"audio"))&&(!U||Object(I.isCodecSupportedInMp4)(U,"video"))}),t.audioTracks&&(d=t.audioTracks.filter(function(w){return!w.audioCodec||Object(I.isCodecSupportedInMp4)(w.audioCodec,"audio")}),Object(x.assignTrackIdsByGroup)(d)),t.subtitles&&(r=t.subtitles,Object(x.assignTrackIdsByGroup)(r)),l.length>0){c=l[0].bitrate,l.sort(function(w,C){return w.bitrate-C.bitrate}),this._levels=l;for(var b=0;b<l.length;b++)if(l[b].bitrate===c){this._firstLevel=b,this.log("manifest loaded, "+l.length+" level(s) found, first bitrate: "+c);break}var M=O&&!m,F={levels:l,audioTracks:d,subtitleTracks:r,firstLevel:this._firstLevel,stats:t.stats,audio:O,video:m,altAudio:!M&&d.some(function(w){return!!w.url})};this.hls.trigger(p.Events.MANIFEST_PARSED,F),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(p.Events.ERROR,{type:S.ErrorTypes.MEDIA_ERROR,details:S.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,reason:"no level with compatible codecs found in manifest"})},u.onError=function(i,t){var l;if(e.prototype.onError.call(this,i,t),!t.fatal){var d=t.context,r=this._levels[this.currentLevelIndex];if(d&&(d.type===A.PlaylistContextType.AUDIO_TRACK&&r.audioGroupIds&&d.groupId===r.audioGroupIds[r.urlId]||d.type===A.PlaylistContextType.SUBTITLE_TRACK&&r.textGroupIds&&d.groupId===r.textGroupIds[r.urlId])){this.redundantFailover(this.currentLevelIndex);return}var c=!1,f=!0,o;switch(t.details){case S.ErrorDetails.FRAG_LOAD_ERROR:case S.ErrorDetails.FRAG_LOAD_TIMEOUT:case S.ErrorDetails.KEY_LOAD_ERROR:case S.ErrorDetails.KEY_LOAD_TIMEOUT:if(t.frag){var v=t.frag.type===A.PlaylistLevelType.MAIN?t.frag.level:this.currentLevelIndex,m=this._levels[v];m?(m.fragmentError++,m.fragmentError>this.hls.config.fragLoadingMaxRetry&&(o=v)):o=v}break;case S.ErrorDetails.LEVEL_LOAD_ERROR:case S.ErrorDetails.LEVEL_LOAD_TIMEOUT:d&&(d.deliveryDirectives&&(f=!1),o=d.level),c=!0;break;case S.ErrorDetails.REMUX_ALLOC_ERROR:o=(l=t.level)!=null?l:this.currentLevelIndex,c=!0;break}o!==void 0&&this.recoverLevel(t,o,c,f)}},u.recoverLevel=function(i,t,l,d){var r=i.details,c=this._levels[t];if(c.loadError++,l){var f=this.retryLoadingOrFail(i);if(f)i.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(d){var o=c.url.length;if(o>1&&c.loadError<o)i.levelRetry=!0,this.redundantFailover(t);else if(this.manualLevelIndex===-1){for(var v=-1,m=this._levels,O=m.length;O--;){var b=(O+this.currentLevelIndex)%m.length;if(b!==this.currentLevelIndex&&m[b].loadError===0){v=b;break}}v>-1&&this.currentLevelIndex!==v&&(this.warn(r+": switch to "+v),i.levelRetry=!0,this.hls.nextAutoLevel=v)}}},u.redundantFailover=function(i){var t=this._levels[i],l=t.url.length;if(l>1){var d=(t.urlId+1)%l;this.warn("Switching to redundant URL-id "+d),this._levels.forEach(function(r){r.urlId=d}),this.level=i}},u.onFragLoaded=function(i,t){var l=t.frag;if(l!==void 0&&l.type===A.PlaylistLevelType.MAIN){var d=this._levels[l.level];d!==void 0&&(d.fragmentError=0,d.loadError=0)}},u.onLevelLoaded=function(i,t){var l,d=t.level,r=t.details,c=this._levels[d];if(!c){var f;this.warn("Invalid level index "+d),(f=t.deliveryDirectives)!==null&&f!==void 0&&f.skip&&(r.deltaUpdateFailed=!0);return}d===this.currentLevelIndex?(c.fragmentError===0&&(c.loadError=0,this.retryCount=0),this.playlistLoaded(d,t,c.details)):(l=t.deliveryDirectives)!==null&&l!==void 0&&l.skip&&(r.deltaUpdateFailed=!0)},u.onAudioTrackSwitched=function(i,t){var l=this.hls.levels[this.currentLevelIndex];if(!!l&&l.audioGroupIds){for(var d=-1,r=this.hls.audioTracks[t.id].groupId,c=0;c<l.audioGroupIds.length;c++)if(l.audioGroupIds[c]===r){d=c;break}d!==l.urlId&&(l.urlId=d,this.startLoad())}},u.loadPlaylist=function(i){var t=this.currentLevelIndex,l=this._levels[t];if(this.canLoad&&l&&l.url.length>0){var d=l.urlId,r=l.url[d];if(i)try{r=i.addDirectives(r)}catch(c){this.warn("Could not construct new URL with HLS Delivery Directives: "+c)}this.log("Attempt loading level index "+t+(i?" at sn "+i.msn+" part "+i.part:"")+" with URL-id "+d+" "+r),this.clearTimer(),this.hls.trigger(p.Events.LEVEL_LOADING,{url:r,level:t,id:d,deliveryDirectives:i||null})}},u.removeLevel=function(i,t){var l=function(c,f){return f!==t},d=this._levels.filter(function(r,c){return c!==i?!0:r.url.length>1&&t!==void 0?(r.url=r.url.filter(l),r.audioGroupIds&&(r.audioGroupIds=r.audioGroupIds.filter(l)),r.textGroupIds&&(r.textGroupIds=r.textGroupIds.filter(l)),r.urlId=0,!0):!1}).map(function(r,c){var f=r.details;return f!=null&&f.fragments&&f.fragments.forEach(function(o){o.level=c}),r});this._levels=d,this.hls.trigger(p.Events.LEVELS_UPDATED,{levels:d})},_(s,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(i){var t,l=this._levels;if(l.length!==0&&!(this.currentLevelIndex===i&&(t=l[i])!==null&&t!==void 0&&t.details)){if(i<0||i>=l.length){var d=i<0;if(this.hls.trigger(p.Events.ERROR,{type:S.ErrorTypes.OTHER_ERROR,details:S.ErrorDetails.LEVEL_SWITCH_ERROR,level:i,fatal:d,reason:"invalid level idx"}),d)return;i=Math.min(i,l.length-1)}this.clearTimer();var r=this.currentLevelIndex,c=l[r],f=l[i];this.log("switching to level "+i+" from "+r),this.currentLevelIndex=i;var o=y({},f,{level:i,maxBitrate:f.maxBitrate,uri:f.uri,urlId:f.urlId});delete o._urlId,this.hls.trigger(p.Events.LEVEL_SWITCHING,o);var v=f.details;if(!v||v.live){var m=this.switchParams(f.uri,c==null?void 0:c.details);this.loadPlaylist(m)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(i){this.manualLevelIndex=i,this._startLevel===void 0&&(this._startLevel=i),i!==-1&&(this.level=i)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(i){this._firstLevel=i}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var i=this.hls.config.startLevel;return i!==void 0?i:this._firstLevel}else return this._startLevel},set:function(i){this._startLevel=i}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(i){this.level=i,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=i)}}]),s}(L.default)},"./src/controller/level-helper.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"addGroupId",function(){return x}),h.d(P,"assignTrackIdsByGroup",function(){return L}),h.d(P,"updatePTS",function(){return A}),h.d(P,"updateFragPTSDTS",function(){return D}),h.d(P,"mergeDetails",function(){return _}),h.d(P,"mapPartIntersection",function(){return g}),h.d(P,"mapFragmentIntersection",function(){return E}),h.d(P,"adjustSliding",function(){return a}),h.d(P,"addSliding",function(){return e}),h.d(P,"computeReloadInterval",function(){return s}),h.d(P,"getFragmentWithSN",function(){return u}),h.d(P,"getPartWith",function(){return n});var R=h("./src/polyfills/number.ts"),p=h("./src/utils/logger.ts"),S=h("./src/loader/date-range.ts");function I(){return I=Object.assign?Object.assign.bind():function(i){for(var t=1;t<arguments.length;t++){var l=arguments[t];for(var d in l)Object.prototype.hasOwnProperty.call(l,d)&&(i[d]=l[d])}return i},I.apply(this,arguments)}function x(i,t,l){switch(t){case"audio":i.audioGroupIds||(i.audioGroupIds=[]),i.audioGroupIds.push(l);break;case"text":i.textGroupIds||(i.textGroupIds=[]),i.textGroupIds.push(l);break}}function L(i){var t={};i.forEach(function(l){var d=l.groupId||"";l.id=t[d]=t[d]||0,t[d]++})}function A(i,t,l){var d=i[t],r=i[l];y(d,r)}function y(i,t){var l=t.startPTS;if(Object(R.isFiniteNumber)(l)){var d=0,r;t.sn>i.sn?(d=l-i.start,r=i):(d=i.start-l,r=t),r.duration!==d&&(r.duration=d)}else if(t.sn>i.sn){var c=i.cc===t.cc;c&&i.minEndPTS?t.start=i.start+(i.minEndPTS-i.start):t.start=i.start+i.duration}else t.start=Math.max(i.start-t.duration,0)}function D(i,t,l,d,r,c){var f=d-l;f<=0&&(p.logger.warn("Fragment should have a positive duration",t),d=l+t.duration,c=r+t.duration);var o=l,v=d,m=t.startPTS,O=t.endPTS;if(Object(R.isFiniteNumber)(m)){var b=Math.abs(m-l);Object(R.isFiniteNumber)(t.deltaPTS)?t.deltaPTS=Math.max(b,t.deltaPTS):t.deltaPTS=b,o=Math.max(l,m),l=Math.min(l,m),r=Math.min(r,t.startDTS),v=Math.min(d,O),d=Math.max(d,O),c=Math.max(c,t.endDTS)}t.duration=d-l;var M=l-t.start;t.appendedPTS=d,t.start=t.startPTS=l,t.maxStartPTS=o,t.startDTS=r,t.endPTS=d,t.minEndPTS=v,t.endDTS=c;var F=t.sn;if(!i||F<i.startSN||F>i.endSN)return 0;var w,C=F-i.startSN,U=i.fragments;for(U[C]=t,w=C;w>0;w--)y(U[w],U[w-1]);for(w=C;w<U.length-1;w++)y(U[w],U[w+1]);return i.fragmentHint&&y(U[U.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,M}function _(i,t){for(var l=null,d=i.fragments,r=d.length-1;r>=0;r--){var c=d[r].initSegment;if(c){l=c;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;var f=0,o;if(E(i,t,function(w,C){w.relurl&&(f=w.cc-C.cc),Object(R.isFiniteNumber)(w.startPTS)&&Object(R.isFiniteNumber)(w.endPTS)&&(C.start=C.startPTS=w.startPTS,C.startDTS=w.startDTS,C.appendedPTS=w.appendedPTS,C.maxStartPTS=w.maxStartPTS,C.endPTS=w.endPTS,C.endDTS=w.endDTS,C.minEndPTS=w.minEndPTS,C.duration=w.endPTS-w.startPTS,C.duration&&(o=C),t.PTSKnown=t.alignedSliding=!0),C.elementaryStreams=w.elementaryStreams,C.loader=w.loader,C.stats=w.stats,C.urlId=w.urlId,w.initSegment&&(C.initSegment=w.initSegment,l=w.initSegment)}),l){var v=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments;v.forEach(function(w){var C;(!w.initSegment||w.initSegment.relurl===((C=l)===null||C===void 0?void 0:C.relurl))&&(w.initSegment=l)})}if(t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some(function(w){return!w}),t.deltaUpdateFailed){p.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var m=t.skippedSegments;m--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=T(i.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));var O=t.fragments;if(f){p.logger.warn("discontinuity sliding from playlist, take drift into account");for(var b=0;b<O.length;b++)O[b].cc+=f}t.skippedSegments&&(t.startCC=t.fragments[0].cc),g(i.partList,t.partList,function(w,C){C.elementaryStreams=w.elementaryStreams,C.stats=w.stats}),o?D(t,o,o.startPTS,o.endPTS,o.startDTS,o.endDTS):a(i,t),O.length&&(t.totalduration=t.edge-O[0].start),t.driftStartTime=i.driftStartTime,t.driftStart=i.driftStart;var M=t.advancedDateTime;if(t.advanced&&M){var F=t.edge;t.driftStart||(t.driftStartTime=M,t.driftStart=F),t.driftEndTime=M,t.driftEnd=F}else t.driftEndTime=i.driftEndTime,t.driftEnd=i.driftEnd,t.advancedDateTime=i.advancedDateTime}function T(i,t,l){var d=I({},i);return l&&l.forEach(function(r){delete d[r]}),Object.keys(t).forEach(function(r){var c=new S.DateRange(t[r].attr,d[r]);c.isValid?d[r]=c:p.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(t[r].attr)+'"')}),d}function g(i,t,l){if(i&&t)for(var d=0,r=0,c=i.length;r<=c;r++){var f=i[r],o=t[r+d];f&&o&&f.index===o.index&&f.fragment.sn===o.fragment.sn?l(f,o):d--}}function E(i,t,l){for(var d=t.skippedSegments,r=Math.max(i.startSN,t.startSN)-t.startSN,c=(i.fragmentHint?1:0)+(d?t.endSN:Math.min(i.endSN,t.endSN))-t.startSN,f=t.startSN-i.startSN,o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,v=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,m=r;m<=c;m++){var O=v[f+m],b=o[m];d&&!b&&m<d&&(b=t.fragments[m]=O),O&&b&&l(O,b)}}function a(i,t){var l=t.startSN+t.skippedSegments-i.startSN,d=i.fragments;l<0||l>=d.length||e(t,d[l].start)}function e(i,t){if(t){for(var l=i.fragments,d=i.skippedSegments;d<l.length;d++)l[d].start+=t;i.fragmentHint&&(i.fragmentHint.start+=t)}}function s(i,t){var l=1e3*i.levelTargetDuration,d=l/2,r=i.age,c=r>0&&r<l*3,f=t.loading.end-t.loading.start,o,v=i.availabilityDelay;if(i.updated===!1)if(c){var m=333*i.misses;o=Math.max(Math.min(d,f*2),m),i.availabilityDelay=(i.availabilityDelay||0)+o}else o=d;else c?(v=Math.min(v||l/2,r),i.availabilityDelay=v,o=v+l-r):o=l-f;return Math.round(o)}function u(i,t,l){if(!i||!i.details)return null;var d=i.details,r=d.fragments[t-d.startSN];return r||(r=d.fragmentHint,r&&r.sn===t)?r:t<d.startSN&&l&&l.sn===t?l:null}function n(i,t,l){if(!i||!i.details)return null;var d=i.details.partList;if(d)for(var r=d.length;r--;){var c=d[r];if(c.index===l&&c.fragment.sn===t)return c}return null}},"./src/controller/stream-controller.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return n});var R=h("./src/polyfills/number.ts"),p=h("./src/controller/base-stream-controller.ts"),S=h("./src/is-supported.ts"),I=h("./src/events.ts"),x=h("./src/utils/buffer-helper.ts"),L=h("./src/controller/fragment-tracker.ts"),A=h("./src/types/loader.ts"),y=h("./src/loader/fragment.ts"),D=h("./src/demux/transmuxer-interface.ts"),_=h("./src/types/transmuxer.ts"),T=h("./src/controller/gap-controller.ts"),g=h("./src/errors.ts");function E(i,t){for(var l=0;l<t.length;l++){var d=t[l];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(i,d.key,d)}}function a(i,t,l){return t&&E(i.prototype,t),l&&E(i,l),Object.defineProperty(i,"prototype",{writable:!1}),i}function e(i,t){i.prototype=Object.create(t.prototype),i.prototype.constructor=i,s(i,t)}function s(i,t){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(d,r){return d.__proto__=r,d},s(i,t)}var u=100,n=function(i){e(t,i);function t(d,r){var c;return c=i.call(this,d,r,"[stream-controller]")||this,c.audioCodecSwap=!1,c.gapController=null,c.level=-1,c._forceStartLoad=!1,c.altAudio=!1,c.audioOnly=!1,c.fragPlaying=null,c.onvplaying=null,c.onvseeked=null,c.fragLastKbps=0,c.couldBacktrack=!1,c.backtrackFragment=null,c.audioCodecSwitch=!1,c.videoBuffer=null,c._registerListeners(),c}var l=t.prototype;return l._registerListeners=function(){var r=this.hls;r.on(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(I.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.on(I.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.on(I.Events.ERROR,this.onError,this),r.on(I.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.on(I.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.on(I.Events.BUFFER_CREATED,this.onBufferCreated,this),r.on(I.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.on(I.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),r.on(I.Events.FRAG_BUFFERED,this.onFragBuffered,this)},l._unregisterListeners=function(){var r=this.hls;r.off(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.off(I.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.off(I.Events.ERROR,this.onError,this),r.off(I.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.off(I.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.off(I.Events.BUFFER_CREATED,this.onBufferCreated,this),r.off(I.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.off(I.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),r.off(I.Events.FRAG_BUFFERED,this.onFragBuffered,this)},l.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},l.startLoad=function(r){if(this.levels){var c=this.lastCurrentTime,f=this.hls;if(this.stopLoad(),this.setInterval(u),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var o=f.startLevel;o===-1&&(f.config.testBandwidth&&this.levels.length>1?(o=0,this.bitrateTest=!0):o=f.nextAutoLevel),this.level=f.nextLoadLevel=o,this.loadedmetadata=!1}c>0&&r===-1&&(this.log("Override startPosition with lastCurrentTime @"+c.toFixed(3)),r=c),this.state=p.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()}else this._forceStartLoad=!0,this.state=p.State.STOPPED},l.stopLoad=function(){this._forceStartLoad=!1,i.prototype.stopLoad.call(this)},l.doTick=function(){switch(this.state){case p.State.IDLE:this.doTickIdle();break;case p.State.WAITING_LEVEL:{var r,c=this.levels,f=this.level,o=c==null||(r=c[f])===null||r===void 0?void 0:r.details;if(o&&(!o.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(o))break;this.state=p.State.IDLE;break}break}case p.State.FRAG_LOADING_WAITING_RETRY:{var v,m=self.performance.now(),O=this.retryDate;(!O||m>=O||(v=this.media)!==null&&v!==void 0&&v.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=p.State.IDLE)}break;default:break}this.onTickEnd()},l.onTickEnd=function(){i.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},l.doTickIdle=function(){var r,c,f=this.hls,o=this.levelLastLoaded,v=this.levels,m=this.media,O=f.config,b=f.nextLoadLevel;if(!(o===null||!m&&(this.startFragRequested||!O.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!v||!v[b])){var M=v[b];this.level=f.nextLoadLevel=b;var F=M.details;if(!F||this.state===p.State.WAITING_LEVEL||F.live&&this.levelLastLoaded!==b){this.state=p.State.WAITING_LEVEL;return}var w=this.getMainFwdBufferInfo();if(w!==null){var C=w.len,U=this.getMaxBufferLength(M.maxBitrate);if(!(C>=U)){if(this._streamEnded(w,F)){var B={};this.altAudio&&(B.type="video"),this.hls.trigger(I.Events.BUFFER_EOS,B),this.state=p.State.ENDED;return}this.backtrackFragment&&this.backtrackFragment.start>w.end&&(this.backtrackFragment=null);var N=this.backtrackFragment?this.backtrackFragment.start:w.end,k=this.getNextFragment(N,F);if(this.couldBacktrack&&!this.fragPrevious&&k&&k.sn!=="initSegment"&&this.fragmentTracker.getState(k)!==L.FragmentState.OK){var j,H=((j=this.backtrackFragment)!=null?j:k).sn,V=H-F.startSN,Y=F.fragments[V-1];Y&&k.cc===Y.cc&&(k=Y,this.fragmentTracker.removeFragment(Y))}else this.backtrackFragment&&w.len&&(this.backtrackFragment=null);if(k&&this.fragmentTracker.getState(k)===L.FragmentState.OK&&this.nextLoadPosition>N){var Q=this.audioOnly&&!this.altAudio?y.ElementaryStreamTypes.AUDIO:y.ElementaryStreamTypes.VIDEO;m&&this.afterBufferFlushed(m,Q,A.PlaylistLevelType.MAIN),k=this.getNextFragment(this.nextLoadPosition,F)}!k||(k.initSegment&&!k.initSegment.data&&!this.bitrateTest&&(k=k.initSegment),((r=k.decryptdata)===null||r===void 0?void 0:r.keyFormat)==="identity"&&!((c=k.decryptdata)!==null&&c!==void 0&&c.key)?this.loadKey(k,F):this.loadFragment(k,F,N))}}}},l.loadFragment=function(r,c,f){var o,v=this.fragmentTracker.getState(r);this.fragCurrent=r,v===L.FragmentState.NOT_LOADED?r.sn==="initSegment"?this._loadInitSegment(r):this.bitrateTest?(this.log("Fragment "+r.sn+" of level "+r.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(r)):(this.startFragRequested=!0,i.prototype.loadFragment.call(this,r,c,f)):v===L.FragmentState.APPENDING?this.reduceMaxBufferLength(r.duration)&&this.fragmentTracker.removeFragment(r):((o=this.media)===null||o===void 0?void 0:o.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},l.getAppendedFrag=function(r){var c=this.fragmentTracker.getAppendedFrag(r,A.PlaylistLevelType.MAIN);return c&&"fragment"in c?c.fragment:c},l.getBufferedFrag=function(r){return this.fragmentTracker.getBufferedFrag(r,A.PlaylistLevelType.MAIN)},l.followingBufferedFrag=function(r){return r?this.getBufferedFrag(r.end+.5):null},l.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},l.nextLevelSwitch=function(){var r=this.levels,c=this.media;if(c!=null&&c.readyState){var f,o=this.getAppendedFrag(c.currentTime);if(o&&o.start>1&&this.flushMainBuffer(0,o.start-1),!c.paused&&r){var v=this.hls.nextLoadLevel,m=r[v],O=this.fragLastKbps;O&&this.fragCurrent?f=this.fragCurrent.duration*m.maxBitrate/(1e3*O)+1:f=0}else f=0;var b=this.getBufferedFrag(c.currentTime+f);if(b){var M=this.followingBufferedFrag(b);if(M){this.abortCurrentFrag();var F=M.maxStartPTS?M.maxStartPTS:M.start,w=M.duration,C=Math.max(b.end,F+Math.min(Math.max(w-this.config.maxFragLookUpTolerance,w*.5),w*.75));this.flushMainBuffer(C,Number.POSITIVE_INFINITY)}}}},l.abortCurrentFrag=function(){var r=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,r!=null&&r.loader&&r.loader.abort(),this.state){case p.State.KEY_LOADING:case p.State.FRAG_LOADING:case p.State.FRAG_LOADING_WAITING_RETRY:case p.State.PARSING:case p.State.PARSED:this.state=p.State.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},l.flushMainBuffer=function(r,c){i.prototype.flushMainBuffer.call(this,r,c,this.altAudio?"video":null)},l.onMediaAttached=function(r,c){i.prototype.onMediaAttached.call(this,r,c);var f=c.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),f.addEventListener("playing",this.onvplaying),f.addEventListener("seeked",this.onvseeked),this.gapController=new T.default(this.config,f,this.fragmentTracker,this.hls)},l.onMediaDetaching=function(){var r=this.media;r&&this.onvplaying&&this.onvseeked&&(r.removeEventListener("playing",this.onvplaying),r.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),i.prototype.onMediaDetaching.call(this)},l.onMediaPlaying=function(){this.tick()},l.onMediaSeeked=function(){var r=this.media,c=r?r.currentTime:null;Object(R.isFiniteNumber)(c)&&this.log("Media seeked to "+c.toFixed(3)),this.tick()},l.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(I.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},l.onManifestParsed=function(r,c){var f=!1,o=!1,v;c.levels.forEach(function(m){v=m.audioCodec,v&&(v.indexOf("mp4a.40.2")!==-1&&(f=!0),v.indexOf("mp4a.40.5")!==-1&&(o=!0))}),this.audioCodecSwitch=f&&o&&!Object(S.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=c.levels,this.startFragRequested=!1},l.onLevelLoading=function(r,c){var f=this.levels;if(!(!f||this.state!==p.State.IDLE)){var o=f[c.level];(!o.details||o.details.live&&this.levelLastLoaded!==c.level||this.waitForCdnTuneIn(o.details))&&(this.state=p.State.WAITING_LEVEL)}},l.onLevelLoaded=function(r,c){var f,o=this.levels,v=c.level,m=c.details,O=m.totalduration;if(!o){this.warn("Levels were reset while loading level "+v);return}this.log("Level "+v+" loaded ["+m.startSN+","+m.endSN+"], cc ["+m.startCC+", "+m.endCC+"] duration:"+O);var b=this.fragCurrent;b&&(this.state===p.State.FRAG_LOADING||this.state===p.State.FRAG_LOADING_WAITING_RETRY)&&b.level!==c.level&&b.loader&&(this.state=p.State.IDLE,this.backtrackFragment=null,b.loader.abort());var M=o[v],F=0;if(m.live||(f=M.details)!==null&&f!==void 0&&f.live){if(m.fragments[0]||(m.deltaUpdateFailed=!0),m.deltaUpdateFailed)return;F=this.alignPlaylists(m,M.details)}if(M.details=m,this.levelLastLoaded=v,this.hls.trigger(I.Events.LEVEL_UPDATED,{details:m,level:v}),this.state===p.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(m))return;this.state=p.State.IDLE}this.startFragRequested?m.live&&this.synchronizeToLiveEdge(m):this.setStartPosition(m,F),this.tick()},l._handleFragmentLoadProgress=function(r){var c,f=r.frag,o=r.part,v=r.payload,m=this.levels;if(!m){this.warn("Levels were reset while fragment load was in progress. Fragment "+f.sn+" of level "+f.level+" will not be buffered");return}var O=m[f.level],b=O.details;if(!b){this.warn("Dropping fragment "+f.sn+" of level "+f.level+" after level details were reset");return}var M=O.videoCodec,F=b.PTSKnown||!b.live,w=(c=f.initSegment)===null||c===void 0?void 0:c.data,C=this._getAudioCodec(O),U=this.transmuxer=this.transmuxer||new D.default(this.hls,A.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),B=o?o.index:-1,N=B!==-1,k=new _.ChunkMetadata(f.level,f.sn,f.stats.chunkCount,v.byteLength,B,N),j=this.initPTS[f.cc];U.push(v,w,C,M,f,o,b.totalduration,F,k,j)},l.onAudioTrackSwitching=function(r,c){var f=this.altAudio,o=!!c.url,v=c.id;if(!o){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var m=this.fragCurrent;m!=null&&m.loader&&(this.log("Switching to main audio track, cancel main fragment load"),m.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var O=this.hls;f&&O.trigger(I.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),O.trigger(I.Events.AUDIO_TRACK_SWITCHED,{id:v})}},l.onAudioTrackSwitched=function(r,c){var f=c.id,o=!!this.hls.audioTracks[f].url;if(o){var v=this.videoBuffer;v&&this.mediaBuffer!==v&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=v)}this.altAudio=o,this.tick()},l.onBufferCreated=function(r,c){var f=c.tracks,o,v,m=!1;for(var O in f){var b=f[O];if(b.id==="main"){if(v=O,o=b,O==="video"){var M=f[O];M&&(this.videoBuffer=M.buffer)}}else m=!0}m&&o?(this.log("Alternate track found, use "+v+".buffered to schedule main fragment loading"),this.mediaBuffer=o.buffer):this.mediaBuffer=this.media},l.onFragBuffered=function(r,c){var f=c.frag,o=c.part;if(!(f&&f.type!==A.PlaylistLevelType.MAIN)){if(this.fragContextChanged(f)){this.warn("Fragment "+f.sn+(o?" p: "+o.index:"")+" of level "+f.level+" finished buffering, but was aborted. state: "+this.state),this.state===p.State.PARSED&&(this.state=p.State.IDLE);return}var v=o?o.stats:f.stats;this.fragLastKbps=Math.round(8*v.total/(v.buffering.end-v.loading.first)),f.sn!=="initSegment"&&(this.fragPrevious=f),this.fragBufferedComplete(f,o)}},l.onError=function(r,c){switch(c.details){case g.ErrorDetails.FRAG_LOAD_ERROR:case g.ErrorDetails.FRAG_LOAD_TIMEOUT:case g.ErrorDetails.KEY_LOAD_ERROR:case g.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(A.PlaylistLevelType.MAIN,c);break;case g.ErrorDetails.LEVEL_LOAD_ERROR:case g.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==p.State.ERROR&&(c.fatal?(this.warn(""+c.details),this.state=p.State.ERROR):!c.levelRetry&&this.state===p.State.WAITING_LEVEL&&(this.state=p.State.IDLE));break;case g.ErrorDetails.BUFFER_FULL_ERROR:if(c.parent==="main"&&(this.state===p.State.PARSING||this.state===p.State.PARSED)){var f=!0,o=this.getFwdBufferInfo(this.media,A.PlaylistLevelType.MAIN);o&&o.len>.5&&(f=!this.reduceMaxBufferLength(o.len)),f&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},l.checkBuffer=function(){var r=this.media,c=this.gapController;if(!(!r||!c||!r.readyState)){if(this.loadedmetadata||!x.BufferHelper.getBuffered(r).length){var f=this.state!==p.State.IDLE?this.fragCurrent:null;c.poll(this.lastCurrentTime,f)}this.lastCurrentTime=r.currentTime}},l.onFragLoadEmergencyAborted=function(){this.state=p.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},l.onBufferFlushed=function(r,c){var f=c.type;if(f!==y.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var o=(f===y.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(o,f,A.PlaylistLevelType.MAIN)}},l.onLevelsUpdated=function(r,c){this.levels=c.levels},l.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},l.seekToStartPos=function(){var r=this.media;if(!!r){var c=r.currentTime,f=this.startPosition;if(f>=0&&c<f){if(r.seeking){this.log("could not seek to "+f+", already seeking at "+c);return}var o=x.BufferHelper.getBuffered(r),v=o.length?o.start(0):0,m=v-f;m>0&&(m<this.config.maxBufferHole||m<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+m+" to match buffer start"),f+=m,this.startPosition=f),this.log("seek to target start position "+f+" from current time "+c),r.currentTime=f}}},l._getAudioCodec=function(r){var c=this.config.defaultAudioCodec||r.audioCodec;return this.audioCodecSwap&&c&&(this.log("Swapping audio codec"),c.indexOf("mp4a.40.5")!==-1?c="mp4a.40.2":c="mp4a.40.5"),c},l._loadBitrateTestFrag=function(r){var c=this;r.bitrateTest=!0,this._doFragLoad(r).then(function(f){var o=c.hls;if(!(!f||o.nextLoadLevel||c.fragContextChanged(r))){c.fragLoadError=0,c.state=p.State.IDLE,c.startFragRequested=!1,c.bitrateTest=!1;var v=r.stats;v.parsing.start=v.parsing.end=v.buffering.start=v.buffering.end=self.performance.now(),o.trigger(I.Events.FRAG_LOADED,f),r.bitrateTest=!1}})},l._handleTransmuxComplete=function(r){var c,f="main",o=this.hls,v=r.remuxResult,m=r.chunkMeta,O=this.getCurrentContext(m);if(!O){this.warn("The loading context changed while buffering fragment "+m.sn+" of level "+m.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(m.level);return}var b=O.frag,M=O.part,F=O.level,w=v.video,C=v.text,U=v.id3,B=v.initSegment,N=F.details,k=this.altAudio?void 0:v.audio;if(!this.fragContextChanged(b)){if(this.state=p.State.PARSING,B){B.tracks&&(this._bufferInitSegment(F,B.tracks,b,m),o.trigger(I.Events.FRAG_PARSING_INIT_SEGMENT,{frag:b,id:f,tracks:B.tracks}));var j=B.initPTS,H=B.timescale;Object(R.isFiniteNumber)(j)&&(this.initPTS[b.cc]=j,o.trigger(I.Events.INIT_PTS_FOUND,{frag:b,id:f,initPTS:j,timescale:H}))}if(w&&v.independent!==!1){if(N){var V=w.startPTS,Y=w.endPTS,Q=w.startDTS,J=w.endDTS;if(M)M.elementaryStreams[w.type]={startPTS:V,endPTS:Y,startDTS:Q,endDTS:J};else if(w.firstKeyFrame&&w.independent&&(this.couldBacktrack=!0),w.dropped&&w.independent){var z=this.getMainFwdBufferInfo(),q=(z?z.end:this.getLoadPosition())+this.config.maxBufferHole,re=w.firstKeyFramePTS?w.firstKeyFramePTS:V;if(q<re-this.config.maxBufferHole){this.backtrack(b);return}b.setElementaryStreamInfo(w.type,b.start,Y,b.start,J,!0)}b.setElementaryStreamInfo(w.type,V,Y,Q,J),this.backtrackFragment&&(this.backtrackFragment=b),this.bufferFragmentData(w,b,M,m)}}else if(v.independent===!1){this.backtrack(b);return}if(k){var X=k.startPTS,le=k.endPTS,ne=k.startDTS,te=k.endDTS;M&&(M.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:X,endPTS:le,startDTS:ne,endDTS:te}),b.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,X,le,ne,te),this.bufferFragmentData(k,b,M,m)}if(N&&U!==null&&U!==void 0&&(c=U.samples)!==null&&c!==void 0&&c.length){var ee={id:f,frag:b,details:N,samples:U.samples};o.trigger(I.Events.FRAG_PARSING_METADATA,ee)}if(N&&C){var $={id:f,frag:b,details:N,samples:C.samples};o.trigger(I.Events.FRAG_PARSING_USERDATA,$)}}},l._bufferInitSegment=function(r,c,f,o){var v=this;if(this.state===p.State.PARSING){this.audioOnly=!!c.audio&&!c.video,this.altAudio&&!this.audioOnly&&delete c.audio;var m=c.audio,O=c.video,b=c.audiovideo;if(m){var M=r.audioCodec,F=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(M&&(M.indexOf("mp4a.40.5")!==-1?M="mp4a.40.2":M="mp4a.40.5"),m.metadata.channelCount!==1&&F.indexOf("firefox")===-1&&(M="mp4a.40.5")),F.indexOf("android")!==-1&&m.container!=="audio/mpeg"&&(M="mp4a.40.2",this.log("Android: force audio codec to "+M)),r.audioCodec&&r.audioCodec!==M&&this.log('Swapping manifest audio codec "'+r.audioCodec+'" for "'+M+'"'),m.levelCodec=M,m.id="main",this.log("Init audio buffer, container:"+m.container+", codecs[selected/level/parsed]=["+(M||"")+"/"+(r.audioCodec||"")+"/"+m.codec+"]")}O&&(O.levelCodec=r.videoCodec,O.id="main",this.log("Init video buffer, container:"+O.container+", codecs[level/parsed]=["+(r.videoCodec||"")+"/"+O.codec+"]")),b&&this.log("Init audiovideo buffer, container:"+b.container+", codecs[level/parsed]=["+(r.attrs.CODECS||"")+"/"+b.codec+"]"),this.hls.trigger(I.Events.BUFFER_CODECS,c),Object.keys(c).forEach(function(w){var C=c[w],U=C.initSegment;U!=null&&U.byteLength&&v.hls.trigger(I.Events.BUFFER_APPENDING,{type:w,data:U,frag:f,part:null,chunkMeta:o,parent:f.type})}),this.tick()}},l.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,A.PlaylistLevelType.MAIN)},l.backtrack=function(r){this.couldBacktrack=!0,this.backtrackFragment=r,this.resetTransmuxer(),this.flushBufferGap(r),this.fragmentTracker.removeFragment(r),this.fragPrevious=null,this.nextLoadPosition=r.start,this.state=p.State.IDLE},l.checkFragmentChanged=function(){var r=this.media,c=null;if(r&&r.readyState>1&&r.seeking===!1){var f=r.currentTime;if(x.BufferHelper.isBuffered(r,f)?c=this.getAppendedFrag(f):x.BufferHelper.isBuffered(r,f+.1)&&(c=this.getAppendedFrag(f+.1)),c){this.backtrackFragment=null;var o=this.fragPlaying,v=c.level;(!o||c.sn!==o.sn||o.level!==v||c.urlId!==o.urlId)&&(this.hls.trigger(I.Events.FRAG_CHANGED,{frag:c}),(!o||o.level!==v)&&this.hls.trigger(I.Events.LEVEL_SWITCHED,{level:v}),this.fragPlaying=c)}}},a(t,[{key:"nextLevel",get:function(){var r=this.nextBufferedFrag;return r?r.level:-1}},{key:"currentFrag",get:function(){var r=this.media;return r?this.fragPlaying||this.getAppendedFrag(r.currentTime):null}},{key:"currentProgramDateTime",get:function(){var r=this.media;if(r){var c=r.currentTime,f=this.currentFrag;if(f&&Object(R.isFiniteNumber)(c)&&Object(R.isFiniteNumber)(f.programDateTime)){var o=f.programDateTime+(c-f.start)*1e3;return new Date(o)}}return null}},{key:"currentLevel",get:function(){var r=this.currentFrag;return r?r.level:-1}},{key:"nextBufferedFrag",get:function(){var r=this.currentFrag;return r?this.followingBufferedFrag(r):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),t}(p.default)},"./src/controller/subtitle-stream-controller.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"SubtitleStreamController",function(){return e});var R=h("./src/events.ts"),p=h("./src/utils/buffer-helper.ts"),S=h("./src/controller/fragment-finders.ts"),I=h("./src/utils/discontinuities.ts"),x=h("./src/controller/level-helper.ts"),L=h("./src/controller/fragment-tracker.ts"),A=h("./src/controller/base-stream-controller.ts"),y=h("./src/types/loader.ts"),D=h("./src/types/level.ts");function _(u,n){for(var i=0;i<n.length;i++){var t=n[i];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(u,t.key,t)}}function T(u,n,i){return n&&_(u.prototype,n),i&&_(u,i),Object.defineProperty(u,"prototype",{writable:!1}),u}function g(u,n){u.prototype=Object.create(n.prototype),u.prototype.constructor=u,E(u,n)}function E(u,n){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,l){return t.__proto__=l,t},E(u,n)}var a=500,e=function(u){g(n,u);function n(t,l){var d;return d=u.call(this,t,l,"[subtitle-stream-controller]")||this,d.levels=[],d.currentTrackId=-1,d.tracksBuffered=[],d.mainDetails=null,d._registerListeners(),d}var i=n.prototype;return i.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},i._registerListeners=function(){var l=this.hls;l.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),l.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.on(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.on(R.Events.ERROR,this.onError,this),l.on(R.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.on(R.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),l.on(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),l.on(R.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),l.on(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i._unregisterListeners=function(){var l=this.hls;l.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),l.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.off(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.off(R.Events.ERROR,this.onError,this),l.off(R.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.off(R.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),l.off(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),l.off(R.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),l.off(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i.startLoad=function(){this.stopLoad(),this.state=A.State.IDLE,this.setInterval(a),this.tick()},i.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},i.onLevelLoaded=function(l,d){this.mainDetails=d.details},i.onSubtitleFragProcessed=function(l,d){var r=d.frag,c=d.success;if(this.fragPrevious=r,this.state=A.State.IDLE,!!c){var f=this.tracksBuffered[this.currentTrackId];if(!!f){for(var o,v=r.start,m=0;m<f.length;m++)if(v>=f[m].start&&v<=f[m].end){o=f[m];break}var O=r.start+r.duration;o?o.end=O:(o={start:v,end:O},f.push(o)),this.fragmentTracker.fragBuffered(r)}}},i.onBufferFlushing=function(l,d){var r=d.startOffset,c=d.endOffset;if(r===0&&c!==Number.POSITIVE_INFINITY){var f=this.currentTrackId,o=this.levels;if(!o.length||!o[f]||!o[f].details)return;var v=o[f].details,m=v.targetduration,O=c-m;if(O<=0)return;d.endOffsetSubtitles=Math.max(0,O),this.tracksBuffered.forEach(function(b){for(var M=0;M<b.length;){if(b[M].end<=O){b.shift();continue}else if(b[M].start<O)b[M].start=O;else break;M++}}),this.fragmentTracker.removeFragmentsInRange(r,O,y.PlaylistLevelType.SUBTITLE)}},i.onError=function(l,d){var r,c=d.frag;!c||c.type!==y.PlaylistLevelType.SUBTITLE||((r=this.fragCurrent)!==null&&r!==void 0&&r.loader&&this.fragCurrent.loader.abort(),this.state=A.State.IDLE)},i.onSubtitleTracksUpdated=function(l,d){var r=this,c=d.subtitleTracks;this.tracksBuffered=[],this.levels=c.map(function(f){return new D.Level(f)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(f){r.tracksBuffered[f.id]=[]}),this.mediaBuffer=null},i.onSubtitleTrackSwitch=function(l,d){if(this.currentTrackId=d.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var r=this.levels[this.currentTrackId];r!=null&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.setInterval(a)},i.onSubtitleTrackLoaded=function(l,d){var r,c=d.details,f=d.id,o=this.currentTrackId,v=this.levels;if(!!v.length){var m=v[o];if(!(f>=v.length||f!==o||!m)){if(this.mediaBuffer=this.mediaBufferTimeRanges,c.live||(r=m.details)!==null&&r!==void 0&&r.live){var O=this.mainDetails;if(c.deltaUpdateFailed||!O)return;var b=O.fragments[0];if(!m.details)c.hasProgramDateTime&&O.hasProgramDateTime?Object(I.alignMediaPlaylistByPDT)(c,O):b&&Object(x.addSliding)(c,b.start);else{var M=this.alignPlaylists(c,m.details);M===0&&b&&Object(x.addSliding)(c,b.start)}}if(m.details=c,this.levelLastLoaded=f,this.tick(),c.live&&!this.fragCurrent&&this.media&&this.state===A.State.IDLE){var F=Object(S.findFragmentByPTS)(null,c.fragments,this.media.currentTime,0);F||(this.warn("Subtitle playlist not aligned with playback"),m.details=void 0)}}}},i._handleFragmentLoadComplete=function(l){var d=l.frag,r=l.payload,c=d.decryptdata,f=this.hls;if(!this.fragContextChanged(d)&&r&&r.byteLength>0&&c&&c.key&&c.iv&&c.method==="AES-128"){var o=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(r),c.key.buffer,c.iv.buffer).then(function(v){var m=performance.now();f.trigger(R.Events.FRAG_DECRYPTED,{frag:d,payload:v,stats:{tstart:o,tdecrypt:m}})})}},i.doTick=function(){if(!this.media){this.state=A.State.IDLE;return}if(this.state===A.State.IDLE){var l=this.currentTrackId,d=this.levels;if(!d.length||!d[l]||!d[l].details)return;var r=d[l].details,c=r.targetduration,f=this.config,o=this.media,v=p.BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],o.currentTime-c,f.maxBufferHole),m=v.end,O=v.len,b=this.getMaxBufferLength()+c;if(O>b)return;console.assert(r,"Subtitle track details are defined on idle subtitle stream controller tick");var M=r.fragments,F=M.length,w=r.edge,C,U=this.fragPrevious;if(m<w){var B=f.maxFragLookUpTolerance;C=Object(S.findFragmentByPTS)(U,M,Math.max(M[0].start,m),B),!C&&U&&U.start<M[0].start&&(C=M[0])}else C=M[F-1];if(C=this.mapToInitFragWhenRequired(C),!C||this.fragmentTracker.getState(C)!==L.FragmentState.NOT_LOADED)return;C.encrypted?this.loadKey(C,r):this.loadFragment(C,r,m)}},i.loadFragment=function(l,d,r){this.fragCurrent=l,l.sn==="initSegment"?this._loadInitSegment(l):u.prototype.loadFragment.call(this,l,d,r)},T(n,[{key:"mediaBufferTimeRanges",get:function(){return new s(this.tracksBuffered[this.currentTrackId]||[])}}]),n}(A.default),s=function(n){this.buffered=void 0;var i=function(l,d,r){if(d=d>>>0,d>r-1)throw new DOMException("Failed to execute '"+l+"' on 'TimeRanges': The index provided ("+d+") is greater than the maximum bound ("+r+")");return n[d][l]};this.buffered={get length(){return n.length},end:function(l){return i("end",l,n.length)},start:function(l){return i("start",l,n.length)}}}},"./src/controller/subtitle-track-controller.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/events.ts"),p=h("./src/utils/texttrack-utils.ts"),S=h("./src/controller/base-playlist-controller.ts"),I=h("./src/types/loader.ts");function x(T,g){for(var E=0;E<g.length;E++){var a=g[E];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(T,a.key,a)}}function L(T,g,E){return g&&x(T.prototype,g),E&&x(T,E),Object.defineProperty(T,"prototype",{writable:!1}),T}function A(T,g){T.prototype=Object.create(g.prototype),T.prototype.constructor=T,y(T,g)}function y(T,g){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,e){return a.__proto__=e,a},y(T,g)}var D=function(T){A(g,T);function g(a){var e;return e=T.call(this,a,"[subtitle-track-controller]")||this,e.media=null,e.tracks=[],e.groupId=null,e.tracksInGroup=[],e.trackId=-1,e.selectDefaultTrack=!0,e.queuedDefaultTrack=-1,e.trackChangeListener=function(){return e.onTextTracksChanged()},e.asyncPollTrackChange=function(){return e.pollTrackChange(0)},e.useTextTrackPolling=!1,e.subtitlePollingInterval=-1,e._subtitleDisplay=!0,e.registerListeners(),e}var E=g.prototype;return E.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,T.prototype.destroy.call(this)},E.registerListeners=function(){var e=this.hls;e.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(R.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(R.Events.ERROR,this.onError,this)},E.unregisterListeners=function(){var e=this.hls;e.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(R.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(R.Events.ERROR,this.onError,this)},E.onMediaAttached=function(e,s){this.media=s.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},E.pollTrackChange=function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)},E.onMediaDetaching=function(){if(!!this.media){self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var e=_(this.media.textTracks);e.forEach(function(s){Object(p.clearCurrentCues)(s)}),this.subtitleTrack=-1,this.media=null}},E.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},E.onManifestParsed=function(e,s){this.tracks=s.subtitleTracks},E.onSubtitleTrackLoaded=function(e,s){var u=s.id,n=s.details,i=this.trackId,t=this.tracksInGroup[i];if(!t){this.warn("Invalid subtitle track id "+u);return}var l=t.details;t.details=s.details,this.log("subtitle track "+u+" loaded ["+n.startSN+"-"+n.endSN+"]"),u===this.trackId&&(this.retryCount=0,this.playlistLoaded(u,s,l))},E.onLevelLoading=function(e,s){this.switchLevel(s.level)},E.onLevelSwitching=function(e,s){this.switchLevel(s.level)},E.switchLevel=function(e){var s=this.hls.levels[e];if(!!(s!=null&&s.textGroupIds)){var u=s.textGroupIds[s.urlId];if(this.groupId!==u){var n=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,i=this.tracks.filter(function(d){return!u||d.groupId===u});this.tracksInGroup=i;var t=this.findTrackId(n==null?void 0:n.name)||this.findTrackId();this.groupId=u;var l={subtitleTracks:i};this.log("Updating subtitle tracks, "+i.length+' track(s) found in "'+u+'" group-id'),this.hls.trigger(R.Events.SUBTITLE_TRACKS_UPDATED,l),t!==-1&&this.setSubtitleTrack(t,n)}}},E.findTrackId=function(e){for(var s=this.tracksInGroup,u=0;u<s.length;u++){var n=s[u];if((!this.selectDefaultTrack||n.default)&&(!e||e===n.name))return n.id}return-1},E.onError=function(e,s){T.prototype.onError.call(this,e,s),!(s.fatal||!s.context)&&s.context.type===I.PlaylistContextType.SUBTITLE_TRACK&&s.context.id===this.trackId&&s.context.groupId===this.groupId&&this.retryLoadingOrFail(s)},E.loadPlaylist=function(e){var s=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(s)){var u=s.id,n=s.groupId,i=s.url;if(e)try{i=e.addDirectives(i)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("Loading subtitle playlist for id "+u),this.hls.trigger(R.Events.SUBTITLE_TRACK_LOADING,{url:i,id:u,groupId:n,deliveryDirectives:e||null})}},E.toggleTrackModes=function(e){var s=this,u=this.media,n=this.trackId;if(!!u){var i=_(u.textTracks),t=i.filter(function(r){return r.groupId===s.groupId});if(e===-1)[].slice.call(i).forEach(function(r){r.mode="disabled"});else{var l=t[n];l&&(l.mode="disabled")}var d=t[e];d&&(d.mode=this.subtitleDisplay?"showing":"hidden")}},E.setSubtitleTrack=function(e,s){var u,n=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),!(this.trackId===e&&(e===-1||(u=n[e])!==null&&u!==void 0&&u.details)||e<-1||e>=n.length)){this.clearTimer();var i=n[e];if(this.log("Switching to subtitle track "+e),this.trackId=e,i){var t=i.id,l=i.groupId,d=l===void 0?"":l,r=i.name,c=i.type,f=i.url;this.hls.trigger(R.Events.SUBTITLE_TRACK_SWITCH,{id:t,groupId:d,name:r,type:c,url:f});var o=this.switchParams(i.url,s==null?void 0:s.details);this.loadPlaylist(o)}else this.hls.trigger(R.Events.SUBTITLE_TRACK_SWITCH,{id:e})}},E.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!(!this.media||!this.hls.config.renderTextTracksNatively)){for(var e=-1,s=_(this.media.textTracks),u=0;u<s.length;u++)if(s[u].mode==="hidden")e=u;else if(s[u].mode==="showing"){e=u;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}},L(g,[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1;var s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,s)}}]),g}(S.default);function _(T){for(var g=[],E=0;E<T.length;E++){var a=T[E];a.kind==="subtitles"&&a.label&&g.push(T[E])}return g}P.default=D},"./src/controller/timeline-controller.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"TimelineController",function(){return T});var R=h("./src/polyfills/number.ts"),p=h("./src/events.ts"),S=h("./src/utils/cea-608-parser.ts"),I=h("./src/utils/output-filter.ts"),x=h("./src/utils/webvtt-parser.ts"),L=h("./src/utils/texttrack-utils.ts"),A=h("./src/utils/imsc1-ttml-parser.ts"),y=h("./src/utils/mp4-tools.ts"),D=h("./src/types/loader.ts"),_=h("./src/utils/logger.ts"),T=function(){function e(u){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=a(),this.captionsProperties=void 0,this.hls=u,this.config=u.config,this.Cues=u.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var n=new I.default(this,"textTrack1"),i=new I.default(this,"textTrack2"),t=new I.default(this,"textTrack3"),l=new I.default(this,"textTrack4");this.cea608Parser1=new S.default(1,n,i),this.cea608Parser2=new S.default(3,t,l)}u.on(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),u.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),u.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.on(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),u.on(p.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),u.on(p.Events.FRAG_LOADING,this.onFragLoading,this),u.on(p.Events.FRAG_LOADED,this.onFragLoaded,this),u.on(p.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),u.on(p.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),u.on(p.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),u.on(p.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),u.on(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var s=e.prototype;return s.destroy=function(){var n=this.hls;n.off(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),n.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),n.off(p.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),n.off(p.Events.FRAG_LOADING,this.onFragLoading,this),n.off(p.Events.FRAG_LOADED,this.onFragLoaded,this),n.off(p.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),n.off(p.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),n.off(p.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.off(p.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),n.off(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},s.addCues=function(n,i,t,l,d){for(var r=!1,c=d.length;c--;){var f=d[c],o=E(f[0],f[1],i,t);if(o>=0&&(f[0]=Math.min(f[0],i),f[1]=Math.max(f[1],t),r=!0,o/(t-i)>.5))return}if(r||d.push([i,t]),this.config.renderTextTracksNatively){var v=this.captionsTracks[n];this.Cues.newCue(v,i,t,l)}else{var m=this.Cues.newCue(null,i,t,l);this.hls.trigger(p.Events.CUES_PARSED,{type:"captions",cues:m,track:n})}},s.onInitPtsFound=function(n,i){var t=this,l=i.frag,d=i.id,r=i.initPTS,c=i.timescale,f=this.unparsedVttFrags;d==="main"&&(this.initPTS[l.cc]=r,this.timescale[l.cc]=c),f.length&&(this.unparsedVttFrags=[],f.forEach(function(o){t.onFragLoaded(p.Events.FRAG_LOADED,o)}))},s.getExistingTrack=function(n){var i=this.media;if(i)for(var t=0;t<i.textTracks.length;t++){var l=i.textTracks[t];if(l[n])return l}return null},s.createCaptionsTrack=function(n){this.config.renderTextTracksNatively?this.createNativeTrack(n):this.createNonNativeTrack(n)},s.createNativeTrack=function(n){if(!this.captionsTracks[n]){var i=this.captionsProperties,t=this.captionsTracks,l=this.media,d=i[n],r=d.label,c=d.languageCode,f=this.getExistingTrack(n);if(f)t[n]=f,Object(L.clearCurrentCues)(t[n]),Object(L.sendAddTrackEvent)(t[n],l);else{var o=this.createTextTrack("captions",r,c);o&&(o[n]=!0,t[n]=o)}}},s.createNonNativeTrack=function(n){if(!this.nonNativeCaptionsTracks[n]){var i=this.captionsProperties[n];if(!!i){var t=i.label,l={_id:n,label:t,kind:"captions",default:i.media?!!i.media.default:!1,closedCaptions:i.media};this.nonNativeCaptionsTracks[n]=l,this.hls.trigger(p.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[l]})}}},s.createTextTrack=function(n,i,t){var l=this.media;if(!!l)return l.addTextTrack(n,i,t)},s.onMediaAttaching=function(n,i){this.media=i.media,this._cleanTracks()},s.onMediaDetaching=function(){var n=this.captionsTracks;Object.keys(n).forEach(function(i){Object(L.clearCurrentCues)(n[i]),delete n[i]}),this.nonNativeCaptionsTracks={}},s.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=a(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},s._cleanTracks=function(){var n=this.media;if(!!n){var i=n.textTracks;if(i)for(var t=0;t<i.length;t++)Object(L.clearCurrentCues)(i[t])}},s.onSubtitleTracksUpdated=function(n,i){var t=this;this.textTracks=[];var l=i.subtitleTracks||[],d=l.some(function(o){return o.textCodec===A.IMSC1_CODEC});if(this.config.enableWebVTT||d&&this.config.enableIMSC1){var r=this.tracks&&l&&this.tracks.length===l.length;if(this.tracks=l||[],this.config.renderTextTracksNatively){var c=this.media?this.media.textTracks:[];this.tracks.forEach(function(o,v){var m;if(v<c.length){for(var O=null,b=0;b<c.length;b++)if(g(c[b],o)){O=c[b];break}O&&(m=O)}if(m)Object(L.clearCurrentCues)(m);else{var M=t._captionsOrSubtitlesFromCharacteristics(o);m=t.createTextTrack(M,o.name,o.lang),m&&(m.mode="disabled")}m&&(m.groupId=o.groupId,t.textTracks.push(m))})}else if(!r&&this.tracks&&this.tracks.length){var f=this.tracks.map(function(o){return{label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}});this.hls.trigger(p.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:f})}}},s._captionsOrSubtitlesFromCharacteristics=function(n){var i;if((i=n.attrs)!==null&&i!==void 0&&i.CHARACTERISTICS){var t=/transcribes-spoken-dialog/gi.test(n.attrs.CHARACTERISTICS),l=/describes-music-and-sound/gi.test(n.attrs.CHARACTERISTICS);if(t&&l)return"captions"}return"subtitles"},s.onManifestLoaded=function(n,i){var t=this;this.config.enableCEA708Captions&&i.captions&&i.captions.forEach(function(l){var d=/(?:CC|SERVICE)([1-4])/.exec(l.instreamId);if(!!d){var r="textTrack"+d[1],c=t.captionsProperties[r];!c||(c.label=l.name,l.lang&&(c.languageCode=l.lang),c.media=l)}})},s.onFragLoading=function(n,i){var t=this.cea608Parser1,l=this.cea608Parser2,d=this.lastSn,r=this.lastPartIndex;if(!(!this.enabled||!(t&&l))&&i.frag.type===D.PlaylistLevelType.MAIN){var c,f,o=i.frag.sn,v=(c=i==null||(f=i.part)===null||f===void 0?void 0:f.index)!=null?c:-1;o===d+1||o===d&&v===r+1||(t.reset(),l.reset()),this.lastSn=o,this.lastPartIndex=v}},s.onFragLoaded=function(n,i){var t=i.frag,l=i.payload,d=this.initPTS,r=this.unparsedVttFrags;if(t.type===D.PlaylistLevelType.SUBTITLE)if(l.byteLength){if(!Object(R.isFiniteNumber)(d[t.cc])){r.push(i),d.length&&this.hls.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:new Error("Missing initial subtitle PTS")});return}var c=t.decryptdata,f="stats"in i;if(c==null||c.key==null||c.method!=="AES-128"||f){var o=this.tracks[t.level],v=this.vttCCs;v[t.cc]||(v[t.cc]={start:t.start,prevCC:this.prevCC,new:!0},this.prevCC=t.cc),o&&o.textCodec===A.IMSC1_CODEC?this._parseIMSC1(t,l):this._parseVTTs(t,l,v)}}else this.hls.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:new Error("Empty subtitle payload")})},s._parseIMSC1=function(n,i){var t=this,l=this.hls;Object(A.parseIMSC1)(i,this.initPTS[n.cc],this.timescale[n.cc],function(d){t._appendCues(d,n.level),l.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:n})},function(d){_.logger.log("Failed to parse IMSC1: "+d),l.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:d})})},s._parseVTTs=function(n,i,t){var l,d=this,r=this.hls,c=(l=n.initSegment)!==null&&l!==void 0&&l.data?Object(y.appendUint8Array)(n.initSegment.data,new Uint8Array(i)):i;Object(x.parseWebVTT)(c,this.initPTS[n.cc],this.timescale[n.cc],t,n.cc,n.start,function(f){d._appendCues(f,n.level),r.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:n})},function(f){d._fallbackToIMSC1(n,i),_.logger.log("Failed to parse VTT cue: "+f),r.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:f})})},s._fallbackToIMSC1=function(n,i){var t=this,l=this.tracks[n.level];l.textCodec||Object(A.parseIMSC1)(i,this.initPTS[n.cc],this.timescale[n.cc],function(){l.textCodec=A.IMSC1_CODEC,t._parseIMSC1(n,i)},function(){l.textCodec="wvtt"})},s._appendCues=function(n,i){var t=this.hls;if(this.config.renderTextTracksNatively){var l=this.textTracks[i];if(!l||l.mode==="disabled")return;n.forEach(function(c){return Object(L.addCueToTrack)(l,c)})}else{var d=this.tracks[i];if(!d)return;var r=d.default?"default":"subtitles"+i;t.trigger(p.Events.CUES_PARSED,{type:"subtitles",cues:n,track:r})}},s.onFragDecrypted=function(n,i){var t=i.frag;if(t.type===D.PlaylistLevelType.SUBTITLE){if(!Object(R.isFiniteNumber)(this.initPTS[t.cc])){this.unparsedVttFrags.push(i);return}this.onFragLoaded(p.Events.FRAG_LOADED,i)}},s.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},s.onFragParsingUserdata=function(n,i){var t=this.cea608Parser1,l=this.cea608Parser2;if(!(!this.enabled||!(t&&l)))for(var d=0;d<i.samples.length;d++){var r=i.samples[d].bytes;if(r){var c=this.extractCea608Data(r);t.addData(i.samples[d].pts,c[0]),l.addData(i.samples[d].pts,c[1])}}},s.onBufferFlushing=function(n,i){var t=i.startOffset,l=i.endOffset,d=i.endOffsetSubtitles,r=i.type,c=this.media;if(!(!c||c.currentTime<l)){if(!r||r==="video"){var f=this.captionsTracks;Object.keys(f).forEach(function(v){return Object(L.removeCuesInRange)(f[v],t,l)})}if(this.config.renderTextTracksNatively&&t===0&&d!==void 0){var o=this.textTracks;Object.keys(o).forEach(function(v){return Object(L.removeCuesInRange)(o[v],t,d)})}}},s.extractCea608Data=function(n){for(var i=[[],[]],t=n[0]&31,l=2,d=0;d<t;d++){var r=n[l++],c=127&n[l++],f=127&n[l++];if(!(c===0&&f===0)){var o=(4&r)!==0;if(o){var v=3&r;(v===0||v===1)&&(i[v].push(c),i[v].push(f))}}}return i},e}();function g(e,s){return e&&e.label===s.name&&!(e.textTrack1||e.textTrack2)}function E(e,s,u,n){return Math.min(s,n)-Math.max(e,u)}function a(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}},"./src/crypt/aes-crypto.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return R});var R=function(){function p(I,x){this.subtle=void 0,this.aesIV=void 0,this.subtle=I,this.aesIV=x}var S=p.prototype;return S.decrypt=function(x,L){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},L,x)},p}()},"./src/crypt/aes-decryptor.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"removePadding",function(){return p}),h.d(P,"default",function(){return S});var R=h("./src/utils/typed-array.ts");function p(I){var x=I.byteLength,L=x&&new DataView(I.buffer).getUint8(x-1);return L?Object(R.sliceUint8)(I,0,x-L):I}var S=function(){function I(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var x=I.prototype;return x.uint8ArrayToUint32Array_=function(A){for(var y=new DataView(A),D=new Uint32Array(4),_=0;_<4;_++)D[_]=y.getUint32(_*4);return D},x.initTable=function(){var A=this.sBox,y=this.invSBox,D=this.subMix,_=D[0],T=D[1],g=D[2],E=D[3],a=this.invSubMix,e=a[0],s=a[1],u=a[2],n=a[3],i=new Uint32Array(256),t=0,l=0,d=0;for(d=0;d<256;d++)d<128?i[d]=d<<1:i[d]=d<<1^283;for(d=0;d<256;d++){var r=l^l<<1^l<<2^l<<3^l<<4;r=r>>>8^r&255^99,A[t]=r,y[r]=t;var c=i[t],f=i[c],o=i[f],v=i[r]*257^r*16843008;_[t]=v<<24|v>>>8,T[t]=v<<16|v>>>16,g[t]=v<<8|v>>>24,E[t]=v,v=o*16843009^f*65537^c*257^t*16843008,e[r]=v<<24|v>>>8,s[r]=v<<16|v>>>16,u[r]=v<<8|v>>>24,n[r]=v,t?(t=c^i[i[i[o^c]]],l^=i[i[l]]):t=l=1}},x.expandKey=function(A){for(var y=this.uint8ArrayToUint32Array_(A),D=!0,_=0;_<y.length&&D;)D=y[_]===this.key[_],_++;if(!D){this.key=y;var T=this.keySize=y.length;if(T!==4&&T!==6&&T!==8)throw new Error("Invalid aes key size="+T);var g=this.ksRows=(T+6+1)*4,E,a,e=this.keySchedule=new Uint32Array(g),s=this.invKeySchedule=new Uint32Array(g),u=this.sBox,n=this.rcon,i=this.invSubMix,t=i[0],l=i[1],d=i[2],r=i[3],c,f;for(E=0;E<g;E++){if(E<T){c=e[E]=y[E];continue}f=c,E%T===0?(f=f<<8|f>>>24,f=u[f>>>24]<<24|u[f>>>16&255]<<16|u[f>>>8&255]<<8|u[f&255],f^=n[E/T|0]<<24):T>6&&E%T===4&&(f=u[f>>>24]<<24|u[f>>>16&255]<<16|u[f>>>8&255]<<8|u[f&255]),e[E]=c=(e[E-T]^f)>>>0}for(a=0;a<g;a++)E=g-a,a&3?f=e[E]:f=e[E-4],a<4||E<=4?s[a]=f:s[a]=t[u[f>>>24]]^l[u[f>>>16&255]]^d[u[f>>>8&255]]^r[u[f&255]],s[a]=s[a]>>>0}},x.networkToHostOrderSwap=function(A){return A<<24|(A&65280)<<8|(A&16711680)>>8|A>>>24},x.decrypt=function(A,y,D){for(var _=this.keySize+6,T=this.invKeySchedule,g=this.invSBox,E=this.invSubMix,a=E[0],e=E[1],s=E[2],u=E[3],n=this.uint8ArrayToUint32Array_(D),i=n[0],t=n[1],l=n[2],d=n[3],r=new Int32Array(A),c=new Int32Array(r.length),f,o,v,m,O,b,M,F,w,C,U,B,N,k,j=this.networkToHostOrderSwap;y<r.length;){for(w=j(r[y]),C=j(r[y+1]),U=j(r[y+2]),B=j(r[y+3]),O=w^T[0],b=B^T[1],M=U^T[2],F=C^T[3],N=4,k=1;k<_;k++)f=a[O>>>24]^e[b>>16&255]^s[M>>8&255]^u[F&255]^T[N],o=a[b>>>24]^e[M>>16&255]^s[F>>8&255]^u[O&255]^T[N+1],v=a[M>>>24]^e[F>>16&255]^s[O>>8&255]^u[b&255]^T[N+2],m=a[F>>>24]^e[O>>16&255]^s[b>>8&255]^u[M&255]^T[N+3],O=f,b=o,M=v,F=m,N=N+4;f=g[O>>>24]<<24^g[b>>16&255]<<16^g[M>>8&255]<<8^g[F&255]^T[N],o=g[b>>>24]<<24^g[M>>16&255]<<16^g[F>>8&255]<<8^g[O&255]^T[N+1],v=g[M>>>24]<<24^g[F>>16&255]<<16^g[O>>8&255]<<8^g[b&255]^T[N+2],m=g[F>>>24]<<24^g[O>>16&255]<<16^g[b>>8&255]<<8^g[M&255]^T[N+3],c[y]=j(f^i),c[y+1]=j(m^t),c[y+2]=j(v^l),c[y+3]=j(o^d),i=w,t=C,l=U,d=B,y=y+4}return c.buffer},I}()},"./src/crypt/decrypter.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return y});var R=h("./src/crypt/aes-crypto.ts"),p=h("./src/crypt/fast-aes-key.ts"),S=h("./src/crypt/aes-decryptor.ts"),I=h("./src/utils/logger.ts"),x=h("./src/utils/mp4-tools.ts"),L=h("./src/utils/typed-array.ts"),A=16,y=function(){function D(T,g,E){var a=E===void 0?{}:E,e=a.removePKCS7Padding,s=e===void 0?!0:e;if(this.logEnabled=!0,this.observer=void 0,this.config=void 0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.observer=T,this.config=g,this.removePKCS7Padding=s,s)try{var u=self.crypto;u&&(this.subtle=u.subtle||u.webkitSubtle)}catch{}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var _=D.prototype;return _.destroy=function(){this.observer=null},_.isSync=function(){return this.config.enableSoftwareAES},_.flush=function(){var g=this.currentResult;if(!g){this.reset();return}var E=new Uint8Array(g);return this.reset(),this.removePKCS7Padding?Object(S.removePadding)(E):E},_.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},_.decrypt=function(g,E,a,e){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(g),E,a);var s=this.flush();s&&e(s.buffer)}else this.webCryptoDecrypt(new Uint8Array(g),E,a).then(e)},_.softwareDecrypt=function(g,E,a){var e=this.currentIV,s=this.currentResult,u=this.remainderData;this.logOnce("JS AES decrypt"),u&&(g=Object(x.appendUint8Array)(u,g),this.remainderData=null);var n=this.getValidChunk(g);if(!n.length)return null;e&&(a=e);var i=this.softwareDecrypter;i||(i=this.softwareDecrypter=new S.default),i.expandKey(E);var t=s;return this.currentResult=i.decrypt(n.buffer,0,a),this.currentIV=Object(L.sliceUint8)(n,-16).buffer,t||null},_.webCryptoDecrypt=function(g,E,a){var e=this,s=this.subtle;return(this.key!==E||!this.fastAesKey)&&(this.key=E,this.fastAesKey=new p.default(s,E)),this.fastAesKey.expandKey().then(function(u){if(!s)return Promise.reject(new Error("web crypto not initialized"));var n=new R.default(s,a);return n.decrypt(g.buffer,u)}).catch(function(u){return e.onWebCryptoError(u,g,E,a)})},_.onWebCryptoError=function(g,E,a,e){return I.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",g),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(E,a,e)},_.getValidChunk=function(g){var E=g,a=g.length-g.length%A;return a!==g.length&&(E=Object(L.sliceUint8)(g,0,a),this.remainderData=Object(L.sliceUint8)(g,a)),E},_.logOnce=function(g){!this.logEnabled||(I.logger.log("[decrypter.ts]: "+g),this.logEnabled=!1)},D}()},"./src/crypt/fast-aes-key.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return R});var R=function(){function p(I,x){this.subtle=void 0,this.key=void 0,this.subtle=I,this.key=x}var S=p.prototype;return S.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},p}()},"./src/demux/aacdemuxer.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/demux/base-audio-demuxer.ts"),p=h("./src/demux/adts.ts"),S=h("./src/utils/logger.ts"),I=h("./src/demux/id3.ts");function x(y,D){y.prototype=Object.create(D.prototype),y.prototype.constructor=y,L(y,D)}function L(y,D){return L=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(T,g){return T.__proto__=g,T},L(y,D)}var A=function(y){x(D,y);function D(T,g){var E;return E=y.call(this)||this,E.observer=void 0,E.config=void 0,E.observer=T,E.config=g,E}var _=D.prototype;return _.resetInitSegment=function(g,E,a,e){y.prototype.resetInitSegment.call(this,g,E,a,e),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:E,duration:e,inputTimeScale:9e4,dropped:0}},D.probe=function(g){if(!g)return!1;for(var E=I.getID3Data(g,0)||[],a=E.length,e=g.length;a<e;a++)if(p.probe(g,a))return S.logger.log("ADTS sync word found !"),!0;return!1},_.canParse=function(g,E){return p.canParse(g,E)},_.appendFrame=function(g,E,a){p.initTrackConfig(g,this.observer,E,a,g.manifestCodec);var e=p.appendFrame(g,E,a,this.basePTS,this.frameIndex);if(e&&e.missing===0)return e},D}(R.default);P.default=A},"./src/demux/adts.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"getAudioConfig",function(){return I}),h.d(P,"isHeaderPattern",function(){return x}),h.d(P,"getHeaderLength",function(){return L}),h.d(P,"getFullFrameLength",function(){return A}),h.d(P,"canGetFrameLength",function(){return y}),h.d(P,"isHeader",function(){return D}),h.d(P,"canParse",function(){return _}),h.d(P,"probe",function(){return T}),h.d(P,"initTrackConfig",function(){return g}),h.d(P,"getFrameDuration",function(){return E}),h.d(P,"parseFrameHeader",function(){return a}),h.d(P,"appendFrame",function(){return e});var R=h("./src/utils/logger.ts"),p=h("./src/errors.ts"),S=h("./src/events.ts");function I(s,u,n,i){var t,l,d,r,c=navigator.userAgent.toLowerCase(),f=i,o=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];t=((u[n+2]&192)>>>6)+1;var v=(u[n+2]&60)>>>2;if(v>o.length-1){s.trigger(S.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+v});return}return d=(u[n+2]&1)<<2,d|=(u[n+3]&192)>>>6,R.logger.log("manifest codec:"+i+", ADTS type:"+t+", samplingIndex:"+v),/firefox/i.test(c)?v>=6?(t=5,r=new Array(4),l=v-3):(t=2,r=new Array(2),l=v):c.indexOf("android")!==-1?(t=2,r=new Array(2),l=v):(t=5,r=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&v>=6?l=v-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(v>=6&&d===1||/vivaldi/i.test(c))||!i&&d===1)&&(t=2,r=new Array(2)),l=v)),r[0]=t<<3,r[0]|=(v&14)>>1,r[1]|=(v&1)<<7,r[1]|=d<<3,t===5&&(r[1]|=(l&14)>>1,r[2]=(l&1)<<7,r[2]|=2<<2,r[3]=0),{config:r,samplerate:o[v],channelCount:d,codec:"mp4a.40."+t,manifestCodec:f}}function x(s,u){return s[u]===255&&(s[u+1]&246)===240}function L(s,u){return s[u+1]&1?7:9}function A(s,u){return(s[u+3]&3)<<11|s[u+4]<<3|(s[u+5]&224)>>>5}function y(s,u){return u+5<s.length}function D(s,u){return u+1<s.length&&x(s,u)}function _(s,u){return y(s,u)&&x(s,u)&&A(s,u)<=s.length-u}function T(s,u){if(D(s,u)){var n=L(s,u);if(u+n>=s.length)return!1;var i=A(s,u);if(i<=n)return!1;var t=u+i;return t===s.length||D(s,t)}return!1}function g(s,u,n,i,t){if(!s.samplerate){var l=I(u,n,i,t);if(!l)return;s.config=l.config,s.samplerate=l.samplerate,s.channelCount=l.channelCount,s.codec=l.codec,s.manifestCodec=l.manifestCodec,R.logger.log("parsed codec:"+s.codec+", rate:"+l.samplerate+", channels:"+l.channelCount)}}function E(s){return 1024*9e4/s}function a(s,u){var n=L(s,u);if(u+n<=s.length){var i=A(s,u)-n;if(i>0)return{headerLength:n,frameLength:i}}}function e(s,u,n,i,t){var l=E(s.samplerate),d=i+t*l,r=a(u,n),c;if(r){var f=r.frameLength,o=r.headerLength,v=o+f,m=Math.max(0,n+v-u.length);m?(c=new Uint8Array(v-o),c.set(u.subarray(n+o,u.length),0)):c=u.subarray(n+o,n+v);var O={unit:c,pts:d};return m||s.samples.push(O),{sample:O,length:v,missing:m}}var b=u.length-n;c=new Uint8Array(b),c.set(u.subarray(n,u.length),0);var M={unit:c,pts:d};return{sample:M,length:b,missing:-1}}},"./src/demux/base-audio-demuxer.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"initPTSFn",function(){return y});var R=h("./src/polyfills/number.ts"),p=h("./src/demux/id3.ts"),S=h("./src/types/demuxer.ts"),I=h("./src/demux/dummy-demuxed-track.ts"),x=h("./src/utils/mp4-tools.ts"),L=h("./src/utils/typed-array.ts"),A=function(){function D(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null}var _=D.prototype;return _.resetInitSegment=function(g,E,a,e){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},_.resetTimeStamp=function(g){this.initPTS=g,this.resetContiguity()},_.resetContiguity=function(){this.basePTS=null,this.frameIndex=0},_.canParse=function(g,E){return!1},_.appendFrame=function(g,E,a){},_.demux=function(g,E){this.cachedData&&(g=Object(x.appendUint8Array)(this.cachedData,g),this.cachedData=null);var a=p.getID3Data(g,0),e=a?a.length:0,s,u,n=this._audioTrack,i=this._id3Track,t=a?p.getTimeStamp(a):void 0,l=g.length;for((this.basePTS===null||this.frameIndex===0&&Object(R.isFiniteNumber)(t))&&(this.basePTS=y(t,E,this.initPTS)),a&&a.length>0&&i.samples.push({pts:this.basePTS,dts:this.basePTS,data:a,type:S.MetadataSchema.audioId3}),u=this.basePTS;e<l;){if(this.canParse(g,e)){var d=this.appendFrame(n,g,e);d?(this.frameIndex++,u=d.sample.pts,e+=d.length,s=e):e=l}else p.canParse(g,e)?(a=p.getID3Data(g,e),i.samples.push({pts:u,dts:u,data:a,type:S.MetadataSchema.audioId3}),e+=a.length,s=e):e++;if(e===l&&s!==l){var r=Object(L.sliceUint8)(g,s);this.cachedData?this.cachedData=Object(x.appendUint8Array)(this.cachedData,r):this.cachedData=r}}return{audioTrack:n,videoTrack:Object(I.dummyTrack)(),id3Track:i,textTrack:Object(I.dummyTrack)()}},_.demuxSampleAes=function(g,E,a){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},_.flush=function(g){var E=this.cachedData;return E&&(this.cachedData=null,this.demux(E,0)),{audioTrack:this._audioTrack,videoTrack:Object(I.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(I.dummyTrack)()}},_.destroy=function(){},D}(),y=function(_,T,g){return Object(R.isFiniteNumber)(_)?_*90:T*9e4+(g||0)};P.default=A},"./src/demux/chunk-cache.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return R});var R=function(){function S(){this.chunks=[],this.dataLength=0}var I=S.prototype;return I.push=function(L){this.chunks.push(L),this.dataLength+=L.length},I.flush=function(){var L=this.chunks,A=this.dataLength,y;if(L.length)L.length===1?y=L[0]:y=p(L,A);else return new Uint8Array(0);return this.reset(),y},I.reset=function(){this.chunks.length=0,this.dataLength=0},S}();function p(S,I){for(var x=new Uint8Array(I),L=0,A=0;A<S.length;A++){var y=S[A];x.set(y,L),L+=y.length}return x}},"./src/demux/dummy-demuxed-track.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"dummyTrack",function(){return R});function R(p,S){return p===void 0&&(p=""),S===void 0&&(S=9e4),{type:p,id:-1,pid:-1,inputTimeScale:S,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/utils/logger.ts"),p=function(){function S(x){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=x,this.bytesAvailable=x.byteLength,this.word=0,this.bitsAvailable=0}var I=S.prototype;return I.loadWord=function(){var L=this.data,A=this.bytesAvailable,y=L.byteLength-A,D=new Uint8Array(4),_=Math.min(4,A);if(_===0)throw new Error("no bytes available");D.set(L.subarray(y,y+_)),this.word=new DataView(D.buffer).getUint32(0),this.bitsAvailable=_*8,this.bytesAvailable-=_},I.skipBits=function(L){var A;this.bitsAvailable>L?(this.word<<=L,this.bitsAvailable-=L):(L-=this.bitsAvailable,A=L>>3,L-=A>>3,this.bytesAvailable-=A,this.loadWord(),this.word<<=L,this.bitsAvailable-=L)},I.readBits=function(L){var A=Math.min(this.bitsAvailable,L),y=this.word>>>32-A;return L>32&&R.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=A,this.bitsAvailable>0?this.word<<=A:this.bytesAvailable>0&&this.loadWord(),A=L-A,A>0&&this.bitsAvailable?y<<A|this.readBits(A):y},I.skipLZ=function(){var L;for(L=0;L<this.bitsAvailable;++L)if((this.word&2147483648>>>L)!==0)return this.word<<=L,this.bitsAvailable-=L,L;return this.loadWord(),L+this.skipLZ()},I.skipUEG=function(){this.skipBits(1+this.skipLZ())},I.skipEG=function(){this.skipBits(1+this.skipLZ())},I.readUEG=function(){var L=this.skipLZ();return this.readBits(L+1)-1},I.readEG=function(){var L=this.readUEG();return 1&L?1+L>>>1:-1*(L>>>1)},I.readBoolean=function(){return this.readBits(1)===1},I.readUByte=function(){return this.readBits(8)},I.readUShort=function(){return this.readBits(16)},I.readUInt=function(){return this.readBits(32)},I.skipScalingList=function(L){for(var A=8,y=8,D,_=0;_<L;_++)y!==0&&(D=this.readEG(),y=(A+D+256)%256),A=y===0?A:y},I.readSPS=function(){var L=0,A=0,y=0,D=0,_,T,g,E=this.readUByte.bind(this),a=this.readBits.bind(this),e=this.readUEG.bind(this),s=this.readBoolean.bind(this),u=this.skipBits.bind(this),n=this.skipEG.bind(this),i=this.skipUEG.bind(this),t=this.skipScalingList.bind(this);E();var l=E();if(a(5),u(3),E(),i(),l===100||l===110||l===122||l===244||l===44||l===83||l===86||l===118||l===128){var d=e();if(d===3&&u(1),i(),i(),u(1),s())for(T=d!==3?8:12,g=0;g<T;g++)s()&&(g<6?t(16):t(64))}i();var r=e();if(r===0)e();else if(r===1)for(u(1),n(),n(),_=e(),g=0;g<_;g++)n();i(),u(1);var c=e(),f=e(),o=a(1);o===0&&u(1),u(1),s()&&(L=e(),A=e(),y=e(),D=e());var v=[1,1];if(s()&&s()){var m=E();switch(m){case 1:v=[1,1];break;case 2:v=[12,11];break;case 3:v=[10,11];break;case 4:v=[16,11];break;case 5:v=[40,33];break;case 6:v=[24,11];break;case 7:v=[20,11];break;case 8:v=[32,11];break;case 9:v=[80,33];break;case 10:v=[18,11];break;case 11:v=[15,11];break;case 12:v=[64,33];break;case 13:v=[160,99];break;case 14:v=[4,3];break;case 15:v=[3,2];break;case 16:v=[2,1];break;case 255:{v=[E()<<8|E(),E()<<8|E()];break}}}return{width:Math.ceil((c+1)*16-L*2-A*2),height:(2-o)*(f+1)*16-(o?2:4)*(y+D),pixelRatio:v}},I.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},S}();P.default=p},"./src/demux/id3.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"isHeader",function(){return R}),h.d(P,"isFooter",function(){return p}),h.d(P,"getID3Data",function(){return S}),h.d(P,"canParse",function(){return x}),h.d(P,"getTimeStamp",function(){return L}),h.d(P,"isTimeStampFrame",function(){return A}),h.d(P,"getID3Frames",function(){return D}),h.d(P,"decodeFrame",function(){return _}),h.d(P,"utf8ArrayToStr",function(){return e}),h.d(P,"testables",function(){return s});var R=function(t,l){return l+10<=t.length&&t[l]===73&&t[l+1]===68&&t[l+2]===51&&t[l+3]<255&&t[l+4]<255&&t[l+6]<128&&t[l+7]<128&&t[l+8]<128&&t[l+9]<128},p=function(t,l){return l+10<=t.length&&t[l]===51&&t[l+1]===68&&t[l+2]===73&&t[l+3]<255&&t[l+4]<255&&t[l+6]<128&&t[l+7]<128&&t[l+8]<128&&t[l+9]<128},S=function(t,l){for(var d=l,r=0;R(t,l);){r+=10;var c=I(t,l+6);r+=c,p(t,l+10)&&(r+=10),l+=r}if(r>0)return t.subarray(d,d+r)},I=function(t,l){var d=0;return d=(t[l]&127)<<21,d|=(t[l+1]&127)<<14,d|=(t[l+2]&127)<<7,d|=t[l+3]&127,d},x=function(t,l){return R(t,l)&&I(t,l+6)+10<=t.length-l},L=function(t){for(var l=D(t),d=0;d<l.length;d++){var r=l[d];if(A(r))return a(r)}},A=function(t){return t&&t.key==="PRIV"&&t.info==="com.apple.streaming.transportStreamTimestamp"},y=function(t){var l=String.fromCharCode(t[0],t[1],t[2],t[3]),d=I(t,4),r=10;return{type:l,size:d,data:t.subarray(r,r+d)}},D=function(t){for(var l=0,d=[];R(t,l);){var r=I(t,l+6);l+=10;for(var c=l+r;l+8<c;){var f=y(t.subarray(l)),o=_(f);o&&d.push(o),l+=f.size+10}p(t,l)&&(l+=10)}return d},_=function(t){return t.type==="PRIV"?T(t):t.type[0]==="W"?E(t):g(t)},T=function(t){if(!(t.size<2)){var l=e(t.data,!0),d=new Uint8Array(t.data.subarray(l.length+1));return{key:t.type,info:l,data:d.buffer}}},g=function(t){if(!(t.size<2)){if(t.type==="TXXX"){var l=1,d=e(t.data.subarray(l),!0);l+=d.length+1;var r=e(t.data.subarray(l));return{key:t.type,info:d,data:r}}var c=e(t.data.subarray(1));return{key:t.type,data:c}}},E=function(t){if(t.type==="WXXX"){if(t.size<2)return;var l=1,d=e(t.data.subarray(l),!0);l+=d.length+1;var r=e(t.data.subarray(l));return{key:t.type,info:d,data:r}}var c=e(t.data);return{key:t.type,data:c}},a=function(t){if(t.data.byteLength===8){var l=new Uint8Array(t.data),d=l[3]&1,r=(l[4]<<23)+(l[5]<<15)+(l[6]<<7)+l[7];return r/=45,d&&(r+=4772185884e-2),Math.round(r)}},e=function(t,l){l===void 0&&(l=!1);var d=n();if(d){var r=d.decode(t);if(l){var c=r.indexOf("\0");return c!==-1?r.substring(0,c):r}return r.replace(/\0/g,"")}for(var f=t.length,o,v,m,O="",b=0;b<f;){if(o=t[b++],o===0&&l)return O;if(o===0||o===3)continue;switch(o>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:O+=String.fromCharCode(o);break;case 12:case 13:v=t[b++],O+=String.fromCharCode((o&31)<<6|v&63);break;case 14:v=t[b++],m=t[b++],O+=String.fromCharCode((o&15)<<12|(v&63)<<6|(m&63)<<0);break;default:}}return O},s={decodeTextFrame:g},u;function n(){return!u&&typeof self.TextDecoder!="undefined"&&(u=new self.TextDecoder("utf-8")),u}},"./src/demux/mp3demuxer.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/demux/base-audio-demuxer.ts"),p=h("./src/demux/id3.ts"),S=h("./src/utils/logger.ts"),I=h("./src/demux/mpegaudio.ts");function x(y,D){y.prototype=Object.create(D.prototype),y.prototype.constructor=y,L(y,D)}function L(y,D){return L=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(T,g){return T.__proto__=g,T},L(y,D)}var A=function(y){x(D,y);function D(){return y.apply(this,arguments)||this}var _=D.prototype;return _.resetInitSegment=function(g,E,a,e){y.prototype.resetInitSegment.call(this,g,E,a,e),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:E,duration:e,inputTimeScale:9e4,dropped:0}},D.probe=function(g){if(!g)return!1;for(var E=p.getID3Data(g,0)||[],a=E.length,e=g.length;a<e;a++)if(I.probe(g,a))return S.logger.log("MPEG Audio sync word found !"),!0;return!1},_.canParse=function(g,E){return I.canParse(g,E)},_.appendFrame=function(g,E,a){if(this.basePTS!==null)return I.appendFrame(g,E,a,this.basePTS,this.frameIndex)},D}(R.default);P.default=A},"./src/demux/mp4demuxer.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/polyfills/number.ts"),p=h("./src/types/demuxer.ts"),S=h("./src/utils/mp4-tools.ts"),I=h("./src/demux/dummy-demuxed-track.ts"),x=/\/emsg[-/]ID3/i,L=function(){function A(D,_){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=_}var y=A.prototype;return y.resetTimeStamp=function(){},y.resetInitSegment=function(_,T,g,E){var a=Object(S.parseInitSegment)(_),e=this.videoTrack=Object(I.dummyTrack)("video",1),s=this.audioTrack=Object(I.dummyTrack)("audio",1),u=this.txtTrack=Object(I.dummyTrack)("text",1);if(this.id3Track=Object(I.dummyTrack)("id3",1),this.timeOffset=0,a.video){var n=a.video,i=n.id,t=n.timescale,l=n.codec;e.id=i,e.timescale=u.timescale=t,e.codec=l}if(a.audio){var d=a.audio,r=d.id,c=d.timescale,f=d.codec;s.id=r,s.timescale=c,s.codec=f}u.id=S.RemuxerTrackIdConfig.text,e.sampleDuration=0,e.duration=s.duration=E},y.resetContiguity=function(){},A.probe=function(_){return _=_.length>16384?_.subarray(0,16384):_,Object(S.findBox)(_,["moof"]).length>0},y.demux=function(_,T){this.timeOffset=T;var g=_,E=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(g=Object(S.appendUint8Array)(this.remainderData,_));var e=Object(S.segmentValidRange)(g);this.remainderData=e.remainder,E.samples=e.valid||new Uint8Array}else E.samples=g;var s=this.extractID3Track(E,T);return a.samples=Object(S.parseSamples)(T,E),{videoTrack:E,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}},y.flush=function(){var _=this.timeOffset,T=this.videoTrack,g=this.txtTrack;T.samples=this.remainderData||new Uint8Array,this.remainderData=null;var E=this.extractID3Track(T,this.timeOffset);return g.samples=Object(S.parseSamples)(_,T),{videoTrack:T,audioTrack:Object(I.dummyTrack)(),id3Track:E,textTrack:Object(I.dummyTrack)()}},y.extractID3Track=function(_,T){var g=this.id3Track;if(_.samples.length){var E=Object(S.findBox)(_.samples,["emsg"]);E&&E.forEach(function(a){var e=Object(S.parseEmsg)(a);if(x.test(e.schemeIdUri)){var s=Object(R.isFiniteNumber)(e.presentationTime)?e.presentationTime/e.timeScale:T+e.presentationTimeDelta/e.timeScale,u=e.payload;g.samples.push({data:u,len:u.byteLength,dts:s,pts:s,type:p.MetadataSchema.emsg})}})}return g},y.demuxSampleAes=function(_,T,g){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},y.destroy=function(){},A}();P.default=L},"./src/demux/mpegaudio.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"appendFrame",function(){return L}),h.d(P,"parseHeader",function(){return A}),h.d(P,"isHeaderPattern",function(){return y}),h.d(P,"isHeader",function(){return D}),h.d(P,"canParse",function(){return _}),h.d(P,"probe",function(){return T});var R=null,p=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],S=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],I=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],x=[0,1,1,4];function L(g,E,a,e,s){if(!(a+24>E.length)){var u=A(E,a);if(u&&a+u.frameLength<=E.length){var n=u.samplesPerFrame*9e4/u.sampleRate,i=e+s*n,t={unit:E.subarray(a,a+u.frameLength),pts:i,dts:i};return g.config=[],g.channelCount=u.channelCount,g.samplerate=u.sampleRate,g.samples.push(t),{sample:t,length:u.frameLength,missing:0}}}}function A(g,E){var a=g[E+1]>>3&3,e=g[E+1]>>1&3,s=g[E+2]>>4&15,u=g[E+2]>>2&3;if(a!==1&&s!==0&&s!==15&&u!==3){var n=g[E+2]>>1&1,i=g[E+3]>>6,t=a===3?3-e:e===3?3:4,l=p[t*14+s-1]*1e3,d=a===3?0:a===2?1:2,r=S[d*3+u],c=i===3?1:2,f=I[a][e],o=x[e],v=f*8*o,m=Math.floor(f*l/r+n)*o;if(R===null){var O=navigator.userAgent||"",b=O.match(/Chrome\/(\d+)/i);R=b?parseInt(b[1]):0}var M=!!R&&R<=87;return M&&e===2&&l>=224e3&&i===0&&(g[E+3]=g[E+3]|128),{sampleRate:r,channelCount:c,frameLength:m,samplesPerFrame:v}}}function y(g,E){return g[E]===255&&(g[E+1]&224)===224&&(g[E+1]&6)!==0}function D(g,E){return E+1<g.length&&y(g,E)}function _(g,E){var a=4;return y(g,E)&&a<=g.length-E}function T(g,E){if(E+1<g.length&&y(g,E)){var a=4,e=A(g,E),s=a;e!=null&&e.frameLength&&(s=e.frameLength);var u=E+s;return u===g.length||D(g,u)}return!1}},"./src/demux/sample-aes.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/crypt/decrypter.ts"),p=h("./src/demux/tsdemuxer.ts"),S=function(){function I(L,A,y){this.keyData=void 0,this.decrypter=void 0,this.keyData=y,this.decrypter=new R.default(L,A,{removePKCS7Padding:!1})}var x=I.prototype;return x.decryptBuffer=function(A,y){this.decrypter.decrypt(A,this.keyData.key.buffer,this.keyData.iv.buffer,y)},x.decryptAacSample=function(A,y,D,_){var T=A[y].unit;if(!(T.length<=16)){var g=T.subarray(16,T.length-T.length%16),E=g.buffer.slice(g.byteOffset,g.byteOffset+g.length),a=this;this.decryptBuffer(E,function(e){var s=new Uint8Array(e);T.set(s,16),_||a.decryptAacSamples(A,y+1,D)})}},x.decryptAacSamples=function(A,y,D){for(;;y++){if(y>=A.length){D();return}if(!(A[y].unit.length<32)){var _=this.decrypter.isSync();if(this.decryptAacSample(A,y,D,_),!_)return}}},x.getAvcEncryptedData=function(A){for(var y=Math.floor((A.length-48)/160)*16+16,D=new Int8Array(y),_=0,T=32;T<A.length-16;T+=160,_+=16)D.set(A.subarray(T,T+16),_);return D},x.getAvcDecryptedUnit=function(A,y){for(var D=new Uint8Array(y),_=0,T=32;T<A.length-16;T+=160,_+=16)A.set(D.subarray(_,_+16),T);return A},x.decryptAvcSample=function(A,y,D,_,T,g){var E=Object(p.discardEPB)(T.data),a=this.getAvcEncryptedData(E),e=this;this.decryptBuffer(a.buffer,function(s){T.data=e.getAvcDecryptedUnit(E,s),g||e.decryptAvcSamples(A,y,D+1,_)})},x.decryptAvcSamples=function(A,y,D,_){if(A instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;y++,D=0){if(y>=A.length){_();return}for(var T=A[y].units;!(D>=T.length);D++){var g=T[D];if(!(g.data.length<=48||g.type!==1&&g.type!==5)){var E=this.decrypter.isSync();if(this.decryptAvcSample(A,y,D,_,g,E),!E)return}}}},I}();P.default=S},"./src/demux/transmuxer-interface.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return T});var R=h("./node_modules/webworkify-webpack/index.js"),p=h.n(R),S=h("./src/events.ts"),I=h("./src/demux/transmuxer.ts"),x=h("./src/utils/logger.ts"),L=h("./src/errors.ts"),A=h("./src/utils/mediasource-helper.ts"),y=h("./node_modules/eventemitter3/index.js"),D=h.n(y),_=Object(A.getMediaSource)()||{isTypeSupported:function(){return!1}},T=function(){function g(a,e,s,u){var n=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=a,this.id=e,this.onTransmuxComplete=s,this.onFlush=u;var i=a.config,t=function(f,o){o=o||{},o.frag=n.frag,o.id=n.id,a.trigger(f,o)};this.observer=new y.EventEmitter,this.observer.on(S.Events.FRAG_DECRYPTED,t),this.observer.on(S.Events.ERROR,t);var l={mp4:_.isTypeSupported("video/mp4"),mpeg:_.isTypeSupported("audio/mpeg"),mp3:_.isTypeSupported('audio/mp4; codecs="mp3"')},d=navigator.vendor;if(i.enableWorker&&typeof Worker!="undefined"){x.logger.log("demuxing in webworker");var r;try{r=this.worker=R("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),r.addEventListener("message",this.onwmsg),r.onerror=function(c){a.trigger(S.Events.ERROR,{type:L.ErrorTypes.OTHER_ERROR,details:L.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(c.message+" ("+c.filename+":"+c.lineno+")")})},r.postMessage({cmd:"init",typeSupported:l,vendor:d,id:e,config:JSON.stringify(i)})}catch(c){x.logger.warn("Error in worker:",c),x.logger.error("Error while initializing DemuxerWorker, fallback to inline"),r&&self.URL.revokeObjectURL(r.objectURL),this.transmuxer=new I.default(this.observer,l,i,d,e),this.worker=null}}else this.transmuxer=new I.default(this.observer,l,i,d,e)}var E=g.prototype;return E.destroy=function(){var e=this.worker;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.worker=null,this.onwmsg=void 0;else{var s=this.transmuxer;s&&(s.destroy(),this.transmuxer=null)}var u=this.observer;u&&u.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},E.push=function(e,s,u,n,i,t,l,d,r,c){var f,o,v=this;r.transmuxing.start=self.performance.now();var m=this.transmuxer,O=this.worker,b=t?t.start:i.start,M=i.decryptdata,F=this.frag,w=!(F&&i.cc===F.cc),C=!(F&&r.level===F.level),U=F?r.sn-F.sn:-1,B=this.part?r.part-this.part.index:-1,N=U===0&&r.id>1&&r.id===(F==null?void 0:F.stats.chunkCount),k=!C&&(U===1||U===0&&(B===1||N&&B<=0)),j=self.performance.now();(C||U||i.stats.parsing.start===0)&&(i.stats.parsing.start=j),t&&(B||!k)&&(t.stats.parsing.start=j);var H=!(F&&((f=i.initSegment)===null||f===void 0?void 0:f.url)===((o=F.initSegment)===null||o===void 0?void 0:o.url)),V=new I.TransmuxState(w,k,d,C,b,H);if(!k||w||H){x.logger.log("[transmuxer-interface, "+i.type+"]: Starting new transmux session for sn: "+r.sn+" p: "+r.part+" level: "+r.level+" id: "+r.id+`
13
+ discontinuity: `+w+`
14
14
  trackSwitch: `+C+`
15
15
  contiguous: `+k+`
16
16
  accurateTimeOffset: `+d+`
17
- timeOffset: `+P+`
18
- initSegmentChange: `+K);var Y=new b.TransmuxConfig(t,r,i,h,f);this.configureTransmuxer(Y)}if(this.frag=a,this.part=n,O)O.postMessage({cmd:"demux",data:e,decryptdata:M,chunkMeta:u,state:G},e instanceof ArrayBuffer?[e]:[]);else if(m){var V=m.push(e,M,u,G);Object(b.isPromise)(V)?V.then(function(Z){E.handleTransmuxComplete(Z)}):this.handleTransmuxComplete(V)}},p.flush=function(e){var i=this;e.transmuxing.start=self.performance.now();var t=this.transmuxer,r=this.worker;if(r)r.postMessage({cmd:"flush",chunkMeta:e});else if(t){var a=t.flush(e);Object(b.isPromise)(a)?a.then(function(n){i.handleFlushResult(n,e)}):this.handleFlushResult(a,e)}},p.handleFlushResult=function(e,i){var t=this;e.forEach(function(r){t.handleTransmuxComplete(r)}),this.onFlush(i)},p.onWorkerMessage=function(e){var i=e.data,t=this.hls;switch(i.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(i.data);break}case"flush":{this.onFlush(i.data);break}default:{i.data=i.data||{},i.data.frag=this.frag,i.data.id=this.id,t.trigger(i.event,i.data);break}}},p.configureTransmuxer=function(e){var i=this.worker,t=this.transmuxer;i?i.postMessage({cmd:"configure",config:e}):t&&t.configure(e)},p.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},v}()},"./src/demux/transmuxer-worker.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"default",function(){return L});var R=c("./src/demux/transmuxer.ts"),y=c("./src/events.ts"),x=c("./src/utils/logger.ts"),b=c("./node_modules/eventemitter3/index.js"),T=c.n(b);function L(S){var v=new b.EventEmitter,p=function(e,i){S.postMessage({event:e,data:i})};v.on(y.Events.FRAG_DECRYPTED,p),v.on(y.Events.ERROR,p),S.addEventListener("message",function(s){var e=s.data;switch(e.cmd){case"init":{var i=JSON.parse(e.config);S.transmuxer=new R.default(v,e.typeSupported,i,e.vendor,e.id),Object(x.enableLogs)(i.debug),p("init",null);break}case"configure":{S.transmuxer.configure(e.config);break}case"demux":{var t=S.transmuxer.push(e.data,e.decryptdata,e.chunkMeta,e.state);Object(R.isPromise)(t)?t.then(function(n){_(S,n)}):_(S,t);break}case"flush":{var r=e.chunkMeta,a=S.transmuxer.flush(r);Object(R.isPromise)(a)?a.then(function(n){A(S,n,r)}):A(S,a,r);break}default:break}})}function _(S,v){if(!D(v.remuxResult)){var p=[],s=v.remuxResult,e=s.audio,i=s.video;e&&g(p,e),i&&g(p,i),S.postMessage({event:"transmuxComplete",data:v},p)}}function g(S,v){v.data1&&S.push(v.data1.buffer),v.data2&&S.push(v.data2.buffer)}function A(S,v,p){v.forEach(function(s){_(S,s)}),S.postMessage({event:"flush",data:p})}function D(S){return!S.audio&&!S.video&&!S.text&&!S.id3&&!S.initSegment}},"./src/demux/transmuxer.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"default",function(){return i}),c.d(I,"isPromise",function(){return a}),c.d(I,"TransmuxConfig",function(){return n}),c.d(I,"TransmuxState",function(){return h});var R=c("./src/events.ts"),y=c("./src/errors.ts"),x=c("./src/crypt/decrypter.ts"),b=c("./src/demux/aacdemuxer.ts"),T=c("./src/demux/mp4demuxer.ts"),L=c("./src/demux/tsdemuxer.ts"),_=c("./src/demux/mp3demuxer.ts"),g=c("./src/remux/mp4-remuxer.ts"),A=c("./src/remux/passthrough-remuxer.ts"),D=c("./src/demux/chunk-cache.ts"),S=c("./src/utils/mp4-tools.ts"),v=c("./src/utils/logger.ts"),p;try{p=self.performance.now.bind(self.performance)}catch{v.logger.debug("Unable to use Performance API on this environment"),p=self.Date.now}var s=[{demux:L.default,remux:g.default},{demux:T.default,remux:A.default},{demux:b.default,remux:g.default},{demux:_.default,remux:g.default}],e=1024;s.forEach(function(d){var u=d.demux;e=Math.max(e,u.minProbeByteLength)});var i=function(){function d(f,l,o,E,m){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.cache=new D.default,this.observer=f,this.typeSupported=l,this.config=o,this.vendor=E,this.id=m}var u=d.prototype;return u.configure=function(l){this.transmuxConfig=l,this.decrypter&&this.decrypter.reset()},u.push=function(l,o,E,m){var O=this,P=E.transmuxing;P.executeStart=p();var M=new Uint8Array(l),F=this.cache,B=this.config,C=this.currentTransmuxState,U=this.transmuxConfig;m&&(this.currentTransmuxState=m);var w=t(M,o);if(w&&w.method==="AES-128"){var k=this.getDecrypter();if(B.enableSoftwareAES){var j=k.softwareDecrypt(M,w.key.buffer,w.iv.buffer);if(!j)return P.executeEnd=p(),r(E);M=new Uint8Array(j)}else return this.decryptionPromise=k.webCryptoDecrypt(M,w.key.buffer,w.iv.buffer).then(function(Q){var se=O.push(Q,null,E);return O.decryptionPromise=null,se}),this.decryptionPromise}var K=m||C,G=K.contiguous,Y=K.discontinuity,V=K.trackSwitch,Z=K.accurateTimeOffset,z=K.timeOffset,ie=K.initSegmentChange,X=U.audioCodec,ee=U.videoCodec,ce=U.defaultInitPts,ae=U.duration,ve=U.initSegmentData;if((Y||V||ie)&&this.resetInitSegment(ve,X,ee,ae),(Y||ie)&&this.resetInitialTimestamp(ce),G||this.resetContiguity(),this.needsProbing(M,Y,V)){if(F.dataLength){var q=F.flush();M=Object(S.appendUint8Array)(q,M)}this.configureTransmuxer(M,U)}var J=this.transmux(M,w,z,Z,E),$=this.currentTransmuxState;return $.contiguous=!0,$.discontinuity=!1,$.trackSwitch=!1,P.executeEnd=p(),J},u.flush=function(l){var o=this,E=l.transmuxing;E.executeStart=p();var m=this.decrypter,O=this.cache,P=this.currentTransmuxState,M=this.decryptionPromise;if(M)return M.then(function(){return o.flush(l)});var F=[],B=P.timeOffset;if(m){var C=m.flush();C&&F.push(this.push(C,null,l))}var U=O.dataLength;O.reset();var w=this.demuxer,k=this.remuxer;if(!w||!k)return U>=e&&this.observer.emit(R.Events.ERROR,R.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),E.executeEnd=p(),[r(l)];var j=w.flush(B);return a(j)?j.then(function(K){return o.flushRemux(F,K,l),F}):(this.flushRemux(F,j,l),F)},u.flushRemux=function(l,o,E){var m=o.audioTrack,O=o.avcTrack,P=o.id3Track,M=o.textTrack,F=this.currentTransmuxState,B=F.accurateTimeOffset,C=F.timeOffset;v.logger.log("[transmuxer.ts]: Flushed fragment "+E.sn+(E.part>-1?" p: "+E.part:"")+" of level "+E.level);var U=this.remuxer.remux(m,O,P,M,C,B,!0,this.id);l.push({remuxResult:U,chunkMeta:E}),E.transmuxing.executeEnd=p()},u.resetInitialTimestamp=function(l){var o=this.demuxer,E=this.remuxer;!o||!E||(o.resetTimeStamp(l),E.resetTimeStamp(l))},u.resetContiguity=function(){var l=this.demuxer,o=this.remuxer;!l||!o||(l.resetContiguity(),o.resetNextTimestamp())},u.resetInitSegment=function(l,o,E,m){var O=this.demuxer,P=this.remuxer;!O||!P||(O.resetInitSegment(o,E,m),P.resetInitSegment(l,o,E))},u.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},u.transmux=function(l,o,E,m,O){var P;return o&&o.method==="SAMPLE-AES"?P=this.transmuxSampleAes(l,o,E,m,O):P=this.transmuxUnencrypted(l,E,m,O),P},u.transmuxUnencrypted=function(l,o,E,m){var O=this.demuxer.demux(l,o,!1,!this.config.progressive),P=O.audioTrack,M=O.avcTrack,F=O.id3Track,B=O.textTrack,C=this.remuxer.remux(P,M,F,B,o,E,!1,this.id);return{remuxResult:C,chunkMeta:m}},u.transmuxSampleAes=function(l,o,E,m,O){var P=this;return this.demuxer.demuxSampleAes(l,o,E).then(function(M){var F=P.remuxer.remux(M.audioTrack,M.avcTrack,M.id3Track,M.textTrack,E,m,!1,P.id);return{remuxResult:F,chunkMeta:O}})},u.configureTransmuxer=function(l,o){for(var E=this.config,m=this.observer,O=this.typeSupported,P=this.vendor,M=o.audioCodec,F=o.defaultInitPts,B=o.duration,C=o.initSegmentData,U=o.videoCodec,w,k=0,j=s.length;k<j;k++)if(s[k].demux.probe(l)){w=s[k];break}w||(v.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),w={demux:T.default,remux:A.default});var K=this.demuxer,G=this.remuxer,Y=w.remux,V=w.demux;(!G||!(G instanceof Y))&&(this.remuxer=new Y(m,E,O,P)),(!K||!(K instanceof V))&&(this.demuxer=new V(m,E,O),this.probe=V.probe),this.resetInitSegment(C,M,U,B),this.resetInitialTimestamp(F)},u.needsProbing=function(l,o,E){return!this.demuxer||!this.remuxer||o||E},u.getDecrypter=function(){var l=this.decrypter;return l||(l=this.decrypter=new x.default(this.observer,this.config)),l},d}();function t(d,u){var f=null;return d.byteLength>0&&u!=null&&u.key!=null&&u.iv!==null&&u.method!=null&&(f=u),f}var r=function(u){return{remuxResult:{},chunkMeta:u}};function a(d){return"then"in d&&d.then instanceof Function}var n=function(u,f,l,o,E){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=u,this.videoCodec=f,this.initSegmentData=l,this.duration=o,this.defaultInitPts=E},h=function(u,f,l,o,E,m){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=u,this.contiguous=f,this.accurateTimeOffset=l,this.trackSwitch=o,this.timeOffset=E,this.initSegmentChange=m}},"./src/demux/tsdemuxer.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"discardEPB",function(){return r});var R=c("./src/demux/adts.ts"),y=c("./src/demux/mpegaudio.ts"),x=c("./src/demux/exp-golomb.ts"),b=c("./src/demux/id3.ts"),T=c("./src/demux/sample-aes.ts"),L=c("./src/events.ts"),_=c("./src/utils/mp4-tools.ts"),g=c("./src/utils/logger.ts"),A=c("./src/errors.ts"),D={video:1,audio:2,id3:3,text:4},S=function(){function a(h,d,u){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this.aacLastPTS=null,this._initPTS=null,this._initDTS=null,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=h,this.config=d,this.typeSupported=u}a.probe=function(d){var u=a.syncOffset(d);return u<0?!1:(u&&g.logger.warn("MPEG2-TS detected but first sync word found @ offset "+u+", junk ahead ?"),!0)},a.syncOffset=function(d){for(var u=Math.min(1e3,d.length-3*188),f=0;f<u;){if(d[f]===71&&d[f+188]===71&&d[f+2*188]===71)return f;f++}return-1},a.createTrack=function(d,u){return{container:d==="video"||d==="audio"?"video/mp2t":void 0,type:d,id:D[d],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:d==="audio"?u:void 0}};var n=a.prototype;return n.resetInitSegment=function(d,u,f){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=a.createTrack("video",f),this._audioTrack=a.createTrack("audio",f),this._id3Track=a.createTrack("id3",f),this._txtTrack=a.createTrack("text",f),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=d,this.videoCodec=u,this._duration=f},n.resetTimeStamp=function(){},n.resetContiguity=function(){var d=this._audioTrack,u=this._avcTrack,f=this._id3Track;d&&(d.pesData=null),u&&(u.pesData=null),f&&(f.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},n.demux=function(d,u,f,l){f===void 0&&(f=!1),l===void 0&&(l=!1),f||(this.sampleAes=null);var o,E=this._avcTrack,m=this._audioTrack,O=this._id3Track,P=E.pid,M=E.pesData,F=m.pid,B=O.pid,C=m.pesData,U=O.pesData,w=!1,k=this.pmtParsed,j=this._pmtId,K=d.length;if(this.remainderData&&(d=Object(_.appendUint8Array)(this.remainderData,d),K=d.length,this.remainderData=null),K<188&&!l)return this.remainderData=d,{audioTrack:m,avcTrack:E,id3Track:O,textTrack:this._txtTrack};var G=Math.max(0,a.syncOffset(d));K-=(K+G)%188,K<d.byteLength&&!l&&(this.remainderData=new Uint8Array(d.buffer,K,d.buffer.byteLength-K));for(var Y=0,V=G;V<K;V+=188)if(d[V]===71){var Z=!!(d[V+1]&64),z=((d[V+1]&31)<<8)+d[V+2],ie=(d[V+3]&48)>>4,X=void 0;if(ie>1){if(X=V+5+d[V+4],X===V+188)continue}else X=V+4;switch(z){case P:Z&&(M&&(o=e(M))&&this.parseAVCPES(o,!1),M={data:[],size:0}),M&&(M.data.push(d.subarray(X,V+188)),M.size+=V+188-X);break;case F:Z&&(C&&(o=e(C))&&(m.isAAC?this.parseAACPES(o):this.parseMPEGPES(o)),C={data:[],size:0}),C&&(C.data.push(d.subarray(X,V+188)),C.size+=V+188-X);break;case B:Z&&(U&&(o=e(U))&&this.parseID3PES(o),U={data:[],size:0}),U&&(U.data.push(d.subarray(X,V+188)),U.size+=V+188-X);break;case 0:Z&&(X+=d[X]+1),j=this._pmtId=p(d,X);break;case j:{Z&&(X+=d[X]+1);var ee=s(d,X,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,f);P=ee.avc,P>0&&(E.pid=P),F=ee.audio,F>0&&(m.pid=F,m.isAAC=ee.isAAC),B=ee.id3,B>0&&(O.pid=B),w&&!k&&(g.logger.log("reparse from beginning"),w=!1,V=G-188),k=this.pmtParsed=!0;break}case 17:case 8191:break;default:w=!0;break}}else Y++;Y>0&&this.observer.emit(L.Events.ERROR,L.Events.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+Y+" TS packet/s that do not start with 0x47"}),E.pesData=M,m.pesData=C,O.pesData=U;var ce={audioTrack:m,avcTrack:E,id3Track:O,textTrack:this._txtTrack};return l&&this.extractRemainingSamples(ce),ce},n.flush=function(){var d=this.remainderData;this.remainderData=null;var u;return d?u=this.demux(d,-1,!1,!0):u={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(u),this.sampleAes?this.decrypt(u,this.sampleAes):u},n.extractRemainingSamples=function(d){var u=d.audioTrack,f=d.avcTrack,l=d.id3Track,o=f.pesData,E=u.pesData,m=l.pesData,O;o&&(O=e(o))?(this.parseAVCPES(O,!0),f.pesData=null):f.pesData=o,E&&(O=e(E))?(u.isAAC?this.parseAACPES(O):this.parseMPEGPES(O),u.pesData=null):(E!=null&&E.size&&g.logger.log("last AAC PES packet truncated,might overlap between fragments"),u.pesData=E),m&&(O=e(m))?(this.parseID3PES(O),l.pesData=null):l.pesData=m},n.demuxSampleAes=function(d,u,f){var l=this.demux(d,f,!0,!this.config.progressive),o=this.sampleAes=new T.default(this.observer,this.config,u);return this.decrypt(l,o)},n.decrypt=function(d,u){return new Promise(function(f){var l=d.audioTrack,o=d.avcTrack;l.samples&&l.isAAC?u.decryptAacSamples(l.samples,0,function(){o.samples?u.decryptAvcSamples(o.samples,0,0,function(){f(d)}):f(d)}):o.samples&&u.decryptAvcSamples(o.samples,0,0,function(){f(d)})})},n.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},n.parseAVCPES=function(d,u){var f=this,l=this._avcTrack,o=this.parseAVCNALu(d.data),E=!1,m=this.avcSample,O,P=!1;d.data=null,m&&o.length&&!l.audFound&&(i(m,l),m=this.avcSample=v(!1,d.pts,d.dts,"")),o.forEach(function(M){switch(M.type){case 1:{O=!0,m||(m=f.avcSample=v(!0,d.pts,d.dts,"")),E&&(m.debug+="NDR "),m.frame=!0;var F=M.data;if(P&&F.length>4){var B=new x.default(F).readSliceType();(B===2||B===4||B===7||B===9)&&(m.key=!0)}break}case 5:O=!0,m||(m=f.avcSample=v(!0,d.pts,d.dts,"")),E&&(m.debug+="IDR "),m.key=!0,m.frame=!0;break;case 6:{O=!0,E&&m&&(m.debug+="SEI ");var C=new x.default(r(M.data));C.readUByte();for(var U=0,w=0,k=!1,j=0;!k&&C.bytesAvailable>1;){U=0;do j=C.readUByte(),U+=j;while(j===255);w=0;do j=C.readUByte(),w+=j;while(j===255);if(U===4&&C.bytesAvailable!==0){k=!0;var K=C.readUByte();if(K===181){var G=C.readUShort();if(G===49){var Y=C.readUInt();if(Y===1195456820){var V=C.readUByte();if(V===3){for(var Z=C.readUByte(),z=C.readUByte(),ie=31&Z,X=[Z,z],ee=0;ee<ie;ee++)X.push(C.readUByte()),X.push(C.readUByte()),X.push(C.readUByte());t(f._txtTrack.samples,{type:3,pts:d.pts,bytes:X})}}}}}else if(U===5&&C.bytesAvailable!==0){if(k=!0,w>16){for(var ce=[],ae=0;ae<16;ae++)ce.push(C.readUByte().toString(16)),(ae===3||ae===5||ae===7||ae===9)&&ce.push("-");for(var ve=w-16,q=new Uint8Array(ve),J=0;J<ve;J++)q[J]=C.readUByte();t(f._txtTrack.samples,{pts:d.pts,payloadType:U,uuid:ce.join(""),userData:Object(b.utf8ArrayToStr)(q),userDataBytes:q})}}else if(w<C.bytesAvailable)for(var $=0;$<w;$++)C.readUByte()}break}case 7:if(O=!0,P=!0,E&&m&&(m.debug+="SPS "),!l.sps){var Q=new x.default(M.data),se=Q.readSPS();l.width=se.width,l.height=se.height,l.pixelRatio=se.pixelRatio,l.sps=[M.data],l.duration=f._duration;for(var he=M.data.subarray(1,4),ue="avc1.",fe=0;fe<3;fe++){var ge=he[fe].toString(16);ge.length<2&&(ge="0"+ge),ue+=ge}l.codec=ue}break;case 8:O=!0,E&&m&&(m.debug+="PPS "),l.pps||(l.pps=[M.data]);break;case 9:O=!1,l.audFound=!0,m&&i(m,l),m=f.avcSample=v(!1,d.pts,d.dts,E?"AUD ":"");break;case 12:O=!1;break;default:O=!1,m&&(m.debug+="unknown NAL "+M.type+" ");break}if(m&&O){var Ee=m.units;Ee.push(M)}}),u&&m&&(i(m,l),this.avcSample=null)},n.getLastNalUnit=function(){var d,u=this.avcSample,f;if(!u||u.units.length===0){var l=this._avcTrack.samples;u=l[l.length-1]}if((d=u)!==null&&d!==void 0&&d.units){var o=u.units;f=o[o.length-1]}return f},n.parseAVCNALu=function(d){var u=d.byteLength,f=this._avcTrack,l=f.naluState||0,o=l,E=[],m=0,O,P,M,F=-1,B=0;for(l===-1&&(F=0,B=d[0]&31,l=0,m=1);m<u;){if(O=d[m++],!l){l=O?0:1;continue}if(l===1){l=O?0:2;continue}if(!O)l=3;else if(O===1){if(F>=0){var C={data:d.subarray(F,m-l-1),type:B};E.push(C)}else{var U=this.getLastNalUnit();if(U&&(o&&m<=4-o&&U.state&&(U.data=U.data.subarray(0,U.data.byteLength-o)),P=m-l-1,P>0)){var w=new Uint8Array(U.data.byteLength+P);w.set(U.data,0),w.set(d.subarray(0,P),U.data.byteLength),U.data=w,U.state=0}}m<u?(M=d[m]&31,F=m,B=M,l=0):l=-1}else l=0}if(F>=0&&l>=0){var k={data:d.subarray(F,u),type:B,state:l};E.push(k)}if(E.length===0){var j=this.getLastNalUnit();if(j){var K=new Uint8Array(j.data.byteLength+d.byteLength);K.set(j.data,0),K.set(d,j.data.byteLength),j.data=K}}return f.naluState=l,E},n.parseAACPES=function(d){var u=0,f=this._audioTrack,l=this.aacOverFlow,o=d.data;if(l){this.aacOverFlow=null;var E=l.sample.unit.byteLength,m=Math.min(l.missing,E),O=E-m;l.sample.unit.set(o.subarray(0,m),O),f.samples.push(l.sample),u=l.missing}var P,M;for(P=u,M=o.length;P<M-1&&!R.isHeader(o,P);P++);if(P!==u){var F,B;if(P<M-1?(F="AAC PES did not start with ADTS header,offset:"+P,B=!1):(F="no ADTS header found in AAC PES",B=!0),g.logger.warn("parsing error:"+F),this.observer.emit(L.Events.ERROR,L.Events.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.FRAG_PARSING_ERROR,fatal:B,reason:F}),B)return}R.initTrackConfig(f,this.observer,o,P,this.audioCodec);var C;if(d.pts!==void 0)C=d.pts;else if(l){var U=R.getFrameDuration(f.samplerate);C=l.sample.pts+U}else{g.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var w=0;P<M;)if(R.isHeader(o,P)){if(P+5<M){var k=R.appendFrame(f,o,P,C,w);if(k)if(k.missing)this.aacOverFlow=k;else{P+=k.length,w++;continue}}break}else P++},n.parseMPEGPES=function(d){var u=d.data,f=u.length,l=0,o=0,E=d.pts;if(E===void 0){g.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;o<f;)if(y.isHeader(u,o)){var m=y.appendFrame(this._audioTrack,u,o,E,l);if(m)o+=m.length,l++;else break}else o++},n.parseID3PES=function(d){if(d.pts===void 0){g.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(d)},a}();S.minProbeByteLength=188;function v(a,n,h,d){return{key:a,frame:!1,pts:n,dts:h,units:[],debug:d,length:0}}function p(a,n){return(a[n+10]&31)<<8|a[n+11]}function s(a,n,h,d){var u={audio:-1,avc:-1,id3:-1,isAAC:!0},f=(a[n+1]&15)<<8|a[n+2],l=n+3+f-4,o=(a[n+10]&15)<<8|a[n+11];for(n+=12+o;n<l;){var E=(a[n+1]&31)<<8|a[n+2];switch(a[n]){case 207:if(!d){g.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:u.audio===-1&&(u.audio=E);break;case 21:u.id3===-1&&(u.id3=E);break;case 219:if(!d){g.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:u.avc===-1&&(u.avc=E);break;case 3:case 4:h?u.audio===-1&&(u.audio=E,u.isAAC=!1):g.logger.log("MPEG audio found, not supported in this browser");break;case 36:g.logger.warn("Unsupported HEVC stream type found");break;default:break}n+=((a[n+3]&15)<<8|a[n+4])+5}return u}function e(a){var n=0,h,d,u,f,l,o=a.data;if(!a||a.size===0)return null;for(;o[0].length<19&&o.length>1;){var E=new Uint8Array(o[0].length+o[1].length);E.set(o[0]),E.set(o[1],o[0].length),o[0]=E,o.splice(1,1)}h=o[0];var m=(h[0]<<16)+(h[1]<<8)+h[2];if(m===1){if(d=(h[4]<<8)+h[5],d&&d>a.size-6)return null;var O=h[7];O&192&&(f=(h[9]&14)*536870912+(h[10]&255)*4194304+(h[11]&254)*16384+(h[12]&255)*128+(h[13]&254)/2,O&64?(l=(h[14]&14)*536870912+(h[15]&255)*4194304+(h[16]&254)*16384+(h[17]&255)*128+(h[18]&254)/2,f-l>60*9e4&&(g.logger.warn(Math.round((f-l)/9e4)+"s delta between PTS and DTS, align them"),f=l)):l=f),u=h[8];var P=u+9;if(a.size<=P)return null;a.size-=P;for(var M=new Uint8Array(a.size),F=0,B=o.length;F<B;F++){h=o[F];var C=h.byteLength;if(P)if(P>C){P-=C;continue}else h=h.subarray(P),C-=P,P=0;M.set(h,n),n+=C}return d&&(d-=u+3),{data:M,pts:f,dts:l,len:d}}return null}function i(a,n){if(a.units.length&&a.frame){if(a.pts===void 0){var h=n.samples,d=h.length;if(d){var u=h[d-1];a.pts=u.pts,a.dts=u.dts}else{n.dropped++;return}}n.samples.push(a)}a.debug.length&&g.logger.log(a.pts+"/"+a.dts+":"+a.debug)}function t(a,n){var h=a.length;if(h>0){if(n.pts>=a[h-1].pts)a.push(n);else for(var d=h-1;d>=0;d--)if(n.pts<a[d].pts){a.splice(d,0,n);break}}else a.push(n)}function r(a){for(var n=a.byteLength,h=[],d=1;d<n-2;)a[d]===0&&a[d+1]===0&&a[d+2]===3?(h.push(d+2),d+=2):d++;if(h.length===0)return a;var u=n-h.length,f=new Uint8Array(u),l=0;for(d=0;d<u;l++,d++)l===h[0]&&(l++,h.shift()),f[d]=a[l];return f}I.default=S},"./src/errors.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"ErrorTypes",function(){return R}),c.d(I,"ErrorDetails",function(){return y});var R;(function(x){x.NETWORK_ERROR="networkError",x.MEDIA_ERROR="mediaError",x.KEY_SYSTEM_ERROR="keySystemError",x.MUX_ERROR="muxError",x.OTHER_ERROR="otherError"})(R||(R={}));var y;(function(x){x.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",x.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",x.KEY_SYSTEM_NO_SESSION="keySystemNoSession",x.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",x.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",x.MANIFEST_LOAD_ERROR="manifestLoadError",x.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",x.MANIFEST_PARSING_ERROR="manifestParsingError",x.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",x.LEVEL_EMPTY_ERROR="levelEmptyError",x.LEVEL_LOAD_ERROR="levelLoadError",x.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",x.LEVEL_SWITCH_ERROR="levelSwitchError",x.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",x.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",x.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",x.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",x.FRAG_LOAD_ERROR="fragLoadError",x.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",x.FRAG_DECRYPT_ERROR="fragDecryptError",x.FRAG_PARSING_ERROR="fragParsingError",x.REMUX_ALLOC_ERROR="remuxAllocError",x.KEY_LOAD_ERROR="keyLoadError",x.KEY_LOAD_TIMEOUT="keyLoadTimeOut",x.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",x.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",x.BUFFER_APPEND_ERROR="bufferAppendError",x.BUFFER_APPENDING_ERROR="bufferAppendingError",x.BUFFER_STALLED_ERROR="bufferStalledError",x.BUFFER_FULL_ERROR="bufferFullError",x.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",x.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",x.INTERNAL_EXCEPTION="internalException",x.INTERNAL_ABORTED="aborted",x.UNKNOWN="unknown"})(y||(y={}))},"./src/events.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"Events",function(){return R});var R;(function(y){y.MEDIA_ATTACHING="hlsMediaAttaching",y.MEDIA_ATTACHED="hlsMediaAttached",y.MEDIA_DETACHING="hlsMediaDetaching",y.MEDIA_DETACHED="hlsMediaDetached",y.BUFFER_RESET="hlsBufferReset",y.BUFFER_CODECS="hlsBufferCodecs",y.BUFFER_CREATED="hlsBufferCreated",y.BUFFER_APPENDING="hlsBufferAppending",y.BUFFER_APPENDED="hlsBufferAppended",y.BUFFER_EOS="hlsBufferEos",y.BUFFER_FLUSHING="hlsBufferFlushing",y.BUFFER_FLUSHED="hlsBufferFlushed",y.MANIFEST_LOADING="hlsManifestLoading",y.MANIFEST_LOADED="hlsManifestLoaded",y.MANIFEST_PARSED="hlsManifestParsed",y.LEVEL_SWITCHING="hlsLevelSwitching",y.LEVEL_SWITCHED="hlsLevelSwitched",y.LEVEL_LOADING="hlsLevelLoading",y.LEVEL_LOADED="hlsLevelLoaded",y.LEVEL_UPDATED="hlsLevelUpdated",y.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",y.LEVELS_UPDATED="hlsLevelsUpdated",y.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",y.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",y.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",y.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",y.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",y.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",y.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",y.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",y.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",y.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",y.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",y.CUES_PARSED="hlsCuesParsed",y.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",y.INIT_PTS_FOUND="hlsInitPtsFound",y.FRAG_LOADING="hlsFragLoading",y.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",y.FRAG_LOADED="hlsFragLoaded",y.FRAG_DECRYPTED="hlsFragDecrypted",y.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",y.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",y.FRAG_PARSING_METADATA="hlsFragParsingMetadata",y.FRAG_PARSED="hlsFragParsed",y.FRAG_BUFFERED="hlsFragBuffered",y.FRAG_CHANGED="hlsFragChanged",y.FPS_DROP="hlsFpsDrop",y.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",y.ERROR="hlsError",y.DESTROYING="hlsDestroying",y.KEY_LOADING="hlsKeyLoading",y.KEY_LOADED="hlsKeyLoaded",y.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",y.BACK_BUFFER_REACHED="hlsBackBufferReached"})(R||(R={}))},"./src/hls.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"default",function(){return a});var R=c("./node_modules/url-toolkit/src/url-toolkit.js"),y=c.n(R),x=c("./src/loader/playlist-loader.ts"),b=c("./src/loader/key-loader.ts"),T=c("./src/controller/id3-track-controller.ts"),L=c("./src/controller/latency-controller.ts"),_=c("./src/controller/level-controller.ts"),g=c("./src/controller/fragment-tracker.ts"),A=c("./src/controller/stream-controller.ts"),D=c("./src/is-supported.ts"),S=c("./src/utils/logger.ts"),v=c("./src/config.ts"),p=c("./node_modules/eventemitter3/index.js"),s=c.n(p),e=c("./src/events.ts"),i=c("./src/errors.ts");function t(n,h){for(var d=0;d<h.length;d++){var u=h[d];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(n,u.key,u)}}function r(n,h,d){return h&&t(n.prototype,h),d&&t(n,d),n}var a=function(){n.isSupported=function(){return Object(D.isSupported)()};function n(d){d===void 0&&(d={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new p.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var u=this.config=Object(v.mergeConfig)(n.DefaultConfig,d);this.userConfig=d,Object(S.enableLogs)(u.debug),this._autoLevelCapping=-1,u.progressive&&Object(v.enableStreamingMode)(u);var f=u.abrController,l=u.bufferController,o=u.capLevelController,E=u.fpsController,m=this.abrController=new f(this),O=this.bufferController=new l(this),P=this.capLevelController=new o(this),M=new E(this),F=new x.default(this),B=new b.default(this),C=new T.default(this),U=this.levelController=new _.default(this),w=new g.FragmentTracker(this),k=this.streamController=new A.default(this,w);P.setStreamController(k),M.setStreamController(k);var j=[U,k];this.networkControllers=j;var K=[F,B,m,O,P,M,C,w];this.audioTrackController=this.createController(u.audioTrackController,null,j),this.createController(u.audioStreamController,w,j),this.subtitleTrackController=this.createController(u.subtitleTrackController,null,j),this.createController(u.subtitleStreamController,w,j),this.createController(u.timelineController,null,K),this.emeController=this.createController(u.emeController,null,K),this.cmcdController=this.createController(u.cmcdController,null,K),this.latencyController=this.createController(L.default,null,K),this.coreComponents=K}var h=n.prototype;return h.createController=function(u,f,l){if(u){var o=f?new u(this,f):new u(this);return l&&l.push(o),o}return null},h.on=function(u,f,l){l===void 0&&(l=this),this._emitter.on(u,f,l)},h.once=function(u,f,l){l===void 0&&(l=this),this._emitter.once(u,f,l)},h.removeAllListeners=function(u){this._emitter.removeAllListeners(u)},h.off=function(u,f,l,o){l===void 0&&(l=this),this._emitter.off(u,f,l,o)},h.listeners=function(u){return this._emitter.listeners(u)},h.emit=function(u,f,l){return this._emitter.emit(u,f,l)},h.trigger=function(u,f){if(this.config.debug)return this.emit(u,u,f);try{return this.emit(u,u,f)}catch(l){S.logger.error("An internal error happened while handling event "+u+'. Error message: "'+l.message+'". Here is a stacktrace:',l),this.trigger(e.Events.ERROR,{type:i.ErrorTypes.OTHER_ERROR,details:i.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:u,error:l})}return!1},h.listenerCount=function(u){return this._emitter.listenerCount(u)},h.destroy=function(){S.logger.log("destroy"),this.trigger(e.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(u){return u.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(u){return u.destroy()}),this.coreComponents.length=0},h.attachMedia=function(u){S.logger.log("attachMedia"),this._media=u,this.trigger(e.Events.MEDIA_ATTACHING,{media:u})},h.detachMedia=function(){S.logger.log("detachMedia"),this.trigger(e.Events.MEDIA_DETACHING,void 0),this._media=null},h.loadSource=function(u){this.stopLoad();var f=this.media,l=this.url,o=this.url=R.buildAbsoluteURL(self.location.href,u,{alwaysNormalize:!0});S.logger.log("loadSource:"+o),f&&l&&l!==o&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(f)),this.trigger(e.Events.MANIFEST_LOADING,{url:u})},h.startLoad=function(u){u===void 0&&(u=-1),S.logger.log("startLoad("+u+")"),this.networkControllers.forEach(function(f){f.startLoad(u)})},h.stopLoad=function(){S.logger.log("stopLoad"),this.networkControllers.forEach(function(u){u.stopLoad()})},h.swapAudioCodec=function(){S.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},h.recoverMediaError=function(){S.logger.log("recoverMediaError");var u=this._media;this.detachMedia(),u&&this.attachMedia(u)},h.removeLevel=function(u,f){f===void 0&&(f=0),this.levelController.removeLevel(u,f)},r(n,[{key:"levels",get:function(){var u=this.levelController.levels;return u||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(u){S.logger.log("set currentLevel:"+u),this.loadLevel=u,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(u){S.logger.log("set nextLevel:"+u),this.levelController.manualLevel=u,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(u){S.logger.log("set loadLevel:"+u),this.levelController.manualLevel=u}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(u){this.levelController.nextLoadLevel=u}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(u){S.logger.log("set firstLevel:"+u),this.levelController.firstLevel=u}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(u){S.logger.log("set startLevel:"+u),u!==-1&&(u=Math.max(u,this.minAutoLevel)),this.levelController.startLevel=u}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(u){var f=!!u;f!==this.config.capLevelToPlayerSize&&(f?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=f)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(u){this._autoLevelCapping!==u&&(S.logger.log("set autoLevelCapping:"+u),this._autoLevelCapping=u)}},{key:"bandwidthEstimate",get:function(){var u=this.abrController.bwEstimator;return u?u.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var u=this.levels,f=this.config.minAutoBitrate;if(!u)return 0;for(var l=u.length,o=0;o<l;o++)if(u[o].maxBitrate>f)return o;return 0}},{key:"maxAutoLevel",get:function(){var u=this.levels,f=this.autoLevelCapping,l;return f===-1&&u&&u.length?l=u.length-1:l=f,l}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(u){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,u)}},{key:"audioTracks",get:function(){var u=this.audioTrackController;return u?u.audioTracks:[]}},{key:"audioTrack",get:function(){var u=this.audioTrackController;return u?u.audioTrack:-1},set:function(u){var f=this.audioTrackController;f&&(f.audioTrack=u)}},{key:"subtitleTracks",get:function(){var u=this.subtitleTrackController;return u?u.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var u=this.subtitleTrackController;return u?u.subtitleTrack:-1},set:function(u){var f=this.subtitleTrackController;f&&(f.subtitleTrack=u)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var u=this.subtitleTrackController;return u?u.subtitleDisplay:!1},set:function(u){var f=this.subtitleTrackController;f&&(f.subtitleDisplay=u)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(u){this.config.lowLatencyMode=u}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.1.5"}},{key:"Events",get:function(){return e.Events}},{key:"ErrorTypes",get:function(){return i.ErrorTypes}},{key:"ErrorDetails",get:function(){return i.ErrorDetails}},{key:"DefaultConfig",get:function(){return n.defaultConfig?n.defaultConfig:v.hlsDefaultConfig},set:function(u){n.defaultConfig=u}}]),n}();a.defaultConfig=void 0},"./src/is-supported.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"isSupported",function(){return x}),c.d(I,"changeTypeSupported",function(){return b});var R=c("./src/utils/mediasource-helper.ts");function y(){return self.SourceBuffer||self.WebKitSourceBuffer}function x(){var T=Object(R.getMediaSource)();if(!T)return!1;var L=y(),_=T&&typeof T.isTypeSupported=="function"&&T.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),g=!L||L.prototype&&typeof L.prototype.appendBuffer=="function"&&typeof L.prototype.remove=="function";return!!_&&!!g}function b(){var T,L=y();return typeof(L==null||(T=L.prototype)===null||T===void 0?void 0:T.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"default",function(){return S}),c.d(I,"LoadError",function(){return p});var R=c("./src/polyfills/number.ts"),y=c("./src/errors.ts");function x(s,e){s.prototype=Object.create(e.prototype),s.prototype.constructor=s,g(s,e)}function b(s){var e=typeof Map=="function"?new Map:void 0;return b=function(t){if(t===null||!_(t))return t;if(typeof t!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e!="undefined"){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return T(t,arguments,A(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),g(r,t)},b(s)}function T(s,e,i){return L()?T=Reflect.construct:T=function(r,a,n){var h=[null];h.push.apply(h,a);var d=Function.bind.apply(r,h),u=new d;return n&&g(u,n.prototype),u},T.apply(null,arguments)}function L(){if(typeof Reflect=="undefined"||!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 _(s){return Function.toString.call(s).indexOf("[native code]")!==-1}function g(s,e){return g=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t},g(s,e)}function A(s){return A=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},A(s)}var D=Math.pow(2,17),S=function(){function s(i){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=i}var e=s.prototype;return e.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},e.abort=function(){this.loader&&this.loader.abort()},e.load=function(t,r){var a=this,n=t.url;if(!n)return Promise.reject(new p({type:y.ErrorTypes.NETWORK_ERROR,details:y.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,networkDetails:null},"Fragment does not have a "+(n?"part list":"url")));this.abort();var h=this.config,d=h.fLoader,u=h.loader;return new Promise(function(f,l){a.loader&&a.loader.destroy();var o=a.loader=t.loader=d?new d(h):new u(h),E=v(t),m={timeout:h.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:h.fragLoadingMaxRetryTimeout,highWaterMark:D};t.stats=o.stats,o.load(E,m,{onSuccess:function(P,M,F,B){a.resetLoader(t,o),f({frag:t,part:null,payload:P.data,networkDetails:B})},onError:function(P,M,F){a.resetLoader(t,o),l(new p({type:y.ErrorTypes.NETWORK_ERROR,details:y.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:P,networkDetails:F}))},onAbort:function(P,M,F){a.resetLoader(t,o),l(new p({type:y.ErrorTypes.NETWORK_ERROR,details:y.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:t,networkDetails:F}))},onTimeout:function(P,M,F){a.resetLoader(t,o),l(new p({type:y.ErrorTypes.NETWORK_ERROR,details:y.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,networkDetails:F}))},onProgress:function(P,M,F,B){r&&r({frag:t,part:null,payload:F,networkDetails:B})}})})},e.loadPart=function(t,r,a){var n=this;this.abort();var h=this.config,d=h.fLoader,u=h.loader;return new Promise(function(f,l){n.loader&&n.loader.destroy();var o=n.loader=t.loader=d?new d(h):new u(h),E=v(t,r),m={timeout:h.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:h.fragLoadingMaxRetryTimeout,highWaterMark:D};r.stats=o.stats,o.load(E,m,{onSuccess:function(P,M,F,B){n.resetLoader(t,o),n.updateStatsFromPart(t,r);var C={frag:t,part:r,payload:P.data,networkDetails:B};a(C),f(C)},onError:function(P,M,F){n.resetLoader(t,o),l(new p({type:y.ErrorTypes.NETWORK_ERROR,details:y.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:r,response:P,networkDetails:F}))},onAbort:function(P,M,F){t.stats.aborted=r.stats.aborted,n.resetLoader(t,o),l(new p({type:y.ErrorTypes.NETWORK_ERROR,details:y.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:t,part:r,networkDetails:F}))},onTimeout:function(P,M,F){n.resetLoader(t,o),l(new p({type:y.ErrorTypes.NETWORK_ERROR,details:y.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:r,networkDetails:F}))}})})},e.updateStatsFromPart=function(t,r){var a=t.stats,n=r.stats,h=n.total;if(a.loaded+=n.loaded,h){var d=Math.round(t.duration/r.duration),u=Math.min(Math.round(a.loaded/h),d),f=d-u,l=f*Math.round(a.loaded/u);a.total=a.loaded+l}else a.total=Math.max(a.loaded,a.total);var o=a.loading,E=n.loading;o.start?o.first+=E.first-E.start:(o.start=E.start,o.first=E.first),o.end=E.end},e.resetLoader=function(t,r){t.loader=null,this.loader===r&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),r.destroy()},s}();function v(s,e){e===void 0&&(e=null);var i=e||s,t={frag:s,part:e,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},r=i.byteRangeStartOffset,a=i.byteRangeEndOffset;return Object(R.isFiniteNumber)(r)&&Object(R.isFiniteNumber)(a)&&(t.rangeStart=r,t.rangeEnd=a),t}var p=function(s){x(e,s);function e(i){for(var t,r=arguments.length,a=new Array(r>1?r-1:0),n=1;n<r;n++)a[n-1]=arguments[n];return t=s.call.apply(s,[this].concat(a))||this,t.data=void 0,t.data=i,t}return e}(b(Error))},"./src/loader/fragment.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"ElementaryStreamTypes",function(){return S}),c.d(I,"BaseSegment",function(){return v}),c.d(I,"Fragment",function(){return p}),c.d(I,"Part",function(){return s});var R=c("./src/polyfills/number.ts"),y=c("./node_modules/url-toolkit/src/url-toolkit.js"),x=c.n(y),b=c("./src/utils/logger.ts"),T=c("./src/loader/level-key.ts"),L=c("./src/loader/load-stats.ts");function _(e,i){e.prototype=Object.create(i.prototype),e.prototype.constructor=e,g(e,i)}function g(e,i){return g=Object.setPrototypeOf||function(r,a){return r.__proto__=a,r},g(e,i)}function A(e,i){for(var t=0;t<i.length;t++){var r=i[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function D(e,i,t){return i&&A(e.prototype,i),t&&A(e,t),e}var S;(function(e){e.AUDIO="audio",e.VIDEO="video",e.AUDIOVIDEO="audiovideo"})(S||(S={}));var v=function(){function e(t){var r;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(r={},r[S.AUDIO]=null,r[S.VIDEO]=null,r[S.AUDIOVIDEO]=null,r),this.baseurl=t}var i=e.prototype;return i.setByteRange=function(r,a){var n=r.split("@",2),h=[];n.length===1?h[0]=a?a.byteRangeEndOffset:0:h[0]=parseInt(n[1]),h[1]=parseInt(n[0])+h[0],this._byteRange=h},D(e,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(y.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(r){this._url=r}}]),e}(),p=function(e){_(i,e);function i(r,a){var n;return n=e.call(this,a)||this,n._decryptdata=null,n.rawProgramDateTime=null,n.programDateTime=null,n.tagList=[],n.duration=0,n.sn=0,n.levelkey=void 0,n.type=void 0,n.loader=null,n.level=-1,n.cc=0,n.startPTS=void 0,n.endPTS=void 0,n.appendedPTS=void 0,n.startDTS=void 0,n.endDTS=void 0,n.start=0,n.deltaPTS=void 0,n.maxStartPTS=void 0,n.minEndPTS=void 0,n.stats=new L.LoadStats,n.urlId=0,n.data=void 0,n.bitrateTest=!1,n.title=null,n.initSegment=null,n.type=r,n}var t=i.prototype;return t.createInitializationVector=function(a){for(var n=new Uint8Array(16),h=12;h<16;h++)n[h]=a>>8*(15-h)&255;return n},t.setDecryptDataFromLevelKey=function(a,n){var h=a;return(a==null?void 0:a.method)==="AES-128"&&a.uri&&!a.iv&&(h=T.LevelKey.fromURI(a.uri),h.method=a.method,h.iv=this.createInitializationVector(n),h.keyFormat="identity"),h},t.setElementaryStreamInfo=function(a,n,h,d,u,f){f===void 0&&(f=!1);var l=this.elementaryStreams,o=l[a];if(!o){l[a]={startPTS:n,endPTS:h,startDTS:d,endDTS:u,partial:f};return}o.startPTS=Math.min(o.startPTS,n),o.endPTS=Math.max(o.endPTS,h),o.startDTS=Math.min(o.startDTS,d),o.endDTS=Math.max(o.endDTS,u)},t.clearElementaryStreamInfo=function(){var a=this.elementaryStreams;a[S.AUDIO]=null,a[S.VIDEO]=null,a[S.AUDIOVIDEO]=null},D(i,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var a=this.sn;typeof a!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&b.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),a=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,a)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!Object(R.isFiniteNumber)(this.programDateTime))return null;var a=Object(R.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+a*1e3}},{key:"encrypted",get:function(){var a;return!!((a=this.decryptdata)!==null&&a!==void 0&&a.keyFormat&&this.decryptdata.uri)}}]),i}(v),s=function(e){_(i,e);function i(t,r,a,n,h){var d;d=e.call(this,a)||this,d.fragOffset=0,d.duration=0,d.gap=!1,d.independent=!1,d.relurl=void 0,d.fragment=void 0,d.index=void 0,d.stats=new L.LoadStats,d.duration=t.decimalFloatingPoint("DURATION"),d.gap=t.bool("GAP"),d.independent=t.bool("INDEPENDENT"),d.relurl=t.enumeratedString("URI"),d.fragment=r,d.index=n;var u=t.enumeratedString("BYTERANGE");return u&&d.setByteRange(u,h),h&&(d.fragOffset=h.fragOffset+h.duration),d}return D(i,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var r=this.elementaryStreams;return!!(r.audio||r.video||r.audiovideo)}}]),i}(v)},"./src/loader/key-loader.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"default",function(){return b});var R=c("./src/events.ts"),y=c("./src/errors.ts"),x=c("./src/utils/logger.ts"),b=function(){function T(_){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=_,this._registerListeners()}var L=T.prototype;return L._registerListeners=function(){this.hls.on(R.Events.KEY_LOADING,this.onKeyLoading,this)},L._unregisterListeners=function(){this.hls.off(R.Events.KEY_LOADING,this.onKeyLoading)},L.destroy=function(){this._unregisterListeners();for(var g in this.loaders){var A=this.loaders[g];A&&A.destroy()}this.loaders={}},L.onKeyLoading=function(g,A){var D=A.frag,S=D.type,v=this.loaders[S];if(!D.decryptdata){x.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var p=D.decryptdata.uri;if(p!==this.decrypturl||this.decryptkey===null){var s=this.hls.config;if(v&&(x.logger.warn("abort previous key loader for type:"+S),v.abort()),!p){x.logger.warn("key uri is falsy");return}var e=s.loader,i=D.loader=this.loaders[S]=new e(s);this.decrypturl=p,this.decryptkey=null;var t={url:p,frag:D,responseType:"arraybuffer"},r={timeout:s.fragLoadingTimeOut,maxRetry:0,retryDelay:s.fragLoadingRetryDelay,maxRetryDelay:s.fragLoadingMaxRetryTimeout,highWaterMark:0},a={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};i.load(t,r,a)}else this.decryptkey&&(D.decryptdata.key=this.decryptkey,this.hls.trigger(R.Events.KEY_LOADED,{frag:D}))},L.loadsuccess=function(g,A,D){var S=D.frag;if(!S.decryptdata){x.logger.error("after key load, decryptdata unset");return}this.decryptkey=S.decryptdata.key=new Uint8Array(g.data),S.loader=null,delete this.loaders[S.type],this.hls.trigger(R.Events.KEY_LOADED,{frag:S})},L.loaderror=function(g,A){var D=A.frag,S=D.loader;S&&S.abort(),delete this.loaders[D.type],this.hls.trigger(R.Events.ERROR,{type:y.ErrorTypes.NETWORK_ERROR,details:y.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:D,response:g})},L.loadtimeout=function(g,A){var D=A.frag,S=D.loader;S&&S.abort(),delete this.loaders[D.type],this.hls.trigger(R.Events.ERROR,{type:y.ErrorTypes.NETWORK_ERROR,details:y.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:D})},T}()},"./src/loader/level-details.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"LevelDetails",function(){return T});var R=c("./src/polyfills/number.ts");function y(L,_){for(var g=0;g<_.length;g++){var A=_[g];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(L,A.key,A)}}function x(L,_,g){return _&&y(L.prototype,_),g&&y(L,g),L}var b=10,T=function(){function L(g){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.needSidxRanges=!1,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.fragments=[],this.url=g}var _=L.prototype;return _.reloaded=function(A){if(!A){this.advanced=!0,this.updated=!0;return}var D=this.lastPartSn-A.lastPartSn,S=this.lastPartIndex-A.lastPartIndex;this.updated=this.endSN!==A.endSN||!!S||!!D,this.advanced=this.endSN>A.endSN||D>0||D===0&&S>0,this.updated||this.advanced?this.misses=Math.floor(A.misses*.6):this.misses=A.misses+1,this.availabilityDelay=A.availabilityDelay},x(L,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(R.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||b}},{key:"drift",get:function(){var A=this.driftEndTime-this.driftStartTime;if(A>0){var D=this.driftEnd-this.driftStart;return D*1e3/A}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var A;return(A=this.partList)!==null&&A!==void 0&&A.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var A;return(A=this.fragments)!==null&&A!==void 0&&A.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var A;return(A=this.partList)!==null&&A!==void 0&&A.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var A;return(A=this.partList)!==null&&A!==void 0&&A.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),L}()},"./src/loader/level-key.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"LevelKey",function(){return T});var R=c("./node_modules/url-toolkit/src/url-toolkit.js"),y=c.n(R);function x(L,_){for(var g=0;g<_.length;g++){var A=_[g];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(L,A.key,A)}}function b(L,_,g){return _&&x(L.prototype,_),g&&x(L,g),L}var T=function(){L.fromURL=function(g,A){return new L(g,A)},L.fromURI=function(g){return new L(g)};function L(_,g){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,g?this._uri=Object(R.buildAbsoluteURL)(_,g,{alwaysNormalize:!0}):this._uri=_}return b(L,[{key:"uri",get:function(){return this._uri}}]),L}()},"./src/loader/load-stats.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"LoadStats",function(){return R});var R=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"default",function(){return i});var R=c("./src/polyfills/number.ts"),y=c("./node_modules/url-toolkit/src/url-toolkit.js"),x=c.n(y),b=c("./src/loader/fragment.ts"),T=c("./src/loader/level-details.ts"),L=c("./src/loader/level-key.ts"),_=c("./src/utils/attr-list.ts"),g=c("./src/utils/logger.ts"),A=c("./src/utils/codecs.ts"),D=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,S=/#EXT-X-MEDIA:(.*)/g,v=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),p=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(PLAYLIST-TYPE):(.+)/.source,/#EXT-X-(MEDIA-SEQUENCE): *(\d+)/.source,/#EXT-X-(SKIP):(.+)/.source,/#EXT-X-(TARGETDURATION): *(\d+)/.source,/#EXT-X-(KEY):(.+)/.source,/#EXT-X-(START):(.+)/.source,/#EXT-X-(ENDLIST)/.source,/#EXT-X-(DISCONTINUITY-SEQ)UENCE: *(\d+)/.source,/#EXT-X-(DIS)CONTINUITY/.source,/#EXT-X-(VERSION):(\d+)/.source,/#EXT-X-(MAP):(.+)/.source,/#EXT-X-(SERVER-CONTROL):(.+)/.source,/#EXT-X-(PART-INF):(.+)/.source,/#EXT-X-(GAP)/.source,/#EXT-X-(BITRATE):\s*(\d+)/.source,/#EXT-X-(PART):(.+)/.source,/#EXT-X-(PRELOAD-HINT):(.+)/.source,/#EXT-X-(RENDITION-REPORT):(.+)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),s=/\.(mp4|m4s|m4v|m4a)$/i;function e(h){var d,u;return s.test((d=(u=y.parseURL(h))===null||u===void 0?void 0:u.path)!=null?d:"")}var i=function(){function h(){}return h.findGroup=function(u,f){for(var l=0;l<u.length;l++){var o=u[l];if(o.id===f)return o}},h.convertAVC1ToAVCOTI=function(u){var f=u.split(".");if(f.length>2){var l=f.shift()+".";return l+=parseInt(f.shift()).toString(16),l+=("000"+parseInt(f.shift()).toString(16)).substr(-4),l}return u},h.resolve=function(u,f){return y.buildAbsoluteURL(f,u,{alwaysNormalize:!0})},h.parseMasterPlaylist=function(u,f){var l=[],o={},E=!1;D.lastIndex=0;for(var m;(m=D.exec(u))!=null;)if(m[1]){var O=new _.AttrList(m[1]),P={attrs:O,bitrate:O.decimalInteger("AVERAGE-BANDWIDTH")||O.decimalInteger("BANDWIDTH"),name:O.NAME,url:h.resolve(m[2],f)},M=O.decimalResolution("RESOLUTION");M&&(P.width=M.width,P.height=M.height),t((O.CODECS||"").split(/[ ,]+/).filter(function(B){return B}),P),P.videoCodec&&P.videoCodec.indexOf("avc1")!==-1&&(P.videoCodec=h.convertAVC1ToAVCOTI(P.videoCodec)),l.push(P)}else if(m[3]){var F=new _.AttrList(m[3]);F["DATA-ID"]&&(E=!0,o[F["DATA-ID"]]=F)}return{levels:l,sessionData:E?o:null}},h.parseMasterPlaylistMedia=function(u,f,l,o){o===void 0&&(o=[]);var E,m=[],O=0;for(S.lastIndex=0;(E=S.exec(u))!==null;){var P=new _.AttrList(E[1]);if(P.TYPE===l){var M={attrs:P,bitrate:0,id:O++,groupId:P["GROUP-ID"],instreamId:P["INSTREAM-ID"],name:P.NAME||P.LANGUAGE||"",type:l,default:P.bool("DEFAULT"),autoselect:P.bool("AUTOSELECT"),forced:P.bool("FORCED"),lang:P.LANGUAGE,url:P.URI?h.resolve(P.URI,f):""};if(o.length){var F=h.findGroup(o,M.groupId)||o[0];r(M,F,"audioCodec"),r(M,F,"textCodec")}m.push(M)}}return m},h.parseLevelPlaylist=function(u,f,l,o,E){var m=new T.LevelDetails(f),O=m.fragments,P=null,M=0,F=0,B=0,C=0,U=null,w=new b.Fragment(o,f),k,j,K,G=-1,Y=!1;for(v.lastIndex=0,m.m3u8=u;(k=v.exec(u))!==null;){Y&&(Y=!1,w=new b.Fragment(o,f),w.start=B,w.sn=M,w.cc=C,w.level=l,P&&(w.initSegment=P,w.rawProgramDateTime=P.rawProgramDateTime));var V=k[1];if(V){w.duration=parseFloat(V);var Z=(" "+k[2]).slice(1);w.title=Z||null,w.tagList.push(Z?["INF",V,Z]:["INF",V])}else if(k[3])Object(R.isFiniteNumber)(w.duration)&&(w.start=B,K&&(w.levelkey=K),w.sn=M,w.level=l,w.cc=C,w.urlId=E,O.push(w),w.relurl=(" "+k[3]).slice(1),n(w,U),U=w,B+=w.duration,M++,F=0,Y=!0);else if(k[4]){var z=(" "+k[4]).slice(1);U?w.setByteRange(z,U):w.setByteRange(z)}else if(k[5])w.rawProgramDateTime=(" "+k[5]).slice(1),w.tagList.push(["PROGRAM-DATE-TIME",w.rawProgramDateTime]),G===-1&&(G=O.length);else{if(k=k[0].match(p),!k){g.logger.warn("No matches on slow regex match for level playlist!");continue}for(j=1;j<k.length&&typeof k[j]=="undefined";j++);var ie=(" "+k[j]).slice(1),X=(" "+k[j+1]).slice(1),ee=k[j+2]?(" "+k[j+2]).slice(1):"";switch(ie){case"PLAYLIST-TYPE":m.type=X.toUpperCase();break;case"MEDIA-SEQUENCE":M=m.startSN=parseInt(X);break;case"SKIP":{var ce=new _.AttrList(X),ae=ce.decimalInteger("SKIPPED-SEGMENTS");if(Object(R.isFiniteNumber)(ae)){m.skippedSegments=ae;for(var ve=ae;ve--;)O.unshift(null);M+=ae}var q=ce.enumeratedString("RECENTLY-REMOVED-DATERANGES");q&&(m.recentlyRemovedDateranges=q.split(" "));break}case"TARGETDURATION":m.targetduration=parseFloat(X);break;case"VERSION":m.version=parseInt(X);break;case"EXTM3U":break;case"ENDLIST":m.live=!1;break;case"#":(X||ee)&&w.tagList.push(ee?[X,ee]:[X]);break;case"DIS":C++;case"GAP":w.tagList.push([ie]);break;case"BITRATE":w.tagList.push([ie,X]);break;case"DISCONTINUITY-SEQ":C=parseInt(X);break;case"KEY":{var J,$=new _.AttrList(X),Q=$.enumeratedString("METHOD"),se=$.URI,he=$.hexadecimalInteger("IV"),ue=$.enumeratedString("KEYFORMATVERSIONS"),fe=$.enumeratedString("KEYID"),ge=(J=$.enumeratedString("KEYFORMAT"))!=null?J:"identity",Ee=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(Ee.indexOf(ge)>-1){g.logger.warn("Keyformat "+ge+" is not supported from the manifest");continue}else if(ge!=="identity")continue;Q&&(K=L.LevelKey.fromURL(f,se),se&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(Q)>=0&&(K.method=Q,K.keyFormat=ge,fe&&(K.keyID=fe),ue&&(K.keyFormatVersions=ue),K.iv=he));break}case"START":{var oe=new _.AttrList(X),le=oe.decimalFloatingPoint("TIME-OFFSET");Object(R.isFiniteNumber)(le)&&(m.startTimeOffset=le);break}case"MAP":{var Te=new _.AttrList(X);w.relurl=Te.URI,Te.BYTERANGE&&w.setByteRange(Te.BYTERANGE),w.level=l,w.sn="initSegment",K&&(w.levelkey=K),w.initSegment=null,P=w,Y=!0;break}case"SERVER-CONTROL":{var de=new _.AttrList(X);m.canBlockReload=de.bool("CAN-BLOCK-RELOAD"),m.canSkipUntil=de.optionalFloat("CAN-SKIP-UNTIL",0),m.canSkipDateRanges=m.canSkipUntil>0&&de.bool("CAN-SKIP-DATERANGES"),m.partHoldBack=de.optionalFloat("PART-HOLD-BACK",0),m.holdBack=de.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var De=new _.AttrList(X);m.partTarget=De.decimalFloatingPoint("PART-TARGET");break}case"PART":{var ye=m.partList;ye||(ye=m.partList=[]);var Se=F>0?ye[ye.length-1]:void 0,Le=F++,Oe=new b.Part(new _.AttrList(X),w,f,Le,Se);ye.push(Oe),w.duration+=Oe.duration;break}case"PRELOAD-HINT":{var W=new _.AttrList(X);m.preloadHint=W;break}case"RENDITION-REPORT":{var H=new _.AttrList(X);m.renditionReports=m.renditionReports||[],m.renditionReports.push(H);break}default:g.logger.warn("line parsed but not handled: "+k);break}}}U&&!U.relurl?(O.pop(),B-=U.duration,m.partList&&(m.fragmentHint=U)):m.partList&&(n(w,U),w.cc=C,m.fragmentHint=w);var re=O.length,ne=O[0],me=O[re-1];if(B+=m.skippedSegments*m.targetduration,B>0&&re&&me){m.averagetargetduration=B/re;var pe=me.sn;m.endSN=pe!=="initSegment"?pe:0,ne&&(m.startCC=ne.cc,ne.initSegment||m.fragments.every(function(te){return te.relurl&&e(te.relurl)})&&(g.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),w=new b.Fragment(o,f),w.relurl=me.relurl,w.level=l,w.sn="initSegment",ne.initSegment=w,m.needSidxRanges=!0))}else m.endSN=0,m.startCC=0;return m.fragmentHint&&(B+=m.fragmentHint.duration),m.totalduration=B,m.endCC=C,G>0&&a(O,G),m},h}();function t(h,d){["video","audio","text"].forEach(function(u){var f=h.filter(function(o){return Object(A.isCodecType)(o,u)});if(f.length){var l=f.filter(function(o){return o.lastIndexOf("avc1",0)===0||o.lastIndexOf("mp4a",0)===0});d[u+"Codec"]=l.length>0?l[0]:f[0],h=h.filter(function(o){return f.indexOf(o)===-1})}}),d.unknownCodecs=h}function r(h,d,u){var f=d[u];f&&(h[u]=f)}function a(h,d){for(var u=h[d],f=d;f--;){var l=h[f];if(!l)return;l.programDateTime=u.programDateTime-l.duration*1e3,u=l}}function n(h,d){h.rawProgramDateTime?h.programDateTime=Date.parse(h.rawProgramDateTime):d!=null&&d.programDateTime&&(h.programDateTime=d.endProgramDateTime),Object(R.isFiniteNumber)(h.programDateTime)||(h.programDateTime=null,h.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(N,I,c){"use strict";c.r(I);var R=c("./src/polyfills/number.ts"),y=c("./src/events.ts"),x=c("./src/errors.ts"),b=c("./src/utils/logger.ts"),T=c("./src/utils/mp4-tools.ts"),L=c("./src/loader/m3u8-parser.ts"),_=c("./src/types/loader.ts"),g=c("./src/utils/attr-list.ts");function A(v){var p=v.type;switch(p){case _.PlaylistContextType.AUDIO_TRACK:return _.PlaylistLevelType.AUDIO;case _.PlaylistContextType.SUBTITLE_TRACK:return _.PlaylistLevelType.SUBTITLE;default:return _.PlaylistLevelType.MAIN}}function D(v,p){var s=v.url;return(s===void 0||s.indexOf("data:")===0)&&(s=p.url),s}var S=function(){function v(s){this.hls=void 0,this.loaders=Object.create(null),this.hls=s,this.registerListeners()}var p=v.prototype;return p.registerListeners=function(){var e=this.hls;e.on(y.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(y.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(y.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.unregisterListeners=function(){var e=this.hls;e.off(y.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(y.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(y.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.createInternalLoader=function(e){var i=this.hls.config,t=i.pLoader,r=i.loader,a=t||r,n=new a(i);return e.loader=n,this.loaders[e.type]=n,n},p.getInternalLoader=function(e){return this.loaders[e.type]},p.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},p.destroyInternalLoaders=function(){for(var e in this.loaders){var i=this.loaders[e];i&&i.destroy(),this.resetInternalLoader(e)}},p.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},p.onManifestLoading=function(e,i){var t=i.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:_.PlaylistContextType.MANIFEST,url:t,deliveryDirectives:null})},p.onLevelLoading=function(e,i){var t=i.id,r=i.level,a=i.url,n=i.deliveryDirectives;this.load({id:t,groupId:null,level:r,responseType:"text",type:_.PlaylistContextType.LEVEL,url:a,deliveryDirectives:n})},p.onAudioTrackLoading=function(e,i){var t=i.id,r=i.groupId,a=i.url,n=i.deliveryDirectives;this.load({id:t,groupId:r,level:null,responseType:"text",type:_.PlaylistContextType.AUDIO_TRACK,url:a,deliveryDirectives:n})},p.onSubtitleTrackLoading=function(e,i){var t=i.id,r=i.groupId,a=i.url,n=i.deliveryDirectives;this.load({id:t,groupId:r,level:null,responseType:"text",type:_.PlaylistContextType.SUBTITLE_TRACK,url:a,deliveryDirectives:n})},p.load=function(e){var i,t=this.hls.config,r=this.getInternalLoader(e);if(r){var a=r.context;if(a&&a.url===e.url){b.logger.trace("[playlist-loader]: playlist request ongoing");return}b.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),r.abort()}var n,h,d,u;switch(e.type){case _.PlaylistContextType.MANIFEST:n=t.manifestLoadingMaxRetry,h=t.manifestLoadingTimeOut,d=t.manifestLoadingRetryDelay,u=t.manifestLoadingMaxRetryTimeout;break;case _.PlaylistContextType.LEVEL:case _.PlaylistContextType.AUDIO_TRACK:case _.PlaylistContextType.SUBTITLE_TRACK:n=0,h=t.levelLoadingTimeOut;break;default:n=t.levelLoadingMaxRetry,h=t.levelLoadingTimeOut,d=t.levelLoadingRetryDelay,u=t.levelLoadingMaxRetryTimeout;break}if(r=this.createInternalLoader(e),(i=e.deliveryDirectives)!==null&&i!==void 0&&i.part){var f;if(e.type===_.PlaylistContextType.LEVEL&&e.level!==null?f=this.hls.levels[e.level].details:e.type===_.PlaylistContextType.AUDIO_TRACK&&e.id!==null?f=this.hls.audioTracks[e.id].details:e.type===_.PlaylistContextType.SUBTITLE_TRACK&&e.id!==null&&(f=this.hls.subtitleTracks[e.id].details),f){var l=f.partTarget,o=f.targetduration;l&&o&&(h=Math.min(Math.max(l*3,o*.8)*1e3,h))}}var E={timeout:h,maxRetry:n,retryDelay:d,maxRetryDelay:u,highWaterMark:0},m={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};r.load(e,E,m)},p.loadsuccess=function(e,i,t,r){if(r===void 0&&(r=null),t.isSidxRequest){this.handleSidxRequest(e,t),this.handlePlaylistLoaded(e,i,t,r);return}this.resetInternalLoader(t.type);var a=e.data;if(a.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(e,t,"no EXTM3U delimiter",r);return}i.parsing.start=performance.now(),a.indexOf("#EXTINF:")>0||a.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,i,t,r):this.handleMasterPlaylist(e,i,t,r)},p.loaderror=function(e,i,t){t===void 0&&(t=null),this.handleNetworkError(i,t,!1,e)},p.loadtimeout=function(e,i,t){t===void 0&&(t=null),this.handleNetworkError(i,t,!0)},p.handleMasterPlaylist=function(e,i,t,r){var a=this.hls,n=e.data,h=D(e,t),d=L.default.parseMasterPlaylist(n,h),u=d.levels,f=d.sessionData;if(!u.length){this.handleManifestParsingError(e,t,"no level found in manifest",r);return}var l=u.map(function(M){return{id:M.attrs.AUDIO,audioCodec:M.audioCodec}}),o=u.map(function(M){return{id:M.attrs.SUBTITLES,textCodec:M.textCodec}}),E=L.default.parseMasterPlaylistMedia(n,h,"AUDIO",l),m=L.default.parseMasterPlaylistMedia(n,h,"SUBTITLES",o),O=L.default.parseMasterPlaylistMedia(n,h,"CLOSED-CAPTIONS");if(E.length){var P=E.some(function(M){return!M.url});!P&&u[0].audioCodec&&!u[0].attrs.AUDIO&&(b.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),E.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new g.AttrList({}),bitrate:0,url:""}))}a.trigger(y.Events.MANIFEST_LOADED,{levels:u,audioTracks:E,subtitles:m,captions:O,url:h,stats:i,networkDetails:r,sessionData:f})},p.handleTrackOrLevelPlaylist=function(e,i,t,r){var a=this.hls,n=t.id,h=t.level,d=t.type,u=D(e,t),f=Object(R.isFiniteNumber)(n)?n:0,l=Object(R.isFiniteNumber)(h)?h:f,o=A(t),E=L.default.parseLevelPlaylist(e.data,u,l,o,f);if(!E.fragments.length){a.trigger(y.Events.ERROR,{type:x.ErrorTypes.NETWORK_ERROR,details:x.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:u,reason:"no fragments found in level",level:typeof t.level=="number"?t.level:void 0});return}if(d===_.PlaylistContextType.MANIFEST){var m={attrs:new g.AttrList({}),bitrate:0,details:E,name:"",url:u};a.trigger(y.Events.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:u,stats:i,networkDetails:r,sessionData:null})}if(i.parsing.end=performance.now(),E.needSidxRanges){var O,P=(O=E.fragments[0].initSegment)===null||O===void 0?void 0:O.url;this.load({url:P,isSidxRequest:!0,type:d,level:h,levelDetails:E,id:n,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}t.levelDetails=E,this.handlePlaylistLoaded(e,i,t,r)},p.handleSidxRequest=function(e,i){var t=Object(T.parseSegmentIndex)(new Uint8Array(e.data));if(!!t){var r=t.references,a=i.levelDetails;r.forEach(function(n,h){var d=n.info,u=a.fragments[h];u.byteRange.length===0&&u.setByteRange(String(1+d.end-d.start)+"@"+String(d.start)),u.initSegment&&u.initSegment.setByteRange(String(t.moovEndOffset)+"@0")})}},p.handleManifestParsingError=function(e,i,t,r){this.hls.trigger(y.Events.ERROR,{type:x.ErrorTypes.NETWORK_ERROR,details:x.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:i.type===_.PlaylistContextType.MANIFEST,url:e.url,reason:t,response:e,context:i,networkDetails:r})},p.handleNetworkError=function(e,i,t,r){t===void 0&&(t=!1),b.logger.warn("[playlist-loader]: A network "+(t?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var a=x.ErrorDetails.UNKNOWN,n=!1,h=this.getInternalLoader(e);switch(e.type){case _.PlaylistContextType.MANIFEST:a=t?x.ErrorDetails.MANIFEST_LOAD_TIMEOUT:x.ErrorDetails.MANIFEST_LOAD_ERROR,n=!0;break;case _.PlaylistContextType.LEVEL:a=t?x.ErrorDetails.LEVEL_LOAD_TIMEOUT:x.ErrorDetails.LEVEL_LOAD_ERROR,n=!1;break;case _.PlaylistContextType.AUDIO_TRACK:a=t?x.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:x.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,n=!1;break;case _.PlaylistContextType.SUBTITLE_TRACK:a=t?x.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:x.ErrorDetails.SUBTITLE_LOAD_ERROR,n=!1;break}h&&this.resetInternalLoader(e.type);var d={type:x.ErrorTypes.NETWORK_ERROR,details:a,fatal:n,url:e.url,loader:h,context:e,networkDetails:i};r&&(d.response=r),this.hls.trigger(y.Events.ERROR,d)},p.handlePlaylistLoaded=function(e,i,t,r){var a=t.type,n=t.level,h=t.id,d=t.groupId,u=t.loader,f=t.levelDetails,l=t.deliveryDirectives;if(!(f!=null&&f.targetduration)){this.handleManifestParsingError(e,t,"invalid target duration",r);return}if(!!u)switch(f.live&&(u.getCacheAge&&(f.ageHeader=u.getCacheAge()||0),(!u.getCacheAge||isNaN(f.ageHeader))&&(f.ageHeader=0)),a){case _.PlaylistContextType.MANIFEST:case _.PlaylistContextType.LEVEL:this.hls.trigger(y.Events.LEVEL_LOADED,{details:f,level:n||0,id:h||0,stats:i,networkDetails:r,deliveryDirectives:l});break;case _.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(y.Events.AUDIO_TRACK_LOADED,{details:f,id:h||0,groupId:d||"",stats:i,networkDetails:r,deliveryDirectives:l});break;case _.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(y.Events.SUBTITLE_TRACK_LOADED,{details:f,id:h||0,groupId:d||"",stats:i,networkDetails:r,deliveryDirectives:l});break}},v}();I.default=S},"./src/polyfills/number.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"isFiniteNumber",function(){return R}),c.d(I,"MAX_SAFE_INTEGER",function(){return y});var R=Number.isFinite||function(x){return typeof x=="number"&&isFinite(x)},y=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(N,I,c){"use strict";c.r(I);var R=function(){function y(){}return y.getSilentFrame=function(b,T){switch(b){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}},y}();I.default=R},"./src/remux/mp4-generator.ts":function(N,I,c){"use strict";c.r(I);var R=Math.pow(2,32)-1,y=function(){function x(){}return x.init=function(){x.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var T;for(T in x.types)x.types.hasOwnProperty(T)&&(x.types[T]=[T.charCodeAt(0),T.charCodeAt(1),T.charCodeAt(2),T.charCodeAt(3)]);var L=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]),_=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]);x.HDLR_TYPES={video:L,audio:_};var g=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),A=new Uint8Array([0,0,0,0,0,0,0,0]);x.STTS=x.STSC=x.STCO=A,x.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),x.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),x.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),x.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var D=new Uint8Array([105,115,111,109]),S=new Uint8Array([97,118,99,49]),v=new Uint8Array([0,0,0,1]);x.FTYP=x.box(x.types.ftyp,D,v,D,S),x.DINF=x.box(x.types.dinf,x.box(x.types.dref,g))},x.box=function(T){for(var L=8,_=arguments.length,g=new Array(_>1?_-1:0),A=1;A<_;A++)g[A-1]=arguments[A];for(var D=g.length,S=D;D--;)L+=g[D].byteLength;var v=new Uint8Array(L);for(v[0]=L>>24&255,v[1]=L>>16&255,v[2]=L>>8&255,v[3]=L&255,v.set(T,4),D=0,L=8;D<S;D++)v.set(g[D],L),L+=g[D].byteLength;return v},x.hdlr=function(T){return x.box(x.types.hdlr,x.HDLR_TYPES[T])},x.mdat=function(T){return x.box(x.types.mdat,T)},x.mdhd=function(T,L){L*=T;var _=Math.floor(L/(R+1)),g=Math.floor(L%(R+1));return x.box(x.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,T>>24&255,T>>16&255,T>>8&255,T&255,_>>24,_>>16&255,_>>8&255,_&255,g>>24,g>>16&255,g>>8&255,g&255,85,196,0,0]))},x.mdia=function(T){return x.box(x.types.mdia,x.mdhd(T.timescale,T.duration),x.hdlr(T.type),x.minf(T))},x.mfhd=function(T){return x.box(x.types.mfhd,new Uint8Array([0,0,0,0,T>>24,T>>16&255,T>>8&255,T&255]))},x.minf=function(T){return T.type==="audio"?x.box(x.types.minf,x.box(x.types.smhd,x.SMHD),x.DINF,x.stbl(T)):x.box(x.types.minf,x.box(x.types.vmhd,x.VMHD),x.DINF,x.stbl(T))},x.moof=function(T,L,_){return x.box(x.types.moof,x.mfhd(T),x.traf(_,L))},x.moov=function(T){for(var L=T.length,_=[];L--;)_[L]=x.trak(T[L]);return x.box.apply(null,[x.types.moov,x.mvhd(T[0].timescale,T[0].duration)].concat(_).concat(x.mvex(T)))},x.mvex=function(T){for(var L=T.length,_=[];L--;)_[L]=x.trex(T[L]);return x.box.apply(null,[x.types.mvex].concat(_))},x.mvhd=function(T,L){L*=T;var _=Math.floor(L/(R+1)),g=Math.floor(L%(R+1)),A=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,T>>24&255,T>>16&255,T>>8&255,T&255,_>>24,_>>16&255,_>>8&255,_&255,g>>24,g>>16&255,g>>8&255,g&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 x.box(x.types.mvhd,A)},x.sdtp=function(T){var L=T.samples||[],_=new Uint8Array(4+L.length),g,A;for(g=0;g<L.length;g++)A=L[g].flags,_[g+4]=A.dependsOn<<4|A.isDependedOn<<2|A.hasRedundancy;return x.box(x.types.sdtp,_)},x.stbl=function(T){return x.box(x.types.stbl,x.stsd(T),x.box(x.types.stts,x.STTS),x.box(x.types.stsc,x.STSC),x.box(x.types.stsz,x.STSZ),x.box(x.types.stco,x.STCO))},x.avc1=function(T){var L=[],_=[],g,A,D;for(g=0;g<T.sps.length;g++)A=T.sps[g],D=A.byteLength,L.push(D>>>8&255),L.push(D&255),L=L.concat(Array.prototype.slice.call(A));for(g=0;g<T.pps.length;g++)A=T.pps[g],D=A.byteLength,_.push(D>>>8&255),_.push(D&255),_=_.concat(Array.prototype.slice.call(A));var S=x.box(x.types.avcC,new Uint8Array([1,L[3],L[4],L[5],252|3,224|T.sps.length].concat(L).concat([T.pps.length]).concat(_))),v=T.width,p=T.height,s=T.pixelRatio[0],e=T.pixelRatio[1];return x.box(x.types.avc1,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,v>>8&255,v&255,p>>8&255,p&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]),S,x.box(x.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),x.box(x.types.pasp,new Uint8Array([s>>24,s>>16&255,s>>8&255,s&255,e>>24,e>>16&255,e>>8&255,e&255])))},x.esds=function(T){var L=T.config.length;return new Uint8Array([0,0,0,0,3,23+L,0,1,0,4,15+L,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([L]).concat(T.config).concat([6,1,2]))},x.mp4a=function(T){var L=T.samplerate;return x.box(x.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,T.channelCount,0,16,0,0,0,0,L>>8&255,L&255,0,0]),x.box(x.types.esds,x.esds(T)))},x.mp3=function(T){var L=T.samplerate;return x.box(x.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,T.channelCount,0,16,0,0,0,0,L>>8&255,L&255,0,0]))},x.stsd=function(T){return T.type==="audio"?!T.isAAC&&T.codec==="mp3"?x.box(x.types.stsd,x.STSD,x.mp3(T)):x.box(x.types.stsd,x.STSD,x.mp4a(T)):x.box(x.types.stsd,x.STSD,x.avc1(T))},x.tkhd=function(T){var L=T.id,_=T.duration*T.timescale,g=T.width,A=T.height,D=Math.floor(_/(R+1)),S=Math.floor(_%(R+1));return x.box(x.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,L>>24&255,L>>16&255,L>>8&255,L&255,0,0,0,0,D>>24,D>>16&255,D>>8&255,D&255,S>>24,S>>16&255,S>>8&255,S&255,0,0,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,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,g>>8&255,g&255,0,0,A>>8&255,A&255,0,0]))},x.traf=function(T,L){var _=x.sdtp(T),g=T.id,A=Math.floor(L/(R+1)),D=Math.floor(L%(R+1));return x.box(x.types.traf,x.box(x.types.tfhd,new Uint8Array([0,0,0,0,g>>24,g>>16&255,g>>8&255,g&255])),x.box(x.types.tfdt,new Uint8Array([1,0,0,0,A>>24,A>>16&255,A>>8&255,A&255,D>>24,D>>16&255,D>>8&255,D&255])),x.trun(T,_.length+16+20+8+16+8+8),_)},x.trak=function(T){return T.duration=T.duration||4294967295,x.box(x.types.trak,x.tkhd(T),x.mdia(T))},x.trex=function(T){var L=T.id;return x.box(x.types.trex,new Uint8Array([0,0,0,0,L>>24,L>>16&255,L>>8&255,L&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},x.trun=function(T,L){var _=T.samples||[],g=_.length,A=12+16*g,D=new Uint8Array(A),S,v,p,s,e,i;for(L+=8+A,D.set([0,0,15,1,g>>>24&255,g>>>16&255,g>>>8&255,g&255,L>>>24&255,L>>>16&255,L>>>8&255,L&255],0),S=0;S<g;S++)v=_[S],p=v.duration,s=v.size,e=v.flags,i=v.cts,D.set([p>>>24&255,p>>>16&255,p>>>8&255,p&255,s>>>24&255,s>>>16&255,s>>>8&255,s&255,e.isLeading<<2|e.dependsOn,e.isDependedOn<<6|e.hasRedundancy<<4|e.paddingValue<<1|e.isNonSync,e.degradPrio&240<<8,e.degradPrio&15,i>>>24&255,i>>>16&255,i>>>8&255,i&255],12+16*S);return x.box(x.types.trun,D)},x.initSegment=function(T){x.types||x.init();var L=x.moov(T),_=new Uint8Array(x.FTYP.byteLength+L.byteLength);return _.set(x.FTYP),_.set(L,x.FTYP.byteLength),_},x}();y.types=void 0,y.HDLR_TYPES=void 0,y.STTS=void 0,y.STSC=void 0,y.STCO=void 0,y.STSZ=void 0,y.VMHD=void 0,y.SMHD=void 0,y.STSD=void 0,y.FTYP=void 0,y.DINF=void 0,I.default=y},"./src/remux/mp4-remuxer.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"default",function(){return i}),c.d(I,"normalizePts",function(){return t});var R=c("./src/polyfills/number.ts"),y=c("./src/remux/aac-helper.ts"),x=c("./src/remux/mp4-generator.ts"),b=c("./src/events.ts"),T=c("./src/errors.ts"),L=c("./src/utils/logger.ts"),_=c("./src/types/loader.ts"),g=c("./src/utils/timescale-conversion.ts");function A(){return A=Object.assign||function(h){for(var d=1;d<arguments.length;d++){var u=arguments[d];for(var f in u)Object.prototype.hasOwnProperty.call(u,f)&&(h[f]=u[f])}return h},A.apply(this,arguments)}var D=10*1e3,S=1024,v=1152,p=null,s=null,e=!1,i=function(){function h(u,f,l,o){if(o===void 0&&(o=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=u,this.config=f,this.typeSupported=l,this.ISGenerated=!1,p===null){var E=navigator.userAgent||"",m=E.match(/Chrome\/(\d+)/i);p=m?parseInt(m[1]):0}if(s===null){var O=navigator.userAgent.match(/Safari\/(\d+)/i);s=O?parseInt(O[1]):0}e=!!p&&p<75||!!s&&s<600}var d=h.prototype;return d.destroy=function(){},d.resetTimeStamp=function(f){L.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=f},d.resetNextTimestamp=function(){L.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},d.resetInitSegment=function(){L.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},d.getVideoStartPts=function(f){var l=!1,o=f.reduce(function(E,m){var O=m.pts-E;return O<-4294967296?(l=!0,t(E,m.pts)):O>0?E:m.pts},f[0].pts);return l&&L.logger.debug("PTS rollover detected"),o},d.remux=function(f,l,o,E,m,O,P,M){var F,B,C,U,w,k,j=m,K=m,G=f.pid>-1,Y=l.pid>-1,V=l.samples.length,Z=f.samples.length>0,z=V>1,ie=(!G||Z)&&(!Y||z)||this.ISGenerated||P;if(ie){this.ISGenerated||(C=this.generateIS(f,l,m));var X=this.isVideoContiguous,ee=-1;if(z&&(ee=r(l.samples),!X&&this.config.forceKeyFrameOnDiscontinuity))if(k=!0,ee>0){L.logger.warn("[mp4-remuxer]: Dropped "+ee+" out of "+V+" video samples due to a missing keyframe");var ce=this.getVideoStartPts(l.samples);l.samples=l.samples.slice(ee),l.dropped+=ee,K+=(l.samples[0].pts-ce)/(l.timescale||9e4)}else ee===-1&&(L.logger.warn("[mp4-remuxer]: No keyframe found out of "+V+" video samples"),k=!1);if(this.ISGenerated){if(Z&&z){var ae=this.getVideoStartPts(l.samples),ve=t(f.samples[0].pts,ae)-ae,q=ve/l.inputTimeScale;j+=Math.max(0,q),K+=Math.max(0,-q)}if(Z){if(f.samplerate||(L.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),C=this.generateIS(f,l,m)),B=this.remuxAudio(f,j,this.isAudioContiguous,O,Y||z||M===_.PlaylistLevelType.AUDIO?K:void 0),z){var J=B?B.endPTS-B.startPTS:0;l.inputTimeScale||(L.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),C=this.generateIS(f,l,m)),F=this.remuxVideo(l,K,X,J)}}else z&&(F=this.remuxVideo(l,K,X,0));F&&(F.firstKeyFrame=ee,F.independent=ee!==-1)}}return this.ISGenerated&&(o.samples.length&&(w=this.remuxID3(o,m)),E.samples.length&&(U=this.remuxText(E,m))),{audio:B,video:F,initSegment:C,independent:k,text:U,id3:w}},d.generateIS=function(f,l,o){var E=f.samples,m=l.samples,O=this.typeSupported,P={},M=!Object(R.isFiniteNumber)(this._initPTS),F="audio/mp4",B,C,U;if(M&&(B=C=1/0),f.config&&E.length&&(f.timescale=f.samplerate,f.isAAC||(O.mpeg?(F="audio/mpeg",f.codec=""):O.mp3&&(f.codec="mp3")),P.audio={id:"audio",container:F,codec:f.codec,initSegment:!f.isAAC&&O.mpeg?new Uint8Array(0):x.default.initSegment([f]),metadata:{channelCount:f.channelCount}},M&&(U=f.inputTimeScale,B=C=E[0].pts-Math.round(U*o))),l.sps&&l.pps&&m.length&&(l.timescale=l.inputTimeScale,P.video={id:"main",container:"video/mp4",codec:l.codec,initSegment:x.default.initSegment([l]),metadata:{width:l.width,height:l.height}},M)){U=l.inputTimeScale;var w=this.getVideoStartPts(m),k=Math.round(U*o);C=Math.min(C,t(m[0].dts,w)-k),B=Math.min(B,w-k)}if(Object.keys(P).length)return this.ISGenerated=!0,M&&(this._initPTS=B,this._initDTS=C),{tracks:P,initPTS:B,timescale:U}},d.remuxVideo=function(f,l,o,E){var m=f.inputTimeScale,O=f.samples,P=[],M=O.length,F=this._initPTS,B=this.nextAvcDts,C=8,U,w,k,j=Number.POSITIVE_INFINITY,K=Number.NEGATIVE_INFINITY,G=0,Y=!1;if(!o||B===null){var V=l*m,Z=O[0].pts-t(O[0].dts,O[0].pts);B=V-Z}for(var z=0;z<M;z++){var ie=O[z];if(ie.pts=t(ie.pts-F,B),ie.dts=t(ie.dts-F,B),ie.dts>ie.pts){var X=9e4*.2;G=Math.max(Math.min(G,ie.pts-ie.dts),-1*X)}ie.dts<O[z>0?z-1:z].dts&&(Y=!0)}Y&&O.sort(function(Ie,ke){var Me=Ie.dts-ke.dts,Ne=Ie.pts-ke.pts;return Me||Ne}),w=O[0].dts,k=O[O.length-1].dts;var ee=Math.round((k-w)/(M-1));if(G<0){if(G<ee*-2){L.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(g.toMsFromMpegTsClock)(-ee,!0)+" ms");for(var ce=G,ae=0;ae<M;ae++)O[ae].dts=ce=Math.max(ce,O[ae].pts-ee),O[ae].pts=Math.max(ce,O[ae].pts)}else{L.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(g.toMsFromMpegTsClock)(G,!0)+" ms to overcome this issue");for(var ve=0;ve<M;ve++)O[ve].dts=O[ve].dts+G}w=O[0].dts}if(o){var q=w-B,J=q>ee,$=q<-1;if(J||$){J?L.logger.warn("AVC: "+Object(g.toMsFromMpegTsClock)(q,!0)+" ms ("+q+"dts) hole between fragments detected, filling it"):L.logger.warn("AVC: "+Object(g.toMsFromMpegTsClock)(-q,!0)+" ms ("+q+"dts) overlapping between fragments detected"),w=B;var Q=O[0].pts-q;O[0].dts=w,O[0].pts=Q,L.logger.log("Video: First PTS/DTS adjusted: "+Object(g.toMsFromMpegTsClock)(Q,!0)+"/"+Object(g.toMsFromMpegTsClock)(w,!0)+", delta: "+Object(g.toMsFromMpegTsClock)(q,!0)+" ms")}}e&&(w=Math.max(0,w));for(var se=0,he=0,ue=0;ue<M;ue++){for(var fe=O[ue],ge=fe.units,Ee=ge.length,oe=0,le=0;le<Ee;le++)oe+=ge[le].data.length;he+=oe,se+=Ee,fe.length=oe,fe.dts=Math.max(fe.dts,w),fe.pts=Math.max(fe.pts,fe.dts,0),j=Math.min(fe.pts,j),K=Math.max(fe.pts,K)}k=O[M-1].dts;var Te=he+4*se+8,de;try{de=new Uint8Array(Te)}catch{this.observer.emit(b.Events.ERROR,b.Events.ERROR,{type:T.ErrorTypes.MUX_ERROR,details:T.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Te,reason:"fail allocating video mdat "+Te});return}var De=new DataView(de.buffer);De.setUint32(0,Te),de.set(x.default.types.mdat,4);for(var ye=0;ye<M;ye++){for(var Se=O[ye],Le=Se.units,Oe=0,W=0,H=Le.length;W<H;W++){var re=Le[W],ne=re.data,me=re.data.byteLength;De.setUint32(C,me),C+=4,de.set(ne,C),C+=me,Oe+=4+me}if(ye<M-1)U=O[ye+1].dts-Se.dts;else{var pe=this.config,te=Se.dts-O[ye>0?ye-1:ye].dts;if(pe.stretchShortVideoTrack&&this.nextAudioPts!==null){var Ae=Math.floor(pe.maxBufferHole*m),xe=(E?j+E*m:this.nextAudioPts)-Se.pts;xe>Ae?(U=xe-te,U<0&&(U=te),L.logger.log("[mp4-remuxer]: It is approximately "+xe/90+" ms to the next segment; using duration "+U/90+" ms for the last video frame.")):U=te}else U=te}var Re=Math.round(Se.pts-Se.dts);P.push(new a(Se.key,U,Oe,Re))}if(P.length&&p&&p<70){var we=P[0].flags;we.dependsOn=2,we.isNonSync=0}console.assert(U!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=B=k+U,this.isVideoContiguous=!0;var je=x.default.moof(f.sequenceNumber++,w,A({},f,{samples:P})),Pe="video",We={data1:je,data2:de,startPTS:j/m,endPTS:(K+U)/m,startDTS:w/m,endDTS:B/m,type:Pe,hasAudio:!1,hasVideo:!0,nb:P.length,dropped:f.dropped};return f.samples=[],f.dropped=0,console.assert(de.length,"MDAT length must not be zero"),We},d.remuxAudio=function(f,l,o,E,m){var O=f.inputTimeScale,P=f.samplerate?f.samplerate:O,M=O/P,F=f.isAAC?S:v,B=F*M,C=this._initPTS,U=!f.isAAC&&this.typeSupported.mpeg,w=[],k=f.samples,j=U?0:8,K=this.nextAudioPts||-1,G=l*O;if(this.isAudioContiguous=o=o||k.length&&K>0&&(E&&Math.abs(G-K)<9e3||Math.abs(t(k[0].pts-C,G)-K)<20*B),k.forEach(function(ne){ne.pts=t(ne.pts-C,G)}),!o||K<0){if(k=k.filter(function(ne){return ne.pts>=0}),!k.length)return;m===0?K=0:E?K=Math.max(0,G):K=k[0].pts}if(f.isAAC)for(var Y=m!==void 0,V=this.config.maxAudioFramesDrift,Z=0,z=K;Z<k.length;Z++){var ie=k[Z],X=ie.pts,ee=X-z,ce=Math.abs(1e3*ee/O);if(ee<=-V*B&&Y)Z===0&&(L.logger.warn("Audio frame @ "+(X/O).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*ee/O)+" ms."),this.nextAudioPts=K=z=X);else if(ee>=V*B&&ce<D&&Y){var ae=Math.round(ee/B);z=X-ae*B,z<0&&(ae--,z+=B),Z===0&&(this.nextAudioPts=K=z),L.logger.warn("[mp4-remuxer]: Injecting "+ae+" audio frame @ "+(z/O).toFixed(3)+"s due to "+Math.round(1e3*ee/O)+" ms gap.");for(var ve=0;ve<ae;ve++){var q=Math.max(z,0),J=y.default.getSilentFrame(f.manifestCodec||f.codec,f.channelCount);J||(L.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),J=ie.unit.subarray()),k.splice(Z,0,{unit:J,pts:q}),z+=B,Z++}}ie.pts=z,z+=B}for(var $=null,Q=null,se,he=0,ue=k.length;ue--;)he+=k[ue].unit.byteLength;for(var fe=0,ge=k.length;fe<ge;fe++){var Ee=k[fe],oe=Ee.unit,le=Ee.pts;if(Q!==null){var Te=w[fe-1];Te.duration=Math.round((le-Q)/M)}else if(o&&f.isAAC&&(le=K),$=le,he>0){he+=j;try{se=new Uint8Array(he)}catch{this.observer.emit(b.Events.ERROR,b.Events.ERROR,{type:T.ErrorTypes.MUX_ERROR,details:T.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:he,reason:"fail allocating audio mdat "+he});return}if(!U){var de=new DataView(se.buffer);de.setUint32(0,he),se.set(x.default.types.mdat,4)}}else return;se.set(oe,j);var De=oe.byteLength;j+=De,w.push(new a(!0,F,De,0)),Q=le}var ye=w.length;if(!!ye){var Se=w[w.length-1];this.nextAudioPts=K=Q+M*Se.duration;var Le=U?new Uint8Array(0):x.default.moof(f.sequenceNumber++,$/M,A({},f,{samples:w}));f.samples=[];var Oe=$/O,W=K/O,H="audio",re={data1:Le,data2:se,startPTS:Oe,endPTS:W,startDTS:Oe,endDTS:W,type:H,hasAudio:!0,hasVideo:!1,nb:ye};return this.isAudioContiguous=!0,console.assert(se.length,"MDAT length must not be zero"),re}},d.remuxEmptyAudio=function(f,l,o,E){var m=f.inputTimeScale,O=f.samplerate?f.samplerate:m,P=m/O,M=this.nextAudioPts,F=(M!==null?M:E.startDTS*m)+this._initDTS,B=E.endDTS*m+this._initDTS,C=P*S,U=Math.ceil((B-F)/C),w=y.default.getSilentFrame(f.manifestCodec||f.codec,f.channelCount);if(L.logger.warn("[mp4-remuxer]: remux empty Audio"),!w){L.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var k=[],j=0;j<U;j++){var K=F+j*C;k.push({unit:w,pts:K,dts:K})}return f.samples=k,this.remuxAudio(f,l,o,!1)},d.remuxID3=function(f,l){var o=f.samples.length;if(!!o){for(var E=f.inputTimeScale,m=this._initPTS,O=this._initDTS,P=0;P<o;P++){var M=f.samples[P];M.pts=t(M.pts-m,l*E)/E,M.dts=t(M.dts-O,l*E)/E}var F=f.samples;return f.samples=[],{samples:F}}},d.remuxText=function(f,l){var o=f.samples.length;if(!!o){for(var E=f.inputTimeScale,m=this._initPTS,O=0;O<o;O++){var P=f.samples[O];P.pts=t(P.pts-m,l*E)/E}f.samples.sort(function(F,B){return F.pts-B.pts});var M=f.samples;return f.samples=[],{samples:M}}},h}();function t(h,d){var u;if(d===null)return h;for(d<h?u=-8589934592:u=8589934592;Math.abs(h-d)>4294967296;)h+=u;return h}function r(h){for(var d=0;d<h.length;d++)if(h[d].key)return d;return-1}var a=function(d,u,f,l){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=u,this.size=f,this.cts=l,this.flags=new n(d)},n=function(d){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=d?2:1,this.isNonSync=d?0:1}},"./src/remux/passthrough-remuxer.ts":function(N,I,c){"use strict";c.r(I);var R=c("./src/polyfills/number.ts"),y=c("./src/utils/mp4-tools.ts"),x=c("./src/loader/fragment.ts"),b=c("./src/utils/logger.ts"),T=function(){function g(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndDTS=null}var A=g.prototype;return A.destroy=function(){},A.resetTimeStamp=function(S){this.initPTS=S,this.lastEndDTS=null},A.resetNextTimestamp=function(){this.lastEndDTS=null},A.resetInitSegment=function(S,v,p){this.audioCodec=v,this.videoCodec=p,this.generateInitSegment(S),this.emitInitSegment=!0},A.generateInitSegment=function(S){var v=this.audioCodec,p=this.videoCodec;if(!S||!S.byteLength){this.initTracks=void 0,this.initData=void 0;return}var s=this.initData=Object(y.parseInitSegment)(S);v||(v=_(s.audio,x.ElementaryStreamTypes.AUDIO)),p||(p=_(s.video,x.ElementaryStreamTypes.VIDEO));var e={};s.audio&&s.video?e.audiovideo={container:"video/mp4",codec:v+","+p,initSegment:S,id:"main"}:s.audio?e.audio={container:"audio/mp4",codec:v,initSegment:S,id:"audio"}:s.video?e.video={container:"video/mp4",codec:p,initSegment:S,id:"main"}:b.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=e},A.remux=function(S,v,p,s,e){var i=this.initPTS,t=this.lastEndDTS,r={audio:void 0,video:void 0,text:s,id3:p,initSegment:void 0};Object(R.isFiniteNumber)(t)||(t=this.lastEndDTS=e||0);var a=v.samples;if(!a||!a.length)return r;var n={initPTS:void 0,timescale:1},h=this.initData;if((!h||!h.length)&&(this.generateInitSegment(a),h=this.initData),!h||!h.length)return b.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),r;this.emitInitSegment&&(n.tracks=this.initTracks,this.emitInitSegment=!1),Object(R.isFiniteNumber)(i)||(this.initPTS=n.initPTS=i=L(h,a,t));var d=Object(y.getDuration)(a,h),u=t,f=d+u;Object(y.offsetStartDTS)(h,a,i),d>0?this.lastEndDTS=f:(b.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var l=!!h.audio,o=!!h.video,E="";l&&(E+="audio"),o&&(E+="video");var m={data1:a,startPTS:u,startDTS:u,endPTS:f,endDTS:f,type:E,hasAudio:l,hasVideo:o,nb:1,dropped:0};return r.audio=m.type==="audio"?m:void 0,r.video=m.type!=="audio"?m:void 0,r.text=s,r.id3=p,r.initSegment=n,r},g}(),L=function(A,D,S){return Object(y.getStartDTS)(A,D)-S};function _(g,A){var D=g==null?void 0:g.codec;return D&&D.length>4?D:D==="hvc1"?"hvc1.1.c.L120.90":D==="av01"?"av01.0.04M.08":D==="avc1"||A===x.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}I.default=T},"./src/task-loop.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"default",function(){return R});var R=function(){function y(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var x=y.prototype;return x.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},x.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},x.onHandlerDestroyed=function(){},x.hasInterval=function(){return!!this._tickInterval},x.hasNextTick=function(){return!!this._tickTimer},x.setInterval=function(T){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,T),!0)},x.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},x.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},x.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},x.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},x.doTick=function(){},y}()},"./src/types/cmcd.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"CMCDVersion",function(){return R}),c.d(I,"CMCDObjectType",function(){return y}),c.d(I,"CMCDStreamingFormat",function(){return x}),c.d(I,"CMCDStreamType",function(){return b});var R=1,y;(function(T){T.MANIFEST="m",T.AUDIO="a",T.VIDEO="v",T.MUXED="av",T.INIT="i",T.CAPTION="c",T.TIMED_TEXT="tt",T.KEY="k",T.OTHER="o"})(y||(y={}));var x;(function(T){T.DASH="d",T.HLS="h",T.SMOOTH="s",T.OTHER="o"})(x||(x={}));var b;(function(T){T.VOD="v",T.LIVE="l"})(b||(b={}))},"./src/types/level.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"HlsSkip",function(){return x}),c.d(I,"getSkipValue",function(){return b}),c.d(I,"HlsUrlParameters",function(){return T}),c.d(I,"Level",function(){return L});function R(_,g){for(var A=0;A<g.length;A++){var D=g[A];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(_,D.key,D)}}function y(_,g,A){return g&&R(_.prototype,g),A&&R(_,A),_}var x;(function(_){_.No="",_.Yes="YES",_.v2="v2"})(x||(x={}));function b(_,g){var A=_.canSkipUntil,D=_.canSkipDateRanges,S=_.endSN,v=g!==void 0?g-S:0;return A&&v<A?D?x.v2:x.Yes:x.No}var T=function(){function _(A,D,S){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=A,this.part=D,this.skip=S}var g=_.prototype;return g.addDirectives=function(D){var S=new self.URL(D);return this.msn!==void 0&&S.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&S.searchParams.set("_HLS_part",this.part.toString()),this.skip&&S.searchParams.set("_HLS_skip",this.skip),S.toString()},_}(),L=function(){function _(g){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[g.url],this.attrs=g.attrs,this.bitrate=g.bitrate,g.details&&(this.details=g.details),this.id=g.id||0,this.name=g.name,this.width=g.width||0,this.height=g.height||0,this.audioCodec=g.audioCodec,this.videoCodec=g.videoCodec,this.unknownCodecs=g.unknownCodecs,this.codecSet=[g.videoCodec,g.audioCodec].filter(function(A){return A}).join(",").replace(/\.[^.,]+/g,"")}return y(_,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(A){var D=A%this.url.length;this._urlId!==D&&(this.details=void 0,this._urlId=D)}}]),_}()},"./src/types/loader.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"PlaylistContextType",function(){return R}),c.d(I,"PlaylistLevelType",function(){return y});var R;(function(x){x.MANIFEST="manifest",x.LEVEL="level",x.AUDIO_TRACK="audioTrack",x.SUBTITLE_TRACK="subtitleTrack"})(R||(R={}));var y;(function(x){x.MAIN="main",x.AUDIO="audio",x.SUBTITLE="subtitle"})(y||(y={}))},"./src/types/transmuxer.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"ChunkMetadata",function(){return R});var R=function(b,T,L,_,g,A){_===void 0&&(_=0),g===void 0&&(g=-1),A===void 0&&(A=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=y(),this.buffering={audio:y(),video:y(),audiovideo:y()},this.level=b,this.sn=T,this.id=L,this.size=_,this.part=g,this.partial=A};function y(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"AttrList",function(){return x});var R=/^(\d+)x(\d+)$/,y=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,x=function(){function b(L){typeof L=="string"&&(L=b.parseAttrList(L));for(var _ in L)L.hasOwnProperty(_)&&(this[_]=L[_])}var T=b.prototype;return T.decimalInteger=function(_){var g=parseInt(this[_],10);return g>Number.MAX_SAFE_INTEGER?1/0:g},T.hexadecimalInteger=function(_){if(this[_]){var g=(this[_]||"0x").slice(2);g=(g.length&1?"0":"")+g;for(var A=new Uint8Array(g.length/2),D=0;D<g.length/2;D++)A[D]=parseInt(g.slice(D*2,D*2+2),16);return A}else return null},T.hexadecimalIntegerAsNumber=function(_){var g=parseInt(this[_],16);return g>Number.MAX_SAFE_INTEGER?1/0:g},T.decimalFloatingPoint=function(_){return parseFloat(this[_])},T.optionalFloat=function(_,g){var A=this[_];return A?parseFloat(A):g},T.enumeratedString=function(_){return this[_]},T.bool=function(_){return this[_]==="YES"},T.decimalResolution=function(_){var g=R.exec(this[_]);if(g!==null)return{width:parseInt(g[1],10),height:parseInt(g[2],10)}},b.parseAttrList=function(_){var g,A={},D='"';for(y.lastIndex=0;(g=y.exec(_))!==null;){var S=g[2];S.indexOf(D)===0&&S.lastIndexOf(D)===S.length-1&&(S=S.slice(1,-1)),A[g[1]]=S}return A},b}()},"./src/utils/binary-search.ts":function(N,I,c){"use strict";c.r(I);var R={search:function(x,b){for(var T=0,L=x.length-1,_=null,g=null;T<=L;){_=(T+L)/2|0,g=x[_];var A=b(g);if(A>0)T=_+1;else if(A<0)L=_-1;else return g}return null}};I.default=R},"./src/utils/buffer-helper.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"BufferHelper",function(){return x});var R=c("./src/utils/logger.ts"),y={length:0,start:function(){return 0},end:function(){return 0}},x=function(){function b(){}return b.isBuffered=function(L,_){try{if(L){for(var g=b.getBuffered(L),A=0;A<g.length;A++)if(_>=g.start(A)&&_<=g.end(A))return!0}}catch{}return!1},b.bufferInfo=function(L,_,g){try{if(L){var A=b.getBuffered(L),D=[],S;for(S=0;S<A.length;S++)D.push({start:A.start(S),end:A.end(S)});return this.bufferedInfo(D,_,g)}}catch{}return{len:0,start:_,end:_,nextStart:void 0}},b.bufferedInfo=function(L,_,g){_=Math.max(0,_),L.sort(function(n,h){var d=n.start-h.start;return d||h.end-n.end});var A=[];if(g)for(var D=0;D<L.length;D++){var S=A.length;if(S){var v=A[S-1].end;L[D].start-v<g?L[D].end>v&&(A[S-1].end=L[D].end):A.push(L[D])}else A.push(L[D])}else A=L;for(var p=0,s,e=_,i=_,t=0;t<A.length;t++){var r=A[t].start,a=A[t].end;if(_+g>=r&&_<a)e=r,i=a,p=i-_;else if(_+g<r){s=r;break}}return{len:p,start:e||0,end:i||0,nextStart:s}},b.getBuffered=function(L){try{return L.buffered}catch(_){return R.logger.log("failed to get media.buffered",_),y}},b}()},"./src/utils/cea-608-parser.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"Row",function(){return i}),c.d(I,"CaptionScreen",function(){return t});var R=c("./src/utils/logger.ts"),y={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},x=function(f){var l=f;return y.hasOwnProperty(f)&&(l=y[f]),String.fromCharCode(l)},b=15,T=100,L={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},_={17:2,18:4,21:6,22:8,23:10,19:13,20:15},g={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},A={25:2,26:4,29:6,30:8,31:10,27:13,28:15},D=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],S;(function(u){u[u.ERROR=0]="ERROR",u[u.TEXT=1]="TEXT",u[u.WARNING=2]="WARNING",u[u.INFO=2]="INFO",u[u.DEBUG=3]="DEBUG",u[u.DATA=3]="DATA"})(S||(S={}));var v=function(){function u(){this.time=null,this.verboseLevel=S.ERROR}var f=u.prototype;return f.log=function(o,E){this.verboseLevel>=o&&R.logger.log(this.time+" ["+o+"] "+E)},u}(),p=function(f){for(var l=[],o=0;o<f.length;o++)l.push(f[o].toString(16));return l},s=function(){function u(l,o,E,m,O){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=l||"white",this.underline=o||!1,this.italics=E||!1,this.background=m||"black",this.flash=O||!1}var f=u.prototype;return f.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},f.setStyles=function(o){for(var E=["foreground","underline","italics","background","flash"],m=0;m<E.length;m++){var O=E[m];o.hasOwnProperty(O)&&(this[O]=o[O])}},f.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},f.equals=function(o){return this.foreground===o.foreground&&this.underline===o.underline&&this.italics===o.italics&&this.background===o.background&&this.flash===o.flash},f.copy=function(o){this.foreground=o.foreground,this.underline=o.underline,this.italics=o.italics,this.background=o.background,this.flash=o.flash},f.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},u}(),e=function(){function u(l,o,E,m,O,P){this.uchar=void 0,this.penState=void 0,this.uchar=l||" ",this.penState=new s(o,E,m,O,P)}var f=u.prototype;return f.reset=function(){this.uchar=" ",this.penState.reset()},f.setChar=function(o,E){this.uchar=o,this.penState.copy(E)},f.setPenState=function(o){this.penState.copy(o)},f.equals=function(o){return this.uchar===o.uchar&&this.penState.equals(o.penState)},f.copy=function(o){this.uchar=o.uchar,this.penState.copy(o.penState)},f.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},u}(),i=function(){function u(l){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var o=0;o<T;o++)this.chars.push(new e);this.logger=l,this.pos=0,this.currPenState=new s}var f=u.prototype;return f.equals=function(o){for(var E=!0,m=0;m<T;m++)if(!this.chars[m].equals(o.chars[m])){E=!1;break}return E},f.copy=function(o){for(var E=0;E<T;E++)this.chars[E].copy(o.chars[E])},f.isEmpty=function(){for(var o=!0,E=0;E<T;E++)if(!this.chars[E].isEmpty()){o=!1;break}return o},f.setCursor=function(o){this.pos!==o&&(this.pos=o),this.pos<0?(this.logger.log(S.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>T&&(this.logger.log(S.DEBUG,"Too large cursor position "+this.pos),this.pos=T)},f.moveCursor=function(o){var E=this.pos+o;if(o>1)for(var m=this.pos+1;m<E+1;m++)this.chars[m].setPenState(this.currPenState);this.setCursor(E)},f.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},f.insertChar=function(o){o>=144&&this.backSpace();var E=x(o);if(this.pos>=T){this.logger.log(S.ERROR,"Cannot insert "+o.toString(16)+" ("+E+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(E,this.currPenState),this.moveCursor(1)},f.clearFromPos=function(o){var E;for(E=o;E<T;E++)this.chars[E].reset()},f.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},f.clearToEndOfRow=function(){this.clearFromPos(this.pos)},f.getTextString=function(){for(var o=[],E=!0,m=0;m<T;m++){var O=this.chars[m].uchar;O!==" "&&(E=!1),o.push(O)}return E?"":o.join("")},f.setPenStyles=function(o){this.currPenState.setStyles(o);var E=this.chars[this.pos];E.setPenState(this.currPenState)},u}(),t=function(){function u(l){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var o=0;o<b;o++)this.rows.push(new i(l));this.logger=l,this.currRow=b-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var f=u.prototype;return f.reset=function(){for(var o=0;o<b;o++)this.rows[o].clear();this.currRow=b-1},f.equals=function(o){for(var E=!0,m=0;m<b;m++)if(!this.rows[m].equals(o.rows[m])){E=!1;break}return E},f.copy=function(o){for(var E=0;E<b;E++)this.rows[E].copy(o.rows[E])},f.isEmpty=function(){for(var o=!0,E=0;E<b;E++)if(!this.rows[E].isEmpty()){o=!1;break}return o},f.backSpace=function(){var o=this.rows[this.currRow];o.backSpace()},f.clearToEndOfRow=function(){var o=this.rows[this.currRow];o.clearToEndOfRow()},f.insertChar=function(o){var E=this.rows[this.currRow];E.insertChar(o)},f.setPen=function(o){var E=this.rows[this.currRow];E.setPenStyles(o)},f.moveCursor=function(o){var E=this.rows[this.currRow];E.moveCursor(o)},f.setCursor=function(o){this.logger.log(S.INFO,"setCursor: "+o);var E=this.rows[this.currRow];E.setCursor(o)},f.setPAC=function(o){this.logger.log(S.INFO,"pacData = "+JSON.stringify(o));var E=o.row-1;if(this.nrRollUpRows&&E<this.nrRollUpRows-1&&(E=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==E){for(var m=0;m<b;m++)this.rows[m].clear();var O=this.currRow+1-this.nrRollUpRows,P=this.lastOutputScreen;if(P){var M=P.rows[O].cueStartTime,F=this.logger.time;if(M&&F!==null&&M<F)for(var B=0;B<this.nrRollUpRows;B++)this.rows[E-this.nrRollUpRows+B+1].copy(P.rows[O+B])}}this.currRow=E;var C=this.rows[this.currRow];if(o.indent!==null){var U=o.indent,w=Math.max(U-1,0);C.setCursor(o.indent),o.color=C.chars[w].penState.foreground}var k={foreground:o.color,underline:o.underline,italics:o.italics,background:"black",flash:!1};this.setPen(k)},f.setBkgData=function(o){this.logger.log(S.INFO,"bkgData = "+JSON.stringify(o)),this.backSpace(),this.setPen(o),this.insertChar(32)},f.setRollUpRows=function(o){this.nrRollUpRows=o},f.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(S.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(S.TEXT,this.getDisplayText());var o=this.currRow+1-this.nrRollUpRows,E=this.rows.splice(o,1)[0];E.clear(),this.rows.splice(this.currRow,0,E),this.logger.log(S.INFO,"Rolling up")},f.getDisplayText=function(o){o=o||!1;for(var E=[],m="",O=-1,P=0;P<b;P++){var M=this.rows[P].getTextString();M&&(O=P+1,o?E.push("Row "+O+": '"+M+"'"):E.push(M.trim()))}return E.length>0&&(o?m="["+E.join(" | ")+"]":m=E.join(`
19
- `)),m},f.getTextAndFormat=function(){return this.rows},u}(),r=function(){function u(l,o,E){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=l,this.outputFilter=o,this.mode=null,this.verbose=0,this.displayedMemory=new t(E),this.nonDisplayedMemory=new t(E),this.lastOutputScreen=new t(E),this.currRollUpRow=this.displayedMemory.rows[b-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=E}var f=u.prototype;return f.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[b-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},f.getHandler=function(){return this.outputFilter},f.setHandler=function(o){this.outputFilter=o},f.setPAC=function(o){this.writeScreen.setPAC(o)},f.setBkgData=function(o){this.writeScreen.setBkgData(o)},f.setMode=function(o){o!==this.mode&&(this.mode=o,this.logger.log(S.INFO,"MODE="+o),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=o)},f.insertChars=function(o){for(var E=0;E<o.length;E++)this.writeScreen.insertChar(o[E]);var m=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(S.INFO,m+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(S.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},f.ccRCL=function(){this.logger.log(S.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},f.ccBS=function(){this.logger.log(S.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},f.ccAOF=function(){},f.ccAON=function(){},f.ccDER=function(){this.logger.log(S.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},f.ccRU=function(o){this.logger.log(S.INFO,"RU("+o+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(o)},f.ccFON=function(){this.logger.log(S.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},f.ccRDC=function(){this.logger.log(S.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},f.ccTR=function(){this.logger.log(S.INFO,"TR"),this.setMode("MODE_TEXT")},f.ccRTD=function(){this.logger.log(S.INFO,"RTD"),this.setMode("MODE_TEXT")},f.ccEDM=function(){this.logger.log(S.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},f.ccCR=function(){this.logger.log(S.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},f.ccENM=function(){this.logger.log(S.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},f.ccEOC=function(){if(this.logger.log(S.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var o=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=o,this.writeScreen=this.nonDisplayedMemory,this.logger.log(S.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},f.ccTO=function(o){this.logger.log(S.INFO,"TO("+o+") - Tab Offset"),this.writeScreen.moveCursor(o)},f.ccMIDROW=function(o){var E={flash:!1};if(E.underline=o%2==1,E.italics=o>=46,E.italics)E.foreground="white";else{var m=Math.floor(o/2)-16,O=["white","green","blue","cyan","red","yellow","magenta"];E.foreground=O[m]}this.logger.log(S.INFO,"MIDROW: "+JSON.stringify(E)),this.writeScreen.setPen(E)},f.outputDataUpdate=function(o){o===void 0&&(o=!1);var E=this.logger.time;E!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=E:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,E,this.lastOutputScreen),o&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:E),this.lastOutputScreen.copy(this.displayedMemory))},f.cueSplitAtTime=function(o){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,o,this.displayedMemory),this.cueStartTime=o))},u}(),a=function(){function u(l,o,E){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var m=new v;this.channels=[null,new r(l,o,m),new r(l+1,E,m)],this.cmdHistory=d(),this.logger=m}var f=u.prototype;return f.getHandler=function(o){return this.channels[o].getHandler()},f.setHandler=function(o,E){this.channels[o].setHandler(E)},f.addData=function(o,E){var m,O,P,M=!1;this.logger.time=o;for(var F=0;F<E.length;F+=2)if(O=E[F]&127,P=E[F+1]&127,!(O===0&&P===0)){if(this.logger.log(S.DATA,"["+p([E[F],E[F+1]])+"] -> ("+p([O,P])+")"),m=this.parseCmd(O,P),m||(m=this.parseMidrow(O,P)),m||(m=this.parsePAC(O,P)),m||(m=this.parseBackgroundAttributes(O,P)),!m&&(M=this.parseChars(O,P),M)){var B=this.currentChannel;if(B&&B>0){var C=this.channels[B];C.insertChars(M)}else this.logger.log(S.WARNING,"No channel found yet. TEXT-MODE?")}!m&&!M&&this.logger.log(S.WARNING,"Couldn't parse cleaned data "+p([O,P])+" orig: "+p([E[F],E[F+1]]))}},f.parseCmd=function(o,E){var m=this.cmdHistory,O=(o===20||o===28||o===21||o===29)&&E>=32&&E<=47,P=(o===23||o===31)&&E>=33&&E<=35;if(!(O||P))return!1;if(h(o,E,m))return n(null,null,m),this.logger.log(S.DEBUG,"Repeated command ("+p([o,E])+") is dropped"),!0;var M=o===20||o===21||o===23?1:2,F=this.channels[M];return o===20||o===21||o===28||o===29?E===32?F.ccRCL():E===33?F.ccBS():E===34?F.ccAOF():E===35?F.ccAON():E===36?F.ccDER():E===37?F.ccRU(2):E===38?F.ccRU(3):E===39?F.ccRU(4):E===40?F.ccFON():E===41?F.ccRDC():E===42?F.ccTR():E===43?F.ccRTD():E===44?F.ccEDM():E===45?F.ccCR():E===46?F.ccENM():E===47&&F.ccEOC():F.ccTO(E-32),n(o,E,m),this.currentChannel=M,!0},f.parseMidrow=function(o,E){var m=0;if((o===17||o===25)&&E>=32&&E<=47){if(o===17?m=1:m=2,m!==this.currentChannel)return this.logger.log(S.ERROR,"Mismatch channel in midrow parsing"),!1;var O=this.channels[m];return O?(O.ccMIDROW(E),this.logger.log(S.DEBUG,"MIDROW ("+p([o,E])+")"),!0):!1}return!1},f.parsePAC=function(o,E){var m,O=this.cmdHistory,P=(o>=17&&o<=23||o>=25&&o<=31)&&E>=64&&E<=127,M=(o===16||o===24)&&E>=64&&E<=95;if(!(P||M))return!1;if(h(o,E,O))return n(null,null,O),!0;var F=o<=23?1:2;E>=64&&E<=95?m=F===1?L[o]:g[o]:m=F===1?_[o]:A[o];var B=this.channels[F];return B?(B.setPAC(this.interpretPAC(m,E)),n(o,E,O),this.currentChannel=F,!0):!1},f.interpretPAC=function(o,E){var m,O={color:null,italics:!1,indent:null,underline:!1,row:o};return E>95?m=E-96:m=E-64,O.underline=(m&1)==1,m<=13?O.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(m/2)]:m<=15?(O.italics=!0,O.color="white"):O.indent=Math.floor((m-16)/2)*4,O},f.parseChars=function(o,E){var m,O=null,P=null;if(o>=25?(m=2,P=o-8):(m=1,P=o),P>=17&&P<=19){var M;P===17?M=E+80:P===18?M=E+112:M=E+144,this.logger.log(S.INFO,"Special char '"+x(M)+"' in channel "+m),O=[M]}else o>=32&&o<=127&&(O=E===0?[o]:[o,E]);if(O){var F=p(O);this.logger.log(S.DEBUG,"Char codes = "+F.join(",")),n(o,E,this.cmdHistory)}return O},f.parseBackgroundAttributes=function(o,E){var m=(o===16||o===24)&&E>=32&&E<=47,O=(o===23||o===31)&&E>=45&&E<=47;if(!(m||O))return!1;var P,M={};o===16||o===24?(P=Math.floor((E-32)/2),M.background=D[P],E%2==1&&(M.background=M.background+"_semi")):E===45?M.background="transparent":(M.foreground="black",E===47&&(M.underline=!0));var F=o<=23?1:2,B=this.channels[F];return B.setBkgData(M),n(o,E,this.cmdHistory),!0},f.reset=function(){for(var o=0;o<Object.keys(this.channels).length;o++){var E=this.channels[o];E&&E.reset()}this.cmdHistory=d()},f.cueSplitAtTime=function(o){for(var E=0;E<this.channels.length;E++){var m=this.channels[E];m&&m.cueSplitAtTime(o)}},u}();function n(u,f,l){l.a=u,l.b=f}function h(u,f,l){return l.a===u&&l.b===f}function d(){return{a:null,b:null}}I.default=a},"./src/utils/codecs.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"isCodecType",function(){return y}),c.d(I,"isCodecSupportedInMp4",function(){return x});var R={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function y(b,T){var L=R[T];return!!L&&L[b.slice(0,4)]===!0}function x(b,T){return MediaSource.isTypeSupported((T||"video")+'/mp4;codecs="'+b+'"')}},"./src/utils/cues.ts":function(N,I,c){"use strict";c.r(I);var R=c("./src/utils/vttparser.ts"),y=c("./src/utils/webvtt-parser.ts"),x=c("./src/utils/texttrack-utils.ts"),b=/\s/,T={newCue:function(_,g,A,D){for(var S=[],v,p,s,e,i,t=self.VTTCue||self.TextTrackCue,r=0;r<D.rows.length;r++)if(v=D.rows[r],s=!0,e=0,i="",!v.isEmpty()){for(var a=0;a<v.chars.length;a++)b.test(v.chars[a].uchar)&&s?e++:(i+=v.chars[a].uchar,s=!1);v.cueStartTime=g,g===A&&(A+=1e-4),e>=16?e--:e++;var n=Object(R.fixLineBreaks)(i.trim()),h=Object(y.generateCueId)(g,A,n);(!_||!_.cues||!_.cues.getCueById(h))&&(p=new t(g,A,n),p.id=h,p.line=r+1,p.align="left",p.position=10+Math.min(80,Math.floor(e*8/32)*10),S.push(p))}return _&&S.length&&(S.sort(function(d,u){return d.line==="auto"||u.line==="auto"?0:d.line>8&&u.line>8?u.line-d.line:d.line-u.line}),S.forEach(function(d){return Object(x.addCueToTrack)(_,d)})),S}};I.default=T},"./src/utils/discontinuities.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"findFirstFragWithCC",function(){return b}),c.d(I,"shouldAlignOnDiscontinuities",function(){return T}),c.d(I,"findDiscontinuousReferenceFrag",function(){return L}),c.d(I,"adjustSlidingStart",function(){return g}),c.d(I,"alignStream",function(){return A}),c.d(I,"alignPDT",function(){return S}),c.d(I,"alignFragmentByPDTDelta",function(){return v}),c.d(I,"alignMediaPlaylistByPDT",function(){return p});var R=c("./src/polyfills/number.ts"),y=c("./src/utils/logger.ts"),x=c("./src/controller/level-helper.ts");function b(s,e){for(var i=null,t=0,r=s.length;t<r;t++){var a=s[t];if(a&&a.cc===e){i=a;break}}return i}function T(s,e,i){return!!(e.details&&(i.endCC>i.startCC||s&&s.cc<i.startCC))}function L(s,e){var i=s.fragments,t=e.fragments;if(!t.length||!i.length){y.logger.log("No fragments to align");return}var r=b(i,t[0].cc);if(!r||r&&!r.startPTS){y.logger.log("No frag in previous level to align on");return}return r}function _(s,e){if(s){var i=s.start+e;s.start=s.startPTS=i,s.endPTS=i+s.duration}}function g(s,e){for(var i=e.fragments,t=0,r=i.length;t<r;t++)_(i[t],s);e.fragmentHint&&_(e.fragmentHint,s),e.alignedSliding=!0}function A(s,e,i){!e||(D(s,i,e),!i.alignedSliding&&e.details&&S(i,e.details),!i.alignedSliding&&e.details&&!i.skippedSegments&&Object(x.adjustSliding)(e.details,i))}function D(s,e,i){if(T(s,i,e)){var t=L(i.details,e);t&&Object(R.isFiniteNumber)(t.start)&&(y.logger.log("Adjusting PTS using last level due to CC increase within current level "+e.url),g(t.start,e))}}function S(s,e){if(!(!e.fragments.length||!s.hasProgramDateTime||!e.hasProgramDateTime)){var i=e.fragments[0].programDateTime,t=s.fragments[0].programDateTime,r=(t-i)/1e3+e.fragments[0].start;r&&Object(R.isFiniteNumber)(r)&&(y.logger.log("Adjusting PTS using programDateTime delta "+(t-i)+"ms, sliding:"+r.toFixed(3)+" "+s.url+" "),g(r,s))}}function v(s,e){var i=s.programDateTime;if(!!i){var t=(i-e)/1e3;s.start=s.startPTS=t,s.endPTS=t+s.duration}}function p(s,e){if(!(!e.fragments.length||!s.hasProgramDateTime||!e.hasProgramDateTime)){var i=e.fragments[0].programDateTime,t=e.fragments[0].start,r=i-t*1e3;s.fragments.forEach(function(a){v(a,r)}),s.fragmentHint&&v(s.fragmentHint,r),s.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":function(N,I,c){"use strict";c.r(I);var R=c("./src/utils/ewma.ts"),y=function(){function x(T,L,_){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=_,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new R.default(T),this.fast_=new R.default(L)}var b=x.prototype;return b.update=function(L,_){var g=this.slow_,A=this.fast_;this.slow_.halfLife!==L&&(this.slow_=new R.default(L,g.getEstimate(),g.getTotalWeight())),this.fast_.halfLife!==_&&(this.fast_=new R.default(_,A.getEstimate(),A.getTotalWeight()))},b.sample=function(L,_){L=Math.max(L,this.minDelayMs_);var g=8*_,A=L/1e3,D=g/A;this.fast_.sample(A,D),this.slow_.sample(A,D)},b.canEstimate=function(){var L=this.fast_;return L&&L.getTotalWeight()>=this.minWeight_},b.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},b.destroy=function(){},x}();I.default=y},"./src/utils/ewma.ts":function(N,I,c){"use strict";c.r(I);var R=function(){function y(b,T,L){T===void 0&&(T=0),L===void 0&&(L=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=b,this.alpha_=b?Math.exp(Math.log(.5)/b):0,this.estimate_=T,this.totalWeight_=L}var x=y.prototype;return x.sample=function(T,L){var _=Math.pow(this.alpha_,T);this.estimate_=L*(1-_)+_*this.estimate_,this.totalWeight_+=T},x.getTotalWeight=function(){return this.totalWeight_},x.getEstimate=function(){if(this.alpha_){var T=1-Math.pow(this.alpha_,this.totalWeight_);if(T)return this.estimate_/T}return this.estimate_},y}();I.default=R},"./src/utils/fetch-loader.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"fetchSupported",function(){return v});var R=c("./src/polyfills/number.ts"),y=c("./src/loader/load-stats.ts"),x=c("./src/demux/chunk-cache.ts");function b(t,r){t.prototype=Object.create(r.prototype),t.prototype.constructor=t,A(t,r)}function T(t){var r=typeof Map=="function"?new Map:void 0;return T=function(n){if(n===null||!g(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(typeof r!="undefined"){if(r.has(n))return r.get(n);r.set(n,h)}function h(){return L(n,arguments,D(this).constructor)}return h.prototype=Object.create(n.prototype,{constructor:{value:h,enumerable:!1,writable:!0,configurable:!0}}),A(h,n)},T(t)}function L(t,r,a){return _()?L=Reflect.construct:L=function(h,d,u){var f=[null];f.push.apply(f,d);var l=Function.bind.apply(h,f),o=new l;return u&&A(o,u.prototype),o},L.apply(null,arguments)}function _(){if(typeof Reflect=="undefined"||!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 g(t){return Function.toString.call(t).indexOf("[native code]")!==-1}function A(t,r){return A=Object.setPrototypeOf||function(n,h){return n.__proto__=h,n},A(t,r)}function D(t){return D=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},D(t)}function S(){return S=Object.assign||function(t){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(t[n]=a[n])}return t},S.apply(this,arguments)}function v(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var p=function(){function t(a){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=a.fetchSetup||e,this.controller=new self.AbortController,this.stats=new y.LoadStats}var r=t.prototype;return r.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},r.abortInternal=function(){var n=this.response;(!n||!n.ok)&&(this.stats.aborted=!0,this.controller.abort())},r.abort=function(){var n;this.abortInternal(),(n=this.callbacks)!==null&&n!==void 0&&n.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},r.load=function(n,h,d){var u=this,f=this.stats;if(f.loading.start)throw new Error("Loader can only be used once.");f.loading.start=self.performance.now();var l=s(n,this.controller.signal),o=d.onProgress,E=n.responseType==="arraybuffer",m=E?"byteLength":"length";this.context=n,this.config=h,this.callbacks=d,this.request=this.fetchSetup(n,l),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){u.abortInternal(),d.onTimeout(f,n,u.response)},h.timeout),self.fetch(this.request).then(function(O){if(u.response=u.loader=O,!O.ok){var P=O.status,M=O.statusText;throw new i(M||"fetch, bad network response",P,O)}return f.loading.first=Math.max(self.performance.now(),f.loading.start),f.total=parseInt(O.headers.get("Content-Length")||"0"),o&&Object(R.isFiniteNumber)(h.highWaterMark)?u.loadProgressively(O,f,n,h.highWaterMark,o):E?O.arrayBuffer():O.text()}).then(function(O){var P=u.response;self.clearTimeout(u.requestTimeout),f.loading.end=Math.max(self.performance.now(),f.loading.first),f.loaded=f.total=O[m];var M={url:P.url,data:O};o&&!Object(R.isFiniteNumber)(h.highWaterMark)&&o(f,n,O,P),d.onSuccess(M,f,n,P)}).catch(function(O){if(self.clearTimeout(u.requestTimeout),!f.aborted){var P=O.code||0;d.onError({code:P,text:O.message},n,O.details)}})},r.getCacheAge=function(){var n=null;if(this.response){var h=this.response.headers.get("age");n=h?parseFloat(h):null}return n},r.loadProgressively=function(n,h,d,u,f){u===void 0&&(u=0);var l=new x.default,o=n.body.getReader(),E=function m(){return o.read().then(function(O){if(O.done)return l.dataLength&&f(h,d,l.flush(),n),Promise.resolve(new ArrayBuffer(0));var P=O.value,M=P.length;return h.loaded+=M,M<u||l.dataLength?(l.push(P),l.dataLength>=u&&f(h,d,l.flush(),n)):f(h,d,P,n),m()}).catch(function(){return Promise.reject()})};return E()},t}();function s(t,r){var a={method:"GET",mode:"cors",credentials:"same-origin",signal:r,headers:new self.Headers(S({},t.headers))};return t.rangeEnd&&a.headers.set("Range","bytes="+t.rangeStart+"-"+String(t.rangeEnd-1)),a}function e(t,r){return new self.Request(t.url,r)}var i=function(t){b(r,t);function r(a,n,h){var d;return d=t.call(this,a)||this,d.code=void 0,d.details=void 0,d.code=n,d.details=h,d}return r}(T(Error));I.default=p},"./src/utils/imsc1-ttml-parser.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"IMSC1_CODEC",function(){return g}),c.d(I,"parseIMSC1",function(){return v});var R=c("./src/utils/mp4-tools.ts"),y=c("./src/utils/vttparser.ts"),x=c("./src/utils/vttcue.ts"),b=c("./src/demux/id3.ts"),T=c("./src/utils/timescale-conversion.ts"),L=c("./src/utils/webvtt-parser.ts");function _(){return _=Object.assign||function(u){for(var f=1;f<arguments.length;f++){var l=arguments[f];for(var o in l)Object.prototype.hasOwnProperty.call(l,o)&&(u[o]=l[o])}return u},_.apply(this,arguments)}var g="stpp.ttml.im1t",A=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,D=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,S={left:"start",center:"center",right:"end",start:"start",end:"end"};function v(u,f,l,o,E){var m=Object(R.findBox)(new Uint8Array(u),["mdat"]);if(m.length===0){E(new Error("Could not parse IMSC1 mdat"));return}var O=m[0],P=Object(b.utf8ArrayToStr)(new Uint8Array(u,O.start,O.end-O.start)),M=Object(T.toTimescaleFromScale)(f,1,l);try{o(p(P,M))}catch(F){E(F)}}function p(u,f){var l=new DOMParser,o=l.parseFromString(u,"text/xml"),E=o.getElementsByTagName("tt")[0];if(!E)throw new Error("Invalid ttml");var m={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},O=Object.keys(m).reduce(function(C,U){return C[U]=E.getAttribute("ttp:"+U)||m[U],C},{}),P=E.getAttribute("xml:space")!=="preserve",M=e(s(E,"styling","style")),F=e(s(E,"layout","region")),B=s(E,"body","[begin]");return[].map.call(B,function(C){var U=i(C,P);if(!U||!C.hasAttribute("begin"))return null;var w=n(C.getAttribute("begin"),O),k=n(C.getAttribute("dur"),O),j=n(C.getAttribute("end"),O);if(w===null)throw a(C);if(j===null){if(k===null)throw a(C);j=w+k}var K=new x.default(w-f,j-f,U);K.id=Object(L.generateCueId)(K.startTime,K.endTime,K.text);var G=F[C.getAttribute("region")],Y=M[C.getAttribute("style")];K.position=10,K.size=80;var V=t(G,Y),Z=V.textAlign;if(Z){var z=S[Z];z&&(K.lineAlign=z),K.align=Z}return _(K,V),K}).filter(function(C){return C!==null})}function s(u,f,l){var o=u.getElementsByTagName(f)[0];return o?[].slice.call(o.querySelectorAll(l)):[]}function e(u){return u.reduce(function(f,l){var o=l.getAttribute("xml:id");return o&&(f[o]=l),f},{})}function i(u,f){return[].slice.call(u.childNodes).reduce(function(l,o,E){var m;return o.nodeName==="br"&&E?l+`
20
- `:(m=o.childNodes)!==null&&m!==void 0&&m.length?i(o,f):f?l+o.textContent.trim().replace(/\s+/g," "):l+o.textContent},"")}function t(u,f){var l="http://www.w3.org/ns/ttml#styling",o=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return o.reduce(function(E,m){var O=r(f,l,m)||r(u,l,m);return O&&(E[m]=O),E},{})}function r(u,f,l){return u.hasAttributeNS(f,l)?u.getAttributeNS(f,l):null}function a(u){return new Error("Could not parse ttml timestamp "+u)}function n(u,f){if(!u)return null;var l=Object(y.parseTimeStamp)(u);return l===null&&(A.test(u)?l=h(u,f):D.test(u)&&(l=d(u,f))),l}function h(u,f){var l=A.exec(u),o=(l[4]|0)+(l[5]|0)/f.subFrameRate;return(l[1]|0)*3600+(l[2]|0)*60+(l[3]|0)+o/f.frameRate}function d(u,f){var l=D.exec(u),o=Number(l[1]),E=l[2];switch(E){case"h":return o*3600;case"m":return o*60;case"ms":return o*1e3;case"f":return o/f.frameRate;case"t":return o/f.tickRate}return o}},"./src/utils/logger.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"enableLogs",function(){return L}),c.d(I,"logger",function(){return _});var R=function(){},y={trace:R,debug:R,log:R,warn:R,info:R,error:R},x=y;function b(g){var A=self.console[g];return A?A.bind(self.console,"["+g+"] >"):R}function T(g){for(var A=arguments.length,D=new Array(A>1?A-1:0),S=1;S<A;S++)D[S-1]=arguments[S];D.forEach(function(v){x[v]=g[v]?g[v].bind(g):b(v)})}function L(g){if(self.console&&g===!0||typeof g=="object"){T(g,"debug","log","info","warn","error");try{x.log()}catch{x=y}}else x=y}var _=x},"./src/utils/mediakeys-helper.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"KeySystems",function(){return R}),c.d(I,"requestMediaKeySystemAccess",function(){return y});var R;(function(x){x.WIDEVINE="com.widevine.alpha",x.PLAYREADY="com.microsoft.playready"})(R||(R={}));var y=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"getMediaSource",function(){return R});function R(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"bin2str",function(){return T}),c.d(I,"readUint16",function(){return L}),c.d(I,"readUint32",function(){return _}),c.d(I,"writeUint32",function(){return g}),c.d(I,"findBox",function(){return A}),c.d(I,"parseSegmentIndex",function(){return D}),c.d(I,"parseInitSegment",function(){return S}),c.d(I,"getStartDTS",function(){return v}),c.d(I,"getDuration",function(){return p}),c.d(I,"computeRawDurationFromSamples",function(){return s}),c.d(I,"offsetStartDTS",function(){return e}),c.d(I,"segmentValidRange",function(){return i}),c.d(I,"appendUint8Array",function(){return t});var R=c("./src/utils/typed-array.ts"),y=c("./src/loader/fragment.ts"),x=Math.pow(2,32)-1,b=[].push;function T(r){return String.fromCharCode.apply(null,r)}function L(r,a){"data"in r&&(a+=r.start,r=r.data);var n=r[a]<<8|r[a+1];return n<0?65536+n:n}function _(r,a){"data"in r&&(a+=r.start,r=r.data);var n=r[a]<<24|r[a+1]<<16|r[a+2]<<8|r[a+3];return n<0?4294967296+n:n}function g(r,a,n){"data"in r&&(a+=r.start,r=r.data),r[a]=n>>24,r[a+1]=n>>16&255,r[a+2]=n>>8&255,r[a+3]=n&255}function A(r,a){var n=[];if(!a.length)return n;var h,d,u;"data"in r?(h=r.data,d=r.start,u=r.end):(h=r,d=0,u=h.byteLength);for(var f=d;f<u;){var l=_(h,f),o=T(h.subarray(f+4,f+8)),E=l>1?f+l:u;if(o===a[0])if(a.length===1)n.push({data:h,start:f+8,end:E});else{var m=A({data:h,start:f+8,end:E},a.slice(1));m.length&&b.apply(n,m)}f=E}return n}function D(r){var a=A(r,["moov"]),n=a[0],h=n?n.end:null,d=A(r,["sidx"]);if(!d||!d[0])return null;var u=[],f=d[0],l=f.data[0],o=l===0?8:16,E=_(f,o);o+=4;var m=0,O=0;l===0?o+=8:o+=16,o+=2;var P=f.end+O,M=L(f,o);o+=2;for(var F=0;F<M;F++){var B=o,C=_(f,B);B+=4;var U=C&2147483647,w=(C&2147483648)>>>31;if(w===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var k=_(f,B);B+=4,u.push({referenceSize:U,subsegmentDuration:k,info:{duration:k/E,start:P,end:P+U-1}}),P+=U,B+=4,o=B}return{earliestPresentationTime:m,timescale:E,version:l,referencesCount:M,references:u,moovEndOffset:h}}function S(r){for(var a=[],n=A(r,["moov","trak"]),h=0;h<n.length;h++){var d=n[h],u=A(d,["tkhd"])[0];if(u){var f=u.data[u.start],l=f===0?12:20,o=_(u,l),E=A(d,["mdia","mdhd"])[0];if(E){f=E.data[E.start],l=f===0?12:20;var m=_(E,l),O=A(d,["mdia","hdlr"])[0];if(O){var P=T(O.data.subarray(O.start+8,O.start+12)),M={soun:y.ElementaryStreamTypes.AUDIO,vide:y.ElementaryStreamTypes.VIDEO}[P];if(M){var F=A(d,["mdia","minf","stbl","stsd"])[0],B=void 0;F&&(B=T(F.data.subarray(F.start+12,F.start+16))),a[o]={timescale:m,type:M},a[M]={timescale:m,id:o,codec:B}}}}}}var C=A(r,["moov","mvex","trex"]);return C.forEach(function(U){var w=_(U,4),k=a[w];k&&(k.default={duration:_(U,12),flags:_(U,20)})}),a}function v(r,a){return A(a,["moof","traf"]).reduce(function(n,h){var d=A(h,["tfdt"])[0],u=d.data[d.start],f=A(h,["tfhd"]).reduce(function(l,o){var E=_(o,4),m=r[E];if(m){var O=_(d,4);u===1&&(O*=Math.pow(2,32),O+=_(d,8));var P=m.timescale||9e4,M=O/P;if(isFinite(M)&&(l===null||M<l))return M}return l},null);return f!==null&&isFinite(f)&&(n===null||f<n)?f:n},null)||0}function p(r,a){for(var n=0,h=0,d=0,u=A(r,["moof","traf"]),f=0;f<u.length;f++){var l=u[f],o=A(l,["tfhd"])[0],E=_(o,4),m=a[E];if(!!m){var O=m.default,P=_(o,0)|(O==null?void 0:O.flags),M=O==null?void 0:O.duration;P&8&&(P&2?M=_(o,12):M=_(o,8));for(var F=m.timescale||9e4,B=A(l,["trun"]),C=0;C<B.length;C++){if(n=s(B[C]),!n&&M){var U=_(B[C],4);n=M*U}m.type===y.ElementaryStreamTypes.VIDEO?h+=n/F:m.type===y.ElementaryStreamTypes.AUDIO&&(d+=n/F)}}}if(h===0&&d===0){var w=D(r);if(w!=null&&w.references)return w.references.reduce(function(k,j){return k+j.info.duration||0},0)}return h||d}function s(r){var a=_(r,0),n=8;a&1&&(n+=4),a&4&&(n+=4);for(var h=0,d=_(r,4),u=0;u<d;u++){if(a&256){var f=_(r,n);h+=f,n+=4}a&512&&(n+=4),a&1024&&(n+=4),a&2048&&(n+=4)}return h}function e(r,a,n){A(a,["moof","traf"]).forEach(function(h){A(h,["tfhd"]).forEach(function(d){var u=_(d,4),f=r[u];if(!!f){var l=f.timescale||9e4;A(h,["tfdt"]).forEach(function(o){var E=o.data[o.start],m=_(o,4);if(E===0)g(o,4,m-n*l);else{m*=Math.pow(2,32),m+=_(o,8),m-=n*l,m=Math.max(m,0);var O=Math.floor(m/(x+1)),P=Math.floor(m%(x+1));g(o,4,O),g(o,8,P)}})}})})}function i(r){var a={valid:null,remainder:null},n=A(r,["moof"]);if(n){if(n.length<2)return a.remainder=r,a}else return a;var h=n[n.length-1];return a.valid=Object(R.sliceUint8)(r,0,h.start-8),a.remainder=Object(R.sliceUint8)(r,h.start-8),a}function t(r,a){var n=new Uint8Array(r.length+a.length);return n.set(r),n.set(a,r.length),n}},"./src/utils/output-filter.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"default",function(){return R});var R=function(){function y(b,T){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=b,this.trackName=T}var x=y.prototype;return x.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},x.newCue=function(T,L,_){(this.startTime===null||this.startTime>T)&&(this.startTime=T),this.endTime=L,this.screen=_,this.timelineController.createCaptionsTrack(this.trackName)},x.reset=function(){this.cueRanges=[],this.startTime=null},y}()},"./src/utils/texttrack-utils.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"sendAddTrackEvent",function(){return y}),c.d(I,"addCueToTrack",function(){return x}),c.d(I,"clearCurrentCues",function(){return b}),c.d(I,"removeCuesInRange",function(){return T}),c.d(I,"getCuesInRange",function(){return _});var R=c("./src/utils/logger.ts");function y(g,A){var D;try{D=new Event("addtrack")}catch{D=document.createEvent("Event"),D.initEvent("addtrack",!1,!1)}D.track=g,A.dispatchEvent(D)}function x(g,A){var D=g.mode;if(D==="disabled"&&(g.mode="hidden"),g.cues&&!g.cues.getCueById(A.id))try{if(g.addCue(A),!g.cues.getCueById(A.id))throw new Error("addCue is failed for: "+A)}catch(v){R.logger.debug("[texttrack-utils]: "+v);var S=new self.TextTrackCue(A.startTime,A.endTime,A.text);S.id=A.id,g.addCue(S)}D==="disabled"&&(g.mode=D)}function b(g){var A=g.mode;if(A==="disabled"&&(g.mode="hidden"),g.cues)for(var D=g.cues.length;D--;)g.removeCue(g.cues[D]);A==="disabled"&&(g.mode=A)}function T(g,A,D){var S=g.mode;if(S==="disabled"&&(g.mode="hidden"),g.cues&&g.cues.length>0)for(var v=_(g.cues,A,D),p=0;p<v.length;p++)g.removeCue(v[p]);S==="disabled"&&(g.mode=S)}function L(g,A){if(A<g[0].startTime)return 0;var D=g.length-1;if(A>g[D].endTime)return-1;for(var S=0,v=D;S<=v;){var p=Math.floor((v+S)/2);if(A<g[p].startTime)v=p-1;else if(A>g[p].startTime&&S<D)S=p+1;else return p}return g[S].startTime-A<A-g[v].startTime?S:v}function _(g,A,D){var S=[],v=L(g,A);if(v>-1)for(var p=v,s=g.length;p<s;p++){var e=g[p];if(e.startTime>=A&&e.endTime<=D)S.push(e);else if(e.startTime>D)return S}return S}},"./src/utils/time-ranges.ts":function(N,I,c){"use strict";c.r(I);var R={toString:function(x){for(var b="",T=x.length,L=0;L<T;L++)b+="["+x.start(L).toFixed(3)+","+x.end(L).toFixed(3)+"]";return b}};I.default=R},"./src/utils/timescale-conversion.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"toTimescaleFromBase",function(){return y}),c.d(I,"toTimescaleFromScale",function(){return x}),c.d(I,"toMsFromMpegTsClock",function(){return b}),c.d(I,"toMpegTsClockFromTimescale",function(){return T});var R=9e4;function y(L,_,g,A){g===void 0&&(g=1),A===void 0&&(A=!1);var D=L*_*g;return A?Math.round(D):D}function x(L,_,g,A){return g===void 0&&(g=1),A===void 0&&(A=!1),y(L,_,1/g,A)}function b(L,_){return _===void 0&&(_=!1),y(L,1e3,1/R,_)}function T(L,_){return _===void 0&&(_=1),y(L,R,1/_)}},"./src/utils/typed-array.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"sliceUint8",function(){return R});function R(y,x,b){return Uint8Array.prototype.slice?y.slice(x,b):new Uint8Array(Array.prototype.slice.call(y,x,b))}},"./src/utils/vttcue.ts":function(N,I,c){"use strict";c.r(I),I.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var R=["","lr","rl"],y=["start","middle","end","left","right"];function x(g,A){if(typeof A!="string"||!Array.isArray(g))return!1;var D=A.toLowerCase();return~g.indexOf(D)?D:!1}function b(g){return x(R,g)}function T(g){return x(y,g)}function L(g){for(var A=arguments.length,D=new Array(A>1?A-1:0),S=1;S<A;S++)D[S-1]=arguments[S];for(var v=1;v<arguments.length;v++){var p=arguments[v];for(var s in p)g[s]=p[s]}return g}function _(g,A,D){var S=this,v={enumerable:!0};S.hasBeenReset=!1;var p="",s=!1,e=g,i=A,t=D,r=null,a="",n=!0,h="auto",d="start",u=50,f="middle",l=50,o="middle";Object.defineProperty(S,"id",L({},v,{get:function(){return p},set:function(m){p=""+m}})),Object.defineProperty(S,"pauseOnExit",L({},v,{get:function(){return s},set:function(m){s=!!m}})),Object.defineProperty(S,"startTime",L({},v,{get:function(){return e},set:function(m){if(typeof m!="number")throw new TypeError("Start time must be set to a number.");e=m,this.hasBeenReset=!0}})),Object.defineProperty(S,"endTime",L({},v,{get:function(){return i},set:function(m){if(typeof m!="number")throw new TypeError("End time must be set to a number.");i=m,this.hasBeenReset=!0}})),Object.defineProperty(S,"text",L({},v,{get:function(){return t},set:function(m){t=""+m,this.hasBeenReset=!0}})),Object.defineProperty(S,"region",L({},v,{get:function(){return r},set:function(m){r=m,this.hasBeenReset=!0}})),Object.defineProperty(S,"vertical",L({},v,{get:function(){return a},set:function(m){var O=b(m);if(O===!1)throw new SyntaxError("An invalid or illegal string was specified.");a=O,this.hasBeenReset=!0}})),Object.defineProperty(S,"snapToLines",L({},v,{get:function(){return n},set:function(m){n=!!m,this.hasBeenReset=!0}})),Object.defineProperty(S,"line",L({},v,{get:function(){return h},set:function(m){if(typeof m!="number"&&m!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");h=m,this.hasBeenReset=!0}})),Object.defineProperty(S,"lineAlign",L({},v,{get:function(){return d},set:function(m){var O=T(m);if(!O)throw new SyntaxError("An invalid or illegal string was specified.");d=O,this.hasBeenReset=!0}})),Object.defineProperty(S,"position",L({},v,{get:function(){return u},set:function(m){if(m<0||m>100)throw new Error("Position must be between 0 and 100.");u=m,this.hasBeenReset=!0}})),Object.defineProperty(S,"positionAlign",L({},v,{get:function(){return f},set:function(m){var O=T(m);if(!O)throw new SyntaxError("An invalid or illegal string was specified.");f=O,this.hasBeenReset=!0}})),Object.defineProperty(S,"size",L({},v,{get:function(){return l},set:function(m){if(m<0||m>100)throw new Error("Size must be between 0 and 100.");l=m,this.hasBeenReset=!0}})),Object.defineProperty(S,"align",L({},v,{get:function(){return o},set:function(m){var O=T(m);if(!O)throw new SyntaxError("An invalid or illegal string was specified.");o=O,this.hasBeenReset=!0}})),S.displayState=void 0}return _.prototype.getCueAsHTML=function(){var g=self.WebVTT;return g.convertCueToDOMTree(self,this.text)},_}()},"./src/utils/vttparser.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"parseTimeStamp",function(){return x}),c.d(I,"fixLineBreaks",function(){return A}),c.d(I,"VTTParser",function(){return D});var R=c("./src/utils/vttcue.ts"),y=function(){function S(){}var v=S.prototype;return v.decode=function(s,e){if(!s)return"";if(typeof s!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(s))},S}();function x(S){function v(s,e,i,t){return(s|0)*3600+(e|0)*60+(i|0)+parseFloat(t||0)}var p=S.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return p?parseFloat(p[2])>59?v(p[2],p[3],0,p[4]):v(p[1],p[2],p[3],p[4]):null}var b=function(){function S(){this.values=Object.create(null)}var v=S.prototype;return v.set=function(s,e){!this.get(s)&&e!==""&&(this.values[s]=e)},v.get=function(s,e,i){return i?this.has(s)?this.values[s]:e[i]:this.has(s)?this.values[s]:e},v.has=function(s){return s in this.values},v.alt=function(s,e,i){for(var t=0;t<i.length;++t)if(e===i[t]){this.set(s,e);break}},v.integer=function(s,e){/^-?\d+$/.test(e)&&this.set(s,parseInt(e,10))},v.percent=function(s,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){var i=parseFloat(e);if(i>=0&&i<=100)return this.set(s,i),!0}return!1},S}();function T(S,v,p,s){var e=s?S.split(s):[S];for(var i in e)if(typeof e[i]=="string"){var t=e[i].split(p);if(t.length===2){var r=t[0],a=t[1];v(r,a)}}}var L=new R.default(0,0,""),_=L.align==="middle"?"middle":"center";function g(S,v,p){var s=S;function e(){var r=x(S);if(r===null)throw new Error("Malformed timestamp: "+s);return S=S.replace(/^[^\sa-zA-Z-]+/,""),r}function i(r,a){var n=new b;T(r,function(u,f){var l;switch(u){case"region":for(var o=p.length-1;o>=0;o--)if(p[o].id===f){n.set(u,p[o].region);break}break;case"vertical":n.alt(u,f,["rl","lr"]);break;case"line":l=f.split(","),n.integer(u,l[0]),n.percent(u,l[0])&&n.set("snapToLines",!1),n.alt(u,l[0],["auto"]),l.length===2&&n.alt("lineAlign",l[1],["start",_,"end"]);break;case"position":l=f.split(","),n.percent(u,l[0]),l.length===2&&n.alt("positionAlign",l[1],["start",_,"end","line-left","line-right","auto"]);break;case"size":n.percent(u,f);break;case"align":n.alt(u,f,["start",_,"end","left","right"]);break}},/:/,/\s/),a.region=n.get("region",null),a.vertical=n.get("vertical","");var h=n.get("line","auto");h==="auto"&&L.line===-1&&(h=-1),a.line=h,a.lineAlign=n.get("lineAlign","start"),a.snapToLines=n.get("snapToLines",!0),a.size=n.get("size",100),a.align=n.get("align",_);var d=n.get("position","auto");d==="auto"&&L.position===50&&(d=a.align==="start"||a.align==="left"?0:a.align==="end"||a.align==="right"?100:50),a.position=d}function t(){S=S.replace(/^\s+/,"")}if(t(),v.startTime=e(),t(),S.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+s);S=S.substr(3),t(),v.endTime=e(),t(),i(S,v)}function A(S){return S.replace(/<br(?: \/)?>/gi,`
21
- `)}var D=function(){function S(){this.state="INITIAL",this.buffer="",this.decoder=new y,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var v=S.prototype;return v.parse=function(s){var e=this;s&&(e.buffer+=e.decoder.decode(s,{stream:!0}));function i(){var d=e.buffer,u=0;for(d=A(d);u<d.length&&d[u]!=="\r"&&d[u]!==`
22
- `;)++u;var f=d.substr(0,u);return d[u]==="\r"&&++u,d[u]===`
23
- `&&++u,e.buffer=d.substr(u),f}function t(d){T(d,function(u,f){},/:/)}try{var r="";if(e.state==="INITIAL"){if(!/\r\n|\n/.test(e.buffer))return this;r=i();var a=r.match(/^()?WEBVTT([ \t].*)?$/);if(!a||!a[0])throw new Error("Malformed WebVTT signature.");e.state="HEADER"}for(var n=!1;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(n?n=!1:r=i(),e.state){case"HEADER":/:/.test(r)?t(r):r||(e.state="ID");continue;case"NOTE":r||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(r)){e.state="NOTE";break}if(!r)continue;if(e.cue=new R.default(0,0,""),e.state="CUE",r.indexOf("-->")===-1){e.cue.id=r;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{g(r,e.cue,e.regionList)}catch{e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":{var h=r.indexOf("-->")!==-1;if(!r||h&&(n=!0)){e.oncue&&e.cue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}if(e.cue===null)continue;e.cue.text&&(e.cue.text+=`
24
- `),e.cue.text+=r}continue;case"BADCUE":r||(e.state="ID")}}}catch{e.state==="CUETEXT"&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state=e.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},v.flush=function(){var s=this;try{if((s.cue||s.state==="HEADER")&&(s.buffer+=`
17
+ timeOffset: `+b+`
18
+ initSegmentChange: `+H);var Y=new I.TransmuxConfig(u,n,s,l,c);this.configureTransmuxer(Y)}if(this.frag=i,this.part=t,O)O.postMessage({cmd:"demux",data:e,decryptdata:M,chunkMeta:r,state:V},e instanceof ArrayBuffer?[e]:[]);else if(m){var Q=m.push(e,M,r,V);Object(I.isPromise)(Q)?Q.then(function(J){v.handleTransmuxComplete(J)}):this.handleTransmuxComplete(Q)}},E.flush=function(e){var s=this;e.transmuxing.start=self.performance.now();var u=this.transmuxer,n=this.worker;if(n)n.postMessage({cmd:"flush",chunkMeta:e});else if(u){var i=u.flush(e);Object(I.isPromise)(i)?i.then(function(t){s.handleFlushResult(t,e)}):this.handleFlushResult(i,e)}},E.handleFlushResult=function(e,s){var u=this;e.forEach(function(n){u.handleTransmuxComplete(n)}),this.onFlush(s)},E.onWorkerMessage=function(e){var s=e.data,u=this.hls;switch(s.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(s.data);break}case"flush":{this.onFlush(s.data);break}case"workerLog":x.logger[s.data.logType]&&x.logger[s.data.logType](s.data.message);break;default:{s.data=s.data||{},s.data.frag=this.frag,s.data.id=this.id,u.trigger(s.event,s.data);break}}},E.configureTransmuxer=function(e){var s=this.worker,u=this.transmuxer;s?s.postMessage({cmd:"configure",config:e}):u&&u.configure(e)},E.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},g}()},"./src/demux/transmuxer-worker.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return L});var R=h("./src/demux/transmuxer.ts"),p=h("./src/events.ts"),S=h("./src/utils/logger.ts"),I=h("./node_modules/eventemitter3/index.js"),x=h.n(I);function L(T){var g=new I.EventEmitter,E=function(s,u){T.postMessage({event:s,data:u})};g.on(p.Events.FRAG_DECRYPTED,E),g.on(p.Events.ERROR,E);var a=function(){var s=function(i){var t=function(d){E("workerLog",{logType:i,message:d})};S.logger[i]=t};for(var u in S.logger)s(u)};T.addEventListener("message",function(e){var s=e.data;switch(s.cmd){case"init":{var u=JSON.parse(s.config);T.transmuxer=new R.default(g,s.typeSupported,u,s.vendor,s.id),Object(S.enableLogs)(u.debug),a(),E("init",null);break}case"configure":{T.transmuxer.configure(s.config);break}case"demux":{var n=T.transmuxer.push(s.data,s.decryptdata,s.chunkMeta,s.state);Object(R.isPromise)(n)?n.then(function(l){A(T,l)}):A(T,n);break}case"flush":{var i=s.chunkMeta,t=T.transmuxer.flush(i);Object(R.isPromise)(t)?t.then(function(l){D(T,l,i)}):D(T,t,i);break}default:break}})}function A(T,g){if(_(g.remuxResult))return!1;var E=[],a=g.remuxResult,e=a.audio,s=a.video;return e&&y(E,e),s&&y(E,s),T.postMessage({event:"transmuxComplete",data:g},E),!0}function y(T,g){g.data1&&T.push(g.data1.buffer),g.data2&&T.push(g.data2.buffer)}function D(T,g,E){var a=g.reduce(function(e,s){return A(T,s)||e},!1);a||T.postMessage({event:"transmuxComplete",data:g[0]}),T.postMessage({event:"flush",data:E})}function _(T){return!T.audio&&!T.video&&!T.text&&!T.id3&&!T.initSegment}},"./src/demux/transmuxer.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return E}),h.d(P,"isPromise",function(){return s}),h.d(P,"TransmuxConfig",function(){return u}),h.d(P,"TransmuxState",function(){return n});var R=h("./src/events.ts"),p=h("./src/errors.ts"),S=h("./src/crypt/decrypter.ts"),I=h("./src/demux/aacdemuxer.ts"),x=h("./src/demux/mp4demuxer.ts"),L=h("./src/demux/tsdemuxer.ts"),A=h("./src/demux/mp3demuxer.ts"),y=h("./src/remux/mp4-remuxer.ts"),D=h("./src/remux/passthrough-remuxer.ts"),_=h("./src/utils/logger.ts"),T;try{T=self.performance.now.bind(self.performance)}catch{_.logger.debug("Unable to use Performance API on this environment"),T=self.Date.now}var g=[{demux:L.default,remux:y.default},{demux:x.default,remux:D.default},{demux:I.default,remux:y.default},{demux:A.default,remux:y.default}],E=function(){function i(l,d,r,c,f){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=l,this.typeSupported=d,this.config=r,this.vendor=c,this.id=f}var t=i.prototype;return t.configure=function(d){this.transmuxConfig=d,this.decrypter&&this.decrypter.reset()},t.push=function(d,r,c,f){var o=this,v=c.transmuxing;v.executeStart=T();var m=new Uint8Array(d),O=this.config,b=this.currentTransmuxState,M=this.transmuxConfig;f&&(this.currentTransmuxState=f);var F=f||b,w=F.contiguous,C=F.discontinuity,U=F.trackSwitch,B=F.accurateTimeOffset,N=F.timeOffset,k=F.initSegmentChange,j=M.audioCodec,H=M.videoCodec,V=M.defaultInitPts,Y=M.duration,Q=M.initSegmentData;(C||U||k)&&this.resetInitSegment(Q,j,H,Y),(C||k)&&this.resetInitialTimestamp(V),w||this.resetContiguity();var J=a(m,r);if(J&&J.method==="AES-128"){var z=this.getDecrypter();if(O.enableSoftwareAES){var q=z.softwareDecrypt(m,J.key.buffer,J.iv.buffer);if(!q)return v.executeEnd=T(),e(c);m=new Uint8Array(q)}else return this.decryptionPromise=z.webCryptoDecrypt(m,J.key.buffer,J.iv.buffer).then(function(le){var ne=o.push(le,null,c);return o.decryptionPromise=null,ne}),this.decryptionPromise}this.needsProbing(m,C,U)&&this.configureTransmuxer(m,M);var re=this.transmux(m,J,N,B,c),X=this.currentTransmuxState;return X.contiguous=!0,X.discontinuity=!1,X.trackSwitch=!1,v.executeEnd=T(),re},t.flush=function(d){var r=this,c=d.transmuxing;c.executeStart=T();var f=this.decrypter,o=this.currentTransmuxState,v=this.decryptionPromise;if(v)return v.then(function(){return r.flush(d)});var m=[],O=o.timeOffset;if(f){var b=f.flush();b&&m.push(this.push(b,null,d))}var M=this.demuxer,F=this.remuxer;if(!M||!F)return this.observer.emit(R.Events.ERROR,R.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),c.executeEnd=T(),[e(d)];var w=M.flush(O);return s(w)?w.then(function(C){return r.flushRemux(m,C,d),m}):(this.flushRemux(m,w,d),m)},t.flushRemux=function(d,r,c){var f=r.audioTrack,o=r.videoTrack,v=r.id3Track,m=r.textTrack,O=this.currentTransmuxState,b=O.accurateTimeOffset,M=O.timeOffset;_.logger.log("[transmuxer.ts]: Flushed fragment "+c.sn+(c.part>-1?" p: "+c.part:"")+" of level "+c.level);var F=this.remuxer.remux(f,o,v,m,M,b,!0,this.id);d.push({remuxResult:F,chunkMeta:c}),c.transmuxing.executeEnd=T()},t.resetInitialTimestamp=function(d){var r=this.demuxer,c=this.remuxer;!r||!c||(r.resetTimeStamp(d),c.resetTimeStamp(d))},t.resetContiguity=function(){var d=this.demuxer,r=this.remuxer;!d||!r||(d.resetContiguity(),r.resetNextTimestamp())},t.resetInitSegment=function(d,r,c,f){var o=this.demuxer,v=this.remuxer;!o||!v||(o.resetInitSegment(d,r,c,f),v.resetInitSegment(d,r,c))},t.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},t.transmux=function(d,r,c,f,o){var v;return r&&r.method==="SAMPLE-AES"?v=this.transmuxSampleAes(d,r,c,f,o):v=this.transmuxUnencrypted(d,c,f,o),v},t.transmuxUnencrypted=function(d,r,c,f){var o=this.demuxer.demux(d,r,!1,!this.config.progressive),v=o.audioTrack,m=o.videoTrack,O=o.id3Track,b=o.textTrack,M=this.remuxer.remux(v,m,O,b,r,c,!1,this.id);return{remuxResult:M,chunkMeta:f}},t.transmuxSampleAes=function(d,r,c,f,o){var v=this;return this.demuxer.demuxSampleAes(d,r,c).then(function(m){var O=v.remuxer.remux(m.audioTrack,m.videoTrack,m.id3Track,m.textTrack,c,f,!1,v.id);return{remuxResult:O,chunkMeta:o}})},t.configureTransmuxer=function(d,r){for(var c=this.config,f=this.observer,o=this.typeSupported,v=this.vendor,m=r.audioCodec,O=r.defaultInitPts,b=r.duration,M=r.initSegmentData,F=r.videoCodec,w,C=0,U=g.length;C<U;C++)if(g[C].demux.probe(d)){w=g[C];break}w||(_.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),w={demux:x.default,remux:D.default});var B=this.demuxer,N=this.remuxer,k=w.remux,j=w.demux;(!N||!(N instanceof k))&&(this.remuxer=new k(f,c,o,v)),(!B||!(B instanceof j))&&(this.demuxer=new j(f,c,o),this.probe=j.probe),this.resetInitSegment(M,m,F,b),this.resetInitialTimestamp(O)},t.needsProbing=function(d,r,c){return!this.demuxer||!this.remuxer||r||c},t.getDecrypter=function(){var d=this.decrypter;return d||(d=this.decrypter=new S.default(this.observer,this.config)),d},i}();function a(i,t){var l=null;return i.byteLength>0&&t!=null&&t.key!=null&&t.iv!==null&&t.method!=null&&(l=t),l}var e=function(t){return{remuxResult:{},chunkMeta:t}};function s(i){return"then"in i&&i.then instanceof Function}var u=function(t,l,d,r,c){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=l,this.initSegmentData=d,this.duration=r,this.defaultInitPts=c},n=function(t,l,d,r,c,f){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=t,this.contiguous=l,this.accurateTimeOffset=d,this.trackSwitch=r,this.timeOffset=c,this.initSegmentChange=f}},"./src/demux/tsdemuxer.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"discardEPB",function(){return u});var R=h("./src/demux/adts.ts"),p=h("./src/demux/mpegaudio.ts"),S=h("./src/demux/exp-golomb.ts"),I=h("./src/demux/sample-aes.ts"),x=h("./src/events.ts"),L=h("./src/utils/mp4-tools.ts"),A=h("./src/utils/logger.ts"),y=h("./src/errors.ts"),D=h("./src/types/demuxer.ts");function _(){return _=Object.assign?Object.assign.bind():function(n){for(var i=1;i<arguments.length;i++){var t=arguments[i];for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&(n[l]=t[l])}return n},_.apply(this,arguments)}var T=function(){function n(t,l,d){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=t,this.config=l,this.typeSupported=d}n.probe=function(l){return l[0]===71&&l[188]===71},n.createTrack=function(l,d){return{container:l==="video"||l==="audio"?"video/mp2t":void 0,type:l,id:L.RemuxerTrackIdConfig[l],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:l==="audio"?d:void 0}};var i=n.prototype;return i.resetInitSegment=function(l,d,r,c){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=n.createTrack("video"),this._audioTrack=n.createTrack("audio",c),this._id3Track=n.createTrack("id3"),this._txtTrack=n.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=d,this.videoCodec=r,this._duration=c},i.resetTimeStamp=function(){},i.resetContiguity=function(){var l=this._audioTrack,d=this._avcTrack,r=this._id3Track;l&&(l.pesData=null),d&&(d.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null},i.demux=function(l,d,r,c){r===void 0&&(r=!1),c===void 0&&(c=!1),r||(this.sampleAes=null);var f,o=this._avcTrack,v=this._audioTrack,m=this._id3Track,O=this._txtTrack,b=o.pid,M=o.pesData,F=v.pid,w=m.pid,C=v.pesData,U=m.pesData,B=null,N=this.pmtParsed,k=this._pmtId,j=l.length;if(this.remainderData&&(l=Object(L.appendUint8Array)(this.remainderData,l),j=l.length,this.remainderData=null),j<188&&!c)return this.remainderData=l,{audioTrack:v,videoTrack:o,id3Track:m,textTrack:O};j-=j%188,j<l.byteLength&&!c&&(this.remainderData=new Uint8Array(l.buffer,j,l.buffer.byteLength-j));for(var H=0,V=0;V<j;V+=188)if(l[V]===71){var Y=!!(l[V+1]&64),Q=((l[V+1]&31)<<8)+l[V+2],J=(l[V+3]&48)>>4,z=void 0;if(J>1){if(z=V+5+l[V+4],z===V+188)continue}else z=V+4;switch(Q){case b:Y&&(M&&(f=e(M))&&this.parseAVCPES(o,O,f,!1),M={data:[],size:0}),M&&(M.data.push(l.subarray(z,V+188)),M.size+=V+188-z);break;case F:if(Y){if(C&&(f=e(C)))switch(v.segmentCodec){case"aac":this.parseAACPES(v,f);break;case"mp3":this.parseMPEGPES(v,f);break}C={data:[],size:0}}C&&(C.data.push(l.subarray(z,V+188)),C.size+=V+188-z);break;case w:Y&&(U&&(f=e(U))&&this.parseID3PES(m,f),U={data:[],size:0}),U&&(U.data.push(l.subarray(z,V+188)),U.size+=V+188-z);break;case 0:Y&&(z+=l[z]+1),k=this._pmtId=E(l,z);break;case k:{Y&&(z+=l[z]+1);var q=a(l,z,this.typeSupported,r);b=q.avc,b>0&&(o.pid=b),F=q.audio,F>0&&(v.pid=F,v.segmentCodec=q.segmentCodec),w=q.id3,w>0&&(m.pid=w),B!==null&&!N&&(A.logger.log("unknown PID '"+B+"' in TS found"),B=null),N=this.pmtParsed=!0;break}case 17:case 8191:break;default:B=Q;break}}else H++;H>0&&this.observer.emit(x.Events.ERROR,x.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+H+" TS packet/s that do not start with 0x47"}),o.pesData=M,v.pesData=C,m.pesData=U;var re={audioTrack:v,videoTrack:o,id3Track:m,textTrack:O};return c&&this.extractRemainingSamples(re),re},i.flush=function(){var l=this.remainderData;this.remainderData=null;var d;return l?d=this.demux(l,-1,!1,!0):d={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(d),this.sampleAes?this.decrypt(d,this.sampleAes):d},i.extractRemainingSamples=function(l){var d=l.audioTrack,r=l.videoTrack,c=l.id3Track,f=l.textTrack,o=r.pesData,v=d.pesData,m=c.pesData,O;if(o&&(O=e(o))?(this.parseAVCPES(r,f,O,!0),r.pesData=null):r.pesData=o,v&&(O=e(v))){switch(d.segmentCodec){case"aac":this.parseAACPES(d,O);break;case"mp3":this.parseMPEGPES(d,O);break}d.pesData=null}else v!=null&&v.size&&A.logger.log("last AAC PES packet truncated,might overlap between fragments"),d.pesData=v;m&&(O=e(m))?(this.parseID3PES(c,O),c.pesData=null):c.pesData=m},i.demuxSampleAes=function(l,d,r){var c=this.demux(l,r,!0,!this.config.progressive),f=this.sampleAes=new I.default(this.observer,this.config,d);return this.decrypt(c,f)},i.decrypt=function(l,d){return new Promise(function(r){var c=l.audioTrack,f=l.videoTrack;c.samples&&c.segmentCodec==="aac"?d.decryptAacSamples(c.samples,0,function(){f.samples?d.decryptAvcSamples(f.samples,0,0,function(){r(l)}):r(l)}):f.samples&&d.decryptAvcSamples(f.samples,0,0,function(){r(l)})})},i.destroy=function(){this._duration=0},i.parseAVCPES=function(l,d,r,c){var f=this,o=this.parseAVCNALu(l,r.data),v=!1,m=this.avcSample,O,b=!1;r.data=null,m&&o.length&&!l.audFound&&(s(m,l),m=this.avcSample=g(!1,r.pts,r.dts,"")),o.forEach(function(M){switch(M.type){case 1:{O=!0,m||(m=f.avcSample=g(!0,r.pts,r.dts,"")),v&&(m.debug+="NDR "),m.frame=!0;var F=M.data;if(b&&F.length>4){var w=new S.default(F).readSliceType();(w===2||w===4||w===7||w===9)&&(m.key=!0)}break}case 5:O=!0,m||(m=f.avcSample=g(!0,r.pts,r.dts,"")),v&&(m.debug+="IDR "),m.key=!0,m.frame=!0;break;case 6:{O=!0,v&&m&&(m.debug+="SEI "),Object(L.parseSEIMessageFromNALu)(u(M.data),r.pts,d.samples);break}case 7:if(O=!0,b=!0,v&&m&&(m.debug+="SPS "),!l.sps){var C=new S.default(M.data),U=C.readSPS();l.width=U.width,l.height=U.height,l.pixelRatio=U.pixelRatio,l.sps=[M.data],l.duration=f._duration;for(var B=M.data.subarray(1,4),N="avc1.",k=0;k<3;k++){var j=B[k].toString(16);j.length<2&&(j="0"+j),N+=j}l.codec=N}break;case 8:O=!0,v&&m&&(m.debug+="PPS "),l.pps||(l.pps=[M.data]);break;case 9:O=!1,l.audFound=!0,m&&s(m,l),m=f.avcSample=g(!1,r.pts,r.dts,v?"AUD ":"");break;case 12:O=!0;break;default:O=!1,m&&(m.debug+="unknown NAL "+M.type+" ");break}if(m&&O){var H=m.units;H.push(M)}}),c&&m&&(s(m,l),this.avcSample=null)},i.getLastNalUnit=function(l){var d,r=this.avcSample,c;if((!r||r.units.length===0)&&(r=l[l.length-1]),(d=r)!==null&&d!==void 0&&d.units){var f=r.units;c=f[f.length-1]}return c},i.parseAVCNALu=function(l,d){var r=d.byteLength,c=l.naluState||0,f=c,o=[],v=0,m,O,b,M=-1,F=0;for(c===-1&&(M=0,F=d[0]&31,c=0,v=1);v<r;){if(m=d[v++],!c){c=m?0:1;continue}if(c===1){c=m?0:2;continue}if(!m)c=3;else if(m===1){if(M>=0){var w={data:d.subarray(M,v-c-1),type:F};o.push(w)}else{var C=this.getLastNalUnit(l.samples);if(C&&(f&&v<=4-f&&C.state&&(C.data=C.data.subarray(0,C.data.byteLength-f)),O=v-c-1,O>0)){var U=new Uint8Array(C.data.byteLength+O);U.set(C.data,0),U.set(d.subarray(0,O),C.data.byteLength),C.data=U,C.state=0}}v<r?(b=d[v]&31,M=v,F=b,c=0):c=-1}else c=0}if(M>=0&&c>=0){var B={data:d.subarray(M,r),type:F,state:c};o.push(B)}if(o.length===0){var N=this.getLastNalUnit(l.samples);if(N){var k=new Uint8Array(N.data.byteLength+d.byteLength);k.set(N.data,0),k.set(d,N.data.byteLength),N.data=k}}return l.naluState=c,o},i.parseAACPES=function(l,d){var r=0,c=this.aacOverFlow,f=d.data;if(c){this.aacOverFlow=null;var o=c.missing,v=c.sample.unit.byteLength;if(o===-1){var m=new Uint8Array(v+f.byteLength);m.set(c.sample.unit,0),m.set(f,v),f=m}else{var O=v-o;c.sample.unit.set(f.subarray(0,o),O),l.samples.push(c.sample),r=c.missing}}var b,M;for(b=r,M=f.length;b<M-1&&!R.isHeader(f,b);b++);if(b!==r){var F,w;if(b<M-1?(F="AAC PES did not start with ADTS header,offset:"+b,w=!1):(F="no ADTS header found in AAC PES",w=!0),A.logger.warn("parsing error:"+F),this.observer.emit(x.Events.ERROR,x.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:w,reason:F}),w)return}R.initTrackConfig(l,this.observer,f,b,this.audioCodec);var C;if(d.pts!==void 0)C=d.pts;else if(c){var U=R.getFrameDuration(l.samplerate);C=c.sample.pts+U}else{A.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var B=0,N;b<M;)if(N=R.appendFrame(l,f,b,C,B),b+=N.length,N.missing){this.aacOverFlow=N;break}else for(B++;b<M-1&&!R.isHeader(f,b);b++);},i.parseMPEGPES=function(l,d){var r=d.data,c=r.length,f=0,o=0,v=d.pts;if(v===void 0){A.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;o<c;)if(p.isHeader(r,o)){var m=p.appendFrame(l,r,o,v,f);if(m)o+=m.length,f++;else break}else o++},i.parseID3PES=function(l,d){if(d.pts===void 0){A.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var r=_({},d,{type:this._avcTrack?D.MetadataSchema.emsg:D.MetadataSchema.audioId3});l.samples.push(r)},n}();function g(n,i,t,l){return{key:n,frame:!1,pts:i,dts:t,units:[],debug:l,length:0}}function E(n,i){return(n[i+10]&31)<<8|n[i+11]}function a(n,i,t,l){var d={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},r=(n[i+1]&15)<<8|n[i+2],c=i+3+r-4,f=(n[i+10]&15)<<8|n[i+11];for(i+=12+f;i<c;){var o=(n[i+1]&31)<<8|n[i+2];switch(n[i]){case 207:if(!l){A.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:d.audio===-1&&(d.audio=o);break;case 21:d.id3===-1&&(d.id3=o);break;case 219:if(!l){A.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:d.avc===-1&&(d.avc=o);break;case 3:case 4:t.mpeg!==!0&&t.mp3!==!0?A.logger.log("MPEG audio found, not supported in this browser"):d.audio===-1&&(d.audio=o,d.segmentCodec="mp3");break;case 36:A.logger.warn("Unsupported HEVC stream type found");break;default:break}i+=((n[i+3]&15)<<8|n[i+4])+5}return d}function e(n){var i=0,t,l,d,r,c,f=n.data;if(!n||n.size===0)return null;for(;f[0].length<19&&f.length>1;){var o=new Uint8Array(f[0].length+f[1].length);o.set(f[0]),o.set(f[1],f[0].length),f[0]=o,f.splice(1,1)}t=f[0];var v=(t[0]<<16)+(t[1]<<8)+t[2];if(v===1){if(l=(t[4]<<8)+t[5],l&&l>n.size-6)return null;var m=t[7];m&192&&(r=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,m&64?(c=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,r-c>60*9e4&&(A.logger.warn(Math.round((r-c)/9e4)+"s delta between PTS and DTS, align them"),r=c)):c=r),d=t[8];var O=d+9;if(n.size<=O)return null;n.size-=O;for(var b=new Uint8Array(n.size),M=0,F=f.length;M<F;M++){t=f[M];var w=t.byteLength;if(O)if(O>w){O-=w;continue}else t=t.subarray(O),w-=O,O=0;b.set(t,i),i+=w}return l&&(l-=d+3),{data:b,pts:r,dts:c,len:l}}return null}function s(n,i){if(n.units.length&&n.frame){if(n.pts===void 0){var t=i.samples,l=t.length;if(l){var d=t[l-1];n.pts=d.pts,n.dts=d.dts}else{i.dropped++;return}}i.samples.push(n)}n.debug.length&&A.logger.log(n.pts+"/"+n.dts+":"+n.debug)}function u(n){for(var i=n.byteLength,t=[],l=1;l<i-2;)n[l]===0&&n[l+1]===0&&n[l+2]===3?(t.push(l+2),l+=2):l++;if(t.length===0)return n;var d=i-t.length,r=new Uint8Array(d),c=0;for(l=0;l<d;c++,l++)c===t[0]&&(c++,t.shift()),r[l]=n[c];return r}P.default=T},"./src/errors.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"ErrorTypes",function(){return R}),h.d(P,"ErrorDetails",function(){return p});var R;(function(S){S.NETWORK_ERROR="networkError",S.MEDIA_ERROR="mediaError",S.KEY_SYSTEM_ERROR="keySystemError",S.MUX_ERROR="muxError",S.OTHER_ERROR="otherError"})(R||(R={}));var p;(function(S){S.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",S.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",S.KEY_SYSTEM_NO_SESSION="keySystemNoSession",S.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",S.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",S.MANIFEST_LOAD_ERROR="manifestLoadError",S.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",S.MANIFEST_PARSING_ERROR="manifestParsingError",S.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",S.LEVEL_EMPTY_ERROR="levelEmptyError",S.LEVEL_LOAD_ERROR="levelLoadError",S.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",S.LEVEL_SWITCH_ERROR="levelSwitchError",S.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",S.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",S.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",S.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",S.FRAG_LOAD_ERROR="fragLoadError",S.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",S.FRAG_DECRYPT_ERROR="fragDecryptError",S.FRAG_PARSING_ERROR="fragParsingError",S.REMUX_ALLOC_ERROR="remuxAllocError",S.KEY_LOAD_ERROR="keyLoadError",S.KEY_LOAD_TIMEOUT="keyLoadTimeOut",S.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",S.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",S.BUFFER_APPEND_ERROR="bufferAppendError",S.BUFFER_APPENDING_ERROR="bufferAppendingError",S.BUFFER_STALLED_ERROR="bufferStalledError",S.BUFFER_FULL_ERROR="bufferFullError",S.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",S.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",S.INTERNAL_EXCEPTION="internalException",S.INTERNAL_ABORTED="aborted",S.UNKNOWN="unknown"})(p||(p={}))},"./src/events.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"Events",function(){return R});var R;(function(p){p.MEDIA_ATTACHING="hlsMediaAttaching",p.MEDIA_ATTACHED="hlsMediaAttached",p.MEDIA_DETACHING="hlsMediaDetaching",p.MEDIA_DETACHED="hlsMediaDetached",p.BUFFER_RESET="hlsBufferReset",p.BUFFER_CODECS="hlsBufferCodecs",p.BUFFER_CREATED="hlsBufferCreated",p.BUFFER_APPENDING="hlsBufferAppending",p.BUFFER_APPENDED="hlsBufferAppended",p.BUFFER_EOS="hlsBufferEos",p.BUFFER_FLUSHING="hlsBufferFlushing",p.BUFFER_FLUSHED="hlsBufferFlushed",p.MANIFEST_LOADING="hlsManifestLoading",p.MANIFEST_LOADED="hlsManifestLoaded",p.MANIFEST_PARSED="hlsManifestParsed",p.LEVEL_SWITCHING="hlsLevelSwitching",p.LEVEL_SWITCHED="hlsLevelSwitched",p.LEVEL_LOADING="hlsLevelLoading",p.LEVEL_LOADED="hlsLevelLoaded",p.LEVEL_UPDATED="hlsLevelUpdated",p.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",p.LEVELS_UPDATED="hlsLevelsUpdated",p.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",p.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",p.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",p.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",p.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",p.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",p.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",p.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",p.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",p.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",p.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",p.CUES_PARSED="hlsCuesParsed",p.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",p.INIT_PTS_FOUND="hlsInitPtsFound",p.FRAG_LOADING="hlsFragLoading",p.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",p.FRAG_LOADED="hlsFragLoaded",p.FRAG_DECRYPTED="hlsFragDecrypted",p.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",p.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",p.FRAG_PARSING_METADATA="hlsFragParsingMetadata",p.FRAG_PARSED="hlsFragParsed",p.FRAG_BUFFERED="hlsFragBuffered",p.FRAG_CHANGED="hlsFragChanged",p.FPS_DROP="hlsFpsDrop",p.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",p.ERROR="hlsError",p.DESTROYING="hlsDestroying",p.KEY_LOADING="hlsKeyLoading",p.KEY_LOADED="hlsKeyLoaded",p.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",p.BACK_BUFFER_REACHED="hlsBackBufferReached"})(R||(R={}))},"./src/hls.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return i});var R=h("./node_modules/url-toolkit/src/url-toolkit.js"),p=h.n(R),S=h("./src/loader/playlist-loader.ts"),I=h("./src/loader/key-loader.ts"),x=h("./src/controller/id3-track-controller.ts"),L=h("./src/controller/latency-controller.ts"),A=h("./src/controller/level-controller.ts"),y=h("./src/controller/fragment-tracker.ts"),D=h("./src/controller/stream-controller.ts"),_=h("./src/is-supported.ts"),T=h("./src/utils/logger.ts"),g=h("./src/config.ts"),E=h("./node_modules/eventemitter3/index.js"),a=h.n(E),e=h("./src/events.ts"),s=h("./src/errors.ts");function u(t,l){for(var d=0;d<l.length;d++){var r=l[d];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function n(t,l,d){return l&&u(t.prototype,l),d&&u(t,d),Object.defineProperty(t,"prototype",{writable:!1}),t}var i=function(){t.isSupported=function(){return Object(_.isSupported)()};function t(d){d===void 0&&(d={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new E.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var r=this.config=Object(g.mergeConfig)(t.DefaultConfig,d);this.userConfig=d,Object(T.enableLogs)(r.debug),this._autoLevelCapping=-1,r.progressive&&Object(g.enableStreamingMode)(r);var c=r.abrController,f=r.bufferController,o=r.capLevelController,v=r.fpsController,m=this.abrController=new c(this),O=this.bufferController=new f(this),b=this.capLevelController=new o(this),M=new v(this),F=new S.default(this),w=new I.default(this),C=new x.default(this),U=this.levelController=new A.default(this),B=new y.FragmentTracker(this),N=this.streamController=new D.default(this,B);b.setStreamController(N),M.setStreamController(N);var k=[F,w,U,N];this.networkControllers=k;var j=[m,O,b,M,C,B];this.audioTrackController=this.createController(r.audioTrackController,null,k),this.createController(r.audioStreamController,B,k),this.subtitleTrackController=this.createController(r.subtitleTrackController,null,k),this.createController(r.subtitleStreamController,B,k),this.createController(r.timelineController,null,j),this.emeController=this.createController(r.emeController,null,j),this.cmcdController=this.createController(r.cmcdController,null,j),this.latencyController=this.createController(L.default,null,j),this.coreComponents=j}var l=t.prototype;return l.createController=function(r,c,f){if(r){var o=c?new r(this,c):new r(this);return f&&f.push(o),o}return null},l.on=function(r,c,f){f===void 0&&(f=this),this._emitter.on(r,c,f)},l.once=function(r,c,f){f===void 0&&(f=this),this._emitter.once(r,c,f)},l.removeAllListeners=function(r){this._emitter.removeAllListeners(r)},l.off=function(r,c,f,o){f===void 0&&(f=this),this._emitter.off(r,c,f,o)},l.listeners=function(r){return this._emitter.listeners(r)},l.emit=function(r,c,f){return this._emitter.emit(r,c,f)},l.trigger=function(r,c){if(this.config.debug)return this.emit(r,r,c);try{return this.emit(r,r,c)}catch(f){T.logger.error("An internal error happened while handling event "+r+'. Error message: "'+f.message+'". Here is a stacktrace:',f),this.trigger(e.Events.ERROR,{type:s.ErrorTypes.OTHER_ERROR,details:s.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:r,error:f})}return!1},l.listenerCount=function(r){return this._emitter.listenerCount(r)},l.destroy=function(){T.logger.log("destroy"),this.trigger(e.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(r){return r.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(r){return r.destroy()}),this.coreComponents.length=0},l.attachMedia=function(r){T.logger.log("attachMedia"),this._media=r,this.trigger(e.Events.MEDIA_ATTACHING,{media:r})},l.detachMedia=function(){T.logger.log("detachMedia"),this.trigger(e.Events.MEDIA_DETACHING,void 0),this._media=null},l.loadSource=function(r){this.stopLoad();var c=this.media,f=this.url,o=this.url=R.buildAbsoluteURL(self.location.href,r,{alwaysNormalize:!0});T.logger.log("loadSource:"+o),c&&f&&f!==o&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(c)),this.trigger(e.Events.MANIFEST_LOADING,{url:r})},l.startLoad=function(r){r===void 0&&(r=-1),T.logger.log("startLoad("+r+")"),this.networkControllers.forEach(function(c){c.startLoad(r)})},l.stopLoad=function(){T.logger.log("stopLoad"),this.networkControllers.forEach(function(r){r.stopLoad()})},l.swapAudioCodec=function(){T.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},l.recoverMediaError=function(){T.logger.log("recoverMediaError");var r=this._media;this.detachMedia(),r&&this.attachMedia(r)},l.removeLevel=function(r,c){c===void 0&&(c=0),this.levelController.removeLevel(r,c)},n(t,[{key:"levels",get:function(){var r=this.levelController.levels;return r||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(r){T.logger.log("set currentLevel:"+r),this.loadLevel=r,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(r){T.logger.log("set nextLevel:"+r),this.levelController.manualLevel=r,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(r){T.logger.log("set loadLevel:"+r),this.levelController.manualLevel=r}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(r){this.levelController.nextLoadLevel=r}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(r){T.logger.log("set firstLevel:"+r),this.levelController.firstLevel=r}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(r){T.logger.log("set startLevel:"+r),r!==-1&&(r=Math.max(r,this.minAutoLevel)),this.levelController.startLevel=r}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(r){var c=!!r;c!==this.config.capLevelToPlayerSize&&(c?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=c)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(r){this._autoLevelCapping!==r&&(T.logger.log("set autoLevelCapping:"+r),this._autoLevelCapping=r)}},{key:"bandwidthEstimate",get:function(){var r=this.abrController.bwEstimator;return r?r.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var r=this.levels,c=this.config.minAutoBitrate;if(!r)return 0;for(var f=r.length,o=0;o<f;o++)if(r[o].maxBitrate>=c)return o;return 0}},{key:"maxAutoLevel",get:function(){var r=this.levels,c=this.autoLevelCapping,f;return c===-1&&r&&r.length?f=r.length-1:f=c,f}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(r){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,r)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"audioTracks",get:function(){var r=this.audioTrackController;return r?r.audioTracks:[]}},{key:"audioTrack",get:function(){var r=this.audioTrackController;return r?r.audioTrack:-1},set:function(r){var c=this.audioTrackController;c&&(c.audioTrack=r)}},{key:"subtitleTracks",get:function(){var r=this.subtitleTrackController;return r?r.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var r=this.subtitleTrackController;return r?r.subtitleTrack:-1},set:function(r){var c=this.subtitleTrackController;c&&(c.subtitleTrack=r)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var r=this.subtitleTrackController;return r?r.subtitleDisplay:!1},set:function(r){var c=this.subtitleTrackController;c&&(c.subtitleDisplay=r)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(r){this.config.lowLatencyMode=r}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.2.3"}},{key:"Events",get:function(){return e.Events}},{key:"ErrorTypes",get:function(){return s.ErrorTypes}},{key:"ErrorDetails",get:function(){return s.ErrorDetails}},{key:"DefaultConfig",get:function(){return t.defaultConfig?t.defaultConfig:g.hlsDefaultConfig},set:function(r){t.defaultConfig=r}}]),t}();i.defaultConfig=void 0},"./src/is-supported.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"isSupported",function(){return S}),h.d(P,"changeTypeSupported",function(){return I});var R=h("./src/utils/mediasource-helper.ts");function p(){return self.SourceBuffer||self.WebKitSourceBuffer}function S(){var x=Object(R.getMediaSource)();if(!x)return!1;var L=p(),A=x&&typeof x.isTypeSupported=="function"&&x.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),y=!L||L.prototype&&typeof L.prototype.appendBuffer=="function"&&typeof L.prototype.remove=="function";return!!A&&!!y}function I(){var x,L=p();return typeof(L==null||(x=L.prototype)===null||x===void 0?void 0:x.changeType)=="function"}},"./src/loader/date-range.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"DateRangeAttribute",function(){return A}),h.d(P,"DateRange",function(){return y});var R=h("./src/polyfills/number.ts"),p=h("./src/utils/attr-list.ts"),S=h("./src/utils/logger.ts");function I(){return I=Object.assign?Object.assign.bind():function(D){for(var _=1;_<arguments.length;_++){var T=arguments[_];for(var g in T)Object.prototype.hasOwnProperty.call(T,g)&&(D[g]=T[g])}return D},I.apply(this,arguments)}function x(D,_){for(var T=0;T<_.length;T++){var g=_[T];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(D,g.key,g)}}function L(D,_,T){return _&&x(D.prototype,_),T&&x(D,T),Object.defineProperty(D,"prototype",{writable:!1}),D}var A;(function(D){D.ID="ID",D.CLASS="CLASS",D.START_DATE="START-DATE",D.DURATION="DURATION",D.END_DATE="END-DATE",D.END_ON_NEXT="END-ON-NEXT",D.PLANNED_DURATION="PLANNED-DURATION",D.SCTE35_OUT="SCTE35-OUT",D.SCTE35_IN="SCTE35-IN"})(A||(A={}));var y=function(){function D(_,T){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,T){var g=T.attr;for(var E in g)if(Object.prototype.hasOwnProperty.call(_,E)&&_[E]!==g[E]){S.logger.warn('DATERANGE tag attribute: "'+E+'" does not match for tags with ID: "'+_.ID+'"'),this._badValueForSameId=E;break}_=I(new p.AttrList({}),g,_)}if(this.attr=_,this._startDate=new Date(_[A.START_DATE]),A.END_DATE in this.attr){var a=new Date(this.attr[A.END_DATE]);Object(R.isFiniteNumber)(a.getTime())&&(this._endDate=a)}}return L(D,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var T=this.duration;return T!==null?new Date(this._startDate.getTime()+T*1e3):null}},{key:"duration",get:function(){if(A.DURATION in this.attr){var T=this.attr.decimalFloatingPoint(A.DURATION);if(Object(R.isFiniteNumber)(T))return T}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return A.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(A.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(A.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&Object(R.isFiniteNumber)(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),D}()},"./src/loader/fragment-loader.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return T}),h.d(P,"LoadError",function(){return E});var R=h("./src/polyfills/number.ts"),p=h("./src/errors.ts");function S(a,e){a.prototype=Object.create(e.prototype),a.prototype.constructor=a,y(a,e)}function I(a){var e=typeof Map=="function"?new Map:void 0;return I=function(u){if(u===null||!A(u))return u;if(typeof u!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e!="undefined"){if(e.has(u))return e.get(u);e.set(u,n)}function n(){return x(u,arguments,D(this).constructor)}return n.prototype=Object.create(u.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),y(n,u)},I(a)}function x(a,e,s){return L()?x=Reflect.construct.bind():x=function(n,i,t){var l=[null];l.push.apply(l,i);var d=Function.bind.apply(n,l),r=new d;return t&&y(r,t.prototype),r},x.apply(null,arguments)}function L(){if(typeof Reflect=="undefined"||!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 A(a){return Function.toString.call(a).indexOf("[native code]")!==-1}function y(a,e){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,n){return u.__proto__=n,u},y(a,e)}function D(a){return D=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(s){return s.__proto__||Object.getPrototypeOf(s)},D(a)}var _=Math.pow(2,17),T=function(){function a(s){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=s}var e=a.prototype;return e.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},e.abort=function(){this.loader&&this.loader.abort()},e.load=function(u,n){var i=this,t=u.url;if(!t)return Promise.reject(new E({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:u,networkDetails:null},"Fragment does not have a "+(t?"part list":"url")));this.abort();var l=this.config,d=l.fLoader,r=l.loader;return new Promise(function(c,f){i.loader&&i.loader.destroy();var o=i.loader=u.loader=d?new d(l):new r(l),v=g(u),m={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:u.sn==="initSegment"?1/0:_};u.stats=o.stats,o.load(v,m,{onSuccess:function(b,M,F,w){i.resetLoader(u,o),c({frag:u,part:null,payload:b.data,networkDetails:w})},onError:function(b,M,F){i.resetLoader(u,o),f(new E({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:u,response:b,networkDetails:F}))},onAbort:function(b,M,F){i.resetLoader(u,o),f(new E({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:u,networkDetails:F}))},onTimeout:function(b,M,F){i.resetLoader(u,o),f(new E({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:u,networkDetails:F}))},onProgress:function(b,M,F,w){n&&n({frag:u,part:null,payload:F,networkDetails:w})}})})},e.loadPart=function(u,n,i){var t=this;this.abort();var l=this.config,d=l.fLoader,r=l.loader;return new Promise(function(c,f){t.loader&&t.loader.destroy();var o=t.loader=u.loader=d?new d(l):new r(l),v=g(u,n),m={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:_};n.stats=o.stats,o.load(v,m,{onSuccess:function(b,M,F,w){t.resetLoader(u,o),t.updateStatsFromPart(u,n);var C={frag:u,part:n,payload:b.data,networkDetails:w};i(C),c(C)},onError:function(b,M,F){t.resetLoader(u,o),f(new E({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:u,part:n,response:b,networkDetails:F}))},onAbort:function(b,M,F){u.stats.aborted=n.stats.aborted,t.resetLoader(u,o),f(new E({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:u,part:n,networkDetails:F}))},onTimeout:function(b,M,F){t.resetLoader(u,o),f(new E({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:u,part:n,networkDetails:F}))}})})},e.updateStatsFromPart=function(u,n){var i=u.stats,t=n.stats,l=t.total;if(i.loaded+=t.loaded,l){var d=Math.round(u.duration/n.duration),r=Math.min(Math.round(i.loaded/l),d),c=d-r,f=c*Math.round(i.loaded/r);i.total=i.loaded+f}else i.total=Math.max(i.loaded,i.total);var o=i.loading,v=t.loading;o.start?o.first+=v.first-v.start:(o.start=v.start,o.first=v.first),o.end=v.end},e.resetLoader=function(u,n){u.loader=null,this.loader===n&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),n.destroy()},a}();function g(a,e){e===void 0&&(e=null);var s=e||a,u={frag:a,part:e,responseType:"arraybuffer",url:s.url,headers:{},rangeStart:0,rangeEnd:0},n=s.byteRangeStartOffset,i=s.byteRangeEndOffset;return Object(R.isFiniteNumber)(n)&&Object(R.isFiniteNumber)(i)&&(u.rangeStart=n,u.rangeEnd=i),u}var E=function(a){S(e,a);function e(s){for(var u,n=arguments.length,i=new Array(n>1?n-1:0),t=1;t<n;t++)i[t-1]=arguments[t];return u=a.call.apply(a,[this].concat(i))||this,u.data=void 0,u.data=s,u}return e}(I(Error))},"./src/loader/fragment.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"ElementaryStreamTypes",function(){return T}),h.d(P,"BaseSegment",function(){return g}),h.d(P,"Fragment",function(){return E}),h.d(P,"Part",function(){return a});var R=h("./src/polyfills/number.ts"),p=h("./node_modules/url-toolkit/src/url-toolkit.js"),S=h.n(p),I=h("./src/utils/logger.ts"),x=h("./src/loader/level-key.ts"),L=h("./src/loader/load-stats.ts");function A(e,s){e.prototype=Object.create(s.prototype),e.prototype.constructor=e,y(e,s)}function y(e,s){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},y(e,s)}function D(e,s){for(var u=0;u<s.length;u++){var n=s[u];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _(e,s,u){return s&&D(e.prototype,s),u&&D(e,u),Object.defineProperty(e,"prototype",{writable:!1}),e}var T;(function(e){e.AUDIO="audio",e.VIDEO="video",e.AUDIOVIDEO="audiovideo"})(T||(T={}));var g=function(){function e(u){var n;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(n={},n[T.AUDIO]=null,n[T.VIDEO]=null,n[T.AUDIOVIDEO]=null,n),this.baseurl=u}var s=e.prototype;return s.setByteRange=function(n,i){var t=n.split("@",2),l=[];t.length===1?l[0]=i?i.byteRangeEndOffset:0:l[0]=parseInt(t[1]),l[1]=parseInt(t[0])+l[0],this._byteRange=l},_(e,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(p.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(n){this._url=n}}]),e}(),E=function(e){A(s,e);function s(n,i){var t;return t=e.call(this,i)||this,t._decryptdata=null,t.rawProgramDateTime=null,t.programDateTime=null,t.tagList=[],t.duration=0,t.sn=0,t.levelkey=void 0,t.type=void 0,t.loader=null,t.level=-1,t.cc=0,t.startPTS=void 0,t.endPTS=void 0,t.appendedPTS=void 0,t.startDTS=void 0,t.endDTS=void 0,t.start=0,t.deltaPTS=void 0,t.maxStartPTS=void 0,t.minEndPTS=void 0,t.stats=new L.LoadStats,t.urlId=0,t.data=void 0,t.bitrateTest=!1,t.title=null,t.initSegment=null,t.type=n,t}var u=s.prototype;return u.createInitializationVector=function(i){for(var t=new Uint8Array(16),l=12;l<16;l++)t[l]=i>>8*(15-l)&255;return t},u.setDecryptDataFromLevelKey=function(i,t){var l=i;return(i==null?void 0:i.method)==="AES-128"&&i.uri&&!i.iv&&(l=x.LevelKey.fromURI(i.uri),l.method=i.method,l.iv=this.createInitializationVector(t),l.keyFormat="identity"),l},u.setElementaryStreamInfo=function(i,t,l,d,r,c){c===void 0&&(c=!1);var f=this.elementaryStreams,o=f[i];if(!o){f[i]={startPTS:t,endPTS:l,startDTS:d,endDTS:r,partial:c};return}o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,l),o.startDTS=Math.min(o.startDTS,d),o.endDTS=Math.max(o.endDTS,r)},u.clearElementaryStreamInfo=function(){var i=this.elementaryStreams;i[T.AUDIO]=null,i[T.VIDEO]=null,i[T.AUDIOVIDEO]=null},_(s,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var i=this.sn;typeof i!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&I.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),i=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,i)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!Object(R.isFiniteNumber)(this.programDateTime))return null;var i=Object(R.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+i*1e3}},{key:"encrypted",get:function(){var i;return!!((i=this.decryptdata)!==null&&i!==void 0&&i.keyFormat&&this.decryptdata.uri)}}]),s}(g),a=function(e){A(s,e);function s(u,n,i,t,l){var d;d=e.call(this,i)||this,d.fragOffset=0,d.duration=0,d.gap=!1,d.independent=!1,d.relurl=void 0,d.fragment=void 0,d.index=void 0,d.stats=new L.LoadStats,d.duration=u.decimalFloatingPoint("DURATION"),d.gap=u.bool("GAP"),d.independent=u.bool("INDEPENDENT"),d.relurl=u.enumeratedString("URI"),d.fragment=n,d.index=t;var r=u.enumeratedString("BYTERANGE");return r&&d.setByteRange(r,l),l&&(d.fragOffset=l.fragOffset+l.duration),d}return _(s,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var n=this.elementaryStreams;return!!(n.audio||n.video||n.audiovideo)}}]),s}(g)},"./src/loader/key-loader.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return I});var R=h("./src/events.ts"),p=h("./src/errors.ts"),S=h("./src/utils/logger.ts"),I=function(){function x(A){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=A,this.registerListeners()}var L=x.prototype;return L.startLoad=function(y){},L.stopLoad=function(){this.destroyInternalLoaders()},L.registerListeners=function(){this.hls.on(R.Events.KEY_LOADING,this.onKeyLoading,this)},L.unregisterListeners=function(){this.hls.off(R.Events.KEY_LOADING,this.onKeyLoading)},L.destroyInternalLoaders=function(){for(var y in this.loaders){var D=this.loaders[y];D&&D.destroy()}this.loaders={}},L.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},L.onKeyLoading=function(y,D){var _=D.frag,T=_.type,g=this.loaders[T];if(!_.decryptdata){S.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var E=_.decryptdata.uri;if(E!==this.decrypturl||this.decryptkey===null){var a=this.hls.config;if(g&&(S.logger.warn("abort previous key loader for type:"+T),g.abort()),!E){S.logger.warn("key uri is falsy");return}var e=a.loader,s=_.loader=this.loaders[T]=new e(a);this.decrypturl=E,this.decryptkey=null;var u={url:E,frag:_,responseType:"arraybuffer"},n={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:a.fragLoadingRetryDelay,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:0},i={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};s.load(u,n,i)}else this.decryptkey&&(_.decryptdata.key=this.decryptkey,this.hls.trigger(R.Events.KEY_LOADED,{frag:_}))},L.loadsuccess=function(y,D,_){var T=_.frag;if(!T.decryptdata){S.logger.error("after key load, decryptdata unset");return}this.decryptkey=T.decryptdata.key=new Uint8Array(y.data),T.loader=null,delete this.loaders[T.type],this.hls.trigger(R.Events.KEY_LOADED,{frag:T})},L.loaderror=function(y,D){var _=D.frag,T=_.loader;T&&T.abort(),delete this.loaders[_.type],this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:_,response:y})},L.loadtimeout=function(y,D){var _=D.frag,T=_.loader;T&&T.abort(),delete this.loaders[_.type],this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:_})},x}()},"./src/loader/level-details.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"LevelDetails",function(){return x});var R=h("./src/polyfills/number.ts");function p(L,A){for(var y=0;y<A.length;y++){var D=A[y];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(L,D.key,D)}}function S(L,A,y){return A&&p(L.prototype,A),y&&p(L,y),Object.defineProperty(L,"prototype",{writable:!1}),L}var I=10,x=function(){function L(y){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.needSidxRanges=!1,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.fragments=[],this.dateRanges={},this.url=y}var A=L.prototype;return A.reloaded=function(D){if(!D){this.advanced=!0,this.updated=!0;return}var _=this.lastPartSn-D.lastPartSn,T=this.lastPartIndex-D.lastPartIndex;this.updated=this.endSN!==D.endSN||!!T||!!_,this.advanced=this.endSN>D.endSN||_>0||_===0&&T>0,this.updated||this.advanced?this.misses=Math.floor(D.misses*.6):this.misses=D.misses+1,this.availabilityDelay=D.availabilityDelay},S(L,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(R.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||I}},{key:"drift",get:function(){var D=this.driftEndTime-this.driftStartTime;if(D>0){var _=this.driftEnd-this.driftStart;return _*1e3/D}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var D;return(D=this.partList)!==null&&D!==void 0&&D.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var D;return(D=this.fragments)!==null&&D!==void 0&&D.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var D;return(D=this.partList)!==null&&D!==void 0&&D.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var D;return(D=this.partList)!==null&&D!==void 0&&D.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),L}()},"./src/loader/level-key.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"LevelKey",function(){return x});var R=h("./node_modules/url-toolkit/src/url-toolkit.js"),p=h.n(R);function S(L,A){for(var y=0;y<A.length;y++){var D=A[y];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(L,D.key,D)}}function I(L,A,y){return A&&S(L.prototype,A),y&&S(L,y),Object.defineProperty(L,"prototype",{writable:!1}),L}var x=function(){L.fromURL=function(y,D){return new L(y,D)},L.fromURI=function(y){return new L(y)};function L(A,y){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,y?this._uri=Object(R.buildAbsoluteURL)(A,y,{alwaysNormalize:!0}):this._uri=A}return I(L,[{key:"uri",get:function(){return this._uri}}]),L}()},"./src/loader/load-stats.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"LoadStats",function(){return R});var R=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return u});var R=h("./src/polyfills/number.ts"),p=h("./node_modules/url-toolkit/src/url-toolkit.js"),S=h.n(p),I=h("./src/loader/date-range.ts"),x=h("./src/loader/fragment.ts"),L=h("./src/loader/level-details.ts"),A=h("./src/loader/level-key.ts"),y=h("./src/utils/attr-list.ts"),D=h("./src/utils/logger.ts"),_=h("./src/utils/codecs.ts"),T=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,g=/#EXT-X-MEDIA:(.*)/g,E=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),a=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),e=/\.(mp4|m4s|m4v|m4a)$/i;function s(r){var c,f;return e.test((c=(f=p.parseURL(r))===null||f===void 0?void 0:f.path)!=null?c:"")}var u=function(){function r(){}return r.findGroup=function(f,o){for(var v=0;v<f.length;v++){var m=f[v];if(m.id===o)return m}},r.convertAVC1ToAVCOTI=function(f){var o=f.split(".");if(o.length>2){var v=o.shift()+".";return v+=parseInt(o.shift()).toString(16),v+=("000"+parseInt(o.shift()).toString(16)).slice(-4),v}return f},r.resolve=function(f,o){return p.buildAbsoluteURL(o,f,{alwaysNormalize:!0})},r.parseMasterPlaylist=function(f,o){var v=[],m={},O=!1;T.lastIndex=0;for(var b;(b=T.exec(f))!=null;)if(b[1]){var M=new y.AttrList(b[1]),F={attrs:M,bitrate:M.decimalInteger("AVERAGE-BANDWIDTH")||M.decimalInteger("BANDWIDTH"),name:M.NAME,url:r.resolve(b[2],o)},w=M.decimalResolution("RESOLUTION");w&&(F.width=w.width,F.height=w.height),n((M.CODECS||"").split(/[ ,]+/).filter(function(U){return U}),F),F.videoCodec&&F.videoCodec.indexOf("avc1")!==-1&&(F.videoCodec=r.convertAVC1ToAVCOTI(F.videoCodec)),v.push(F)}else if(b[3]){var C=new y.AttrList(b[3]);C["DATA-ID"]&&(O=!0,m[C["DATA-ID"]]=C)}return{levels:v,sessionData:O?m:null}},r.parseMasterPlaylistMedia=function(f,o,v,m){m===void 0&&(m=[]);var O,b=[],M=0;for(g.lastIndex=0;(O=g.exec(f))!==null;){var F=new y.AttrList(O[1]);if(F.TYPE===v){var w={attrs:F,bitrate:0,id:M++,groupId:F["GROUP-ID"],instreamId:F["INSTREAM-ID"],name:F.NAME||F.LANGUAGE||"",type:v,default:F.bool("DEFAULT"),autoselect:F.bool("AUTOSELECT"),forced:F.bool("FORCED"),lang:F.LANGUAGE,url:F.URI?r.resolve(F.URI,o):""};if(m.length){var C=r.findGroup(m,w.groupId)||m[0];i(w,C,"audioCodec"),i(w,C,"textCodec")}b.push(w)}}return b},r.parseLevelPlaylist=function(f,o,v,m,O){var b=new L.LevelDetails(o),M=b.fragments,F=null,w=0,C=0,U=0,B=0,N=null,k=new x.Fragment(m,o),j,H,V,Y=-1,Q=!1;for(E.lastIndex=0,b.m3u8=f;(j=E.exec(f))!==null;){Q&&(Q=!1,k=new x.Fragment(m,o),k.start=U,k.sn=w,k.cc=B,k.level=v,F&&(k.initSegment=F,k.rawProgramDateTime=F.rawProgramDateTime,F.rawProgramDateTime=null));var J=j[1];if(J){k.duration=parseFloat(J);var z=(" "+j[2]).slice(1);k.title=z||null,k.tagList.push(z?["INF",J,z]:["INF",J])}else if(j[3])Object(R.isFiniteNumber)(k.duration)&&(k.start=U,V&&(k.levelkey=V),k.sn=w,k.level=v,k.cc=B,k.urlId=O,M.push(k),k.relurl=(" "+j[3]).slice(1),l(k,N),N=k,U+=k.duration,w++,C=0,Q=!0);else if(j[4]){var q=(" "+j[4]).slice(1);N?k.setByteRange(q,N):k.setByteRange(q)}else if(j[5])k.rawProgramDateTime=(" "+j[5]).slice(1),k.tagList.push(["PROGRAM-DATE-TIME",k.rawProgramDateTime]),Y===-1&&(Y=M.length);else{if(j=j[0].match(a),!j){D.logger.warn("No matches on slow regex match for level playlist!");continue}for(H=1;H<j.length&&typeof j[H]=="undefined";H++);var re=(" "+j[H]).slice(1),X=(" "+j[H+1]).slice(1),le=j[H+2]?(" "+j[H+2]).slice(1):"";switch(re){case"PLAYLIST-TYPE":b.type=X.toUpperCase();break;case"MEDIA-SEQUENCE":w=b.startSN=parseInt(X);break;case"SKIP":{var ne=new y.AttrList(X),te=ne.decimalInteger("SKIPPED-SEGMENTS");if(Object(R.isFiniteNumber)(te)){b.skippedSegments=te;for(var ee=te;ee--;)M.unshift(null);w+=te}var $=ne.enumeratedString("RECENTLY-REMOVED-DATERANGES");$&&(b.recentlyRemovedDateranges=$.split(" "));break}case"TARGETDURATION":b.targetduration=parseFloat(X);break;case"VERSION":b.version=parseInt(X);break;case"EXTM3U":break;case"ENDLIST":b.live=!1;break;case"#":(X||le)&&k.tagList.push(le?[X,le]:[X]);break;case"DISCONTINUITY":B++,k.tagList.push(["DIS"]);break;case"GAP":k.tagList.push([re]);break;case"BITRATE":k.tagList.push([re,X]);break;case"DATERANGE":{var Z=new y.AttrList(X),ue=new I.DateRange(Z,b.dateRanges[Z.ID]);ue.isValid||b.skippedSegments?b.dateRanges[ue.id]=ue:D.logger.warn('Ignoring invalid DATERANGE tag: "'+X+'"'),k.tagList.push(["EXT-X-DATERANGE",X]);break}case"DISCONTINUITY-SEQUENCE":B=parseInt(X);break;case"KEY":{var he,se=new y.AttrList(X),me=se.enumeratedString("METHOD"),pe=se.URI,Ee=se.hexadecimalInteger("IV"),ae=se.enumeratedString("KEYFORMATVERSIONS"),fe=se.enumeratedString("KEYID"),ge=(he=se.enumeratedString("KEYFORMAT"))!=null?he:"identity",ve=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(ve.indexOf(ge)>-1){D.logger.warn("Keyformat "+ge+" is not supported from the manifest");continue}else if(ge!=="identity")continue;me&&(V=A.LevelKey.fromURL(o,pe),pe&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(me)>=0&&(V.method=me,V.keyFormat=ge,fe&&(V.keyID=fe),ae&&(V.keyFormatVersions=ae),V.iv=Ee));break}case"START":{var Te=new y.AttrList(X),_e=Te.decimalFloatingPoint("TIME-OFFSET");Object(R.isFiniteNumber)(_e)&&(b.startTimeOffset=_e);break}case"MAP":{var Oe=new y.AttrList(X);if(k.duration){var xe=new x.Fragment(m,o);d(xe,Oe,v,V),F=xe,k.initSegment=F,F.rawProgramDateTime&&!k.rawProgramDateTime&&(k.rawProgramDateTime=F.rawProgramDateTime)}else d(k,Oe,v,V),F=k,Q=!0;break}case"SERVER-CONTROL":{var ye=new y.AttrList(X);b.canBlockReload=ye.bool("CAN-BLOCK-RELOAD"),b.canSkipUntil=ye.optionalFloat("CAN-SKIP-UNTIL",0),b.canSkipDateRanges=b.canSkipUntil>0&&ye.bool("CAN-SKIP-DATERANGES"),b.partHoldBack=ye.optionalFloat("PART-HOLD-BACK",0),b.holdBack=ye.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var W=new y.AttrList(X);b.partTarget=W.decimalFloatingPoint("PART-TARGET");break}case"PART":{var G=b.partList;G||(G=b.partList=[]);var oe=C>0?G[G.length-1]:void 0,de=C++,ce=new x.Part(new y.AttrList(X),k,o,de,oe);G.push(ce),k.duration+=ce.duration;break}case"PRELOAD-HINT":{var Se=new y.AttrList(X);b.preloadHint=Se;break}case"RENDITION-REPORT":{var ie=new y.AttrList(X);b.renditionReports=b.renditionReports||[],b.renditionReports.push(ie);break}default:D.logger.warn("line parsed but not handled: "+j);break}}}N&&!N.relurl?(M.pop(),U-=N.duration,b.partList&&(b.fragmentHint=N)):b.partList&&(l(k,N),k.cc=B,b.fragmentHint=k);var Ae=M.length,De=M[0],Le=M[Ae-1];if(U+=b.skippedSegments*b.targetduration,U>0&&Ae&&Le){b.averagetargetduration=U/Ae;var Ce=Le.sn;b.endSN=Ce!=="initSegment"?Ce:0,De&&(b.startCC=De.cc,De.initSegment||b.fragments.every(function(Pe){return Pe.relurl&&s(Pe.relurl)})&&(D.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),k=new x.Fragment(m,o),k.relurl=Le.relurl,k.level=v,k.sn="initSegment",De.initSegment=k,b.needSidxRanges=!0))}else b.endSN=0,b.startCC=0;return b.fragmentHint&&(U+=b.fragmentHint.duration),b.totalduration=U,b.endCC=B,Y>0&&t(M,Y),b},r}();function n(r,c){["video","audio","text"].forEach(function(f){var o=r.filter(function(m){return Object(_.isCodecType)(m,f)});if(o.length){var v=o.filter(function(m){return m.lastIndexOf("avc1",0)===0||m.lastIndexOf("mp4a",0)===0});c[f+"Codec"]=v.length>0?v[0]:o[0],r=r.filter(function(m){return o.indexOf(m)===-1})}}),c.unknownCodecs=r}function i(r,c,f){var o=c[f];o&&(r[f]=o)}function t(r,c){for(var f=r[c],o=c;o--;){var v=r[o];if(!v)return;v.programDateTime=f.programDateTime-v.duration*1e3,f=v}}function l(r,c){r.rawProgramDateTime?r.programDateTime=Date.parse(r.rawProgramDateTime):c!=null&&c.programDateTime&&(r.programDateTime=c.endProgramDateTime),Object(R.isFiniteNumber)(r.programDateTime)||(r.programDateTime=null,r.rawProgramDateTime=null)}function d(r,c,f,o){r.relurl=c.URI,c.BYTERANGE&&r.setByteRange(c.BYTERANGE),r.level=f,r.sn="initSegment",o&&(r.levelkey=o),r.initSegment=null}},"./src/loader/playlist-loader.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/polyfills/number.ts"),p=h("./src/events.ts"),S=h("./src/errors.ts"),I=h("./src/utils/logger.ts"),x=h("./src/utils/mp4-tools.ts"),L=h("./src/loader/m3u8-parser.ts"),A=h("./src/types/loader.ts"),y=h("./src/utils/attr-list.ts");function D(g){var E=g.type;switch(E){case A.PlaylistContextType.AUDIO_TRACK:return A.PlaylistLevelType.AUDIO;case A.PlaylistContextType.SUBTITLE_TRACK:return A.PlaylistLevelType.SUBTITLE;default:return A.PlaylistLevelType.MAIN}}function _(g,E){var a=g.url;return(a===void 0||a.indexOf("data:")===0)&&(a=E.url),a}var T=function(){function g(a){this.hls=void 0,this.loaders=Object.create(null),this.hls=a,this.registerListeners()}var E=g.prototype;return E.startLoad=function(e){},E.stopLoad=function(){this.destroyInternalLoaders()},E.registerListeners=function(){var e=this.hls;e.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(p.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},E.unregisterListeners=function(){var e=this.hls;e.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(p.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(p.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},E.createInternalLoader=function(e){var s=this.hls.config,u=s.pLoader,n=s.loader,i=u||n,t=new i(s);return e.loader=t,this.loaders[e.type]=t,t},E.getInternalLoader=function(e){return this.loaders[e.type]},E.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},E.destroyInternalLoaders=function(){for(var e in this.loaders){var s=this.loaders[e];s&&s.destroy(),this.resetInternalLoader(e)}},E.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},E.onManifestLoading=function(e,s){var u=s.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:A.PlaylistContextType.MANIFEST,url:u,deliveryDirectives:null})},E.onLevelLoading=function(e,s){var u=s.id,n=s.level,i=s.url,t=s.deliveryDirectives;this.load({id:u,groupId:null,level:n,responseType:"text",type:A.PlaylistContextType.LEVEL,url:i,deliveryDirectives:t})},E.onAudioTrackLoading=function(e,s){var u=s.id,n=s.groupId,i=s.url,t=s.deliveryDirectives;this.load({id:u,groupId:n,level:null,responseType:"text",type:A.PlaylistContextType.AUDIO_TRACK,url:i,deliveryDirectives:t})},E.onSubtitleTrackLoading=function(e,s){var u=s.id,n=s.groupId,i=s.url,t=s.deliveryDirectives;this.load({id:u,groupId:n,level:null,responseType:"text",type:A.PlaylistContextType.SUBTITLE_TRACK,url:i,deliveryDirectives:t})},E.load=function(e){var s,u=this.hls.config,n=this.getInternalLoader(e);if(n){var i=n.context;if(i&&i.url===e.url){I.logger.trace("[playlist-loader]: playlist request ongoing");return}I.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),n.abort()}var t,l,d,r;switch(e.type){case A.PlaylistContextType.MANIFEST:t=u.manifestLoadingMaxRetry,l=u.manifestLoadingTimeOut,d=u.manifestLoadingRetryDelay,r=u.manifestLoadingMaxRetryTimeout;break;case A.PlaylistContextType.LEVEL:case A.PlaylistContextType.AUDIO_TRACK:case A.PlaylistContextType.SUBTITLE_TRACK:t=0,l=u.levelLoadingTimeOut;break;default:t=u.levelLoadingMaxRetry,l=u.levelLoadingTimeOut,d=u.levelLoadingRetryDelay,r=u.levelLoadingMaxRetryTimeout;break}if(n=this.createInternalLoader(e),(s=e.deliveryDirectives)!==null&&s!==void 0&&s.part){var c;if(e.type===A.PlaylistContextType.LEVEL&&e.level!==null?c=this.hls.levels[e.level].details:e.type===A.PlaylistContextType.AUDIO_TRACK&&e.id!==null?c=this.hls.audioTracks[e.id].details:e.type===A.PlaylistContextType.SUBTITLE_TRACK&&e.id!==null&&(c=this.hls.subtitleTracks[e.id].details),c){var f=c.partTarget,o=c.targetduration;f&&o&&(l=Math.min(Math.max(f*3,o*.8)*1e3,l))}}var v={timeout:l,maxRetry:t,retryDelay:d,maxRetryDelay:r,highWaterMark:0},m={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};n.load(e,v,m)},E.loadsuccess=function(e,s,u,n){if(n===void 0&&(n=null),u.isSidxRequest){this.handleSidxRequest(e,u),this.handlePlaylistLoaded(e,s,u,n);return}this.resetInternalLoader(u.type);var i=e.data;if(i.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(e,u,"no EXTM3U delimiter",n);return}s.parsing.start=performance.now(),i.indexOf("#EXTINF:")>0||i.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,s,u,n):this.handleMasterPlaylist(e,s,u,n)},E.loaderror=function(e,s,u){u===void 0&&(u=null),this.handleNetworkError(s,u,!1,e)},E.loadtimeout=function(e,s,u){u===void 0&&(u=null),this.handleNetworkError(s,u,!0)},E.handleMasterPlaylist=function(e,s,u,n){var i=this.hls,t=e.data,l=_(e,u),d=L.default.parseMasterPlaylist(t,l),r=d.levels,c=d.sessionData;if(!r.length){this.handleManifestParsingError(e,u,"no level found in manifest",n);return}var f=r.map(function(M){return{id:M.attrs.AUDIO,audioCodec:M.audioCodec}}),o=r.map(function(M){return{id:M.attrs.SUBTITLES,textCodec:M.textCodec}}),v=L.default.parseMasterPlaylistMedia(t,l,"AUDIO",f),m=L.default.parseMasterPlaylistMedia(t,l,"SUBTITLES",o),O=L.default.parseMasterPlaylistMedia(t,l,"CLOSED-CAPTIONS");if(v.length){var b=v.some(function(M){return!M.url});!b&&r[0].audioCodec&&!r[0].attrs.AUDIO&&(I.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),v.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new y.AttrList({}),bitrate:0,url:""}))}i.trigger(p.Events.MANIFEST_LOADED,{levels:r,audioTracks:v,subtitles:m,captions:O,url:l,stats:s,networkDetails:n,sessionData:c})},E.handleTrackOrLevelPlaylist=function(e,s,u,n){var i=this.hls,t=u.id,l=u.level,d=u.type,r=_(e,u),c=Object(R.isFiniteNumber)(t)?t:0,f=Object(R.isFiniteNumber)(l)?l:c,o=D(u),v=L.default.parseLevelPlaylist(e.data,r,f,o,c);if(!v.fragments.length){i.trigger(p.Events.ERROR,{type:S.ErrorTypes.NETWORK_ERROR,details:S.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:r,reason:"no fragments found in level",level:typeof u.level=="number"?u.level:void 0});return}if(d===A.PlaylistContextType.MANIFEST){var m={attrs:new y.AttrList({}),bitrate:0,details:v,name:"",url:r};i.trigger(p.Events.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:r,stats:s,networkDetails:n,sessionData:null})}if(s.parsing.end=performance.now(),v.needSidxRanges){var O,b=(O=v.fragments[0].initSegment)===null||O===void 0?void 0:O.url;this.load({url:b,isSidxRequest:!0,type:d,level:l,levelDetails:v,id:t,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}u.levelDetails=v,this.handlePlaylistLoaded(e,s,u,n)},E.handleSidxRequest=function(e,s){var u=new Uint8Array(e.data),n=Object(x.findBox)(u,["sidx"])[0];if(!!n){var i=Object(x.parseSegmentIndex)(n);if(!!i){var t=i.references,l=s.levelDetails;t.forEach(function(d,r){var c=d.info,f=l.fragments[r];if(f.byteRange.length===0&&f.setByteRange(String(1+c.end-c.start)+"@"+String(c.start)),f.initSegment){var o=Object(x.findBox)(u,["moov"])[0],v=o?o.length:null;f.initSegment.setByteRange(String(v)+"@0")}})}}},E.handleManifestParsingError=function(e,s,u,n){this.hls.trigger(p.Events.ERROR,{type:S.ErrorTypes.NETWORK_ERROR,details:S.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:s.type===A.PlaylistContextType.MANIFEST,url:e.url,reason:u,response:e,context:s,networkDetails:n})},E.handleNetworkError=function(e,s,u,n){u===void 0&&(u=!1),I.logger.warn("[playlist-loader]: A network "+(u?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var i=S.ErrorDetails.UNKNOWN,t=!1,l=this.getInternalLoader(e);switch(e.type){case A.PlaylistContextType.MANIFEST:i=u?S.ErrorDetails.MANIFEST_LOAD_TIMEOUT:S.ErrorDetails.MANIFEST_LOAD_ERROR,t=!0;break;case A.PlaylistContextType.LEVEL:i=u?S.ErrorDetails.LEVEL_LOAD_TIMEOUT:S.ErrorDetails.LEVEL_LOAD_ERROR,t=!1;break;case A.PlaylistContextType.AUDIO_TRACK:i=u?S.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:S.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,t=!1;break;case A.PlaylistContextType.SUBTITLE_TRACK:i=u?S.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:S.ErrorDetails.SUBTITLE_LOAD_ERROR,t=!1;break}l&&this.resetInternalLoader(e.type);var d={type:S.ErrorTypes.NETWORK_ERROR,details:i,fatal:t,url:e.url,loader:l,context:e,networkDetails:s};n&&(d.response=n),this.hls.trigger(p.Events.ERROR,d)},E.handlePlaylistLoaded=function(e,s,u,n){var i=u.type,t=u.level,l=u.id,d=u.groupId,r=u.loader,c=u.levelDetails,f=u.deliveryDirectives;if(!(c!=null&&c.targetduration)){this.handleManifestParsingError(e,u,"invalid target duration",n);return}if(!!r)switch(c.live&&(r.getCacheAge&&(c.ageHeader=r.getCacheAge()||0),(!r.getCacheAge||isNaN(c.ageHeader))&&(c.ageHeader=0)),i){case A.PlaylistContextType.MANIFEST:case A.PlaylistContextType.LEVEL:this.hls.trigger(p.Events.LEVEL_LOADED,{details:c,level:t||0,id:l||0,stats:s,networkDetails:n,deliveryDirectives:f});break;case A.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(p.Events.AUDIO_TRACK_LOADED,{details:c,id:l||0,groupId:d||"",stats:s,networkDetails:n,deliveryDirectives:f});break;case A.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(p.Events.SUBTITLE_TRACK_LOADED,{details:c,id:l||0,groupId:d||"",stats:s,networkDetails:n,deliveryDirectives:f});break}},g}();P.default=T},"./src/polyfills/number.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"isFiniteNumber",function(){return R}),h.d(P,"MAX_SAFE_INTEGER",function(){return p});var R=Number.isFinite||function(S){return typeof S=="number"&&isFinite(S)},p=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(K,P,h){"use strict";h.r(P);var R=function(){function p(){}return p.getSilentFrame=function(I,x){switch(I){case"mp4a.40.2":if(x===1)return new Uint8Array([0,200,0,128,35,128]);if(x===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(x===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(x===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(x===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(x===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(x===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(x===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(x===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}},p}();P.default=R},"./src/remux/mp4-generator.ts":function(K,P,h){"use strict";h.r(P);var R=Math.pow(2,32)-1,p=function(){function S(){}return S.init=function(){S.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var x;for(x in S.types)S.types.hasOwnProperty(x)&&(S.types[x]=[x.charCodeAt(0),x.charCodeAt(1),x.charCodeAt(2),x.charCodeAt(3)]);var L=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]),A=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);S.HDLR_TYPES={video:L,audio:A};var y=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),D=new Uint8Array([0,0,0,0,0,0,0,0]);S.STTS=S.STSC=S.STCO=D,S.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),S.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),S.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),S.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var _=new Uint8Array([105,115,111,109]),T=new Uint8Array([97,118,99,49]),g=new Uint8Array([0,0,0,1]);S.FTYP=S.box(S.types.ftyp,_,g,_,T),S.DINF=S.box(S.types.dinf,S.box(S.types.dref,y))},S.box=function(x){for(var L=8,A=arguments.length,y=new Array(A>1?A-1:0),D=1;D<A;D++)y[D-1]=arguments[D];for(var _=y.length,T=_;_--;)L+=y[_].byteLength;var g=new Uint8Array(L);for(g[0]=L>>24&255,g[1]=L>>16&255,g[2]=L>>8&255,g[3]=L&255,g.set(x,4),_=0,L=8;_<T;_++)g.set(y[_],L),L+=y[_].byteLength;return g},S.hdlr=function(x){return S.box(S.types.hdlr,S.HDLR_TYPES[x])},S.mdat=function(x){return S.box(S.types.mdat,x)},S.mdhd=function(x,L){L*=x;var A=Math.floor(L/(R+1)),y=Math.floor(L%(R+1));return S.box(S.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,x>>24&255,x>>16&255,x>>8&255,x&255,A>>24,A>>16&255,A>>8&255,A&255,y>>24,y>>16&255,y>>8&255,y&255,85,196,0,0]))},S.mdia=function(x){return S.box(S.types.mdia,S.mdhd(x.timescale,x.duration),S.hdlr(x.type),S.minf(x))},S.mfhd=function(x){return S.box(S.types.mfhd,new Uint8Array([0,0,0,0,x>>24,x>>16&255,x>>8&255,x&255]))},S.minf=function(x){return x.type==="audio"?S.box(S.types.minf,S.box(S.types.smhd,S.SMHD),S.DINF,S.stbl(x)):S.box(S.types.minf,S.box(S.types.vmhd,S.VMHD),S.DINF,S.stbl(x))},S.moof=function(x,L,A){return S.box(S.types.moof,S.mfhd(x),S.traf(A,L))},S.moov=function(x){for(var L=x.length,A=[];L--;)A[L]=S.trak(x[L]);return S.box.apply(null,[S.types.moov,S.mvhd(x[0].timescale,x[0].duration)].concat(A).concat(S.mvex(x)))},S.mvex=function(x){for(var L=x.length,A=[];L--;)A[L]=S.trex(x[L]);return S.box.apply(null,[S.types.mvex].concat(A))},S.mvhd=function(x,L){L*=x;var A=Math.floor(L/(R+1)),y=Math.floor(L%(R+1)),D=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,x>>24&255,x>>16&255,x>>8&255,x&255,A>>24,A>>16&255,A>>8&255,A&255,y>>24,y>>16&255,y>>8&255,y&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 S.box(S.types.mvhd,D)},S.sdtp=function(x){var L=x.samples||[],A=new Uint8Array(4+L.length),y,D;for(y=0;y<L.length;y++)D=L[y].flags,A[y+4]=D.dependsOn<<4|D.isDependedOn<<2|D.hasRedundancy;return S.box(S.types.sdtp,A)},S.stbl=function(x){return S.box(S.types.stbl,S.stsd(x),S.box(S.types.stts,S.STTS),S.box(S.types.stsc,S.STSC),S.box(S.types.stsz,S.STSZ),S.box(S.types.stco,S.STCO))},S.avc1=function(x){var L=[],A=[],y,D,_;for(y=0;y<x.sps.length;y++)D=x.sps[y],_=D.byteLength,L.push(_>>>8&255),L.push(_&255),L=L.concat(Array.prototype.slice.call(D));for(y=0;y<x.pps.length;y++)D=x.pps[y],_=D.byteLength,A.push(_>>>8&255),A.push(_&255),A=A.concat(Array.prototype.slice.call(D));var T=S.box(S.types.avcC,new Uint8Array([1,L[3],L[4],L[5],255,224|x.sps.length].concat(L).concat([x.pps.length]).concat(A))),g=x.width,E=x.height,a=x.pixelRatio[0],e=x.pixelRatio[1];return S.box(S.types.avc1,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,g>>8&255,g&255,E>>8&255,E&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]),T,S.box(S.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),S.box(S.types.pasp,new Uint8Array([a>>24,a>>16&255,a>>8&255,a&255,e>>24,e>>16&255,e>>8&255,e&255])))},S.esds=function(x){var L=x.config.length;return new Uint8Array([0,0,0,0,3,23+L,0,1,0,4,15+L,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([L]).concat(x.config).concat([6,1,2]))},S.mp4a=function(x){var L=x.samplerate;return S.box(S.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,x.channelCount,0,16,0,0,0,0,L>>8&255,L&255,0,0]),S.box(S.types.esds,S.esds(x)))},S.mp3=function(x){var L=x.samplerate;return S.box(S.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,x.channelCount,0,16,0,0,0,0,L>>8&255,L&255,0,0]))},S.stsd=function(x){return x.type==="audio"?x.segmentCodec==="mp3"&&x.codec==="mp3"?S.box(S.types.stsd,S.STSD,S.mp3(x)):S.box(S.types.stsd,S.STSD,S.mp4a(x)):S.box(S.types.stsd,S.STSD,S.avc1(x))},S.tkhd=function(x){var L=x.id,A=x.duration*x.timescale,y=x.width,D=x.height,_=Math.floor(A/(R+1)),T=Math.floor(A%(R+1));return S.box(S.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,L>>24&255,L>>16&255,L>>8&255,L&255,0,0,0,0,_>>24,_>>16&255,_>>8&255,_&255,T>>24,T>>16&255,T>>8&255,T&255,0,0,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,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,y>>8&255,y&255,0,0,D>>8&255,D&255,0,0]))},S.traf=function(x,L){var A=S.sdtp(x),y=x.id,D=Math.floor(L/(R+1)),_=Math.floor(L%(R+1));return S.box(S.types.traf,S.box(S.types.tfhd,new Uint8Array([0,0,0,0,y>>24,y>>16&255,y>>8&255,y&255])),S.box(S.types.tfdt,new Uint8Array([1,0,0,0,D>>24,D>>16&255,D>>8&255,D&255,_>>24,_>>16&255,_>>8&255,_&255])),S.trun(x,A.length+16+20+8+16+8+8),A)},S.trak=function(x){return x.duration=x.duration||4294967295,S.box(S.types.trak,S.tkhd(x),S.mdia(x))},S.trex=function(x){var L=x.id;return S.box(S.types.trex,new Uint8Array([0,0,0,0,L>>24,L>>16&255,L>>8&255,L&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},S.trun=function(x,L){var A=x.samples||[],y=A.length,D=12+16*y,_=new Uint8Array(D),T,g,E,a,e,s;for(L+=8+D,_.set([x.type==="video"?1:0,0,15,1,y>>>24&255,y>>>16&255,y>>>8&255,y&255,L>>>24&255,L>>>16&255,L>>>8&255,L&255],0),T=0;T<y;T++)g=A[T],E=g.duration,a=g.size,e=g.flags,s=g.cts,_.set([E>>>24&255,E>>>16&255,E>>>8&255,E&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255,e.isLeading<<2|e.dependsOn,e.isDependedOn<<6|e.hasRedundancy<<4|e.paddingValue<<1|e.isNonSync,e.degradPrio&240<<8,e.degradPrio&15,s>>>24&255,s>>>16&255,s>>>8&255,s&255],12+16*T);return S.box(S.types.trun,_)},S.initSegment=function(x){S.types||S.init();var L=S.moov(x),A=new Uint8Array(S.FTYP.byteLength+L.byteLength);return A.set(S.FTYP),A.set(L,S.FTYP.byteLength),A},S}();p.types=void 0,p.HDLR_TYPES=void 0,p.STTS=void 0,p.STSC=void 0,p.STCO=void 0,p.STSZ=void 0,p.VMHD=void 0,p.SMHD=void 0,p.STSD=void 0,p.FTYP=void 0,p.DINF=void 0,P.default=p},"./src/remux/mp4-remuxer.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return e}),h.d(P,"normalizePts",function(){return s}),h.d(P,"flushTextTrackMetadataCueSamples",function(){return n}),h.d(P,"flushTextTrackUserdataCueSamples",function(){return i});var R=h("./src/polyfills/number.ts"),p=h("./src/remux/aac-helper.ts"),S=h("./src/remux/mp4-generator.ts"),I=h("./src/events.ts"),x=h("./src/errors.ts"),L=h("./src/utils/logger.ts"),A=h("./src/types/loader.ts"),y=h("./src/utils/timescale-conversion.ts");function D(){return D=Object.assign?Object.assign.bind():function(d){for(var r=1;r<arguments.length;r++){var c=arguments[r];for(var f in c)Object.prototype.hasOwnProperty.call(c,f)&&(d[f]=c[f])}return d},D.apply(this,arguments)}var _=10*1e3,T=1024,g=1152,E=null,a=null,e=function(){function d(c,f,o,v){if(v===void 0&&(v=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=c,this.config=f,this.typeSupported=o,this.ISGenerated=!1,E===null){var m=navigator.userAgent||"",O=m.match(/Chrome\/(\d+)/i);E=O?parseInt(O[1]):0}if(a===null){var b=navigator.userAgent.match(/Safari\/(\d+)/i);a=b?parseInt(b[1]):0}}var r=d.prototype;return r.destroy=function(){},r.resetTimeStamp=function(f){L.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=f},r.resetNextTimestamp=function(){L.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},r.resetInitSegment=function(){L.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},r.getVideoStartPts=function(f){var o=!1,v=f.reduce(function(m,O){var b=O.pts-m;return b<-4294967296?(o=!0,s(m,O.pts)):b>0?m:O.pts},f[0].pts);return o&&L.logger.debug("PTS rollover detected"),v},r.remux=function(f,o,v,m,O,b,M,F){var w,C,U,B,N,k,j=O,H=O,V=f.pid>-1,Y=o.pid>-1,Q=o.samples.length,J=f.samples.length>0,z=M&&Q>0||Q>1,q=(!V||J)&&(!Y||z)||this.ISGenerated||M;if(q){this.ISGenerated||(U=this.generateIS(f,o,O));var re=this.isVideoContiguous,X=-1,le;if(z&&(X=u(o.samples),!re&&this.config.forceKeyFrameOnDiscontinuity))if(k=!0,X>0){L.logger.warn("[mp4-remuxer]: Dropped "+X+" out of "+Q+" video samples due to a missing keyframe");var ne=this.getVideoStartPts(o.samples);o.samples=o.samples.slice(X),o.dropped+=X,H+=(o.samples[0].pts-ne)/o.inputTimeScale,le=H}else X===-1&&(L.logger.warn("[mp4-remuxer]: No keyframe found out of "+Q+" video samples"),k=!1);if(this.ISGenerated){if(J&&z){var te=this.getVideoStartPts(o.samples),ee=s(f.samples[0].pts,te)-te,$=ee/o.inputTimeScale;j+=Math.max(0,$),H+=Math.max(0,-$)}if(J){if(f.samplerate||(L.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),U=this.generateIS(f,o,O)),C=this.remuxAudio(f,j,this.isAudioContiguous,b,Y||z||F===A.PlaylistLevelType.AUDIO?H:void 0),z){var Z=C?C.endPTS-C.startPTS:0;o.inputTimeScale||(L.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),U=this.generateIS(f,o,O)),w=this.remuxVideo(o,H,re,Z)}}else z&&(w=this.remuxVideo(o,H,re,0));w&&(w.firstKeyFrame=X,w.independent=X!==-1,w.firstKeyFramePTS=le)}}return this.ISGenerated&&(v.samples.length&&(N=n(v,O,this._initPTS,this._initDTS)),m.samples.length&&(B=i(m,O,this._initPTS))),{audio:C,video:w,initSegment:U,independent:k,text:B,id3:N}},r.generateIS=function(f,o,v){var m=f.samples,O=o.samples,b=this.typeSupported,M={},F=!Object(R.isFiniteNumber)(this._initPTS),w="audio/mp4",C,U,B;if(F&&(C=U=1/0),f.config&&m.length){switch(f.timescale=f.samplerate,f.segmentCodec){case"mp3":b.mpeg?(w="audio/mpeg",f.codec=""):b.mp3&&(f.codec="mp3");break}M.audio={id:"audio",container:w,codec:f.codec,initSegment:f.segmentCodec==="mp3"&&b.mpeg?new Uint8Array(0):S.default.initSegment([f]),metadata:{channelCount:f.channelCount}},F&&(B=f.inputTimeScale,C=U=m[0].pts-Math.round(B*v))}if(o.sps&&o.pps&&O.length&&(o.timescale=o.inputTimeScale,M.video={id:"main",container:"video/mp4",codec:o.codec,initSegment:S.default.initSegment([o]),metadata:{width:o.width,height:o.height}},F)){B=o.inputTimeScale;var N=this.getVideoStartPts(O),k=Math.round(B*v);U=Math.min(U,s(O[0].dts,N)-k),C=Math.min(C,N-k)}if(Object.keys(M).length)return this.ISGenerated=!0,F&&(this._initPTS=C,this._initDTS=U),{tracks:M,initPTS:C,timescale:B}},r.remuxVideo=function(f,o,v,m){var O=f.inputTimeScale,b=f.samples,M=[],F=b.length,w=this._initPTS,C=this.nextAvcDts,U=8,B=this.videoSampleDuration,N,k,j=Number.POSITIVE_INFINITY,H=Number.NEGATIVE_INFINITY,V=!1;if(!v||C===null){var Y=o*O,Q=b[0].pts-s(b[0].dts,b[0].pts);C=Y-Q}for(var J=0;J<F;J++){var z=b[J];z.pts=s(z.pts-w,C),z.dts=s(z.dts-w,C),z.dts<b[J>0?J-1:J].dts&&(V=!0)}V&&b.sort(function(we,Xe){var Qe=we.dts-Xe.dts,qe=we.pts-Xe.pts;return Qe||qe}),N=b[0].dts,k=b[b.length-1].dts;var q=k-N,re=q?Math.round(q/(F-1)):B||f.inputTimeScale/30;if(v){var X=N-C,le=X>re,ne=X<-1;if(le||ne){le?L.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(X,!0)+" ms ("+X+"dts) hole between fragments detected, filling it"):L.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(-X,!0)+" ms ("+X+"dts) overlapping between fragments detected"),N=C;var te=b[0].pts-X;b[0].dts=N,b[0].pts=te,L.logger.log("Video: First PTS/DTS adjusted: "+Object(y.toMsFromMpegTsClock)(te,!0)+"/"+Object(y.toMsFromMpegTsClock)(N,!0)+", delta: "+Object(y.toMsFromMpegTsClock)(X,!0)+" ms")}}N=Math.max(0,N);for(var ee=0,$=0,Z=0;Z<F;Z++){for(var ue=b[Z],he=ue.units,se=he.length,me=0,pe=0;pe<se;pe++)me+=he[pe].data.length;$+=me,ee+=se,ue.length=me,ue.dts=Math.max(ue.dts,N),j=Math.min(ue.pts,j),H=Math.max(ue.pts,H)}k=b[F-1].dts;var Ee=$+4*ee+8,ae;try{ae=new Uint8Array(Ee)}catch{this.observer.emit(I.Events.ERROR,I.Events.ERROR,{type:x.ErrorTypes.MUX_ERROR,details:x.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Ee,reason:"fail allocating video mdat "+Ee});return}var fe=new DataView(ae.buffer);fe.setUint32(0,Ee),ae.set(S.default.types.mdat,4);for(var ge=!1,ve=Number.POSITIVE_INFINITY,Te=Number.POSITIVE_INFINITY,_e=Number.NEGATIVE_INFINITY,Oe=Number.NEGATIVE_INFINITY,xe=0;xe<F;xe++){for(var ye=b[xe],W=ye.units,G=0,oe=0,de=W.length;oe<de;oe++){var ce=W[oe],Se=ce.data,ie=ce.data.byteLength;fe.setUint32(U,ie),U+=4,ae.set(Se,U),U+=ie,G+=4+ie}var Ae=void 0;if(xe<F-1)B=b[xe+1].dts-ye.dts,Ae=b[xe+1].pts-ye.pts;else{var De=this.config,Le=xe>0?ye.dts-b[xe-1].dts:re;if(Ae=xe>0?ye.pts-b[xe-1].pts:re,De.stretchShortVideoTrack&&this.nextAudioPts!==null){var Ce=Math.floor(De.maxBufferHole*O),Pe=(m?j+m*O:this.nextAudioPts)-ye.pts;Pe>Ce?(B=Pe-Le,B<0?B=Le:ge=!0,L.logger.log("[mp4-remuxer]: It is approximately "+Pe/90+" ms to the next segment; using duration "+B/90+" ms for the last video frame.")):B=Le}else B=Le}var Ie=Math.round(ye.pts-ye.dts);ve=Math.min(ve,B),_e=Math.max(_e,B),Te=Math.min(Te,Ae),Oe=Math.max(Oe,Ae),M.push(new t(ye.key,B,G,Ie))}if(M.length){if(E){if(E<70){var Ve=M[0].flags;Ve.dependsOn=2,Ve.isNonSync=0}}else if(a&&Oe-Te<_e-ve&&re/_e<.025&&M[0].cts===0){L.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var Be=N,Re=0,Fe=M.length;Re<Fe;Re++){var ke=Be+M[Re].duration,Ne=Be+M[Re].cts;if(Re<Fe-1){var Ye=ke+M[Re+1].cts;M[Re].duration=Ye-Ne}else M[Re].duration=Re?M[Re-1].duration:re;M[Re].cts=0,Be=ke}}}console.assert(B!==null,"mp4SampleDuration must be computed"),B=ge||!B?re:B,this.nextAvcDts=C=k+B,this.videoSampleDuration=B,this.isVideoContiguous=!0;var ze=S.default.moof(f.sequenceNumber++,N,D({},f,{samples:M})),$e="video",Ze={data1:ze,data2:ae,startPTS:j/O,endPTS:(H+B)/O,startDTS:N/O,endDTS:C/O,type:$e,hasAudio:!1,hasVideo:!0,nb:M.length,dropped:f.dropped};return f.samples=[],f.dropped=0,console.assert(ae.length,"MDAT length must not be zero"),Ze},r.remuxAudio=function(f,o,v,m,O){var b=f.inputTimeScale,M=f.samplerate?f.samplerate:b,F=b/M,w=f.segmentCodec==="aac"?T:g,C=w*F,U=this._initPTS,B=f.segmentCodec==="mp3"&&this.typeSupported.mpeg,N=[],k=O!==void 0,j=f.samples,H=B?0:8,V=this.nextAudioPts||-1,Y=o*b;if(this.isAudioContiguous=v=v||j.length&&V>0&&(m&&Math.abs(Y-V)<9e3||Math.abs(s(j[0].pts-U,Y)-V)<20*C),j.forEach(function(ce){ce.pts=s(ce.pts-U,Y)}),!v||V<0){if(j=j.filter(function(ce){return ce.pts>=0}),!j.length)return;O===0?V=0:m&&!k?V=Math.max(0,Y):V=j[0].pts}if(f.segmentCodec==="aac")for(var Q=this.config.maxAudioFramesDrift,J=0,z=V;J<j.length;J++){var q=j[J],re=q.pts,X=re-z,le=Math.abs(1e3*X/b);if(X<=-Q*C&&k)J===0&&(L.logger.warn("Audio frame @ "+(re/b).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*X/b)+" ms."),this.nextAudioPts=V=z=re);else if(X>=Q*C&&le<_&&k){var ne=Math.round(X/C);z=re-ne*C,z<0&&(ne--,z+=C),J===0&&(this.nextAudioPts=V=z),L.logger.warn("[mp4-remuxer]: Injecting "+ne+" audio frame @ "+(z/b).toFixed(3)+"s due to "+Math.round(1e3*X/b)+" ms gap.");for(var te=0;te<ne;te++){var ee=Math.max(z,0),$=p.default.getSilentFrame(f.manifestCodec||f.codec,f.channelCount);$||(L.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),$=q.unit.subarray()),j.splice(J,0,{unit:$,pts:ee}),z+=C,J++}}q.pts=z,z+=C}for(var Z=null,ue=null,he,se=0,me=j.length;me--;)se+=j[me].unit.byteLength;for(var pe=0,Ee=j.length;pe<Ee;pe++){var ae=j[pe],fe=ae.unit,ge=ae.pts;if(ue!==null){var ve=N[pe-1];ve.duration=Math.round((ge-ue)/F)}else if(v&&f.segmentCodec==="aac"&&(ge=V),Z=ge,se>0){se+=H;try{he=new Uint8Array(se)}catch{this.observer.emit(I.Events.ERROR,I.Events.ERROR,{type:x.ErrorTypes.MUX_ERROR,details:x.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:se,reason:"fail allocating audio mdat "+se});return}if(!B){var Te=new DataView(he.buffer);Te.setUint32(0,se),he.set(S.default.types.mdat,4)}}else return;he.set(fe,H);var _e=fe.byteLength;H+=_e,N.push(new t(!0,w,_e,0)),ue=ge}var Oe=N.length;if(!!Oe){var xe=N[N.length-1];this.nextAudioPts=V=ue+F*xe.duration;var ye=B?new Uint8Array(0):S.default.moof(f.sequenceNumber++,Z/F,D({},f,{samples:N}));f.samples=[];var W=Z/b,G=V/b,oe="audio",de={data1:ye,data2:he,startPTS:W,endPTS:G,startDTS:W,endDTS:G,type:oe,hasAudio:!0,hasVideo:!1,nb:Oe};return this.isAudioContiguous=!0,console.assert(he.length,"MDAT length must not be zero"),de}},r.remuxEmptyAudio=function(f,o,v,m){var O=f.inputTimeScale,b=f.samplerate?f.samplerate:O,M=O/b,F=this.nextAudioPts,w=(F!==null?F:m.startDTS*O)+this._initDTS,C=m.endDTS*O+this._initDTS,U=M*T,B=Math.ceil((C-w)/U),N=p.default.getSilentFrame(f.manifestCodec||f.codec,f.channelCount);if(L.logger.warn("[mp4-remuxer]: remux empty Audio"),!N){L.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var k=[],j=0;j<B;j++){var H=w+j*U;k.push({unit:N,pts:H,dts:H})}return f.samples=k,this.remuxAudio(f,o,v,!1)},d}();function s(d,r){var c;if(r===null)return d;for(r<d?c=-8589934592:c=8589934592;Math.abs(d-r)>4294967296;)d+=c;return d}function u(d){for(var r=0;r<d.length;r++)if(d[r].key)return r;return-1}function n(d,r,c,f){var o=d.samples.length;if(!!o){for(var v=d.inputTimeScale,m=0;m<o;m++){var O=d.samples[m];O.pts=s(O.pts-c,r*v)/v,O.dts=s(O.dts-f,r*v)/v}var b=d.samples;return d.samples=[],{samples:b}}}function i(d,r,c){var f=d.samples.length;if(!!f){for(var o=d.inputTimeScale,v=0;v<f;v++){var m=d.samples[v];m.pts=s(m.pts-c,r*o)/o}d.samples.sort(function(b,M){return b.pts-M.pts});var O=d.samples;return d.samples=[],{samples:O}}}var t=function(r,c,f,o){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=c,this.size=f,this.cts=o,this.flags=new l(r)},l=function(r){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=r?2:1,this.isNonSync=r?0:1}},"./src/remux/passthrough-remuxer.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/polyfills/number.ts"),p=h("./src/remux/mp4-remuxer.ts"),S=h("./src/utils/mp4-tools.ts"),I=h("./src/loader/fragment.ts"),x=h("./src/utils/logger.ts"),L=function(){function y(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndTime=null}var D=y.prototype;return D.destroy=function(){},D.resetTimeStamp=function(T){this.initPTS=T,this.lastEndTime=null},D.resetNextTimestamp=function(){this.lastEndTime=null},D.resetInitSegment=function(T,g,E){this.audioCodec=g,this.videoCodec=E,this.generateInitSegment(T),this.emitInitSegment=!0},D.generateInitSegment=function(T){var g=this.audioCodec,E=this.videoCodec;if(!T||!T.byteLength){this.initTracks=void 0,this.initData=void 0;return}var a=this.initData=Object(S.parseInitSegment)(T);g||(g=A(a.audio,I.ElementaryStreamTypes.AUDIO)),E||(E=A(a.video,I.ElementaryStreamTypes.VIDEO));var e={};a.audio&&a.video?e.audiovideo={container:"video/mp4",codec:g+","+E,initSegment:T,id:"main"}:a.audio?e.audio={container:"audio/mp4",codec:g,initSegment:T,id:"audio"}:a.video?e.video={container:"video/mp4",codec:E,initSegment:T,id:"main"}:x.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=e},D.remux=function(T,g,E,a,e){var s,u=this.initPTS,n=this.lastEndTime,i={audio:void 0,video:void 0,text:a,id3:E,initSegment:void 0};Object(R.isFiniteNumber)(n)||(n=this.lastEndTime=e||0);var t=g.samples;if(!t||!t.length)return i;var l={initPTS:void 0,timescale:1},d=this.initData;if((!d||!d.length)&&(this.generateInitSegment(t),d=this.initData),!d||!d.length)return x.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),i;this.emitInitSegment&&(l.tracks=this.initTracks,this.emitInitSegment=!1);var r=Object(S.getStartDTS)(d,t);Object(R.isFiniteNumber)(u)||(this.initPTS=l.initPTS=u=r-e);var c=Object(S.getDuration)(t,d),f=T?r-u:n,o=f+c;Object(S.offsetStartDTS)(d,t,u),c>0?this.lastEndTime=o:(x.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var v=!!d.audio,m=!!d.video,O="";v&&(O+="audio"),m&&(O+="video");var b={data1:t,startPTS:f,startDTS:f,endPTS:o,endDTS:o,type:O,hasAudio:v,hasVideo:m,nb:1,dropped:0};i.audio=b.type==="audio"?b:void 0,i.video=b.type!=="audio"?b:void 0,i.initSegment=l;var M=(s=this.initPTS)!=null?s:0;return i.id3=Object(p.flushTextTrackMetadataCueSamples)(E,e,M,M),a.samples.length&&(i.text=Object(p.flushTextTrackUserdataCueSamples)(a,e,M)),i},y}();function A(y,D){var _=y==null?void 0:y.codec;return _&&_.length>4?_:_==="hvc1"||_==="hev1"?"hvc1.1.c.L120.90":_==="av01"?"av01.0.04M.08":_==="avc1"||D===I.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}P.default=L},"./src/task-loop.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return R});var R=function(){function p(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var S=p.prototype;return S.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},S.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},S.onHandlerDestroyed=function(){},S.hasInterval=function(){return!!this._tickInterval},S.hasNextTick=function(){return!!this._tickTimer},S.setInterval=function(x){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,x),!0)},S.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},S.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},S.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},S.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},S.doTick=function(){},p}()},"./src/types/cmcd.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"CMCDVersion",function(){return R}),h.d(P,"CMCDObjectType",function(){return p}),h.d(P,"CMCDStreamingFormat",function(){return S}),h.d(P,"CMCDStreamType",function(){return I});var R=1,p;(function(x){x.MANIFEST="m",x.AUDIO="a",x.VIDEO="v",x.MUXED="av",x.INIT="i",x.CAPTION="c",x.TIMED_TEXT="tt",x.KEY="k",x.OTHER="o"})(p||(p={}));var S;(function(x){x.DASH="d",x.HLS="h",x.SMOOTH="s",x.OTHER="o"})(S||(S={}));var I;(function(x){x.VOD="v",x.LIVE="l"})(I||(I={}))},"./src/types/demuxer.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"MetadataSchema",function(){return R});var R;(function(p){p.audioId3="org.id3",p.dateRange="com.apple.quicktime.HLS",p.emsg="https://aomedia.org/emsg/ID3"})(R||(R={}))},"./src/types/level.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"HlsSkip",function(){return S}),h.d(P,"getSkipValue",function(){return I}),h.d(P,"HlsUrlParameters",function(){return x}),h.d(P,"Level",function(){return L});function R(A,y){for(var D=0;D<y.length;D++){var _=y[D];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(A,_.key,_)}}function p(A,y,D){return y&&R(A.prototype,y),D&&R(A,D),Object.defineProperty(A,"prototype",{writable:!1}),A}var S;(function(A){A.No="",A.Yes="YES",A.v2="v2"})(S||(S={}));function I(A,y){var D=A.canSkipUntil,_=A.canSkipDateRanges,T=A.endSN,g=y!==void 0?y-T:0;return D&&g<D?_?S.v2:S.Yes:S.No}var x=function(){function A(D,_,T){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=D,this.part=_,this.skip=T}var y=A.prototype;return y.addDirectives=function(_){var T=new self.URL(_);return this.msn!==void 0&&T.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&T.searchParams.set("_HLS_part",this.part.toString()),this.skip&&T.searchParams.set("_HLS_skip",this.skip),T.toString()},A}(),L=function(){function A(y){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[y.url],this.attrs=y.attrs,this.bitrate=y.bitrate,y.details&&(this.details=y.details),this.id=y.id||0,this.name=y.name,this.width=y.width||0,this.height=y.height||0,this.audioCodec=y.audioCodec,this.videoCodec=y.videoCodec,this.unknownCodecs=y.unknownCodecs,this.codecSet=[y.videoCodec,y.audioCodec].filter(function(D){return D}).join(",").replace(/\.[^.,]+/g,"")}return p(A,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(D){var _=D%this.url.length;this._urlId!==_&&(this.details=void 0,this._urlId=_)}}]),A}()},"./src/types/loader.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"PlaylistContextType",function(){return R}),h.d(P,"PlaylistLevelType",function(){return p});var R;(function(S){S.MANIFEST="manifest",S.LEVEL="level",S.AUDIO_TRACK="audioTrack",S.SUBTITLE_TRACK="subtitleTrack"})(R||(R={}));var p;(function(S){S.MAIN="main",S.AUDIO="audio",S.SUBTITLE="subtitle"})(p||(p={}))},"./src/types/transmuxer.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"ChunkMetadata",function(){return R});var R=function(I,x,L,A,y,D){A===void 0&&(A=0),y===void 0&&(y=-1),D===void 0&&(D=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=p(),this.buffering={audio:p(),video:p(),audiovideo:p()},this.level=I,this.sn=x,this.id=L,this.size=A,this.part=y,this.partial=D};function p(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"AttrList",function(){return S});var R=/^(\d+)x(\d+)$/,p=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,S=function(){function I(L){typeof L=="string"&&(L=I.parseAttrList(L));for(var A in L)L.hasOwnProperty(A)&&(this[A]=L[A])}var x=I.prototype;return x.decimalInteger=function(A){var y=parseInt(this[A],10);return y>Number.MAX_SAFE_INTEGER?1/0:y},x.hexadecimalInteger=function(A){if(this[A]){var y=(this[A]||"0x").slice(2);y=(y.length&1?"0":"")+y;for(var D=new Uint8Array(y.length/2),_=0;_<y.length/2;_++)D[_]=parseInt(y.slice(_*2,_*2+2),16);return D}else return null},x.hexadecimalIntegerAsNumber=function(A){var y=parseInt(this[A],16);return y>Number.MAX_SAFE_INTEGER?1/0:y},x.decimalFloatingPoint=function(A){return parseFloat(this[A])},x.optionalFloat=function(A,y){var D=this[A];return D?parseFloat(D):y},x.enumeratedString=function(A){return this[A]},x.bool=function(A){return this[A]==="YES"},x.decimalResolution=function(A){var y=R.exec(this[A]);if(y!==null)return{width:parseInt(y[1],10),height:parseInt(y[2],10)}},I.parseAttrList=function(A){var y,D={},_='"';for(p.lastIndex=0;(y=p.exec(A))!==null;){var T=y[2];T.indexOf(_)===0&&T.lastIndexOf(_)===T.length-1&&(T=T.slice(1,-1)),D[y[1]]=T}return D},I}()},"./src/utils/binary-search.ts":function(K,P,h){"use strict";h.r(P);var R={search:function(S,I){for(var x=0,L=S.length-1,A=null,y=null;x<=L;){A=(x+L)/2|0,y=S[A];var D=I(y);if(D>0)x=A+1;else if(D<0)L=A-1;else return y}return null}};P.default=R},"./src/utils/buffer-helper.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"BufferHelper",function(){return S});var R=h("./src/utils/logger.ts"),p={length:0,start:function(){return 0},end:function(){return 0}},S=function(){function I(){}return I.isBuffered=function(L,A){try{if(L){for(var y=I.getBuffered(L),D=0;D<y.length;D++)if(A>=y.start(D)&&A<=y.end(D))return!0}}catch{}return!1},I.bufferInfo=function(L,A,y){try{if(L){var D=I.getBuffered(L),_=[],T;for(T=0;T<D.length;T++)_.push({start:D.start(T),end:D.end(T)});return this.bufferedInfo(_,A,y)}}catch{}return{len:0,start:A,end:A,nextStart:void 0}},I.bufferedInfo=function(L,A,y){A=Math.max(0,A),L.sort(function(t,l){var d=t.start-l.start;return d||l.end-t.end});var D=[];if(y)for(var _=0;_<L.length;_++){var T=D.length;if(T){var g=D[T-1].end;L[_].start-g<y?L[_].end>g&&(D[T-1].end=L[_].end):D.push(L[_])}else D.push(L[_])}else D=L;for(var E=0,a,e=A,s=A,u=0;u<D.length;u++){var n=D[u].start,i=D[u].end;if(A+y>=n&&A<i)e=n,s=i,E=s-A;else if(A+y<n){a=n;break}}return{len:E,start:e||0,end:s||0,nextStart:a}},I.getBuffered=function(L){try{return L.buffered}catch(A){return R.logger.log("failed to get media.buffered",A),p}},I}()},"./src/utils/cea-608-parser.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"Row",function(){return s}),h.d(P,"CaptionScreen",function(){return u});var R=h("./src/utils/logger.ts"),p={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},S=function(c){var f=c;return p.hasOwnProperty(c)&&(f=p[c]),String.fromCharCode(f)},I=15,x=100,L={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},A={17:2,18:4,21:6,22:8,23:10,19:13,20:15},y={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},D={25:2,26:4,29:6,30:8,31:10,27:13,28:15},_=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],T;(function(r){r[r.ERROR=0]="ERROR",r[r.TEXT=1]="TEXT",r[r.WARNING=2]="WARNING",r[r.INFO=2]="INFO",r[r.DEBUG=3]="DEBUG",r[r.DATA=3]="DATA"})(T||(T={}));var g=function(){function r(){this.time=null,this.verboseLevel=T.ERROR}var c=r.prototype;return c.log=function(o,v){this.verboseLevel>=o&&R.logger.log(this.time+" ["+o+"] "+v)},r}(),E=function(c){for(var f=[],o=0;o<c.length;o++)f.push(c[o].toString(16));return f},a=function(){function r(f,o,v,m,O){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=f||"white",this.underline=o||!1,this.italics=v||!1,this.background=m||"black",this.flash=O||!1}var c=r.prototype;return c.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},c.setStyles=function(o){for(var v=["foreground","underline","italics","background","flash"],m=0;m<v.length;m++){var O=v[m];o.hasOwnProperty(O)&&(this[O]=o[O])}},c.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},c.equals=function(o){return this.foreground===o.foreground&&this.underline===o.underline&&this.italics===o.italics&&this.background===o.background&&this.flash===o.flash},c.copy=function(o){this.foreground=o.foreground,this.underline=o.underline,this.italics=o.italics,this.background=o.background,this.flash=o.flash},c.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},r}(),e=function(){function r(f,o,v,m,O,b){this.uchar=void 0,this.penState=void 0,this.uchar=f||" ",this.penState=new a(o,v,m,O,b)}var c=r.prototype;return c.reset=function(){this.uchar=" ",this.penState.reset()},c.setChar=function(o,v){this.uchar=o,this.penState.copy(v)},c.setPenState=function(o){this.penState.copy(o)},c.equals=function(o){return this.uchar===o.uchar&&this.penState.equals(o.penState)},c.copy=function(o){this.uchar=o.uchar,this.penState.copy(o.penState)},c.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},r}(),s=function(){function r(f){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var o=0;o<x;o++)this.chars.push(new e);this.logger=f,this.pos=0,this.currPenState=new a}var c=r.prototype;return c.equals=function(o){for(var v=!0,m=0;m<x;m++)if(!this.chars[m].equals(o.chars[m])){v=!1;break}return v},c.copy=function(o){for(var v=0;v<x;v++)this.chars[v].copy(o.chars[v])},c.isEmpty=function(){for(var o=!0,v=0;v<x;v++)if(!this.chars[v].isEmpty()){o=!1;break}return o},c.setCursor=function(o){this.pos!==o&&(this.pos=o),this.pos<0?(this.logger.log(T.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>x&&(this.logger.log(T.DEBUG,"Too large cursor position "+this.pos),this.pos=x)},c.moveCursor=function(o){var v=this.pos+o;if(o>1)for(var m=this.pos+1;m<v+1;m++)this.chars[m].setPenState(this.currPenState);this.setCursor(v)},c.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},c.insertChar=function(o){o>=144&&this.backSpace();var v=S(o);if(this.pos>=x){this.logger.log(T.ERROR,"Cannot insert "+o.toString(16)+" ("+v+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(v,this.currPenState),this.moveCursor(1)},c.clearFromPos=function(o){var v;for(v=o;v<x;v++)this.chars[v].reset()},c.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},c.clearToEndOfRow=function(){this.clearFromPos(this.pos)},c.getTextString=function(){for(var o=[],v=!0,m=0;m<x;m++){var O=this.chars[m].uchar;O!==" "&&(v=!1),o.push(O)}return v?"":o.join("")},c.setPenStyles=function(o){this.currPenState.setStyles(o);var v=this.chars[this.pos];v.setPenState(this.currPenState)},r}(),u=function(){function r(f){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var o=0;o<I;o++)this.rows.push(new s(f));this.logger=f,this.currRow=I-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var c=r.prototype;return c.reset=function(){for(var o=0;o<I;o++)this.rows[o].clear();this.currRow=I-1},c.equals=function(o){for(var v=!0,m=0;m<I;m++)if(!this.rows[m].equals(o.rows[m])){v=!1;break}return v},c.copy=function(o){for(var v=0;v<I;v++)this.rows[v].copy(o.rows[v])},c.isEmpty=function(){for(var o=!0,v=0;v<I;v++)if(!this.rows[v].isEmpty()){o=!1;break}return o},c.backSpace=function(){var o=this.rows[this.currRow];o.backSpace()},c.clearToEndOfRow=function(){var o=this.rows[this.currRow];o.clearToEndOfRow()},c.insertChar=function(o){var v=this.rows[this.currRow];v.insertChar(o)},c.setPen=function(o){var v=this.rows[this.currRow];v.setPenStyles(o)},c.moveCursor=function(o){var v=this.rows[this.currRow];v.moveCursor(o)},c.setCursor=function(o){this.logger.log(T.INFO,"setCursor: "+o);var v=this.rows[this.currRow];v.setCursor(o)},c.setPAC=function(o){this.logger.log(T.INFO,"pacData = "+JSON.stringify(o));var v=o.row-1;if(this.nrRollUpRows&&v<this.nrRollUpRows-1&&(v=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==v){for(var m=0;m<I;m++)this.rows[m].clear();var O=this.currRow+1-this.nrRollUpRows,b=this.lastOutputScreen;if(b){var M=b.rows[O].cueStartTime,F=this.logger.time;if(M&&F!==null&&M<F)for(var w=0;w<this.nrRollUpRows;w++)this.rows[v-this.nrRollUpRows+w+1].copy(b.rows[O+w])}}this.currRow=v;var C=this.rows[this.currRow];if(o.indent!==null){var U=o.indent,B=Math.max(U-1,0);C.setCursor(o.indent),o.color=C.chars[B].penState.foreground}var N={foreground:o.color,underline:o.underline,italics:o.italics,background:"black",flash:!1};this.setPen(N)},c.setBkgData=function(o){this.logger.log(T.INFO,"bkgData = "+JSON.stringify(o)),this.backSpace(),this.setPen(o),this.insertChar(32)},c.setRollUpRows=function(o){this.nrRollUpRows=o},c.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(T.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(T.TEXT,this.getDisplayText());var o=this.currRow+1-this.nrRollUpRows,v=this.rows.splice(o,1)[0];v.clear(),this.rows.splice(this.currRow,0,v),this.logger.log(T.INFO,"Rolling up")},c.getDisplayText=function(o){o=o||!1;for(var v=[],m="",O=-1,b=0;b<I;b++){var M=this.rows[b].getTextString();M&&(O=b+1,o?v.push("Row "+O+": '"+M+"'"):v.push(M.trim()))}return v.length>0&&(o?m="["+v.join(" | ")+"]":m=v.join(`
19
+ `)),m},c.getTextAndFormat=function(){return this.rows},r}(),n=function(){function r(f,o,v){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=f,this.outputFilter=o,this.mode=null,this.verbose=0,this.displayedMemory=new u(v),this.nonDisplayedMemory=new u(v),this.lastOutputScreen=new u(v),this.currRollUpRow=this.displayedMemory.rows[I-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=v}var c=r.prototype;return c.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[I-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},c.getHandler=function(){return this.outputFilter},c.setHandler=function(o){this.outputFilter=o},c.setPAC=function(o){this.writeScreen.setPAC(o)},c.setBkgData=function(o){this.writeScreen.setBkgData(o)},c.setMode=function(o){o!==this.mode&&(this.mode=o,this.logger.log(T.INFO,"MODE="+o),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=o)},c.insertChars=function(o){for(var v=0;v<o.length;v++)this.writeScreen.insertChar(o[v]);var m=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(T.INFO,m+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(T.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},c.ccRCL=function(){this.logger.log(T.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},c.ccBS=function(){this.logger.log(T.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},c.ccAOF=function(){},c.ccAON=function(){},c.ccDER=function(){this.logger.log(T.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},c.ccRU=function(o){this.logger.log(T.INFO,"RU("+o+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(o)},c.ccFON=function(){this.logger.log(T.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},c.ccRDC=function(){this.logger.log(T.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},c.ccTR=function(){this.logger.log(T.INFO,"TR"),this.setMode("MODE_TEXT")},c.ccRTD=function(){this.logger.log(T.INFO,"RTD"),this.setMode("MODE_TEXT")},c.ccEDM=function(){this.logger.log(T.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},c.ccCR=function(){this.logger.log(T.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},c.ccENM=function(){this.logger.log(T.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},c.ccEOC=function(){if(this.logger.log(T.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var o=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=o,this.writeScreen=this.nonDisplayedMemory,this.logger.log(T.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},c.ccTO=function(o){this.logger.log(T.INFO,"TO("+o+") - Tab Offset"),this.writeScreen.moveCursor(o)},c.ccMIDROW=function(o){var v={flash:!1};if(v.underline=o%2===1,v.italics=o>=46,v.italics)v.foreground="white";else{var m=Math.floor(o/2)-16,O=["white","green","blue","cyan","red","yellow","magenta"];v.foreground=O[m]}this.logger.log(T.INFO,"MIDROW: "+JSON.stringify(v)),this.writeScreen.setPen(v)},c.outputDataUpdate=function(o){o===void 0&&(o=!1);var v=this.logger.time;v!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=v:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,v,this.lastOutputScreen),o&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:v),this.lastOutputScreen.copy(this.displayedMemory))},c.cueSplitAtTime=function(o){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,o,this.displayedMemory),this.cueStartTime=o))},r}(),i=function(){function r(f,o,v){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var m=new g;this.channels=[null,new n(f,o,m),new n(f+1,v,m)],this.cmdHistory=d(),this.logger=m}var c=r.prototype;return c.getHandler=function(o){return this.channels[o].getHandler()},c.setHandler=function(o,v){this.channels[o].setHandler(v)},c.addData=function(o,v){var m,O,b,M=!1;this.logger.time=o;for(var F=0;F<v.length;F+=2)if(O=v[F]&127,b=v[F+1]&127,!(O===0&&b===0)){if(this.logger.log(T.DATA,"["+E([v[F],v[F+1]])+"] -> ("+E([O,b])+")"),m=this.parseCmd(O,b),m||(m=this.parseMidrow(O,b)),m||(m=this.parsePAC(O,b)),m||(m=this.parseBackgroundAttributes(O,b)),!m&&(M=this.parseChars(O,b),M)){var w=this.currentChannel;if(w&&w>0){var C=this.channels[w];C.insertChars(M)}else this.logger.log(T.WARNING,"No channel found yet. TEXT-MODE?")}!m&&!M&&this.logger.log(T.WARNING,"Couldn't parse cleaned data "+E([O,b])+" orig: "+E([v[F],v[F+1]]))}},c.parseCmd=function(o,v){var m=this.cmdHistory,O=(o===20||o===28||o===21||o===29)&&v>=32&&v<=47,b=(o===23||o===31)&&v>=33&&v<=35;if(!(O||b))return!1;if(l(o,v,m))return t(null,null,m),this.logger.log(T.DEBUG,"Repeated command ("+E([o,v])+") is dropped"),!0;var M=o===20||o===21||o===23?1:2,F=this.channels[M];return o===20||o===21||o===28||o===29?v===32?F.ccRCL():v===33?F.ccBS():v===34?F.ccAOF():v===35?F.ccAON():v===36?F.ccDER():v===37?F.ccRU(2):v===38?F.ccRU(3):v===39?F.ccRU(4):v===40?F.ccFON():v===41?F.ccRDC():v===42?F.ccTR():v===43?F.ccRTD():v===44?F.ccEDM():v===45?F.ccCR():v===46?F.ccENM():v===47&&F.ccEOC():F.ccTO(v-32),t(o,v,m),this.currentChannel=M,!0},c.parseMidrow=function(o,v){var m=0;if((o===17||o===25)&&v>=32&&v<=47){if(o===17?m=1:m=2,m!==this.currentChannel)return this.logger.log(T.ERROR,"Mismatch channel in midrow parsing"),!1;var O=this.channels[m];return O?(O.ccMIDROW(v),this.logger.log(T.DEBUG,"MIDROW ("+E([o,v])+")"),!0):!1}return!1},c.parsePAC=function(o,v){var m,O=this.cmdHistory,b=(o>=17&&o<=23||o>=25&&o<=31)&&v>=64&&v<=127,M=(o===16||o===24)&&v>=64&&v<=95;if(!(b||M))return!1;if(l(o,v,O))return t(null,null,O),!0;var F=o<=23?1:2;v>=64&&v<=95?m=F===1?L[o]:y[o]:m=F===1?A[o]:D[o];var w=this.channels[F];return w?(w.setPAC(this.interpretPAC(m,v)),t(o,v,O),this.currentChannel=F,!0):!1},c.interpretPAC=function(o,v){var m,O={color:null,italics:!1,indent:null,underline:!1,row:o};return v>95?m=v-96:m=v-64,O.underline=(m&1)===1,m<=13?O.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(m/2)]:m<=15?(O.italics=!0,O.color="white"):O.indent=Math.floor((m-16)/2)*4,O},c.parseChars=function(o,v){var m,O=null,b=null;if(o>=25?(m=2,b=o-8):(m=1,b=o),b>=17&&b<=19){var M;b===17?M=v+80:b===18?M=v+112:M=v+144,this.logger.log(T.INFO,"Special char '"+S(M)+"' in channel "+m),O=[M]}else o>=32&&o<=127&&(O=v===0?[o]:[o,v]);if(O){var F=E(O);this.logger.log(T.DEBUG,"Char codes = "+F.join(",")),t(o,v,this.cmdHistory)}return O},c.parseBackgroundAttributes=function(o,v){var m=(o===16||o===24)&&v>=32&&v<=47,O=(o===23||o===31)&&v>=45&&v<=47;if(!(m||O))return!1;var b,M={};o===16||o===24?(b=Math.floor((v-32)/2),M.background=_[b],v%2===1&&(M.background=M.background+"_semi")):v===45?M.background="transparent":(M.foreground="black",v===47&&(M.underline=!0));var F=o<=23?1:2,w=this.channels[F];return w.setBkgData(M),t(o,v,this.cmdHistory),!0},c.reset=function(){for(var o=0;o<Object.keys(this.channels).length;o++){var v=this.channels[o];v&&v.reset()}this.cmdHistory=d()},c.cueSplitAtTime=function(o){for(var v=0;v<this.channels.length;v++){var m=this.channels[v];m&&m.cueSplitAtTime(o)}},r}();function t(r,c,f){f.a=r,f.b=c}function l(r,c,f){return f.a===r&&f.b===c}function d(){return{a:null,b:null}}P.default=i},"./src/utils/codecs.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"isCodecType",function(){return p}),h.d(P,"isCodecSupportedInMp4",function(){return S});var R={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function p(I,x){var L=R[x];return!!L&&L[I.slice(0,4)]===!0}function S(I,x){return MediaSource.isTypeSupported((x||"video")+'/mp4;codecs="'+I+'"')}},"./src/utils/cues.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/utils/vttparser.ts"),p=h("./src/utils/webvtt-parser.ts"),S=h("./src/utils/texttrack-utils.ts"),I=/\s/,x={newCue:function(A,y,D,_){for(var T=[],g,E,a,e,s,u=self.VTTCue||self.TextTrackCue,n=0;n<_.rows.length;n++)if(g=_.rows[n],a=!0,e=0,s="",!g.isEmpty()){for(var i=0;i<g.chars.length;i++)I.test(g.chars[i].uchar)&&a?e++:(s+=g.chars[i].uchar,a=!1);g.cueStartTime=y,y===D&&(D+=1e-4),e>=16?e--:e++;var t=Object(R.fixLineBreaks)(s.trim()),l=Object(p.generateCueId)(y,D,t);(!A||!A.cues||!A.cues.getCueById(l))&&(E=new u(y,D,t),E.id=l,E.line=n+1,E.align="left",E.position=10+Math.min(80,Math.floor(e*8/32)*10),T.push(E))}return A&&T.length&&(T.sort(function(d,r){return d.line==="auto"||r.line==="auto"?0:d.line>8&&r.line>8?r.line-d.line:d.line-r.line}),T.forEach(function(d){return Object(S.addCueToTrack)(A,d)})),T}};P.default=x},"./src/utils/discontinuities.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"findFirstFragWithCC",function(){return I}),h.d(P,"shouldAlignOnDiscontinuities",function(){return x}),h.d(P,"findDiscontinuousReferenceFrag",function(){return L}),h.d(P,"adjustSlidingStart",function(){return y}),h.d(P,"alignStream",function(){return D}),h.d(P,"alignPDT",function(){return T}),h.d(P,"alignFragmentByPDTDelta",function(){return g}),h.d(P,"alignMediaPlaylistByPDT",function(){return E});var R=h("./src/polyfills/number.ts"),p=h("./src/utils/logger.ts"),S=h("./src/controller/level-helper.ts");function I(a,e){for(var s=null,u=0,n=a.length;u<n;u++){var i=a[u];if(i&&i.cc===e){s=i;break}}return s}function x(a,e,s){return!!(e.details&&(s.endCC>s.startCC||a&&a.cc<s.startCC))}function L(a,e){var s=a.fragments,u=e.fragments;if(!u.length||!s.length){p.logger.log("No fragments to align");return}var n=I(s,u[0].cc);if(!n||n&&!n.startPTS){p.logger.log("No frag in previous level to align on");return}return n}function A(a,e){if(a){var s=a.start+e;a.start=a.startPTS=s,a.endPTS=s+a.duration}}function y(a,e){for(var s=e.fragments,u=0,n=s.length;u<n;u++)A(s[u],a);e.fragmentHint&&A(e.fragmentHint,a),e.alignedSliding=!0}function D(a,e,s){!e||(_(a,s,e),!s.alignedSliding&&e.details&&T(s,e.details),!s.alignedSliding&&e.details&&!s.skippedSegments&&Object(S.adjustSliding)(e.details,s))}function _(a,e,s){if(x(a,s,e)){var u=L(s.details,e);u&&Object(R.isFiniteNumber)(u.start)&&(p.logger.log("Adjusting PTS using last level due to CC increase within current level "+e.url),y(u.start,e))}}function T(a,e){if(!(!e.fragments.length||!a.hasProgramDateTime||!e.hasProgramDateTime)){var s=e.fragments[0].programDateTime,u=a.fragments[0].programDateTime,n=(u-s)/1e3+e.fragments[0].start;n&&Object(R.isFiniteNumber)(n)&&(p.logger.log("Adjusting PTS using programDateTime delta "+(u-s)+"ms, sliding:"+n.toFixed(3)+" "+a.url+" "),y(n,a))}}function g(a,e){var s=a.programDateTime;if(!!s){var u=(s-e)/1e3;a.start=a.startPTS=u,a.endPTS=u+a.duration}}function E(a,e){if(!(!e.fragments.length||!a.hasProgramDateTime||!e.hasProgramDateTime)){var s=e.fragments[0].programDateTime,u=e.fragments[0].start,n=s-u*1e3;a.fragments.forEach(function(i){g(i,n)}),a.fragmentHint&&g(a.fragmentHint,n),a.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/utils/ewma.ts"),p=function(){function S(x,L,A){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=A,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new R.default(x),this.fast_=new R.default(L)}var I=S.prototype;return I.update=function(L,A){var y=this.slow_,D=this.fast_;this.slow_.halfLife!==L&&(this.slow_=new R.default(L,y.getEstimate(),y.getTotalWeight())),this.fast_.halfLife!==A&&(this.fast_=new R.default(A,D.getEstimate(),D.getTotalWeight()))},I.sample=function(L,A){L=Math.max(L,this.minDelayMs_);var y=8*A,D=L/1e3,_=y/D;this.fast_.sample(D,_),this.slow_.sample(D,_)},I.canEstimate=function(){var L=this.fast_;return L&&L.getTotalWeight()>=this.minWeight_},I.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},I.destroy=function(){},S}();P.default=p},"./src/utils/ewma.ts":function(K,P,h){"use strict";h.r(P);var R=function(){function p(I,x,L){x===void 0&&(x=0),L===void 0&&(L=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=I,this.alpha_=I?Math.exp(Math.log(.5)/I):0,this.estimate_=x,this.totalWeight_=L}var S=p.prototype;return S.sample=function(x,L){var A=Math.pow(this.alpha_,x);this.estimate_=L*(1-A)+A*this.estimate_,this.totalWeight_+=x},S.getTotalWeight=function(){return this.totalWeight_},S.getEstimate=function(){if(this.alpha_){var x=1-Math.pow(this.alpha_,this.totalWeight_);if(x)return this.estimate_/x}return this.estimate_},p}();P.default=R},"./src/utils/fetch-loader.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"fetchSupported",function(){return g});var R=h("./src/polyfills/number.ts"),p=h("./src/loader/load-stats.ts"),S=h("./src/demux/chunk-cache.ts");function I(u,n){u.prototype=Object.create(n.prototype),u.prototype.constructor=u,D(u,n)}function x(u){var n=typeof Map=="function"?new Map:void 0;return x=function(t){if(t===null||!y(t))return t;if(typeof t!="function")throw new TypeError("Super expression must either be null or a function");if(typeof n!="undefined"){if(n.has(t))return n.get(t);n.set(t,l)}function l(){return L(t,arguments,_(this).constructor)}return l.prototype=Object.create(t.prototype,{constructor:{value:l,enumerable:!1,writable:!0,configurable:!0}}),D(l,t)},x(u)}function L(u,n,i){return A()?L=Reflect.construct.bind():L=function(l,d,r){var c=[null];c.push.apply(c,d);var f=Function.bind.apply(l,c),o=new f;return r&&D(o,r.prototype),o},L.apply(null,arguments)}function A(){if(typeof Reflect=="undefined"||!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 y(u){return Function.toString.call(u).indexOf("[native code]")!==-1}function D(u,n){return D=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,l){return t.__proto__=l,t},D(u,n)}function _(u){return _=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},_(u)}function T(){return T=Object.assign?Object.assign.bind():function(u){for(var n=1;n<arguments.length;n++){var i=arguments[n];for(var t in i)Object.prototype.hasOwnProperty.call(i,t)&&(u[t]=i[t])}return u},T.apply(this,arguments)}function g(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var E=function(){function u(i){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=i.fetchSetup||e,this.controller=new self.AbortController,this.stats=new p.LoadStats}var n=u.prototype;return n.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},n.abortInternal=function(){var t=this.response;(!t||!t.ok)&&(this.stats.aborted=!0,this.controller.abort())},n.abort=function(){var t;this.abortInternal(),(t=this.callbacks)!==null&&t!==void 0&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},n.load=function(t,l,d){var r=this,c=this.stats;if(c.loading.start)throw new Error("Loader can only be used once.");c.loading.start=self.performance.now();var f=a(t,this.controller.signal),o=d.onProgress,v=t.responseType==="arraybuffer",m=v?"byteLength":"length";this.context=t,this.config=l,this.callbacks=d,this.request=this.fetchSetup(t,f),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){r.abortInternal(),d.onTimeout(c,t,r.response)},l.timeout),self.fetch(this.request).then(function(O){if(r.response=r.loader=O,!O.ok){var b=O.status,M=O.statusText;throw new s(M||"fetch, bad network response",b,O)}return c.loading.first=Math.max(self.performance.now(),c.loading.start),c.total=parseInt(O.headers.get("Content-Length")||"0"),o&&Object(R.isFiniteNumber)(l.highWaterMark)?r.loadProgressively(O,c,t,l.highWaterMark,o):v?O.arrayBuffer():O.text()}).then(function(O){var b=r.response;self.clearTimeout(r.requestTimeout),c.loading.end=Math.max(self.performance.now(),c.loading.first),c.loaded=c.total=O[m];var M={url:b.url,data:O};o&&!Object(R.isFiniteNumber)(l.highWaterMark)&&o(c,t,O,b),d.onSuccess(M,c,t,b)}).catch(function(O){if(self.clearTimeout(r.requestTimeout),!c.aborted){var b=O&&O.code||0,M=O?O.message:null;d.onError({code:b,text:M},t,O?O.details:null)}})},n.getCacheAge=function(){var t=null;if(this.response){var l=this.response.headers.get("age");t=l?parseFloat(l):null}return t},n.loadProgressively=function(t,l,d,r,c){r===void 0&&(r=0);var f=new S.default,o=t.body.getReader(),v=function m(){return o.read().then(function(O){if(O.done)return f.dataLength&&c(l,d,f.flush(),t),Promise.resolve(new ArrayBuffer(0));var b=O.value,M=b.length;return l.loaded+=M,M<r||f.dataLength?(f.push(b),f.dataLength>=r&&c(l,d,f.flush(),t)):c(l,d,b,t),m()}).catch(function(){return Promise.reject()})};return v()},u}();function a(u,n){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:n,headers:new self.Headers(T({},u.headers))};return u.rangeEnd&&i.headers.set("Range","bytes="+u.rangeStart+"-"+String(u.rangeEnd-1)),i}function e(u,n){return new self.Request(u.url,n)}var s=function(u){I(n,u);function n(i,t,l){var d;return d=u.call(this,i)||this,d.code=void 0,d.details=void 0,d.code=t,d.details=l,d}return n}(x(Error));P.default=E},"./src/utils/imsc1-ttml-parser.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"IMSC1_CODEC",function(){return y}),h.d(P,"parseIMSC1",function(){return g});var R=h("./src/utils/mp4-tools.ts"),p=h("./src/utils/vttparser.ts"),S=h("./src/utils/vttcue.ts"),I=h("./src/demux/id3.ts"),x=h("./src/utils/timescale-conversion.ts"),L=h("./src/utils/webvtt-parser.ts");function A(){return A=Object.assign?Object.assign.bind():function(r){for(var c=1;c<arguments.length;c++){var f=arguments[c];for(var o in f)Object.prototype.hasOwnProperty.call(f,o)&&(r[o]=f[o])}return r},A.apply(this,arguments)}var y="stpp.ttml.im1t",D=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,_=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,T={left:"start",center:"center",right:"end",start:"start",end:"end"};function g(r,c,f,o,v){var m=Object(R.findBox)(new Uint8Array(r),["mdat"]);if(m.length===0){v(new Error("Could not parse IMSC1 mdat"));return}var O=m.map(function(M){return Object(I.utf8ArrayToStr)(M)}),b=Object(x.toTimescaleFromScale)(c,1,f);try{O.forEach(function(M){return o(E(M,b))})}catch(M){v(M)}}function E(r,c){var f=new DOMParser,o=f.parseFromString(r,"text/xml"),v=o.getElementsByTagName("tt")[0];if(!v)throw new Error("Invalid ttml");var m={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},O=Object.keys(m).reduce(function(C,U){return C[U]=v.getAttribute("ttp:"+U)||m[U],C},{}),b=v.getAttribute("xml:space")!=="preserve",M=e(a(v,"styling","style")),F=e(a(v,"layout","region")),w=a(v,"body","[begin]");return[].map.call(w,function(C){var U=s(C,b);if(!U||!C.hasAttribute("begin"))return null;var B=t(C.getAttribute("begin"),O),N=t(C.getAttribute("dur"),O),k=t(C.getAttribute("end"),O);if(B===null)throw i(C);if(k===null){if(N===null)throw i(C);k=B+N}var j=new S.default(B-c,k-c,U);j.id=Object(L.generateCueId)(j.startTime,j.endTime,j.text);var H=F[C.getAttribute("region")],V=M[C.getAttribute("style")];j.position=10,j.size=80;var Y=u(H,V,M),Q=Y.textAlign;if(Q){var J=T[Q];J&&(j.lineAlign=J),j.align=Q}return A(j,Y),j}).filter(function(C){return C!==null})}function a(r,c,f){var o=r.getElementsByTagName(c)[0];return o?[].slice.call(o.querySelectorAll(f)):[]}function e(r){return r.reduce(function(c,f){var o=f.getAttribute("xml:id");return o&&(c[o]=f),c},{})}function s(r,c){return[].slice.call(r.childNodes).reduce(function(f,o,v){var m;return o.nodeName==="br"&&v?f+`
20
+ `:(m=o.childNodes)!==null&&m!==void 0&&m.length?s(o,c):c?f+o.textContent.trim().replace(/\s+/g," "):f+o.textContent},"")}function u(r,c,f){var o="http://www.w3.org/ns/ttml#styling",v=null,m=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],O=r!=null&&r.hasAttribute("style")?r.getAttribute("style"):null;return O&&f.hasOwnProperty(O)&&(v=f[O]),m.reduce(function(b,M){var F=n(c,o,M)||n(r,o,M)||n(v,o,M);return F&&(b[M]=F),b},{})}function n(r,c,f){return r&&r.hasAttributeNS(c,f)?r.getAttributeNS(c,f):null}function i(r){return new Error("Could not parse ttml timestamp "+r)}function t(r,c){if(!r)return null;var f=Object(p.parseTimeStamp)(r);return f===null&&(D.test(r)?f=l(r,c):_.test(r)&&(f=d(r,c))),f}function l(r,c){var f=D.exec(r),o=(f[4]|0)+(f[5]|0)/c.subFrameRate;return(f[1]|0)*3600+(f[2]|0)*60+(f[3]|0)+o/c.frameRate}function d(r,c){var f=_.exec(r),o=Number(f[1]),v=f[2];switch(v){case"h":return o*3600;case"m":return o*60;case"ms":return o*1e3;case"f":return o/c.frameRate;case"t":return o/c.tickRate}return o}},"./src/utils/logger.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"enableLogs",function(){return L}),h.d(P,"logger",function(){return A});var R=function(){},p={trace:R,debug:R,log:R,warn:R,info:R,error:R},S=p;function I(y){var D=self.console[y];return D?D.bind(self.console,"["+y+"] >"):R}function x(y){for(var D=arguments.length,_=new Array(D>1?D-1:0),T=1;T<D;T++)_[T-1]=arguments[T];_.forEach(function(g){S[g]=y[g]?y[g].bind(y):I(g)})}function L(y){if(self.console&&y===!0||typeof y=="object"){x(y,"debug","log","info","warn","error");try{S.log()}catch{S=p}}else S=p}var A=S},"./src/utils/mediakeys-helper.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"KeySystems",function(){return R}),h.d(P,"requestMediaKeySystemAccess",function(){return p});var R;(function(S){S.WIDEVINE="com.widevine.alpha",S.PLAYREADY="com.microsoft.playready"})(R||(R={}));var p=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"getMediaSource",function(){return R});function R(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"RemuxerTrackIdConfig",function(){return L}),h.d(P,"bin2str",function(){return A}),h.d(P,"readUint16",function(){return y}),h.d(P,"readUint32",function(){return D}),h.d(P,"readSint32",function(){return _}),h.d(P,"writeUint32",function(){return T}),h.d(P,"findBox",function(){return g}),h.d(P,"parseSegmentIndex",function(){return E}),h.d(P,"parseInitSegment",function(){return a}),h.d(P,"getStartDTS",function(){return e}),h.d(P,"getDuration",function(){return s}),h.d(P,"computeRawDurationFromSamples",function(){return u}),h.d(P,"offsetStartDTS",function(){return n}),h.d(P,"segmentValidRange",function(){return i}),h.d(P,"appendUint8Array",function(){return t}),h.d(P,"parseSamples",function(){return l}),h.d(P,"parseSEIMessageFromNALu",function(){return c}),h.d(P,"parseEmsg",function(){return o});var R=h("./src/utils/typed-array.ts"),p=h("./src/loader/fragment.ts"),S=h("./src/demux/id3.ts"),I=Math.pow(2,32)-1,x=[].push,L={video:1,audio:2,id3:3,text:4};function A(v){return String.fromCharCode.apply(null,v)}function y(v,m){var O=v[m]<<8|v[m+1];return O<0?65536+O:O}function D(v,m){var O=_(v,m);return O<0?4294967296+O:O}function _(v,m){return v[m]<<24|v[m+1]<<16|v[m+2]<<8|v[m+3]}function T(v,m,O){v[m]=O>>24,v[m+1]=O>>16&255,v[m+2]=O>>8&255,v[m+3]=O&255}function g(v,m){var O=[];if(!m.length)return O;for(var b=v.byteLength,M=0;M<b;){var F=D(v,M),w=A(v.subarray(M+4,M+8)),C=F>1?M+F:b;if(w===m[0])if(m.length===1)O.push(v.subarray(M+8,C));else{var U=g(v.subarray(M+8,C),m.slice(1));U.length&&x.apply(O,U)}M=C}return O}function E(v){var m=[],O=v[0],b=8,M=D(v,b);b+=4;var F=0,w=0;O===0?b+=8:b+=16,b+=2;var C=v.length+w,U=y(v,b);b+=2;for(var B=0;B<U;B++){var N=b,k=D(v,N);N+=4;var j=k&2147483647,H=(k&2147483648)>>>31;if(H===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var V=D(v,N);N+=4,m.push({referenceSize:j,subsegmentDuration:V,info:{duration:V/M,start:C,end:C+j-1}}),C+=j,N+=4,b=N}return{earliestPresentationTime:F,timescale:M,version:O,referencesCount:U,references:m}}function a(v){for(var m=[],O=g(v,["moov","trak"]),b=0;b<O.length;b++){var M=O[b],F=g(M,["tkhd"])[0];if(F){var w=F[0],C=w===0?12:20,U=D(F,C),B=g(M,["mdia","mdhd"])[0];if(B){w=B[0],C=w===0?12:20;var N=D(B,C),k=g(M,["mdia","hdlr"])[0];if(k){var j=A(k.subarray(8,12)),H={soun:p.ElementaryStreamTypes.AUDIO,vide:p.ElementaryStreamTypes.VIDEO}[j];if(H){var V=g(M,["mdia","minf","stbl","stsd"])[0],Y=void 0;V&&(Y=A(V.subarray(12,16))),m[U]={timescale:N,type:H},m[H]={timescale:N,id:U,codec:Y}}}}}}var Q=g(v,["moov","mvex","trex"]);return Q.forEach(function(J){var z=D(J,4),q=m[z];q&&(q.default={duration:D(J,12),flags:D(J,20)})}),m}function e(v,m){return g(m,["moof","traf"]).reduce(function(O,b){var M=g(b,["tfdt"])[0],F=M[0],w=g(b,["tfhd"]).reduce(function(C,U){var B=D(U,4),N=v[B];if(N){var k=D(M,4);F===1&&(k*=Math.pow(2,32),k+=D(M,8));var j=N.timescale||9e4,H=k/j;if(isFinite(H)&&(C===null||H<C))return H}return C},null);return w!==null&&isFinite(w)&&(O===null||w<O)?w:O},null)||0}function s(v,m){for(var O=0,b=0,M=0,F=g(v,["moof","traf"]),w=0;w<F.length;w++){var C=F[w],U=g(C,["tfhd"])[0],B=D(U,4),N=m[B];if(!!N){var k=N.default,j=D(U,0)|(k==null?void 0:k.flags),H=k==null?void 0:k.duration;j&8&&(j&2?H=D(U,12):H=D(U,8));for(var V=N.timescale||9e4,Y=g(C,["trun"]),Q=0;Q<Y.length;Q++){if(O=u(Y[Q]),!O&&H){var J=D(Y[Q],4);O=H*J}N.type===p.ElementaryStreamTypes.VIDEO?b+=O/V:N.type===p.ElementaryStreamTypes.AUDIO&&(M+=O/V)}}}if(b===0&&M===0){for(var z=0,q=g(v,["sidx"]),re=0;re<q.length;re++){var X=E(q[re]);X!=null&&X.references&&(z+=X.references.reduce(function(le,ne){return le+ne.info.duration||0},0))}return z}return b||M}function u(v){var m=D(v,0),O=8;m&1&&(O+=4),m&4&&(O+=4);for(var b=0,M=D(v,4),F=0;F<M;F++){if(m&256){var w=D(v,O);b+=w,O+=4}m&512&&(O+=4),m&1024&&(O+=4),m&2048&&(O+=4)}return b}function n(v,m,O){g(m,["moof","traf"]).forEach(function(b){g(b,["tfhd"]).forEach(function(M){var F=D(M,4),w=v[F];if(!!w){var C=w.timescale||9e4;g(b,["tfdt"]).forEach(function(U){var B=U[0],N=D(U,4);if(B===0)N-=O*C,N=Math.max(N,0),T(U,4,N);else{N*=Math.pow(2,32),N+=D(U,8),N-=O*C,N=Math.max(N,0);var k=Math.floor(N/(I+1)),j=Math.floor(N%(I+1));T(U,4,k),T(U,8,j)}})}})})}function i(v){var m={valid:null,remainder:null},O=g(v,["moof"]);if(O){if(O.length<2)return m.remainder=v,m}else return m;var b=O[O.length-1];return m.valid=Object(R.sliceUint8)(v,0,b.byteOffset-8),m.remainder=Object(R.sliceUint8)(v,b.byteOffset-8),m}function t(v,m){var O=new Uint8Array(v.length+m.length);return O.set(v),O.set(m,v.length),O}function l(v,m){var O=[],b=m.samples,M=m.timescale,F=m.id,w=!1,C=g(b,["moof"]);return C.map(function(U){var B=U.byteOffset-8,N=g(U,["traf"]);N.map(function(k){var j=g(k,["tfdt"]).map(function(H){var V=H[0],Y=D(H,4);return V===1&&(Y*=Math.pow(2,32),Y+=D(H,8)),Y/M})[0];return j!==void 0&&(v=j),g(k,["tfhd"]).map(function(H){var V=D(H,4),Y=D(H,0)&16777215,Q=(Y&1)!==0,J=(Y&2)!==0,z=(Y&8)!==0,q=0,re=(Y&16)!==0,X=0,le=(Y&32)!==0,ne=8;V===F&&(Q&&(ne+=8),J&&(ne+=4),z&&(q=D(H,ne),ne+=4),re&&(X=D(H,ne),ne+=4),le&&(ne+=4),m.type==="video"&&(w=d(m.codec)),g(k,["trun"]).map(function(te){var ee=te[0],$=D(te,0)&16777215,Z=($&1)!==0,ue=0,he=($&4)!==0,se=($&256)!==0,me=0,pe=($&512)!==0,Ee=0,ae=($&1024)!==0,fe=($&2048)!==0,ge=0,ve=D(te,4),Te=8;Z&&(ue=D(te,Te),Te+=4),he&&(Te+=4);for(var _e=ue+B,Oe=0;Oe<ve;Oe++){if(se?(me=D(te,Te),Te+=4):me=q,pe?(Ee=D(te,Te),Te+=4):Ee=X,ae&&(Te+=4),fe&&(ee===0?ge=D(te,Te):ge=_(te,Te),Te+=4),m.type===p.ElementaryStreamTypes.VIDEO)for(var xe=0;xe<Ee;){var ye=D(b,_e);_e+=4;var W=b[_e]&31;if(r(w,W)){var G=b.subarray(_e,_e+ye);c(G,v+ge/M,O)}_e+=ye,xe+=ye+4}v+=me/M}}))})})}),O}function d(v){if(!v)return!1;var m=v.indexOf("."),O=m<0?v:v.substring(0,m);return O==="hvc1"||O==="hev1"||O==="dvh1"||O==="dvhe"}function r(v,m){return v?m===39||m===40:m===6}function c(v,m,O){var b=f(v),M=0;M++;for(var F=0,w=0,C=!1,U=0;M<b.length;){F=0;do{if(M>=b.length)break;U=b[M++],F+=U}while(U===255);w=0;do{if(M>=b.length)break;U=b[M++],w+=U}while(U===255);var B=b.length-M;if(!C&&F===4&&M<b.length){C=!0;var N=b[M++];if(N===181){var k=y(b,M);if(M+=2,k===49){var j=D(b,M);if(M+=4,j===1195456820){var H=b[M++];if(H===3){var V=b[M++],Y=31&V,Q=64&V,J=Q?2+Y*3:0,z=new Uint8Array(J);if(Q){z[0]=V;for(var q=1;q<J;q++)z[q]=b[M++]}O.push({type:H,payloadType:F,pts:m,bytes:z})}}}}}else if(F===5&&w<B){if(C=!0,w>16){for(var re=[],X=0;X<16;X++){var le=b[M++].toString(16);re.push(le.length==1?"0"+le:le),(X===3||X===5||X===7||X===9)&&re.push("-")}for(var ne=w-16,te=new Uint8Array(ne),ee=0;ee<ne;ee++)te[ee]=b[M++];O.push({payloadType:F,pts:m,uuid:re.join(""),userData:Object(S.utf8ArrayToStr)(te),userDataBytes:te})}}else if(w<B)M+=w;else if(w>B)break}}function f(v){for(var m=v.byteLength,O=[],b=1;b<m-2;)v[b]===0&&v[b+1]===0&&v[b+2]===3?(O.push(b+2),b+=2):b++;if(O.length===0)return v;var M=m-O.length,F=new Uint8Array(M),w=0;for(b=0;b<M;w++,b++)w===O[0]&&(w++,O.shift()),F[b]=v[w];return F}function o(v){var m=v[0],O="",b="",M=0,F=0,w=0,C=0,U=0,B=0;if(m===0){for(;A(v.subarray(B,B+1))!=="\0";)O+=A(v.subarray(B,B+1)),B+=1;for(O+=A(v.subarray(B,B+1)),B+=1;A(v.subarray(B,B+1))!=="\0";)b+=A(v.subarray(B,B+1)),B+=1;b+=A(v.subarray(B,B+1)),B+=1,M=D(v,12),F=D(v,16),C=D(v,20),U=D(v,24),B=28}else if(m===1){B+=4,M=D(v,B),B+=4;var N=D(v,B);B+=4;var k=D(v,B);for(B+=4,w=Math.pow(2,32)*N+k,Number.isSafeInteger(w)||(w=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),C=D(v,B),B+=4,U=D(v,B),B+=4;A(v.subarray(B,B+1))!=="\0";)O+=A(v.subarray(B,B+1)),B+=1;for(O+=A(v.subarray(B,B+1)),B+=1;A(v.subarray(B,B+1))!=="\0";)b+=A(v.subarray(B,B+1)),B+=1;b+=A(v.subarray(B,B+1)),B+=1}var j=v.subarray(B,v.byteLength);return{schemeIdUri:O,value:b,timeScale:M,presentationTime:w,presentationTimeDelta:F,eventDuration:C,id:U,payload:j}}},"./src/utils/output-filter.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return R});var R=function(){function p(I,x){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=I,this.trackName=x}var S=p.prototype;return S.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},S.newCue=function(x,L,A){(this.startTime===null||this.startTime>x)&&(this.startTime=x),this.endTime=L,this.screen=A,this.timelineController.createCaptionsTrack(this.trackName)},S.reset=function(){this.cueRanges=[],this.startTime=null},p}()},"./src/utils/texttrack-utils.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"sendAddTrackEvent",function(){return p}),h.d(P,"addCueToTrack",function(){return S}),h.d(P,"clearCurrentCues",function(){return I}),h.d(P,"removeCuesInRange",function(){return x}),h.d(P,"getCuesInRange",function(){return A});var R=h("./src/utils/logger.ts");function p(y,D){var _;try{_=new Event("addtrack")}catch{_=document.createEvent("Event"),_.initEvent("addtrack",!1,!1)}_.track=y,D.dispatchEvent(_)}function S(y,D){var _=y.mode;if(_==="disabled"&&(y.mode="hidden"),y.cues&&!y.cues.getCueById(D.id))try{if(y.addCue(D),!y.cues.getCueById(D.id))throw new Error("addCue is failed for: "+D)}catch(g){R.logger.debug("[texttrack-utils]: "+g);var T=new self.TextTrackCue(D.startTime,D.endTime,D.text);T.id=D.id,y.addCue(T)}_==="disabled"&&(y.mode=_)}function I(y){var D=y.mode;if(D==="disabled"&&(y.mode="hidden"),y.cues)for(var _=y.cues.length;_--;)y.removeCue(y.cues[_]);D==="disabled"&&(y.mode=D)}function x(y,D,_,T){var g=y.mode;if(g==="disabled"&&(y.mode="hidden"),y.cues&&y.cues.length>0)for(var E=A(y.cues,D,_),a=0;a<E.length;a++)(!T||T(E[a]))&&y.removeCue(E[a]);g==="disabled"&&(y.mode=g)}function L(y,D){if(D<y[0].startTime)return 0;var _=y.length-1;if(D>y[_].endTime)return-1;for(var T=0,g=_;T<=g;){var E=Math.floor((g+T)/2);if(D<y[E].startTime)g=E-1;else if(D>y[E].startTime&&T<_)T=E+1;else return E}return y[T].startTime-D<D-y[g].startTime?T:g}function A(y,D,_){var T=[],g=L(y,D);if(g>-1)for(var E=g,a=y.length;E<a;E++){var e=y[E];if(e.startTime>=D&&e.endTime<=_)T.push(e);else if(e.startTime>_)return T}return T}},"./src/utils/time-ranges.ts":function(K,P,h){"use strict";h.r(P);var R={toString:function(S){for(var I="",x=S.length,L=0;L<x;L++)I+="["+S.start(L).toFixed(3)+","+S.end(L).toFixed(3)+"]";return I}};P.default=R},"./src/utils/timescale-conversion.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"toTimescaleFromBase",function(){return p}),h.d(P,"toTimescaleFromScale",function(){return S}),h.d(P,"toMsFromMpegTsClock",function(){return I}),h.d(P,"toMpegTsClockFromTimescale",function(){return x});var R=9e4;function p(L,A,y,D){y===void 0&&(y=1),D===void 0&&(D=!1);var _=L*A*y;return D?Math.round(_):_}function S(L,A,y,D){return y===void 0&&(y=1),D===void 0&&(D=!1),p(L,A,1/y,D)}function I(L,A){return A===void 0&&(A=!1),p(L,1e3,1/R,A)}function x(L,A){return A===void 0&&(A=1),p(L,R,1/A)}},"./src/utils/typed-array.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"sliceUint8",function(){return R});function R(p,S,I){return Uint8Array.prototype.slice?p.slice(S,I):new Uint8Array(Array.prototype.slice.call(p,S,I))}},"./src/utils/vttcue.ts":function(K,P,h){"use strict";h.r(P),P.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var R=["","lr","rl"],p=["start","middle","end","left","right"];function S(y,D){if(typeof D!="string"||!Array.isArray(y))return!1;var _=D.toLowerCase();return~y.indexOf(_)?_:!1}function I(y){return S(R,y)}function x(y){return S(p,y)}function L(y){for(var D=arguments.length,_=new Array(D>1?D-1:0),T=1;T<D;T++)_[T-1]=arguments[T];for(var g=1;g<arguments.length;g++){var E=arguments[g];for(var a in E)y[a]=E[a]}return y}function A(y,D,_){var T=this,g={enumerable:!0};T.hasBeenReset=!1;var E="",a=!1,e=y,s=D,u=_,n=null,i="",t=!0,l="auto",d="start",r=50,c="middle",f=50,o="middle";Object.defineProperty(T,"id",L({},g,{get:function(){return E},set:function(m){E=""+m}})),Object.defineProperty(T,"pauseOnExit",L({},g,{get:function(){return a},set:function(m){a=!!m}})),Object.defineProperty(T,"startTime",L({},g,{get:function(){return e},set:function(m){if(typeof m!="number")throw new TypeError("Start time must be set to a number.");e=m,this.hasBeenReset=!0}})),Object.defineProperty(T,"endTime",L({},g,{get:function(){return s},set:function(m){if(typeof m!="number")throw new TypeError("End time must be set to a number.");s=m,this.hasBeenReset=!0}})),Object.defineProperty(T,"text",L({},g,{get:function(){return u},set:function(m){u=""+m,this.hasBeenReset=!0}})),Object.defineProperty(T,"region",L({},g,{get:function(){return n},set:function(m){n=m,this.hasBeenReset=!0}})),Object.defineProperty(T,"vertical",L({},g,{get:function(){return i},set:function(m){var O=I(m);if(O===!1)throw new SyntaxError("An invalid or illegal string was specified.");i=O,this.hasBeenReset=!0}})),Object.defineProperty(T,"snapToLines",L({},g,{get:function(){return t},set:function(m){t=!!m,this.hasBeenReset=!0}})),Object.defineProperty(T,"line",L({},g,{get:function(){return l},set:function(m){if(typeof m!="number"&&m!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");l=m,this.hasBeenReset=!0}})),Object.defineProperty(T,"lineAlign",L({},g,{get:function(){return d},set:function(m){var O=x(m);if(!O)throw new SyntaxError("An invalid or illegal string was specified.");d=O,this.hasBeenReset=!0}})),Object.defineProperty(T,"position",L({},g,{get:function(){return r},set:function(m){if(m<0||m>100)throw new Error("Position must be between 0 and 100.");r=m,this.hasBeenReset=!0}})),Object.defineProperty(T,"positionAlign",L({},g,{get:function(){return c},set:function(m){var O=x(m);if(!O)throw new SyntaxError("An invalid or illegal string was specified.");c=O,this.hasBeenReset=!0}})),Object.defineProperty(T,"size",L({},g,{get:function(){return f},set:function(m){if(m<0||m>100)throw new Error("Size must be between 0 and 100.");f=m,this.hasBeenReset=!0}})),Object.defineProperty(T,"align",L({},g,{get:function(){return o},set:function(m){var O=x(m);if(!O)throw new SyntaxError("An invalid or illegal string was specified.");o=O,this.hasBeenReset=!0}})),T.displayState=void 0}return A.prototype.getCueAsHTML=function(){var y=self.WebVTT;return y.convertCueToDOMTree(self,this.text)},A}()},"./src/utils/vttparser.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"parseTimeStamp",function(){return S}),h.d(P,"fixLineBreaks",function(){return D}),h.d(P,"VTTParser",function(){return _});var R=h("./src/utils/vttcue.ts"),p=function(){function T(){}var g=T.prototype;return g.decode=function(a,e){if(!a)return"";if(typeof a!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(a))},T}();function S(T){function g(a,e,s,u){return(a|0)*3600+(e|0)*60+(s|0)+parseFloat(u||0)}var E=T.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return E?parseFloat(E[2])>59?g(E[2],E[3],0,E[4]):g(E[1],E[2],E[3],E[4]):null}var I=function(){function T(){this.values=Object.create(null)}var g=T.prototype;return g.set=function(a,e){!this.get(a)&&e!==""&&(this.values[a]=e)},g.get=function(a,e,s){return s?this.has(a)?this.values[a]:e[s]:this.has(a)?this.values[a]:e},g.has=function(a){return a in this.values},g.alt=function(a,e,s){for(var u=0;u<s.length;++u)if(e===s[u]){this.set(a,e);break}},g.integer=function(a,e){/^-?\d+$/.test(e)&&this.set(a,parseInt(e,10))},g.percent=function(a,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){var s=parseFloat(e);if(s>=0&&s<=100)return this.set(a,s),!0}return!1},T}();function x(T,g,E,a){var e=a?T.split(a):[T];for(var s in e)if(typeof e[s]=="string"){var u=e[s].split(E);if(u.length===2){var n=u[0],i=u[1];g(n,i)}}}var L=new R.default(0,0,""),A=L.align==="middle"?"middle":"center";function y(T,g,E){var a=T;function e(){var n=S(T);if(n===null)throw new Error("Malformed timestamp: "+a);return T=T.replace(/^[^\sa-zA-Z-]+/,""),n}function s(n,i){var t=new I;x(n,function(r,c){var f;switch(r){case"region":for(var o=E.length-1;o>=0;o--)if(E[o].id===c){t.set(r,E[o].region);break}break;case"vertical":t.alt(r,c,["rl","lr"]);break;case"line":f=c.split(","),t.integer(r,f[0]),t.percent(r,f[0])&&t.set("snapToLines",!1),t.alt(r,f[0],["auto"]),f.length===2&&t.alt("lineAlign",f[1],["start",A,"end"]);break;case"position":f=c.split(","),t.percent(r,f[0]),f.length===2&&t.alt("positionAlign",f[1],["start",A,"end","line-left","line-right","auto"]);break;case"size":t.percent(r,c);break;case"align":t.alt(r,c,["start",A,"end","left","right"]);break}},/:/,/\s/),i.region=t.get("region",null),i.vertical=t.get("vertical","");var l=t.get("line","auto");l==="auto"&&L.line===-1&&(l=-1),i.line=l,i.lineAlign=t.get("lineAlign","start"),i.snapToLines=t.get("snapToLines",!0),i.size=t.get("size",100),i.align=t.get("align",A);var d=t.get("position","auto");d==="auto"&&L.position===50&&(d=i.align==="start"||i.align==="left"?0:i.align==="end"||i.align==="right"?100:50),i.position=d}function u(){T=T.replace(/^\s+/,"")}if(u(),g.startTime=e(),u(),T.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+a);T=T.slice(3),u(),g.endTime=e(),u(),s(T,g)}function D(T){return T.replace(/<br(?: \/)?>/gi,`
21
+ `)}var _=function(){function T(){this.state="INITIAL",this.buffer="",this.decoder=new p,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var g=T.prototype;return g.parse=function(a){var e=this;a&&(e.buffer+=e.decoder.decode(a,{stream:!0}));function s(){var d=e.buffer,r=0;for(d=D(d);r<d.length&&d[r]!=="\r"&&d[r]!==`
22
+ `;)++r;var c=d.slice(0,r);return d[r]==="\r"&&++r,d[r]===`
23
+ `&&++r,e.buffer=d.slice(r),c}function u(d){x(d,function(r,c){},/:/)}try{var n="";if(e.state==="INITIAL"){if(!/\r\n|\n/.test(e.buffer))return this;n=s();var i=n.match(/^()?WEBVTT([ \t].*)?$/);if(!i||!i[0])throw new Error("Malformed WebVTT signature.");e.state="HEADER"}for(var t=!1;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(t?t=!1:n=s(),e.state){case"HEADER":/:/.test(n)?u(n):n||(e.state="ID");continue;case"NOTE":n||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){e.state="NOTE";break}if(!n)continue;if(e.cue=new R.default(0,0,""),e.state="CUE",n.indexOf("-->")===-1){e.cue.id=n;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{y(n,e.cue,e.regionList)}catch{e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":{var l=n.indexOf("-->")!==-1;if(!n||l&&(t=!0)){e.oncue&&e.cue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}if(e.cue===null)continue;e.cue.text&&(e.cue.text+=`
24
+ `),e.cue.text+=n}continue;case"BADCUE":n||(e.state="ID")}}}catch{e.state==="CUETEXT"&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state=e.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},g.flush=function(){var a=this;try{if((a.cue||a.state==="HEADER")&&(a.buffer+=`
25
25
 
26
- `,s.parse()),s.state==="INITIAL"||s.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){s.onparsingerror&&s.onparsingerror(e)}return s.onflush&&s.onflush(),this},S}()},"./src/utils/webvtt-parser.ts":function(N,I,c){"use strict";c.r(I),c.d(I,"generateCueId",function(){return D}),c.d(I,"parseWebVTT",function(){return v});var R=c("./src/polyfills/number.ts"),y=c("./src/utils/vttparser.ts"),x=c("./src/demux/id3.ts"),b=c("./src/utils/timescale-conversion.ts"),T=c("./src/remux/mp4-remuxer.ts"),L=/\r\n|\n\r|\n|\r/g,_=function(s,e,i){return i===void 0&&(i=0),s.substr(i,e.length)===e},g=function(s){var e=parseInt(s.substr(-3)),i=parseInt(s.substr(-6,2)),t=parseInt(s.substr(-9,2)),r=s.length>9?parseInt(s.substr(0,s.indexOf(":"))):0;if(!Object(R.isFiniteNumber)(e)||!Object(R.isFiniteNumber)(i)||!Object(R.isFiniteNumber)(t)||!Object(R.isFiniteNumber)(r))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+s);return e+=1e3*i,e+=60*1e3*t,e+=60*60*1e3*r,e},A=function(s){for(var e=5381,i=s.length;i;)e=e*33^s.charCodeAt(--i);return(e>>>0).toString()};function D(p,s,e){return A(p.toString())+A(s.toString())+A(e)}var S=function(s,e,i){var t=s[e],r=s[t.prevCC];if(!r||!r.new&&t.new){s.ccOffset=s.presentationOffset=t.start,t.new=!1;return}for(;(a=r)!==null&&a!==void 0&&a.new;){var a;s.ccOffset+=t.start-r.start,t.new=!1,t=r,r=s[t.prevCC]}s.presentationOffset=i};function v(p,s,e,i,t,r,a,n){var h=new y.VTTParser,d=Object(x.utf8ArrayToStr)(new Uint8Array(p)).trim().replace(L,`
26
+ `,a.parse()),a.state==="INITIAL"||a.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){a.onparsingerror&&a.onparsingerror(e)}return a.onflush&&a.onflush(),this},T}()},"./src/utils/webvtt-parser.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"generateCueId",function(){return _}),h.d(P,"parseWebVTT",function(){return g});var R=h("./src/polyfills/number.ts"),p=h("./src/utils/vttparser.ts"),S=h("./src/demux/id3.ts"),I=h("./src/utils/timescale-conversion.ts"),x=h("./src/remux/mp4-remuxer.ts"),L=/\r\n|\n\r|\n|\r/g,A=function(a,e,s){return s===void 0&&(s=0),a.slice(s,s+e.length)===e},y=function(a){var e=parseInt(a.slice(-3)),s=parseInt(a.slice(-6,-4)),u=parseInt(a.slice(-9,-7)),n=a.length>9?parseInt(a.substring(0,a.indexOf(":"))):0;if(!Object(R.isFiniteNumber)(e)||!Object(R.isFiniteNumber)(s)||!Object(R.isFiniteNumber)(u)||!Object(R.isFiniteNumber)(n))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+a);return e+=1e3*s,e+=60*1e3*u,e+=60*60*1e3*n,e},D=function(a){for(var e=5381,s=a.length;s;)e=e*33^a.charCodeAt(--s);return(e>>>0).toString()};function _(E,a,e){return D(E.toString())+D(a.toString())+D(e)}var T=function(a,e,s){var u=a[e],n=a[u.prevCC];if(!n||!n.new&&u.new){a.ccOffset=a.presentationOffset=u.start,u.new=!1;return}for(;(i=n)!==null&&i!==void 0&&i.new;){var i;a.ccOffset+=u.start-n.start,u.new=!1,u=n,n=a[u.prevCC]}a.presentationOffset=s};function g(E,a,e,s,u,n,i,t){var l=new p.VTTParser,d=Object(S.utf8ArrayToStr)(new Uint8Array(E)).trim().replace(L,`
27
27
  `).split(`
28
- `),u=[],f=Object(b.toMpegTsClockFromTimescale)(s,e),l="00:00.000",o=0,E=0,m,O=!0,P=!1;h.oncue=function(M){var F=i[t],B=i.ccOffset,C=(o-f)/9e4;if(F!=null&&F.new&&(E!==void 0?B=i.ccOffset=F.start:S(i,t,C)),C&&(B=C-i.presentationOffset),P){var U=M.endTime-M.startTime,w=Object(T.normalizePts)((M.startTime+B-E)*9e4,r*9e4)/9e4;M.startTime=w,M.endTime=w+U}var k=M.text.trim();M.text=decodeURIComponent(encodeURIComponent(k)),M.id||(M.id=D(M.startTime,M.endTime,k)),M.endTime>0&&u.push(M)},h.onparsingerror=function(M){m=M},h.onflush=function(){if(m){n(m);return}a(u)},d.forEach(function(M){if(O)if(_(M,"X-TIMESTAMP-MAP=")){O=!1,P=!0,M.substr(16).split(",").forEach(function(F){_(F,"LOCAL:")?l=F.substr(6):_(F,"MPEGTS:")&&(o=parseInt(F.substr(7)))});try{E=g(l)/1e3}catch(F){P=!1,m=F}return}else M===""&&(O=!1);h.parse(M+`
29
- `)}),h.flush()}},"./src/utils/xhr-loader.ts":function(N,I,c){"use strict";c.r(I);var R=c("./src/utils/logger.ts"),y=c("./src/loader/load-stats.ts"),x=/^age:\s*[\d.]+\s*$/m,b=function(){function T(_){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=_?_.xhrSetup:null,this.stats=new y.LoadStats,this.retryDelay=0}var L=T.prototype;return L.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},L.abortInternal=function(){var g=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),g&&(g.onreadystatechange=null,g.onprogress=null,g.readyState!==4&&(this.stats.aborted=!0,g.abort()))},L.abort=function(){var g;this.abortInternal(),(g=this.callbacks)!==null&&g!==void 0&&g.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},L.load=function(g,A,D){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=g,this.config=A,this.callbacks=D,this.retryDelay=A.retryDelay,this.loadInternal()},L.loadInternal=function(){var g=this.config,A=this.context;if(!!g){var D=this.loader=new self.XMLHttpRequest,S=this.stats;S.loading.first=0,S.loaded=0;var v=this.xhrSetup;try{if(v)try{v(D,A.url)}catch{D.open("GET",A.url,!0),v(D,A.url)}D.readyState||D.open("GET",A.url,!0);var p=this.context.headers;if(p)for(var s in p)D.setRequestHeader(s,p[s])}catch(e){this.callbacks.onError({code:D.status,text:e.message},A,D);return}A.rangeEnd&&D.setRequestHeader("Range","bytes="+A.rangeStart+"-"+(A.rangeEnd-1)),D.onreadystatechange=this.readystatechange.bind(this),D.onprogress=this.loadprogress.bind(this),D.responseType=A.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),g.timeout),D.send()}},L.readystatechange=function(){var g=this.context,A=this.loader,D=this.stats;if(!(!g||!A)){var S=A.readyState,v=this.config;if(!D.aborted&&S>=2)if(self.clearTimeout(this.requestTimeout),D.loading.first===0&&(D.loading.first=Math.max(self.performance.now(),D.loading.start)),S===4){A.onreadystatechange=null,A.onprogress=null;var p=A.status;if(p>=200&&p<300){D.loading.end=Math.max(self.performance.now(),D.loading.first);var s,e;if(g.responseType==="arraybuffer"?(s=A.response,e=s.byteLength):(s=A.responseText,e=s.length),D.loaded=D.total=e,!this.callbacks)return;var i=this.callbacks.onProgress;if(i&&i(D,g,s,A),!this.callbacks)return;var t={url:A.responseURL,data:s};this.callbacks.onSuccess(t,D,g,A)}else D.retry>=v.maxRetry||p>=400&&p<499?(R.logger.error(p+" while loading "+g.url),this.callbacks.onError({code:p,text:A.statusText},g,A)):(R.logger.warn(p+" while loading "+g.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,v.maxRetryDelay),D.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),v.timeout)}},L.loadtimeout=function(){R.logger.warn("timeout while loading "+this.context.url);var g=this.callbacks;g&&(this.abortInternal(),g.onTimeout(this.stats,this.context,this.loader))},L.loadprogress=function(g){var A=this.stats;A.loaded=g.loaded,g.lengthComputable&&(A.total=g.total)},L.getCacheAge=function(){var g=null;if(this.loader&&x.test(this.loader.getAllResponseHeaders())){var A=this.loader.getResponseHeader("age");g=A?parseFloat(A):null}return g},T}();I.default=b}}).default})});var lt=Ve(pt()),be=Ve(Xe());var nt=Ve(Xe()),at={ANY:"any",MUTED:"muted"},Ct=Object.values(at),yt=N=>typeof N=="boolean"||typeof N=="string"&&Ct.includes(N),Ft=(N,I,c)=>{let R=!1,y=!1,x=yt(I)?I:!!I,b=()=>{N.addEventListener("playing",()=>{R=!0},{once:!0})};if(b(),N.addEventListener("loadstart",()=>{R=!1,b(),st(N,x)},{once:!0}),N.addEventListener("loadedmetadata",()=>{c||(y=!Number.isFinite(N.duration)),st(N,x)},{once:!0}),c&&c.once(nt.default.Events.LEVEL_LOADED,(L,_)=>{var g;y=(g=_.details.live)!=null?g:!1}),!x){let L=()=>{!y||((c==null?void 0:c.liveSyncPosition)?N.currentTime=c.liveSyncPosition:Number.isFinite(N.seekable.end(0))&&(N.currentTime=N.seekable.end(0)))};N.addEventListener("play",()=>{c&&N.preload==="metadata"?c.once(nt.default.Events.LEVEL_UPDATED,L):c&&L()},{once:!0})}return L=>{R||(x=yt(L)?L:!!L,st(N,x))}},st=(N,I)=>{if(!I)return;let c=N.muted,R=()=>N.muted=c;switch(I){case at.ANY:N.play().catch(y=>{N.muted=!0,N.play().catch(R)});break;case at.MUTED:N.muted=!0,N.play().catch(R);break;default:N.play().catch(()=>{});break}};var Fe=class extends Error{constructor(I,c=Fe.MEDIA_ERR_CUSTOM,R){super(I);var y;this.name="MediaError",this.code=c,this.fatal=R!=null?R:c>=Fe.MEDIA_ERR_NETWORK&&c<=Fe.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(y=Fe.defaultMessages[this.code])!=null?y:"")}},_e=Fe;_e.MEDIA_ERR_ABORTED=1,_e.MEDIA_ERR_NETWORK=2,_e.MEDIA_ERR_DECODE=3,_e.MEDIA_ERR_SRC_NOT_SUPPORTED=4,_e.MEDIA_ERR_ENCRYPTED=5,_e.MEDIA_ERR_CUSTOM=100,_e.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};var Be=Ve(Xe());function Et(N,I){I.on(Be.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(y,{tracks:x})=>{x.forEach(b=>{var _;let T=(_=b.subtitleTrack)!=null?_:b.closedCaptions,L=I.subtitleTracks.findIndex(({lang:g,name:A,type:D})=>g==(T==null?void 0:T.lang)&&A===b.label&&D.toLowerCase()===b.kind);Tt(N,b.kind,b.label,T==null?void 0:T.lang,`${b.kind}${L}`)})});let c=()=>{var b;if(!I.subtitleTracks.length)return;let y=Array.from(N.textTracks).find(T=>T.id&&T.mode==="showing"&&["subtitles","captions"].includes(T.kind)),x=`${(b=I.subtitleTracks[I.subtitleTrack])==null?void 0:b.type.toLowerCase()}${I.subtitleTrack}`;if(y&&(I.subtitleTrack<0||(y==null?void 0:y.id)!==x)){let T=I.subtitleTracks.findIndex(({lang:L,name:_,type:g})=>L==y.language&&_===y.label&&g.toLowerCase()===y.kind);I.subtitleTrack=T}y&&(y==null?void 0:y.id)===x&&y.cues&&Array.from(y.cues).forEach(T=>{y.addCue(T)})};N.textTracks.addEventListener("change",c),I.on(Be.default.Events.CUES_PARSED,(y,{track:x,type:b,cues:T})=>{let L=N.textTracks.getTrackById(x);if(!L)return;let _=L.mode==="disabled";_&&(L.mode="hidden"),T.forEach(g=>{var A;((A=L.cues)==null?void 0:A.getCueById(g.id))||L.addCue(g)}),_&&(L.mode="disabled")}),I.on(Be.default.Events.DESTROYING,()=>{N.textTracks.removeEventListener("change",c),N.querySelectorAll("track[data-removeondestroy]").forEach(x=>{x.remove()})});let R=()=>{Array.from(N.textTracks).forEach(y=>{var x,b;if(!["subtitles","caption"].includes(y.kind)&&y.label==="thumbnails"){if(!((x=y.cues)==null?void 0:x.length)){let T=N.querySelector('track[label="thumbnails"]'),L=(b=T==null?void 0:T.getAttribute("src"))!=null?b:"";T==null||T.removeAttribute("src"),setTimeout(()=>{T==null||T.setAttribute("src",L)},0)}y.mode!=="hidden"&&(y.mode="hidden")}})};I.once(Be.default.Events.MANIFEST_LOADED,R),I.once(Be.default.Events.MEDIA_ATTACHED,R)}function Tt(N,I,c,R,y){let x=document.createElement("track");return x.kind=I,x.label=c,R&&(x.srclang=R),y&&(x.id=y),x.track.mode="disabled",x.setAttribute("data-removeondestroy",""),N.append(x),x.track}function Bt(N,I){let c=Array.prototype.find.call(N.querySelectorAll("track"),R=>R.track===I);c==null||c.remove()}var ot=(N,I)=>N in I;var xt="mux.com",ir=()=>lt.default.utils.now(),ze={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},Ue={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},ut={HLS:Ue.M3U8},nr=Object.keys(ut),ar=[...Object.values(Ue),"hls","HLS"],Ut=N=>{let I=N.indexOf("?");if(I<0)return[N];let c=N.slice(0,I),R=N.slice(I);return[c,R]},sr=(N,{domain:I=xt}={})=>{if(!N)return;let[c,R=""]=Ut(N);return`https://stream.${I}/${c}.m3u8${R}`},wt=N=>{let I="";try{I=new URL(N).pathname}catch{console.error("invalid url")}let c=I.lastIndexOf(".");if(c<0)return"";let y=I.slice(c+1).toUpperCase();return ot(y,Ue)?Ue[y]:""},St=N=>{let I=N.type;if(I){let R=I.toUpperCase();return ot(R,ut)?ut[R]:I}let{src:c}=N;return c?wt(c):""},kt=N=>{if([ze.LIVE,ze.LL_LIVE].includes(N)){let I={backBufferLength:12};return N===ze.LL_LIVE?{...I,maxFragLookUpTolerance:.001}:I}return{}},Qe=new WeakMap,or=N=>{var I;return(I=Qe.get(N))==null?void 0:I.error},Nt=(N,I)=>{I&&(I.detachMedia(),I.destroy()),(N==null?void 0:N.mux)&&!N.mux.deleted&&(N.mux.destroy(),N.mux),N&&(N.removeEventListener("error",_t),N.removeEventListener("error",ft),Qe.delete(N))},Kt=(N,I)=>{var v,p,s;let{debug:c,preferMse:R,streamType:y,startTime:x=-1}=N,b=St(N),T=b===Ue.M3U8,L=!b||((v=I==null?void 0:I.canPlayType(b))!=null?v:!0),_=be.default.isSupported(),D=((s=(p=window==null?void 0:window.navigator)==null?void 0:p.userAgent)!=null?s:"").toLowerCase().indexOf("android")!==-1;if(T&&!(!T||L&&!((R||D)&&_))&&_){let e={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},i=kt(y);return new be.default({debug:c,startPosition:x,...e,...i})}},jt=({playbackId:N,src:I,customDomain:c})=>{if(N)return!0;if(typeof I!="string")return!1;let R=new URL(I).hostname.toLocaleLowerCase();return R.includes(xt)||!!c&&R.includes(c.toLocaleLowerCase())},Wt=(N,I,c)=>{let{envKey:R}=N,y=jt(N);if((R||y)&&I){let{playerInitTime:x,playerSoftwareName:b,playerSoftwareVersion:T,beaconCollectionDomain:L,metadata:_,debug:g}=N,A=D=>typeof D.player_error_code=="string"?!1:typeof N.errorTranslator=="function"?N.errorTranslator(D):D;lt.default.monitor(I,{debug:g,beaconCollectionDomain:L,hlsjs:c,Hls:c?be.default:void 0,automaticErrorTracking:!1,errorTranslator:A,data:{...R?{env_key:R}:{},player_software_name:b,player_software_version:T,player_init_time:x,..._}})}},Ht=(N,I,c)=>{var v,p,s;if(!I){console.warn("attempting to load media before mediaEl exists");return}let{preferMse:R,streamType:y}=N,x=St(N),b=x===Ue.M3U8,T=!x||((v=I==null?void 0:I.canPlayType(x))!=null?v:!0),L=be.default.isSupported(),A=((s=(p=window==null?void 0:window.navigator)==null?void 0:p.userAgent)!=null?s:"").toLowerCase().indexOf("android")!==-1&&y===ze.LL_LIVE,D=!b||T&&!((R||A)&&L),{src:S}=N;if(I&&T&&D){if(typeof S=="string"){let{startTime:e}=N;if(I.setAttribute("src",S),e){let i=({target:t})=>{t.currentTime=e,t.removeEventListener("loadedmetadata",i)};I.addEventListener("loadedmetadata",i)}}else I.removeAttribute("src");I.addEventListener("error",_t),I.addEventListener("error",ft)}else if(c&&S){switch(c.on(be.default.Events.ERROR,(e,i)=>{let t={[be.default.ErrorTypes.NETWORK_ERROR]:_e.MEDIA_ERR_NETWORK,[be.default.ErrorTypes.MEDIA_ERROR]:_e.MEDIA_ERR_DECODE},r=new _e("",t[i.type]);r.fatal=i.fatal,r.data=i,I.dispatchEvent(new CustomEvent("error",{detail:r}))}),I.addEventListener("error",ft),Et(I,c),I.preload){case"none":I.addEventListener("play",()=>c.loadSource(S),{once:!0});break;case"metadata":let e=c.config.maxBufferLength,i=c.config.maxBufferSize;c.config.maxBufferLength=1,c.config.maxBufferSize=1,I.addEventListener("play",()=>{c.config.maxBufferLength=e,c.config.maxBufferSize=i},{once:!0}),c.loadSource(S);break;default:c.loadSource(S)}c.attachMedia(I)}else console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};async function _t(N){if(!N.isTrusted)return;N.stopImmediatePropagation();let I=N.target;if(!(I==null?void 0:I.error))return;let{message:c,code:R}=I.error,y=new _e(c,R);if(I.src&&(R!==_e.MEDIA_ERR_DECODE||R!==void 0)){let{status:x}=await fetch(I.src);y.data={response:{code:x}}}I.dispatchEvent(new CustomEvent("error",{detail:y}))}function ft(N){var y;if(!(N instanceof CustomEvent)||!(N.detail instanceof _e))return;let I=N.target,c=N.detail;if(!c||!c.fatal)return;let R=Qe.get(I);R&&(R.error=c),(y=I.mux)==null||y.emit("error",{player_error_code:c.code,player_error_message:c.message})}var lr=(N,I,c)=>{Nt(I,c),Qe.set(I,{});let R=Kt(N,I);return Wt(N,I,R),Ht(N,I,R),R};})();
28
+ `),r=[],c=Object(I.toMpegTsClockFromTimescale)(a,e),f="00:00.000",o=0,v=0,m,O=!0;l.oncue=function(b){var M=s[u],F=s.ccOffset,w=(o-c)/9e4;M!=null&&M.new&&(v!==void 0?F=s.ccOffset=M.start:T(s,u,w)),w&&(F=w-s.presentationOffset);var C=b.endTime-b.startTime,U=Object(x.normalizePts)((b.startTime+F-v)*9e4,n*9e4)/9e4;b.startTime=Math.max(U,0),b.endTime=Math.max(U+C,0);var B=b.text.trim();b.text=decodeURIComponent(encodeURIComponent(B)),b.id||(b.id=_(b.startTime,b.endTime,B)),b.endTime>0&&r.push(b)},l.onparsingerror=function(b){m=b},l.onflush=function(){if(m){t(m);return}i(r)},d.forEach(function(b){if(O)if(A(b,"X-TIMESTAMP-MAP=")){O=!1,b.slice(16).split(",").forEach(function(M){A(M,"LOCAL:")?f=M.slice(6):A(M,"MPEGTS:")&&(o=parseInt(M.slice(7)))});try{v=y(f)/1e3}catch(M){m=M}return}else b===""&&(O=!1);l.parse(b+`
29
+ `)}),l.flush()}},"./src/utils/xhr-loader.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/utils/logger.ts"),p=h("./src/loader/load-stats.ts"),S=/^age:\s*[\d.]+\s*$/m,I=function(){function x(A){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=A?A.xhrSetup:null,this.stats=new p.LoadStats,this.retryDelay=0}var L=x.prototype;return L.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},L.abortInternal=function(){var y=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),y&&(y.onreadystatechange=null,y.onprogress=null,y.readyState!==4&&(this.stats.aborted=!0,y.abort()))},L.abort=function(){var y;this.abortInternal(),(y=this.callbacks)!==null&&y!==void 0&&y.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},L.load=function(y,D,_){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=y,this.config=D,this.callbacks=_,this.retryDelay=D.retryDelay,this.loadInternal()},L.loadInternal=function(){var y=this.config,D=this.context;if(!!y){var _=this.loader=new self.XMLHttpRequest,T=this.stats;T.loading.first=0,T.loaded=0;var g=this.xhrSetup;try{if(g)try{g(_,D.url)}catch{_.open("GET",D.url,!0),g(_,D.url)}_.readyState||_.open("GET",D.url,!0);var E=this.context.headers;if(E)for(var a in E)_.setRequestHeader(a,E[a])}catch(e){this.callbacks.onError({code:_.status,text:e.message},D,_);return}D.rangeEnd&&_.setRequestHeader("Range","bytes="+D.rangeStart+"-"+(D.rangeEnd-1)),_.onreadystatechange=this.readystatechange.bind(this),_.onprogress=this.loadprogress.bind(this),_.responseType=D.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),y.timeout),_.send()}},L.readystatechange=function(){var y=this.context,D=this.loader,_=this.stats;if(!(!y||!D)){var T=D.readyState,g=this.config;if(!_.aborted&&T>=2)if(self.clearTimeout(this.requestTimeout),_.loading.first===0&&(_.loading.first=Math.max(self.performance.now(),_.loading.start)),T===4){D.onreadystatechange=null,D.onprogress=null;var E=D.status;if(E>=200&&E<300){_.loading.end=Math.max(self.performance.now(),_.loading.first);var a,e;if(y.responseType==="arraybuffer"?(a=D.response,e=a.byteLength):(a=D.responseText,e=a.length),_.loaded=_.total=e,!this.callbacks)return;var s=this.callbacks.onProgress;if(s&&s(_,y,a,D),!this.callbacks)return;var u={url:D.responseURL,data:a};this.callbacks.onSuccess(u,_,y,D)}else _.retry>=g.maxRetry||E>=400&&E<499?(R.logger.error(E+" while loading "+y.url),this.callbacks.onError({code:E,text:D.statusText},y,D)):(R.logger.warn(E+" while loading "+y.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,g.maxRetryDelay),_.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),g.timeout)}},L.loadtimeout=function(){R.logger.warn("timeout while loading "+this.context.url);var y=this.callbacks;y&&(this.abortInternal(),y.onTimeout(this.stats,this.context,this.loader))},L.loadprogress=function(y){var D=this.stats;D.loaded=y.loaded,y.lengthComputable&&(D.total=y.total)},L.getCacheAge=function(){var y=null;if(this.loader&&S.test(this.loader.getAllResponseHeaders())){var D=this.loader.getResponseHeader("age");y=D?parseFloat(D):null}return y},x}();P.default=I}}).default})});var gt=tt(Et()),Ue=tt(it());var ut=tt(it());var Me=(K,P,h,R)=>{K.addEventListener(P,h,R),K.addEventListener("teardown",()=>{K.removeEventListener(P,h)},{once:!0})},ot=(K,P)=>K in P;function Tt(K,P,h){P&&h>P&&(h=P);for(let R=0;R<K.length;R++)if(K.start(R)<=h&&K.end(R)>=h)return!0;return!1}var ft={ANY:"any",MUTED:"muted"},jt=Object.values(ft),xt=K=>typeof K=="boolean"||typeof K=="string"&&jt.includes(K),Wt=(K,P,h)=>{let R=!1,p=!1,S=xt(P)?P:!!P,I=()=>{R||Me(K,"playing",()=>{R=!0},{once:!0})};if(I(),Me(K,"loadstart",()=>{R=!1,I(),lt(K,S)},{once:!0}),Me(K,"loadstart",()=>{h||(p=!Number.isFinite(K.duration)),lt(K,S)},{once:!0}),h&&h.once(ut.default.Events.LEVEL_LOADED,(L,A)=>{var y;p=(y=A.details.live)!=null?y:!1}),!S){let L=()=>{!p||(h!=null&&h.liveSyncPosition?K.currentTime=h.liveSyncPosition:Number.isFinite(K.seekable.end(0))&&(K.currentTime=K.seekable.end(0)))};h&&Me(K,"play",()=>{K.preload==="metadata"?h.once(ut.default.Events.LEVEL_UPDATED,L):L()},{once:!0})}return L=>{R||(S=xt(L)?L:!!L,lt(K,S))}},lt=(K,P)=>{if(!P)return;let h=K.muted,R=()=>K.muted=h;switch(P){case ft.ANY:K.play().catch(p=>{K.muted=!0,K.play().catch(R)});break;case ft.MUTED:K.muted=!0,K.play().catch(R);break;default:K.play().catch(()=>{});break}};var je=class extends Error{constructor(h,R=je.MEDIA_ERR_CUSTOM,p){var S;super(h);this.name="MediaError",this.code=R,this.fatal=p!=null?p:R>=je.MEDIA_ERR_NETWORK&&R<=je.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(S=je.defaultMessages[this.code])!=null?S:"")}},be=je;be.MEDIA_ERR_ABORTED=1,be.MEDIA_ERR_NETWORK=2,be.MEDIA_ERR_DECODE=3,be.MEDIA_ERR_SRC_NOT_SUPPORTED=4,be.MEDIA_ERR_ENCRYPTED=5,be.MEDIA_ERR_CUSTOM=100,be.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};var We=tt(it());function St(K,P){P.on(We.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(p,{tracks:S})=>{S.forEach(I=>{var A;let x=(A=I.subtitleTrack)!=null?A:I.closedCaptions,L=P.subtitleTracks.findIndex(({lang:y,name:D,type:_})=>y==(x==null?void 0:x.lang)&&D===I.label&&_.toLowerCase()===I.kind);Dt(K,I.kind,I.label,x==null?void 0:x.lang,`${I.kind}${L}`)})});let h=()=>{var I;if(!P.subtitleTracks.length)return;let p=Array.from(K.textTracks).find(x=>x.id&&x.mode==="showing"&&["subtitles","captions"].includes(x.kind)),S=`${(I=P.subtitleTracks[P.subtitleTrack])==null?void 0:I.type.toLowerCase()}${P.subtitleTrack}`;if(p&&(P.subtitleTrack<0||(p==null?void 0:p.id)!==S)){let x=P.subtitleTracks.findIndex(({lang:L,name:A,type:y})=>L==p.language&&A===p.label&&y.toLowerCase()===p.kind);P.subtitleTrack=x}p&&(p==null?void 0:p.id)===S&&p.cues&&Array.from(p.cues).forEach(x=>{p.addCue(x)})};K.textTracks.addEventListener("change",h),P.on(We.default.Events.CUES_PARSED,(p,{track:S,type:I,cues:x})=>{let L=K.textTracks.getTrackById(S);if(!L)return;let A=L.mode==="disabled";A&&(L.mode="hidden"),x.forEach(y=>{var D;(D=L.cues)!=null&&D.getCueById(y.id)||L.addCue(y)}),A&&(L.mode="disabled")}),P.once(We.default.Events.DESTROYING,()=>{K.textTracks.removeEventListener("change",h),K.querySelectorAll("track[data-removeondestroy]").forEach(S=>{S.remove()})});let R=()=>{Array.from(K.textTracks).forEach(p=>{var S,I;if(!["subtitles","caption"].includes(p.kind)&&p.label==="thumbnails"){if(!((S=p.cues)!=null&&S.length)){let x=K.querySelector('track[label="thumbnails"]'),L=(I=x==null?void 0:x.getAttribute("src"))!=null?I:"";x==null||x.removeAttribute("src"),setTimeout(()=>{x==null||x.setAttribute("src",L)},0)}p.mode!=="hidden"&&(p.mode="hidden")}})};P.once(We.default.Events.MANIFEST_LOADED,R),P.once(We.default.Events.MEDIA_ATTACHED,R)}function Dt(K,P,h,R,p){let S=document.createElement("track");return S.kind=P,S.label=h,R&&(S.srclang=R),p&&(S.id=p),S.track.mode="disabled",S.setAttribute("data-removeondestroy",""),K.append(S),S.track}function Gt(K,P){let h=Array.prototype.find.call(K.querySelectorAll("track"),R=>R.track===P);h==null||h.remove()}var _t,At,Ht=(At=(_t=globalThis==null?void 0:globalThis.navigator)==null?void 0:_t.userAgent)!=null?At:"",Vt=Ht.toLowerCase().indexOf("android")!==-1,bt="mux.com",Lt,Ot,ct=(Ot=(Lt=Ue.default).isSupported)==null?void 0:Ot.call(Lt),Rt=Vt,vr=()=>gt.default.utils.now(),dt={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},Ge={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},ht={HLS:Ge.M3U8},gr=Object.keys(ht),mr=[...Object.values(Ge),"hls","HLS"],Yt=K=>{let P=K.indexOf("?");if(P<0)return[K];let h=K.slice(0,P),R=K.slice(P);return[h,R]},pr=(K,{domain:P=bt}={})=>{if(!K)return;let[h,R=""]=Yt(K);return`https://stream.${P}/${h}.m3u8${R}`},zt=K=>{let P="";try{P=new URL(K).pathname}catch{console.error("invalid url")}let h=P.lastIndexOf(".");if(h<0)return"";let p=P.slice(h+1).toUpperCase();return ot(p,Ge)?Ge[p]:""},Pt=K=>{let P=K.type;if(P){let R=P.toUpperCase();return ot(R,ht)?ht[R]:P}let{src:h}=K;return h?zt(h):""},Xt=K=>{if([dt.LIVE,dt.LL_LIVE].includes(K)){let P={backBufferLength:12};return K===dt.LL_LIVE?{...P,maxFragLookUpTolerance:.001}:P}return{}},He=new WeakMap,yr=K=>{var P;return(P=He.get(K))==null?void 0:P.error},Qt=(K,P)=>{P&&(P.detachMedia(),P.destroy()),(K==null?void 0:K.mux)&&!K.mux.deleted&&(K.mux.destroy(),delete K.mux),K&&(K.removeAttribute("src"),K.load(),K.removeEventListener("error",Mt),K.removeEventListener("error",vt),K.removeEventListener("durationchange",It),He.delete(K),K.dispatchEvent(new Event("teardown")))},Jt=(K,P)=>{var y;let{debug:h,preferMse:R,streamType:p,startTime:S=-1}=K,I=Pt(K),x=I===Ge.M3U8,L=!I||((y=P==null?void 0:P.canPlayType(I))!=null?y:!0);if(x&&!(!x||L&&!((R||Rt)&&ct))&&ct){let D={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},_=Xt(p);return new Ue.default({debug:h,startPosition:S,...D,..._})}},$t=({playbackId:K,src:P,customDomain:h})=>{if(K)return!0;if(typeof P!="string")return!1;let R=new URL(P).hostname.toLocaleLowerCase();return R.includes(bt)||!!h&&R.includes(h.toLocaleLowerCase())},Zt=(K,P,h)=>{let{envKey:R}=K,p=$t(K);if((R||p)&&P){let{playerInitTime:S,playerSoftwareName:I,playerSoftwareVersion:x,beaconCollectionDomain:L,metadata:A,debug:y}=K,D=_=>typeof _.player_error_code=="string"?!1:typeof K.errorTranslator=="function"?K.errorTranslator(_):_;gt.default.monitor(P,{debug:y,beaconCollectionDomain:L,hlsjs:h,Hls:h?Ue.default:void 0,automaticErrorTracking:!1,errorTranslator:D,data:{...R?{env_key:R}:{},player_software_name:I,player_software:I,player_software_version:x,player_init_time:S,...A}})}},qt=(K,P,h)=>{var y,D;if(!P){console.warn("attempting to load media before mediaEl exists");return}let{preferMse:R,streamType:p}=K,S=Pt(K),I=S===Ge.M3U8,x=!S||((y=P==null?void 0:P.canPlayType(S))!=null?y:!0),L=!I||x&&!((R||Rt)&&ct),{src:A}=K;if(P&&x&&L)typeof A=="string"?(P.setAttribute("src",A),K.startTime&&(((D=He.get(P))!=null?D:{}).startTime=K.startTime,P.addEventListener("durationchange",It,{once:!0}))):P.removeAttribute("src"),P.addEventListener("error",Mt),P.addEventListener("error",vt);else if(h&&A){switch(h.on(Ue.default.Events.ERROR,(_,T)=>{let g={[Ue.default.ErrorTypes.NETWORK_ERROR]:be.MEDIA_ERR_NETWORK,[Ue.default.ErrorTypes.MEDIA_ERROR]:be.MEDIA_ERR_DECODE},E=new be("",g[T.type]);E.fatal=T.fatal,E.data=T,P.dispatchEvent(new CustomEvent("error",{detail:E}))}),P.addEventListener("error",vt),St(P,h),P.preload){case"none":Me(P,"play",()=>h.loadSource(A),{once:!0});break;case"metadata":let _=h.config.maxBufferLength,T=h.config.maxBufferSize;h.config.maxBufferLength=1,h.config.maxBufferSize=1,Me(P,"play",()=>{h.config.maxBufferLength=_,h.config.maxBufferSize=T},{once:!0}),h.loadSource(A);break;default:h.loadSource(A)}h.attachMedia(P)}else console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};function It(K){var R;let P=K.target,h=(R=He.get(P))==null?void 0:R.startTime;if(!!h&&Tt(P.seekable,P.duration,h)){let p=P.preload==="auto";p&&(P.preload="none"),P.currentTime=h,p&&(P.preload="auto")}}async function Mt(K){if(!K.isTrusted)return;K.stopImmediatePropagation();let P=K.target;if(!(P!=null&&P.error))return;let{message:h,code:R}=P.error,p=new be(h,R);if(P.src&&(R!==be.MEDIA_ERR_DECODE||R!==void 0)){let{status:S}=await fetch(P.src);p.data={response:{code:S}}}P.dispatchEvent(new CustomEvent("error",{detail:p}))}function vt(K){var R,p;if(!(K instanceof CustomEvent)||!(K.detail instanceof be))return;let P=K.target,h=K.detail;!h||!h.fatal||(((R=He.get(P))!=null?R:{}).error=h,(p=P.mux)==null||p.emit("error",{player_error_code:h.code,player_error_message:h.message}))}var Er=(K,P,h)=>{Qt(P,h),He.set(P,{});let R=Jt(K,P);return Zt(K,P,R),qt(K,P,R),R};})();
30
30
  //# sourceMappingURL=playback-core.js.map