@mux/mux-video 0.8.6 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -6
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +3 -3
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +3 -3
- package/dist/mux-video.js +18 -18
- package/dist/mux-video.js.map +4 -4
- package/dist/mux-video.mjs +18 -18
- package/dist/mux-video.mjs.map +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +29 -14
- package/dist/types-ts3.4/index.d.ts +26 -12
- package/package.json +9 -6
package/dist/mux-video.mjs
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
var br=Object.create;var Lt=Object.defineProperty;var Rr=Object.getOwnPropertyDescriptor;var Pr=Object.getOwnPropertyNames;var Ir=Object.getPrototypeOf,Mr=Object.prototype.hasOwnProperty;var Cr=(B,P,n)=>P in B?Lt(B,P,{enumerable:!0,configurable:!0,writable:!0,value:n}):B[P]=n;var Qt=(B,P)=>()=>(P||B((P={exports:{}}).exports,P),P.exports);var Fr=(B,P,n,R)=>{if(P&&typeof P=="object"||typeof P=="function")for(let p of Pr(P))!Mr.call(B,p)&&p!==n&&Lt(B,p,{get:()=>P[p],enumerable:!(R=Rr(P,p))||R.enumerable});return B};var yt=(B,P,n)=>(n=B!=null?br(Ir(B)):{},Fr(P||!B||!B.__esModule?Lt(n,"default",{value:B,enumerable:!0}):n,B));var at=(B,P,n)=>(Cr(B,typeof P!="symbol"?P+"":P,n),n),Ot=(B,P,n)=>{if(!P.has(B))throw TypeError("Cannot "+n)};var ne=(B,P,n)=>(Ot(B,P,"read from private field"),n?n.call(B):P.get(B)),ve=(B,P,n)=>{if(P.has(B))throw TypeError("Cannot add the same private member more than once");P instanceof WeakSet?P.add(B):P.set(B,n)},Pe=(B,P,n,R)=>(Ot(B,P,"write to private field"),R?R.call(B,n):P.set(B,n),n);var be=(B,P,n)=>(Ot(B,P,"access private method"),n);var Zt=Qt((Et,It)=>{(function(){var B=!1;(function(P,n){typeof Et=="object"&&typeof It=="object"?It.exports=n():typeof B=="function"&&B.amd?B("mux",[],n):typeof Et=="object"?Et.mux=n():P.mux=n()})(typeof self!="undefined"?self:this,function(){return function(P){function n(p){if(R[p])return R[p].exports;var T=R[p]={i:p,l:!1,exports:{}};return P[p].call(T.exports,T,T.exports,n),T.l=!0,T.exports}var R={};return n.m=P,n.c=R,n.d=function(p,T,I){n.o(p,T)||Object.defineProperty(p,T,{configurable:!1,enumerable:!0,get:I})},n.n=function(p){var T=p&&p.__esModule?function(){return p.default}:function(){return p};return n.d(T,"a",T),T},n.o=function(p,T){return Object.prototype.hasOwnProperty.call(p,T)},n.p="",n(n.s=18)}([function(P,n,R){(function(p){var T;T=typeof window!="undefined"?window:p!==void 0?p:typeof self!="undefined"?self:{},P.exports=T}).call(n,R(20))},function(P,n){function R(C,U,k){switch(k.length){case 0:return C.call(U);case 1:return C.call(U,k[0]);case 2:return C.call(U,k[0],k[1]);case 3:return C.call(U,k[0],k[1],k[2])}return C.apply(U,k)}function p(C,U){for(var k=-1,j=Array(C);++k<C;)j[k]=U(k);return j}function T(C,U){var k=F(C)||g(C)?p(C.length,String):[],j=k.length,N=!!j;for(var W in C)!U&&!l.call(C,W)||N&&(W=="length"||E(W,j))||k.push(W);return k}function I(C,U,k){var j=C[U];l.call(C,U)&&x(j,k)&&(k!==void 0||U in C)||(C[U]=k)}function S(C){if(!D(C))return L(C);var U=[];for(var k in Object(C))l.call(C,k)&&k!="constructor"&&U.push(k);return U}function O(C,U){return U=b(U===void 0?C.length-1:U,0),function(){for(var k=arguments,j=-1,N=b(k.length-U,0),W=Array(N);++j<N;)W[j]=k[U+j];j=-1;for(var Y=Array(U+1);++j<U;)Y[j]=k[j];return Y[U]=W,R(C,this,Y)}}function _(C,U,k,j){k||(k={});for(var N=-1,W=U.length;++N<W;){var Y=U[N],K=j?j(k[Y],C[Y],Y,k,C):void 0;I(k,Y,K===void 0?C[Y]:K)}return k}function E(C,U){return!!(U=U==null?t:U)&&(typeof C=="number"||h.test(C))&&C>-1&&C%1==0&&C<U}function A(C,U,k){if(!f(k))return!1;var j=typeof U;return!!(j=="number"?y(k)&&E(U,k.length):j=="string"&&U in k)&&x(k[U],C)}function D(C){var U=C&&C.constructor;return C===(typeof U=="function"&&U.prototype||d)}function x(C,U){return C===U||C!==C&&U!==U}function g(C){return s(C)&&l.call(C,"callee")&&(!m.call(C,"callee")||v.call(C)==u)}function y(C){return C!=null&&o(C.length)&&!e(C)}function s(C){return a(C)&&y(C)}function e(C){var U=f(C)?v.call(C):"";return U==c||U==r}function o(C){return typeof C=="number"&&C>-1&&C%1==0&&C<=t}function f(C){var U=typeof C;return!!C&&(U=="object"||U=="function")}function a(C){return!!C&&typeof C=="object"}function i(C){return y(C)?T(C):S(C)}var t=9007199254740991,u="[object Arguments]",c="[object Function]",r="[object GeneratorFunction]",h=/^(?:0|[1-9]\d*)$/,d=Object.prototype,l=d.hasOwnProperty,v=d.toString,m=d.propertyIsEnumerable,L=function(C,U){return function(k){return C(U(k))}}(Object.keys,Object),b=Math.max,M=!m.call({valueOf:1},"valueOf"),F=Array.isArray,w=function(C){return O(function(U,k){var j=-1,N=k.length,W=N>1?k[N-1]:void 0,Y=N>2?k[2]:void 0;for(W=C.length>3&&typeof W=="function"?(N--,W):void 0,Y&&A(k[0],k[1],Y)&&(W=N<3?void 0:W,N=1),U=Object(U);++j<N;){var K=k[j];K&&C(U,K,j,W)}return U})}(function(C,U){if(M||D(U)||y(U))return void _(U,i(U),C);for(var k in U)l.call(U,k)&&I(C,k,U[k])});P.exports=w},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var p=R(0),T=function(S){return S&&S.__esModule?S:{default:S}}(p),I={};I.now=function(){var S=T.default.performance,O=S&&S.timing;return O&&typeof O.navigationStart=="number"&&typeof S.now=="function"?O.navigationStart+S.now():Date.now()},n.default=I},function(P,n,R){"use strict";function p(T,I,S){S=S===void 0?1:S,T[I]=T[I]||0,T[I]+=S}Object.defineProperty(n,"__esModule",{value:!0}),n.default=p},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var p=R(21),T=function(S){return S&&S.__esModule?S:{default:S}}(p),I=T.default.methodFactory;T.default.methodFactory=function(S,O,_){var E=I(S,O,_);return function(){for(var A=["[mux]"],D=0;D<arguments.length;D++)A.push(arguments[D]);E.apply(void 0,A)}},T.default.setLevel(T.default.getLevel()),n.default=T.default},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var p=function(S){return I(S)[0]},T=function(S){return I(S)[1]},I=function(S){if(typeof S!="string"||S==="")return["localhost"];var O=/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,_=S.match(O)||[],E=_[4],A=void 0;return E&&(A=(E.match(/[^\.]+\.[^\.]+$/)||[])[0]),[E,A]};n.extractHostnameAndDomain=I,n.extractHostname=p,n.extractDomain=T},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var p=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(I){var S=16*Math.random()|0;return(I==="x"?S:3&S|8).toString(16)})},T=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)};n.generateUUID=p,n.generateShortID=T},function(P,n,R){"use strict";function p(I){I=I||"";var S={};return I.trim().split(/[\r\n]+/).forEach(function(O){if(O){var _=O.split(": "),E=_.shift();E&&(T.indexOf(E.toLowerCase())>=0||E.toLowerCase().indexOf("x-litix-")===0)&&(S[E]=_.join(": "))}}),S}Object.defineProperty(n,"__esModule",{value:!0}),n.default=p;var T=["x-cdn","content-type"]},function(P,n,R){"use strict";var p=SyntaxError,T=Function,I=TypeError,S=function(l){try{return T('"use strict"; return ('+l+").constructor;")()}catch{}},O=Object.getOwnPropertyDescriptor;if(O)try{O({},"")}catch{O=null}var _=function(){throw new I},E=O?function(){try{return arguments.callee,_}catch{try{return O(arguments,"callee").get}catch{return _}}}():_,A=R(43)(),D=Object.getPrototypeOf||function(l){return l.__proto__},x={},g=typeof Uint8Array=="undefined"?void 0:D(Uint8Array),y={"%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%":x,"%AsyncGenerator%":x,"%AsyncGeneratorFunction%":x,"%AsyncIteratorPrototype%":x,"%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%":T,"%GeneratorFunction%":x,"%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%":p,"%ThrowTypeError%":E,"%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},s=function l(v){var m;if(v==="%AsyncFunction%")m=S("async function () {}");else if(v==="%GeneratorFunction%")m=S("function* () {}");else if(v==="%AsyncGeneratorFunction%")m=S("async function* () {}");else if(v==="%AsyncGenerator%"){var L=l("%AsyncGeneratorFunction%");L&&(m=L.prototype)}else if(v==="%AsyncIteratorPrototype%"){var b=l("%AsyncGenerator%");b&&(m=D(b.prototype))}return y[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"]},o=R(9),f=R(46),a=o.call(Function.call,Array.prototype.concat),i=o.call(Function.apply,Array.prototype.splice),t=o.call(Function.call,String.prototype.replace),u=o.call(Function.call,String.prototype.slice),c=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,r=/\\(\\)?/g,h=function(l){var v=u(l,0,1),m=u(l,-1);if(v==="%"&&m!=="%")throw new p("invalid intrinsic syntax, expected closing `%`");if(m==="%"&&v!=="%")throw new p("invalid intrinsic syntax, expected opening `%`");var L=[];return t(l,c,function(b,M,F,w){L[L.length]=F?t(w,r,"$1"):M||b}),L},d=function(l,v){var m,L=l;if(f(e,L)&&(m=e[L],L="%"+m[0]+"%"),f(y,L)){var b=y[L];if(b===x&&(b=s(L)),b===void 0&&!v)throw new I("intrinsic "+l+" exists, but is not available. Please file an issue!");return{alias:m,name:L,value:b}}throw new p("intrinsic "+l+" does not exist!")};P.exports=function(l,v){if(typeof l!="string"||l.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=h(l),L=m.length>0?m[0]:"",b=d("%"+L+"%",v),M=b.name,F=b.value,w=!1,C=b.alias;C&&(L=C[0],i(m,a([0,1],C)));for(var U=1,k=!0;U<m.length;U+=1){var j=m[U],N=u(j,0,1),W=u(j,-1);if((N==='"'||N==="'"||N==="`"||W==='"'||W==="'"||W==="`")&&N!==W)throw new p("property names with quotes must have matching quotes");if(j!=="constructor"&&k||(w=!0),L+="."+j,M="%"+L+"%",f(y,M))F=y[M];else if(F!=null){if(!(j in F)){if(!v)throw new I("base intrinsic for "+l+" exists, but the property is not available.");return}if(O&&U+1>=m.length){var Y=O(F,j);k=!!Y,F=k&&"get"in Y&&!("originalValue"in Y.get)?Y.get:F[j]}else k=f(F,j),F=F[j];k&&!w&&(y[M]=F)}}return F}},function(P,n,R){"use strict";var p=R(45);P.exports=Function.prototype.bind||p},function(P,n,R){"use strict";var p=String.prototype.replace,T=/%20/g,I={RFC1738:"RFC1738",RFC3986:"RFC3986"};P.exports={default:I.RFC3986,formatters:{RFC1738:function(S){return p.call(S,T,"+")},RFC3986:function(S){return String(S)}},RFC1738:I.RFC1738,RFC3986:I.RFC3986}},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.findMediaElement=n.getMuxPlayerId=void 0;var p=R(6),T=function(S){return S&&S.nodeName!==void 0?(S.muxId||(S.muxId=S.id||(0,p.generateShortID)()),S.muxId):S},I=function(S){var O=void 0;return S&&S.nodeName!==void 0?(O=S,S=T(O)):O=document.querySelector(S),[O,S,O&&O.nodeName?O.nodeName.toLowerCase():""]};n.getMuxPlayerId=T,n.findMediaElement=I},function(P,n,R){"use strict";function p(){return(I.default.doNotTrack||I.default.navigator&&(I.default.navigator.doNotTrack||I.default.navigator.msDoNotTrack))==="1"}Object.defineProperty(n,"__esModule",{value:!0}),n.default=p;var T=R(0),I=function(S){return S&&S.__esModule?S:{default:S}}(T)},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var p=R(0),T=function(S){return S&&S.__esModule?S:{default:S}}(p),I={};I.exists=function(){var S=T.default.performance;return(S&&S.timing)!==void 0},I.domContentLoadedEventEnd=function(){var S=T.default.performance,O=S&&S.timing;return O&&O.domContentLoadedEventEnd},I.navigationStart=function(){var S=T.default.performance,O=S&&S.timing;return O&&O.navigationStart},n.default=I},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var p=function(T){var I={};for(var S in T){var O=T[S];O["DATA-ID"].search("io.litix.data.")!==-1&&(I[O["DATA-ID"].replace("io.litix.data.","")]=O.VALUE)}return I};n.default=p},function(P,n,R){"use strict";var p=R(41),T=R(51),I=R(10);P.exports={formats:I,parse:T,stringify:p}},function(P,n,R){"use strict";var p=R(10),T=Object.prototype.hasOwnProperty,I=Array.isArray,S=function(){for(var f=[],a=0;a<256;++a)f.push("%"+((a<16?"0":"")+a.toString(16)).toUpperCase());return f}(),O=function(f){for(;f.length>1;){var a=f.pop(),i=a.obj[a.prop];if(I(i)){for(var t=[],u=0;u<i.length;++u)i[u]!==void 0&&t.push(i[u]);a.obj[a.prop]=t}}},_=function(f,a){for(var i=a&&a.plainObjects?Object.create(null):{},t=0;t<f.length;++t)f[t]!==void 0&&(i[t]=f[t]);return i},E=function f(a,i,t){if(!i)return a;if(typeof i!="object"){if(I(a))a.push(i);else{if(!a||typeof a!="object")return[a,i];(t&&(t.plainObjects||t.allowPrototypes)||!T.call(Object.prototype,i))&&(a[i]=!0)}return a}if(!a||typeof a!="object")return[a].concat(i);var u=a;return I(a)&&!I(i)&&(u=_(a,t)),I(a)&&I(i)?(i.forEach(function(c,r){if(T.call(a,r)){var h=a[r];h&&typeof h=="object"&&c&&typeof c=="object"?a[r]=f(h,c,t):a.push(c)}else a[r]=c}),a):Object.keys(i).reduce(function(c,r){var h=i[r];return T.call(c,r)?c[r]=f(c[r],h,t):c[r]=h,c},u)},A=function(f,a){return Object.keys(a).reduce(function(i,t){return i[t]=a[t],i},f)},D=function(f,a,i){var t=f.replace(/\+/g," ");if(i==="iso-8859-1")return t.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(t)}catch{return t}},x=function(f,a,i,t,u){if(f.length===0)return f;var c=f;if(typeof f=="symbol"?c=Symbol.prototype.toString.call(f):typeof f!="string"&&(c=String(f)),i==="iso-8859-1")return escape(c).replace(/%u[0-9a-f]{4}/gi,function(l){return"%26%23"+parseInt(l.slice(2),16)+"%3B"});for(var r="",h=0;h<c.length;++h){var d=c.charCodeAt(h);d===45||d===46||d===95||d===126||d>=48&&d<=57||d>=65&&d<=90||d>=97&&d<=122||u===p.RFC1738&&(d===40||d===41)?r+=c.charAt(h):d<128?r+=S[d]:d<2048?r+=S[192|d>>6]+S[128|63&d]:d<55296||d>=57344?r+=S[224|d>>12]+S[128|d>>6&63]+S[128|63&d]:(h+=1,d=65536+((1023&d)<<10|1023&c.charCodeAt(h)),r+=S[240|d>>18]+S[128|d>>12&63]+S[128|d>>6&63]+S[128|63&d])}return r},g=function(f){for(var a=[{obj:{o:f},prop:"o"}],i=[],t=0;t<a.length;++t)for(var u=a[t],c=u.obj[u.prop],r=Object.keys(c),h=0;h<r.length;++h){var d=r[h],l=c[d];typeof l=="object"&&l!==null&&i.indexOf(l)===-1&&(a.push({obj:c,prop:d}),i.push(l))}return O(a),f},y=function(f){return Object.prototype.toString.call(f)==="[object RegExp]"},s=function(f){return!(!f||typeof f!="object")&&!!(f.constructor&&f.constructor.isBuffer&&f.constructor.isBuffer(f))},e=function(f,a){return[].concat(f,a)},o=function(f,a){if(I(f)){for(var i=[],t=0;t<f.length;t+=1)i.push(a(f[t]));return i}return a(f)};P.exports={arrayToObject:_,assign:A,combine:e,compact:g,decode:D,encode:x,isBuffer:s,isRegExp:y,maybeMap:o,merge:E}},function(P,n,R){"use strict";function p(y){return y&&y.__esModule?y:{default:y}}function T(y){var s={};for(var e in y)y.hasOwnProperty(e)&&(s[y[e]]=e);return s}function I(y){var s={},e={};return Object.keys(y).forEach(function(o){var f=!1;if(y.hasOwnProperty(o)&&y[o]!==void 0){var a=o.split("_"),i=a[0],t=D[i];t||(O.default.info("Data key word `"+a[0]+"` not expected in "+o),t=i+"_"),a.splice(1).forEach(function(u){u==="url"&&(f=!0),g[u]?t+=g[u]:Number(u)&&Math.floor(Number(u))===Number(u)?t+=u:(O.default.info("Data key word `"+u+"` not expected in "+o),t+="_"+u+"_")}),f?e[t]=y[o]:s[t]=y[o]}}),(0,E.default)(s,e)}Object.defineProperty(n,"__esModule",{value:!0}),n.default=I;var S=R(4),O=p(S),_=R(1),E=p(_),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=T(A),x={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=T(x)},function(P,n,R){"use strict";P.exports=R(19).default},function(P,n,R){"use strict";function p(r){return r&&r.__esModule?r:{default:r}}Object.defineProperty(n,"__esModule",{value:!0});var T=function(){function r(h,d){var l=[],v=!0,m=!1,L=void 0;try{for(var b,M=h[Symbol.iterator]();!(v=(b=M.next()).done)&&(l.push(b.value),!d||l.length!==d);v=!0);}catch(F){m=!0,L=F}finally{try{!v&&M.return&&M.return()}finally{if(m)throw L}}return l}return function(h,d){if(Array.isArray(h))return h;if(Symbol.iterator in Object(h))return r(h,d);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),I=R(0),S=p(I),O=R(11),_=R(4),E=p(_),A=R(12),D=p(A),x=R(2),g=p(x),y=R(22),s=p(y),e=R(58),o=p(e),f=R(59),a=p(f),i=R(64),t=p(i),u={},c=function r(h){var d=arguments;typeof h=="string"?r.hasOwnProperty(h)?S.default.setTimeout(function(){d=Array.prototype.splice.call(d,1),r[h].apply(null,d)},0):E.default.warn("`"+h+"` is an unknown task"):typeof h=="function"?S.default.setTimeout(function(){h(r)},0):E.default.warn("`"+h+"` is invalid.")};c.loaded=g.default.now(),c.NAME="mux-embed",c.VERSION="4.8.0",c.API_VERSION="2.1",c.PLAYER_TRACKED=!1,c.monitor=function(r,h){return(0,o.default)(c,r,h)},c.destroyMonitor=function(r){var h=(0,O.findMediaElement)(r),d=T(h,1),l=d[0];l&&l.mux&&typeof l.mux.destroy=="function"?l.mux.destroy():E.default.error("A video element monitor for `"+r+"` has not been initialized via `mux.monitor`.")},c.addHLSJS=function(r,h){var d=(0,O.getMuxPlayerId)(r);u[d]?u[d].addHLSJS(h):E.default.error("A monitor for `"+d+"` has not been initialized.")},c.addDashJS=function(r,h){var d=(0,O.getMuxPlayerId)(r);u[d]?u[d].addDashJS(h):E.default.error("A monitor for `"+d+"` has not been initialized.")},c.removeHLSJS=function(r){var h=(0,O.getMuxPlayerId)(r);u[h]?u[h].removeHLSJS():E.default.error("A monitor for `"+h+"` has not been initialized.")},c.removeDashJS=function(r){var h=(0,O.getMuxPlayerId)(r);u[h]?u[h].removeDashJS():E.default.error("A monitor for `"+h+"` has not been initialized.")},c.init=function(r,h){(0,D.default)()&&h&&h.respectDoNotTrack&&E.default.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var d=(0,O.getMuxPlayerId)(r);u[d]=new s.default(c,d,h)},c.emit=function(r,h,d){var l=(0,O.getMuxPlayerId)(r);u[l]?(u[l].emit(h,d),h==="destroy"&&delete u[l]):E.default.error("A monitor for `"+l+"` has not been initialized.")},S.default!==void 0&&typeof S.default.addEventListener=="function"&&S.default.addEventListener("pagehide",function(r){r.persisted||(c.WINDOW_UNLOADING=!0)},!1),c.checkDoNotTrack=D.default,c.log=E.default,c.utils=a.default,c.events=t.default,n.default=c},function(P,n){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,n,R){var p,T;(function(I,S){"use strict";p=S,(T=typeof p=="function"?p.call(n,R,n,P):p)!==void 0&&(P.exports=T)})(0,function(){"use strict";function I(a,i){var t=a[i];if(typeof t.bind=="function")return t.bind(a);try{return Function.prototype.bind.call(t,a)}catch{return function(){return Function.prototype.apply.apply(t,[a,arguments])}}}function S(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function O(a){return a==="debug"&&(a="log"),typeof console!==g&&(a==="trace"&&y?S:console[a]!==void 0?I(console,a):console.log!==void 0?I(console,"log"):x)}function _(a,i){for(var t=0;t<s.length;t++){var u=s[t];this[u]=t<a?x:this.methodFactory(u,a,i)}this.log=this.debug}function E(a,i,t){return function(){typeof console!==g&&(_.call(this,i,t),this[a].apply(this,arguments))}}function A(a,i,t){return O(a)||E.apply(this,arguments)}function D(a,i,t){function u(m){var L=(s[m]||"silent").toUpperCase();if(typeof window!==g&&l){try{return void(window.localStorage[l]=L)}catch{}try{window.document.cookie=encodeURIComponent(l)+"="+L+";"}catch{}}}function c(){var m;if(typeof window!==g&&l){try{m=window.localStorage[l]}catch{}if(typeof m===g)try{var L=window.document.cookie,b=L.indexOf(encodeURIComponent(l)+"=");b!==-1&&(m=/^([^;]+)/.exec(L.slice(b))[1])}catch{}return d.levels[m]===void 0&&(m=void 0),m}}function r(){if(typeof window!==g&&l){try{return void window.localStorage.removeItem(l)}catch{}try{window.document.cookie=encodeURIComponent(l)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}var h,d=this;i=i==null?"WARN":i;var l="loglevel";typeof a=="string"?l+=":"+a:typeof a=="symbol"&&(l=void 0),d.name=a,d.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},d.methodFactory=t||A,d.getLevel=function(){return h},d.setLevel=function(m,L){if(typeof m=="string"&&d.levels[m.toUpperCase()]!==void 0&&(m=d.levels[m.toUpperCase()]),!(typeof m=="number"&&m>=0&&m<=d.levels.SILENT))throw"log.setLevel() called with invalid level: "+m;if(h=m,L!==!1&&u(m),_.call(d,m,a),typeof console===g&&m<d.levels.SILENT)return"No console available for logging"},d.setDefaultLevel=function(m){i=m,c()||d.setLevel(m,!1)},d.resetLevel=function(){d.setLevel(i,!1),r()},d.enableAll=function(m){d.setLevel(d.levels.TRACE,m)},d.disableAll=function(m){d.setLevel(d.levels.SILENT,m)};var v=c();v==null&&(v=i),d.setLevel(v,!1)}var x=function(){},g="undefined",y=typeof window!==g&&typeof window.navigator!==g&&/Trident\/|MSIE /.test(window.navigator.userAgent),s=["trace","debug","info","warn","error"],e=new D,o={};e.getLogger=function(a){if(typeof a!="symbol"&&typeof a!="string"||a==="")throw new TypeError("You must supply a name when creating a logger.");var i=o[a];return i||(i=o[a]=new D(a,e.getLevel(),e.methodFactory)),i};var f=typeof window!==g?window.log:void 0;return e.noConflict=function(){return typeof window!==g&&window.log===e&&(window.log=f),e},e.getLoggers=function(){return o},e.default=e,e})},function(P,n,R){"use strict";function p(ee){return ee&&ee.__esModule?ee:{default:ee}}Object.defineProperty(n,"__esModule",{value:!0});var T=function(){function ee(Z,q){var fe=[],ge=!0,ie=!1,me=void 0;try{for(var ye,Te=Z[Symbol.iterator]();!(ge=(ye=Te.next()).done)&&(fe.push(ye.value),!q||fe.length!==q);ge=!0);}catch(oe){ie=!0,me=oe}finally{try{!ge&&Te.return&&Te.return()}finally{if(ie)throw me}}return fe}return function(Z,q){if(Array.isArray(Z))return Z;if(Symbol.iterator in Object(Z))return ee(Z,q);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),I=R(4),S=p(I),O=R(1),_=p(O),E=R(6),A=R(5),D=R(0),x=p(D),g=R(13),y=p(g),s=R(3),e=p(s),o=R(23),f=R(24),a=R(25),i=p(a),t=R(26),u=p(t),c=R(27),r=p(c),h=R(28),d=p(h),l=R(29),v=p(l),m=R(30),L=p(m),b=R(31),M=p(b),F=R(32),w=p(F),C=R(33),U=p(C),k=R(34),j=p(k),N=R(35),W=p(N),Y=R(36),K=p(Y),H=R(37),z=p(H),$=R(38),X=p($),J=R(39),te=p(J),Q=R(57),ae=p(Q),se=["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"],re=function(ee,Z,q){var fe=this;this.DOM_CONTENT_LOADED_EVENT_END=y.default.domContentLoadedEventEnd(),this.NAVIGATION_START=y.default.navigationStart();var ge={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=ee,this.id=Z,q=(0,_.default)(ge,q),q.data=q.data||{},q.data.property_key&&(q.data.env_key=q.data.property_key,delete q.data.property_key),S.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 te.default(ee,q.data.env_key,q),this.data={player_instance_id:(0,E.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,de){de=(0,_.default)({viewer_time:this.mux.utils.now()},de),this.oldEmit(oe,de)};var ie=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,de){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),(0,_.default)(this.data,de),this._initializeViewData(),this.one("play",ie),this.one("adbreakstart",ie)});var me=function(oe){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",oe)}.bind(this);if(this.on("videochange",function(oe,de){me(de)}),this.on("programchange",function(oe,de){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,_.default)(de,{view_program_changed:!0})),ie(),this.emit("play"),this.emit("playing")}),this.on("fragmentchange",function(oe,de){this.currentFragmentPDT=de.currentFragmentPDT,this.currentFragmentStart=de.currentFragmentStart}),this.on("destroy",this.destroy),x.default!==void 0&&typeof x.default.addEventListener=="function"&&typeof x.default.removeEventListener=="function"){var ye=function(oe){oe.persisted||fe.destroy()};x.default.addEventListener("pagehide",ye,!1),this.on("destroy",function(){x.default.removeEventListener("pagehide",ye)})}this.on("playerready",function(oe,de){(0,_.default)(this.data,de)}),se.forEach(function(oe){fe.on(oe,function(de,Se){oe.indexOf("ad")!==0&&this._updateStateData(),(0,_.default)(this.data,Se),this._sanitizeData()}),fe.on("after"+oe,function(){(oe!=="error"||this.viewErrored)&&this.send(oe)})}),this.on("viewend",function(oe,de){(0,_.default)(fe.data,de)});var Te=function(oe){var de=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=de-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",Te),r.default.apply(this),X.default.apply(this),W.default.apply(this),L.default.apply(this),u.default.apply(this),j.default.apply(this),d.default.apply(this),v.default.apply(this),K.default.apply(this),M.default.apply(this),w.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)(re.prototype,i.default.prototype),(0,_.default)(re.prototype,L.default.prototype),(0,_.default)(re.prototype,W.default.prototype),(0,_.default)(re.prototype,u.default.prototype),(0,_.default)(re.prototype,d.default.prototype),(0,_.default)(re.prototype,v.default.prototype),(0,_.default)(re.prototype,K.default.prototype),(0,_.default)(re.prototype,w.default.prototype),(0,_.default)(re.prototype,U.default.prototype),re.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(),x.default.clearTimeout(this._heartBeatTimeout))},re.prototype.send=function(ee){var Z=(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(Z.video_source_is_live===void 0&&(Z.player_source_duration===1/0||Z.video_source_duration===1/0?Z.video_source_is_live=!0:(Z.player_source_duration>0||Z.video_source_duration>0)&&(Z.video_source_is_live=!1)),Z.video_source_is_live||q.forEach(function(ye){Z[ye]=void 0}),Z.video_source_url=Z.video_source_url||Z.player_source_url,Z.video_source_url){var fe=(0,A.extractHostnameAndDomain)(Z.video_source_url),ge=T(fe,2),ie=ge[0],me=ge[1];Z.video_source_domain=me,Z.video_source_hostname=ie}delete Z.ad_request_id,this.playbackEventDispatcher.send(ee,Z),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()},re.prototype._updateStateData=function(){(0,_.default)(this.data,this.getStateData()),this._updatePlayheadTime(),this._sanitizeData()},re.prototype._sanitizeData=function(){var ee=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(Z){var q=parseInt(ee.data[Z],10);ee.data[Z]=isNaN(q)?void 0:q}),["player_source_url","video_source_url"].forEach(function(Z){if(ee.data[Z]){var q=ee.data[Z].toLowerCase();q.indexOf("data:")!==0&&q.indexOf("blob:")!==0||(ee.data[Z]="MSE style URL")}})},re.prototype._resetVideoData=function(ee,Z){var q=this;Object.keys(this.data).forEach(function(fe){fe.indexOf("video_")===0&&delete q.data[fe]})},re.prototype._resetViewData=function(){var ee=this;Object.keys(this.data).forEach(function(Z){Z.indexOf("view_")===0&&delete ee.data[Z]}),this.data.view_sequence_number=1},re.prototype._resetErrorData=function(ee,Z){delete this.data.player_error_code,delete this.data.player_error_message},re.prototype._initializeViewData=function(){var ee=this,Z=this.data.view_id=(0,E.generateUUID)(),q=function(){Z===ee.data.view_id&&(0,e.default)(ee.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",q):q()},re.prototype._restartHeartBeat=function(){var ee=this;x.default.clearTimeout(this._heartBeatTimeout),this.viewErrored||(this._heartBeatTimeout=x.default.setTimeout(function(){ee.data.player_is_paused||ee.emit("hb")},1e4))},re.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,o.monitorHlsJs)(this.mux,this.id,ee.hlsjs,{},ee.Hls||x.default.Hls)):void this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")},re.prototype.removeHLSJS=function(){this.hlsjs&&((0,o.stopMonitoringHlsJs)(this.hlsjs),this.hlsjs=void 0)},re.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,f.monitorDashJS)(this.mux,this.id,ee.dashjs)):void this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")},re.prototype.removeDashJS=function(){this.dashjs&&((0,f.stopMonitoringDashJS)(this.dashjs),this.dashjs=void 0)},n.default=re},function(P,n,R){"use strict";function p(s){return s&&s.__esModule?s:{default:s}}Object.defineProperty(n,"__esModule",{value:!0}),n.stopMonitoringHlsJs=n.monitorHlsJs=void 0;var T=R(7),I=p(T),S=R(13),O=p(S),_=R(5),E=R(14),A=p(E),D=function(s){if(!s)return{};var e=O.default.navigationStart(),o=s.loading,f=o?o.start:s.trequest,a=o?o.first:s.tfirst,i=o?o.end:s.tload;return{bytesLoaded:s.total,requestStart:Math.round(e+f),responseStart:Math.round(e+a),responseEnd:Math.round(e+i)}},x=function(s){if(s&&typeof s.getAllResponseHeaders=="function")return(0,I.default)(s.getAllResponseHeaders())},g=function(s,e,o){var f=(arguments.length>3&&arguments[3]!==void 0&&arguments[3],arguments[4]),a=s.log,i=s.utils.secondsToMs,t=function(b){var M=parseInt(f.version),F=void 0;return M===1&&b.programDateTime!==null&&(F=b.programDateTime),M===0&&b.pdt!==null&&(F=b.pdt),F};if(!O.default.exists())return void a.warn("performance timing not supported. Not tracking HLS.js.");var u=function(b,M){return s.emit(e,b,M)},c=function(b,M){var F=M.levels,w=M.audioTracks,C=M.url,U=M.stats,k=M.networkDetails,j=M.sessionData,N={},W={},Y={};Y=(0,A.default)(j),F.forEach(function(J,te){N[te]={width:J.width,height:J.height,bitrate:J.bitrate,attrs:J.attrs}}),w.forEach(function(J,te){W[te]={name:J.name,language:J.lang,bitrate:J.bitrate}});var K=D(U),H=K.bytesLoaded,z=K.requestStart,$=K.responseStart,X=K.responseEnd;Y.request_event_type=b,Y.request_bytes_loaded=H,Y.request_start=z,Y.request_response_start=$,Y.request_response_end=X,Y.request_type="manifest",Y.request_hostname=(0,_.extractHostname)(C),Y.request_response_headers=x(k),Y.request_rendition_lists={media:N,audio:W,video:{}},u("requestcompleted",Y)};o.on(f.Events.MANIFEST_LOADED,c);var r=function(b,M){var F=M.details,w=M.level,C=M.networkDetails,U=M.stats,k=D(U),j=k.bytesLoaded,N=k.requestStart,W=k.responseStart,Y=k.responseEnd,K=F.fragments[F.fragments.length-1],H=t(K)+i(K.duration);u("requestcompleted",{request_event_type:b,request_bytes_loaded:j,request_start:N,request_response_start:W,request_response_end:Y,request_current_level:w,request_type:"manifest",request_hostname:(0,_.extractHostname)(F.url),request_response_headers:x(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(H)?void 0:H})};o.on(f.Events.LEVEL_LOADED,r);var h=function(b,M){var F=M.details,w=M.networkDetails,C=M.stats,U=D(C),k=U.bytesLoaded,j=U.requestStart,N=U.responseStart,W=U.responseEnd;u("requestcompleted",{request_event_type:b,request_bytes_loaded:k,request_start:j,request_response_start:N,request_response_end:W,request_type:"manifest",request_hostname:(0,_.extractHostname)(F.url),request_response_headers:x(w)})};o.on(f.Events.AUDIO_TRACK_LOADED,h);var d=function(b,M){var F=M.stats,w=M.networkDetails,C=M.frag,U=D(F),k=U.bytesLoaded,j=U.requestStart,N=U.responseStart,W=U.responseEnd,Y={request_event_type:b,request_bytes_loaded:k,request_start:j,request_response_start:N,request_response_end:W,request_hostname:w?(0,_.extractHostname)(w.responseURL):void 0,request_response_headers:x(w),request_media_duration:C.duration};C.type==="main"?(Y.request_type="media",Y.request_current_level=C.level,Y.request_video_width=(o.levels[C.level]||{}).width,Y.request_video_height=(o.levels[C.level]||{}).height):Y.request_type=C.type,u("requestcompleted",Y)};o.on(f.Events.FRAG_LOADED,d);var l=function(b,M){var F=M.frag,w=F.start,C=t(F),U={currentFragmentPDT:C,currentFragmentStart:i(w)};u("fragmentchange",U)};o.on(f.Events.FRAG_CHANGED,l);var v=function(b,M){var F=M.type,w=M.details,C=M.response,U=M.fatal,k=M.context,j=M.frag;if(w===f.ErrorDetails.MANIFEST_LOAD_ERROR||w===f.ErrorDetails.MANIFEST_LOAD_TIMEOUT||w===f.ErrorDetails.FRAG_LOAD_ERROR||w===f.ErrorDetails.FRAG_LOAD_TIMEOUT||w===f.ErrorDetails.LEVEL_LOAD_ERROR||w===f.ErrorDetails.LEVEL_LOAD_TIMEOUT){var N=j&&j.url||k&&k.url||"";u("requestfailed",{request_error:w,request_url:N,request_hostname:(0,_.extractHostname)(N),request_type:w===f.ErrorDetails.FRAG_LOAD_ERROR||w===f.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:C&&C.code,request_error_text:C&&C.text})}U&&u("error",{player_error_code:F,player_error_message:w})};o.on(f.Events.ERROR,v);var m=function(b,M){var F=M.frag,w=F&&F._url||"";u("requestcanceled",{request_cancel:b,request_url:w,request_type:"media",request_hostname:(0,_.extractHostname)(w)})};o.on(f.Events.FRAG_LOAD_EMERGENCY_ABORTED,m);var L=function(b,M){var F=M.level,w=o.levels[F];if(w&&w.attrs&&w.attrs.BANDWIDTH){var C=w.attrs.BANDWIDTH;C?u("renditionchange",{video_source_bitrate:C,video_source_width:w.width,video_source_height:w.height}):a.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};o.on(f.Events.LEVEL_SWITCHED,L),o._stopMuxMonitor=function(){o.off(f.Events.MANIFEST_LOADED,c),o.off(f.Events.LEVEL_LOADED,r),o.off(f.Events.AUDIO_TRACK_LOADED,h),o.off(f.Events.FRAG_LOADED,d),o.off(f.Events.FRAG_CHANGED,l),o.off(f.Events.ERROR,v),o.off(f.Events.FRAG_LOAD_EMERGENCY_ABORTED,m),o.off(f.Events.LEVEL_SWITCHED,L),o.off(f.Events.DESTROYING,o._stopMuxMonitor),delete o._stopMuxMonitor},o.on(f.Events.DESTROYING,o._stopMuxMonitor)},y=function(s){s&&typeof s._stopMuxMonitor=="function"&&s._stopMuxMonitor()};n.monitorHlsJs=g,n.stopMonitoringHlsJs=y},function(P,n,R){"use strict";function p(g){return g&&g.__esModule?g:{default:g}}Object.defineProperty(n,"__esModule",{value:!0}),n.stopMonitoringDashJS=n.monitorDashJS=void 0;var T=R(0),I=p(T),S=R(7),O=p(S),_=R(5),E=function(g,y){if(!g||typeof g.getRequests!="function")return{};var s=g.getRequests({state:"executed"});if(s.length===0)return{};var e=s[s.length-1],o=(0,_.extractHostname)(e.url),f=e.bytesLoaded,a=new Date(e.requestStartDate).getTime(),i=new Date(e.firstByteDate).getTime(),t=new Date(e.requestEndDate).getTime(),u=isNaN(e.duration)?0:e.duration,c=typeof y.getMetricsFor=="function"?y.getMetricsFor(e.mediaType).HttpList:y.getDashMetrics().getHttpRequests(e.mediaType),r=void 0;return c.length>0&&(r=(0,O.default)(c[c.length-1]._responseHeaders||"")),{requestStart:a,requestResponseStart:i,requestResponseEnd:t,requestBytesLoaded:f,requestResponseHeaders:r,requestMediaDuration:u,requestHostname:o}},A=function(g,y){var s=y.getQualityFor(g),e=y.getCurrentTrackFor(g),o=e.bitrateList;return o?{currentLevel:s,renditionWidth:o[s].width||null,renditionHeight:o[s].height||null,renditionBitrate:o[s].bandwidth}:{}},D=function(g,y,s){var e=(arguments.length>3&&arguments[3]!==void 0&&arguments[3],g.log);if(!s||!s.on)return void e.warn("Invalid dash.js player reference. Monitoring blocked.");var o=function(d,l){return g.emit(y,d,l)},f=function(d){var l=d.type,v=d.data,m=v||{},L=m.url;o("requestcompleted",{request_event_type:l,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:(0,_.extractHostname)(L)})};s.on("manifestLoaded",f);var a={},i=function(d){var l=d.type,v=d.fragmentModel,m=d.chunk,L=m||{},b=L.mediaInfo,M=b||{},F=M.type,w=M.bitrateList;w=w||[];var C={};w.forEach(function(H,z){C[z]={},C[z].width=H.width,C[z].height=H.height,C[z].bitrate=H.bandwidth,C[z].attrs={}}),F==="video"?a.video=C:F==="audio"?a.audio=C:a.media=C;var U=E(v,s),k=U.requestStart,j=U.requestResponseStart,N=U.requestResponseEnd,W=U.requestResponseHeaders,Y=U.requestMediaDuration,K=U.requestHostname;o("requestcompleted",{request_event_type:l,request_start:k,request_response_start:j,request_response_end:N,request_bytes_loaded:-1,request_type:F+"_init",request_response_headers:W,request_hostname:K,request_media_duration:Y,request_rendition_lists:a})};s.on("initFragmentLoaded",i);var t=function(d){var l=d.type,v=d.fragmentModel,m=d.chunk,L=m||{},b=L.mediaInfo,M=L.start,F=b||{},w=F.type,C=E(v,s),U=C.requestStart,k=C.requestResponseStart,j=C.requestResponseEnd,N=C.requestBytesLoaded,W=C.requestResponseHeaders,Y=C.requestMediaDuration,K=C.requestHostname,H=A(w,s),z=H.currentLevel,$=H.renditionWidth,X=H.renditionHeight,J=H.renditionBitrate;o("requestcompleted",{request_event_type:l,request_start:U,request_response_start:k,request_response_end:j,request_bytes_loaded:N,request_type:w,request_response_headers:W,request_hostname:K,request_media_start_time:M,request_media_duration:Y,request_current_level:z,request_labeled_bitrate:J,request_video_width:$,request_video_height:X})};s.on("mediaFragmentLoaded",t);var u={video:void 0,audio:void 0,totalBitrate:void 0},c=function(){if(u.video&&typeof u.video.bitrate=="number"){if(!u.video.width||!u.video.height)return void e.warn("have bitrate info for video but missing width/height");var d=u.video.bitrate;return u.audio&&typeof u.audio.bitrate=="number"&&(d+=u.audio.bitrate),d!==u.totalBitrate?(u.totalBitrate=d,{video_source_bitrate:d,video_source_height:u.video.height,video_source_width:u.video.width}):void 0}},r=function(d,l,v){if(typeof d.newQuality!="number")return void e.warn("missing evt.newQuality in qualityChangeRendered event",d);var m=d.mediaType;if(m==="audio"||m==="video"){var L=s.getBitrateInfoListFor(m).find(function(M){return M.qualityIndex===d.newQuality});if(!L||typeof L.bitrate!="number")return void e.warn("missing bitrate info for "+m);u[m]=L;var b=c();b&&o("renditionchange",b)}};s.on("qualityChangeRendered",r);var h=function(d){var l=d.error,v=d.event;v=v||{};var m=v.request||{},L=I.default.event&&I.default.event.currentTarget||{};o("requestfailed",{request_error:l+"_"+v.id+"_"+m.type,request_url:v.url,request_hostname:(0,_.extractHostname)(v.url),request_type:m.mediaType,request_error_code:L.status,request_error_type:L.statusText})};s.on("error",h),s._stopMuxMonitor=function(){s.off("manifestLoaded",f),s.off("initFragmentLoaded",i),s.off("mediaFragmentLoaded",t),s.off("qualityChangeRendered",r),s.off("error",h),delete s._stopMuxMonitor}},x=function(g){g&&typeof g._stopMuxMonitor=="function"&&g._stopMuxMonitor()};n.monitorDashJS=D,n.stopMonitoringDashJS=x},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var p=function(){},T=0;p.prototype.on=function(I,S,O){return S._eventEmitterGuid=S._eventEmitterGuid||++T,this._listeners=this._listeners||{},this._listeners[I]=this._listeners[I]||[],O&&(S=S.bind(O)),this._listeners[I].push(S),S},p.prototype.off=function(I,S){var O=this._listeners&&this._listeners[I];O&&O.forEach(function(_,E){_._eventEmitterGuid===S._eventEmitterGuid&&O.splice(E,1)})},p.prototype.one=function(I,S,O){var _=this;S._eventEmitterGuid=S._eventEmitterGuid||++T;var E=function A(){_.off(I,A),S.apply(O||this,arguments)};E._eventEmitterGuid=S._eventEmitterGuid,this.on(I,E)},p.prototype.emit=function(I,S){var O=this;if(this._listeners){S=S||{};var _=this._listeners["before*"]||[],E=this._listeners[I]||[],A=this._listeners["after"+I]||[],D=function(x,g){x=x.slice(),x.forEach(function(y){y.call(O,{type:I},g)})};D(_,S),D(E,S),D(A,S)}},n.default=p},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var p=R(0),T=function(S){return S&&S.__esModule?S:{default:S}}(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(S,O){this._playbackHeartbeatInterval!==null&&(T.default.clearInterval(this._playbackHeartbeatInterval),this.emit("playbackheartbeatend",{viewer_time:O.viewer_time}),this._playbackHeartbeatInterval=null)})};I.prototype._startPlaybackHeartbeatInterval=function(){var S=this;this._playbackHeartbeatInterval===null&&(this.emit("playbackheartbeat"),this._playbackHeartbeatInterval=T.default.setInterval(function(){S.emit("playbackheartbeat")},this.playbackHeartbeatTime))},I.prototype._stopPlaybackHeartbeatInterval=function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(T.default.clearInterval(this._playbackHeartbeatInterval),this.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)},n.default=I},function(P,n,R){"use strict";function p(){var T=this;this.on("viewinit",function(){T.viewErrored=!1}),this.on("error",function(){try{var I=T.errorTranslator({player_error_code:T.data.player_error_code,player_error_message:T.data.player_error_message});I?(T.data.player_error_code=I.player_error_code,T.data.player_error_message=I.player_error_message,T.viewErrored=!0):(delete T.data.player_error_code,delete T.data.player_error_message)}catch(S){T.mux.log.warn("Exception in error translator callback.",S),T.viewErrored=!0}})}Object.defineProperty(n,"__esModule",{value:!0}),n.default=p},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var p=R(3),T=function(S){return S&&S.__esModule?S:{default:S}}(p),I=function(){this._watchTimeTrackerLastCheckedTime=null,this.on("playbackheartbeat",this._updateWatchTime),this.on("playbackheartbeatend",this._clearWatchTimeState)};I.prototype._updateWatchTime=function(S,O){var _=O.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=_),(0,T.default)(this.data,"view_watch_time",_-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=_},I.prototype._clearWatchTimeState=function(S,O){this._updateWatchTime(S,O),this._watchTimeTrackerLastCheckedTime=null},n.default=I},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var p=R(3),T=function(S){return S&&S.__esModule?S:{default:S}}(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 S=this.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&S>this._playbackTimeTrackerLastPlayheadPosition){var O=S-this._playbackTimeTrackerLastPlayheadPosition;O<=1e3&&(0,T.default)(this.data,"view_content_playback_time",O)}this._playbackTimeTrackerLastPlayheadPosition=S},I.prototype._clearPlaybackTimeState=function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1},n.default=I},function(P,n,R){"use strict";Object.defineProperty(n,"__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(T,I){var S=this,O=function(){S.currentFragmentPDT&&S.currentFragmentStart&&(S.data.player_program_time=S.currentFragmentPDT+S.data.player_playhead_time-S.currentFragmentStart)};if(I&&I.player_playhead_time)this.data.player_playhead_time=I.player_playhead_time,O(),this._updateMaxPlayheadPosition();else if(this.getPlayheadTime){var _=this.getPlayheadTime();_!==void 0&&(this.data.player_playhead_time=_,O(),this._updateMaxPlayheadPosition())}},n.default=p},function(P,n,R){"use strict";function p(){var S=this;if(!this.disableRebufferTracking){var O=void 0,_=function(){if(O){var E=S.data.viewer_time-O;(0,I.default)(S.data,"view_rebuffer_duration",E),O=S.data.viewer_time}S.data.view_watch_time>=0&&S.data.view_rebuffer_count>0&&(S.data.view_rebuffer_frequency=S.data.view_rebuffer_count/S.data.view_watch_time,S.data.view_rebuffer_percentage=S.data.view_rebuffer_duration/S.data.view_watch_time)};this.on("playbackheartbeat",function(){return _()}),this.on("rebufferstart",function(){O||((0,I.default)(S.data,"view_rebuffer_count",1),O=S.data.viewer_time,S.one("rebufferend",function(){_(),O=void 0}))})}}Object.defineProperty(n,"__esModule",{value:!0}),n.default=p;var T=R(3),I=function(S){return S&&S.__esModule?S:{default:S}}(T)},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var p=R(2),T=function(S){return S&&S.__esModule?S:{default:S}}(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:T.default.now()})}))};I.prototype._checkIfRebuffering=function(S,O){return this.isSeeking||this.isAdBreak||!this._playheadShouldBeProgressing?void this._cleanupRebufferTracker(S,O):this._lastCheckedTime===null?void this._prepareRebufferTrackerState(O.viewer_time):this._lastPlayheadTime!==this.data.player_playhead_time?void this._cleanupRebufferTracker(S,O,!0):(O.viewer_time-this._lastPlayheadTimeUpdatedTime>=this.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),void(this._lastCheckedTime=O.viewer_time))},I.prototype._clearRebufferTrackerState=function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null},I.prototype._prepareRebufferTrackerState=function(S){this._lastCheckedTime=S,this._lastPlayheadTime=this.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=S},I.prototype._cleanupRebufferTracker=function(S,O){var _=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.emit("rebufferend",{viewer_time:O.viewer_time});else{if(this._lastCheckedTime===null)return;var E=this.data.player_playhead_time-this._lastPlayheadTime,A=O.viewer_time-this._lastPlayheadTimeUpdatedTime;E>0&&A-E>this.minimumRebufferDuration&&(this.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+A-E}))}_?this._prepareRebufferTrackerState(O.viewer_time):this._clearRebufferTrackerState()},n.default=I},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var p=R(2),T=function(S){return S&&S.__esModule?S:{default:S}}(p),I=function(){this.on("viewinit",function(){var S=this.data,O=S.view_id;if(!S.view_program_changed){var _=function(E,A){var D=A.viewer_time;E.type==="playing"&&this.data.view_time_to_first_frame===void 0?this.calculateTimeToFirstFrame(D||T.default.now(),O):E.type!=="adplaying"||this.data.view_time_to_first_frame!==void 0&&!this.inPrerollPosition()||this.calculateTimeToFirstFrame(D||T.default.now(),O)};this.one("playing",_),this.one("adplaying",_),this.one("viewend",function(){this.off("playing",_),this.off("adplaying",_)})}})};I.prototype.calculateTimeToFirstFrame=function(S,O){O===this.data.view_id&&(this._updateWatchTime(null,{viewer_time:S}),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))},n.default=I},function(P,n,R){"use strict";function p(){var S=this;this.on("viewinit",function(){this._lastPlayheadPosition=-1});var O=["pause","rebufferstart","seeking","error","adbreakstart","hb"],_=["playing","hb"];O.forEach(function(E){S.on(E,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),x=Math.max(0,D-1),g=Math.max(0,1-D);this.data.view_max_upscale_percentage=Math.max(this.data.view_max_upscale_percentage||0,x),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",A),(0,I.default)(this.data,"view_total_upscaling",x*A),(0,I.default)(this.data,"view_total_downscaling",g*A)}this._lastPlayheadPosition=-1})}),_.forEach(function(E){S.on(E,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(n,"__esModule",{value:!0}),n.default=p;var T=R(3),I=function(S){return S&&S.__esModule?S:{default:S}}(T)},function(P,n,R){"use strict";function p(D){return D&&D.__esModule?D:{default:D}}function T(){this.isSeeking=!1,this.on("seeking",function(D,x){(0,A.default)(this.data,x),this._lastSeekingTime=S.default.now(),this.isSeeking===!1&&(this.isSeeking=!0,this.send("seeking"))}),this.on("seeked",function(){this.isSeeking=!1;var D=this._lastSeekingTime||S.default.now(),x=S.default.now()-D;(0,_.default)(this.data,"view_seek_count",1),(0,_.default)(this.data,"view_seek_duration",x);var g=this.data.view_max_seek_time||0;this.data.view_max_seek_time=Math.max(g,x)}),this.on("viewend",function(){this.isSeeking=!1})}Object.defineProperty(n,"__esModule",{value:!0}),n.default=T;var I=R(2),S=p(I),O=R(3),_=p(O),E=R(1),A=p(E)},function(P,n,R){"use strict";function p(g){return g&&g.__esModule?g:{default:g}}Object.defineProperty(n,"__esModule",{value:!0});var T=function(){function g(y,s){var e=[],o=!0,f=!1,a=void 0;try{for(var i,t=y[Symbol.iterator]();!(o=(i=t.next()).done)&&(e.push(i.value),!s||e.length!==s);o=!0);}catch(u){f=!0,a=u}finally{try{!o&&t.return&&t.return()}finally{if(f)throw a}}return e}return function(y,s){if(Array.isArray(y))return y;if(Symbol.iterator in Object(y))return g(y,s);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),I=R(3),S=p(I),O=R(5),_=R(1),E=p(_),A=function(g,y){g.push(y),g.sort(function(s,e){return s.viewer_time-e.viewer_time})},D=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],x=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}),D.forEach(function(s){return g.on(s,g._updateAdData)});var y=function(){g.isAdBreak=!1};this.on("adbreakstart",function(){this.isAdBreak=!0}),this.on("play",y),this.on("playing",y),this.on("viewend",y),this.on("adrequest",function(s,e){e=(0,E.default)({ad_request_id:"generatedAdRequestId"+this._currentAdRequestNumber++},e),A(this._adRequests,e),(0,S.default)(this.data,"view_ad_request_count"),this.inPrerollPosition()&&(this.data.view_preroll_requested=!0,this._adHasPlayed||(0,S.default)(this.data,"view_preroll_request_count"))}),this.on("adresponse",function(s,e){e=(0,E.default)({ad_request_id:"generatedAdRequestId"+this._currentAdResponseNumber++},e),A(this._adResponses,e);var o=this.findAdRequest(e.ad_request_id);o&&(0,S.default)(this.data,"view_ad_request_time",Math.max(0,e.viewer_time-o.viewer_time))}),this.on("adplay",function(s,e){this._adHasPlayed=!0,this._wouldBeNewAdPlay&&(this._wouldBeNewAdPlay=!1,(0,S.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})};x.prototype.inPrerollPosition=function(){return this.data.view_content_playback_time===void 0||this.data.view_content_playback_time<=1e3},x.prototype.findAdRequest=function(g){for(var y=0;y<this._adRequests.length;y++)if(this._adRequests[y].ad_request_id===g)return this._adRequests[y]},x.prototype._updateAdData=function(g,y){if(this.inPrerollPosition()){if(!this.data.view_preroll_ad_tag_hostname&&y.ad_tag_url){var s=(0,O.extractHostnameAndDomain)(y.ad_tag_url),e=T(s,2),o=e[0],f=e[1];this.data.view_preroll_ad_tag_domain=f,this.data.view_preroll_ad_tag_hostname=o}if(!this.data.view_preroll_ad_asset_hostname&&y.ad_asset_url){var a=(0,O.extractHostnameAndDomain)(y.ad_asset_url),i=T(a,2),t=i[0],u=i[1];this.data.view_preroll_ad_asset_domain=u,this.data.view_preroll_ad_asset_hostname=t}}},n.default=x},function(P,n,R){"use strict";function p(E){return E&&E.__esModule?E:{default:E}}function T(){var E=this,A=void 0,D=void 0,x=function(){E.disableRebufferTracking||((0,_.default)(E.data,"view_waiting_rebuffer_count",1),A=S.default.now(),D=window.setInterval(function(){if(A){var o=S.default.now();(0,_.default)(E.data,"view_waiting_rebuffer_duration",o-A),A=o}},250))},g=function(){E.disableRebufferTracking||A&&((0,_.default)(E.data,"view_waiting_rebuffer_duration",S.default.now()-A),A=!1,window.clearInterval(D))},y=!1,s=function(){y=!0},e=function(){y=!1,g()};this.on("waiting",function(){y&&x()}),this.on("playing",function(){g(),s()}),this.on("pause",e),this.on("seeking",e)}Object.defineProperty(n,"__esModule",{value:!0}),n.default=T;var I=R(2),S=p(I),O=R(3),_=p(O)},function(P,n,R){"use strict";function p(D){return D&&D.__esModule?D:{default:D}}function T(){var D=this;this.one("playbackheartbeat",E),this.on("playbackheartbeatend",function(){D.off("before*",A),D.one("playbackheartbeat",E)})}Object.defineProperty(n,"__esModule",{value:!0}),n.default=T;var I=R(1),S=p(I),O=R(2),_=p(O),E=function(){this.lastWallClockTime=_.default.now(),this.on("before*",A)},A=function(D){var x=_.default.now(),g=this.lastWallClockTime;this.lastWallClockTime=x,x-g>3e4&&(this.emit("devicesleep",{viewer_time:g}),(0,S.default)(this.data,{viewer_time:g}),this.send("devicesleep"),this.emit("devicewake",{viewer_time:x}),(0,S.default)(this.data,{viewer_time:x}),this.send("devicewake"))}},function(P,n,R){"use strict";function p(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(n,"__esModule",{value:!0});var T=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},I=R(0),S=p(I),O=R(40),_=R(4),E=p(_),A=R(53),D=p(A),x=R(12),g=p(x),y=R(54),s=p(y),e=R(17),o=p(e),f=R(55),a=p(f),i=R(1),t=p(i),u=["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"],c=["viewstart","error","ended","viewend"],r=function(l,v){var m=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.mux=l,this.envKey=v,this.eventQueue=new a.default((0,D.default)(v,m)),this.previousBeaconData=null,this.lastEventTime=null,this.sampleRate=m.sampleRate,this.disableCookies=m.disableCookies,this.respectDoNotTrack=m.respectDoNotTrack;var L=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:L.name,viewer_application_version:L.version,viewer_application_engine:L.layout,viewer_device_name:L.product,viewer_device_category:"",viewer_device_manufacturer:L.manufacturer,viewer_os_family:L.os&&L.os.family,viewer_os_architecture:L.os&&L.os.architecture,viewer_os_version:L.os&&L.os.version};var b=(0,s.default)();b&&(this.pageLevelData=(0,t.default)(this.pageLevelData,{viewer_connection_type:b})),S.default!==void 0&&S.default.location&&S.default.location.href&&(this.pageLevelData.page_url=S.default.location.href),this.viewerData=this.disableCookies?{}:(0,O.getAndUpdateViewerData)()};r.prototype.send=function(l,v){if(l){if(this.respectDoNotTrack&&(0,g.default)())return E.default.info("Not sending `"+l+"` because Do Not Track is enabled");if(!v||(v===void 0?"undefined":T(v))!=="object")return E.default.error("A data object was expected in send() but was not provided");var m=this.disableCookies?{}:(0,O.getAndUpdateSessionData)(),L={};(0,t.default)(L,this.pageLevelData),(0,t.default)(L,v),(0,t.default)(L,m),(0,t.default)(L,this.viewerData),L.event=l,L.env_key=this.envKey,L.user_id&&(L.viewer_user_id=L.user_id,delete L.user_id);var b=L.mux_sample_number>=this.sampleRate,M=this._deduplicateBeaconData(l,L),F=(0,o.default)(M);if(this.lastEventTime=this.mux.utils.now(),b)return E.default.info("Not sending event due to sample rate restriction",l,L,F);if(this.envKey||E.default.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",l,L,F),!this.rateLimited){if(E.default.info("Sending event",l,L,F),this.rateLimited=!this.eventQueue.queueEvent(l,F),this.mux.WINDOW_UNLOADING&&l==="viewend")this.eventQueue.destroy(!0);else if((c.indexOf(l)>=0||this.mux.WINDOW_VISIBLE===!1&&l==="hb")&&this.eventQueue.flushEvents(),this.rateLimited)return L.event="eventrateexceeded",F=(0,o.default)(L),this.eventQueue.queueEvent(L.event,F),E.default.error("Beaconing disabled due to rate limit.")}}},r.prototype.destroy=function(){this.eventQueue.destroy(!1)};var h=function(l,v,m,L){return!(!l||v.indexOf("request_")!==0)&&(v==="request_response_headers"||(m===void 0?"undefined":T(m))!=="object"||(L===void 0?"undefined":T(L))!=="object"||Object.keys(m||{}).length!==Object.keys(L||{}).length)},d=function(l,v){return l==="renditionchange"&&v.indexOf("video_source_")===0};r.prototype._deduplicateBeaconData=function(l,v){var m=this,L={},b=v.view_id;if(!b||l==="viewstart"||l==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)L=(0,t.default)({},v),b&&(this.previousBeaconData=L),b&&l==="viewend"&&(this.previousBeaconData=null);else{var M=l.indexOf("request")===0;Object.keys(v).forEach(function(F){var w=v[F];(w!==m.previousBeaconData[F]||u.indexOf(F)>-1||h(M,F,w,m.previousBeaconData[F])||d(l,F))&&(L[F]=w,m.previousBeaconData[F]=w)})}return L},n.default=r},function(P,n,R){"use strict";function p(s){return s&&s.__esModule?s:{default:s}}Object.defineProperty(n,"__esModule",{value:!0}),n.getAndUpdateSessionData=n.getAndUpdateViewerData=void 0;var T=R(15),I=p(T),S=R(52),O=p(S),_=R(6),E=R(2),A=p(E),D=function(){var s=void 0;try{s=I.default.parse(O.default.get("muxData")||"")}catch{s={}}return s},x=function(s){try{O.default.set("muxData",I.default.stringify(s),{expires:7300})}catch{}},g=function(){var s=D();return s.mux_viewer_id=s.mux_viewer_id||(0,_.generateUUID)(),s.msn=s.msn||Math.random(),x(s),{mux_viewer_id:s.mux_viewer_id,mux_sample_number:s.msn}},y=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,x(s),{session_id:s.sid,session_start:s.sst,session_expires:s.sex}};n.getAndUpdateViewerData=g,n.getAndUpdateSessionData=y},function(P,n,R){"use strict";var p=R(42),T=R(16),I=R(10),S=Object.prototype.hasOwnProperty,O={brackets:function(a){return a+"[]"},comma:"comma",indices:function(a,i){return a+"["+i+"]"},repeat:function(a){return a}},_=Array.isArray,E=String.prototype.split,A=Array.prototype.push,D=function(a,i){A.apply(a,_(i)?i:[i])},x=Date.prototype.toISOString,g=I.default,y={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:T.encode,encodeValuesOnly:!1,format:g,formatter:I.formatters[g],indices:!1,serializeDate:function(a){return x.call(a)},skipNulls:!1,strictNullHandling:!1},s=function(a){return typeof a=="string"||typeof a=="number"||typeof a=="boolean"||typeof a=="symbol"||typeof a=="bigint"},e={},o=function a(i,t,u,c,r,h,d,l,v,m,L,b,M,F,w){for(var C=i,U=w,k=0,j=!1;(U=U.get(e))!==void 0&&!j;){var N=U.get(i);if(k+=1,N!==void 0){if(N===k)throw new RangeError("Cyclic object value");j=!0}U.get(e)===void 0&&(k=0)}if(typeof d=="function"?C=d(t,C):C instanceof Date?C=m(C):u==="comma"&&_(C)&&(C=T.maybeMap(C,function(re){return re instanceof Date?m(re):re})),C===null){if(c)return h&&!M?h(t,y.encoder,F,"key",L):t;C=""}if(s(C)||T.isBuffer(C)){if(h){var W=M?t:h(t,y.encoder,F,"key",L);if(u==="comma"&&M){for(var Y=E.call(String(C),","),K="",H=0;H<Y.length;++H)K+=(H===0?"":",")+b(h(Y[H],y.encoder,F,"value",L));return[b(W)+"="+K]}return[b(W)+"="+b(h(C,y.encoder,F,"value",L))]}return[b(t)+"="+b(String(C))]}var z=[];if(C===void 0)return z;var $;if(u==="comma"&&_(C))$=[{value:C.length>0?C.join(",")||null:void 0}];else if(_(d))$=d;else{var X=Object.keys(C);$=l?X.sort(l):X}for(var J=0;J<$.length;++J){var te=$[J],Q=typeof te=="object"&&te.value!==void 0?te.value:C[te];if(!r||Q!==null){var ae=_(C)?typeof u=="function"?u(t,te):t:t+(v?"."+te:"["+te+"]");w.set(i,k);var se=p();se.set(e,w),D(z,a(Q,ae,u,c,r,h,d,l,v,m,L,b,M,F,se))}}return z},f=function(a){if(!a)return y;if(a.encoder!==null&&a.encoder!==void 0&&typeof a.encoder!="function")throw new TypeError("Encoder has to be a function.");var i=a.charset||y.charset;if(a.charset!==void 0&&a.charset!=="utf-8"&&a.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(a.format!==void 0){if(!S.call(I.formatters,a.format))throw new TypeError("Unknown format option provided.");t=a.format}var u=I.formatters[t],c=y.filter;return(typeof a.filter=="function"||_(a.filter))&&(c=a.filter),{addQueryPrefix:typeof a.addQueryPrefix=="boolean"?a.addQueryPrefix:y.addQueryPrefix,allowDots:a.allowDots===void 0?y.allowDots:!!a.allowDots,charset:i,charsetSentinel:typeof a.charsetSentinel=="boolean"?a.charsetSentinel:y.charsetSentinel,delimiter:a.delimiter===void 0?y.delimiter:a.delimiter,encode:typeof a.encode=="boolean"?a.encode:y.encode,encoder:typeof a.encoder=="function"?a.encoder:y.encoder,encodeValuesOnly:typeof a.encodeValuesOnly=="boolean"?a.encodeValuesOnly:y.encodeValuesOnly,filter:c,format:t,formatter:u,serializeDate:typeof a.serializeDate=="function"?a.serializeDate:y.serializeDate,skipNulls:typeof a.skipNulls=="boolean"?a.skipNulls:y.skipNulls,sort:typeof a.sort=="function"?a.sort:null,strictNullHandling:typeof a.strictNullHandling=="boolean"?a.strictNullHandling:y.strictNullHandling}};P.exports=function(a,i){var t,u,c=a,r=f(i);typeof r.filter=="function"?(u=r.filter,c=u("",c)):_(r.filter)&&(u=r.filter,t=u);var h=[];if(typeof c!="object"||c===null)return"";var d;d=i&&i.arrayFormat in O?i.arrayFormat:i&&"indices"in i?i.indices?"indices":"repeat":"indices";var l=O[d];t||(t=Object.keys(c)),r.sort&&t.sort(r.sort);for(var v=p(),m=0;m<t.length;++m){var L=t[m];r.skipNulls&&c[L]===null||D(h,o(c[L],L,l,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=h.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,n,R){"use strict";var p=R(8),T=R(47),I=R(49),S=p("%TypeError%"),O=p("%WeakMap%",!0),_=p("%Map%",!0),E=T("WeakMap.prototype.get",!0),A=T("WeakMap.prototype.set",!0),D=T("WeakMap.prototype.has",!0),x=T("Map.prototype.get",!0),g=T("Map.prototype.set",!0),y=T("Map.prototype.has",!0),s=function(a,i){for(var t,u=a;(t=u.next)!==null;u=t)if(t.key===i)return u.next=t.next,t.next=a.next,a.next=t,t},e=function(a,i){var t=s(a,i);return t&&t.value},o=function(a,i,t){var u=s(a,i);u?u.value=t:a.next={key:i,next:a.next,value:t}},f=function(a,i){return!!s(a,i)};P.exports=function(){var a,i,t,u={assert:function(c){if(!u.has(c))throw new S("Side channel does not contain "+I(c))},get:function(c){if(O&&c&&(typeof c=="object"||typeof c=="function")){if(a)return E(a,c)}else if(_){if(i)return x(i,c)}else if(t)return e(t,c)},has:function(c){if(O&&c&&(typeof c=="object"||typeof c=="function")){if(a)return D(a,c)}else if(_){if(i)return y(i,c)}else if(t)return f(t,c);return!1},set:function(c,r){O&&c&&(typeof c=="object"||typeof c=="function")?(a||(a=new O),A(a,c,r)):_?(i||(i=new _),g(i,c,r)):(t||(t={key:{},next:null}),o(t,c,r))}};return u}},function(P,n,R){"use strict";var p=typeof Symbol!="undefined"&&Symbol,T=R(44);P.exports=function(){return typeof p=="function"&&typeof Symbol=="function"&&typeof p("foo")=="symbol"&&typeof Symbol("bar")=="symbol"&&T()}},function(P,n,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={},T=Symbol("test"),I=Object(T);if(typeof T=="string"||Object.prototype.toString.call(T)!=="[object Symbol]"||Object.prototype.toString.call(I)!=="[object Symbol]")return!1;p[T]=42;for(T 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 S=Object.getOwnPropertySymbols(p);if(S.length!==1||S[0]!==T||!Object.prototype.propertyIsEnumerable.call(p,T))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var O=Object.getOwnPropertyDescriptor(p,T);if(O.value!==42||O.enumerable!==!0)return!1}return!0}},function(P,n,R){"use strict";var p=Array.prototype.slice,T=Object.prototype.toString;P.exports=function(I){var S=this;if(typeof S!="function"||T.call(S)!=="[object Function]")throw new TypeError("Function.prototype.bind called on incompatible "+S);for(var O,_=p.call(arguments,1),E=function(){if(this instanceof O){var y=S.apply(this,_.concat(p.call(arguments)));return Object(y)===y?y:this}return S.apply(I,_.concat(p.call(arguments)))},A=Math.max(0,S.length-_.length),D=[],x=0;x<A;x++)D.push("$"+x);if(O=Function("binder","return function ("+D.join(",")+"){ return binder.apply(this,arguments); }")(E),S.prototype){var g=function(){};g.prototype=S.prototype,O.prototype=new g,g.prototype=null}return O}},function(P,n,R){"use strict";var p=R(9);P.exports=p.call(Function.call,Object.prototype.hasOwnProperty)},function(P,n,R){"use strict";var p=R(8),T=R(48),I=T(p("String.prototype.indexOf"));P.exports=function(S,O){var _=p(S,!!O);return typeof _=="function"&&I(S,".prototype.")>-1?T(_):_}},function(P,n,R){"use strict";var p=R(9),T=R(8),I=T("%Function.prototype.apply%"),S=T("%Function.prototype.call%"),O=T("%Reflect.apply%",!0)||p.call(S,I),_=T("%Object.getOwnPropertyDescriptor%",!0),E=T("%Object.defineProperty%",!0),A=T("%Math.max%");if(E)try{E({},"a",{value:1})}catch{E=null}P.exports=function(x){var g=O(p,S,arguments);return _&&E&&_(g,"length").configurable&&E(g,"length",{value:1+A(0,x.length-(arguments.length-1))}),g};var D=function(){return O(p,I,arguments)};E?E(P.exports,"apply",{value:D}):P.exports.apply=D},function(P,n,R){function p(G,V){if(G===1/0||G===-1/0||G!==G||G&&G>-1e3&&G<1e3||fe.call(/e/,V))return V;var ue=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof G=="number"){var he=G<0?-ye(-G):ye(G);if(he!==G){var pe=String(he),_e=re.call(V,pe.length+1);return ee.call(pe,ue,"$&_")+"."+ee.call(ee.call(_e,/([0-9]{3})/g,"$&_"),/_$/,"")}}return ee.call(V,ue,"$&_")}function T(G,V,ue){var he=(ue.quoteStyle||V)==="double"?'"':"'";return he+G+he}function I(G){return ee.call(String(G),/"/g,""")}function S(G){return!(e(G)!=="[object Array]"||Ee&&typeof G=="object"&&Ee in G)}function O(G){return!(e(G)!=="[object Date]"||Ee&&typeof G=="object"&&Ee in G)}function _(G){return!(e(G)!=="[object RegExp]"||Ee&&typeof G=="object"&&Ee in G)}function E(G){return!(e(G)!=="[object Error]"||Ee&&typeof G=="object"&&Ee in G)}function A(G){return!(e(G)!=="[object String]"||Ee&&typeof G=="object"&&Ee in G)}function D(G){return!(e(G)!=="[object Number]"||Ee&&typeof G=="object"&&Ee in G)}function x(G){return!(e(G)!=="[object Boolean]"||Ee&&typeof G=="object"&&Ee in G)}function g(G){if(Se)return G&&typeof G=="object"&&G instanceof Symbol;if(typeof G=="symbol")return!0;if(!G||typeof G!="object"||!de)return!1;try{return de.call(G),!0}catch{}return!1}function y(G){if(!G||typeof G!="object"||!Te)return!1;try{return Te.call(G),!0}catch{}return!1}function s(G,V){return xe.call(G,V)}function e(G){return Q.call(G)}function o(G){if(G.name)return G.name;var V=se.call(ae.call(G),/^function\s*([\w$]+)/);return V?V[1]:null}function f(G,V){if(G.indexOf)return G.indexOf(V);for(var ue=0,he=G.length;ue<he;ue++)if(G[ue]===V)return ue;return-1}function a(G){if(!U||!G||typeof G!="object")return!1;try{U.call(G);try{W.call(G)}catch{return!0}return G instanceof Map}catch{}return!1}function i(G){if(!H||!G||typeof G!="object")return!1;try{H.call(G,H);try{$.call(G,$)}catch{return!0}return G instanceof WeakMap}catch{}return!1}function t(G){if(!J||!G||typeof G!="object")return!1;try{return J.call(G),!0}catch{}return!1}function u(G){if(!W||!G||typeof G!="object")return!1;try{W.call(G);try{U.call(G)}catch{return!0}return G instanceof Set}catch{}return!1}function c(G){if(!$||!G||typeof G!="object")return!1;try{$.call(G,$);try{H.call(G,H)}catch{return!0}return G instanceof WeakSet}catch{}return!1}function r(G){return!(!G||typeof G!="object")&&(typeof HTMLElement!="undefined"&&G instanceof HTMLElement||typeof G.nodeName=="string"&&typeof G.getAttribute=="function")}function h(G,V){if(G.length>V.maxStringLength){var ue=G.length-V.maxStringLength,he="... "+ue+" more character"+(ue>1?"s":"");return h(re.call(G,0,V.maxStringLength),V)+he}return T(ee.call(ee.call(G,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,d),"single",V)}function d(G){var V=G.charCodeAt(0),ue={8:"b",9:"t",10:"n",12:"f",13:"r"}[V];return ue?"\\"+ue:"\\x"+(V<16?"0":"")+Z.call(V.toString(16))}function l(G){return"Object("+G+")"}function v(G){return G+" { ? }"}function m(G,V,ue,he){return G+" ("+V+") {"+(he?M(ue,he):ie.call(ue,", "))+"}"}function L(G){for(var V=0;V<G.length;V++)if(f(G[V],`
|
|
2
|
-
`)>=0)return!1;return!0}function
|
|
1
|
+
var Or=Object.create;var Ot=Object.defineProperty;var Rr=Object.getOwnPropertyDescriptor;var Pr=Object.getOwnPropertyNames;var Ir=Object.getPrototypeOf,Mr=Object.prototype.hasOwnProperty;var Cr=(B,P,n)=>P in B?Ot(B,P,{enumerable:!0,configurable:!0,writable:!0,value:n}):B[P]=n;var Qt=(B,P)=>()=>(P||B((P={exports:{}}).exports,P),P.exports);var Fr=(B,P,n,R)=>{if(P&&typeof P=="object"||typeof P=="function")for(let m of Pr(P))!Mr.call(B,m)&&m!==n&&Ot(B,m,{get:()=>P[m],enumerable:!(R=Rr(P,m))||R.enumerable});return B};var Et=(B,P,n)=>(n=B!=null?Or(Ir(B)):{},Fr(P||!B||!B.__esModule?Ot(n,"default",{value:B,enumerable:!0}):n,B));var at=(B,P,n)=>(Cr(B,typeof P!="symbol"?P+"":P,n),n),Rt=(B,P,n)=>{if(!P.has(B))throw TypeError("Cannot "+n)};var ne=(B,P,n)=>(Rt(B,P,"read from private field"),n?n.call(B):P.get(B)),ve=(B,P,n)=>{if(P.has(B))throw TypeError("Cannot add the same private member more than once");P instanceof WeakSet?P.add(B):P.set(B,n)},Pe=(B,P,n,R)=>(Rt(B,P,"write to private field"),R?R.call(B,n):P.set(B,n),n);var Oe=(B,P,n)=>(Rt(B,P,"access private method"),n);var Zt=Qt((Tt,Ct)=>{(function(){var B=!1;(function(P,n){typeof Tt=="object"&&typeof Ct=="object"?Ct.exports=n():typeof B=="function"&&B.amd?B("mux",[],n):typeof Tt=="object"?Tt.mux=n():P.mux=n()})(typeof self!="undefined"?self:this,function(){return function(P){function n(m){if(R[m])return R[m].exports;var S=R[m]={i:m,l:!1,exports:{}};return P[m].call(S.exports,S,S.exports,n),S.l=!0,S.exports}var R={};return n.m=P,n.c=R,n.d=function(m,S,I){n.o(m,S)||Object.defineProperty(m,S,{configurable:!1,enumerable:!0,get:I})},n.n=function(m){var S=m&&m.__esModule?function(){return m.default}:function(){return m};return n.d(S,"a",S),S},n.o=function(m,S){return Object.prototype.hasOwnProperty.call(m,S)},n.p="",n(n.s=18)}([function(P,n,R){(function(m){var S;S=typeof window!="undefined"?window:m!==void 0?m:typeof self!="undefined"?self:{},P.exports=S}).call(n,R(20))},function(P,n){function R(C,k,U){switch(U.length){case 0:return C.call(k);case 1:return C.call(k,U[0]);case 2:return C.call(k,U[0],U[1]);case 3:return C.call(k,U[0],U[1],U[2])}return C.apply(k,U)}function m(C,k){for(var U=-1,j=Array(C);++U<C;)j[U]=k(U);return j}function S(C,k){var U=F(C)||g(C)?m(C.length,String):[],j=U.length,N=!!j;for(var W in C)!k&&!l.call(C,W)||N&&(W=="length"||E(W,j))||U.push(W);return U}function I(C,k,U){var j=C[k];l.call(C,k)&&x(j,U)&&(U!==void 0||k in C)||(C[k]=U)}function T(C){if(!D(C))return L(C);var k=[];for(var U in Object(C))l.call(C,U)&&U!="constructor"&&k.push(U);return k}function b(C,k){return k=O(k===void 0?C.length-1:k,0),function(){for(var U=arguments,j=-1,N=O(U.length-k,0),W=Array(N);++j<N;)W[j]=U[k+j];j=-1;for(var Y=Array(k+1);++j<k;)Y[j]=U[j];return Y[k]=W,R(C,this,Y)}}function _(C,k,U,j){U||(U={});for(var N=-1,W=k.length;++N<W;){var Y=k[N],K=j?j(U[Y],C[Y],Y,U,C):void 0;I(U,Y,K===void 0?C[Y]:K)}return U}function E(C,k){return!!(k=k==null?t:k)&&(typeof C=="number"||h.test(C))&&C>-1&&C%1==0&&C<k}function A(C,k,U){if(!f(U))return!1;var j=typeof k;return!!(j=="number"?y(U)&&E(k,U.length):j=="string"&&k in U)&&x(U[k],C)}function D(C){var k=C&&C.constructor;return C===(typeof k=="function"&&k.prototype||d)}function x(C,k){return C===k||C!==C&&k!==k}function g(C){return s(C)&&l.call(C,"callee")&&(!p.call(C,"callee")||v.call(C)==u)}function y(C){return C!=null&&o(C.length)&&!e(C)}function s(C){return a(C)&&y(C)}function e(C){var k=f(C)?v.call(C):"";return k==c||k==r}function o(C){return typeof C=="number"&&C>-1&&C%1==0&&C<=t}function f(C){var k=typeof C;return!!C&&(k=="object"||k=="function")}function a(C){return!!C&&typeof C=="object"}function i(C){return y(C)?S(C):T(C)}var t=9007199254740991,u="[object Arguments]",c="[object Function]",r="[object GeneratorFunction]",h=/^(?:0|[1-9]\d*)$/,d=Object.prototype,l=d.hasOwnProperty,v=d.toString,p=d.propertyIsEnumerable,L=function(C,k){return function(U){return C(k(U))}}(Object.keys,Object),O=Math.max,M=!p.call({valueOf:1},"valueOf"),F=Array.isArray,w=function(C){return b(function(k,U){var j=-1,N=U.length,W=N>1?U[N-1]:void 0,Y=N>2?U[2]:void 0;for(W=C.length>3&&typeof W=="function"?(N--,W):void 0,Y&&A(U[0],U[1],Y)&&(W=N<3?void 0:W,N=1),k=Object(k);++j<N;){var K=U[j];K&&C(k,K,j,W)}return k})}(function(C,k){if(M||D(k)||y(k))return void _(k,i(k),C);for(var U in k)l.call(k,U)&&I(C,U,k[U])});P.exports=w},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var m=R(0),S=function(T){return T&&T.__esModule?T:{default:T}}(m),I={};I.now=function(){var T=S.default.performance,b=T&&T.timing;return b&&typeof b.navigationStart=="number"&&typeof T.now=="function"?b.navigationStart+T.now():Date.now()},n.default=I},function(P,n,R){"use strict";function m(S,I,T){T=T===void 0?1:T,S[I]=S[I]||0,S[I]+=T}Object.defineProperty(n,"__esModule",{value:!0}),n.default=m},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var m=R(21),S=function(T){return T&&T.__esModule?T:{default:T}}(m),I=S.default.methodFactory;S.default.methodFactory=function(T,b,_){var E=I(T,b,_);return function(){for(var A=["[mux]"],D=0;D<arguments.length;D++)A.push(arguments[D]);E.apply(void 0,A)}},S.default.setLevel(S.default.getLevel()),n.default=S.default},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var m=function(T){return I(T)[0]},S=function(T){return I(T)[1]},I=function(T){if(typeof T!="string"||T==="")return["localhost"];var b=/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,_=T.match(b)||[],E=_[4],A=void 0;return E&&(A=(E.match(/[^\.]+\.[^\.]+$/)||[])[0]),[E,A]};n.extractHostnameAndDomain=I,n.extractHostname=m,n.extractDomain=S},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var m=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(I){var T=16*Math.random()|0;return(I==="x"?T:3&T|8).toString(16)})},S=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)};n.generateUUID=m,n.generateShortID=S},function(P,n,R){"use strict";function m(I){I=I||"";var T={};return I.trim().split(/[\r\n]+/).forEach(function(b){if(b){var _=b.split(": "),E=_.shift();E&&(S.indexOf(E.toLowerCase())>=0||E.toLowerCase().indexOf("x-litix-")===0)&&(T[E]=_.join(": "))}}),T}Object.defineProperty(n,"__esModule",{value:!0}),n.default=m;var S=["x-cdn","content-type"]},function(P,n,R){"use strict";var m=SyntaxError,S=Function,I=TypeError,T=function(l){try{return S('"use strict"; return ('+l+").constructor;")()}catch{}},b=Object.getOwnPropertyDescriptor;if(b)try{b({},"")}catch{b=null}var _=function(){throw new I},E=b?function(){try{return arguments.callee,_}catch{try{return b(arguments,"callee").get}catch{return _}}}():_,A=R(43)(),D=Object.getPrototypeOf||function(l){return l.__proto__},x={},g=typeof Uint8Array=="undefined"?void 0:D(Uint8Array),y={"%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%":x,"%AsyncGenerator%":x,"%AsyncGeneratorFunction%":x,"%AsyncIteratorPrototype%":x,"%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%":x,"%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%":m,"%ThrowTypeError%":E,"%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},s=function l(v){var p;if(v==="%AsyncFunction%")p=T("async function () {}");else if(v==="%GeneratorFunction%")p=T("function* () {}");else if(v==="%AsyncGeneratorFunction%")p=T("async function* () {}");else if(v==="%AsyncGenerator%"){var L=l("%AsyncGeneratorFunction%");L&&(p=L.prototype)}else if(v==="%AsyncIteratorPrototype%"){var O=l("%AsyncGenerator%");O&&(p=D(O.prototype))}return y[v]=p,p},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"]},o=R(9),f=R(46),a=o.call(Function.call,Array.prototype.concat),i=o.call(Function.apply,Array.prototype.splice),t=o.call(Function.call,String.prototype.replace),u=o.call(Function.call,String.prototype.slice),c=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,r=/\\(\\)?/g,h=function(l){var v=u(l,0,1),p=u(l,-1);if(v==="%"&&p!=="%")throw new m("invalid intrinsic syntax, expected closing `%`");if(p==="%"&&v!=="%")throw new m("invalid intrinsic syntax, expected opening `%`");var L=[];return t(l,c,function(O,M,F,w){L[L.length]=F?t(w,r,"$1"):M||O}),L},d=function(l,v){var p,L=l;if(f(e,L)&&(p=e[L],L="%"+p[0]+"%"),f(y,L)){var O=y[L];if(O===x&&(O=s(L)),O===void 0&&!v)throw new I("intrinsic "+l+" exists, but is not available. Please file an issue!");return{alias:p,name:L,value:O}}throw new m("intrinsic "+l+" does not exist!")};P.exports=function(l,v){if(typeof l!="string"||l.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 p=h(l),L=p.length>0?p[0]:"",O=d("%"+L+"%",v),M=O.name,F=O.value,w=!1,C=O.alias;C&&(L=C[0],i(p,a([0,1],C)));for(var k=1,U=!0;k<p.length;k+=1){var j=p[k],N=u(j,0,1),W=u(j,-1);if((N==='"'||N==="'"||N==="`"||W==='"'||W==="'"||W==="`")&&N!==W)throw new m("property names with quotes must have matching quotes");if(j!=="constructor"&&U||(w=!0),L+="."+j,M="%"+L+"%",f(y,M))F=y[M];else if(F!=null){if(!(j in F)){if(!v)throw new I("base intrinsic for "+l+" exists, but the property is not available.");return}if(b&&k+1>=p.length){var Y=b(F,j);U=!!Y,F=U&&"get"in Y&&!("originalValue"in Y.get)?Y.get:F[j]}else U=f(F,j),F=F[j];U&&!w&&(y[M]=F)}}return F}},function(P,n,R){"use strict";var m=R(45);P.exports=Function.prototype.bind||m},function(P,n,R){"use strict";var m=String.prototype.replace,S=/%20/g,I={RFC1738:"RFC1738",RFC3986:"RFC3986"};P.exports={default:I.RFC3986,formatters:{RFC1738:function(T){return m.call(T,S,"+")},RFC3986:function(T){return String(T)}},RFC1738:I.RFC1738,RFC3986:I.RFC3986}},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.findMediaElement=n.getMuxPlayerId=void 0;var m=R(6),S=function(T){return T&&T.nodeName!==void 0?(T.muxId||(T.muxId=T.id||(0,m.generateShortID)()),T.muxId):T},I=function(T){var b=void 0;return T&&T.nodeName!==void 0?(b=T,T=S(b)):b=document.querySelector(T),[b,T,b&&b.nodeName?b.nodeName.toLowerCase():""]};n.getMuxPlayerId=S,n.findMediaElement=I},function(P,n,R){"use strict";function m(){return(I.default.doNotTrack||I.default.navigator&&(I.default.navigator.doNotTrack||I.default.navigator.msDoNotTrack))==="1"}Object.defineProperty(n,"__esModule",{value:!0}),n.default=m;var S=R(0),I=function(T){return T&&T.__esModule?T:{default:T}}(S)},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var m=R(0),S=function(T){return T&&T.__esModule?T:{default:T}}(m),I={};I.exists=function(){var T=S.default.performance;return(T&&T.timing)!==void 0},I.domContentLoadedEventEnd=function(){var T=S.default.performance,b=T&&T.timing;return b&&b.domContentLoadedEventEnd},I.navigationStart=function(){var T=S.default.performance,b=T&&T.timing;return b&&b.navigationStart},n.default=I},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var m=function(S){var I={};for(var T in S){var b=S[T];b["DATA-ID"].search("io.litix.data.")!==-1&&(I[b["DATA-ID"].replace("io.litix.data.","")]=b.VALUE)}return I};n.default=m},function(P,n,R){"use strict";var m=R(41),S=R(51),I=R(10);P.exports={formats:I,parse:S,stringify:m}},function(P,n,R){"use strict";var m=R(10),S=Object.prototype.hasOwnProperty,I=Array.isArray,T=function(){for(var f=[],a=0;a<256;++a)f.push("%"+((a<16?"0":"")+a.toString(16)).toUpperCase());return f}(),b=function(f){for(;f.length>1;){var a=f.pop(),i=a.obj[a.prop];if(I(i)){for(var t=[],u=0;u<i.length;++u)i[u]!==void 0&&t.push(i[u]);a.obj[a.prop]=t}}},_=function(f,a){for(var i=a&&a.plainObjects?Object.create(null):{},t=0;t<f.length;++t)f[t]!==void 0&&(i[t]=f[t]);return i},E=function f(a,i,t){if(!i)return a;if(typeof i!="object"){if(I(a))a.push(i);else{if(!a||typeof a!="object")return[a,i];(t&&(t.plainObjects||t.allowPrototypes)||!S.call(Object.prototype,i))&&(a[i]=!0)}return a}if(!a||typeof a!="object")return[a].concat(i);var u=a;return I(a)&&!I(i)&&(u=_(a,t)),I(a)&&I(i)?(i.forEach(function(c,r){if(S.call(a,r)){var h=a[r];h&&typeof h=="object"&&c&&typeof c=="object"?a[r]=f(h,c,t):a.push(c)}else a[r]=c}),a):Object.keys(i).reduce(function(c,r){var h=i[r];return S.call(c,r)?c[r]=f(c[r],h,t):c[r]=h,c},u)},A=function(f,a){return Object.keys(a).reduce(function(i,t){return i[t]=a[t],i},f)},D=function(f,a,i){var t=f.replace(/\+/g," ");if(i==="iso-8859-1")return t.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(t)}catch{return t}},x=function(f,a,i,t,u){if(f.length===0)return f;var c=f;if(typeof f=="symbol"?c=Symbol.prototype.toString.call(f):typeof f!="string"&&(c=String(f)),i==="iso-8859-1")return escape(c).replace(/%u[0-9a-f]{4}/gi,function(l){return"%26%23"+parseInt(l.slice(2),16)+"%3B"});for(var r="",h=0;h<c.length;++h){var d=c.charCodeAt(h);d===45||d===46||d===95||d===126||d>=48&&d<=57||d>=65&&d<=90||d>=97&&d<=122||u===m.RFC1738&&(d===40||d===41)?r+=c.charAt(h):d<128?r+=T[d]:d<2048?r+=T[192|d>>6]+T[128|63&d]:d<55296||d>=57344?r+=T[224|d>>12]+T[128|d>>6&63]+T[128|63&d]:(h+=1,d=65536+((1023&d)<<10|1023&c.charCodeAt(h)),r+=T[240|d>>18]+T[128|d>>12&63]+T[128|d>>6&63]+T[128|63&d])}return r},g=function(f){for(var a=[{obj:{o:f},prop:"o"}],i=[],t=0;t<a.length;++t)for(var u=a[t],c=u.obj[u.prop],r=Object.keys(c),h=0;h<r.length;++h){var d=r[h],l=c[d];typeof l=="object"&&l!==null&&i.indexOf(l)===-1&&(a.push({obj:c,prop:d}),i.push(l))}return b(a),f},y=function(f){return Object.prototype.toString.call(f)==="[object RegExp]"},s=function(f){return!(!f||typeof f!="object")&&!!(f.constructor&&f.constructor.isBuffer&&f.constructor.isBuffer(f))},e=function(f,a){return[].concat(f,a)},o=function(f,a){if(I(f)){for(var i=[],t=0;t<f.length;t+=1)i.push(a(f[t]));return i}return a(f)};P.exports={arrayToObject:_,assign:A,combine:e,compact:g,decode:D,encode:x,isBuffer:s,isRegExp:y,maybeMap:o,merge:E}},function(P,n,R){"use strict";function m(y){return y&&y.__esModule?y:{default:y}}function S(y){var s={};for(var e in y)y.hasOwnProperty(e)&&(s[y[e]]=e);return s}function I(y){var s={},e={};return Object.keys(y).forEach(function(o){var f=!1;if(y.hasOwnProperty(o)&&y[o]!==void 0){var a=o.split("_"),i=a[0],t=D[i];t||(b.default.info("Data key word `"+a[0]+"` not expected in "+o),t=i+"_"),a.splice(1).forEach(function(u){u==="url"&&(f=!0),g[u]?t+=g[u]:Number(u)&&Math.floor(Number(u))===Number(u)?t+=u:(b.default.info("Data key word `"+u+"` not expected in "+o),t+="_"+u+"_")}),f?e[t]=y[o]:s[t]=y[o]}}),(0,E.default)(s,e)}Object.defineProperty(n,"__esModule",{value:!0}),n.default=I;var T=R(4),b=m(T),_=R(1),E=m(_),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=S(A),x={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(x)},function(P,n,R){"use strict";P.exports=R(19).default},function(P,n,R){"use strict";function m(r){return r&&r.__esModule?r:{default:r}}Object.defineProperty(n,"__esModule",{value:!0});var S=function(){function r(h,d){var l=[],v=!0,p=!1,L=void 0;try{for(var O,M=h[Symbol.iterator]();!(v=(O=M.next()).done)&&(l.push(O.value),!d||l.length!==d);v=!0);}catch(F){p=!0,L=F}finally{try{!v&&M.return&&M.return()}finally{if(p)throw L}}return l}return function(h,d){if(Array.isArray(h))return h;if(Symbol.iterator in Object(h))return r(h,d);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),I=R(0),T=m(I),b=R(11),_=R(4),E=m(_),A=R(12),D=m(A),x=R(2),g=m(x),y=R(22),s=m(y),e=R(58),o=m(e),f=R(59),a=m(f),i=R(64),t=m(i),u={},c=function r(h){var d=arguments;typeof h=="string"?r.hasOwnProperty(h)?T.default.setTimeout(function(){d=Array.prototype.splice.call(d,1),r[h].apply(null,d)},0):E.default.warn("`"+h+"` is an unknown task"):typeof h=="function"?T.default.setTimeout(function(){h(r)},0):E.default.warn("`"+h+"` is invalid.")};c.loaded=g.default.now(),c.NAME="mux-embed",c.VERSION="4.8.0",c.API_VERSION="2.1",c.PLAYER_TRACKED=!1,c.monitor=function(r,h){return(0,o.default)(c,r,h)},c.destroyMonitor=function(r){var h=(0,b.findMediaElement)(r),d=S(h,1),l=d[0];l&&l.mux&&typeof l.mux.destroy=="function"?l.mux.destroy():E.default.error("A video element monitor for `"+r+"` has not been initialized via `mux.monitor`.")},c.addHLSJS=function(r,h){var d=(0,b.getMuxPlayerId)(r);u[d]?u[d].addHLSJS(h):E.default.error("A monitor for `"+d+"` has not been initialized.")},c.addDashJS=function(r,h){var d=(0,b.getMuxPlayerId)(r);u[d]?u[d].addDashJS(h):E.default.error("A monitor for `"+d+"` has not been initialized.")},c.removeHLSJS=function(r){var h=(0,b.getMuxPlayerId)(r);u[h]?u[h].removeHLSJS():E.default.error("A monitor for `"+h+"` has not been initialized.")},c.removeDashJS=function(r){var h=(0,b.getMuxPlayerId)(r);u[h]?u[h].removeDashJS():E.default.error("A monitor for `"+h+"` has not been initialized.")},c.init=function(r,h){(0,D.default)()&&h&&h.respectDoNotTrack&&E.default.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var d=(0,b.getMuxPlayerId)(r);u[d]=new s.default(c,d,h)},c.emit=function(r,h,d){var l=(0,b.getMuxPlayerId)(r);u[l]?(u[l].emit(h,d),h==="destroy"&&delete u[l]):E.default.error("A monitor for `"+l+"` has not been initialized.")},T.default!==void 0&&typeof T.default.addEventListener=="function"&&T.default.addEventListener("pagehide",function(r){r.persisted||(c.WINDOW_UNLOADING=!0)},!1),c.checkDoNotTrack=D.default,c.log=E.default,c.utils=a.default,c.events=t.default,n.default=c},function(P,n){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,n,R){var m,S;(function(I,T){"use strict";m=T,(S=typeof m=="function"?m.call(n,R,n,P):m)!==void 0&&(P.exports=S)})(0,function(){"use strict";function I(a,i){var t=a[i];if(typeof t.bind=="function")return t.bind(a);try{return Function.prototype.bind.call(t,a)}catch{return function(){return Function.prototype.apply.apply(t,[a,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 b(a){return a==="debug"&&(a="log"),typeof console!==g&&(a==="trace"&&y?T:console[a]!==void 0?I(console,a):console.log!==void 0?I(console,"log"):x)}function _(a,i){for(var t=0;t<s.length;t++){var u=s[t];this[u]=t<a?x:this.methodFactory(u,a,i)}this.log=this.debug}function E(a,i,t){return function(){typeof console!==g&&(_.call(this,i,t),this[a].apply(this,arguments))}}function A(a,i,t){return b(a)||E.apply(this,arguments)}function D(a,i,t){function u(p){var L=(s[p]||"silent").toUpperCase();if(typeof window!==g&&l){try{return void(window.localStorage[l]=L)}catch{}try{window.document.cookie=encodeURIComponent(l)+"="+L+";"}catch{}}}function c(){var p;if(typeof window!==g&&l){try{p=window.localStorage[l]}catch{}if(typeof p===g)try{var L=window.document.cookie,O=L.indexOf(encodeURIComponent(l)+"=");O!==-1&&(p=/^([^;]+)/.exec(L.slice(O))[1])}catch{}return d.levels[p]===void 0&&(p=void 0),p}}function r(){if(typeof window!==g&&l){try{return void window.localStorage.removeItem(l)}catch{}try{window.document.cookie=encodeURIComponent(l)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}var h,d=this;i=i==null?"WARN":i;var l="loglevel";typeof a=="string"?l+=":"+a:typeof a=="symbol"&&(l=void 0),d.name=a,d.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},d.methodFactory=t||A,d.getLevel=function(){return h},d.setLevel=function(p,L){if(typeof p=="string"&&d.levels[p.toUpperCase()]!==void 0&&(p=d.levels[p.toUpperCase()]),!(typeof p=="number"&&p>=0&&p<=d.levels.SILENT))throw"log.setLevel() called with invalid level: "+p;if(h=p,L!==!1&&u(p),_.call(d,p,a),typeof console===g&&p<d.levels.SILENT)return"No console available for logging"},d.setDefaultLevel=function(p){i=p,c()||d.setLevel(p,!1)},d.resetLevel=function(){d.setLevel(i,!1),r()},d.enableAll=function(p){d.setLevel(d.levels.TRACE,p)},d.disableAll=function(p){d.setLevel(d.levels.SILENT,p)};var v=c();v==null&&(v=i),d.setLevel(v,!1)}var x=function(){},g="undefined",y=typeof window!==g&&typeof window.navigator!==g&&/Trident\/|MSIE /.test(window.navigator.userAgent),s=["trace","debug","info","warn","error"],e=new D,o={};e.getLogger=function(a){if(typeof a!="symbol"&&typeof a!="string"||a==="")throw new TypeError("You must supply a name when creating a logger.");var i=o[a];return i||(i=o[a]=new D(a,e.getLevel(),e.methodFactory)),i};var f=typeof window!==g?window.log:void 0;return e.noConflict=function(){return typeof window!==g&&window.log===e&&(window.log=f),e},e.getLoggers=function(){return o},e.default=e,e})},function(P,n,R){"use strict";function m(ee){return ee&&ee.__esModule?ee:{default:ee}}Object.defineProperty(n,"__esModule",{value:!0});var S=function(){function ee(Z,q){var fe=[],ge=!0,ie=!1,me=void 0;try{for(var ye,Te=Z[Symbol.iterator]();!(ge=(ye=Te.next()).done)&&(fe.push(ye.value),!q||fe.length!==q);ge=!0);}catch(oe){ie=!0,me=oe}finally{try{!ge&&Te.return&&Te.return()}finally{if(ie)throw me}}return fe}return function(Z,q){if(Array.isArray(Z))return Z;if(Symbol.iterator in Object(Z))return ee(Z,q);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),I=R(4),T=m(I),b=R(1),_=m(b),E=R(6),A=R(5),D=R(0),x=m(D),g=R(13),y=m(g),s=R(3),e=m(s),o=R(23),f=R(24),a=R(25),i=m(a),t=R(26),u=m(t),c=R(27),r=m(c),h=R(28),d=m(h),l=R(29),v=m(l),p=R(30),L=m(p),O=R(31),M=m(O),F=R(32),w=m(F),C=R(33),k=m(C),U=R(34),j=m(U),N=R(35),W=m(N),Y=R(36),K=m(Y),H=R(37),z=m(H),$=R(38),X=m($),J=R(39),te=m(J),Q=R(57),ae=m(Q),se=["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"],re=function(ee,Z,q){var fe=this;this.DOM_CONTENT_LOADED_EVENT_END=y.default.domContentLoadedEventEnd(),this.NAVIGATION_START=y.default.navigationStart();var ge={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=ee,this.id=Z,q=(0,_.default)(ge,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 te.default(ee,q.data.env_key,q),this.data={player_instance_id:(0,E.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,de){de=(0,_.default)({viewer_time:this.mux.utils.now()},de),this.oldEmit(oe,de)};var ie=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,de){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),(0,_.default)(this.data,de),this._initializeViewData(),this.one("play",ie),this.one("adbreakstart",ie)});var me=function(oe){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",oe)}.bind(this);if(this.on("videochange",function(oe,de){me(de)}),this.on("programchange",function(oe,de){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,_.default)(de,{view_program_changed:!0})),ie(),this.emit("play"),this.emit("playing")}),this.on("fragmentchange",function(oe,de){this.currentFragmentPDT=de.currentFragmentPDT,this.currentFragmentStart=de.currentFragmentStart}),this.on("destroy",this.destroy),x.default!==void 0&&typeof x.default.addEventListener=="function"&&typeof x.default.removeEventListener=="function"){var ye=function(oe){oe.persisted||fe.destroy()};x.default.addEventListener("pagehide",ye,!1),this.on("destroy",function(){x.default.removeEventListener("pagehide",ye)})}this.on("playerready",function(oe,de){(0,_.default)(this.data,de)}),se.forEach(function(oe){fe.on(oe,function(de,Se){oe.indexOf("ad")!==0&&this._updateStateData(),(0,_.default)(this.data,Se),this._sanitizeData()}),fe.on("after"+oe,function(){(oe!=="error"||this.viewErrored)&&this.send(oe)})}),this.on("viewend",function(oe,de){(0,_.default)(fe.data,de)});var Te=function(oe){var de=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=de-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",Te),r.default.apply(this),X.default.apply(this),W.default.apply(this),L.default.apply(this),u.default.apply(this),j.default.apply(this),d.default.apply(this),v.default.apply(this),K.default.apply(this),M.default.apply(this),w.default.apply(this),k.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)(re.prototype,i.default.prototype),(0,_.default)(re.prototype,L.default.prototype),(0,_.default)(re.prototype,W.default.prototype),(0,_.default)(re.prototype,u.default.prototype),(0,_.default)(re.prototype,d.default.prototype),(0,_.default)(re.prototype,v.default.prototype),(0,_.default)(re.prototype,K.default.prototype),(0,_.default)(re.prototype,w.default.prototype),(0,_.default)(re.prototype,k.default.prototype),re.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(),x.default.clearTimeout(this._heartBeatTimeout))},re.prototype.send=function(ee){var Z=(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(Z.video_source_is_live===void 0&&(Z.player_source_duration===1/0||Z.video_source_duration===1/0?Z.video_source_is_live=!0:(Z.player_source_duration>0||Z.video_source_duration>0)&&(Z.video_source_is_live=!1)),Z.video_source_is_live||q.forEach(function(ye){Z[ye]=void 0}),Z.video_source_url=Z.video_source_url||Z.player_source_url,Z.video_source_url){var fe=(0,A.extractHostnameAndDomain)(Z.video_source_url),ge=S(fe,2),ie=ge[0],me=ge[1];Z.video_source_domain=me,Z.video_source_hostname=ie}delete Z.ad_request_id,this.playbackEventDispatcher.send(ee,Z),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()},re.prototype._updateStateData=function(){(0,_.default)(this.data,this.getStateData()),this._updatePlayheadTime(),this._sanitizeData()},re.prototype._sanitizeData=function(){var ee=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(Z){var q=parseInt(ee.data[Z],10);ee.data[Z]=isNaN(q)?void 0:q}),["player_source_url","video_source_url"].forEach(function(Z){if(ee.data[Z]){var q=ee.data[Z].toLowerCase();q.indexOf("data:")!==0&&q.indexOf("blob:")!==0||(ee.data[Z]="MSE style URL")}})},re.prototype._resetVideoData=function(ee,Z){var q=this;Object.keys(this.data).forEach(function(fe){fe.indexOf("video_")===0&&delete q.data[fe]})},re.prototype._resetViewData=function(){var ee=this;Object.keys(this.data).forEach(function(Z){Z.indexOf("view_")===0&&delete ee.data[Z]}),this.data.view_sequence_number=1},re.prototype._resetErrorData=function(ee,Z){delete this.data.player_error_code,delete this.data.player_error_message},re.prototype._initializeViewData=function(){var ee=this,Z=this.data.view_id=(0,E.generateUUID)(),q=function(){Z===ee.data.view_id&&(0,e.default)(ee.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",q):q()},re.prototype._restartHeartBeat=function(){var ee=this;x.default.clearTimeout(this._heartBeatTimeout),this.viewErrored||(this._heartBeatTimeout=x.default.setTimeout(function(){ee.data.player_is_paused||ee.emit("hb")},1e4))},re.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,o.monitorHlsJs)(this.mux,this.id,ee.hlsjs,{},ee.Hls||x.default.Hls)):void this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")},re.prototype.removeHLSJS=function(){this.hlsjs&&((0,o.stopMonitoringHlsJs)(this.hlsjs),this.hlsjs=void 0)},re.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,f.monitorDashJS)(this.mux,this.id,ee.dashjs)):void this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")},re.prototype.removeDashJS=function(){this.dashjs&&((0,f.stopMonitoringDashJS)(this.dashjs),this.dashjs=void 0)},n.default=re},function(P,n,R){"use strict";function m(s){return s&&s.__esModule?s:{default:s}}Object.defineProperty(n,"__esModule",{value:!0}),n.stopMonitoringHlsJs=n.monitorHlsJs=void 0;var S=R(7),I=m(S),T=R(13),b=m(T),_=R(5),E=R(14),A=m(E),D=function(s){if(!s)return{};var e=b.default.navigationStart(),o=s.loading,f=o?o.start:s.trequest,a=o?o.first:s.tfirst,i=o?o.end:s.tload;return{bytesLoaded:s.total,requestStart:Math.round(e+f),responseStart:Math.round(e+a),responseEnd:Math.round(e+i)}},x=function(s){if(s&&typeof s.getAllResponseHeaders=="function")return(0,I.default)(s.getAllResponseHeaders())},g=function(s,e,o){var f=(arguments.length>3&&arguments[3]!==void 0&&arguments[3],arguments[4]),a=s.log,i=s.utils.secondsToMs,t=function(O){var M=parseInt(f.version),F=void 0;return M===1&&O.programDateTime!==null&&(F=O.programDateTime),M===0&&O.pdt!==null&&(F=O.pdt),F};if(!b.default.exists())return void a.warn("performance timing not supported. Not tracking HLS.js.");var u=function(O,M){return s.emit(e,O,M)},c=function(O,M){var F=M.levels,w=M.audioTracks,C=M.url,k=M.stats,U=M.networkDetails,j=M.sessionData,N={},W={},Y={};Y=(0,A.default)(j),F.forEach(function(J,te){N[te]={width:J.width,height:J.height,bitrate:J.bitrate,attrs:J.attrs}}),w.forEach(function(J,te){W[te]={name:J.name,language:J.lang,bitrate:J.bitrate}});var K=D(k),H=K.bytesLoaded,z=K.requestStart,$=K.responseStart,X=K.responseEnd;Y.request_event_type=O,Y.request_bytes_loaded=H,Y.request_start=z,Y.request_response_start=$,Y.request_response_end=X,Y.request_type="manifest",Y.request_hostname=(0,_.extractHostname)(C),Y.request_response_headers=x(U),Y.request_rendition_lists={media:N,audio:W,video:{}},u("requestcompleted",Y)};o.on(f.Events.MANIFEST_LOADED,c);var r=function(O,M){var F=M.details,w=M.level,C=M.networkDetails,k=M.stats,U=D(k),j=U.bytesLoaded,N=U.requestStart,W=U.responseStart,Y=U.responseEnd,K=F.fragments[F.fragments.length-1],H=t(K)+i(K.duration);u("requestcompleted",{request_event_type:O,request_bytes_loaded:j,request_start:N,request_response_start:W,request_response_end:Y,request_current_level:w,request_type:"manifest",request_hostname:(0,_.extractHostname)(F.url),request_response_headers:x(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(H)?void 0:H})};o.on(f.Events.LEVEL_LOADED,r);var h=function(O,M){var F=M.details,w=M.networkDetails,C=M.stats,k=D(C),U=k.bytesLoaded,j=k.requestStart,N=k.responseStart,W=k.responseEnd;u("requestcompleted",{request_event_type:O,request_bytes_loaded:U,request_start:j,request_response_start:N,request_response_end:W,request_type:"manifest",request_hostname:(0,_.extractHostname)(F.url),request_response_headers:x(w)})};o.on(f.Events.AUDIO_TRACK_LOADED,h);var d=function(O,M){var F=M.stats,w=M.networkDetails,C=M.frag,k=D(F),U=k.bytesLoaded,j=k.requestStart,N=k.responseStart,W=k.responseEnd,Y={request_event_type:O,request_bytes_loaded:U,request_start:j,request_response_start:N,request_response_end:W,request_hostname:w?(0,_.extractHostname)(w.responseURL):void 0,request_response_headers:x(w),request_media_duration:C.duration};C.type==="main"?(Y.request_type="media",Y.request_current_level=C.level,Y.request_video_width=(o.levels[C.level]||{}).width,Y.request_video_height=(o.levels[C.level]||{}).height):Y.request_type=C.type,u("requestcompleted",Y)};o.on(f.Events.FRAG_LOADED,d);var l=function(O,M){var F=M.frag,w=F.start,C=t(F),k={currentFragmentPDT:C,currentFragmentStart:i(w)};u("fragmentchange",k)};o.on(f.Events.FRAG_CHANGED,l);var v=function(O,M){var F=M.type,w=M.details,C=M.response,k=M.fatal,U=M.context,j=M.frag;if(w===f.ErrorDetails.MANIFEST_LOAD_ERROR||w===f.ErrorDetails.MANIFEST_LOAD_TIMEOUT||w===f.ErrorDetails.FRAG_LOAD_ERROR||w===f.ErrorDetails.FRAG_LOAD_TIMEOUT||w===f.ErrorDetails.LEVEL_LOAD_ERROR||w===f.ErrorDetails.LEVEL_LOAD_TIMEOUT){var N=j&&j.url||U&&U.url||"";u("requestfailed",{request_error:w,request_url:N,request_hostname:(0,_.extractHostname)(N),request_type:w===f.ErrorDetails.FRAG_LOAD_ERROR||w===f.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:C&&C.code,request_error_text:C&&C.text})}k&&u("error",{player_error_code:F,player_error_message:w})};o.on(f.Events.ERROR,v);var p=function(O,M){var F=M.frag,w=F&&F._url||"";u("requestcanceled",{request_cancel:O,request_url:w,request_type:"media",request_hostname:(0,_.extractHostname)(w)})};o.on(f.Events.FRAG_LOAD_EMERGENCY_ABORTED,p);var L=function(O,M){var F=M.level,w=o.levels[F];if(w&&w.attrs&&w.attrs.BANDWIDTH){var C=w.attrs.BANDWIDTH;C?u("renditionchange",{video_source_bitrate:C,video_source_width:w.width,video_source_height:w.height}):a.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};o.on(f.Events.LEVEL_SWITCHED,L),o._stopMuxMonitor=function(){o.off(f.Events.MANIFEST_LOADED,c),o.off(f.Events.LEVEL_LOADED,r),o.off(f.Events.AUDIO_TRACK_LOADED,h),o.off(f.Events.FRAG_LOADED,d),o.off(f.Events.FRAG_CHANGED,l),o.off(f.Events.ERROR,v),o.off(f.Events.FRAG_LOAD_EMERGENCY_ABORTED,p),o.off(f.Events.LEVEL_SWITCHED,L),o.off(f.Events.DESTROYING,o._stopMuxMonitor),delete o._stopMuxMonitor},o.on(f.Events.DESTROYING,o._stopMuxMonitor)},y=function(s){s&&typeof s._stopMuxMonitor=="function"&&s._stopMuxMonitor()};n.monitorHlsJs=g,n.stopMonitoringHlsJs=y},function(P,n,R){"use strict";function m(g){return g&&g.__esModule?g:{default:g}}Object.defineProperty(n,"__esModule",{value:!0}),n.stopMonitoringDashJS=n.monitorDashJS=void 0;var S=R(0),I=m(S),T=R(7),b=m(T),_=R(5),E=function(g,y){if(!g||typeof g.getRequests!="function")return{};var s=g.getRequests({state:"executed"});if(s.length===0)return{};var e=s[s.length-1],o=(0,_.extractHostname)(e.url),f=e.bytesLoaded,a=new Date(e.requestStartDate).getTime(),i=new Date(e.firstByteDate).getTime(),t=new Date(e.requestEndDate).getTime(),u=isNaN(e.duration)?0:e.duration,c=typeof y.getMetricsFor=="function"?y.getMetricsFor(e.mediaType).HttpList:y.getDashMetrics().getHttpRequests(e.mediaType),r=void 0;return c.length>0&&(r=(0,b.default)(c[c.length-1]._responseHeaders||"")),{requestStart:a,requestResponseStart:i,requestResponseEnd:t,requestBytesLoaded:f,requestResponseHeaders:r,requestMediaDuration:u,requestHostname:o}},A=function(g,y){var s=y.getQualityFor(g),e=y.getCurrentTrackFor(g),o=e.bitrateList;return o?{currentLevel:s,renditionWidth:o[s].width||null,renditionHeight:o[s].height||null,renditionBitrate:o[s].bandwidth}:{}},D=function(g,y,s){var e=(arguments.length>3&&arguments[3]!==void 0&&arguments[3],g.log);if(!s||!s.on)return void e.warn("Invalid dash.js player reference. Monitoring blocked.");var o=function(d,l){return g.emit(y,d,l)},f=function(d){var l=d.type,v=d.data,p=v||{},L=p.url;o("requestcompleted",{request_event_type:l,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:(0,_.extractHostname)(L)})};s.on("manifestLoaded",f);var a={},i=function(d){var l=d.type,v=d.fragmentModel,p=d.chunk,L=p||{},O=L.mediaInfo,M=O||{},F=M.type,w=M.bitrateList;w=w||[];var C={};w.forEach(function(H,z){C[z]={},C[z].width=H.width,C[z].height=H.height,C[z].bitrate=H.bandwidth,C[z].attrs={}}),F==="video"?a.video=C:F==="audio"?a.audio=C:a.media=C;var k=E(v,s),U=k.requestStart,j=k.requestResponseStart,N=k.requestResponseEnd,W=k.requestResponseHeaders,Y=k.requestMediaDuration,K=k.requestHostname;o("requestcompleted",{request_event_type:l,request_start:U,request_response_start:j,request_response_end:N,request_bytes_loaded:-1,request_type:F+"_init",request_response_headers:W,request_hostname:K,request_media_duration:Y,request_rendition_lists:a})};s.on("initFragmentLoaded",i);var t=function(d){var l=d.type,v=d.fragmentModel,p=d.chunk,L=p||{},O=L.mediaInfo,M=L.start,F=O||{},w=F.type,C=E(v,s),k=C.requestStart,U=C.requestResponseStart,j=C.requestResponseEnd,N=C.requestBytesLoaded,W=C.requestResponseHeaders,Y=C.requestMediaDuration,K=C.requestHostname,H=A(w,s),z=H.currentLevel,$=H.renditionWidth,X=H.renditionHeight,J=H.renditionBitrate;o("requestcompleted",{request_event_type:l,request_start:k,request_response_start:U,request_response_end:j,request_bytes_loaded:N,request_type:w,request_response_headers:W,request_hostname:K,request_media_start_time:M,request_media_duration:Y,request_current_level:z,request_labeled_bitrate:J,request_video_width:$,request_video_height:X})};s.on("mediaFragmentLoaded",t);var u={video:void 0,audio:void 0,totalBitrate:void 0},c=function(){if(u.video&&typeof u.video.bitrate=="number"){if(!u.video.width||!u.video.height)return void e.warn("have bitrate info for video but missing width/height");var d=u.video.bitrate;return u.audio&&typeof u.audio.bitrate=="number"&&(d+=u.audio.bitrate),d!==u.totalBitrate?(u.totalBitrate=d,{video_source_bitrate:d,video_source_height:u.video.height,video_source_width:u.video.width}):void 0}},r=function(d,l,v){if(typeof d.newQuality!="number")return void e.warn("missing evt.newQuality in qualityChangeRendered event",d);var p=d.mediaType;if(p==="audio"||p==="video"){var L=s.getBitrateInfoListFor(p).find(function(M){return M.qualityIndex===d.newQuality});if(!L||typeof L.bitrate!="number")return void e.warn("missing bitrate info for "+p);u[p]=L;var O=c();O&&o("renditionchange",O)}};s.on("qualityChangeRendered",r);var h=function(d){var l=d.error,v=d.event;v=v||{};var p=v.request||{},L=I.default.event&&I.default.event.currentTarget||{};o("requestfailed",{request_error:l+"_"+v.id+"_"+p.type,request_url:v.url,request_hostname:(0,_.extractHostname)(v.url),request_type:p.mediaType,request_error_code:L.status,request_error_type:L.statusText})};s.on("error",h),s._stopMuxMonitor=function(){s.off("manifestLoaded",f),s.off("initFragmentLoaded",i),s.off("mediaFragmentLoaded",t),s.off("qualityChangeRendered",r),s.off("error",h),delete s._stopMuxMonitor}},x=function(g){g&&typeof g._stopMuxMonitor=="function"&&g._stopMuxMonitor()};n.monitorDashJS=D,n.stopMonitoringDashJS=x},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var m=function(){},S=0;m.prototype.on=function(I,T,b){return T._eventEmitterGuid=T._eventEmitterGuid||++S,this._listeners=this._listeners||{},this._listeners[I]=this._listeners[I]||[],b&&(T=T.bind(b)),this._listeners[I].push(T),T},m.prototype.off=function(I,T){var b=this._listeners&&this._listeners[I];b&&b.forEach(function(_,E){_._eventEmitterGuid===T._eventEmitterGuid&&b.splice(E,1)})},m.prototype.one=function(I,T,b){var _=this;T._eventEmitterGuid=T._eventEmitterGuid||++S;var E=function A(){_.off(I,A),T.apply(b||this,arguments)};E._eventEmitterGuid=T._eventEmitterGuid,this.on(I,E)},m.prototype.emit=function(I,T){var b=this;if(this._listeners){T=T||{};var _=this._listeners["before*"]||[],E=this._listeners[I]||[],A=this._listeners["after"+I]||[],D=function(x,g){x=x.slice(),x.forEach(function(y){y.call(b,{type:I},g)})};D(_,T),D(E,T),D(A,T)}},n.default=m},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var m=R(0),S=function(T){return T&&T.__esModule?T:{default:T}}(m),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(T,b){this._playbackHeartbeatInterval!==null&&(S.default.clearInterval(this._playbackHeartbeatInterval),this.emit("playbackheartbeatend",{viewer_time:b.viewer_time}),this._playbackHeartbeatInterval=null)})};I.prototype._startPlaybackHeartbeatInterval=function(){var T=this;this._playbackHeartbeatInterval===null&&(this.emit("playbackheartbeat"),this._playbackHeartbeatInterval=S.default.setInterval(function(){T.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)},n.default=I},function(P,n,R){"use strict";function m(){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(T){S.mux.log.warn("Exception in error translator callback.",T),S.viewErrored=!0}})}Object.defineProperty(n,"__esModule",{value:!0}),n.default=m},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var m=R(3),S=function(T){return T&&T.__esModule?T:{default:T}}(m),I=function(){this._watchTimeTrackerLastCheckedTime=null,this.on("playbackheartbeat",this._updateWatchTime),this.on("playbackheartbeatend",this._clearWatchTimeState)};I.prototype._updateWatchTime=function(T,b){var _=b.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=_),(0,S.default)(this.data,"view_watch_time",_-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=_},I.prototype._clearWatchTimeState=function(T,b){this._updateWatchTime(T,b),this._watchTimeTrackerLastCheckedTime=null},n.default=I},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var m=R(3),S=function(T){return T&&T.__esModule?T:{default:T}}(m),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 T=this.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&T>this._playbackTimeTrackerLastPlayheadPosition){var b=T-this._playbackTimeTrackerLastPlayheadPosition;b<=1e3&&(0,S.default)(this.data,"view_content_playback_time",b)}this._playbackTimeTrackerLastPlayheadPosition=T},I.prototype._clearPlaybackTimeState=function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1},n.default=I},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var m=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)})};m.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)},m.prototype._updatePlayheadTime=function(S,I){var T=this,b=function(){T.currentFragmentPDT&&T.currentFragmentStart&&(T.data.player_program_time=T.currentFragmentPDT+T.data.player_playhead_time-T.currentFragmentStart)};if(I&&I.player_playhead_time)this.data.player_playhead_time=I.player_playhead_time,b(),this._updateMaxPlayheadPosition();else if(this.getPlayheadTime){var _=this.getPlayheadTime();_!==void 0&&(this.data.player_playhead_time=_,b(),this._updateMaxPlayheadPosition())}},n.default=m},function(P,n,R){"use strict";function m(){var T=this;if(!this.disableRebufferTracking){var b=void 0,_=function(){if(b){var E=T.data.viewer_time-b;(0,I.default)(T.data,"view_rebuffer_duration",E),b=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(){b||((0,I.default)(T.data,"view_rebuffer_count",1),b=T.data.viewer_time,T.one("rebufferend",function(){_(),b=void 0}))})}}Object.defineProperty(n,"__esModule",{value:!0}),n.default=m;var S=R(3),I=function(T){return T&&T.__esModule?T:{default:T}}(S)},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var m=R(2),S=function(T){return T&&T.__esModule?T:{default:T}}(m),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(T,b){return this.isSeeking||this.isAdBreak||!this._playheadShouldBeProgressing?void this._cleanupRebufferTracker(T,b):this._lastCheckedTime===null?void this._prepareRebufferTrackerState(b.viewer_time):this._lastPlayheadTime!==this.data.player_playhead_time?void this._cleanupRebufferTracker(T,b,!0):(b.viewer_time-this._lastPlayheadTimeUpdatedTime>=this.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),void(this._lastCheckedTime=b.viewer_time))},I.prototype._clearRebufferTrackerState=function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null},I.prototype._prepareRebufferTrackerState=function(T){this._lastCheckedTime=T,this._lastPlayheadTime=this.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=T},I.prototype._cleanupRebufferTracker=function(T,b){var _=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.emit("rebufferend",{viewer_time:b.viewer_time});else{if(this._lastCheckedTime===null)return;var E=this.data.player_playhead_time-this._lastPlayheadTime,A=b.viewer_time-this._lastPlayheadTimeUpdatedTime;E>0&&A-E>this.minimumRebufferDuration&&(this.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+A-E}))}_?this._prepareRebufferTrackerState(b.viewer_time):this._clearRebufferTrackerState()},n.default=I},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var m=R(2),S=function(T){return T&&T.__esModule?T:{default:T}}(m),I=function(){this.on("viewinit",function(){var T=this.data,b=T.view_id;if(!T.view_program_changed){var _=function(E,A){var D=A.viewer_time;E.type==="playing"&&this.data.view_time_to_first_frame===void 0?this.calculateTimeToFirstFrame(D||S.default.now(),b):E.type!=="adplaying"||this.data.view_time_to_first_frame!==void 0&&!this.inPrerollPosition()||this.calculateTimeToFirstFrame(D||S.default.now(),b)};this.one("playing",_),this.one("adplaying",_),this.one("viewend",function(){this.off("playing",_),this.off("adplaying",_)})}})};I.prototype.calculateTimeToFirstFrame=function(T,b){b===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))},n.default=I},function(P,n,R){"use strict";function m(){var T=this;this.on("viewinit",function(){this._lastPlayheadPosition=-1});var b=["pause","rebufferstart","seeking","error","adbreakstart","hb"],_=["playing","hb"];b.forEach(function(E){T.on(E,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),x=Math.max(0,D-1),g=Math.max(0,1-D);this.data.view_max_upscale_percentage=Math.max(this.data.view_max_upscale_percentage||0,x),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",A),(0,I.default)(this.data,"view_total_upscaling",x*A),(0,I.default)(this.data,"view_total_downscaling",g*A)}this._lastPlayheadPosition=-1})}),_.forEach(function(E){T.on(E,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(n,"__esModule",{value:!0}),n.default=m;var S=R(3),I=function(T){return T&&T.__esModule?T:{default:T}}(S)},function(P,n,R){"use strict";function m(D){return D&&D.__esModule?D:{default:D}}function S(){this.isSeeking=!1,this.on("seeking",function(D,x){(0,A.default)(this.data,x),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(),x=T.default.now()-D;(0,_.default)(this.data,"view_seek_count",1),(0,_.default)(this.data,"view_seek_duration",x);var g=this.data.view_max_seek_time||0;this.data.view_max_seek_time=Math.max(g,x)}),this.on("viewend",function(){this.isSeeking=!1})}Object.defineProperty(n,"__esModule",{value:!0}),n.default=S;var I=R(2),T=m(I),b=R(3),_=m(b),E=R(1),A=m(E)},function(P,n,R){"use strict";function m(g){return g&&g.__esModule?g:{default:g}}Object.defineProperty(n,"__esModule",{value:!0});var S=function(){function g(y,s){var e=[],o=!0,f=!1,a=void 0;try{for(var i,t=y[Symbol.iterator]();!(o=(i=t.next()).done)&&(e.push(i.value),!s||e.length!==s);o=!0);}catch(u){f=!0,a=u}finally{try{!o&&t.return&&t.return()}finally{if(f)throw a}}return e}return function(y,s){if(Array.isArray(y))return y;if(Symbol.iterator in Object(y))return g(y,s);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),I=R(3),T=m(I),b=R(5),_=R(1),E=m(_),A=function(g,y){g.push(y),g.sort(function(s,e){return s.viewer_time-e.viewer_time})},D=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],x=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}),D.forEach(function(s){return g.on(s,g._updateAdData)});var y=function(){g.isAdBreak=!1};this.on("adbreakstart",function(){this.isAdBreak=!0}),this.on("play",y),this.on("playing",y),this.on("viewend",y),this.on("adrequest",function(s,e){e=(0,E.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,E.default)({ad_request_id:"generatedAdRequestId"+this._currentAdResponseNumber++},e),A(this._adResponses,e);var o=this.findAdRequest(e.ad_request_id);o&&(0,T.default)(this.data,"view_ad_request_time",Math.max(0,e.viewer_time-o.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})};x.prototype.inPrerollPosition=function(){return this.data.view_content_playback_time===void 0||this.data.view_content_playback_time<=1e3},x.prototype.findAdRequest=function(g){for(var y=0;y<this._adRequests.length;y++)if(this._adRequests[y].ad_request_id===g)return this._adRequests[y]},x.prototype._updateAdData=function(g,y){if(this.inPrerollPosition()){if(!this.data.view_preroll_ad_tag_hostname&&y.ad_tag_url){var s=(0,b.extractHostnameAndDomain)(y.ad_tag_url),e=S(s,2),o=e[0],f=e[1];this.data.view_preroll_ad_tag_domain=f,this.data.view_preroll_ad_tag_hostname=o}if(!this.data.view_preroll_ad_asset_hostname&&y.ad_asset_url){var a=(0,b.extractHostnameAndDomain)(y.ad_asset_url),i=S(a,2),t=i[0],u=i[1];this.data.view_preroll_ad_asset_domain=u,this.data.view_preroll_ad_asset_hostname=t}}},n.default=x},function(P,n,R){"use strict";function m(E){return E&&E.__esModule?E:{default:E}}function S(){var E=this,A=void 0,D=void 0,x=function(){E.disableRebufferTracking||((0,_.default)(E.data,"view_waiting_rebuffer_count",1),A=T.default.now(),D=window.setInterval(function(){if(A){var o=T.default.now();(0,_.default)(E.data,"view_waiting_rebuffer_duration",o-A),A=o}},250))},g=function(){E.disableRebufferTracking||A&&((0,_.default)(E.data,"view_waiting_rebuffer_duration",T.default.now()-A),A=!1,window.clearInterval(D))},y=!1,s=function(){y=!0},e=function(){y=!1,g()};this.on("waiting",function(){y&&x()}),this.on("playing",function(){g(),s()}),this.on("pause",e),this.on("seeking",e)}Object.defineProperty(n,"__esModule",{value:!0}),n.default=S;var I=R(2),T=m(I),b=R(3),_=m(b)},function(P,n,R){"use strict";function m(D){return D&&D.__esModule?D:{default:D}}function S(){var D=this;this.one("playbackheartbeat",E),this.on("playbackheartbeatend",function(){D.off("before*",A),D.one("playbackheartbeat",E)})}Object.defineProperty(n,"__esModule",{value:!0}),n.default=S;var I=R(1),T=m(I),b=R(2),_=m(b),E=function(){this.lastWallClockTime=_.default.now(),this.on("before*",A)},A=function(D){var x=_.default.now(),g=this.lastWallClockTime;this.lastWallClockTime=x,x-g>3e4&&(this.emit("devicesleep",{viewer_time:g}),(0,T.default)(this.data,{viewer_time:g}),this.send("devicesleep"),this.emit("devicewake",{viewer_time:x}),(0,T.default)(this.data,{viewer_time:x}),this.send("devicewake"))}},function(P,n,R){"use strict";function m(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(n,"__esModule",{value:!0});var S=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},I=R(0),T=m(I),b=R(40),_=R(4),E=m(_),A=R(53),D=m(A),x=R(12),g=m(x),y=R(54),s=m(y),e=R(17),o=m(e),f=R(55),a=m(f),i=R(1),t=m(i),u=["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"],c=["viewstart","error","ended","viewend"],r=function(l,v){var p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.mux=l,this.envKey=v,this.eventQueue=new a.default((0,D.default)(v,p)),this.previousBeaconData=null,this.lastEventTime=null,this.sampleRate=p.sampleRate,this.disableCookies=p.disableCookies,this.respectDoNotTrack=p.respectDoNotTrack;var L=p.platform||{};this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:L.name,viewer_application_version:L.version,viewer_application_engine:L.layout,viewer_device_name:L.product,viewer_device_category:"",viewer_device_manufacturer:L.manufacturer,viewer_os_family:L.os&&L.os.family,viewer_os_architecture:L.os&&L.os.architecture,viewer_os_version:L.os&&L.os.version};var O=(0,s.default)();O&&(this.pageLevelData=(0,t.default)(this.pageLevelData,{viewer_connection_type:O})),T.default!==void 0&&T.default.location&&T.default.location.href&&(this.pageLevelData.page_url=T.default.location.href),this.viewerData=this.disableCookies?{}:(0,b.getAndUpdateViewerData)()};r.prototype.send=function(l,v){if(l){if(this.respectDoNotTrack&&(0,g.default)())return E.default.info("Not sending `"+l+"` because Do Not Track is enabled");if(!v||(v===void 0?"undefined":S(v))!=="object")return E.default.error("A data object was expected in send() but was not provided");var p=this.disableCookies?{}:(0,b.getAndUpdateSessionData)(),L={};(0,t.default)(L,this.pageLevelData),(0,t.default)(L,v),(0,t.default)(L,p),(0,t.default)(L,this.viewerData),L.event=l,L.env_key=this.envKey,L.user_id&&(L.viewer_user_id=L.user_id,delete L.user_id);var O=L.mux_sample_number>=this.sampleRate,M=this._deduplicateBeaconData(l,L),F=(0,o.default)(M);if(this.lastEventTime=this.mux.utils.now(),O)return E.default.info("Not sending event due to sample rate restriction",l,L,F);if(this.envKey||E.default.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",l,L,F),!this.rateLimited){if(E.default.info("Sending event",l,L,F),this.rateLimited=!this.eventQueue.queueEvent(l,F),this.mux.WINDOW_UNLOADING&&l==="viewend")this.eventQueue.destroy(!0);else if((c.indexOf(l)>=0||this.mux.WINDOW_VISIBLE===!1&&l==="hb")&&this.eventQueue.flushEvents(),this.rateLimited)return L.event="eventrateexceeded",F=(0,o.default)(L),this.eventQueue.queueEvent(L.event,F),E.default.error("Beaconing disabled due to rate limit.")}}},r.prototype.destroy=function(){this.eventQueue.destroy(!1)};var h=function(l,v,p,L){return!(!l||v.indexOf("request_")!==0)&&(v==="request_response_headers"||(p===void 0?"undefined":S(p))!=="object"||(L===void 0?"undefined":S(L))!=="object"||Object.keys(p||{}).length!==Object.keys(L||{}).length)},d=function(l,v){return l==="renditionchange"&&v.indexOf("video_source_")===0};r.prototype._deduplicateBeaconData=function(l,v){var p=this,L={},O=v.view_id;if(!O||l==="viewstart"||l==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)L=(0,t.default)({},v),O&&(this.previousBeaconData=L),O&&l==="viewend"&&(this.previousBeaconData=null);else{var M=l.indexOf("request")===0;Object.keys(v).forEach(function(F){var w=v[F];(w!==p.previousBeaconData[F]||u.indexOf(F)>-1||h(M,F,w,p.previousBeaconData[F])||d(l,F))&&(L[F]=w,p.previousBeaconData[F]=w)})}return L},n.default=r},function(P,n,R){"use strict";function m(s){return s&&s.__esModule?s:{default:s}}Object.defineProperty(n,"__esModule",{value:!0}),n.getAndUpdateSessionData=n.getAndUpdateViewerData=void 0;var S=R(15),I=m(S),T=R(52),b=m(T),_=R(6),E=R(2),A=m(E),D=function(){var s=void 0;try{s=I.default.parse(b.default.get("muxData")||"")}catch{s={}}return s},x=function(s){try{b.default.set("muxData",I.default.stringify(s),{expires:7300})}catch{}},g=function(){var s=D();return s.mux_viewer_id=s.mux_viewer_id||(0,_.generateUUID)(),s.msn=s.msn||Math.random(),x(s),{mux_viewer_id:s.mux_viewer_id,mux_sample_number:s.msn}},y=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,x(s),{session_id:s.sid,session_start:s.sst,session_expires:s.sex}};n.getAndUpdateViewerData=g,n.getAndUpdateSessionData=y},function(P,n,R){"use strict";var m=R(42),S=R(16),I=R(10),T=Object.prototype.hasOwnProperty,b={brackets:function(a){return a+"[]"},comma:"comma",indices:function(a,i){return a+"["+i+"]"},repeat:function(a){return a}},_=Array.isArray,E=String.prototype.split,A=Array.prototype.push,D=function(a,i){A.apply(a,_(i)?i:[i])},x=Date.prototype.toISOString,g=I.default,y={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(a){return x.call(a)},skipNulls:!1,strictNullHandling:!1},s=function(a){return typeof a=="string"||typeof a=="number"||typeof a=="boolean"||typeof a=="symbol"||typeof a=="bigint"},e={},o=function a(i,t,u,c,r,h,d,l,v,p,L,O,M,F,w){for(var C=i,k=w,U=0,j=!1;(k=k.get(e))!==void 0&&!j;){var N=k.get(i);if(U+=1,N!==void 0){if(N===U)throw new RangeError("Cyclic object value");j=!0}k.get(e)===void 0&&(U=0)}if(typeof d=="function"?C=d(t,C):C instanceof Date?C=p(C):u==="comma"&&_(C)&&(C=S.maybeMap(C,function(re){return re instanceof Date?p(re):re})),C===null){if(c)return h&&!M?h(t,y.encoder,F,"key",L):t;C=""}if(s(C)||S.isBuffer(C)){if(h){var W=M?t:h(t,y.encoder,F,"key",L);if(u==="comma"&&M){for(var Y=E.call(String(C),","),K="",H=0;H<Y.length;++H)K+=(H===0?"":",")+O(h(Y[H],y.encoder,F,"value",L));return[O(W)+"="+K]}return[O(W)+"="+O(h(C,y.encoder,F,"value",L))]}return[O(t)+"="+O(String(C))]}var z=[];if(C===void 0)return z;var $;if(u==="comma"&&_(C))$=[{value:C.length>0?C.join(",")||null:void 0}];else if(_(d))$=d;else{var X=Object.keys(C);$=l?X.sort(l):X}for(var J=0;J<$.length;++J){var te=$[J],Q=typeof te=="object"&&te.value!==void 0?te.value:C[te];if(!r||Q!==null){var ae=_(C)?typeof u=="function"?u(t,te):t:t+(v?"."+te:"["+te+"]");w.set(i,U);var se=m();se.set(e,w),D(z,a(Q,ae,u,c,r,h,d,l,v,p,L,O,M,F,se))}}return z},f=function(a){if(!a)return y;if(a.encoder!==null&&a.encoder!==void 0&&typeof a.encoder!="function")throw new TypeError("Encoder has to be a function.");var i=a.charset||y.charset;if(a.charset!==void 0&&a.charset!=="utf-8"&&a.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(a.format!==void 0){if(!T.call(I.formatters,a.format))throw new TypeError("Unknown format option provided.");t=a.format}var u=I.formatters[t],c=y.filter;return(typeof a.filter=="function"||_(a.filter))&&(c=a.filter),{addQueryPrefix:typeof a.addQueryPrefix=="boolean"?a.addQueryPrefix:y.addQueryPrefix,allowDots:a.allowDots===void 0?y.allowDots:!!a.allowDots,charset:i,charsetSentinel:typeof a.charsetSentinel=="boolean"?a.charsetSentinel:y.charsetSentinel,delimiter:a.delimiter===void 0?y.delimiter:a.delimiter,encode:typeof a.encode=="boolean"?a.encode:y.encode,encoder:typeof a.encoder=="function"?a.encoder:y.encoder,encodeValuesOnly:typeof a.encodeValuesOnly=="boolean"?a.encodeValuesOnly:y.encodeValuesOnly,filter:c,format:t,formatter:u,serializeDate:typeof a.serializeDate=="function"?a.serializeDate:y.serializeDate,skipNulls:typeof a.skipNulls=="boolean"?a.skipNulls:y.skipNulls,sort:typeof a.sort=="function"?a.sort:null,strictNullHandling:typeof a.strictNullHandling=="boolean"?a.strictNullHandling:y.strictNullHandling}};P.exports=function(a,i){var t,u,c=a,r=f(i);typeof r.filter=="function"?(u=r.filter,c=u("",c)):_(r.filter)&&(u=r.filter,t=u);var h=[];if(typeof c!="object"||c===null)return"";var d;d=i&&i.arrayFormat in b?i.arrayFormat:i&&"indices"in i?i.indices?"indices":"repeat":"indices";var l=b[d];t||(t=Object.keys(c)),r.sort&&t.sort(r.sort);for(var v=m(),p=0;p<t.length;++p){var L=t[p];r.skipNulls&&c[L]===null||D(h,o(c[L],L,l,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 O=h.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&"),O.length>0?M+O:""}},function(P,n,R){"use strict";var m=R(8),S=R(47),I=R(49),T=m("%TypeError%"),b=m("%WeakMap%",!0),_=m("%Map%",!0),E=S("WeakMap.prototype.get",!0),A=S("WeakMap.prototype.set",!0),D=S("WeakMap.prototype.has",!0),x=S("Map.prototype.get",!0),g=S("Map.prototype.set",!0),y=S("Map.prototype.has",!0),s=function(a,i){for(var t,u=a;(t=u.next)!==null;u=t)if(t.key===i)return u.next=t.next,t.next=a.next,a.next=t,t},e=function(a,i){var t=s(a,i);return t&&t.value},o=function(a,i,t){var u=s(a,i);u?u.value=t:a.next={key:i,next:a.next,value:t}},f=function(a,i){return!!s(a,i)};P.exports=function(){var a,i,t,u={assert:function(c){if(!u.has(c))throw new T("Side channel does not contain "+I(c))},get:function(c){if(b&&c&&(typeof c=="object"||typeof c=="function")){if(a)return E(a,c)}else if(_){if(i)return x(i,c)}else if(t)return e(t,c)},has:function(c){if(b&&c&&(typeof c=="object"||typeof c=="function")){if(a)return D(a,c)}else if(_){if(i)return y(i,c)}else if(t)return f(t,c);return!1},set:function(c,r){b&&c&&(typeof c=="object"||typeof c=="function")?(a||(a=new b),A(a,c,r)):_?(i||(i=new _),g(i,c,r)):(t||(t={key:{},next:null}),o(t,c,r))}};return u}},function(P,n,R){"use strict";var m=typeof Symbol!="undefined"&&Symbol,S=R(44);P.exports=function(){return typeof m=="function"&&typeof Symbol=="function"&&typeof m("foo")=="symbol"&&typeof Symbol("bar")=="symbol"&&S()}},function(P,n,R){"use strict";P.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var m={},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;m[S]=42;for(S in m)return!1;if(typeof Object.keys=="function"&&Object.keys(m).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(m).length!==0)return!1;var T=Object.getOwnPropertySymbols(m);if(T.length!==1||T[0]!==S||!Object.prototype.propertyIsEnumerable.call(m,S))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var b=Object.getOwnPropertyDescriptor(m,S);if(b.value!==42||b.enumerable!==!0)return!1}return!0}},function(P,n,R){"use strict";var m=Array.prototype.slice,S=Object.prototype.toString;P.exports=function(I){var T=this;if(typeof T!="function"||S.call(T)!=="[object Function]")throw new TypeError("Function.prototype.bind called on incompatible "+T);for(var b,_=m.call(arguments,1),E=function(){if(this instanceof b){var y=T.apply(this,_.concat(m.call(arguments)));return Object(y)===y?y:this}return T.apply(I,_.concat(m.call(arguments)))},A=Math.max(0,T.length-_.length),D=[],x=0;x<A;x++)D.push("$"+x);if(b=Function("binder","return function ("+D.join(",")+"){ return binder.apply(this,arguments); }")(E),T.prototype){var g=function(){};g.prototype=T.prototype,b.prototype=new g,g.prototype=null}return b}},function(P,n,R){"use strict";var m=R(9);P.exports=m.call(Function.call,Object.prototype.hasOwnProperty)},function(P,n,R){"use strict";var m=R(8),S=R(48),I=S(m("String.prototype.indexOf"));P.exports=function(T,b){var _=m(T,!!b);return typeof _=="function"&&I(T,".prototype.")>-1?S(_):_}},function(P,n,R){"use strict";var m=R(9),S=R(8),I=S("%Function.prototype.apply%"),T=S("%Function.prototype.call%"),b=S("%Reflect.apply%",!0)||m.call(T,I),_=S("%Object.getOwnPropertyDescriptor%",!0),E=S("%Object.defineProperty%",!0),A=S("%Math.max%");if(E)try{E({},"a",{value:1})}catch{E=null}P.exports=function(x){var g=b(m,T,arguments);return _&&E&&_(g,"length").configurable&&E(g,"length",{value:1+A(0,x.length-(arguments.length-1))}),g};var D=function(){return b(m,I,arguments)};E?E(P.exports,"apply",{value:D}):P.exports.apply=D},function(P,n,R){function m(G,V){if(G===1/0||G===-1/0||G!==G||G&&G>-1e3&&G<1e3||fe.call(/e/,V))return V;var ue=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof G=="number"){var he=G<0?-ye(-G):ye(G);if(he!==G){var pe=String(he),_e=re.call(V,pe.length+1);return ee.call(pe,ue,"$&_")+"."+ee.call(ee.call(_e,/([0-9]{3})/g,"$&_"),/_$/,"")}}return ee.call(V,ue,"$&_")}function S(G,V,ue){var he=(ue.quoteStyle||V)==="double"?'"':"'";return he+G+he}function I(G){return ee.call(String(G),/"/g,""")}function T(G){return!(e(G)!=="[object Array]"||Ee&&typeof G=="object"&&Ee in G)}function b(G){return!(e(G)!=="[object Date]"||Ee&&typeof G=="object"&&Ee in G)}function _(G){return!(e(G)!=="[object RegExp]"||Ee&&typeof G=="object"&&Ee in G)}function E(G){return!(e(G)!=="[object Error]"||Ee&&typeof G=="object"&&Ee in G)}function A(G){return!(e(G)!=="[object String]"||Ee&&typeof G=="object"&&Ee in G)}function D(G){return!(e(G)!=="[object Number]"||Ee&&typeof G=="object"&&Ee in G)}function x(G){return!(e(G)!=="[object Boolean]"||Ee&&typeof G=="object"&&Ee in G)}function g(G){if(Se)return G&&typeof G=="object"&&G instanceof Symbol;if(typeof G=="symbol")return!0;if(!G||typeof G!="object"||!de)return!1;try{return de.call(G),!0}catch{}return!1}function y(G){if(!G||typeof G!="object"||!Te)return!1;try{return Te.call(G),!0}catch{}return!1}function s(G,V){return xe.call(G,V)}function e(G){return Q.call(G)}function o(G){if(G.name)return G.name;var V=se.call(ae.call(G),/^function\s*([\w$]+)/);return V?V[1]:null}function f(G,V){if(G.indexOf)return G.indexOf(V);for(var ue=0,he=G.length;ue<he;ue++)if(G[ue]===V)return ue;return-1}function a(G){if(!k||!G||typeof G!="object")return!1;try{k.call(G);try{W.call(G)}catch{return!0}return G instanceof Map}catch{}return!1}function i(G){if(!H||!G||typeof G!="object")return!1;try{H.call(G,H);try{$.call(G,$)}catch{return!0}return G instanceof WeakMap}catch{}return!1}function t(G){if(!J||!G||typeof G!="object")return!1;try{return J.call(G),!0}catch{}return!1}function u(G){if(!W||!G||typeof G!="object")return!1;try{W.call(G);try{k.call(G)}catch{return!0}return G instanceof Set}catch{}return!1}function c(G){if(!$||!G||typeof G!="object")return!1;try{$.call(G,$);try{H.call(G,H)}catch{return!0}return G instanceof WeakSet}catch{}return!1}function r(G){return!(!G||typeof G!="object")&&(typeof HTMLElement!="undefined"&&G instanceof HTMLElement||typeof G.nodeName=="string"&&typeof G.getAttribute=="function")}function h(G,V){if(G.length>V.maxStringLength){var ue=G.length-V.maxStringLength,he="... "+ue+" more character"+(ue>1?"s":"");return h(re.call(G,0,V.maxStringLength),V)+he}return S(ee.call(ee.call(G,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,d),"single",V)}function d(G){var V=G.charCodeAt(0),ue={8:"b",9:"t",10:"n",12:"f",13:"r"}[V];return ue?"\\"+ue:"\\x"+(V<16?"0":"")+Z.call(V.toString(16))}function l(G){return"Object("+G+")"}function v(G){return G+" { ? }"}function p(G,V,ue,he){return G+" ("+V+") {"+(he?M(ue,he):ie.call(ue,", "))+"}"}function L(G){for(var V=0;V<G.length;V++)if(f(G[V],`
|
|
2
|
+
`)>=0)return!1;return!0}function O(G,V){var ue;if(G.indent===" ")ue=" ";else{if(!(typeof G.indent=="number"&&G.indent>0))return null;ue=ie.call(Array(G.indent+1)," ")}return{base:ue,prev:ie.call(Array(V+1),ue)}}function M(G,V){if(G.length===0)return"";var ue=`
|
|
3
3
|
`+V.prev+V.base;return ue+ie.call(G,","+ue)+`
|
|
4
|
-
`+V.prev}function F(G,V){var ue=S(G),he=[];if(ue){he.length=G.length;for(var pe=0;pe<G.length;pe++)he[pe]=s(G,pe)?V(G[pe],G):""}var _e,le=typeof oe=="function"?oe(G):[];if(Se){_e={};for(var Re=0;Re<le.length;Re++)_e["$"+le[Re]]=le[Re]}for(var Le in G)s(G,Le)&&(ue&&String(Number(Le))===Le&&Le<G.length||Se&&_e["$"+Le]instanceof Symbol||(fe.call(/[^\w$]/,Le)?he.push(V(Le,G)+": "+V(G[Le],G)):he.push(Le+": "+V(G[Le],G))));if(typeof oe=="function")for(var Ie=0;Ie<le.length;Ie++)Ae.call(G,le[Ie])&&he.push("["+V(le[Ie])+"]: "+V(G[le[Ie]],G));return he}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,k=w&&Map.prototype.forEach,j=typeof Set=="function"&&Set.prototype,N=Object.getOwnPropertyDescriptor&&j?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,W=j&&N&&typeof N.get=="function"?N.get:null,Y=j&&Set.prototype.forEach,K=typeof WeakMap=="function"&&WeakMap.prototype,H=K?WeakMap.prototype.has:null,z=typeof WeakSet=="function"&&WeakSet.prototype,$=z?WeakSet.prototype.has:null,X=typeof WeakRef=="function"&&WeakRef.prototype,J=X?WeakRef.prototype.deref:null,te=Boolean.prototype.valueOf,Q=Object.prototype.toString,ae=Function.prototype.toString,se=String.prototype.match,re=String.prototype.slice,ee=String.prototype.replace,Z=String.prototype.toUpperCase,q=String.prototype.toLowerCase,fe=RegExp.prototype.test,ge=Array.prototype.concat,ie=Array.prototype.join,me=Array.prototype.slice,ye=Math.floor,Te=typeof BigInt=="function"?BigInt.prototype.valueOf:null,oe=Object.getOwnPropertySymbols,de=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Se=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Ee=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Se?"object":"symbol")?Symbol.toStringTag:null,Ae=Object.prototype.propertyIsEnumerable,Oe=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(G){return G.__proto__}:null),Me=R(50).custom,De=Me&&g(Me)?Me:null;P.exports=function G(V,ue,he,pe){function _e(ze,pt,Or){if(pt&&(pe=me.call(pe),pe.push(pt)),Or){var Xt={depth:le.depth};return s(le,"quoteStyle")&&(Xt.quoteStyle=le.quoteStyle),G(ze,Xt,he+1,pe)}return G(ze,le,he+1,pe)}var le=ue||{};if(s(le,"quoteStyle")&&le.quoteStyle!=="single"&&le.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(s(le,"maxStringLength")&&(typeof le.maxStringLength=="number"?le.maxStringLength<0&&le.maxStringLength!==1/0:le.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var Re=!s(le,"customInspect")||le.customInspect;if(typeof Re!="boolean"&&Re!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(s(le,"indent")&&le.indent!==null&&le.indent!==" "&&!(parseInt(le.indent,10)===le.indent&&le.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(s(le,"numericSeparator")&&typeof le.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var Le=le.numericSeparator;if(V===void 0)return"undefined";if(V===null)return"null";if(typeof V=="boolean")return V?"true":"false";if(typeof V=="string")return h(V,le);if(typeof V=="number"){if(V===0)return 1/0/V>0?"0":"-0";var Ie=String(V);return Le?p(V,Ie):Ie}if(typeof V=="bigint"){var je=String(V)+"n";return Le?p(V,je):je}var ke=le.depth===void 0?5:le.depth;if(he===void 0&&(he=0),he>=ke&&ke>0&&typeof V=="object")return S(V)?"[Array]":"[Object]";var Be=b(le,he);if(pe===void 0)pe=[];else if(f(pe,V)>=0)return"[Circular]";if(typeof V=="function"){var et=o(V),He=F(V,_e);return"[Function"+(et?": "+et:" (anonymous)")+"]"+(He.length>0?" { "+ie.call(He,", ")+" }":"")}if(g(V)){var Ce=Se?ee.call(String(V),/^(Symbol\(.*\))_[^)]*$/,"$1"):de.call(V);return typeof V!="object"||Se?Ce:l(Ce)}if(r(V)){for(var Ke="<"+q.call(String(V.nodeName)),Ve=V.attributes||[],Ye=0;Ye<Ve.length;Ye++)Ke+=" "+Ve[Ye].name+"="+T(I(Ve[Ye].value),"double",le);return Ke+=">",V.childNodes&&V.childNodes.length&&(Ke+="..."),Ke+="</"+q.call(String(V.nodeName))+">"}if(S(V)){if(V.length===0)return"[]";var tt=F(V,_e);return Be&&!L(tt)?"["+M(tt,Be)+"]":"[ "+ie.call(tt,", ")+" ]"}if(E(V)){var rt=F(V,_e);return"cause"in V&&!Ae.call(V,"cause")?"{ ["+String(V)+"] "+ie.call(ge.call("[cause]: "+_e(V.cause),rt),", ")+" }":rt.length===0?"["+String(V)+"]":"{ ["+String(V)+"] "+ie.call(rt,", ")+" }"}if(typeof V=="object"&&Re){if(De&&typeof V[De]=="function")return V[De]();if(Re!=="symbol"&&typeof V.inspect=="function")return V.inspect()}if(a(V)){var vt=[];return k.call(V,function(ze,pt){vt.push(_e(pt,V,!0)+" => "+_e(ze,V))}),m("Map",U.call(V),vt,Be)}if(u(V)){var gt=[];return Y.call(V,function(ze){gt.push(_e(ze,V))}),m("Set",W.call(V),gt,Be)}if(i(V))return v("WeakMap");if(c(V))return v("WeakSet");if(t(V))return v("WeakRef");if(D(V))return l(_e(Number(V)));if(y(V))return l(_e(Te.call(V)));if(x(V))return l(te.call(V));if(A(V))return l(_e(String(V)));if(!O(V)&&!_(V)){var We=F(V,_e),it=Oe?Oe(V)===Object.prototype:V instanceof Object||V.constructor===Object,nt=V instanceof Object?"":"null prototype",mt=!it&&Ee&&Object(V)===V&&Ee in V?re.call(e(V),8,-1):nt?"Object":"",Lr=it||typeof V.constructor!="function"?"":V.constructor.name?V.constructor.name+" ":"",_t=Lr+(mt||nt?"["+ie.call(ge.call([],mt||[],nt||[]),": ")+"] ":"");return We.length===0?_t+"{}":Be?_t+"{"+M(We,Be)+"}":_t+"{ "+ie.call(We,", ")+" }"}return String(V)};var xe=Object.prototype.hasOwnProperty||function(G){return G in this}},function(P,n){},function(P,n,R){"use strict";var p=R(16),T=Object.prototype.hasOwnProperty,I=Array.isArray,S={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},O=function(g){return g.replace(/&#(\d+);/g,function(y,s){return String.fromCharCode(parseInt(s,10))})},_=function(g,y){return g&&typeof g=="string"&&y.comma&&g.indexOf(",")>-1?g.split(","):g},E=function(g,y){var s,e={},o=y.ignoreQueryPrefix?g.replace(/^\?/,""):g,f=y.parameterLimit===1/0?void 0:y.parameterLimit,a=o.split(y.delimiter,f),i=-1,t=y.charset;if(y.charsetSentinel)for(s=0;s<a.length;++s)a[s].indexOf("utf8=")===0&&(a[s]==="utf8=%E2%9C%93"?t="utf-8":a[s]==="utf8=%26%2310003%3B"&&(t="iso-8859-1"),i=s,s=a.length);for(s=0;s<a.length;++s)if(s!==i){var u,c,r=a[s],h=r.indexOf("]="),d=h===-1?r.indexOf("="):h+1;d===-1?(u=y.decoder(r,S.decoder,t,"key"),c=y.strictNullHandling?null:""):(u=y.decoder(r.slice(0,d),S.decoder,t,"key"),c=p.maybeMap(_(r.slice(d+1),y),function(l){return y.decoder(l,S.decoder,t,"value")})),c&&y.interpretNumericEntities&&t==="iso-8859-1"&&(c=O(c)),r.indexOf("[]=")>-1&&(c=I(c)?[c]:c),T.call(e,u)?e[u]=p.combine(e[u],c):e[u]=c}return e},A=function(g,y,s,e){for(var o=e?y:_(y,s),f=g.length-1;f>=0;--f){var a,i=g[f];if(i==="[]"&&s.parseArrays)a=[].concat(o);else{a=s.plainObjects?Object.create(null):{};var t=i.charAt(0)==="["&&i.charAt(i.length-1)==="]"?i.slice(1,-1):i,u=parseInt(t,10);s.parseArrays||t!==""?!isNaN(u)&&i!==t&&String(u)===t&&u>=0&&s.parseArrays&&u<=s.arrayLimit?(a=[],a[u]=o):t!=="__proto__"&&(a[t]=o):a={0:o}}o=a}return o},D=function(g,y,s,e){if(g){var o=s.allowDots?g.replace(/\.([^.[]+)/g,"[$1]"):g,f=/(\[[^[\]]*])/,a=/(\[[^[\]]*])/g,i=s.depth>0&&f.exec(o),t=i?o.slice(0,i.index):o,u=[];if(t){if(!s.plainObjects&&T.call(Object.prototype,t)&&!s.allowPrototypes)return;u.push(t)}for(var c=0;s.depth>0&&(i=a.exec(o))!==null&&c<s.depth;){if(c+=1,!s.plainObjects&&T.call(Object.prototype,i[1].slice(1,-1))&&!s.allowPrototypes)return;u.push(i[1])}return i&&u.push("["+o.slice(i.index)+"]"),A(u,y,s,e)}},x=function(g){if(!g)return S;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 y=g.charset===void 0?S.charset:g.charset;return{allowDots:g.allowDots===void 0?S.allowDots:!!g.allowDots,allowPrototypes:typeof g.allowPrototypes=="boolean"?g.allowPrototypes:S.allowPrototypes,allowSparse:typeof g.allowSparse=="boolean"?g.allowSparse:S.allowSparse,arrayLimit:typeof g.arrayLimit=="number"?g.arrayLimit:S.arrayLimit,charset:y,charsetSentinel:typeof g.charsetSentinel=="boolean"?g.charsetSentinel:S.charsetSentinel,comma:typeof g.comma=="boolean"?g.comma:S.comma,decoder:typeof g.decoder=="function"?g.decoder:S.decoder,delimiter:typeof g.delimiter=="string"||p.isRegExp(g.delimiter)?g.delimiter:S.delimiter,depth:typeof g.depth=="number"||g.depth===!1?+g.depth:S.depth,ignoreQueryPrefix:g.ignoreQueryPrefix===!0,interpretNumericEntities:typeof g.interpretNumericEntities=="boolean"?g.interpretNumericEntities:S.interpretNumericEntities,parameterLimit:typeof g.parameterLimit=="number"?g.parameterLimit:S.parameterLimit,parseArrays:g.parseArrays!==!1,plainObjects:typeof g.plainObjects=="boolean"?g.plainObjects:S.plainObjects,strictNullHandling:typeof g.strictNullHandling=="boolean"?g.strictNullHandling:S.strictNullHandling}};P.exports=function(g,y){var s=x(y);if(g===""||g===null||g===void 0)return s.plainObjects?Object.create(null):{};for(var e=typeof g=="string"?E(g,s):g,o=s.plainObjects?Object.create(null):{},f=Object.keys(e),a=0;a<f.length;++a){var i=f[a],t=D(i,e[i],s,typeof g=="string");o=p.merge(o,t,s)}return s.allowSparse===!0?o:p.compact(o)}},function(P,n,R){"use strict";var p,T,I=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(S){return typeof S}:function(S){return S&&typeof Symbol=="function"&&S.constructor===Symbol&&S!==Symbol.prototype?"symbol":typeof S};(function(S){var O=!1;if(p=S,(T=typeof p=="function"?p.call(n,R,n,P):p)!==void 0&&(P.exports=T),O=!0,I(n)==="object"&&(P.exports=S(),O=!0),!O){var _=window.Cookies,E=window.Cookies=S();E.noConflict=function(){return window.Cookies=_,E}}})(function(){function S(_){function E(A,D,x){var g;if(typeof document!="undefined"){if(arguments.length>1){if(x=O({path:"/"},E.defaults,x),typeof x.expires=="number"){var y=new Date;y.setMilliseconds(y.getMilliseconds()+864e5*x.expires),x.expires=y}try{g=JSON.stringify(D),/^[\{\[]/.test(g)&&(D=g)}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,x.expires?"; expires="+x.expires.toUTCString():"",x.path?"; path="+x.path:"",x.domain?"; domain="+x.domain:"",x.secure?"; secure":""].join("")}A||(g={});for(var s=document.cookie?document.cookie.split("; "):[],e=/(%[0-9A-Z]{2})+/g,o=0;o<s.length;o++){var f=s[o].split("="),a=f.slice(1).join("=");a.charAt(0)==='"'&&(a=a.slice(1,-1));try{var i=f[0].replace(e,decodeURIComponent);if(a=_.read?_.read(a,i):_(a,i)||a.replace(e,decodeURIComponent),this.json)try{a=JSON.parse(a)}catch{}if(A===i){g=a;break}A||(g[i]=a)}catch{}}return g}}return E.set=E,E.get=function(A){return E.call(E,A)},E.getJSON=function(){return E.apply({json:!0},[].slice.call(arguments))},E.defaults={},E.remove=function(A,D){E(A,"",O(D,{expires:-1}))},E.withConverter=S,E}var O=function(){for(var _=0,E={};_<arguments.length;_++){var A=arguments[_];for(var D in A)E[D]=A[D]}return E};return S(function(){})})},function(P,n,R){"use strict";function p(T,I){var S=I.beaconCollectionDomain,O=I.beaconDomain;if(S)return"https://"+S;T=T||"inferred";var _=O||"litix.io";return T.match(/^[a-z0-9]+$/)?"https://"+T+"."+_:"https://img.litix.io/a.gif"}Object.defineProperty(n,"__esModule",{value:!0}),n.default=p},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var p=R(0),T=function(O){return O&&O.__esModule?O:{default:O}}(p),I=function(){var O=void 0;switch(S()){case"cellular":O="cellular";break;case"ethernet":O="wired";break;case"wifi":O="wifi";break;case void 0:break;default:O="other"}return O},S=function(){var O=T.default.navigator,_=O&&(O.connection||O.mozConnection||O.webkitConnection);return _&&_.type};n.default=I},function(P,n,R){"use strict";function p(a){return a&&a.__esModule?a:{default:a}}Object.defineProperty(n,"__esModule",{value:!0});var T=R(0),I=p(T),S=R(4),O=p(S),_=R(56),E=p(_),A=R(1),D=p(A),x=R(17),g=p(x),y=R(2),s=p(y),e=!!I.default.XMLHttpRequest&&"withCredentials"in new I.default.XMLHttpRequest,o={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4},f=function(a,i){this._beaconUrl=a||"https://img.litix.io",this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=(0,D.default)({},o,i)};f.prototype.queueEvent=function(a,i){var t=(0,D.default)({},i);return e?(this._eventQueue.length<=this._options.maxQueueLength||a==="eventrateexceeded")&&(this._eventQueue.push(t),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength):(E.default.send(this._beaconUrl,t),!0)},f.prototype.flushEvents=function(){e&&(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},f.prototype.destroy=function(){var a=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,a?this._clearBeaconQueue():this.flushEvents(),I.default.clearTimeout(this._sendTimeout)},f.prototype._clearBeaconQueue=function(){var a=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,D.default)(t[t.length-1],(0,g.default)({mux_view_message:"event queue truncated"}));var u=this._createPayload(t);if(a.sendBeacon)a.sendBeacon(this._beaconUrl,u);else if(I.default.XMLHttpRequest){var c=new I.default.XMLHttpRequest;c.open("POST",this._beaconUrl),c.setRequestHeader("Content-Type","application/json"),c.send(u)}else E.default.send(this._beaconUrl,t[t.length-1])},f.prototype._sendBeaconQueue=function(){var a=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?(a._eventQueue=t.concat(a._eventQueue),a._failureCount+=1,O.default.info("Error sending beacon: "+i.status),O.default.info(i.responseText)):a._failureCount=0,a._roundTripTime=s.default.now()-c,a._postInFlight=!1)},i.open("POST",this._beaconUrl),i.setRequestHeader("Content-Type","application/json");var u=this._createPayload(t),c=s.default.now();i.send(u)}},f.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var a=Math.pow(2,this._failureCount-1);return(1+(a*=Math.random()))*this._options.baseTimeBetweenBeacons},f.prototype._startBeaconSending=function(){var a=this;I.default.clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=I.default.setTimeout(function(){a._eventQueue.length&&a._sendBeaconQueue(),a._startBeaconSending()},this._getNextBeaconTime()))},f.prototype._createPayload=function(a){var i={transmission_timestamp:Math.round(s.default.now())};return this._roundTripTime&&(i.rtt_ms=Math.round(this._roundTripTime)),JSON.stringify({metadata:i,events:a})},n.default=f},function(P,n,R){"use strict";function p(E){return E&&E.__esModule?E:{default:E}}Object.defineProperty(n,"__esModule",{value:!0});var T=R(15),I=p(T),S=R(0),O=p(S),_={};_.send=function(E,A){function D(){x.src=y+(g?"&rc="+g:"")}var x=new Image,g=0,y=E+"?"+I.default.stringify(A);return x.addEventListener("error",function(){g>3||O.default.setTimeout(function(){g++,D()},5e3*g)}),D(),x},n.default=_},function(P,n,R){"use strict";function p(){function T(y,s){var e=s.request_start,o=s.request_response_start,f=s.request_response_end,a=s.request_bytes_loaded;A++;var i=void 0,t=void 0;if(o?(i=o-e,t=f-o):t=f-e,t>0&&a>0){var u=a/t*8e3;D++,_+=a,E+=t,this.data.view_min_request_throughput=Math.min(this.data.view_min_request_throughput||1/0,u),this.data.view_average_request_throughput=_/E*8e3,this.data.view_request_count=A,i>0&&(O+=i,this.data.view_max_request_latency=Math.max(this.data.view_max_request_latency||0,i),this.data.view_average_request_latency=O/D)}}function I(y,s){A++,x++,this.data.view_request_count=A,this.data.view_request_failed_count=x}function S(y,s){A++,g++,this.data.view_request_count=A,this.data.view_request_canceled_count=g}var O=0,_=0,E=0,A=0,D=0,x=0,g=0;this.on("requestcompleted",T),this.on("requestfailed",I),this.on("requestcanceled",S)}Object.defineProperty(n,"__esModule",{value:!0}),n.default=p},function(P,n,R){"use strict";function p(D,x,g){var y=(0,_.findMediaElement)(x),s=I(y,3),e=s[0],o=s[1],f=s[2],a=D.log,i=D.utils.getComputedStyle,t=D.utils.secondsToMs,u={automaticErrorTracking:!0};if(!e)return a.error("No element was found with the `"+o+"` query selector.");if(f!=="video"&&f!=="audio")return a.error("The element of `"+o+"` was not a media element.");g=(0,O.default)(u,g),g.data=(0,O.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,h=this.dashjs&&T(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||h||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,h){D.emit(o,r,h)};var c=function(){a.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=c,e.mux.swapElement=c,e.mux.emit=c,e.mux.addHLSJS=c,e.mux.addDashJS=c,e.mux.removeHLSJS=c,e.mux.removeDashJS=c,e.mux.deleted=!0,D.emit(o,"destroy")},e.mux.swapElement=function(r){var h=(0,_.findMediaElement)(r),d=I(h,3),l=d[0],v=d[1],m=d[2];return l?m!=="video"&&m!=="audio"?D.log.error("The element of `"+v+"` was not a media element."):(l.muxId=e.muxId,delete e.muxId,l.mux=l.mux||{},l.mux.listeners=(0,O.default)({},e.mux.listeners),delete e.mux.listeners,Object.keys(l.mux.listeners).forEach(function(L){e.removeEventListener(L,l.mux.listeners[L],!1),l.addEventListener(L,l.mux.listeners[L],!1)}),l.mux.swapElement=e.mux.swapElement,l.mux.destroy=e.mux.destroy,delete e.mux,void(e=l)):D.log.error("No element was found with the `"+v+"` query selector.")},e.mux.addHLSJS=function(r){D.addHLSJS(o,r)},e.mux.addDashJS=function(r){D.addDashJS(o,r)},e.mux.removeHLSJS=function(){D.removeHLSJS(o)},e.mux.removeDashJS=function(){D.removeDashJS(o)},D.init(o,g),D.emit(o,"playerready"),e.paused||(D.emit(o,"play"),e.readyState>2&&D.emit(o,"playing")),e.mux.listeners={},E.forEach(function(r){(r!=="error"||g.automaticErrorTracking)&&(e.mux.listeners[r]=function(){var h={};if(r==="error"){if(!e.error||e.error.code===1)return;h.player_error_code=e.error.code,h.player_error_message=A[e.error.code]||e.error.message}D.emit(o,r,h)},e.addEventListener(r,e.mux.listeners[r],!1))})}Object.defineProperty(n,"__esModule",{value:!0});var T=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},I=function(){function D(x,g){var y=[],s=!0,e=!1,o=void 0;try{for(var f,a=x[Symbol.iterator]();!(s=(f=a.next()).done)&&(y.push(f.value),!g||y.length!==g);s=!0);}catch(i){e=!0,o=i}finally{try{!s&&a.return&&a.return()}finally{if(e)throw o}}return y}return function(x,g){if(Array.isArray(x))return x;if(Symbol.iterator in Object(x))return D(x,g);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();n.default=p;var S=R(1),O=function(D){return D&&D.__esModule?D:{default:D}}(S),_=R(11),E=["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(P,n,R){"use strict";function p(u){return u&&u.__esModule?u:{default:u}}Object.defineProperty(n,"__esModule",{value:!0});var T=R(60),I=p(T),S=R(3),O=p(S),_=R(61),E=p(_),A=R(62),D=p(A),x=R(1),g=p(x),y=R(7),s=p(y),e=R(5),o=R(2),f=p(o),a=R(63),i=p(a),t={};t.safeCall=I.default,t.safeIncrement=O.default,t.getComputedStyle=E.default,t.secondsToMs=D.default,t.assign=g.default,t.headersStringToObject=s.default,t.extractHostnameAndDomain=e.extractHostnameAndDomain,t.extractHostname=e.extractHostname,t.now=f.default.now,t.manifestParser=i.default,n.default=t},function(P,n,R){"use strict";function p(S,O,_,E){var A=E;if(S&&typeof S[O]=="function")try{A=S[O].apply(S,_)}catch(D){I.default.info("safeCall error",D)}return A}Object.defineProperty(n,"__esModule",{value:!0}),n.default=p;var T=R(4),I=function(S){return S&&S.__esModule?S:{default:S}}(T)},function(P,n,R){"use strict";function p(O,_){if(O&&_&&I.default&&typeof I.default.getComputedStyle=="function"){var E=void 0;return S&&S.has(O)&&(E=S.get(O)),E||(E=I.default.getComputedStyle(O,null),S&&S.set(O,E)),E.getPropertyValue(_)}}Object.defineProperty(n,"__esModule",{value:!0}),n.default=p;var T=R(0),I=function(O){return O&&O.__esModule?O:{default:O}}(T),S=void 0;I.default&&I.default.WeakMap&&(S=new WeakMap)},function(P,n,R){"use strict";function p(T){return Math.floor(1e3*T)}Object.defineProperty(n,"__esModule",{value:!0}),n.default=p},function(P,n,R){"use strict";function p(f){return f&&f.__esModule?f:{default:f}}Object.defineProperty(n,"__esModule",{value:!0});var T=R(1),I=p(T),S=R(14),O=p(S),_={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"},E=function(f){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(f),this.manifest};E.prototype.process=function(f){var a=void 0;for(this.buffer+=f,a=this.buffer.indexOf(`
|
|
4
|
+
`+V.prev}function F(G,V){var ue=T(G),he=[];if(ue){he.length=G.length;for(var pe=0;pe<G.length;pe++)he[pe]=s(G,pe)?V(G[pe],G):""}var _e,le=typeof oe=="function"?oe(G):[];if(Se){_e={};for(var Re=0;Re<le.length;Re++)_e["$"+le[Re]]=le[Re]}for(var Le in G)s(G,Le)&&(ue&&String(Number(Le))===Le&&Le<G.length||Se&&_e["$"+Le]instanceof Symbol||(fe.call(/[^\w$]/,Le)?he.push(V(Le,G)+": "+V(G[Le],G)):he.push(Le+": "+V(G[Le],G))));if(typeof oe=="function")for(var Ie=0;Ie<le.length;Ie++)Ae.call(G,le[Ie])&&he.push("["+V(le[Ie])+"]: "+V(G[le[Ie]],G));return he}var w=typeof Map=="function"&&Map.prototype,C=Object.getOwnPropertyDescriptor&&w?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,k=w&&C&&typeof C.get=="function"?C.get:null,U=w&&Map.prototype.forEach,j=typeof Set=="function"&&Set.prototype,N=Object.getOwnPropertyDescriptor&&j?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,W=j&&N&&typeof N.get=="function"?N.get:null,Y=j&&Set.prototype.forEach,K=typeof WeakMap=="function"&&WeakMap.prototype,H=K?WeakMap.prototype.has:null,z=typeof WeakSet=="function"&&WeakSet.prototype,$=z?WeakSet.prototype.has:null,X=typeof WeakRef=="function"&&WeakRef.prototype,J=X?WeakRef.prototype.deref:null,te=Boolean.prototype.valueOf,Q=Object.prototype.toString,ae=Function.prototype.toString,se=String.prototype.match,re=String.prototype.slice,ee=String.prototype.replace,Z=String.prototype.toUpperCase,q=String.prototype.toLowerCase,fe=RegExp.prototype.test,ge=Array.prototype.concat,ie=Array.prototype.join,me=Array.prototype.slice,ye=Math.floor,Te=typeof BigInt=="function"?BigInt.prototype.valueOf:null,oe=Object.getOwnPropertySymbols,de=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Se=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Ee=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Se?"object":"symbol")?Symbol.toStringTag:null,Ae=Object.prototype.propertyIsEnumerable,be=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(G){return G.__proto__}:null),Me=R(50).custom,De=Me&&g(Me)?Me:null;P.exports=function G(V,ue,he,pe){function _e(Xe,yt,br){if(yt&&(pe=me.call(pe),pe.push(yt)),br){var Xt={depth:le.depth};return s(le,"quoteStyle")&&(Xt.quoteStyle=le.quoteStyle),G(Xe,Xt,he+1,pe)}return G(Xe,le,he+1,pe)}var le=ue||{};if(s(le,"quoteStyle")&&le.quoteStyle!=="single"&&le.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(s(le,"maxStringLength")&&(typeof le.maxStringLength=="number"?le.maxStringLength<0&&le.maxStringLength!==1/0:le.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var Re=!s(le,"customInspect")||le.customInspect;if(typeof Re!="boolean"&&Re!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(s(le,"indent")&&le.indent!==null&&le.indent!==" "&&!(parseInt(le.indent,10)===le.indent&&le.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(s(le,"numericSeparator")&&typeof le.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var Le=le.numericSeparator;if(V===void 0)return"undefined";if(V===null)return"null";if(typeof V=="boolean")return V?"true":"false";if(typeof V=="string")return h(V,le);if(typeof V=="number"){if(V===0)return 1/0/V>0?"0":"-0";var Ie=String(V);return Le?m(V,Ie):Ie}if(typeof V=="bigint"){var je=String(V)+"n";return Le?m(V,je):je}var Ue=le.depth===void 0?5:le.depth;if(he===void 0&&(he=0),he>=Ue&&Ue>0&&typeof V=="object")return T(V)?"[Array]":"[Object]";var Be=O(le,he);if(pe===void 0)pe=[];else if(f(pe,V)>=0)return"[Circular]";if(typeof V=="function"){var et=o(V),Ve=F(V,_e);return"[Function"+(et?": "+et:" (anonymous)")+"]"+(Ve.length>0?" { "+ie.call(Ve,", ")+" }":"")}if(g(V)){var Ce=Se?ee.call(String(V),/^(Symbol\(.*\))_[^)]*$/,"$1"):de.call(V);return typeof V!="object"||Se?Ce:l(Ce)}if(r(V)){for(var Ke="<"+q.call(String(V.nodeName)),Ye=V.attributes||[],ze=0;ze<Ye.length;ze++)Ke+=" "+Ye[ze].name+"="+S(I(Ye[ze].value),"double",le);return Ke+=">",V.childNodes&&V.childNodes.length&&(Ke+="..."),Ke+="</"+q.call(String(V.nodeName))+">"}if(T(V)){if(V.length===0)return"[]";var tt=F(V,_e);return Be&&!L(tt)?"["+M(tt,Be)+"]":"[ "+ie.call(tt,", ")+" ]"}if(E(V)){var rt=F(V,_e);return"cause"in V&&!Ae.call(V,"cause")?"{ ["+String(V)+"] "+ie.call(ge.call("[cause]: "+_e(V.cause),rt),", ")+" }":rt.length===0?"["+String(V)+"]":"{ ["+String(V)+"] "+ie.call(rt,", ")+" }"}if(typeof V=="object"&&Re){if(De&&typeof V[De]=="function")return V[De]();if(Re!=="symbol"&&typeof V.inspect=="function")return V.inspect()}if(a(V)){var gt=[];return U.call(V,function(Xe,yt){gt.push(_e(yt,V,!0)+" => "+_e(Xe,V))}),p("Map",k.call(V),gt,Be)}if(u(V)){var mt=[];return Y.call(V,function(Xe){mt.push(_e(Xe,V))}),p("Set",W.call(V),mt,Be)}if(i(V))return v("WeakMap");if(c(V))return v("WeakSet");if(t(V))return v("WeakRef");if(D(V))return l(_e(Number(V)));if(y(V))return l(_e(Te.call(V)));if(x(V))return l(te.call(V));if(A(V))return l(_e(String(V)));if(!b(V)&&!_(V)){var We=F(V,_e),it=be?be(V)===Object.prototype:V instanceof Object||V.constructor===Object,nt=V instanceof Object?"":"null prototype",pt=!it&&Ee&&Object(V)===V&&Ee in V?re.call(e(V),8,-1):nt?"Object":"",Lr=it||typeof V.constructor!="function"?"":V.constructor.name?V.constructor.name+" ":"",bt=Lr+(pt||nt?"["+ie.call(ge.call([],pt||[],nt||[]),": ")+"] ":"");return We.length===0?bt+"{}":Be?bt+"{"+M(We,Be)+"}":bt+"{ "+ie.call(We,", ")+" }"}return String(V)};var xe=Object.prototype.hasOwnProperty||function(G){return G in this}},function(P,n){},function(P,n,R){"use strict";var m=R(16),S=Object.prototype.hasOwnProperty,I=Array.isArray,T={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:m.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},b=function(g){return g.replace(/&#(\d+);/g,function(y,s){return String.fromCharCode(parseInt(s,10))})},_=function(g,y){return g&&typeof g=="string"&&y.comma&&g.indexOf(",")>-1?g.split(","):g},E=function(g,y){var s,e={},o=y.ignoreQueryPrefix?g.replace(/^\?/,""):g,f=y.parameterLimit===1/0?void 0:y.parameterLimit,a=o.split(y.delimiter,f),i=-1,t=y.charset;if(y.charsetSentinel)for(s=0;s<a.length;++s)a[s].indexOf("utf8=")===0&&(a[s]==="utf8=%E2%9C%93"?t="utf-8":a[s]==="utf8=%26%2310003%3B"&&(t="iso-8859-1"),i=s,s=a.length);for(s=0;s<a.length;++s)if(s!==i){var u,c,r=a[s],h=r.indexOf("]="),d=h===-1?r.indexOf("="):h+1;d===-1?(u=y.decoder(r,T.decoder,t,"key"),c=y.strictNullHandling?null:""):(u=y.decoder(r.slice(0,d),T.decoder,t,"key"),c=m.maybeMap(_(r.slice(d+1),y),function(l){return y.decoder(l,T.decoder,t,"value")})),c&&y.interpretNumericEntities&&t==="iso-8859-1"&&(c=b(c)),r.indexOf("[]=")>-1&&(c=I(c)?[c]:c),S.call(e,u)?e[u]=m.combine(e[u],c):e[u]=c}return e},A=function(g,y,s,e){for(var o=e?y:_(y,s),f=g.length-1;f>=0;--f){var a,i=g[f];if(i==="[]"&&s.parseArrays)a=[].concat(o);else{a=s.plainObjects?Object.create(null):{};var t=i.charAt(0)==="["&&i.charAt(i.length-1)==="]"?i.slice(1,-1):i,u=parseInt(t,10);s.parseArrays||t!==""?!isNaN(u)&&i!==t&&String(u)===t&&u>=0&&s.parseArrays&&u<=s.arrayLimit?(a=[],a[u]=o):t!=="__proto__"&&(a[t]=o):a={0:o}}o=a}return o},D=function(g,y,s,e){if(g){var o=s.allowDots?g.replace(/\.([^.[]+)/g,"[$1]"):g,f=/(\[[^[\]]*])/,a=/(\[[^[\]]*])/g,i=s.depth>0&&f.exec(o),t=i?o.slice(0,i.index):o,u=[];if(t){if(!s.plainObjects&&S.call(Object.prototype,t)&&!s.allowPrototypes)return;u.push(t)}for(var c=0;s.depth>0&&(i=a.exec(o))!==null&&c<s.depth;){if(c+=1,!s.plainObjects&&S.call(Object.prototype,i[1].slice(1,-1))&&!s.allowPrototypes)return;u.push(i[1])}return i&&u.push("["+o.slice(i.index)+"]"),A(u,y,s,e)}},x=function(g){if(!g)return T;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 y=g.charset===void 0?T.charset:g.charset;return{allowDots:g.allowDots===void 0?T.allowDots:!!g.allowDots,allowPrototypes:typeof g.allowPrototypes=="boolean"?g.allowPrototypes:T.allowPrototypes,allowSparse:typeof g.allowSparse=="boolean"?g.allowSparse:T.allowSparse,arrayLimit:typeof g.arrayLimit=="number"?g.arrayLimit:T.arrayLimit,charset:y,charsetSentinel:typeof g.charsetSentinel=="boolean"?g.charsetSentinel:T.charsetSentinel,comma:typeof g.comma=="boolean"?g.comma:T.comma,decoder:typeof g.decoder=="function"?g.decoder:T.decoder,delimiter:typeof g.delimiter=="string"||m.isRegExp(g.delimiter)?g.delimiter:T.delimiter,depth:typeof g.depth=="number"||g.depth===!1?+g.depth:T.depth,ignoreQueryPrefix:g.ignoreQueryPrefix===!0,interpretNumericEntities:typeof g.interpretNumericEntities=="boolean"?g.interpretNumericEntities:T.interpretNumericEntities,parameterLimit:typeof g.parameterLimit=="number"?g.parameterLimit:T.parameterLimit,parseArrays:g.parseArrays!==!1,plainObjects:typeof g.plainObjects=="boolean"?g.plainObjects:T.plainObjects,strictNullHandling:typeof g.strictNullHandling=="boolean"?g.strictNullHandling:T.strictNullHandling}};P.exports=function(g,y){var s=x(y);if(g===""||g===null||g===void 0)return s.plainObjects?Object.create(null):{};for(var e=typeof g=="string"?E(g,s):g,o=s.plainObjects?Object.create(null):{},f=Object.keys(e),a=0;a<f.length;++a){var i=f[a],t=D(i,e[i],s,typeof g=="string");o=m.merge(o,t,s)}return s.allowSparse===!0?o:m.compact(o)}},function(P,n,R){"use strict";var m,S,I=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 b=!1;if(m=T,(S=typeof m=="function"?m.call(n,R,n,P):m)!==void 0&&(P.exports=S),b=!0,I(n)==="object"&&(P.exports=T(),b=!0),!b){var _=window.Cookies,E=window.Cookies=T();E.noConflict=function(){return window.Cookies=_,E}}})(function(){function T(_){function E(A,D,x){var g;if(typeof document!="undefined"){if(arguments.length>1){if(x=b({path:"/"},E.defaults,x),typeof x.expires=="number"){var y=new Date;y.setMilliseconds(y.getMilliseconds()+864e5*x.expires),x.expires=y}try{g=JSON.stringify(D),/^[\{\[]/.test(g)&&(D=g)}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,x.expires?"; expires="+x.expires.toUTCString():"",x.path?"; path="+x.path:"",x.domain?"; domain="+x.domain:"",x.secure?"; secure":""].join("")}A||(g={});for(var s=document.cookie?document.cookie.split("; "):[],e=/(%[0-9A-Z]{2})+/g,o=0;o<s.length;o++){var f=s[o].split("="),a=f.slice(1).join("=");a.charAt(0)==='"'&&(a=a.slice(1,-1));try{var i=f[0].replace(e,decodeURIComponent);if(a=_.read?_.read(a,i):_(a,i)||a.replace(e,decodeURIComponent),this.json)try{a=JSON.parse(a)}catch{}if(A===i){g=a;break}A||(g[i]=a)}catch{}}return g}}return E.set=E,E.get=function(A){return E.call(E,A)},E.getJSON=function(){return E.apply({json:!0},[].slice.call(arguments))},E.defaults={},E.remove=function(A,D){E(A,"",b(D,{expires:-1}))},E.withConverter=T,E}var b=function(){for(var _=0,E={};_<arguments.length;_++){var A=arguments[_];for(var D in A)E[D]=A[D]}return E};return T(function(){})})},function(P,n,R){"use strict";function m(S,I){var T=I.beaconCollectionDomain,b=I.beaconDomain;if(T)return"https://"+T;S=S||"inferred";var _=b||"litix.io";return S.match(/^[a-z0-9]+$/)?"https://"+S+"."+_:"https://img.litix.io/a.gif"}Object.defineProperty(n,"__esModule",{value:!0}),n.default=m},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var m=R(0),S=function(b){return b&&b.__esModule?b:{default:b}}(m),I=function(){var b=void 0;switch(T()){case"cellular":b="cellular";break;case"ethernet":b="wired";break;case"wifi":b="wifi";break;case void 0:break;default:b="other"}return b},T=function(){var b=S.default.navigator,_=b&&(b.connection||b.mozConnection||b.webkitConnection);return _&&_.type};n.default=I},function(P,n,R){"use strict";function m(a){return a&&a.__esModule?a:{default:a}}Object.defineProperty(n,"__esModule",{value:!0});var S=R(0),I=m(S),T=R(4),b=m(T),_=R(56),E=m(_),A=R(1),D=m(A),x=R(17),g=m(x),y=R(2),s=m(y),e=!!I.default.XMLHttpRequest&&"withCredentials"in new I.default.XMLHttpRequest,o={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4},f=function(a,i){this._beaconUrl=a||"https://img.litix.io",this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=(0,D.default)({},o,i)};f.prototype.queueEvent=function(a,i){var t=(0,D.default)({},i);return e?(this._eventQueue.length<=this._options.maxQueueLength||a==="eventrateexceeded")&&(this._eventQueue.push(t),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength):(E.default.send(this._beaconUrl,t),!0)},f.prototype.flushEvents=function(){e&&(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},f.prototype.destroy=function(){var a=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,a?this._clearBeaconQueue():this.flushEvents(),I.default.clearTimeout(this._sendTimeout)},f.prototype._clearBeaconQueue=function(){var a=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,D.default)(t[t.length-1],(0,g.default)({mux_view_message:"event queue truncated"}));var u=this._createPayload(t);if(a.sendBeacon)a.sendBeacon(this._beaconUrl,u);else if(I.default.XMLHttpRequest){var c=new I.default.XMLHttpRequest;c.open("POST",this._beaconUrl),c.setRequestHeader("Content-Type","application/json"),c.send(u)}else E.default.send(this._beaconUrl,t[t.length-1])},f.prototype._sendBeaconQueue=function(){var a=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?(a._eventQueue=t.concat(a._eventQueue),a._failureCount+=1,b.default.info("Error sending beacon: "+i.status),b.default.info(i.responseText)):a._failureCount=0,a._roundTripTime=s.default.now()-c,a._postInFlight=!1)},i.open("POST",this._beaconUrl),i.setRequestHeader("Content-Type","application/json");var u=this._createPayload(t),c=s.default.now();i.send(u)}},f.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var a=Math.pow(2,this._failureCount-1);return(1+(a*=Math.random()))*this._options.baseTimeBetweenBeacons},f.prototype._startBeaconSending=function(){var a=this;I.default.clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=I.default.setTimeout(function(){a._eventQueue.length&&a._sendBeaconQueue(),a._startBeaconSending()},this._getNextBeaconTime()))},f.prototype._createPayload=function(a){var i={transmission_timestamp:Math.round(s.default.now())};return this._roundTripTime&&(i.rtt_ms=Math.round(this._roundTripTime)),JSON.stringify({metadata:i,events:a})},n.default=f},function(P,n,R){"use strict";function m(E){return E&&E.__esModule?E:{default:E}}Object.defineProperty(n,"__esModule",{value:!0});var S=R(15),I=m(S),T=R(0),b=m(T),_={};_.send=function(E,A){function D(){x.src=y+(g?"&rc="+g:"")}var x=new Image,g=0,y=E+"?"+I.default.stringify(A);return x.addEventListener("error",function(){g>3||b.default.setTimeout(function(){g++,D()},5e3*g)}),D(),x},n.default=_},function(P,n,R){"use strict";function m(){function S(y,s){var e=s.request_start,o=s.request_response_start,f=s.request_response_end,a=s.request_bytes_loaded;A++;var i=void 0,t=void 0;if(o?(i=o-e,t=f-o):t=f-e,t>0&&a>0){var u=a/t*8e3;D++,_+=a,E+=t,this.data.view_min_request_throughput=Math.min(this.data.view_min_request_throughput||1/0,u),this.data.view_average_request_throughput=_/E*8e3,this.data.view_request_count=A,i>0&&(b+=i,this.data.view_max_request_latency=Math.max(this.data.view_max_request_latency||0,i),this.data.view_average_request_latency=b/D)}}function I(y,s){A++,x++,this.data.view_request_count=A,this.data.view_request_failed_count=x}function T(y,s){A++,g++,this.data.view_request_count=A,this.data.view_request_canceled_count=g}var b=0,_=0,E=0,A=0,D=0,x=0,g=0;this.on("requestcompleted",S),this.on("requestfailed",I),this.on("requestcanceled",T)}Object.defineProperty(n,"__esModule",{value:!0}),n.default=m},function(P,n,R){"use strict";function m(D,x,g){var y=(0,_.findMediaElement)(x),s=I(y,3),e=s[0],o=s[1],f=s[2],a=D.log,i=D.utils.getComputedStyle,t=D.utils.secondsToMs,u={automaticErrorTracking:!0};if(!e)return a.error("No element was found with the `"+o+"` query selector.");if(f!=="video"&&f!=="audio")return a.error("The element of `"+o+"` was not a media element.");g=(0,b.default)(u,g),g.data=(0,b.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,h=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||h||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,h){D.emit(o,r,h)};var c=function(){a.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=c,e.mux.swapElement=c,e.mux.emit=c,e.mux.addHLSJS=c,e.mux.addDashJS=c,e.mux.removeHLSJS=c,e.mux.removeDashJS=c,e.mux.deleted=!0,D.emit(o,"destroy")},e.mux.swapElement=function(r){var h=(0,_.findMediaElement)(r),d=I(h,3),l=d[0],v=d[1],p=d[2];return l?p!=="video"&&p!=="audio"?D.log.error("The element of `"+v+"` was not a media element."):(l.muxId=e.muxId,delete e.muxId,l.mux=l.mux||{},l.mux.listeners=(0,b.default)({},e.mux.listeners),delete e.mux.listeners,Object.keys(l.mux.listeners).forEach(function(L){e.removeEventListener(L,l.mux.listeners[L],!1),l.addEventListener(L,l.mux.listeners[L],!1)}),l.mux.swapElement=e.mux.swapElement,l.mux.destroy=e.mux.destroy,delete e.mux,void(e=l)):D.log.error("No element was found with the `"+v+"` query selector.")},e.mux.addHLSJS=function(r){D.addHLSJS(o,r)},e.mux.addDashJS=function(r){D.addDashJS(o,r)},e.mux.removeHLSJS=function(){D.removeHLSJS(o)},e.mux.removeDashJS=function(){D.removeDashJS(o)},D.init(o,g),D.emit(o,"playerready"),e.paused||(D.emit(o,"play"),e.readyState>2&&D.emit(o,"playing")),e.mux.listeners={},E.forEach(function(r){(r!=="error"||g.automaticErrorTracking)&&(e.mux.listeners[r]=function(){var h={};if(r==="error"){if(!e.error||e.error.code===1)return;h.player_error_code=e.error.code,h.player_error_message=A[e.error.code]||e.error.message}D.emit(o,r,h)},e.addEventListener(r,e.mux.listeners[r],!1))})}Object.defineProperty(n,"__esModule",{value:!0});var S=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},I=function(){function D(x,g){var y=[],s=!0,e=!1,o=void 0;try{for(var f,a=x[Symbol.iterator]();!(s=(f=a.next()).done)&&(y.push(f.value),!g||y.length!==g);s=!0);}catch(i){e=!0,o=i}finally{try{!s&&a.return&&a.return()}finally{if(e)throw o}}return y}return function(x,g){if(Array.isArray(x))return x;if(Symbol.iterator in Object(x))return D(x,g);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();n.default=m;var T=R(1),b=function(D){return D&&D.__esModule?D:{default:D}}(T),_=R(11),E=["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(P,n,R){"use strict";function m(u){return u&&u.__esModule?u:{default:u}}Object.defineProperty(n,"__esModule",{value:!0});var S=R(60),I=m(S),T=R(3),b=m(T),_=R(61),E=m(_),A=R(62),D=m(A),x=R(1),g=m(x),y=R(7),s=m(y),e=R(5),o=R(2),f=m(o),a=R(63),i=m(a),t={};t.safeCall=I.default,t.safeIncrement=b.default,t.getComputedStyle=E.default,t.secondsToMs=D.default,t.assign=g.default,t.headersStringToObject=s.default,t.extractHostnameAndDomain=e.extractHostnameAndDomain,t.extractHostname=e.extractHostname,t.now=f.default.now,t.manifestParser=i.default,n.default=t},function(P,n,R){"use strict";function m(T,b,_,E){var A=E;if(T&&typeof T[b]=="function")try{A=T[b].apply(T,_)}catch(D){I.default.info("safeCall error",D)}return A}Object.defineProperty(n,"__esModule",{value:!0}),n.default=m;var S=R(4),I=function(T){return T&&T.__esModule?T:{default:T}}(S)},function(P,n,R){"use strict";function m(b,_){if(b&&_&&I.default&&typeof I.default.getComputedStyle=="function"){var E=void 0;return T&&T.has(b)&&(E=T.get(b)),E||(E=I.default.getComputedStyle(b,null),T&&T.set(b,E)),E.getPropertyValue(_)}}Object.defineProperty(n,"__esModule",{value:!0}),n.default=m;var S=R(0),I=function(b){return b&&b.__esModule?b:{default:b}}(S),T=void 0;I.default&&I.default.WeakMap&&(T=new WeakMap)},function(P,n,R){"use strict";function m(S){return Math.floor(1e3*S)}Object.defineProperty(n,"__esModule",{value:!0}),n.default=m},function(P,n,R){"use strict";function m(f){return f&&f.__esModule?f:{default:f}}Object.defineProperty(n,"__esModule",{value:!0});var S=R(1),I=m(S),T=R(14),b=m(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"},E=function(f){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(f),this.manifest};E.prototype.process=function(f){var a=void 0;for(this.buffer+=f,a=this.buffer.indexOf(`
|
|
5
5
|
`);a>-1;a=this.buffer.indexOf(`
|
|
6
|
-
`))this.processLine(this.buffer.substring(0,a)),this.buffer=this.buffer.substring(a+1)},E.prototype.processLine=function(f){var a=f.indexOf(":"),i=e(f,a),t=i[0],u=i.length===2?x(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 _.TARGET_DURATION:if(!isFinite(u)||u<0)return;this.manifest.targetDuration=u,this.setHoldBack();break;case _.PART_INF:A(this.manifest,i),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case _.SERVER_CONTROL:A(this.manifest,i),this.setHoldBack();break;case _.INF:u===0?this.currentUri.duration=.01:u>0&&(this.currentUri.duration=u);break;case _.PROGRAM_DATE_TIME:var c=u,r=new Date(c);this.manifest.dateTimeString||(this.manifest.dateTimeString=c,this.manifest.dateTimeObject=r),this.currentUri.dateTimeString=c,this.currentUri.dateTimeObject=r;break;case _.VERSION:A(this.manifest,i);break;case _.SESSION_DATA:var h=o(i[1]),d=(0,O.default)(h);(0,I.default)(this.manifest.sessionData,d)}},E.prototype.setHoldBack=function(){var f=this.manifest,a=f.serverControl,i=f.targetDuration,t=f.partTargetDuration;if(a){var u="holdBack",c="partHoldBack",r=i&&3*i,h=t&&2*t;i&&!a.hasOwnProperty(u)&&(a[u]=r),r&&a[u]<r&&(a[u]=r),t&&!a.hasOwnProperty(c)&&(a[c]=3*t),t&&a[c]<h&&(a[c]=h)}};var A=function(f,a){var i=D(a[0].replace("#EXT-X-","")),t=void 0;s(a[1])?(t={},t=(0,I.default)(y(a[1]),t)):t=x(a[1]),f[i]=t},D=function(f){return f.toLowerCase().replace(/-(\w)/g,function(a){return a[1].toUpperCase()})},x=function(f){if(f.toLowerCase()==="yes"||f.toLowerCase()==="no")return f.toLowerCase()==="yes";var a=f.indexOf(":")!==-1?f:parseFloat(f);return isNaN(a)?f:a},g=function(f){var a={},i=f.split("=");return i.length>1&&(a[D(i[0])]=x(i[1])),a},y=function(f){for(var a=f.split(","),i={},t=0;a.length>t;t++){var u=a[t],c=g(u);i=(0,I.default)(c,i)}return i},s=function(f){return f.indexOf("=")>-1},e=function(f,a){return a===-1?[f]:[f.substring(0,a),f.substring(a+1)]},o=function(f){var a={};if(f){var i=f.search(",");return[f.slice(0,i),f.slice(i+1)].forEach(function(t,u){for(var c=t.replace(/['"]+/g,"").split("="),r=0;r<c.length;r++)c[r]==="DATA-ID"&&(a["DATA-ID"]=c[1-r]),c[r]==="VALUE"&&(a.VALUE=c[1-r])}),{data:a}}};n.default=E},function(P,n,R){"use strict";Object.defineProperty(n,"__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"};n.default=p}])})})()});var Tt=Qt((lt,Mt)=>{typeof window!="undefined"&&function(P,n){typeof lt=="object"&&typeof Mt=="object"?Mt.exports=n():typeof define=="function"&&define.amd?define([],n):typeof lt=="object"?lt.Hls=n():P.Hls=n()}(lt,function(){return function(B){var P={};function n(R){if(P[R])return P[R].exports;var p=P[R]={i:R,l:!1,exports:{}};return B[R].call(p.exports,p,p.exports,n),p.l=!0,p.exports}return n.m=B,n.c=P,n.d=function(R,p,T){n.o(R,p)||Object.defineProperty(R,p,{enumerable:!0,get:T})},n.r=function(R){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(R,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(R,"__esModule",{value:!0})},n.t=function(R,p){if(p&1&&(R=n(R)),p&8||p&4&&typeof R=="object"&&R&&R.__esModule)return R;var T=Object.create(null);if(n.r(T),Object.defineProperty(T,"default",{enumerable:!0,value:R}),p&2&&typeof R!="string")for(var I in R)n.d(T,I,function(S){return R[S]}.bind(null,I));return T},n.n=function(R){var p=R&&R.__esModule?function(){return R.default}:function(){return R};return n.d(p,"a",p),p},n.o=function(R,p){return Object.prototype.hasOwnProperty.call(R,p)},n.p="/dist/",n(n.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(B,P,n){"use strict";var R=Object.prototype.hasOwnProperty,p="~";function T(){}Object.create&&(T.prototype=Object.create(null),new T().__proto__||(p=!1));function I(E,A,D){this.fn=E,this.context=A,this.once=D||!1}function S(E,A,D,x,g){if(typeof D!="function")throw new TypeError("The listener must be a function");var y=new I(D,x||E,g),s=p?p+A:A;return E._events[s]?E._events[s].fn?E._events[s]=[E._events[s],y]:E._events[s].push(y):(E._events[s]=y,E._eventsCount++),E}function O(E,A){--E._eventsCount===0?E._events=new T:delete E._events[A]}function _(){this._events=new T,this._eventsCount=0}_.prototype.eventNames=function(){var A=[],D,x;if(this._eventsCount===0)return A;for(x in D=this._events)R.call(D,x)&&A.push(p?x.slice(1):x);return Object.getOwnPropertySymbols?A.concat(Object.getOwnPropertySymbols(D)):A},_.prototype.listeners=function(A){var D=p?p+A:A,x=this._events[D];if(!x)return[];if(x.fn)return[x.fn];for(var g=0,y=x.length,s=new Array(y);g<y;g++)s[g]=x[g].fn;return s},_.prototype.listenerCount=function(A){var D=p?p+A:A,x=this._events[D];return x?x.fn?1:x.length:0},_.prototype.emit=function(A,D,x,g,y,s){var e=p?p+A:A;if(!this._events[e])return!1;var o=this._events[e],f=arguments.length,a,i;if(o.fn){switch(o.once&&this.removeListener(A,o.fn,void 0,!0),f){case 1:return o.fn.call(o.context),!0;case 2:return o.fn.call(o.context,D),!0;case 3:return o.fn.call(o.context,D,x),!0;case 4:return o.fn.call(o.context,D,x,g),!0;case 5:return o.fn.call(o.context,D,x,g,y),!0;case 6:return o.fn.call(o.context,D,x,g,y,s),!0}for(i=1,a=new Array(f-1);i<f;i++)a[i-1]=arguments[i];o.fn.apply(o.context,a)}else{var t=o.length,u;for(i=0;i<t;i++)switch(o[i].once&&this.removeListener(A,o[i].fn,void 0,!0),f){case 1:o[i].fn.call(o[i].context);break;case 2:o[i].fn.call(o[i].context,D);break;case 3:o[i].fn.call(o[i].context,D,x);break;case 4:o[i].fn.call(o[i].context,D,x,g);break;default:if(!a)for(u=1,a=new Array(f-1);u<f;u++)a[u-1]=arguments[u];o[i].fn.apply(o[i].context,a)}}return!0},_.prototype.on=function(A,D,x){return S(this,A,D,x,!1)},_.prototype.once=function(A,D,x){return S(this,A,D,x,!0)},_.prototype.removeListener=function(A,D,x,g){var y=p?p+A:A;if(!this._events[y])return this;if(!D)return O(this,y),this;var s=this._events[y];if(s.fn)s.fn===D&&(!g||s.once)&&(!x||s.context===x)&&O(this,y);else{for(var e=0,o=[],f=s.length;e<f;e++)(s[e].fn!==D||g&&!s[e].once||x&&s[e].context!==x)&&o.push(s[e]);o.length?this._events[y]=o.length===1?o[0]:o:O(this,y)}return this},_.prototype.removeAllListeners=function(A){var D;return A?(D=p?p+A:A,this._events[D]&&O(this,D)):(this._events=new T,this._eventsCount=0),this},_.prototype.off=_.prototype.removeListener,_.prototype.addListener=_.prototype.on,_.prefixed=p,_.EventEmitter=_,B.exports=_},"./node_modules/url-toolkit/src/url-toolkit.js":function(B,P,n){(function(R){var p=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,T=/^(?=([^\/?#]*))\1([^]*)$/,I=/(?:\/|^)\.(?=\/)/g,S=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,O={buildAbsoluteURL:function(_,E,A){if(A=A||{},_=_.trim(),E=E.trim(),!E){if(!A.alwaysNormalize)return _;var D=O.parseURL(_);if(!D)throw new Error("Error trying to parse base URL.");return D.path=O.normalizePath(D.path),O.buildURLFromParts(D)}var x=O.parseURL(E);if(!x)throw new Error("Error trying to parse relative URL.");if(x.scheme)return A.alwaysNormalize?(x.path=O.normalizePath(x.path),O.buildURLFromParts(x)):E;var g=O.parseURL(_);if(!g)throw new Error("Error trying to parse base URL.");if(!g.netLoc&&g.path&&g.path[0]!=="/"){var y=T.exec(g.path);g.netLoc=y[1],g.path=y[2]}g.netLoc&&!g.path&&(g.path="/");var s={scheme:g.scheme,netLoc:x.netLoc,path:null,params:x.params,query:x.query,fragment:x.fragment};if(!x.netLoc&&(s.netLoc=g.netLoc,x.path[0]!=="/"))if(!x.path)s.path=g.path,x.params||(s.params=g.params,x.query||(s.query=g.query));else{var e=g.path,o=e.substring(0,e.lastIndexOf("/")+1)+x.path;s.path=O.normalizePath(o)}return s.path===null&&(s.path=A.alwaysNormalize?O.normalizePath(x.path):x.path),O.buildURLFromParts(s)},parseURL:function(_){var E=p.exec(_);return E?{scheme:E[1]||"",netLoc:E[2]||"",path:E[3]||"",params:E[4]||"",query:E[5]||"",fragment:E[6]||""}:null},normalizePath:function(_){for(_=_.split("").reverse().join("").replace(I,"");_.length!==(_=_.replace(S,"")).length;);return _.split("").reverse().join("")},buildURLFromParts:function(_){return _.scheme+_.netLoc+_.path+_.params+_.query+_.fragment}};B.exports=O})(this)},"./node_modules/webworkify-webpack/index.js":function(B,P,n){function R(A){var D={};function x(y){if(D[y])return D[y].exports;var s=D[y]={i:y,l:!1,exports:{}};return A[y].call(s.exports,s,s.exports,x),s.l=!0,s.exports}x.m=A,x.c=D,x.i=function(y){return y},x.d=function(y,s,e){x.o(y,s)||Object.defineProperty(y,s,{configurable:!1,enumerable:!0,get:e})},x.r=function(y){Object.defineProperty(y,"__esModule",{value:!0})},x.n=function(y){var s=y&&y.__esModule?function(){return y.default}:function(){return y};return x.d(s,"a",s),s},x.o=function(y,s){return Object.prototype.hasOwnProperty.call(y,s)},x.p="/",x.oe=function(y){throw console.error(y),y};var g=x(x.s=ENTRY_MODULE);return g.default||g}var p="[\\.|\\-|\\+|\\w|/|@]+",T="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+p+").*?\\)";function I(A){return(A+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function S(A){return!isNaN(1*A)}function O(A,D,x){var g={};g[x]=[];var y=D.toString(),s=y.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!s)return g;for(var e=s[1],o=new RegExp("(\\\\n|\\W)"+I(e)+T,"g"),f;f=o.exec(y);)f[3]!=="dll-reference"&&g[x].push(f[3]);for(o=new RegExp("\\("+I(e)+'\\("(dll-reference\\s('+p+'))"\\)\\)'+T,"g");f=o.exec(y);)A[f[2]]||(g[x].push(f[1]),A[f[2]]=n(f[1]).m),g[f[2]]=g[f[2]]||[],g[f[2]].push(f[4]);for(var a=Object.keys(g),i=0;i<a.length;i++)for(var t=0;t<g[a[i]].length;t++)S(g[a[i]][t])&&(g[a[i]][t]=1*g[a[i]][t]);return g}function _(A){var D=Object.keys(A);return D.reduce(function(x,g){return x||A[g].length>0},!1)}function E(A,D){for(var x={main:[D]},g={main:[]},y={main:{}};_(x);)for(var s=Object.keys(x),e=0;e<s.length;e++){var o=s[e],f=x[o],a=f.pop();if(y[o]=y[o]||{},!(y[o][a]||!A[o][a])){y[o][a]=!0,g[o]=g[o]||[],g[o].push(a);for(var i=O(A,A[o][a],o),t=Object.keys(i),u=0;u<t.length;u++)x[t[u]]=x[t[u]]||[],x[t[u]]=x[t[u]].concat(i[t[u]])}}return g}B.exports=function(A,D){D=D||{};var x={main:n.m},g=D.all?{main:Object.keys(x.main)}:E(x,A),y="";Object.keys(g).filter(function(a){return a!=="main"}).forEach(function(a){for(var i=0;g[a][i];)i++;g[a].push(i),x[a][i]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",y=y+"var "+a+" = ("+R.toString().replace("ENTRY_MODULE",JSON.stringify(i))+")({"+g[a].map(function(t){return""+JSON.stringify(t)+": "+x[a][t].toString()}).join(",")+`});
|
|
7
|
-
`}),y=y+"new (("+R.toString().replace("ENTRY_MODULE",JSON.stringify(A))+")({"+g.main.map(function(a){return""+JSON.stringify(a)+": "+x.main[a].toString()}).join(",")+"}))(self);";var s=new window.Blob([y],{type:"text/javascript"});if(D.bare)return s;var e=window.URL||window.webkitURL||window.mozURL||window.msURL,o=e.createObjectURL(s),f=new window.Worker(o);return f.objectURL=o,f}},"./src/config.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"hlsDefaultConfig",function(){return u}),n.d(P,"mergeConfig",function(){return r}),n.d(P,"enableStreamingMode",function(){return h});var R=n("./src/controller/abr-controller.ts"),
|
|
8
|
-
Current BW estimate: `+(Object(R.isFiniteNumber)(
|
|
6
|
+
`))this.processLine(this.buffer.substring(0,a)),this.buffer=this.buffer.substring(a+1)},E.prototype.processLine=function(f){var a=f.indexOf(":"),i=e(f,a),t=i[0],u=i.length===2?x(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 _.TARGET_DURATION:if(!isFinite(u)||u<0)return;this.manifest.targetDuration=u,this.setHoldBack();break;case _.PART_INF:A(this.manifest,i),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case _.SERVER_CONTROL:A(this.manifest,i),this.setHoldBack();break;case _.INF:u===0?this.currentUri.duration=.01:u>0&&(this.currentUri.duration=u);break;case _.PROGRAM_DATE_TIME:var c=u,r=new Date(c);this.manifest.dateTimeString||(this.manifest.dateTimeString=c,this.manifest.dateTimeObject=r),this.currentUri.dateTimeString=c,this.currentUri.dateTimeObject=r;break;case _.VERSION:A(this.manifest,i);break;case _.SESSION_DATA:var h=o(i[1]),d=(0,b.default)(h);(0,I.default)(this.manifest.sessionData,d)}},E.prototype.setHoldBack=function(){var f=this.manifest,a=f.serverControl,i=f.targetDuration,t=f.partTargetDuration;if(a){var u="holdBack",c="partHoldBack",r=i&&3*i,h=t&&2*t;i&&!a.hasOwnProperty(u)&&(a[u]=r),r&&a[u]<r&&(a[u]=r),t&&!a.hasOwnProperty(c)&&(a[c]=3*t),t&&a[c]<h&&(a[c]=h)}};var A=function(f,a){var i=D(a[0].replace("#EXT-X-","")),t=void 0;s(a[1])?(t={},t=(0,I.default)(y(a[1]),t)):t=x(a[1]),f[i]=t},D=function(f){return f.toLowerCase().replace(/-(\w)/g,function(a){return a[1].toUpperCase()})},x=function(f){if(f.toLowerCase()==="yes"||f.toLowerCase()==="no")return f.toLowerCase()==="yes";var a=f.indexOf(":")!==-1?f:parseFloat(f);return isNaN(a)?f:a},g=function(f){var a={},i=f.split("=");return i.length>1&&(a[D(i[0])]=x(i[1])),a},y=function(f){for(var a=f.split(","),i={},t=0;a.length>t;t++){var u=a[t],c=g(u);i=(0,I.default)(c,i)}return i},s=function(f){return f.indexOf("=")>-1},e=function(f,a){return a===-1?[f]:[f.substring(0,a),f.substring(a+1)]},o=function(f){var a={};if(f){var i=f.search(",");return[f.slice(0,i),f.slice(i+1)].forEach(function(t,u){for(var c=t.replace(/['"]+/g,"").split("="),r=0;r<c.length;r++)c[r]==="DATA-ID"&&(a["DATA-ID"]=c[1-r]),c[r]==="VALUE"&&(a.VALUE=c[1-r])}),{data:a}}};n.default=E},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var m={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"};n.default=m}])})})()});var St=Qt((lt,Ft)=>{typeof window!="undefined"&&function(P,n){typeof lt=="object"&&typeof Ft=="object"?Ft.exports=n():typeof define=="function"&&define.amd?define([],n):typeof lt=="object"?lt.Hls=n():P.Hls=n()}(lt,function(){return function(B){var P={};function n(R){if(P[R])return P[R].exports;var m=P[R]={i:R,l:!1,exports:{}};return B[R].call(m.exports,m,m.exports,n),m.l=!0,m.exports}return n.m=B,n.c=P,n.d=function(R,m,S){n.o(R,m)||Object.defineProperty(R,m,{enumerable:!0,get:S})},n.r=function(R){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(R,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(R,"__esModule",{value:!0})},n.t=function(R,m){if(m&1&&(R=n(R)),m&8||m&4&&typeof R=="object"&&R&&R.__esModule)return R;var S=Object.create(null);if(n.r(S),Object.defineProperty(S,"default",{enumerable:!0,value:R}),m&2&&typeof R!="string")for(var I in R)n.d(S,I,function(T){return R[T]}.bind(null,I));return S},n.n=function(R){var m=R&&R.__esModule?function(){return R.default}:function(){return R};return n.d(m,"a",m),m},n.o=function(R,m){return Object.prototype.hasOwnProperty.call(R,m)},n.p="/dist/",n(n.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(B,P,n){"use strict";var R=Object.prototype.hasOwnProperty,m="~";function S(){}Object.create&&(S.prototype=Object.create(null),new S().__proto__||(m=!1));function I(E,A,D){this.fn=E,this.context=A,this.once=D||!1}function T(E,A,D,x,g){if(typeof D!="function")throw new TypeError("The listener must be a function");var y=new I(D,x||E,g),s=m?m+A:A;return E._events[s]?E._events[s].fn?E._events[s]=[E._events[s],y]:E._events[s].push(y):(E._events[s]=y,E._eventsCount++),E}function b(E,A){--E._eventsCount===0?E._events=new S:delete E._events[A]}function _(){this._events=new S,this._eventsCount=0}_.prototype.eventNames=function(){var A=[],D,x;if(this._eventsCount===0)return A;for(x in D=this._events)R.call(D,x)&&A.push(m?x.slice(1):x);return Object.getOwnPropertySymbols?A.concat(Object.getOwnPropertySymbols(D)):A},_.prototype.listeners=function(A){var D=m?m+A:A,x=this._events[D];if(!x)return[];if(x.fn)return[x.fn];for(var g=0,y=x.length,s=new Array(y);g<y;g++)s[g]=x[g].fn;return s},_.prototype.listenerCount=function(A){var D=m?m+A:A,x=this._events[D];return x?x.fn?1:x.length:0},_.prototype.emit=function(A,D,x,g,y,s){var e=m?m+A:A;if(!this._events[e])return!1;var o=this._events[e],f=arguments.length,a,i;if(o.fn){switch(o.once&&this.removeListener(A,o.fn,void 0,!0),f){case 1:return o.fn.call(o.context),!0;case 2:return o.fn.call(o.context,D),!0;case 3:return o.fn.call(o.context,D,x),!0;case 4:return o.fn.call(o.context,D,x,g),!0;case 5:return o.fn.call(o.context,D,x,g,y),!0;case 6:return o.fn.call(o.context,D,x,g,y,s),!0}for(i=1,a=new Array(f-1);i<f;i++)a[i-1]=arguments[i];o.fn.apply(o.context,a)}else{var t=o.length,u;for(i=0;i<t;i++)switch(o[i].once&&this.removeListener(A,o[i].fn,void 0,!0),f){case 1:o[i].fn.call(o[i].context);break;case 2:o[i].fn.call(o[i].context,D);break;case 3:o[i].fn.call(o[i].context,D,x);break;case 4:o[i].fn.call(o[i].context,D,x,g);break;default:if(!a)for(u=1,a=new Array(f-1);u<f;u++)a[u-1]=arguments[u];o[i].fn.apply(o[i].context,a)}}return!0},_.prototype.on=function(A,D,x){return T(this,A,D,x,!1)},_.prototype.once=function(A,D,x){return T(this,A,D,x,!0)},_.prototype.removeListener=function(A,D,x,g){var y=m?m+A:A;if(!this._events[y])return this;if(!D)return b(this,y),this;var s=this._events[y];if(s.fn)s.fn===D&&(!g||s.once)&&(!x||s.context===x)&&b(this,y);else{for(var e=0,o=[],f=s.length;e<f;e++)(s[e].fn!==D||g&&!s[e].once||x&&s[e].context!==x)&&o.push(s[e]);o.length?this._events[y]=o.length===1?o[0]:o:b(this,y)}return this},_.prototype.removeAllListeners=function(A){var D;return A?(D=m?m+A:A,this._events[D]&&b(this,D)):(this._events=new S,this._eventsCount=0),this},_.prototype.off=_.prototype.removeListener,_.prototype.addListener=_.prototype.on,_.prefixed=m,_.EventEmitter=_,B.exports=_},"./node_modules/url-toolkit/src/url-toolkit.js":function(B,P,n){(function(R){var m=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,S=/^(?=([^\/?#]*))\1([^]*)$/,I=/(?:\/|^)\.(?=\/)/g,T=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,b={buildAbsoluteURL:function(_,E,A){if(A=A||{},_=_.trim(),E=E.trim(),!E){if(!A.alwaysNormalize)return _;var D=b.parseURL(_);if(!D)throw new Error("Error trying to parse base URL.");return D.path=b.normalizePath(D.path),b.buildURLFromParts(D)}var x=b.parseURL(E);if(!x)throw new Error("Error trying to parse relative URL.");if(x.scheme)return A.alwaysNormalize?(x.path=b.normalizePath(x.path),b.buildURLFromParts(x)):E;var g=b.parseURL(_);if(!g)throw new Error("Error trying to parse base URL.");if(!g.netLoc&&g.path&&g.path[0]!=="/"){var y=S.exec(g.path);g.netLoc=y[1],g.path=y[2]}g.netLoc&&!g.path&&(g.path="/");var s={scheme:g.scheme,netLoc:x.netLoc,path:null,params:x.params,query:x.query,fragment:x.fragment};if(!x.netLoc&&(s.netLoc=g.netLoc,x.path[0]!=="/"))if(!x.path)s.path=g.path,x.params||(s.params=g.params,x.query||(s.query=g.query));else{var e=g.path,o=e.substring(0,e.lastIndexOf("/")+1)+x.path;s.path=b.normalizePath(o)}return s.path===null&&(s.path=A.alwaysNormalize?b.normalizePath(x.path):x.path),b.buildURLFromParts(s)},parseURL:function(_){var E=m.exec(_);return E?{scheme:E[1]||"",netLoc:E[2]||"",path:E[3]||"",params:E[4]||"",query:E[5]||"",fragment:E[6]||""}:null},normalizePath:function(_){for(_=_.split("").reverse().join("").replace(I,"");_.length!==(_=_.replace(T,"")).length;);return _.split("").reverse().join("")},buildURLFromParts:function(_){return _.scheme+_.netLoc+_.path+_.params+_.query+_.fragment}};B.exports=b})(this)},"./node_modules/webworkify-webpack/index.js":function(B,P,n){function R(A){var D={};function x(y){if(D[y])return D[y].exports;var s=D[y]={i:y,l:!1,exports:{}};return A[y].call(s.exports,s,s.exports,x),s.l=!0,s.exports}x.m=A,x.c=D,x.i=function(y){return y},x.d=function(y,s,e){x.o(y,s)||Object.defineProperty(y,s,{configurable:!1,enumerable:!0,get:e})},x.r=function(y){Object.defineProperty(y,"__esModule",{value:!0})},x.n=function(y){var s=y&&y.__esModule?function(){return y.default}:function(){return y};return x.d(s,"a",s),s},x.o=function(y,s){return Object.prototype.hasOwnProperty.call(y,s)},x.p="/",x.oe=function(y){throw console.error(y),y};var g=x(x.s=ENTRY_MODULE);return g.default||g}var m="[\\.|\\-|\\+|\\w|/|@]+",S="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+m+").*?\\)";function I(A){return(A+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function T(A){return!isNaN(1*A)}function b(A,D,x){var g={};g[x]=[];var y=D.toString(),s=y.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!s)return g;for(var e=s[1],o=new RegExp("(\\\\n|\\W)"+I(e)+S,"g"),f;f=o.exec(y);)f[3]!=="dll-reference"&&g[x].push(f[3]);for(o=new RegExp("\\("+I(e)+'\\("(dll-reference\\s('+m+'))"\\)\\)'+S,"g");f=o.exec(y);)A[f[2]]||(g[x].push(f[1]),A[f[2]]=n(f[1]).m),g[f[2]]=g[f[2]]||[],g[f[2]].push(f[4]);for(var a=Object.keys(g),i=0;i<a.length;i++)for(var t=0;t<g[a[i]].length;t++)T(g[a[i]][t])&&(g[a[i]][t]=1*g[a[i]][t]);return g}function _(A){var D=Object.keys(A);return D.reduce(function(x,g){return x||A[g].length>0},!1)}function E(A,D){for(var x={main:[D]},g={main:[]},y={main:{}};_(x);)for(var s=Object.keys(x),e=0;e<s.length;e++){var o=s[e],f=x[o],a=f.pop();if(y[o]=y[o]||{},!(y[o][a]||!A[o][a])){y[o][a]=!0,g[o]=g[o]||[],g[o].push(a);for(var i=b(A,A[o][a],o),t=Object.keys(i),u=0;u<t.length;u++)x[t[u]]=x[t[u]]||[],x[t[u]]=x[t[u]].concat(i[t[u]])}}return g}B.exports=function(A,D){D=D||{};var x={main:n.m},g=D.all?{main:Object.keys(x.main)}:E(x,A),y="";Object.keys(g).filter(function(a){return a!=="main"}).forEach(function(a){for(var i=0;g[a][i];)i++;g[a].push(i),x[a][i]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",y=y+"var "+a+" = ("+R.toString().replace("ENTRY_MODULE",JSON.stringify(i))+")({"+g[a].map(function(t){return""+JSON.stringify(t)+": "+x[a][t].toString()}).join(",")+`});
|
|
7
|
+
`}),y=y+"new (("+R.toString().replace("ENTRY_MODULE",JSON.stringify(A))+")({"+g.main.map(function(a){return""+JSON.stringify(a)+": "+x.main[a].toString()}).join(",")+"}))(self);";var s=new window.Blob([y],{type:"text/javascript"});if(D.bare)return s;var e=window.URL||window.webkitURL||window.mozURL||window.msURL,o=e.createObjectURL(s),f=new window.Worker(o);return f.objectURL=o,f}},"./src/config.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"hlsDefaultConfig",function(){return u}),n.d(P,"mergeConfig",function(){return r}),n.d(P,"enableStreamingMode",function(){return h});var R=n("./src/controller/abr-controller.ts"),m=n("./src/controller/audio-stream-controller.ts"),S=n("./src/controller/audio-track-controller.ts"),I=n("./src/controller/subtitle-stream-controller.ts"),T=n("./src/controller/subtitle-track-controller.ts"),b=n("./src/controller/buffer-controller.ts"),_=n("./src/controller/timeline-controller.ts"),E=n("./src/controller/cap-level-controller.ts"),A=n("./src/controller/fps-controller.ts"),D=n("./src/controller/eme-controller.ts"),x=n("./src/controller/cmcd-controller.ts"),g=n("./src/utils/xhr-loader.ts"),y=n("./src/utils/fetch-loader.ts"),s=n("./src/utils/cues.ts"),e=n("./src/utils/mediakeys-helper.ts"),o=n("./src/utils/logger.ts");function f(){return f=Object.assign?Object.assign.bind():function(d){for(var l=1;l<arguments.length;l++){var v=arguments[l];for(var p in v)Object.prototype.hasOwnProperty.call(v,p)&&(d[p]=v[p])}return d},f.apply(this,arguments)}function a(d,l){var v=Object.keys(d);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(d);l&&(p=p.filter(function(L){return Object.getOwnPropertyDescriptor(d,L).enumerable})),v.push.apply(v,p)}return v}function i(d){for(var l=1;l<arguments.length;l++){var v=arguments[l]!=null?arguments[l]:{};l%2?a(Object(v),!0).forEach(function(p){t(d,p,v[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(v)):a(Object(v)).forEach(function(p){Object.defineProperty(d,p,Object.getOwnPropertyDescriptor(v,p))})}return d}function t(d,l,v){return l in d?Object.defineProperty(d,l,{value:v,enumerable:!0,configurable:!0,writable:!0}):d[l]=v,d}var u=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:b.default,capLevelController:E.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,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},c()),{},{subtitleStreamController:I.SubtitleStreamController,subtitleTrackController:T.default,timelineController:_.TimelineController,audioStreamController:m.default,audioTrackController:S.default,emeController:D.default,cmcdController:x.default});function c(){return{cueHandler:s.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(d,l){if((l.liveSyncDurationCount||l.liveMaxLatencyDurationCount)&&(l.liveSyncDuration||l.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(l.liveMaxLatencyDurationCount!==void 0&&(l.liveSyncDurationCount===void 0||l.liveMaxLatencyDurationCount<=l.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(l.liveMaxLatencyDuration!==void 0&&(l.liveSyncDuration===void 0||l.liveMaxLatencyDuration<=l.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return f({},d,l)}function h(d){var l=d.loader;if(l!==y.default&&l!==g.default)o.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),d.progressive=!1;else{var v=Object(y.fetchSupported)();v&&(d.loader=y.default,d.progressive=!0,d.enableSoftwareAES=!0,o.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/polyfills/number.ts"),m=n("./src/utils/ewma-bandwidth-estimator.ts"),S=n("./src/events.ts"),I=n("./src/utils/buffer-helper.ts"),T=n("./src/errors.ts"),b=n("./src/types/loader.ts"),_=n("./src/utils/logger.ts");function E(x,g){for(var y=0;y<g.length;y++){var s=g[y];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(x,s.key,s)}}function A(x,g,y){return g&&E(x.prototype,g),y&&E(x,y),Object.defineProperty(x,"prototype",{writable:!1}),x}var D=function(){function x(y){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=y;var s=y.config;this.bwEstimator=new m.default(s.abrEwmaSlowVoD,s.abrEwmaFastVoD,s.abrEwmaDefaultEstimate),this.registerListeners()}var g=x.prototype;return g.registerListeners=function(){var s=this.hls;s.on(S.Events.FRAG_LOADING,this.onFragLoading,this),s.on(S.Events.FRAG_LOADED,this.onFragLoaded,this),s.on(S.Events.FRAG_BUFFERED,this.onFragBuffered,this),s.on(S.Events.LEVEL_LOADED,this.onLevelLoaded,this),s.on(S.Events.ERROR,this.onError,this)},g.unregisterListeners=function(){var s=this.hls;s.off(S.Events.FRAG_LOADING,this.onFragLoading,this),s.off(S.Events.FRAG_LOADED,this.onFragLoaded,this),s.off(S.Events.FRAG_BUFFERED,this.onFragBuffered,this),s.off(S.Events.LEVEL_LOADED,this.onLevelLoaded,this),s.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(s,e){var o=e.frag;if(o.type===b.PlaylistLevelType.MAIN&&!this.timer){var f;this.fragCurrent=o,this.partCurrent=(f=e.part)!=null?f:null,this.timer=self.setInterval(this.onCheck,100)}},g.onLevelLoaded=function(s,e){var o=this.hls.config;e.details.live?this.bwEstimator.update(o.abrEwmaSlowLive,o.abrEwmaFastLive):this.bwEstimator.update(o.abrEwmaSlowVoD,o.abrEwmaFastVoD)},g._abandonRulesCheck=function(){var s=this.fragCurrent,e=this.partCurrent,o=this.hls,f=o.autoLevelEnabled,a=o.config,i=o.media;if(!(!s||!i)){var t=e?e.stats:s.stats,u=e?e.duration:s.duration;if(t.aborted){_.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!(!f||i.paused||!i.playbackRate||!i.readyState)){var c=performance.now()-t.loading.start,r=Math.abs(i.playbackRate);if(!(c<=500*u/r)){var h=o.levels,d=o.minAutoLevel,l=h[s.level],v=t.total||Math.max(t.loaded,Math.round(u*l.maxBitrate/8)),p=Math.max(1,t.bwEstimate?t.bwEstimate/8:t.loaded*1e3/c),L=(v-t.loaded)/p,O=i.currentTime,M=(I.BufferHelper.bufferInfo(i,O,a.maxBufferHole).end-O)/r;if(!(M>=2*u/r||L<=M)){var F=Number.POSITIVE_INFINITY,w;for(w=s.level-1;w>d;w--){var C=h[w].maxBitrate;if(F=u*C/(8*.8*p),F<M)break}if(!(F>=L)){var k=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 "+w+`
|
|
8
|
+
Current BW estimate: `+(Object(R.isFiniteNumber)(k)?(k/1024).toFixed(3):"Unknown")+` Kb/s
|
|
9
9
|
Estimated load time for current fragment: `+L.toFixed(3)+` s
|
|
10
10
|
Estimated load time for the next fragment: `+F.toFixed(3)+` s
|
|
11
|
-
Time to underbuffer: `+M.toFixed(3)+" s"),o.nextLoadLevel=w,this.bwEstimator.sample(c,t.loaded),this.clearTimer(),s.loader&&(this.fragCurrent=this.partCurrent=null,s.loader.abort()),o.trigger(T.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:s,part:e,stats:t})}}}}}},g.onFragLoaded=function(s,e){var o=e.frag,f=e.part;if(o.type===O.PlaylistLevelType.MAIN&&Object(R.isFiniteNumber)(o.sn)){var a=f?f.stats:o.stats,i=f?f.duration:o.duration;if(this.clearTimer(),this.lastLoadedFragLevel=o.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var t=this.hls.levels[o.level],u=(t.loaded?t.loaded.bytes:0)+a.loaded,c=(t.loaded?t.loaded.duration:0)+i;t.loaded={bytes:u,duration:c},t.realBitrate=Math.round(8*u/c)}if(o.bitrateTest){var r={stats:a,frag:o,part:f,id:o.type};this.onFragBuffered(T.Events.FRAG_BUFFERED,r)}}},g.onFragBuffered=function(s,e){var o=e.frag,f=e.part,a=f?f.stats:o.stats;if(!a.aborted&&!(o.type!==O.PlaylistLevelType.MAIN||o.sn==="initSegment")){var i=a.parsing.end-a.loading.start;this.bwEstimator.sample(i,a.loaded),a.bwEstimate=this.bwEstimator.getEstimate(),o.bitrateTest?this.bitrateTestDelay=i/1e3:this.bitrateTestDelay=0}},g.onError=function(s,e){switch(e.details){case S.ErrorDetails.FRAG_LOAD_ERROR:case S.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},g.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},g.getNextABRAutoLevel=function(){var s=this.fragCurrent,e=this.partCurrent,o=this.hls,f=o.maxAutoLevel,a=o.config,i=o.minAutoLevel,t=o.media,u=e?e.duration:s?s.duration:0,c=t?t.currentTime:0,r=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,h=this.bwEstimator?this.bwEstimator.getEstimate():a.abrEwmaDefaultEstimate,d=(I.BufferHelper.bufferInfo(t,c,a.maxBufferHole).end-c)/r,l=this.findBestLevel(h,i,f,d,a.abrBandWidthFactor,a.abrBandWidthUpFactor);if(l>=0)return l;_.logger.trace((d?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var v=u?Math.min(u,a.maxStarvationDelay):a.maxStarvationDelay,m=a.abrBandWidthFactor,L=a.abrBandWidthUpFactor;if(!d){var b=this.bitrateTestDelay;if(b){var M=u?Math.min(u,a.maxLoadingDelay):a.maxLoadingDelay;v=M-b,_.logger.trace("bitrate test took "+Math.round(1e3*b)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*v)+" ms"),m=L=1}}return l=this.findBestLevel(h,i,f,d+v,m,L),Math.max(l,0)},g.findBestLevel=function(s,e,o,f,a,i){for(var t,u=this.fragCurrent,c=this.partCurrent,r=this.lastLoadedFragLevel,h=this.hls.levels,d=h[r],l=!!(d!=null&&(t=d.details)!==null&&t!==void 0&&t.live),v=d==null?void 0:d.codecSet,m=c?c.duration:u?u.duration:0,L=o;L>=e;L--){var b=h[L];if(!(!b||v&&b.codecSet!==v)){var M=b.details,F=(c?M==null?void 0:M.partTarget:M==null?void 0:M.averagetargetduration)||m,w=void 0;L<=r?w=a*s:w=i*s;var C=h[L].maxBitrate,U=C*F/w;if(_.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+L+"/"+Math.round(w)+"/"+C+"/"+F+"/"+f+"/"+U),w>C&&(!U||l&&!this.bitrateTestDelay||U<f))return L}}return-1},A(x,[{key:"nextAutoLevel",get:function(){var s=this._nextAutoLevel,e=this.bwEstimator;if(s!==-1&&!e.canEstimate())return s;var o=this.getNextABRAutoLevel();return s!==-1&&this.hls.levels[o].loadError?s:(s!==-1&&(o=Math.min(s,o)),o)},set:function(s){this._nextAutoLevel=s}}]),x}();P.default=D},"./src/controller/audio-stream-controller.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/polyfills/number.ts"),p=n("./src/controller/base-stream-controller.ts"),T=n("./src/events.ts"),I=n("./src/utils/buffer-helper.ts"),S=n("./src/controller/fragment-tracker.ts"),O=n("./src/types/level.ts"),_=n("./src/types/loader.ts"),E=n("./src/loader/fragment.ts"),A=n("./src/demux/chunk-cache.ts"),D=n("./src/demux/transmuxer-interface.ts"),x=n("./src/types/transmuxer.ts"),g=n("./src/controller/fragment-finders.ts"),y=n("./src/utils/discontinuities.ts"),s=n("./src/errors.ts");function e(){return e=Object.assign?Object.assign.bind():function(t){for(var u=1;u<arguments.length;u++){var c=arguments[u];for(var r in c)Object.prototype.hasOwnProperty.call(c,r)&&(t[r]=c[r])}return t},e.apply(this,arguments)}function o(t,u){t.prototype=Object.create(u.prototype),t.prototype.constructor=t,f(t,u)}function f(t,u){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,h){return r.__proto__=h,r},f(t,u)}var a=100,i=function(t){o(u,t);function u(r,h){var d;return d=t.call(this,r,h,"[audio-stream-controller]")||this,d.videoBuffer=null,d.videoTrackCC=-1,d.waitingVideoCC=-1,d.audioSwitch=!1,d.trackId=-1,d.waitingData=null,d.mainDetails=null,d.bufferFlushed=!1,d.cachedTrackLoadedData=null,d._registerListeners(),d}var c=u.prototype;return c.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},c._registerListeners=function(){var h=this.hls;h.on(T.Events.MEDIA_ATTACHED,this.onMediaAttached,this),h.on(T.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.on(T.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.on(T.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.on(T.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),h.on(T.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),h.on(T.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),h.on(T.Events.ERROR,this.onError,this),h.on(T.Events.BUFFER_RESET,this.onBufferReset,this),h.on(T.Events.BUFFER_CREATED,this.onBufferCreated,this),h.on(T.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),h.on(T.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.on(T.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c._unregisterListeners=function(){var h=this.hls;h.off(T.Events.MEDIA_ATTACHED,this.onMediaAttached,this),h.off(T.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.off(T.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.off(T.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.off(T.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),h.off(T.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),h.off(T.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),h.off(T.Events.ERROR,this.onError,this),h.off(T.Events.BUFFER_RESET,this.onBufferReset,this),h.off(T.Events.BUFFER_CREATED,this.onBufferCreated,this),h.off(T.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),h.off(T.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.off(T.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c.onInitPtsFound=function(h,d){var l=d.frag,v=d.id,m=d.initPTS;if(v==="main"){var L=l.cc;this.initPTS[l.cc]=m,this.log("InitPTS for cc: "+L+" found from main: "+m),this.videoTrackCC=L,this.state===p.State.WAITING_INIT_PTS&&this.tick()}},c.startLoad=function(h){if(!this.levels){this.startPosition=h,this.state=p.State.STOPPED;return}var d=this.lastCurrentTime;this.stopLoad(),this.setInterval(a),this.fragLoadError=0,d>0&&h===-1?(this.log("Override startPosition with lastCurrentTime @"+d.toFixed(3)),h=d,this.state=p.State.IDLE):(this.loadedmetadata=!1,this.state=p.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=h,this.tick()},c.doTick=function(){switch(this.state){case p.State.IDLE:this.doTickIdle();break;case p.State.WAITING_TRACK:{var h,d=this.levels,l=this.trackId,v=d==null||(h=d[l])===null||h===void 0?void 0:h.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,L=performance.now(),b=this.retryDate;(!b||L>=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 k=C.flush(),j={frag:F,part:w,payload:k,networkDetails:null};this._handleFragmentLoadProgress(j),U&&t.prototype._handleFragmentLoadComplete.call(this,j)}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 N=this.getLoadPosition(),W=I.BufferHelper.bufferInfo(this.mediaBuffer,N,this.config.maxBufferHole),Y=Object(g.fragmentWithinToleranceTest)(W.end,this.config.maxFragLookUpTolerance,F);Y<0&&(this.log("Waiting fragment cc ("+F.cc+") @ "+F.start+" cancelled because another fragment at "+W.end+" is needed"),this.clearWaitingFragment())}}else this.state=p.State.IDLE}}this.onTickEnd()},c.clearWaitingFragment=function(){var h=this.waitingData;h&&(this.fragmentTracker.removeFragment(h.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=p.State.IDLE)},c.resetLoadingState=function(){this.clearWaitingFragment(),t.prototype.resetLoadingState.call(this)},c.onTickEnd=function(){var h=this.media;if(!(!h||!h.readyState)){var d=this.mediaBuffer?this.mediaBuffer:h,l=d.buffered;!this.loadedmetadata&&l.length&&(this.loadedmetadata=!0),this.lastCurrentTime=h.currentTime}},c.doTickIdle=function(){var h,d,l=this.hls,v=this.levels,m=this.media,L=this.trackId,b=l.config;if(!(!v||!v[L])&&!(!m&&(this.startFragRequested||!b.startFragPrefetch))){var M=v[L],F=M.details;if(!F||F.live&&this.levelLastLoaded!==L||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,E.ElementaryStreamTypes.AUDIO,_.PlaylistLevelType.AUDIO));var C=this.getFwdBufferInfo(w,_.PlaylistLevelType.AUDIO);if(C!==null){var U=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,_.PlaylistLevelType.MAIN),k=C.len,j=this.getMaxBufferLength(U==null?void 0:U.len),N=this.audioSwitch;if(!(k>=j&&!N)){if(!N&&this._streamEnded(C,F)){l.trigger(T.Events.BUFFER_EOS,{type:"audio"}),this.state=p.State.ENDED;return}var W=F.fragments,Y=W[0].start,K=C.end;if(N&&m){var H=this.getLoadPosition();K=H,F.PTSKnown&&H<Y&&(C.end>Y||C.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),m.currentTime=Y+.05)}if(!(U&&K>U.end+F.targetduration)&&!((!U||!U.len)&&C.len)){var z=this.getNextFragment(K,F);if(!z){this.bufferFlushed=!0;return}((h=z.decryptdata)===null||h===void 0?void 0:h.keyFormat)==="identity"&&!((d=z.decryptdata)!==null&&d!==void 0&&d.key)?this.loadKey(z,F):this.loadFragment(z,F,K)}}}}},c.getMaxBufferLength=function(h){var d=t.prototype.getMaxBufferLength.call(this);return h?Math.max(d,h):d},c.onMediaDetaching=function(){this.videoBuffer=null,t.prototype.onMediaDetaching.call(this)},c.onAudioTracksUpdated=function(h,d){var l=d.audioTracks;this.resetTransmuxer(),this.levels=l.map(function(v){return new O.Level(v)})},c.onAudioTrackSwitching=function(h,d){var l=!!d.url;this.trackId=d.id;var v=this.fragCurrent;v!=null&&v.loader&&v.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),l?this.setInterval(a):this.resetTransmuxer(),l?(this.audioSwitch=!0,this.state=p.State.IDLE):this.state=p.State.STOPPED,this.tick()},c.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},c.onLevelLoaded=function(h,d){this.mainDetails=d.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(T.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},c.onAudioTrackLoaded=function(h,d){var l;if(this.mainDetails==null){this.cachedTrackLoadedData=d;return}var v=this.levels,m=d.details,L=d.id;if(!v){this.warn("Audio tracks were reset while loading level "+L);return}this.log("Track "+L+" loaded ["+m.startSN+","+m.endSN+"],duration:"+m.totalduration);var b=v[L],M=0;if(m.live||(l=b.details)!==null&&l!==void 0&&l.live){var F=this.mainDetails;if(m.fragments[0]||(m.deltaUpdateFailed=!0),m.deltaUpdateFailed||!F)return;!b.details&&m.hasProgramDateTime&&F.hasProgramDateTime?(Object(y.alignMediaPlaylistByPDT)(m,F),M=m.fragments[0].start):M=this.alignPlaylists(m,b.details)}b.details=m,this.levelLastLoaded=L,!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()},c._handleFragmentLoadProgress=function(h){var d,l=h.frag,v=h.part,m=h.payload,L=this.config,b=this.trackId,M=this.levels;if(!M){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+l.sn+" of level "+l.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=L.defaultAudioCodec||F.audioCodec||"mp4a.40.2",U=this.transmuxer;U||(U=this.transmuxer=new D.default(this.hls,_.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var k=this.initPTS[l.cc],j=(d=l.initSegment)===null||d===void 0?void 0:d.data;if(k!==void 0){var N=!1,W=v?v.index:-1,Y=W!==-1,K=new x.ChunkMetadata(l.level,l.sn,l.stats.chunkCount,m.byteLength,W,Y);U.push(m,j,C,"",l,v,w.totalduration,N,K,k)}else{this.log("Unknown video PTS for cc "+l.cc+", waiting for video PTS before demuxing audio frag "+l.sn+" of ["+w.startSN+" ,"+w.endSN+"],track "+b);var H=this.waitingData=this.waitingData||{frag:l,part:v,cache:new A.default,complete:!1},z=H.cache;z.push(new Uint8Array(m)),this.waitingVideoCC=this.videoTrackCC,this.state=p.State.WAITING_INIT_PTS}},c._handleFragmentLoadComplete=function(h){if(this.waitingData){this.waitingData.complete=!0;return}t.prototype._handleFragmentLoadComplete.call(this,h)},c.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},c.onBufferCreated=function(h,d){var l=d.tracks.audio;l&&(this.mediaBuffer=l.buffer||null),d.tracks.video&&(this.videoBuffer=d.tracks.video.buffer||null)},c.onFragBuffered=function(h,d){var l=d.frag,v=d.part;if(l.type===_.PlaylistLevelType.AUDIO){if(this.fragContextChanged(l)){this.warn("Fragment "+l.sn+(v?" p: "+v.index:"")+" of level "+l.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}l.sn!=="initSegment"&&(this.fragPrevious=l,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(T.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(l,v)}},c.onError=function(h,d){switch(d.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,d);break;case s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==p.State.ERROR&&this.state!==p.State.STOPPED&&(this.state=d.fatal?p.State.ERROR:p.State.IDLE,this.warn(d.details+" while loading frag, switching to "+this.state+" state"));break;case s.ErrorDetails.BUFFER_FULL_ERROR:if(d.parent==="audio"&&(this.state===p.State.PARSING||this.state===p.State.PARSED)){var l=!0,v=this.getFwdBufferInfo(this.mediaBuffer,_.PlaylistLevelType.AUDIO);v&&v.len>.5&&(l=!this.reduceMaxBufferLength(v.len)),l&&(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}},c.onBufferFlushed=function(h,d){var l=d.type;l===E.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},c._handleTransmuxComplete=function(h){var d,l="audio",v=this.hls,m=h.remuxResult,L=h.chunkMeta,b=this.getCurrentContext(L);if(!b){this.warn("The loading context changed while buffering fragment "+L.sn+" of level "+L.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(L.level);return}var M=b.frag,F=b.part,w=b.level.details,C=m.audio,U=m.text,k=m.id3,j=m.initSegment;if(!(this.fragContextChanged(M)||!w)){if(this.state=p.State.PARSING,this.audioSwitch&&C&&this.completeAudioSwitch(),j!=null&&j.tracks&&(this._bufferInitSegment(j.tracks,M,L),v.trigger(T.Events.FRAG_PARSING_INIT_SEGMENT,{frag:M,id:l,tracks:j.tracks})),C){var N=C.startPTS,W=C.endPTS,Y=C.startDTS,K=C.endDTS;F&&(F.elementaryStreams[E.ElementaryStreamTypes.AUDIO]={startPTS:N,endPTS:W,startDTS:Y,endDTS:K}),M.setElementaryStreamInfo(E.ElementaryStreamTypes.AUDIO,N,W,Y,K),this.bufferFragmentData(C,M,F,L)}if(k!=null&&(d=k.samples)!==null&&d!==void 0&&d.length){var H=e({id:l,frag:M,details:w},k);v.trigger(T.Events.FRAG_PARSING_METADATA,H)}if(U){var z=e({id:l,frag:M,details:w},U);v.trigger(T.Events.FRAG_PARSING_USERDATA,z)}}},c._bufferInitSegment=function(h,d,l){if(this.state===p.State.PARSING){h.video&&delete h.video;var v=h.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(T.Events.BUFFER_CODECS,h);var m=v.initSegment;if(m!=null&&m.byteLength){var L={type:"audio",frag:d,part:null,chunkMeta:l,parent:d.type,data:m};this.hls.trigger(T.Events.BUFFER_APPENDING,L)}this.tick()}}},c.loadFragment=function(h,d,l){var v=this.fragmentTracker.getState(h);this.fragCurrent=h,(this.audioSwitch||v===S.FragmentState.NOT_LOADED||v===S.FragmentState.PARTIAL)&&(h.sn==="initSegment"?this._loadInitSegment(h):d.live&&!Object(R.isFiniteNumber)(this.initPTS[h.cc])?(this.log("Waiting for video PTS in continuity counter "+h.cc+" of live stream before loading audio fragment "+h.sn+" of level "+this.trackId),this.state=p.State.WAITING_INIT_PTS):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,h,d,l)))},c.completeAudioSwitch=function(){var h=this.hls,d=this.media,l=this.trackId;d&&(this.log("Switching audio track : flushing all audio"),t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,h.trigger(T.Events.AUDIO_TRACK_SWITCHED,{id:l})},u}(p.default);P.default=i},"./src/controller/audio-track-controller.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/events.ts"),p=n("./src/errors.ts"),T=n("./src/controller/base-playlist-controller.ts"),I=n("./src/types/loader.ts");function S(D,x){for(var g=0;g<x.length;g++){var y=x[g];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(D,y.key,y)}}function O(D,x,g){return x&&S(D.prototype,x),g&&S(D,g),Object.defineProperty(D,"prototype",{writable:!1}),D}function _(D,x){D.prototype=Object.create(x.prototype),D.prototype.constructor=D,E(D,x)}function E(D,x){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(y,s){return y.__proto__=s,y},E(D,x)}var A=function(D){_(x,D);function x(y){var s;return s=D.call(this,y,"[audio-track-controller]")||this,s.tracks=[],s.groupId=null,s.tracksInGroup=[],s.trackId=-1,s.trackName="",s.selectDefaultTrack=!0,s.registerListeners(),s}var g=x.prototype;return g.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)},g.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)},g.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,D.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(s,e){this.tracks=e.audioTracks||[]},g.onAudioTrackLoaded=function(s,e){var o=e.id,f=e.details,a=this.tracksInGroup[o];if(!a){this.warn("Invalid audio track id "+o);return}var i=a.details;a.details=e.details,this.log("audioTrack "+o+" loaded ["+f.startSN+"-"+f.endSN+"]"),o===this.trackId&&(this.retryCount=0,this.playlistLoaded(o,e,i))},g.onLevelLoading=function(s,e){this.switchLevel(e.level)},g.onLevelSwitching=function(s,e){this.switchLevel(e.level)},g.switchLevel=function(s){var e=this.hls.levels[s];if(!!(e!=null&&e.audioGroupIds)){var o=e.audioGroupIds[e.urlId];if(this.groupId!==o){this.groupId=o;var f=this.tracks.filter(function(i){return!o||i.groupId===o});this.selectDefaultTrack&&!f.some(function(i){return i.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=f;var a={audioTracks:f};this.log("Updating audio tracks, "+f.length+' track(s) found in "'+o+'" group-id'),this.hls.trigger(R.Events.AUDIO_TRACKS_UPDATED,a),this.selectInitialTrack()}}},g.onError=function(s,e){D.prototype.onError.call(this,s,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(s){var e=this.tracksInGroup;if(s<0||s>=e.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var o=e[this.trackId];this.log("Now switching to audio-track index "+s);var f=e[s],a=f.id,i=f.groupId,t=i===void 0?"":i,u=f.name,c=f.type,r=f.url;if(this.trackId=s,this.trackName=u,this.selectDefaultTrack=!1,this.hls.trigger(R.Events.AUDIO_TRACK_SWITCHING,{id:a,groupId:t,name:u,type:c,url:r}),!(f.details&&!f.details.live)){var h=this.switchParams(f.url,o==null?void 0:o.details);this.loadPlaylist(h)}},g.selectInitialTrack=function(){var s=this.tracksInGroup;console.assert(s.length,"Initial audio track should be selected when tracks are known");var e=this.trackName,o=this.findTrackId(e)||this.findTrackId();o!==-1?this.setAudioTrack(o):(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(s){for(var e=this.tracksInGroup,o=0;o<e.length;o++){var f=e[o];if((!this.selectDefaultTrack||f.default)&&(!s||s===f.name))return f.id}return-1},g.loadPlaylist=function(s){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var o=e.id,f=e.groupId,a=e.url;if(s)try{a=s.addDirectives(a)}catch(i){this.warn("Could not construct new URL with HLS Delivery Directives: "+i)}this.log("loading audio-track playlist for id: "+o),this.clearTimer(),this.hls.trigger(R.Events.AUDIO_TRACK_LOADING,{url:a,id:o,groupId:f,deliveryDirectives:s||null})}},O(x,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(s){this.selectDefaultTrack=!1,this.setAudioTrack(s)}}]),x}(T.default);P.default=A},"./src/controller/base-playlist-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return O});var R=n("./src/polyfills/number.ts"),p=n("./src/types/level.ts"),T=n("./src/controller/level-helper.ts"),I=n("./src/utils/logger.ts"),S=n("./src/errors.ts"),O=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,D+":"),this.warn=I.logger.warn.bind(I.logger,D+":"),this.hls=A}var E=_.prototype;return E.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},E.onError=function(D,x){x.fatal&&x.type===S.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},E.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},E.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},E.stopLoad=function(){this.canLoad=!1,this.clearTimer()},E.switchParams=function(D,x){var g=x==null?void 0:x.renditionReports;if(g)for(var y=0;y<g.length;y++){var s=g[y],e=""+s.URI;if(e===D.slice(-e.length)){var o=parseInt(s["LAST-MSN"]),f=parseInt(s["LAST-PART"]);if(x&&this.hls.config.lowLatencyMode){var a=Math.min(x.age-x.partTarget,x.targetduration);f!==void 0&&a>x.partTarget&&(f+=1)}if(Object(R.isFiniteNumber)(o))return new p.HlsUrlParameters(o,Object(R.isFiniteNumber)(f)?f:void 0,p.HlsSkip.No)}}},E.loadPlaylist=function(D){},E.shouldLoadTrack=function(D){return this.canLoad&&D&&!!D.url&&(!D.details||D.details.live)},E.playlistLoaded=function(D,x,g){var y=this,s=x.details,e=x.stats,o=e.loading.end?Math.max(0,self.performance.now()-e.loading.end):0;if(s.advancedDateTime=Date.now()-o,s.live||g!=null&&g.live){if(s.reloaded(g),g&&this.log("live playlist "+D+" "+(s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:"MISSED")),g&&s.fragments.length>0&&Object(T.mergeDetails)(g,s),!this.canLoad||!s.live)return;var f,a=void 0,i=void 0;if(s.canBlockReload&&s.endSN&&s.advanced){var t=this.hls.config.lowLatencyMode,u=s.lastPartSn,c=s.endSN,r=s.lastPartIndex,h=r!==-1,d=u===c,l=t?0:r;h?(a=d?c+1:u,i=d?l:r+1):a=c+1;var v=s.age,m=v+s.ageHeader,L=Math.min(m-s.partTarget,s.targetduration*1.5);if(L>0){if(g&&L>g.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+g.tuneInGoal+" to: "+L+" with playlist age: "+s.age),L=0;else{var b=Math.floor(L/s.targetduration);if(a+=b,i!==void 0){var M=Math.round(L%s.targetduration/s.partTarget);i+=M}this.log("CDN Tune-in age: "+s.ageHeader+"s last advanced "+v.toFixed(2)+"s goal: "+L+" skip sn "+b+" to part "+i)}s.tuneInGoal=L}if(f=this.getDeliveryDirectives(s,x.deliveryDirectives,a,i),t||!d){this.loadPlaylist(f);return}}else f=this.getDeliveryDirectives(s,x.deliveryDirectives,a,i);var F=Object(T.computeReloadInterval)(s,e);a!==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 y.loadPlaylist(f)},F)}else this.clearTimer()},E.getDeliveryDirectives=function(D,x,g,y){var s=Object(p.getSkipValue)(D,g);return x!=null&&x.skip&&D.deltaUpdateFailed&&(g=x.msn,y=x.part,s=p.HlsSkip.No),new p.HlsUrlParameters(g,y,s)},E.retryLoadingOrFail=function(D){var x=this,g=this.hls.config,y=this.retryCount<g.levelLoadingMaxRetry;if(y){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)*g.levelLoadingRetryDelay,g.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return x.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 y},_}()},"./src/controller/base-stream-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"State",function(){return c}),n.d(P,"default",function(){return r});var R=n("./src/polyfills/number.ts"),p=n("./src/task-loop.ts"),T=n("./src/controller/fragment-tracker.ts"),I=n("./src/utils/buffer-helper.ts"),S=n("./src/utils/logger.ts"),O=n("./src/events.ts"),_=n("./src/errors.ts"),E=n("./src/types/transmuxer.ts"),A=n("./src/utils/mp4-tools.ts"),D=n("./src/utils/discontinuities.ts"),x=n("./src/controller/fragment-finders.ts"),g=n("./src/controller/level-helper.ts"),y=n("./src/loader/fragment-loader.ts"),s=n("./src/crypt/decrypter.ts"),e=n("./src/utils/time-ranges.ts"),o=n("./src/types/loader.ts");function f(h,d){for(var l=0;l<d.length;l++){var v=d[l];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(h,v.key,v)}}function a(h,d,l){return d&&f(h.prototype,d),l&&f(h,l),Object.defineProperty(h,"prototype",{writable:!1}),h}function i(h){if(h===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return h}function t(h,d){h.prototype=Object.create(d.prototype),h.prototype.constructor=h,u(h,d)}function u(h,d){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,m){return v.__proto__=m,v},u(h,d)}var c={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(h){t(d,h);function d(v,m,L){var b;return b=h.call(this)||this,b.hls=void 0,b.fragPrevious=null,b.fragCurrent=null,b.fragmentTracker=void 0,b.transmuxer=null,b._state=c.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=L,b.log=S.logger.log.bind(S.logger,L+":"),b.warn=S.logger.warn.bind(S.logger,L+":"),b.hls=v,b.fragmentLoader=new y.default(v.config),b.fragmentTracker=m,b.config=v.config,b.decrypter=new s.default(v,v.config),v.on(O.Events.KEY_LOADED,b.onKeyLoaded,i(b)),v.on(O.Events.LEVEL_SWITCHING,b.onLevelSwitching,i(b)),b}var l=d.prototype;return l.doTick=function(){this.onTickEnd()},l.onTickEnd=function(){},l.startLoad=function(m){},l.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=c.STOPPED},l._streamEnded=function(m,L){var b=this.fragCurrent,M=this.fragmentTracker;if(!L.live&&b&&this.media&&b.sn>=L.endSN&&!m.nextStart){var F=L.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===T.FragmentState.PARTIAL||U===T.FragmentState.OK}return!1},l.onMediaAttached=function(m,L){var b=this.media=this.mediaBuffer=L.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===c.STOPPED&&this.startLoad(M.startPosition)},l.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()},l.onMediaSeeking=function(){var m=this.config,L=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===c.ENDED)this.resetLoadingState();else if(L&&!C.len){var U=m.maxFragLookUpTolerance,k=L.start-U,j=L.start+L.duration+U,N=w>j;(w<k||N)&&(N&&L.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),L.loader.abort()),this.resetLoadingState())}b&&(this.lastCurrentTime=w),!this.loadedmetadata&&!C.len&&(this.nextLoadPosition=this.startPosition=w),this.tickImmediate()},l.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},l.onKeyLoaded=function(m,L){if(!(this.state!==c.KEY_LOADING||L.frag!==this.fragCurrent||!this.levels)){this.state=c.IDLE;var b=this.levels[L.frag.level].details;b&&this.loadFragment(L.frag,b,L.frag.start)}},l.onLevelSwitching=function(m,L){this.fragLoadError=0},l.onHandlerDestroying=function(){this.stopLoad(),h.prototype.onHandlerDestroying.call(this)},l.onHandlerDestroyed=function(){this.state=c.STOPPED,this.hls.off(O.Events.KEY_LOADED,this.onKeyLoaded,this),this.hls.off(O.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,h.prototype.onHandlerDestroyed.call(this)},l.loadKey=function(m,L){this.log("Loading key for "+m.sn+" of ["+L.startSN+"-"+L.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+m.level),this.state=c.KEY_LOADING,this.fragCurrent=m,this.hls.trigger(O.Events.KEY_LOADING,{frag:m})},l.loadFragment=function(m,L,b){this._loadFragForPlayback(m,L,b)},l._loadFragForPlayback=function(m,L,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,L,b,F).then(function(w){if(!!w){M.fragLoadError=0;var C=M.state;if(M.fragContextChanged(m)){(C===c.FRAG_LOADING||!M.fragCurrent&&C===c.PARSING)&&(M.fragmentTracker.removeFragment(m),M.state=c.IDLE);return}"payload"in w&&(M.log("Loaded fragment "+m.sn+" of level "+m.level),M.hls.trigger(O.Events.FRAG_LOADED,w)),M._handleFragmentLoadComplete(w)}}).catch(function(w){M.state===c.STOPPED||M.state===c.ERROR||(M.warn(w),M.resetFragmentLoading(m))})},l.flushMainBuffer=function(m,L,b){if(b===void 0&&(b=null),!!(m-L)){var M={startOffset:m,endOffset:L,type:b};this.fragLoadError=0,this.hls.trigger(O.Events.BUFFER_FLUSHING,M)}},l._loadInitSegment=function(m){var L=this;this._doFragLoad(m).then(function(b){if(!b||L.fragContextChanged(m)||!L.levels)throw new Error("init load aborted");return b}).then(function(b){var M=L.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 L.decrypter.webCryptoDecrypt(new Uint8Array(F),w.key.buffer,w.iv.buffer).then(function(U){var k=self.performance.now();return M.trigger(O.Events.FRAG_DECRYPTED,{frag:m,payload:U,stats:{tstart:C,tdecrypt:k}}),b.payload=U,b})}return b}).then(function(b){var M=L.fragCurrent,F=L.hls,w=L.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;L.state=c.IDLE,L.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(O.Events.FRAG_BUFFERED,{stats:U,frag:M,part:null,id:m.type}),L.tick()}).catch(function(b){L.state===c.STOPPED||L.state===c.ERROR||(L.warn(b),L.resetFragmentLoading(m))})},l.fragContextChanged=function(m){var L=this.fragCurrent;return!m||!L||m.level!==L.level||m.sn!==L.sn||m.urlId!==L.urlId},l.fragBufferedComplete=function(m,L){var b=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+m.type+" sn: "+m.sn+(L?" part: "+L.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+m.level+" "+(b?e.default.toString(I.BufferHelper.getBuffered(b)):"(detached)")),this.state=c.IDLE,b&&(!this.loadedmetadata&&b.buffered.length&&this.fragCurrent===this.fragPrevious&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},l.seekToStartPos=function(){},l._handleFragmentLoadComplete=function(m){var L=this.transmuxer;if(!!L){var b=m.frag,M=m.part,F=m.partsLoaded,w=!F||F.length===0||F.some(function(U){return!U}),C=new E.ChunkMetadata(b.level,b.sn,b.stats.chunkCount+1,0,M?M.index:-1,!w);L.flush(C)}},l._handleFragmentLoadProgress=function(m){},l._doFragLoad=function(m,L,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&&L){var w=L.partList;if(w&&M){b>m.end&&L.fragmentHint&&(m=L.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 ["+L.startSN+"-"+L.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=c.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:m,part:w[C],targetBufferTime:b}),this.doFragPartsLoad(m,w,C,M).catch(function(k){return F.handleFragLoadError(k)})}else if(!m.url||this.loadedEndOfParts(w,b))return Promise.resolve(null)}}return this.log("Loading fragment "+m.sn+" cc: "+m.cc+" "+(L?"of ["+L.startSN+"-"+L.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=c.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:m,targetBufferTime:b}),this.fragmentLoader.load(m,M).catch(function(k){return F.handleFragLoadError(k)})},l.doFragPartsLoad=function(m,L,b,M){var F=this;return new Promise(function(w,C){var U=[],k=function j(N){var W=L[N];F.fragmentLoader.loadPart(m,W,M).then(function(Y){U[W.index]=Y;var K=Y.part;F.hls.trigger(O.Events.FRAG_LOADED,Y);var H=L[N+1];if(H&&H.fragment===m)j(N+1);else return w({frag:m,part:K,partsLoaded:U})}).catch(C)};k(b)})},l.handleFragLoadError=function(m){var L=m.data;return L&&L.details===_.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(L.frag,L.part):this.hls.trigger(O.Events.ERROR,L),null},l._handleTransmuxerFlush=function(m){var L=this.getCurrentContext(m);if(!L||this.state!==c.PARSING){this.fragCurrent||(this.state=c.IDLE);return}var b=L.frag,M=L.part,F=L.level,w=self.performance.now();b.stats.parsing.end=w,M&&(M.stats.parsing.end=w),this.updateLevelTiming(b,M,F,m.partial)},l.getCurrentContext=function(m){var L=this.levels,b=m.level,M=m.sn,F=m.part;if(!L||!L[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=L[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},l.bufferFragmentData=function(m,L,b,M){if(!(!m||this.state!==c.PARSING)){var F=m.data1,w=m.data2,C=F;if(F&&w&&(C=Object(A.appendUint8Array)(F,w)),!(!C||!C.length)){var U={type:m.type,frag:L,part:b,chunkMeta:M,parent:L.type,data:C};this.hls.trigger(O.Events.BUFFER_APPENDING,U),m.dropped&&m.independent&&!b&&this.flushBufferGap(L)}}},l.flushBufferGap=function(m){var L=this.media;if(!!L){if(!I.BufferHelper.isBuffered(L,L.currentTime)){this.flushMainBuffer(0,m.start);return}var b=L.currentTime,M=I.BufferHelper.bufferInfo(L,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)}},l.getFwdBufferInfo=function(m,L){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,L);if(w&&F.nextStart<w.end)return I.BufferHelper.bufferInfo(m,M,Math.max(F.nextStart,b.maxBufferHole))}return F},l.getMaxBufferLength=function(m){var L=this.config,b;return m?b=Math.max(8*L.maxBufferSize/m,L.maxBufferLength):b=L.maxBufferLength,Math.min(b,L.maxMaxBufferLength)},l.reduceMaxBufferLength=function(m){var L=this.config,b=m||L.maxBufferLength;return L.maxMaxBufferLength>=b?(L.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+L.maxMaxBufferLength+"s"),!0):!1},l.getNextFragment=function(m,L){var b=L.fragments,M=b.length;if(!M)return null;var F=this.config,w=b[0].start,C;if(L.live){var U=F.initialLiveManifestSize;if(M<U)return this.warn("Not enough fragments to start playback (have: "+M+", need: "+U+")"),null;!L.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(C=this.getInitialLiveFragment(L,b),this.startPosition=C?this.hls.liveSyncPosition||C.start:m)}else m<=w&&(C=b[0]);if(!C){var k=F.lowLatencyMode?L.partEnd:L.fragmentEnd;C=this.getFragmentAtPosition(m,k,L)}return this.mapToInitFragWhenRequired(C)},l.mapToInitFragWhenRequired=function(m){return m!=null&&m.initSegment&&!(m!=null&&m.initSegment.data)&&!this.bitrateTest?m.initSegment:m},l.getNextPart=function(m,L,b){for(var M=-1,F=!1,w=!0,C=0,U=m.length;C<U;C++){var k=m[C];if(w=w&&!k.independent,M>-1&&b<k.start)break;var j=k.loaded;!j&&(F||k.independent||w)&&k.fragment===L&&(M=C),F=j}return M},l.loadedEndOfParts=function(m,L){var b=m[m.length-1];return b&&L>b.start&&b.loaded},l.getInitialLiveFragment=function(m,L){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(x.findFragmentByPDT)(L,b.endProgramDateTime,this.config.maxFragLookUpTolerance)),!M){var F=b.sn+1;if(F>=m.startSN&&F<=m.endSN){var w=L[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(x.findFragWithCC)(L,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},l.getFragmentAtPosition=function(m,L,b){var M=this.config,F=this.fragPrevious,w=b.fragments,C=b.endSN,U=b.fragmentHint,k=M.maxFragLookUpTolerance,j=!!(M.lowLatencyMode&&b.partList&&U);j&&U&&!this.bitrateTest&&(w=w.concat(U),C=U.sn);var N;if(m<L){var W=m>L-k?0:k;N=Object(x.findFragmentByPTS)(F,w,m,W)}else N=w[w.length-1];if(N){var Y=N.sn-b.startSN;if(F&&N.sn===F.sn&&!j){var K=F&&N.level===F.level;if(K){var H=w[Y+1];N.sn<C&&this.fragmentTracker.getState(H)!==T.FragmentState.OK?(this.log("SN "+N.sn+" just loaded, load next one: "+H.sn),N=H):N=null}}}return N},l.synchronizeToLiveEdge=function(m){var L=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-L.maxFragLookUpTolerance&&F<=C;if(M!==null&&b.duration>M&&(F<M||!U)){var k=L.liveMaxLatencyDuration!==void 0?L.liveMaxLatencyDuration:L.liveMaxLatencyDurationCount*m.targetduration;(!U&&b.readyState<4||F<C-k)&&(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))}}},l.alignPlaylists=function(m,L){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,k=!L,j=m.alignedSliding&&Object(R.isFiniteNumber)(U);if(k||!j&&!U){Object(D.alignStream)(F,w,m);var N=m.fragments[0].start;return this.log("Live playlist sliding: "+N.toFixed(2)+" start-sn: "+(L?L.startSN:"na")+"->"+m.startSN+" prev-sn: "+(F?F.sn:"na")+" fragments: "+C),N}return U},l.waitForCdnTuneIn=function(m){var L=3;return m.live&&m.canBlockReload&&m.partTarget&&m.tuneInGoal>Math.max(m.partHoldBack,m.partTarget*L)},l.setStartPosition=function(m,L){var b=this.startPosition;if(b<L&&(b=-1),b===-1||this.lastCurrentTime===-1){var M=m.startTimeOffset;Object(R.isFiniteNumber)(M)?(b=L+M,M<0&&(b+=m.totalduration),b=Math.min(Math.max(L,b),L+m.totalduration),this.log("Start time offset "+M+" found in playlist, adjust startPosition to "+b),this.startPosition=b):m.live?b=this.hls.liveSyncPosition||L:this.startPosition=b=0,this.lastCurrentTime=b}this.nextLoadPosition=b},l.getLoadPosition=function(){var m=this.media,L=0;return this.loadedmetadata&&m?L=m.currentTime:this.nextLoadPosition&&(L=this.nextLoadPosition),L},l.handleFragLoadAborted=function(m,L){this.transmuxer&&m.sn!=="initSegment"&&m.stats.aborted&&(this.warn("Fragment "+m.sn+(L?" part"+L.index:"")+" of level "+m.level+" was aborted"),this.resetFragmentLoading(m))},l.resetFragmentLoading=function(m){(!this.fragCurrent||!this.fragContextChanged(m)&&this.state!==c.FRAG_LOADING_WAITING_RETRY)&&(this.state=c.IDLE)},l.onFragmentOrKeyLoadError=function(m,L){if(!L.fatal){var b=L.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=c.FRAG_LOADING_WAITING_RETRY}else L.levelRetry?(m===o.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=c.IDLE):(S.logger.error(L.details+" reaches max retry, redispatch as fatal ..."),L.fatal=!0,this.hls.stopLoad(),this.state=c.ERROR)}}},l.afterBufferFlushed=function(m,L,b){if(!!m){var M=I.BufferHelper.getBuffered(m);this.fragmentTracker.detectEvictedFragments(L,M,b),this.state===c.ENDED&&this.resetLoadingState()}},l.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=c.IDLE},l.resetStartWhenNotLoaded=function(m){if(!this.loadedmetadata){this.startFragRequested=!1;var L=this.levels?this.levels[m].details:null;L!=null&&L.live?(this.startPosition=-1,this.setStartPosition(L,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},l.updateLevelTiming=function(m,L,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,k){var j=m.elementaryStreams[k];if(j){var N=j.endPTS-j.startPTS;if(N<=0)return F.warn("Could not parse fragment "+m.sn+" "+k+" duration reliably ("+N+")"),U||!1;var W=M?0:Object(g.updateFragPTSDTS)(w,m,j.startPTS,j.endPTS,j.startDTS,j.endDTS);return F.hls.trigger(O.Events.LEVEL_PTS_UPDATED,{details:w,level:b,drift:W,type:k,frag:m,start:j.startPTS,end:j.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=c.PARSED,this.hls.trigger(O.Events.FRAG_PARSED,{frag:m,part:L})},l.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},a(d,[{key:"state",get:function(){return this._state},set:function(m){var L=this._state;L!==m&&(this._state=m,this.log(L+"->"+m))}}]),d}(p.default)},"./src/controller/buffer-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return x});var R=n("./src/polyfills/number.ts"),p=n("./src/events.ts"),T=n("./src/utils/logger.ts"),I=n("./src/errors.ts"),S=n("./src/utils/buffer-helper.ts"),O=n("./src/utils/mediasource-helper.ts"),_=n("./src/loader/fragment.ts"),E=n("./src/controller/buffer-operation-queue.ts"),A=Object(O.getMediaSource)(),D=/([ha]vc.)(?:\.[^.,]+)+/,x=function(){function g(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 o=e.hls,f=e.media,a=e.mediaSource;T.logger.log("[buffer-controller]: Media source opened"),f&&(e.updateMediaElementDuration(),o.trigger(p.Events.MEDIA_ATTACHED,{media:f})),a&&a.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){T.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){T.logger.log("[buffer-controller]: Media source ended")},this.hls=s,this._initSourceBuffer(),this.registerListeners()}var y=g.prototype;return y.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},y.destroy=function(){this.unregisterListeners(),this.details=null},y.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)},y.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)},y._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new E.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},y.onManifestParsed=function(e,o){var f=2;(o.audio&&!o.video||!o.altAudio)&&(f=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=f,this.details=null,T.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},y.onMediaAttaching=function(e,o){var f=this.media=o.media;if(f&&A){var a=this.mediaSource=new A;a.addEventListener("sourceopen",this._onMediaSourceOpen),a.addEventListener("sourceended",this._onMediaSourceEnded),a.addEventListener("sourceclose",this._onMediaSourceClose),f.src=self.URL.createObjectURL(a),this._objectUrl=f.src}},y.onMediaDetaching=function(){var e=this.media,o=this.mediaSource,f=this._objectUrl;if(o){if(T.logger.log("[buffer-controller]: media source detaching"),o.readyState==="open")try{o.endOfStream()}catch(a){T.logger.warn("[buffer-controller]: onMediaDetaching: "+a.message+" while calling endOfStream")}this.onBufferReset(),o.removeEventListener("sourceopen",this._onMediaSourceOpen),o.removeEventListener("sourceended",this._onMediaSourceEnded),o.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(f&&self.URL.revokeObjectURL(f),e.src===f?(e.removeAttribute("src"),e.load()):T.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)},y.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(o){var f=e.sourceBuffer[o];try{f&&(e.removeBufferListeners(o),e.mediaSource&&e.mediaSource.removeSourceBuffer(f),e.sourceBuffer[o]=void 0)}catch(a){T.logger.warn("[buffer-controller]: Failed to reset the "+o+" buffer",a)}}),this._initSourceBuffer()},y.onBufferCodecs=function(e,o){var f=this,a=this.getSourceBufferTypes().length;Object.keys(o).forEach(function(i){if(a){var t=f.tracks[i];if(t&&typeof t.buffer.changeType=="function"){var u=o[i],c=u.id,r=u.codec,h=u.levelCodec,d=u.container,l=u.metadata,v=(t.levelCodec||t.codec).replace(D,"$1"),m=(h||r).replace(D,"$1");if(v!==m){var L=d+";codecs="+(h||r);f.appendChangeType(i,L),T.logger.log("[buffer-controller]: switching codec "+v+" to "+m),f.tracks[i]={buffer:t.buffer,codec:r,container:d,levelCodec:h,metadata:l,id:c}}}}else f.pendingTracks[i]=o[i]}),!a&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},y.appendChangeType=function(e,o){var f=this,a=this.operationQueue,i={execute:function(){var u=f.sourceBuffer[e];u&&(T.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+o),u.changeType(o)),a.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(u){T.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",u)}};a.append(i,e)},y.onBufferAppending=function(e,o){var f=this,a=this.hls,i=this.operationQueue,t=this.tracks,u=o.data,c=o.type,r=o.frag,h=o.part,d=o.chunkMeta,l=d.buffering[c],v=self.performance.now();l.start=v;var m=r.stats.buffering,L=h?h.stats.buffering:null;m.start===0&&(m.start=v),L&&L.start===0&&(L.start=v);var b=t.audio,M=c==="audio"&&d.id===1&&(b==null?void 0:b.container)==="audio/mpeg",F={execute:function(){if(l.executeStart=self.performance.now(),M){var C=f.sourceBuffer[c];if(C){var U=r.start-C.timestampOffset;Math.abs(U)>=.1&&(T.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+r.start+" (delta: "+U+") sn: "+r.sn+")"),C.timestampOffset=r.start)}}f.appendExecutor(u,c)},onStart:function(){},onComplete:function(){var C=self.performance.now();l.executeEnd=l.end=C,m.first===0&&(m.first=C),L&&L.first===0&&(L.first=C);var U=f.sourceBuffer,k={};for(var j in U)k[j]=S.BufferHelper.getBuffered(U[j]);f.appendError=0,f.hls.trigger(p.Events.BUFFER_APPENDED,{type:c,frag:r,part:h,chunkMeta:d,parent:r.type,timeRanges:k})},onError:function(C){T.logger.error("[buffer-controller]: Error encountered while trying to append to the "+c+" 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:(f.appendError++,U.details=I.ErrorDetails.BUFFER_APPEND_ERROR,f.appendError>a.config.appendErrorMaxRetry&&(T.logger.error("[buffer-controller]: Failed "+a.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),U.fatal=!0,a.stopLoad())),a.trigger(p.Events.ERROR,U)}};i.append(F,c)},y.onBufferFlushing=function(e,o){var f=this,a=this.operationQueue,i=function(u){return{execute:f.removeExecutor.bind(f,u,o.startOffset,o.endOffset),onStart:function(){},onComplete:function(){f.hls.trigger(p.Events.BUFFER_FLUSHED,{type:u})},onError:function(r){T.logger.warn("[buffer-controller]: Failed to remove from "+u+" SourceBuffer",r)}}};o.type?a.append(i(o.type),o.type):this.getSourceBufferTypes().forEach(function(t){a.append(i(t),t)})},y.onFragParsed=function(e,o){var f=this,a=o.frag,i=o.part,t=[],u=i?i.elementaryStreams:a.elementaryStreams;u[_.ElementaryStreamTypes.AUDIOVIDEO]?t.push("audiovideo"):(u[_.ElementaryStreamTypes.AUDIO]&&t.push("audio"),u[_.ElementaryStreamTypes.VIDEO]&&t.push("video"));var c=function(){var h=self.performance.now();a.stats.buffering.end=h,i&&(i.stats.buffering.end=h);var d=i?i.stats:a.stats;f.hls.trigger(p.Events.FRAG_BUFFERED,{frag:a,part:i,stats:d,id:a.type})};t.length===0&&T.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+a.type+" level: "+a.level+" sn: "+a.sn),this.blockBuffers(c,t)},y.onFragChanged=function(e,o){this.flushBackBuffer()},y.onBufferEos=function(e,o){var f=this,a=this.getSourceBufferTypes().reduce(function(i,t){var u=f.sourceBuffer[t];return(!o.type||o.type===t)&&u&&!u.ended&&(u.ended=!0,T.logger.log("[buffer-controller]: "+t+" sourceBuffer now EOS")),i&&!!(!u||u.ended)},!0);a&&this.blockBuffers(function(){var i=f.mediaSource;!i||i.readyState!=="open"||i.endOfStream()})},y.onLevelUpdated=function(e,o){var f=o.details;!f.fragments.length||(this.details=f,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},y.flushBackBuffer=function(){var e=this.hls,o=this.details,f=this.media,a=this.sourceBuffer;if(!(!f||o===null)){var i=this.getSourceBufferTypes();if(!!i.length){var t=o.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(!(!Object(R.isFiniteNumber)(t)||t<0)){var u=f.currentTime,c=o.levelTargetDuration,r=Math.max(t,c),h=Math.floor(u/c)*c-r;i.forEach(function(d){var l=a[d];if(l){var v=S.BufferHelper.getBuffered(l);v.length>0&&h>v.start(0)&&(e.trigger(p.Events.BACK_BUFFER_REACHED,{bufferEnd:h}),o.live&&e.trigger(p.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:h}),e.trigger(p.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:h,type:d}))}})}}}},y.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var e=this.details,o=this.hls,f=this.media,a=this.mediaSource,i=e.fragments[0].start+e.totalduration,t=f.duration,u=Object(R.isFiniteNumber)(a.duration)?a.duration:0;e.live&&o.config.liveDurationInfinity?(T.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),a.duration=1/0,this.updateSeekableRange(e)):(i>u&&i>t||!Object(R.isFiniteNumber)(t))&&(T.logger.log("[buffer-controller]: Updating Media Source duration to "+i.toFixed(3)),a.duration=i)}},y.updateSeekableRange=function(e){var o=this.mediaSource,f=e.fragments,a=f.length;if(a&&e.live&&o!==null&&o!==void 0&&o.setLiveSeekableRange){var i=Math.max(0,f[0].start),t=Math.max(i,i+e.totalduration);o.setLiveSeekableRange(i,t)}},y.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,o=this.operationQueue,f=this.pendingTracks,a=Object.keys(f).length;if(a&&!e||a===2){this.createSourceBuffers(f),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){o.executeNext(t)})}},y.createSourceBuffers=function(e){var o=this.sourceBuffer,f=this.mediaSource;if(!f)throw Error("createSourceBuffers called when mediaSource was null");var a=0;for(var i in e)if(!o[i]){var t=e[i];if(!t)throw Error("source buffer exists for track "+i+", however track does not");var u=t.levelCodec||t.codec,c=t.container+";codecs="+u;T.logger.log("[buffer-controller]: creating sourceBuffer("+c+")");try{var r=o[i]=f.addSourceBuffer(c),h=i;this.addBufferListener(h,"updatestart",this._onSBUpdateStart),this.addBufferListener(h,"updateend",this._onSBUpdateEnd),this.addBufferListener(h,"error",this._onSBUpdateError),this.tracks[i]={buffer:r,codec:u,container:t.container,levelCodec:t.levelCodec,metadata:t.metadata,id:t.id},a++}catch(d){T.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+d.message),this.hls.trigger(p.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:d,mimeType:c})}}a&&this.hls.trigger(p.Events.BUFFER_CREATED,{tracks:this.tracks})},y._onSBUpdateStart=function(e){var o=this.operationQueue,f=o.current(e);f.onStart()},y._onSBUpdateEnd=function(e){var o=this.operationQueue,f=o.current(e);f.onComplete(),o.shiftAndExecuteNext(e)},y._onSBUpdateError=function(e,o){T.logger.error("[buffer-controller]: "+e+" SourceBuffer error",o),this.hls.trigger(p.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var f=this.operationQueue.current(e);f&&f.onError(o)},y.removeExecutor=function(e,o,f){var a=this.media,i=this.mediaSource,t=this.operationQueue,u=this.sourceBuffer,c=u[e];if(!a||!i||!c){T.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)(a.duration)?a.duration:1/0,h=Object(R.isFiniteNumber)(i.duration)?i.duration:1/0,d=Math.max(0,o),l=Math.min(f,r,h);l>d?(T.logger.log("[buffer-controller]: Removing ["+d+","+l+"] from the "+e+" SourceBuffer"),console.assert(!c.updating,e+" sourceBuffer must not be updating"),c.remove(d,l)):t.shiftAndExecuteNext(e)},y.appendExecutor=function(e,o){var f=this.operationQueue,a=this.sourceBuffer,i=a[o];if(!i){T.logger.warn("[buffer-controller]: Attempting to append to the "+o+" SourceBuffer, but it does not exist"),f.shiftAndExecuteNext(o);return}i.ended=!1,console.assert(!i.updating,o+" sourceBuffer must not be updating"),i.appendBuffer(e)},y.blockBuffers=function(e,o){var f=this;if(o===void 0&&(o=this.getSourceBufferTypes()),!o.length){T.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}var a=this.operationQueue,i=o.map(function(t){return a.appendBlocker(t)});Promise.all(i).then(function(){e(),o.forEach(function(t){var u=f.sourceBuffer[t];(!u||!u.updating)&&a.shiftAndExecuteNext(t)})})},y.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},y.addBufferListener=function(e,o,f){var a=this.sourceBuffer[e];if(!!a){var i=f.bind(this,e);this.listeners[e].push({event:o,listener:i}),a.addEventListener(o,i)}},y.removeBufferListeners=function(e){var o=this.sourceBuffer[e];!o||this.listeners[e].forEach(function(f){o.removeEventListener(f.event,f.listener)})},g}()},"./src/controller/buffer-operation-queue.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return p});var R=n("./src/utils/logger.ts"),p=function(){function T(S){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=S}var I=T.prototype;return I.append=function(O,_){var E=this.queues[_];E.push(O),E.length===1&&this.buffers[_]&&this.executeNext(_)},I.insertAbort=function(O,_){var E=this.queues[_];E.unshift(O),this.executeNext(_)},I.appendBlocker=function(O){var _,E=new Promise(function(D){_=D}),A={execute:_,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(A,O),E},I.executeNext=function(O){var _=this.buffers,E=this.queues,A=_[O],D=E[O];if(D.length){var x=D[0];try{x.execute()}catch(g){R.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),x.onError(g),(!A||!A.updating)&&(D.shift(),this.executeNext(O))}}},I.shiftAndExecuteNext=function(O){this.queues[O].shift(),this.executeNext(O)},I.current=function(O){return this.queues[O][0]},T}()},"./src/controller/cap-level-controller.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/events.ts");function p(S,O){for(var _=0;_<O.length;_++){var E=O[_];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(S,E.key,E)}}function T(S,O,_){return O&&p(S.prototype,O),_&&p(S,_),Object.defineProperty(S,"prototype",{writable:!1}),S}var I=function(){function S(_){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 O=S.prototype;return O.setStreamController=function(E){this.streamController=E},O.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},O.registerListeners=function(){var E=this.hls;E.on(R.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),E.on(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),E.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),E.on(R.Events.BUFFER_CODECS,this.onBufferCodecs,this),E.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},O.unregisterListener=function(){var E=this.hls;E.off(R.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),E.off(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),E.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),E.off(R.Events.BUFFER_CODECS,this.onBufferCodecs,this),E.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},O.onFpsDropLevelCapping=function(E,A){S.isLevelAllowed(A.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(A.droppedLevel)},O.onMediaAttaching=function(E,A){this.media=A.media instanceof HTMLVideoElement?A.media:null},O.onManifestParsed=function(E,A){var D=this.hls;this.restrictedLevels=[],this.firstLevel=A.firstLevel,D.config.capLevelToPlayerSize&&A.video&&this.startCapping()},O.onBufferCodecs=function(E,A){var D=this.hls;D.config.capLevelToPlayerSize&&A.video&&this.startCapping()},O.onMediaDetaching=function(){this.stopCapping()},O.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var E=this.hls.levels;if(E.length){var A=this.hls;A.autoLevelCapping=this.getMaxLevel(E.length-1),A.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=A.autoLevelCapping}}},O.getMaxLevel=function(E){var A=this,D=this.hls.levels;if(!D.length)return-1;var x=D.filter(function(g,y){return S.isLevelAllowed(y,A.restrictedLevels)&&y<=E});return this.clientRect=null,S.getMaxLevelByMediaSize(x,this.mediaWidth,this.mediaHeight)},O.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())},O.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},O.getDimensions=function(){if(this.clientRect)return this.clientRect;var E=this.media,A={width:0,height:0};if(E){var D=E.getBoundingClientRect();A.width=D.width,A.height=D.height,!A.width&&!A.height&&(A.width=D.right-D.left||E.width||0,A.height=D.bottom-D.top||E.height||0)}return this.clientRect=A,A},S.isLevelAllowed=function(E,A){return A===void 0&&(A=[]),A.indexOf(E)===-1},S.getMaxLevelByMediaSize=function(E,A,D){if(!E||!E.length)return-1;for(var x=function(o,f){return f?o.width!==f.width||o.height!==f.height:!0},g=E.length-1,y=0;y<E.length;y+=1){var s=E[y];if((s.width>=A||s.height>=D)&&x(s,E[y+1])){g=y;break}}return g},T(S,[{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 E=1;if(!this.hls.config.ignoreDevicePixelRatio)try{E=self.devicePixelRatio}catch{}return E}}]),S}();P.default=I},"./src/controller/cmcd-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return x});var R=n("./src/events.ts"),p=n("./src/types/cmcd.ts"),T=n("./src/utils/buffer-helper.ts"),I=n("./src/utils/logger.ts");function S(g,y){for(var s=0;s<y.length;s++){var e=y[s];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(g,e.key,e)}}function O(g,y,s){return y&&S(g.prototype,y),s&&S(g,s),Object.defineProperty(g,"prototype",{writable:!1}),g}function _(g,y){var s=typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(s)return(s=s.call(g)).next.bind(s);if(Array.isArray(g)||(s=E(g))||y&&g&&typeof g.length=="number"){s&&(g=s);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 E(g,y){if(!!g){if(typeof g=="string")return A(g,y);var s=Object.prototype.toString.call(g).slice(8,-1);if(s==="Object"&&g.constructor&&(s=g.constructor.name),s==="Map"||s==="Set")return Array.from(g);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return A(g,y)}}function A(g,y){(y==null||y>g.length)&&(y=g.length);for(var s=0,e=new Array(y);s<y;s++)e[s]=g[s];return e}function D(){return D=Object.assign?Object.assign.bind():function(g){for(var y=1;y<arguments.length;y++){var s=arguments[y];for(var e in s)Object.prototype.hasOwnProperty.call(s,e)&&(g[e]=s[e])}return g},D.apply(this,arguments)}var x=function(){function g(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(a){try{e.apply(a,{ot:p.CMCDObjectType.MANIFEST,su:!e.initialized})}catch(i){I.logger.warn("Could not generate manifest CMCD data.",i)}},this.applyFragmentData=function(a){try{var i=a.frag,t=e.hls.levels[i.level],u=e.getObjectType(i),c={d:i.duration*1e3,ot:u};(u===p.CMCDObjectType.VIDEO||u===p.CMCDObjectType.AUDIO||u==p.CMCDObjectType.MUXED)&&(c.br=t.bitrate/1e3,c.tb=e.getTopBandwidth(u)/1e3,c.bl=e.getBufferLength(u)),e.apply(a,c)}catch(r){I.logger.warn("Could not generate segment CMCD data.",r)}},this.hls=s;var o=this.config=s.config,f=o.cmcd;f!=null&&(o.pLoader=this.createPlaylistLoader(),o.fLoader=this.createFragmentLoader(),this.sid=f.sessionId||g.uuid(),this.cid=f.contentId,this.useHeaders=f.useHeaders===!0,this.registerListeners())}var y=g.prototype;return y.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)},y.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()},y.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},y.onMediaAttached=function(e,o){this.media=o.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},y.onMediaDetached=function(){!this.media||(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},y.onBufferCreated=function(e,o){var f,a;this.audioBuffer=(f=o.tracks.audio)===null||f===void 0?void 0:f.buffer,this.videoBuffer=(a=o.tracks.video)===null||a===void 0?void 0:a.buffer},y.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}},y.apply=function(e,o){o===void 0&&(o={}),D(o,this.createData());var f=o.ot===p.CMCDObjectType.INIT||o.ot===p.CMCDObjectType.VIDEO||o.ot===p.CMCDObjectType.MUXED;if(this.starved&&f&&(o.bs=!0,o.su=!0,this.starved=!1),o.su==null&&(o.su=this.buffering),this.useHeaders){var a=g.toHeaders(o);if(!Object.keys(a).length)return;e.headers||(e.headers={}),D(e.headers,a)}else{var i=g.toQuery(o);if(!i)return;e.url=g.appendQueryToUri(e.url,i)}},y.getObjectType=function(e){var o=e.type;if(o==="subtitle")return p.CMCDObjectType.TIMED_TEXT;if(e.sn==="initSegment")return p.CMCDObjectType.INIT;if(o==="audio")return p.CMCDObjectType.AUDIO;if(o==="main")return this.hls.audioTracks.length?p.CMCDObjectType.VIDEO:p.CMCDObjectType.MUXED},y.getTopBandwidth=function(e){var o=0,f,a=this.hls;if(e===p.CMCDObjectType.AUDIO)f=a.audioTracks;else{var i=a.maxAutoLevel,t=i>-1?i+1:a.levels.length;f=a.levels.slice(0,t)}for(var u=_(f),c;!(c=u()).done;){var r=c.value;r.bitrate>o&&(o=r.bitrate)}return o>0?o:NaN},y.getBufferLength=function(e){var o=this.hls.media,f=e===p.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!f||!o)return NaN;var a=T.BufferHelper.bufferInfo(f,o.currentTime,this.config.maxBufferHole);return a.len*1e3},y.createPlaylistLoader=function(){var e=this.config.pLoader,o=this.applyPlaylistData,f=e||this.config.loader;return function(){function a(t){this.loader=void 0,this.loader=new f(t)}var i=a.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(u,c,r){o(u),this.loader.load(u,c,r)},O(a,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),a}()},y.createFragmentLoader=function(){var e=this.config.fLoader,o=this.applyFragmentData,f=e||this.config.loader;return function(){function a(t){this.loader=void 0,this.loader=new f(t)}var i=a.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(u,c,r){o(u),this.loader.load(u,c,r)},O(a,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),a}()},g.uuid=function(){var e=URL.createObjectURL(new Blob),o=e.toString();return URL.revokeObjectURL(e),o.slice(o.lastIndexOf("/")+1)},g.serialize=function(e){for(var o=[],f=function(M){return!Number.isNaN(M)&&M!=null&&M!==""&&M!==!1},a=function(M){return Math.round(M)},i=function(M){return a(M/100)*100},t=function(M){return encodeURIComponent(M)},u={br:a,d:a,bl:i,dl:i,mtp:i,nor:t,rtp:i,tb:a},c=Object.keys(e||{}).sort(),r=_(c),h;!(h=r()).done;){var d=h.value,l=e[d];if(!!f(l)&&!(d==="v"&&l===1)&&!(d=="pr"&&l===1)){var v=u[d];v&&(l=v(l));var m=typeof l,L=void 0;d==="ot"||d==="sf"||d==="st"?L=d+"="+l:m==="boolean"?L=d:m==="number"?L=d+"="+l:L=d+"="+JSON.stringify(l),o.push(L)}}return o.join(",")},g.toHeaders=function(e){for(var o=Object.keys(e),f={},a=["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},u=0,c=o;u<c.length;u++){var r=c[u],h=t[r]!=null?t[r]:1;i[h][r]=e[r]}for(var d=0;d<i.length;d++){var l=g.serialize(i[d]);l&&(f["CMCD-"+a[d]]=l)}return f},g.toQuery=function(e){return"CMCD="+encodeURIComponent(g.serialize(e))},g.appendQueryToUri=function(e,o){if(!o)return e;var f=e.includes("?")?"&":"?";return""+e+f+o},g}()},"./src/controller/eme-controller.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/events.ts"),p=n("./src/errors.ts"),T=n("./src/utils/logger.ts"),I=n("./src/utils/mediakeys-helper.ts");function S(x,g){for(var y=0;y<g.length;y++){var s=g[y];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(x,s.key,s)}}function O(x,g,y){return g&&S(x.prototype,g),y&&S(x,y),Object.defineProperty(x,"prototype",{writable:!1}),x}var _=3,E=function(g,y,s){var e={audioCapabilities:[],videoCapabilities:[]};return g.forEach(function(o){e.audioCapabilities.push({contentType:'audio/mp4; codecs="'+o+'"',robustness:s.audioRobustness||""})}),y.forEach(function(o){e.videoCapabilities.push({contentType:'video/mp4; codecs="'+o+'"',robustness:s.videoRobustness||""})}),[e]},A=function(g,y,s,e){switch(g){case I.KeySystems.WIDEVINE:return E(y,s,e);default:throw new Error("Unknown key-system: "+g)}},D=function(){function x(y){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=y,this._config=y.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=x.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(s){switch(s){case I.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+s+'"')},g._attemptKeySystemAccess=function(s,e,o){var f=this,a=A(s,e,o,this._drmSystemOptions);T.logger.log("Requesting encrypted media key-system access");var i=this.requestMediaKeySystemAccess(s,a);this.mediaKeysPromise=i.then(function(t){return f._onMediaKeySystemAccessObtained(s,t)}),i.catch(function(t){T.logger.error('Failed to obtain key-system "'+s+'" access:',t)})},g._onMediaKeySystemAccessObtained=function(s,e){var o=this;T.logger.log('Access for key-system "'+s+'" obtained');var f={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:e,mediaKeySystemDomain:s};this._mediaKeysList.push(f);var a=Promise.resolve().then(function(){return e.createMediaKeys()}).then(function(i){return f.mediaKeys=i,T.logger.log('Media-keys created for key-system "'+s+'"'),o._onMediaKeysCreated(),i});return a.catch(function(i){T.logger.error("Failed to create media-keys:",i)}),a},g._onMediaKeysCreated=function(){var s=this;this._mediaKeysList.forEach(function(e){e.mediaKeysSession||(e.mediaKeysSession=e.mediaKeys.createSession(),s._onNewMediaKeySession(e.mediaKeysSession))})},g._onNewMediaKeySession=function(s){var e=this;T.logger.log("New key-system session "+s.sessionId),s.addEventListener("message",function(o){e._onKeySessionMessage(s,o.message)},!1)},g._onKeySessionMessage=function(s,e){T.logger.log("Got EME message event, creating license request"),this._requestLicense(e,function(o){T.logger.log("Received license data (length: "+(o&&o.byteLength)+"), updating key-session"),s.update(o).catch(function(f){T.logger.warn("Updating key-session failed: "+f)})})},g.onMediaEncrypted=function(s){var e=this;if(T.logger.log('Media is encrypted using "'+s.initDataType+'" init data type'),!this.mediaKeysPromise){T.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 o=function(a){!e._media||(e._attemptSetMediaKeys(a),e._generateRequestWithPreferredKeySession(s.initDataType,s.initData))};this.mediaKeysPromise.then(o).catch(o)},g._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){T.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}T.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}},g._generateRequestWithPreferredKeySession=function(s,e){var o=this,f=this._mediaKeysList[0];if(!f){T.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(f.mediaKeysSessionInitialized){T.logger.warn("Key-Session already initialized but requested again");return}var a=f.mediaKeysSession;if(!a){T.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){T.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}T.logger.log('Generating key-session request for "'+s+'" init data type'),f.mediaKeysSessionInitialized=!0,a.generateRequest(s,e).then(function(){T.logger.debug("Key-session generation succeeded")}).catch(function(i){T.logger.error("Error generating key-session request:",i),o.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},g._createLicenseXhr=function(s,e,o){var f=new XMLHttpRequest;f.responseType="arraybuffer",f.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,f,s,e,o);var a=this._licenseXhrSetup;if(a)try{a.call(this.hls,f,s),a=void 0}catch(i){T.logger.error(i)}try{f.readyState||f.open("POST",s,!0),a&&a.call(this.hls,f,s)}catch(i){throw new Error("issue setting up KeySystem license XHR "+i)}return f},g._onLicenseRequestReadyStageChange=function(s,e,o,f){switch(s.readyState){case 4:if(s.status===200){this._requestLicenseFailureCount=0,T.logger.log("License request succeeded");var a=s.response,i=this._licenseResponseCallback;if(i)try{a=i.call(this.hls,s,e)}catch(u){T.logger.error(u)}f(a)}else{if(T.logger.error("License Request XHR failed ("+e+"). Status: "+s.status+" ("+s.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>_){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=_-this._requestLicenseFailureCount+1;T.logger.warn("Retrying license request, "+t+" attempts left"),this._requestLicense(o,f)}break}},g._generateLicenseRequestChallenge=function(s,e){switch(s.mediaKeySystemDomain){case I.KeySystems.WIDEVINE:return e}throw new Error("unsupported key-system: "+s.mediaKeySystemDomain)},g._requestLicense=function(s,e){T.logger.log("Requesting content license for key-system");var o=this._mediaKeysList[0];if(!o){T.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 f=this.getLicenseServerUrl(o.mediaKeySystemDomain),a=this._createLicenseXhr(f,s,e);T.logger.log("Sending license request to URL: "+f);var i=this._generateLicenseRequestChallenge(o,s);a.send(i)}catch(t){T.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(s,e){if(!!this._emeEnabled){var o=e.media;this._media=o,o.addEventListener("encrypted",this._onMediaEncrypted)}},g.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(o){if(o.mediaKeysSession)return o.mediaKeysSession.close().catch(function(){})})).then(function(){return s.setMediaKeys(null)}).catch(function(){}))},g.onManifestParsed=function(s,e){if(!!this._emeEnabled){var o=e.levels.map(function(a){return a.audioCodec}).filter(function(a){return!!a}),f=e.levels.map(function(a){return a.videoCodec}).filter(function(a){return!!a});this._attemptKeySystemAccess(I.KeySystems.WIDEVINE,o,f)}},O(x,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),x}();P.default=D},"./src/controller/fps-controller.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/events.ts"),p=n("./src/utils/logger.ts"),T=function(){function I(O){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=O,this.registerListeners()}var S=I.prototype;return S.setStreamController=function(_){this.streamController=_},S.registerListeners=function(){this.hls.on(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},S.unregisterListeners=function(){this.hls.off(R.Events.MEDIA_ATTACHING,this.onMediaAttaching)},S.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},S.onMediaAttaching=function(_,E){var A=this.hls.config;if(A.capLevelOnFPSDrop){var D=E.media instanceof self.HTMLVideoElement?E.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)}},S.checkFPS=function(_,E,A){var D=performance.now();if(E){if(this.lastTime){var x=D-this.lastTime,g=A-this.lastDroppedFrames,y=E-this.lastDecodedFrames,s=1e3*g/x,e=this.hls;if(e.trigger(R.Events.FPS_DROP,{currentDropped:g,currentDecoded:y,totalDroppedFrames:A}),s>0&&g>e.config.fpsDroppedMonitoringThreshold*y){var o=e.currentLevel;p.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+o),o>0&&(e.autoLevelCapping===-1||e.autoLevelCapping>=o)&&(o=o-1,e.trigger(R.Events.FPS_DROP_LEVEL_CAPPING,{level:o,droppedLevel:e.currentLevel}),e.autoLevelCapping=o,this.streamController.nextLevelSwitch())}}this.lastTime=D,this.lastDroppedFrames=A,this.lastDecodedFrames=E}},S.checkFPSInterval=function(){var _=this.media;if(_)if(this.isVideoPlaybackQualityAvailable){var E=_.getVideoPlaybackQuality();this.checkFPS(_,E.totalVideoFrames,E.droppedVideoFrames)}else this.checkFPS(_,_.webkitDecodedFrameCount,_.webkitDroppedFrameCount)},I}();P.default=T},"./src/controller/fragment-finders.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"findFragmentByPDT",function(){return T}),n.d(P,"findFragmentByPTS",function(){return I}),n.d(P,"fragmentWithinToleranceTest",function(){return S}),n.d(P,"pdtWithinToleranceTest",function(){return O}),n.d(P,"findFragWithCC",function(){return _});var R=n("./src/polyfills/number.ts"),p=n("./src/utils/binary-search.ts");function T(E,A,D){if(A===null||!Array.isArray(E)||!E.length||!Object(R.isFiniteNumber)(A))return null;var x=E[0].programDateTime;if(A<(x||0))return null;var g=E[E.length-1].endProgramDateTime;if(A>=(g||0))return null;D=D||0;for(var y=0;y<E.length;++y){var s=E[y];if(O(A,D,s))return s}return null}function I(E,A,D,x){D===void 0&&(D=0),x===void 0&&(x=0);var g=null;if(E?g=A[E.sn-A[0].sn+1]||null:D===0&&A[0].start===0&&(g=A[0]),g&&S(D,x,g)===0)return g;var y=p.default.search(A,S.bind(null,D,x));return y||g}function S(E,A,D){E===void 0&&(E=0),A===void 0&&(A=0);var x=Math.min(A,D.duration+(D.deltaPTS?D.deltaPTS:0));return D.start+D.duration-x<=E?1:D.start-x>E&&D.start?-1:0}function O(E,A,D){var x=Math.min(A,D.duration+(D.deltaPTS?D.deltaPTS:0))*1e3,g=D.endProgramDateTime||0;return g-x>E}function _(E,A){return p.default.search(E,function(D){return D.cc<A?1:D.cc>A?-1:0})}},"./src/controller/fragment-tracker.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"FragmentState",function(){return T}),n.d(P,"FragmentTracker",function(){return I});var R=n("./src/events.ts"),p=n("./src/types/loader.ts"),T;(function(_){_.NOT_LOADED="NOT_LOADED",_.APPENDING="APPENDING",_.PARTIAL="PARTIAL",_.OK="OK"})(T||(T={}));var I=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 E=_.prototype;return E._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)},E._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)},E.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},E.getAppendedFrag=function(D,x){if(x===p.PlaylistLevelType.MAIN){var g=this.activeFragment,y=this.activeParts;if(!g)return null;if(y)for(var s=y.length;s--;){var e=y[s],o=e?e.end:g.appendedPTS;if(e.start<=D&&o!==void 0&&D<=o)return s>9&&(this.activeParts=y.slice(s-9)),e}else if(g.start<=D&&g.appendedPTS!==void 0&&D<=g.appendedPTS)return g}return this.getBufferedFrag(D,x)},E.getBufferedFrag=function(D,x){for(var g=this.fragments,y=Object.keys(g),s=y.length;s--;){var e=g[y[s]];if((e==null?void 0:e.body.type)===x&&e.buffered){var o=e.body;if(o.start<=D&&D<=o.end)return o}}return null},E.detectEvictedFragments=function(D,x,g){var y=this;Object.keys(this.fragments).forEach(function(s){var e=y.fragments[s];if(!!e){if(!e.buffered){e.body.type===g&&y.removeFragment(e.body);return}var o=e.range[D];!o||o.time.some(function(f){var a=!y.isTimeBuffered(f.startPTS,f.endPTS,x);return a&&y.removeFragment(e.body),a})}})},E.detectPartialFragments=function(D){var x=this,g=this.timeRanges,y=D.frag,s=D.part;if(!(!g||y.sn==="initSegment")){var e=O(y),o=this.fragments[e];!o||(Object.keys(g).forEach(function(f){var a=y.elementaryStreams[f];if(!!a){var i=g[f],t=s!==null||a.partial===!0;o.range[f]=x.getBufferedTimes(y,s,t,i)}}),o.loaded=null,Object.keys(o.range).length?o.buffered=!0:this.removeFragment(o.body))}},E.fragBuffered=function(D){var x=O(D),g=this.fragments[x];g&&(g.loaded=null,g.buffered=!0)},E.getBufferedTimes=function(D,x,g,y){for(var s={time:[],partial:g},e=x?x.start:D.start,o=x?x.end:D.end,f=D.minEndPTS||o,a=D.maxStartPTS||e,i=0;i<y.length;i++){var t=y.start(i)-this.bufferPadding,u=y.end(i)+this.bufferPadding;if(a>=t&&f<=u){s.time.push({startPTS:Math.max(e,y.start(i)),endPTS:Math.min(o,y.end(i))});break}else if(e<u&&o>t)s.partial=!0,s.time.push({startPTS:Math.max(e,y.start(i)),endPTS:Math.min(o,y.end(i))});else if(o<=t)break}return s},E.getPartialFragment=function(D){var x=null,g,y,s,e=0,o=this.bufferPadding,f=this.fragments;return Object.keys(f).forEach(function(a){var i=f[a];!i||S(i)&&(y=i.body.start-o,s=i.body.end+o,D>=y&&D<=s&&(g=Math.min(D-y,s-D),e<=g&&(x=i.body,e=g)))}),x},E.getState=function(D){var x=O(D),g=this.fragments[x];return g?g.buffered?S(g)?T.PARTIAL:T.OK:T.APPENDING:T.NOT_LOADED},E.isTimeBuffered=function(D,x,g){for(var y,s,e=0;e<g.length;e++){if(y=g.start(e)-this.bufferPadding,s=g.end(e)+this.bufferPadding,D>=y&&x<=s)return!0;if(x<=y)return!1}return!1},E.onFragLoaded=function(D,x){var g=x.frag,y=x.part;if(!(g.sn==="initSegment"||g.bitrateTest||y)){var s=O(g);this.fragments[s]={body:g,loaded:x,buffered:!1,range:Object.create(null)}}},E.onBufferAppended=function(D,x){var g=this,y=x.frag,s=x.part,e=x.timeRanges;if(y.type===p.PlaylistLevelType.MAIN)if(this.activeFragment=y,s){var o=this.activeParts;o||(this.activeParts=o=[]),o.push(s)}else this.activeParts=null;this.timeRanges=e,Object.keys(e).forEach(function(f){var a=e[f];if(g.detectEvictedFragments(f,a),!s)for(var i=0;i<a.length;i++)y.appendedPTS=Math.max(a.end(i),y.appendedPTS||0)})},E.onFragBuffered=function(D,x){this.detectPartialFragments(x)},E.hasFragment=function(D){var x=O(D);return!!this.fragments[x]},E.removeFragmentsInRange=function(D,x,g){var y=this;Object.keys(this.fragments).forEach(function(s){var e=y.fragments[s];if(!!e&&e.buffered){var o=e.body;o.type===g&&o.start<x&&o.end>D&&y.removeFragment(o)}})},E.removeFragment=function(D){var x=O(D);D.stats.loaded=0,D.clearElementaryStreamInfo(),delete this.fragments[x]},E.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},_}();function S(_){var E,A;return _.buffered&&(((E=_.range.video)===null||E===void 0?void 0:E.partial)||((A=_.range.audio)===null||A===void 0?void 0:A.partial))}function O(_){return _.type+"_"+_.level+"_"+_.urlId+"_"+_.sn}},"./src/controller/gap-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"STALL_MINIMUM_DURATION_MS",function(){return S}),n.d(P,"MAX_START_GAP_JUMP",function(){return O}),n.d(P,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return _}),n.d(P,"SKIP_BUFFER_RANGE_START",function(){return E}),n.d(P,"default",function(){return A});var R=n("./src/utils/buffer-helper.ts"),p=n("./src/errors.ts"),T=n("./src/events.ts"),I=n("./src/utils/logger.ts"),S=250,O=2,_=.1,E=.05,A=function(){function D(g,y,s,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=y,this.fragmentTracker=s,this.hls=e}var x=D.prototype;return x.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},x.poll=function(y,s){var e=this.config,o=this.media,f=this.stalled;if(o!==null){var a=o.currentTime,i=o.seeking,t=this.seeking&&!i,u=!this.seeking&&i;if(this.seeking=i,a!==y){if(this.moved=!0,f!==null){if(this.stallReported){var c=self.performance.now()-f;I.logger.warn("playback not stuck anymore @"+a+", after "+Math.round(c)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((u||t)&&(this.stalled=null),!(o.paused&&!i||o.ended||o.playbackRate===0||!R.BufferHelper.getBuffered(o).length)){var r=R.BufferHelper.bufferInfo(o,a,0),h=r.len>0,d=r.nextStart||0;if(!(!h&&!d)){if(i){var l=r.len>O,v=!d||s&&s.start<=a||d-a>O&&!this.fragmentTracker.getPartialFragment(a);if(l||v)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var m,L=Math.max(d,r.start||0)-a,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:O;if(L>0&&L<=F){this._trySkipBufferHole(null);return}}var w=self.performance.now();if(f===null){this.stalled=w;return}var C=w-f;if(!(!i&&C>=S&&(this._reportStall(r),!this.media))){var U=R.BufferHelper.bufferInfo(o,a,e.maxBufferHole);this._tryFixBufferStall(U,C)}}}}},x._tryFixBufferStall=function(y,s){var e=this.config,o=this.fragmentTracker,f=this.media;if(f!==null){var a=f.currentTime,i=o.getPartialFragment(a);if(i){var t=this._trySkipBufferHole(i);if(t||!this.media)return}y.len>e.maxBufferHole&&s>e.highBufferWatchdogPeriod*1e3&&(I.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},x._reportStall=function(y){var s=this.hls,e=this.media,o=this.stallReported;!o&&e&&(this.stallReported=!0,I.logger.warn("Playback stalling at @"+e.currentTime+" due to low buffer ("+JSON.stringify(y)+")"),s.trigger(T.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:y.len}))},x._trySkipBufferHole=function(y){var s=this.config,e=this.hls,o=this.media;if(o===null)return 0;for(var f=o.currentTime,a=0,i=R.BufferHelper.getBuffered(o),t=0;t<i.length;t++){var u=i.start(t);if(f+s.maxBufferHole>=a&&f<u){var c=Math.max(u+E,o.currentTime+_);return I.logger.warn("skipping hole, adjusting currentTime from "+f+" to "+c),this.moved=!0,this.stalled=null,o.currentTime=c,y&&e.trigger(T.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+f+" to "+c,frag:y}),c}a=i.end(t)}return 0},x._tryNudgeBuffer=function(){var y=this.config,s=this.hls,e=this.media,o=this.nudgeRetry;if(e!==null){var f=e.currentTime;if(this.nudgeRetry++,o<y.nudgeMaxRetry){var a=f+(o+1)*y.nudgeOffset;I.logger.warn("Nudging 'currentTime' from "+f+" to "+a),e.currentTime=a,s.trigger(T.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 @"+f+" after "+y.nudgeMaxRetry+" nudges"),s.trigger(T.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},D}()},"./src/controller/id3-track-controller.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/polyfills/number.ts"),p=n("./src/events.ts"),T=n("./src/utils/texttrack-utils.ts"),I=n("./src/demux/id3.ts"),S=n("./src/loader/date-range.ts"),O=n("./src/types/demuxer.ts"),_=.25;function E(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}function A(g,y){return g.getTime()/1e3-y}function D(g){return Uint8Array.from(g.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var x=function(){function g(s){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=s,this._registerListeners()}var y=g.prototype;return y.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},y._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)},y._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)},y.onMediaAttached=function(e,o){this.media=o.media},y.onMediaDetaching=function(){!this.id3Track||(Object(T.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},y.onManifestLoading=function(){this.dateRangeCuesAppended={}},y.createTrack=function(e){var o=this.getID3Track(e.textTracks);return o.mode="hidden",o},y.getID3Track=function(e){if(!!this.media){for(var o=0;o<e.length;o++){var f=e[o];if(f.kind==="metadata"&&f.label==="id3")return Object(T.sendAddTrackEvent)(f,this.media),f}return this.media.addTextTrack("metadata","id3")}},y.onFragParsingMetadata=function(e,o){if(!!this.media){var f=this.hls.config,a=f.enableEmsgMetadataCues,i=f.enableID3MetadataCues;if(!(!a&&!i)){var t=o.frag,u=o.samples,c=o.details;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var r=c.edge||t.end,h=E(),d=!1,l={},v=0;v<u.length;v++){var m=u[v].type;if(!(m===O.MetadataSchema.emsg&&!a||!i)){var L=I.getID3Frames(u[v].data);if(L){var b=u[v].pts,M=r,F=M-b;F<=0&&(M=b+_);for(var w=0;w<L.length;w++){var C=L[w];if(!I.isTimeStampFrame(C)){var U=new h(b,M,"");U.value=C,m&&(U.type=m),this.id3Track.addCue(U),l[C.key]=null,d=!0}}}}}d&&this.updateId3CueEnds(l)}}},y.updateId3CueEnds=function(e){var o,f=(o=this.id3Track)===null||o===void 0?void 0:o.cues;if(f)for(var a=f.length;a--;){var i,t=f[a],u=(i=t.value)===null||i===void 0?void 0:i.key;if(u&&u in e){var c=e[u];c&&t.endTime!==c&&(t.endTime=c),e[u]=t.startTime}}},y.onBufferFlushing=function(e,o){var f=o.startOffset,a=o.endOffset,i=o.type,t=this.id3Track,u=this.hls;if(!!u){var c=u.config,r=c.enableEmsgMetadataCues,h=c.enableID3MetadataCues;if(t&&(r||h)){var d;i==="audio"?d=function(v){return v.type===O.MetadataSchema.audioId3&&h}:i==="video"?d=function(v){return v.type===O.MetadataSchema.emsg&&r}:d=function(v){return v.type===O.MetadataSchema.audioId3&&h||v.type===O.MetadataSchema.emsg&&r},Object(T.removeCuesInRange)(t,f,a,d)}}},y.onLevelUpdated=function(e,o){var f=this,a=o.details;if(!(!this.media||!a.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var i=this.dateRangeCuesAppended,t=this.id3Track,u=a.dateRanges,c=Object.keys(u);if(t)for(var r=Object.keys(i).filter(function(F){return!c.includes(F)}),h=function(w){var C=r[w];Object.keys(i[C].cues).forEach(function(U){t.removeCue(i[C].cues[U])}),delete i[C]},d=r.length;d--;)h(d);var l=a.fragments[a.fragments.length-1];if(!(c.length===0||!Object(R.isFiniteNumber)(l==null?void 0:l.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var v=l.programDateTime/1e3-l.start,m=a.edge||l.end,L=E(),b=function(w){var C=c[w],U=u[C],k=i[C],j=(k==null?void 0:k.cues)||{},N=(k==null?void 0:k.durationKnown)||!1,W=A(U.startDate,v),Y=m,K=U.endDate;if(K)Y=A(K,v),N=!0;else if(U.endOnNext&&!N){var H=c.reduce(function(Q,ae){var se=u[ae];return se.class===U.class&&se.id!==ae&&se.startDate>U.startDate&&Q.push(se),Q},[]).sort(function(Q,ae){return Q.startDate.getTime()-ae.startDate.getTime()})[0];H&&(Y=A(H.startDate,v),N=!0)}for(var z=Object.keys(U.attr),$=0;$<z.length;$++){var X=z[$];if(!(X===S.DateRangeAttribute.ID||X===S.DateRangeAttribute.CLASS||X===S.DateRangeAttribute.START_DATE||X===S.DateRangeAttribute.DURATION||X===S.DateRangeAttribute.END_DATE||X===S.DateRangeAttribute.END_ON_NEXT)){var J=j[X];if(J)N&&!k.durationKnown&&(J.endTime=Y);else{var te=U.attr[X];J=new L(W,Y,""),(X===S.DateRangeAttribute.SCTE35_OUT||X===S.DateRangeAttribute.SCTE35_IN)&&(te=D(te)),J.value={key:X,data:te},J.type=O.MetadataSchema.dateRange,f.id3Track.addCue(J),j[X]=J}}}i[C]={cues:j,dateRange:U,durationKnown:N}},M=0;M<c.length;M++)b(M)}}},g}();P.default=x},"./src/controller/latency-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return O});var R=n("./src/errors.ts"),p=n("./src/events.ts"),T=n("./src/utils/logger.ts");function I(_,E){for(var A=0;A<E.length;A++){var D=E[A];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(_,D.key,D)}}function S(_,E,A){return E&&I(_.prototype,E),A&&I(_,A),Object.defineProperty(_,"prototype",{writable:!1}),_}var O=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 E=_.prototype;return E.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},E.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)},E.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)},E.onMediaAttached=function(D,x){this.media=x.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},E.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},E.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},E.onLevelUpdated=function(D,x){var g=x.details;this.levelDetails=g,g.advanced&&this.timeupdate(),!g.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},E.onError=function(D,x){x.details===R.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,T.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},E.timeupdate=function(){var D=this.media,x=this.levelDetails;if(!(!D||!x)){this.currentTime=D.currentTime;var g=this.computeLatency();if(g!==null){this._latency=g;var y=this.config,s=y.lowLatencyMode,e=y.maxLiveSyncPlaybackRate;if(!(!s||e===1)){var o=this.targetLatency;if(o!==null){var f=g-o,a=Math.min(this.maxLatency,o+x.targetduration),i=f<a;if(x.live&&i&&f>.05&&this.forwardBufferLength>1){var t=Math.min(2,Math.max(1,e)),u=Math.round(2/(1+Math.exp(-.75*f-this.edgeStalled))*20)/20;D.playbackRate=Math.min(t,Math.max(1,u))}else D.playbackRate!==1&&D.playbackRate!==0&&(D.playbackRate=1)}}}}},E.estimateLiveEdge=function(){var D=this.levelDetails;return D===null?null:D.edge+D.age},E.computeLatency=function(){var D=this.estimateLiveEdge();return D===null?null:D-this.currentTime},S(_,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var D=this.config,x=this.levelDetails;return D.liveMaxLatencyDuration!==void 0?D.liveMaxLatencyDuration:x?D.liveMaxLatencyDurationCount*x.targetduration:0}},{key:"targetLatency",get:function(){var D=this.levelDetails;if(D===null)return null;var x=D.holdBack,g=D.partHoldBack,y=D.targetduration,s=this.config,e=s.liveSyncDuration,o=s.liveSyncDurationCount,f=s.lowLatencyMode,a=this.hls.userConfig,i=f&&g||x;(a.liveSyncDuration||a.liveSyncDurationCount||i===0)&&(i=e!==void 0?e:o*y);var t=y,u=1;return i+Math.min(this.stallCount*u,t)}},{key:"liveSyncPosition",get:function(){var D=this.estimateLiveEdge(),x=this.targetLatency,g=this.levelDetails;if(D===null||x===null||g===null)return null;var y=g.edge,s=D-x-this.edgeStalled,e=y-g.totalduration,o=y-(this.config.lowLatencyMode&&g.partTarget||g.targetduration);return Math.min(Math.max(e,s),o)}},{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 x=(this.config.lowLatencyMode&&D.partTarget||D.targetduration)*3;return Math.max(D.age-x,0)}},{key:"forwardBufferLength",get:function(){var D=this.media,x=this.levelDetails;if(!D||!x)return 0;var g=D.buffered.length;return(g?D.buffered.end(g-1):x.edge)-this.currentTime}}]),_}()},"./src/controller/level-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return s});var R=n("./src/types/level.ts"),p=n("./src/events.ts"),T=n("./src/errors.ts"),I=n("./src/utils/codecs.ts"),S=n("./src/controller/level-helper.ts"),O=n("./src/controller/base-playlist-controller.ts"),_=n("./src/types/loader.ts");function E(){return E=Object.assign?Object.assign.bind():function(e){for(var o=1;o<arguments.length;o++){var f=arguments[o];for(var a in f)Object.prototype.hasOwnProperty.call(f,a)&&(e[a]=f[a])}return e},E.apply(this,arguments)}function A(e,o){for(var f=0;f<o.length;f++){var a=o[f];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function D(e,o,f){return o&&A(e.prototype,o),f&&A(e,f),Object.defineProperty(e,"prototype",{writable:!1}),e}function x(e,o){e.prototype=Object.create(o.prototype),e.prototype.constructor=e,g(e,o)}function g(e,o){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,i){return a.__proto__=i,a},g(e,o)}var y=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),s=function(e){x(o,e);function o(a){var i;return i=e.call(this,a,"[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 f=o.prototype;return f._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)},f._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)},f.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,e.prototype.destroy.call(this)},f.startLoad=function(){var i=this._levels;i.forEach(function(t){t.loadError=0}),e.prototype.startLoad.call(this)},f.onManifestLoaded=function(i,t){var u=[],c=[],r=[],h,d={},l,v=!1,m=!1,L=!1;if(t.levels.forEach(function(w){var C=w.attrs;v=v||!!(w.width&&w.height),m=m||!!w.videoCodec,L=L||!!w.audioCodec,y&&w.audioCodec&&w.audioCodec.indexOf("mp4a.40.34")!==-1&&(w.audioCodec=void 0);var U=w.bitrate+"-"+w.attrs.RESOLUTION+"-"+w.attrs.CODECS;l=d[U],l?l.url.push(w.url):(l=new R.Level(w),d[U]=l,u.push(l)),C&&(C.AUDIO&&Object(S.addGroupId)(l,"audio",C.AUDIO),C.SUBTITLES&&Object(S.addGroupId)(l,"text",C.SUBTITLES))}),(v||m)&&L&&(u=u.filter(function(w){var C=w.videoCodec,U=w.width,k=w.height;return!!C||!!(U&&k)})),u=u.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&&(c=t.audioTracks.filter(function(w){return!w.audioCodec||Object(I.isCodecSupportedInMp4)(w.audioCodec,"audio")}),Object(S.assignTrackIdsByGroup)(c)),t.subtitles&&(r=t.subtitles,Object(S.assignTrackIdsByGroup)(r)),u.length>0){h=u[0].bitrate,u.sort(function(w,C){return w.bitrate-C.bitrate}),this._levels=u;for(var b=0;b<u.length;b++)if(u[b].bitrate===h){this._firstLevel=b,this.log("manifest loaded, "+u.length+" level(s) found, first bitrate: "+h);break}var M=L&&!m,F={levels:u,audioTracks:c,subtitleTracks:r,firstLevel:this._firstLevel,stats:t.stats,audio:L,video:m,altAudio:!M&&c.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:T.ErrorTypes.MEDIA_ERROR,details:T.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,reason:"no level with compatible codecs found in manifest"})},f.onError=function(i,t){var u;if(e.prototype.onError.call(this,i,t),!t.fatal){var c=t.context,r=this._levels[this.currentLevelIndex];if(c&&(c.type===_.PlaylistContextType.AUDIO_TRACK&&r.audioGroupIds&&c.groupId===r.audioGroupIds[r.urlId]||c.type===_.PlaylistContextType.SUBTITLE_TRACK&&r.textGroupIds&&c.groupId===r.textGroupIds[r.urlId])){this.redundantFailover(this.currentLevelIndex);return}var h=!1,d=!0,l;switch(t.details){case T.ErrorDetails.FRAG_LOAD_ERROR:case T.ErrorDetails.FRAG_LOAD_TIMEOUT:case T.ErrorDetails.KEY_LOAD_ERROR:case T.ErrorDetails.KEY_LOAD_TIMEOUT:if(t.frag){var v=t.frag.type===_.PlaylistLevelType.MAIN?t.frag.level:this.currentLevelIndex,m=this._levels[v];m?(m.fragmentError++,m.fragmentError>this.hls.config.fragLoadingMaxRetry&&(l=v)):l=v}break;case T.ErrorDetails.LEVEL_LOAD_ERROR:case T.ErrorDetails.LEVEL_LOAD_TIMEOUT:c&&(c.deliveryDirectives&&(d=!1),l=c.level),h=!0;break;case T.ErrorDetails.REMUX_ALLOC_ERROR:l=(u=t.level)!=null?u:this.currentLevelIndex,h=!0;break}l!==void 0&&this.recoverLevel(t,l,h,d)}},f.recoverLevel=function(i,t,u,c){var r=i.details,h=this._levels[t];if(h.loadError++,u){var d=this.retryLoadingOrFail(i);if(d)i.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(c){var l=h.url.length;if(l>1&&h.loadError<l)i.levelRetry=!0,this.redundantFailover(t);else if(this.manualLevelIndex===-1){for(var v=-1,m=this._levels,L=m.length;L--;){var b=(L+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)}}},f.redundantFailover=function(i){var t=this._levels[i],u=t.url.length;if(u>1){var c=(t.urlId+1)%u;this.warn("Switching to redundant URL-id "+c),this._levels.forEach(function(r){r.urlId=c}),this.level=i}},f.onFragLoaded=function(i,t){var u=t.frag;if(u!==void 0&&u.type===_.PlaylistLevelType.MAIN){var c=this._levels[u.level];c!==void 0&&(c.fragmentError=0,c.loadError=0)}},f.onLevelLoaded=function(i,t){var u,c=t.level,r=t.details,h=this._levels[c];if(!h){var d;this.warn("Invalid level index "+c),(d=t.deliveryDirectives)!==null&&d!==void 0&&d.skip&&(r.deltaUpdateFailed=!0);return}c===this.currentLevelIndex?(h.fragmentError===0&&(h.loadError=0,this.retryCount=0),this.playlistLoaded(c,t,h.details)):(u=t.deliveryDirectives)!==null&&u!==void 0&&u.skip&&(r.deltaUpdateFailed=!0)},f.onAudioTrackSwitched=function(i,t){var u=this.hls.levels[this.currentLevelIndex];if(!!u&&u.audioGroupIds){for(var c=-1,r=this.hls.audioTracks[t.id].groupId,h=0;h<u.audioGroupIds.length;h++)if(u.audioGroupIds[h]===r){c=h;break}c!==u.urlId&&(u.urlId=c,this.startLoad())}},f.loadPlaylist=function(i){var t=this.currentLevelIndex,u=this._levels[t];if(this.canLoad&&u&&u.url.length>0){var c=u.urlId,r=u.url[c];if(i)try{r=i.addDirectives(r)}catch(h){this.warn("Could not construct new URL with HLS Delivery Directives: "+h)}this.log("Attempt loading level index "+t+(i?" at sn "+i.msn+" part "+i.part:"")+" with URL-id "+c+" "+r),this.clearTimer(),this.hls.trigger(p.Events.LEVEL_LOADING,{url:r,level:t,id:c,deliveryDirectives:i||null})}},f.removeLevel=function(i,t){var u=function(h,d){return d!==t},c=this._levels.filter(function(r,h){return h!==i?!0:r.url.length>1&&t!==void 0?(r.url=r.url.filter(u),r.audioGroupIds&&(r.audioGroupIds=r.audioGroupIds.filter(u)),r.textGroupIds&&(r.textGroupIds=r.textGroupIds.filter(u)),r.urlId=0,!0):!1}).map(function(r,h){var d=r.details;return d!=null&&d.fragments&&d.fragments.forEach(function(l){l.level=h}),r});this._levels=c,this.hls.trigger(p.Events.LEVELS_UPDATED,{levels:c})},D(o,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(i){var t,u=this._levels;if(u.length!==0&&!(this.currentLevelIndex===i&&(t=u[i])!==null&&t!==void 0&&t.details)){if(i<0||i>=u.length){var c=i<0;if(this.hls.trigger(p.Events.ERROR,{type:T.ErrorTypes.OTHER_ERROR,details:T.ErrorDetails.LEVEL_SWITCH_ERROR,level:i,fatal:c,reason:"invalid level idx"}),c)return;i=Math.min(i,u.length-1)}this.clearTimer();var r=this.currentLevelIndex,h=u[r],d=u[i];this.log("switching to level "+i+" from "+r),this.currentLevelIndex=i;var l=E({},d,{level:i,maxBitrate:d.maxBitrate,uri:d.uri,urlId:d.urlId});delete l._urlId,this.hls.trigger(p.Events.LEVEL_SWITCHING,l);var v=d.details;if(!v||v.live){var m=this.switchParams(d.uri,h==null?void 0:h.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)}}]),o}(O.default)},"./src/controller/level-helper.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"addGroupId",function(){return S}),n.d(P,"assignTrackIdsByGroup",function(){return O}),n.d(P,"updatePTS",function(){return _}),n.d(P,"updateFragPTSDTS",function(){return A}),n.d(P,"mergeDetails",function(){return D}),n.d(P,"mapPartIntersection",function(){return g}),n.d(P,"mapFragmentIntersection",function(){return y}),n.d(P,"adjustSliding",function(){return s}),n.d(P,"addSliding",function(){return e}),n.d(P,"computeReloadInterval",function(){return o}),n.d(P,"getFragmentWithSN",function(){return f}),n.d(P,"getPartWith",function(){return a});var R=n("./src/polyfills/number.ts"),p=n("./src/utils/logger.ts"),T=n("./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 u=arguments[t];for(var c in u)Object.prototype.hasOwnProperty.call(u,c)&&(i[c]=u[c])}return i},I.apply(this,arguments)}function S(i,t,u){switch(t){case"audio":i.audioGroupIds||(i.audioGroupIds=[]),i.audioGroupIds.push(u);break;case"text":i.textGroupIds||(i.textGroupIds=[]),i.textGroupIds.push(u);break}}function O(i){var t={};i.forEach(function(u){var c=u.groupId||"";u.id=t[c]=t[c]||0,t[c]++})}function _(i,t,u){var c=i[t],r=i[u];E(c,r)}function E(i,t){var u=t.startPTS;if(Object(R.isFiniteNumber)(u)){var c=0,r;t.sn>i.sn?(c=u-i.start,r=i):(c=i.start-u,r=t),r.duration!==c&&(r.duration=c)}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 A(i,t,u,c,r,h){var d=c-u;d<=0&&(p.logger.warn("Fragment should have a positive duration",t),c=u+t.duration,h=r+t.duration);var l=u,v=c,m=t.startPTS,L=t.endPTS;if(Object(R.isFiniteNumber)(m)){var b=Math.abs(m-u);Object(R.isFiniteNumber)(t.deltaPTS)?t.deltaPTS=Math.max(b,t.deltaPTS):t.deltaPTS=b,l=Math.max(u,m),u=Math.min(u,m),r=Math.min(r,t.startDTS),v=Math.min(c,L),c=Math.max(c,L),h=Math.max(h,t.endDTS)}t.duration=c-u;var M=u-t.start;t.appendedPTS=c,t.start=t.startPTS=u,t.maxStartPTS=l,t.startDTS=r,t.endPTS=c,t.minEndPTS=v,t.endDTS=h;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--)E(U[w],U[w-1]);for(w=C;w<U.length-1;w++)E(U[w],U[w+1]);return i.fragmentHint&&E(U[U.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,M}function D(i,t){for(var u=null,c=i.fragments,r=c.length-1;r>=0;r--){var h=c[r].initSegment;if(h){u=h;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;var d=0,l;if(y(i,t,function(w,C){w.relurl&&(d=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&&(l=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,u=w.initSegment)}),u){var v=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments;v.forEach(function(w){var C;(!w.initSegment||w.initSegment.relurl===((C=u)===null||C===void 0?void 0:C.relurl))&&(w.initSegment=u)})}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=x(i.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));var L=t.fragments;if(d){p.logger.warn("discontinuity sliding from playlist, take drift into account");for(var b=0;b<L.length;b++)L[b].cc+=d}t.skippedSegments&&(t.startCC=t.fragments[0].cc),g(i.partList,t.partList,function(w,C){C.elementaryStreams=w.elementaryStreams,C.stats=w.stats}),l?A(t,l,l.startPTS,l.endPTS,l.startDTS,l.endDTS):s(i,t),L.length&&(t.totalduration=t.edge-L[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 x(i,t,u){var c=I({},i);return u&&u.forEach(function(r){delete c[r]}),Object.keys(t).forEach(function(r){var h=new T.DateRange(t[r].attr,c[r]);h.isValid?c[r]=h:p.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(t[r].attr)+'"')}),c}function g(i,t,u){if(i&&t)for(var c=0,r=0,h=i.length;r<=h;r++){var d=i[r],l=t[r+c];d&&l&&d.index===l.index&&d.fragment.sn===l.fragment.sn?u(d,l):c--}}function y(i,t,u){for(var c=t.skippedSegments,r=Math.max(i.startSN,t.startSN)-t.startSN,h=(i.fragmentHint?1:0)+(c?t.endSN:Math.min(i.endSN,t.endSN))-t.startSN,d=t.startSN-i.startSN,l=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,v=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,m=r;m<=h;m++){var L=v[d+m],b=l[m];c&&!b&&m<c&&(b=t.fragments[m]=L),L&&b&&u(L,b)}}function s(i,t){var u=t.startSN+t.skippedSegments-i.startSN,c=i.fragments;u<0||u>=c.length||e(t,c[u].start)}function e(i,t){if(t){for(var u=i.fragments,c=i.skippedSegments;c<u.length;c++)u[c].start+=t;i.fragmentHint&&(i.fragmentHint.start+=t)}}function o(i,t){var u=1e3*i.levelTargetDuration,c=u/2,r=i.age,h=r>0&&r<u*3,d=t.loading.end-t.loading.start,l,v=i.availabilityDelay;if(i.updated===!1)if(h){var m=333*i.misses;l=Math.max(Math.min(c,d*2),m),i.availabilityDelay=(i.availabilityDelay||0)+l}else l=c;else h?(v=Math.min(v||u/2,r),i.availabilityDelay=v,l=v+u-r):l=u-d;return Math.round(l)}function f(i,t,u){if(!i||!i.details)return null;var c=i.details,r=c.fragments[t-c.startSN];return r||(r=c.fragmentHint,r&&r.sn===t)?r:t<c.startSN&&u&&u.sn===t?u:null}function a(i,t,u){if(!i||!i.details)return null;var c=i.details.partList;if(c)for(var r=c.length;r--;){var h=c[r];if(h.index===u&&h.fragment.sn===t)return h}return null}},"./src/controller/stream-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return a});var R=n("./src/polyfills/number.ts"),p=n("./src/controller/base-stream-controller.ts"),T=n("./src/is-supported.ts"),I=n("./src/events.ts"),S=n("./src/utils/buffer-helper.ts"),O=n("./src/controller/fragment-tracker.ts"),_=n("./src/types/loader.ts"),E=n("./src/loader/fragment.ts"),A=n("./src/demux/transmuxer-interface.ts"),D=n("./src/types/transmuxer.ts"),x=n("./src/controller/gap-controller.ts"),g=n("./src/errors.ts");function y(i,t){for(var u=0;u<t.length;u++){var c=t[u];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(i,c.key,c)}}function s(i,t,u){return t&&y(i.prototype,t),u&&y(i,u),Object.defineProperty(i,"prototype",{writable:!1}),i}function e(i,t){i.prototype=Object.create(t.prototype),i.prototype.constructor=i,o(i,t)}function o(i,t){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(c,r){return c.__proto__=r,c},o(i,t)}var f=100,a=function(i){e(t,i);function t(c,r){var h;return h=i.call(this,c,r,"[stream-controller]")||this,h.audioCodecSwap=!1,h.gapController=null,h.level=-1,h._forceStartLoad=!1,h.altAudio=!1,h.audioOnly=!1,h.fragPlaying=null,h.onvplaying=null,h.onvseeked=null,h.fragLastKbps=0,h.couldBacktrack=!1,h.backtrackFragment=null,h.audioCodecSwitch=!1,h.videoBuffer=null,h._registerListeners(),h}var u=t.prototype;return u._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)},u._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)},u.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},u.startLoad=function(r){if(this.levels){var h=this.lastCurrentTime,d=this.hls;if(this.stopLoad(),this.setInterval(f),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var l=d.startLevel;l===-1&&(d.config.testBandwidth&&this.levels.length>1?(l=0,this.bitrateTest=!0):l=d.nextAutoLevel),this.level=d.nextLoadLevel=l,this.loadedmetadata=!1}h>0&&r===-1&&(this.log("Override startPosition with lastCurrentTime @"+h.toFixed(3)),r=h),this.state=p.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()}else this._forceStartLoad=!0,this.state=p.State.STOPPED},u.stopLoad=function(){this._forceStartLoad=!1,i.prototype.stopLoad.call(this)},u.doTick=function(){switch(this.state){case p.State.IDLE:this.doTickIdle();break;case p.State.WAITING_LEVEL:{var r,h=this.levels,d=this.level,l=h==null||(r=h[d])===null||r===void 0?void 0:r.details;if(l&&(!l.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(l))break;this.state=p.State.IDLE;break}break}case p.State.FRAG_LOADING_WAITING_RETRY:{var v,m=self.performance.now(),L=this.retryDate;(!L||m>=L||(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()},u.onTickEnd=function(){i.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},u.doTickIdle=function(){var r,h,d=this.hls,l=this.levelLastLoaded,v=this.levels,m=this.media,L=d.config,b=d.nextLoadLevel;if(!(l===null||!m&&(this.startFragRequested||!L.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!v||!v[b])){var M=v[b];this.level=d.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 k={};this.altAudio&&(k.type="video"),this.hls.trigger(I.Events.BUFFER_EOS,k),this.state=p.State.ENDED;return}this.backtrackFragment&&this.backtrackFragment.start>w.end&&(this.backtrackFragment=null);var j=this.backtrackFragment?this.backtrackFragment.start:w.end,N=this.getNextFragment(j,F);if(this.couldBacktrack&&!this.fragPrevious&&N&&N.sn!=="initSegment"&&this.fragmentTracker.getState(N)!==O.FragmentState.OK){var W,Y=((W=this.backtrackFragment)!=null?W:N).sn,K=Y-F.startSN,H=F.fragments[K-1];H&&N.cc===H.cc&&(N=H,this.fragmentTracker.removeFragment(H))}else this.backtrackFragment&&w.len&&(this.backtrackFragment=null);if(N&&this.fragmentTracker.getState(N)===O.FragmentState.OK&&this.nextLoadPosition>j){var z=this.audioOnly&&!this.altAudio?E.ElementaryStreamTypes.AUDIO:E.ElementaryStreamTypes.VIDEO;m&&this.afterBufferFlushed(m,z,_.PlaylistLevelType.MAIN),N=this.getNextFragment(this.nextLoadPosition,F)}!N||(N.initSegment&&!N.initSegment.data&&!this.bitrateTest&&(N=N.initSegment),((r=N.decryptdata)===null||r===void 0?void 0:r.keyFormat)==="identity"&&!((h=N.decryptdata)!==null&&h!==void 0&&h.key)?this.loadKey(N,F):this.loadFragment(N,F,j))}}}},u.loadFragment=function(r,h,d){var l,v=this.fragmentTracker.getState(r);this.fragCurrent=r,v===O.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,h,d)):v===O.FragmentState.APPENDING?this.reduceMaxBufferLength(r.duration)&&this.fragmentTracker.removeFragment(r):((l=this.media)===null||l===void 0?void 0:l.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},u.getAppendedFrag=function(r){var h=this.fragmentTracker.getAppendedFrag(r,_.PlaylistLevelType.MAIN);return h&&"fragment"in h?h.fragment:h},u.getBufferedFrag=function(r){return this.fragmentTracker.getBufferedFrag(r,_.PlaylistLevelType.MAIN)},u.followingBufferedFrag=function(r){return r?this.getBufferedFrag(r.end+.5):null},u.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},u.nextLevelSwitch=function(){var r=this.levels,h=this.media;if(h!=null&&h.readyState){var d,l=this.getAppendedFrag(h.currentTime);if(l&&l.start>1&&this.flushMainBuffer(0,l.start-1),!h.paused&&r){var v=this.hls.nextLoadLevel,m=r[v],L=this.fragLastKbps;L&&this.fragCurrent?d=this.fragCurrent.duration*m.maxBitrate/(1e3*L)+1:d=0}else d=0;var b=this.getBufferedFrag(h.currentTime+d);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)}}}},u.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()},u.flushMainBuffer=function(r,h){i.prototype.flushMainBuffer.call(this,r,h,this.altAudio?"video":null)},u.onMediaAttached=function(r,h){i.prototype.onMediaAttached.call(this,r,h);var d=h.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),d.addEventListener("playing",this.onvplaying),d.addEventListener("seeked",this.onvseeked),this.gapController=new x.default(this.config,d,this.fragmentTracker,this.hls)},u.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)},u.onMediaPlaying=function(){this.tick()},u.onMediaSeeked=function(){var r=this.media,h=r?r.currentTime:null;Object(R.isFiniteNumber)(h)&&this.log("Media seeked to "+h.toFixed(3)),this.tick()},u.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},u.onManifestParsed=function(r,h){var d=!1,l=!1,v;h.levels.forEach(function(m){v=m.audioCodec,v&&(v.indexOf("mp4a.40.2")!==-1&&(d=!0),v.indexOf("mp4a.40.5")!==-1&&(l=!0))}),this.audioCodecSwitch=d&&l&&!Object(T.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=h.levels,this.startFragRequested=!1},u.onLevelLoading=function(r,h){var d=this.levels;if(!(!d||this.state!==p.State.IDLE)){var l=d[h.level];(!l.details||l.details.live&&this.levelLastLoaded!==h.level||this.waitForCdnTuneIn(l.details))&&(this.state=p.State.WAITING_LEVEL)}},u.onLevelLoaded=function(r,h){var d,l=this.levels,v=h.level,m=h.details,L=m.totalduration;if(!l){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:"+L);var b=this.fragCurrent;b&&(this.state===p.State.FRAG_LOADING||this.state===p.State.FRAG_LOADING_WAITING_RETRY)&&b.level!==h.level&&b.loader&&(this.state=p.State.IDLE,this.backtrackFragment=null,b.loader.abort());var M=l[v],F=0;if(m.live||(d=M.details)!==null&&d!==void 0&&d.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()},u._handleFragmentLoadProgress=function(r){var h,d=r.frag,l=r.part,v=r.payload,m=this.levels;if(!m){this.warn("Levels were reset while fragment load was in progress. Fragment "+d.sn+" of level "+d.level+" will not be buffered");return}var L=m[d.level],b=L.details;if(!b){this.warn("Dropping fragment "+d.sn+" of level "+d.level+" after level details were reset");return}var M=L.videoCodec,F=b.PTSKnown||!b.live,w=(h=d.initSegment)===null||h===void 0?void 0:h.data,C=this._getAudioCodec(L),U=this.transmuxer=this.transmuxer||new A.default(this.hls,_.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),k=l?l.index:-1,j=k!==-1,N=new D.ChunkMetadata(d.level,d.sn,d.stats.chunkCount,v.byteLength,k,j),W=this.initPTS[d.cc];U.push(v,w,C,M,d,l,b.totalduration,F,N,W)},u.onAudioTrackSwitching=function(r,h){var d=this.altAudio,l=!!h.url,v=h.id;if(!l){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 L=this.hls;d&&L.trigger(I.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),L.trigger(I.Events.AUDIO_TRACK_SWITCHED,{id:v})}},u.onAudioTrackSwitched=function(r,h){var d=h.id,l=!!this.hls.audioTracks[d].url;if(l){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=l,this.tick()},u.onBufferCreated=function(r,h){var d=h.tracks,l,v,m=!1;for(var L in d){var b=d[L];if(b.id==="main"){if(v=L,l=b,L==="video"){var M=d[L];M&&(this.videoBuffer=M.buffer)}}else m=!0}m&&l?(this.log("Alternate track found, use "+v+".buffered to schedule main fragment loading"),this.mediaBuffer=l.buffer):this.mediaBuffer=this.media},u.onFragBuffered=function(r,h){var d=h.frag,l=h.part;if(!(d&&d.type!==_.PlaylistLevelType.MAIN)){if(this.fragContextChanged(d)){this.warn("Fragment "+d.sn+(l?" p: "+l.index:"")+" of level "+d.level+" finished buffering, but was aborted. state: "+this.state),this.state===p.State.PARSED&&(this.state=p.State.IDLE);return}var v=l?l.stats:d.stats;this.fragLastKbps=Math.round(8*v.total/(v.buffering.end-v.loading.first)),d.sn!=="initSegment"&&(this.fragPrevious=d),this.fragBufferedComplete(d,l)}},u.onError=function(r,h){switch(h.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(_.PlaylistLevelType.MAIN,h);break;case g.ErrorDetails.LEVEL_LOAD_ERROR:case g.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==p.State.ERROR&&(h.fatal?(this.warn(""+h.details),this.state=p.State.ERROR):!h.levelRetry&&this.state===p.State.WAITING_LEVEL&&(this.state=p.State.IDLE));break;case g.ErrorDetails.BUFFER_FULL_ERROR:if(h.parent==="main"&&(this.state===p.State.PARSING||this.state===p.State.PARSED)){var d=!0,l=this.getFwdBufferInfo(this.media,_.PlaylistLevelType.MAIN);l&&l.len>.5&&(d=!this.reduceMaxBufferLength(l.len)),d&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},u.checkBuffer=function(){var r=this.media,h=this.gapController;if(!(!r||!h||!r.readyState)){if(this.loadedmetadata||!S.BufferHelper.getBuffered(r).length){var d=this.state!==p.State.IDLE?this.fragCurrent:null;h.poll(this.lastCurrentTime,d)}this.lastCurrentTime=r.currentTime}},u.onFragLoadEmergencyAborted=function(){this.state=p.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},u.onBufferFlushed=function(r,h){var d=h.type;if(d!==E.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var l=(d===E.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(l,d,_.PlaylistLevelType.MAIN)}},u.onLevelsUpdated=function(r,h){this.levels=h.levels},u.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},u.seekToStartPos=function(){var r=this.media;if(!!r){var h=r.currentTime,d=this.startPosition;if(d>=0&&h<d){if(r.seeking){this.log("could not seek to "+d+", already seeking at "+h);return}var l=S.BufferHelper.getBuffered(r),v=l.length?l.start(0):0,m=v-d;m>0&&(m<this.config.maxBufferHole||m<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+m+" to match buffer start"),d+=m,this.startPosition=d),this.log("seek to target start position "+d+" from current time "+h),r.currentTime=d}}},u._getAudioCodec=function(r){var h=this.config.defaultAudioCodec||r.audioCodec;return this.audioCodecSwap&&h&&(this.log("Swapping audio codec"),h.indexOf("mp4a.40.5")!==-1?h="mp4a.40.2":h="mp4a.40.5"),h},u._loadBitrateTestFrag=function(r){var h=this;r.bitrateTest=!0,this._doFragLoad(r).then(function(d){var l=h.hls;if(!(!d||l.nextLoadLevel||h.fragContextChanged(r))){h.fragLoadError=0,h.state=p.State.IDLE,h.startFragRequested=!1,h.bitrateTest=!1;var v=r.stats;v.parsing.start=v.parsing.end=v.buffering.start=v.buffering.end=self.performance.now(),l.trigger(I.Events.FRAG_LOADED,d),r.bitrateTest=!1}})},u._handleTransmuxComplete=function(r){var h,d="main",l=this.hls,v=r.remuxResult,m=r.chunkMeta,L=this.getCurrentContext(m);if(!L){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=L.frag,M=L.part,F=L.level,w=v.video,C=v.text,U=v.id3,k=v.initSegment,j=F.details,N=this.altAudio?void 0:v.audio;if(!this.fragContextChanged(b)){if(this.state=p.State.PARSING,k){k.tracks&&(this._bufferInitSegment(F,k.tracks,b,m),l.trigger(I.Events.FRAG_PARSING_INIT_SEGMENT,{frag:b,id:d,tracks:k.tracks}));var W=k.initPTS,Y=k.timescale;Object(R.isFiniteNumber)(W)&&(this.initPTS[b.cc]=W,l.trigger(I.Events.INIT_PTS_FOUND,{frag:b,id:d,initPTS:W,timescale:Y}))}if(w&&v.independent!==!1){if(j){var K=w.startPTS,H=w.endPTS,z=w.startDTS,$=w.endDTS;if(M)M.elementaryStreams[w.type]={startPTS:K,endPTS:H,startDTS:z,endDTS:$};else if(w.firstKeyFrame&&w.independent&&(this.couldBacktrack=!0),w.dropped&&w.independent){var X=this.getMainFwdBufferInfo(),J=(X?X.end:this.getLoadPosition())+this.config.maxBufferHole,te=w.firstKeyFramePTS?w.firstKeyFramePTS:K;if(J<te-this.config.maxBufferHole){this.backtrack(b);return}b.setElementaryStreamInfo(w.type,b.start,H,b.start,$,!0)}b.setElementaryStreamInfo(w.type,K,H,z,$),this.backtrackFragment&&(this.backtrackFragment=b),this.bufferFragmentData(w,b,M,m)}}else if(v.independent===!1){this.backtrack(b);return}if(N){var Q=N.startPTS,ae=N.endPTS,se=N.startDTS,re=N.endDTS;M&&(M.elementaryStreams[E.ElementaryStreamTypes.AUDIO]={startPTS:Q,endPTS:ae,startDTS:se,endDTS:re}),b.setElementaryStreamInfo(E.ElementaryStreamTypes.AUDIO,Q,ae,se,re),this.bufferFragmentData(N,b,M,m)}if(j&&U!==null&&U!==void 0&&(h=U.samples)!==null&&h!==void 0&&h.length){var ee={id:d,frag:b,details:j,samples:U.samples};l.trigger(I.Events.FRAG_PARSING_METADATA,ee)}if(j&&C){var Z={id:d,frag:b,details:j,samples:C.samples};l.trigger(I.Events.FRAG_PARSING_USERDATA,Z)}}},u._bufferInitSegment=function(r,h,d,l){var v=this;if(this.state===p.State.PARSING){this.audioOnly=!!h.audio&&!h.video,this.altAudio&&!this.audioOnly&&delete h.audio;var m=h.audio,L=h.video,b=h.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+"]")}L&&(L.levelCodec=r.videoCodec,L.id="main",this.log("Init video buffer, container:"+L.container+", codecs[level/parsed]=["+(r.videoCodec||"")+"/"+L.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,h),Object.keys(h).forEach(function(w){var C=h[w],U=C.initSegment;U!=null&&U.byteLength&&v.hls.trigger(I.Events.BUFFER_APPENDING,{type:w,data:U,frag:d,part:null,chunkMeta:l,parent:d.type})}),this.tick()}},u.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,_.PlaylistLevelType.MAIN)},u.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},u.checkFragmentChanged=function(){var r=this.media,h=null;if(r&&r.readyState>1&&r.seeking===!1){var d=r.currentTime;if(S.BufferHelper.isBuffered(r,d)?h=this.getAppendedFrag(d):S.BufferHelper.isBuffered(r,d+.1)&&(h=this.getAppendedFrag(d+.1)),h){this.backtrackFragment=null;var l=this.fragPlaying,v=h.level;(!l||h.sn!==l.sn||l.level!==v||h.urlId!==l.urlId)&&(this.hls.trigger(I.Events.FRAG_CHANGED,{frag:h}),(!l||l.level!==v)&&this.hls.trigger(I.Events.LEVEL_SWITCHED,{level:v}),this.fragPlaying=h)}}},s(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 h=r.currentTime,d=this.currentFrag;if(d&&Object(R.isFiniteNumber)(h)&&Object(R.isFiniteNumber)(d.programDateTime)){var l=d.programDateTime+(h-d.start)*1e3;return new Date(l)}}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(B,P,n){"use strict";n.r(P),n.d(P,"SubtitleStreamController",function(){return e});var R=n("./src/events.ts"),p=n("./src/utils/buffer-helper.ts"),T=n("./src/controller/fragment-finders.ts"),I=n("./src/utils/discontinuities.ts"),S=n("./src/controller/level-helper.ts"),O=n("./src/controller/fragment-tracker.ts"),_=n("./src/controller/base-stream-controller.ts"),E=n("./src/types/loader.ts"),A=n("./src/types/level.ts");function D(f,a){for(var i=0;i<a.length;i++){var t=a[i];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(f,t.key,t)}}function x(f,a,i){return a&&D(f.prototype,a),i&&D(f,i),Object.defineProperty(f,"prototype",{writable:!1}),f}function g(f,a){f.prototype=Object.create(a.prototype),f.prototype.constructor=f,y(f,a)}function y(f,a){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,u){return t.__proto__=u,t},y(f,a)}var s=500,e=function(f){g(a,f);function a(t,u){var c;return c=f.call(this,t,u,"[subtitle-stream-controller]")||this,c.levels=[],c.currentTrackId=-1,c.tracksBuffered=[],c.mainDetails=null,c._registerListeners(),c}var i=a.prototype;return i.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},i._registerListeners=function(){var u=this.hls;u.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),u.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),u.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.on(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.on(R.Events.ERROR,this.onError,this),u.on(R.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),u.on(R.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),u.on(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),u.on(R.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),u.on(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i._unregisterListeners=function(){var u=this.hls;u.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),u.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),u.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.off(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.off(R.Events.ERROR,this.onError,this),u.off(R.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),u.off(R.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),u.off(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),u.off(R.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),u.off(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i.startLoad=function(){this.stopLoad(),this.state=_.State.IDLE,this.setInterval(s),this.tick()},i.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},i.onLevelLoaded=function(u,c){this.mainDetails=c.details},i.onSubtitleFragProcessed=function(u,c){var r=c.frag,h=c.success;if(this.fragPrevious=r,this.state=_.State.IDLE,!!h){var d=this.tracksBuffered[this.currentTrackId];if(!!d){for(var l,v=r.start,m=0;m<d.length;m++)if(v>=d[m].start&&v<=d[m].end){l=d[m];break}var L=r.start+r.duration;l?l.end=L:(l={start:v,end:L},d.push(l)),this.fragmentTracker.fragBuffered(r)}}},i.onBufferFlushing=function(u,c){var r=c.startOffset,h=c.endOffset;if(r===0&&h!==Number.POSITIVE_INFINITY){var d=this.currentTrackId,l=this.levels;if(!l.length||!l[d]||!l[d].details)return;var v=l[d].details,m=v.targetduration,L=h-m;if(L<=0)return;c.endOffsetSubtitles=Math.max(0,L),this.tracksBuffered.forEach(function(b){for(var M=0;M<b.length;){if(b[M].end<=L){b.shift();continue}else if(b[M].start<L)b[M].start=L;else break;M++}}),this.fragmentTracker.removeFragmentsInRange(r,L,E.PlaylistLevelType.SUBTITLE)}},i.onError=function(u,c){var r,h=c.frag;!h||h.type!==E.PlaylistLevelType.SUBTITLE||((r=this.fragCurrent)!==null&&r!==void 0&&r.loader&&this.fragCurrent.loader.abort(),this.state=_.State.IDLE)},i.onSubtitleTracksUpdated=function(u,c){var r=this,h=c.subtitleTracks;this.tracksBuffered=[],this.levels=h.map(function(d){return new A.Level(d)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(d){r.tracksBuffered[d.id]=[]}),this.mediaBuffer=null},i.onSubtitleTrackSwitch=function(u,c){if(this.currentTrackId=c.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(s)},i.onSubtitleTrackLoaded=function(u,c){var r,h=c.details,d=c.id,l=this.currentTrackId,v=this.levels;if(!!v.length){var m=v[l];if(!(d>=v.length||d!==l||!m)){if(this.mediaBuffer=this.mediaBufferTimeRanges,h.live||(r=m.details)!==null&&r!==void 0&&r.live){var L=this.mainDetails;if(h.deltaUpdateFailed||!L)return;var b=L.fragments[0];if(!m.details)h.hasProgramDateTime&&L.hasProgramDateTime?Object(I.alignMediaPlaylistByPDT)(h,L):b&&Object(S.addSliding)(h,b.start);else{var M=this.alignPlaylists(h,m.details);M===0&&b&&Object(S.addSliding)(h,b.start)}}if(m.details=h,this.levelLastLoaded=d,this.tick(),h.live&&!this.fragCurrent&&this.media&&this.state===_.State.IDLE){var F=Object(T.findFragmentByPTS)(null,h.fragments,this.media.currentTime,0);F||(this.warn("Subtitle playlist not aligned with playback"),m.details=void 0)}}}},i._handleFragmentLoadComplete=function(u){var c=u.frag,r=u.payload,h=c.decryptdata,d=this.hls;if(!this.fragContextChanged(c)&&r&&r.byteLength>0&&h&&h.key&&h.iv&&h.method==="AES-128"){var l=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(r),h.key.buffer,h.iv.buffer).then(function(v){var m=performance.now();d.trigger(R.Events.FRAG_DECRYPTED,{frag:c,payload:v,stats:{tstart:l,tdecrypt:m}})})}},i.doTick=function(){if(!this.media){this.state=_.State.IDLE;return}if(this.state===_.State.IDLE){var u=this.currentTrackId,c=this.levels;if(!c.length||!c[u]||!c[u].details)return;var r=c[u].details,h=r.targetduration,d=this.config,l=this.media,v=p.BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],l.currentTime-h,d.maxBufferHole),m=v.end,L=v.len,b=this.getMaxBufferLength()+h;if(L>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 k=d.maxFragLookUpTolerance;C=Object(T.findFragmentByPTS)(U,M,Math.max(M[0].start,m),k),!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)!==O.FragmentState.NOT_LOADED)return;C.encrypted?this.loadKey(C,r):this.loadFragment(C,r,m)}},i.loadFragment=function(u,c,r){this.fragCurrent=u,u.sn==="initSegment"?this._loadInitSegment(u):f.prototype.loadFragment.call(this,u,c,r)},x(a,[{key:"mediaBufferTimeRanges",get:function(){return new o(this.tracksBuffered[this.currentTrackId]||[])}}]),a}(_.default),o=function(a){this.buffered=void 0;var i=function(u,c,r){if(c=c>>>0,c>r-1)throw new DOMException("Failed to execute '"+u+"' on 'TimeRanges': The index provided ("+c+") is greater than the maximum bound ("+r+")");return a[c][u]};this.buffered={get length(){return a.length},end:function(u){return i("end",u,a.length)},start:function(u){return i("start",u,a.length)}}}},"./src/controller/subtitle-track-controller.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/events.ts"),p=n("./src/utils/texttrack-utils.ts"),T=n("./src/controller/base-playlist-controller.ts"),I=n("./src/types/loader.ts");function S(x,g){for(var y=0;y<g.length;y++){var s=g[y];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(x,s.key,s)}}function O(x,g,y){return g&&S(x.prototype,g),y&&S(x,y),Object.defineProperty(x,"prototype",{writable:!1}),x}function _(x,g){x.prototype=Object.create(g.prototype),x.prototype.constructor=x,E(x,g)}function E(x,g){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,e){return s.__proto__=e,s},E(x,g)}var A=function(x){_(g,x);function g(s){var e;return e=x.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 y=g.prototype;return y.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,x.prototype.destroy.call(this)},y.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)},y.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)},y.onMediaAttached=function(e,o){this.media=o.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))},y.pollTrackChange=function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)},y.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(o){Object(p.clearCurrentCues)(o)}),this.subtitleTrack=-1,this.media=null}},y.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},y.onManifestParsed=function(e,o){this.tracks=o.subtitleTracks},y.onSubtitleTrackLoaded=function(e,o){var f=o.id,a=o.details,i=this.trackId,t=this.tracksInGroup[i];if(!t){this.warn("Invalid subtitle track id "+f);return}var u=t.details;t.details=o.details,this.log("subtitle track "+f+" loaded ["+a.startSN+"-"+a.endSN+"]"),f===this.trackId&&(this.retryCount=0,this.playlistLoaded(f,o,u))},y.onLevelLoading=function(e,o){this.switchLevel(o.level)},y.onLevelSwitching=function(e,o){this.switchLevel(o.level)},y.switchLevel=function(e){var o=this.hls.levels[e];if(!!(o!=null&&o.textGroupIds)){var f=o.textGroupIds[o.urlId];if(this.groupId!==f){var a=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,i=this.tracks.filter(function(c){return!f||c.groupId===f});this.tracksInGroup=i;var t=this.findTrackId(a==null?void 0:a.name)||this.findTrackId();this.groupId=f;var u={subtitleTracks:i};this.log("Updating subtitle tracks, "+i.length+' track(s) found in "'+f+'" group-id'),this.hls.trigger(R.Events.SUBTITLE_TRACKS_UPDATED,u),t!==-1&&this.setSubtitleTrack(t,a)}}},y.findTrackId=function(e){for(var o=this.tracksInGroup,f=0;f<o.length;f++){var a=o[f];if((!this.selectDefaultTrack||a.default)&&(!e||e===a.name))return a.id}return-1},y.onError=function(e,o){x.prototype.onError.call(this,e,o),!(o.fatal||!o.context)&&o.context.type===I.PlaylistContextType.SUBTITLE_TRACK&&o.context.id===this.trackId&&o.context.groupId===this.groupId&&this.retryLoadingOrFail(o)},y.loadPlaylist=function(e){var o=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(o)){var f=o.id,a=o.groupId,i=o.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 "+f),this.hls.trigger(R.Events.SUBTITLE_TRACK_LOADING,{url:i,id:f,groupId:a,deliveryDirectives:e||null})}},y.toggleTrackModes=function(e){var o=this,f=this.media,a=this.trackId;if(!!f){var i=D(f.textTracks),t=i.filter(function(r){return r.groupId===o.groupId});if(e===-1)[].slice.call(i).forEach(function(r){r.mode="disabled"});else{var u=t[a];u&&(u.mode="disabled")}var c=t[e];c&&(c.mode=this.subtitleDisplay?"showing":"hidden")}},y.setSubtitleTrack=function(e,o){var f,a=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),!(this.trackId===e&&(e===-1||(f=a[e])!==null&&f!==void 0&&f.details)||e<-1||e>=a.length)){this.clearTimer();var i=a[e];if(this.log("Switching to subtitle track "+e),this.trackId=e,i){var t=i.id,u=i.groupId,c=u===void 0?"":u,r=i.name,h=i.type,d=i.url;this.hls.trigger(R.Events.SUBTITLE_TRACK_SWITCH,{id:t,groupId:c,name:r,type:h,url:d});var l=this.switchParams(i.url,o==null?void 0:o.details);this.loadPlaylist(l)}else this.hls.trigger(R.Events.SUBTITLE_TRACK_SWITCH,{id:e})}},y.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!(!this.media||!this.hls.config.renderTextTracksNatively)){for(var e=-1,o=D(this.media.textTracks),f=0;f<o.length;f++)if(o[f].mode==="hidden")e=f;else if(o[f].mode==="showing"){e=f;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}},O(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 o=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,o)}}]),g}(T.default);function D(x){for(var g=[],y=0;y<x.length;y++){var s=x[y];s.kind==="subtitles"&&s.label&&g.push(x[y])}return g}P.default=A},"./src/controller/timeline-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"TimelineController",function(){return x});var R=n("./src/polyfills/number.ts"),p=n("./src/events.ts"),T=n("./src/utils/cea-608-parser.ts"),I=n("./src/utils/output-filter.ts"),S=n("./src/utils/webvtt-parser.ts"),O=n("./src/utils/texttrack-utils.ts"),_=n("./src/utils/imsc1-ttml-parser.ts"),E=n("./src/utils/mp4-tools.ts"),A=n("./src/types/loader.ts"),D=n("./src/utils/logger.ts"),x=function(){function e(f){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=s(),this.captionsProperties=void 0,this.hls=f,this.config=f.config,this.Cues=f.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 a=new I.default(this,"textTrack1"),i=new I.default(this,"textTrack2"),t=new I.default(this,"textTrack3"),u=new I.default(this,"textTrack4");this.cea608Parser1=new T.default(1,a,i),this.cea608Parser2=new T.default(3,t,u)}f.on(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),f.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),f.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),f.on(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),f.on(p.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),f.on(p.Events.FRAG_LOADING,this.onFragLoading,this),f.on(p.Events.FRAG_LOADED,this.onFragLoaded,this),f.on(p.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),f.on(p.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),f.on(p.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),f.on(p.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),f.on(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var o=e.prototype;return o.destroy=function(){var a=this.hls;a.off(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),a.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.off(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),a.off(p.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),a.off(p.Events.FRAG_LOADING,this.onFragLoading,this),a.off(p.Events.FRAG_LOADED,this.onFragLoaded,this),a.off(p.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),a.off(p.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),a.off(p.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),a.off(p.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),a.off(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},o.addCues=function(a,i,t,u,c){for(var r=!1,h=c.length;h--;){var d=c[h],l=y(d[0],d[1],i,t);if(l>=0&&(d[0]=Math.min(d[0],i),d[1]=Math.max(d[1],t),r=!0,l/(t-i)>.5))return}if(r||c.push([i,t]),this.config.renderTextTracksNatively){var v=this.captionsTracks[a];this.Cues.newCue(v,i,t,u)}else{var m=this.Cues.newCue(null,i,t,u);this.hls.trigger(p.Events.CUES_PARSED,{type:"captions",cues:m,track:a})}},o.onInitPtsFound=function(a,i){var t=this,u=i.frag,c=i.id,r=i.initPTS,h=i.timescale,d=this.unparsedVttFrags;c==="main"&&(this.initPTS[u.cc]=r,this.timescale[u.cc]=h),d.length&&(this.unparsedVttFrags=[],d.forEach(function(l){t.onFragLoaded(p.Events.FRAG_LOADED,l)}))},o.getExistingTrack=function(a){var i=this.media;if(i)for(var t=0;t<i.textTracks.length;t++){var u=i.textTracks[t];if(u[a])return u}return null},o.createCaptionsTrack=function(a){this.config.renderTextTracksNatively?this.createNativeTrack(a):this.createNonNativeTrack(a)},o.createNativeTrack=function(a){if(!this.captionsTracks[a]){var i=this.captionsProperties,t=this.captionsTracks,u=this.media,c=i[a],r=c.label,h=c.languageCode,d=this.getExistingTrack(a);if(d)t[a]=d,Object(O.clearCurrentCues)(t[a]),Object(O.sendAddTrackEvent)(t[a],u);else{var l=this.createTextTrack("captions",r,h);l&&(l[a]=!0,t[a]=l)}}},o.createNonNativeTrack=function(a){if(!this.nonNativeCaptionsTracks[a]){var i=this.captionsProperties[a];if(!!i){var t=i.label,u={_id:a,label:t,kind:"captions",default:i.media?!!i.media.default:!1,closedCaptions:i.media};this.nonNativeCaptionsTracks[a]=u,this.hls.trigger(p.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[u]})}}},o.createTextTrack=function(a,i,t){var u=this.media;if(!!u)return u.addTextTrack(a,i,t)},o.onMediaAttaching=function(a,i){this.media=i.media,this._cleanTracks()},o.onMediaDetaching=function(){var a=this.captionsTracks;Object.keys(a).forEach(function(i){Object(O.clearCurrentCues)(a[i]),delete a[i]}),this.nonNativeCaptionsTracks={}},o.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=s(),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())},o._cleanTracks=function(){var a=this.media;if(!!a){var i=a.textTracks;if(i)for(var t=0;t<i.length;t++)Object(O.clearCurrentCues)(i[t])}},o.onSubtitleTracksUpdated=function(a,i){var t=this;this.textTracks=[];var u=i.subtitleTracks||[],c=u.some(function(l){return l.textCodec===_.IMSC1_CODEC});if(this.config.enableWebVTT||c&&this.config.enableIMSC1){var r=this.tracks&&u&&this.tracks.length===u.length;if(this.tracks=u||[],this.config.renderTextTracksNatively){var h=this.media?this.media.textTracks:[];this.tracks.forEach(function(l,v){var m;if(v<h.length){for(var L=null,b=0;b<h.length;b++)if(g(h[b],l)){L=h[b];break}L&&(m=L)}if(m)Object(O.clearCurrentCues)(m);else{var M=t._captionsOrSubtitlesFromCharacteristics(l);m=t.createTextTrack(M,l.name,l.lang),m&&(m.mode="disabled")}m&&(m.groupId=l.groupId,t.textTracks.push(m))})}else if(!r&&this.tracks&&this.tracks.length){var d=this.tracks.map(function(l){return{label:l.name,kind:l.type.toLowerCase(),default:l.default,subtitleTrack:l}});this.hls.trigger(p.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:d})}}},o._captionsOrSubtitlesFromCharacteristics=function(a){var i;if((i=a.attrs)!==null&&i!==void 0&&i.CHARACTERISTICS){var t=/transcribes-spoken-dialog/gi.test(a.attrs.CHARACTERISTICS),u=/describes-music-and-sound/gi.test(a.attrs.CHARACTERISTICS);if(t&&u)return"captions"}return"subtitles"},o.onManifestLoaded=function(a,i){var t=this;this.config.enableCEA708Captions&&i.captions&&i.captions.forEach(function(u){var c=/(?:CC|SERVICE)([1-4])/.exec(u.instreamId);if(!!c){var r="textTrack"+c[1],h=t.captionsProperties[r];!h||(h.label=u.name,u.lang&&(h.languageCode=u.lang),h.media=u)}})},o.onFragLoading=function(a,i){var t=this.cea608Parser1,u=this.cea608Parser2,c=this.lastSn,r=this.lastPartIndex;if(!(!this.enabled||!(t&&u))&&i.frag.type===A.PlaylistLevelType.MAIN){var h,d,l=i.frag.sn,v=(h=i==null||(d=i.part)===null||d===void 0?void 0:d.index)!=null?h:-1;l===c+1||l===c&&v===r+1||(t.reset(),u.reset()),this.lastSn=l,this.lastPartIndex=v}},o.onFragLoaded=function(a,i){var t=i.frag,u=i.payload,c=this.initPTS,r=this.unparsedVttFrags;if(t.type===A.PlaylistLevelType.SUBTITLE)if(u.byteLength){if(!Object(R.isFiniteNumber)(c[t.cc])){r.push(i),c.length&&this.hls.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:new Error("Missing initial subtitle PTS")});return}var h=t.decryptdata,d="stats"in i;if(h==null||h.key==null||h.method!=="AES-128"||d){var l=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),l&&l.textCodec===_.IMSC1_CODEC?this._parseIMSC1(t,u):this._parseVTTs(t,u,v)}}else this.hls.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:new Error("Empty subtitle payload")})},o._parseIMSC1=function(a,i){var t=this,u=this.hls;Object(_.parseIMSC1)(i,this.initPTS[a.cc],this.timescale[a.cc],function(c){t._appendCues(c,a.level),u.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:a})},function(c){D.logger.log("Failed to parse IMSC1: "+c),u.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:a,error:c})})},o._parseVTTs=function(a,i,t){var u,c=this,r=this.hls,h=(u=a.initSegment)!==null&&u!==void 0&&u.data?Object(E.appendUint8Array)(a.initSegment.data,new Uint8Array(i)):i;Object(S.parseWebVTT)(h,this.initPTS[a.cc],this.timescale[a.cc],t,a.cc,a.start,function(d){c._appendCues(d,a.level),r.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:a})},function(d){c._fallbackToIMSC1(a,i),D.logger.log("Failed to parse VTT cue: "+d),r.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:a,error:d})})},o._fallbackToIMSC1=function(a,i){var t=this,u=this.tracks[a.level];u.textCodec||Object(_.parseIMSC1)(i,this.initPTS[a.cc],this.timescale[a.cc],function(){u.textCodec=_.IMSC1_CODEC,t._parseIMSC1(a,i)},function(){u.textCodec="wvtt"})},o._appendCues=function(a,i){var t=this.hls;if(this.config.renderTextTracksNatively){var u=this.textTracks[i];if(!u||u.mode==="disabled")return;a.forEach(function(h){return Object(O.addCueToTrack)(u,h)})}else{var c=this.tracks[i];if(!c)return;var r=c.default?"default":"subtitles"+i;t.trigger(p.Events.CUES_PARSED,{type:"subtitles",cues:a,track:r})}},o.onFragDecrypted=function(a,i){var t=i.frag;if(t.type===A.PlaylistLevelType.SUBTITLE){if(!Object(R.isFiniteNumber)(this.initPTS[t.cc])){this.unparsedVttFrags.push(i);return}this.onFragLoaded(p.Events.FRAG_LOADED,i)}},o.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},o.onFragParsingUserdata=function(a,i){var t=this.cea608Parser1,u=this.cea608Parser2;if(!(!this.enabled||!(t&&u)))for(var c=0;c<i.samples.length;c++){var r=i.samples[c].bytes;if(r){var h=this.extractCea608Data(r);t.addData(i.samples[c].pts,h[0]),u.addData(i.samples[c].pts,h[1])}}},o.onBufferFlushing=function(a,i){var t=i.startOffset,u=i.endOffset,c=i.endOffsetSubtitles,r=i.type,h=this.media;if(!(!h||h.currentTime<u)){if(!r||r==="video"){var d=this.captionsTracks;Object.keys(d).forEach(function(v){return Object(O.removeCuesInRange)(d[v],t,u)})}if(this.config.renderTextTracksNatively&&t===0&&c!==void 0){var l=this.textTracks;Object.keys(l).forEach(function(v){return Object(O.removeCuesInRange)(l[v],t,c)})}}},o.extractCea608Data=function(a){for(var i=[[],[]],t=a[0]&31,u=2,c=0;c<t;c++){var r=a[u++],h=127&a[u++],d=127&a[u++];if(!(h===0&&d===0)){var l=(4&r)!==0;if(l){var v=3&r;(v===0||v===1)&&(i[v].push(h),i[v].push(d))}}}return i},e}();function g(e,o){return e&&e.label===o.name&&!(e.textTrack1||e.textTrack2)}function y(e,o,f,a){return Math.min(o,a)-Math.max(e,f)}function s(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}},"./src/crypt/aes-crypto.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return R});var R=function(){function p(I,S){this.subtle=void 0,this.aesIV=void 0,this.subtle=I,this.aesIV=S}var T=p.prototype;return T.decrypt=function(S,O){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},O,S)},p}()},"./src/crypt/aes-decryptor.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"removePadding",function(){return p}),n.d(P,"default",function(){return T});var R=n("./src/utils/typed-array.ts");function p(I){var S=I.byteLength,O=S&&new DataView(I.buffer).getUint8(S-1);return O?Object(R.sliceUint8)(I,0,S-O):I}var T=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 S=I.prototype;return S.uint8ArrayToUint32Array_=function(_){for(var E=new DataView(_),A=new Uint32Array(4),D=0;D<4;D++)A[D]=E.getUint32(D*4);return A},S.initTable=function(){var _=this.sBox,E=this.invSBox,A=this.subMix,D=A[0],x=A[1],g=A[2],y=A[3],s=this.invSubMix,e=s[0],o=s[1],f=s[2],a=s[3],i=new Uint32Array(256),t=0,u=0,c=0;for(c=0;c<256;c++)c<128?i[c]=c<<1:i[c]=c<<1^283;for(c=0;c<256;c++){var r=u^u<<1^u<<2^u<<3^u<<4;r=r>>>8^r&255^99,_[t]=r,E[r]=t;var h=i[t],d=i[h],l=i[d],v=i[r]*257^r*16843008;D[t]=v<<24|v>>>8,x[t]=v<<16|v>>>16,g[t]=v<<8|v>>>24,y[t]=v,v=l*16843009^d*65537^h*257^t*16843008,e[r]=v<<24|v>>>8,o[r]=v<<16|v>>>16,f[r]=v<<8|v>>>24,a[r]=v,t?(t=h^i[i[i[l^h]]],u^=i[i[u]]):t=u=1}},S.expandKey=function(_){for(var E=this.uint8ArrayToUint32Array_(_),A=!0,D=0;D<E.length&&A;)A=E[D]===this.key[D],D++;if(!A){this.key=E;var x=this.keySize=E.length;if(x!==4&&x!==6&&x!==8)throw new Error("Invalid aes key size="+x);var g=this.ksRows=(x+6+1)*4,y,s,e=this.keySchedule=new Uint32Array(g),o=this.invKeySchedule=new Uint32Array(g),f=this.sBox,a=this.rcon,i=this.invSubMix,t=i[0],u=i[1],c=i[2],r=i[3],h,d;for(y=0;y<g;y++){if(y<x){h=e[y]=E[y];continue}d=h,y%x===0?(d=d<<8|d>>>24,d=f[d>>>24]<<24|f[d>>>16&255]<<16|f[d>>>8&255]<<8|f[d&255],d^=a[y/x|0]<<24):x>6&&y%x===4&&(d=f[d>>>24]<<24|f[d>>>16&255]<<16|f[d>>>8&255]<<8|f[d&255]),e[y]=h=(e[y-x]^d)>>>0}for(s=0;s<g;s++)y=g-s,s&3?d=e[y]:d=e[y-4],s<4||y<=4?o[s]=d:o[s]=t[f[d>>>24]]^u[f[d>>>16&255]]^c[f[d>>>8&255]]^r[f[d&255]],o[s]=o[s]>>>0}},S.networkToHostOrderSwap=function(_){return _<<24|(_&65280)<<8|(_&16711680)>>8|_>>>24},S.decrypt=function(_,E,A){for(var D=this.keySize+6,x=this.invKeySchedule,g=this.invSBox,y=this.invSubMix,s=y[0],e=y[1],o=y[2],f=y[3],a=this.uint8ArrayToUint32Array_(A),i=a[0],t=a[1],u=a[2],c=a[3],r=new Int32Array(_),h=new Int32Array(r.length),d,l,v,m,L,b,M,F,w,C,U,k,j,N,W=this.networkToHostOrderSwap;E<r.length;){for(w=W(r[E]),C=W(r[E+1]),U=W(r[E+2]),k=W(r[E+3]),L=w^x[0],b=k^x[1],M=U^x[2],F=C^x[3],j=4,N=1;N<D;N++)d=s[L>>>24]^e[b>>16&255]^o[M>>8&255]^f[F&255]^x[j],l=s[b>>>24]^e[M>>16&255]^o[F>>8&255]^f[L&255]^x[j+1],v=s[M>>>24]^e[F>>16&255]^o[L>>8&255]^f[b&255]^x[j+2],m=s[F>>>24]^e[L>>16&255]^o[b>>8&255]^f[M&255]^x[j+3],L=d,b=l,M=v,F=m,j=j+4;d=g[L>>>24]<<24^g[b>>16&255]<<16^g[M>>8&255]<<8^g[F&255]^x[j],l=g[b>>>24]<<24^g[M>>16&255]<<16^g[F>>8&255]<<8^g[L&255]^x[j+1],v=g[M>>>24]<<24^g[F>>16&255]<<16^g[L>>8&255]<<8^g[b&255]^x[j+2],m=g[F>>>24]<<24^g[L>>16&255]<<16^g[b>>8&255]<<8^g[M&255]^x[j+3],h[E]=W(d^i),h[E+1]=W(m^t),h[E+2]=W(v^u),h[E+3]=W(l^c),i=w,t=C,u=U,c=k,E=E+4}return h.buffer},I}()},"./src/crypt/decrypter.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return E});var R=n("./src/crypt/aes-crypto.ts"),p=n("./src/crypt/fast-aes-key.ts"),T=n("./src/crypt/aes-decryptor.ts"),I=n("./src/utils/logger.ts"),S=n("./src/utils/mp4-tools.ts"),O=n("./src/utils/typed-array.ts"),_=16,E=function(){function A(x,g,y){var s=y===void 0?{}:y,e=s.removePKCS7Padding,o=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=x,this.config=g,this.removePKCS7Padding=o,o)try{var f=self.crypto;f&&(this.subtle=f.subtle||f.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 g=this.currentResult;if(!g){this.reset();return}var y=new Uint8Array(g);return this.reset(),this.removePKCS7Padding?Object(T.removePadding)(y):y},D.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},D.decrypt=function(g,y,s,e){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(g),y,s);var o=this.flush();o&&e(o.buffer)}else this.webCryptoDecrypt(new Uint8Array(g),y,s).then(e)},D.softwareDecrypt=function(g,y,s){var e=this.currentIV,o=this.currentResult,f=this.remainderData;this.logOnce("JS AES decrypt"),f&&(g=Object(S.appendUint8Array)(f,g),this.remainderData=null);var a=this.getValidChunk(g);if(!a.length)return null;e&&(s=e);var i=this.softwareDecrypter;i||(i=this.softwareDecrypter=new T.default),i.expandKey(y);var t=o;return this.currentResult=i.decrypt(a.buffer,0,s),this.currentIV=Object(O.sliceUint8)(a,-16).buffer,t||null},D.webCryptoDecrypt=function(g,y,s){var e=this,o=this.subtle;return(this.key!==y||!this.fastAesKey)&&(this.key=y,this.fastAesKey=new p.default(o,y)),this.fastAesKey.expandKey().then(function(f){if(!o)return Promise.reject(new Error("web crypto not initialized"));var a=new R.default(o,s);return a.decrypt(g.buffer,f)}).catch(function(f){return e.onWebCryptoError(f,g,y,s)})},D.onWebCryptoError=function(g,y,s,e){return I.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",g),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(y,s,e)},D.getValidChunk=function(g){var y=g,s=g.length-g.length%_;return s!==g.length&&(y=Object(O.sliceUint8)(g,0,s),this.remainderData=Object(O.sliceUint8)(g,s)),y},D.logOnce=function(g){!this.logEnabled||(I.logger.log("[decrypter.ts]: "+g),this.logEnabled=!1)},A}()},"./src/crypt/fast-aes-key.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return R});var R=function(){function p(I,S){this.subtle=void 0,this.key=void 0,this.subtle=I,this.key=S}var T=p.prototype;return T.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},p}()},"./src/demux/aacdemuxer.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/demux/base-audio-demuxer.ts"),p=n("./src/demux/adts.ts"),T=n("./src/utils/logger.ts"),I=n("./src/demux/id3.ts");function S(E,A){E.prototype=Object.create(A.prototype),E.prototype.constructor=E,O(E,A)}function O(E,A){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(x,g){return x.__proto__=g,x},O(E,A)}var _=function(E){S(A,E);function A(x,g){var y;return y=E.call(this)||this,y.observer=void 0,y.config=void 0,y.observer=x,y.config=g,y}var D=A.prototype;return D.resetInitSegment=function(g,y,s,e){E.prototype.resetInitSegment.call(this,g,y,s,e),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:y,duration:e,inputTimeScale:9e4,dropped:0}},A.probe=function(g){if(!g)return!1;for(var y=I.getID3Data(g,0)||[],s=y.length,e=g.length;s<e;s++)if(p.probe(g,s))return T.logger.log("ADTS sync word found !"),!0;return!1},D.canParse=function(g,y){return p.canParse(g,y)},D.appendFrame=function(g,y,s){p.initTrackConfig(g,this.observer,y,s,g.manifestCodec);var e=p.appendFrame(g,y,s,this.basePTS,this.frameIndex);if(e&&e.missing===0)return e},A}(R.default);P.default=_},"./src/demux/adts.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"getAudioConfig",function(){return I}),n.d(P,"isHeaderPattern",function(){return S}),n.d(P,"getHeaderLength",function(){return O}),n.d(P,"getFullFrameLength",function(){return _}),n.d(P,"canGetFrameLength",function(){return E}),n.d(P,"isHeader",function(){return A}),n.d(P,"canParse",function(){return D}),n.d(P,"probe",function(){return x}),n.d(P,"initTrackConfig",function(){return g}),n.d(P,"getFrameDuration",function(){return y}),n.d(P,"parseFrameHeader",function(){return s}),n.d(P,"appendFrame",function(){return e});var R=n("./src/utils/logger.ts"),p=n("./src/errors.ts"),T=n("./src/events.ts");function I(o,f,a,i){var t,u,c,r,h=navigator.userAgent.toLowerCase(),d=i,l=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];t=((f[a+2]&192)>>>6)+1;var v=(f[a+2]&60)>>>2;if(v>l.length-1){o.trigger(T.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+v});return}return c=(f[a+2]&1)<<2,c|=(f[a+3]&192)>>>6,R.logger.log("manifest codec:"+i+", ADTS type:"+t+", samplingIndex:"+v),/firefox/i.test(h)?v>=6?(t=5,r=new Array(4),u=v-3):(t=2,r=new Array(2),u=v):h.indexOf("android")!==-1?(t=2,r=new Array(2),u=v):(t=5,r=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&v>=6?u=v-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(v>=6&&c===1||/vivaldi/i.test(h))||!i&&c===1)&&(t=2,r=new Array(2)),u=v)),r[0]=t<<3,r[0]|=(v&14)>>1,r[1]|=(v&1)<<7,r[1]|=c<<3,t===5&&(r[1]|=(u&14)>>1,r[2]=(u&1)<<7,r[2]|=2<<2,r[3]=0),{config:r,samplerate:l[v],channelCount:c,codec:"mp4a.40."+t,manifestCodec:d}}function S(o,f){return o[f]===255&&(o[f+1]&246)===240}function O(o,f){return o[f+1]&1?7:9}function _(o,f){return(o[f+3]&3)<<11|o[f+4]<<3|(o[f+5]&224)>>>5}function E(o,f){return f+5<o.length}function A(o,f){return f+1<o.length&&S(o,f)}function D(o,f){return E(o,f)&&S(o,f)&&_(o,f)<=o.length-f}function x(o,f){if(A(o,f)){var a=O(o,f);if(f+a>=o.length)return!1;var i=_(o,f);if(i<=a)return!1;var t=f+i;return t===o.length||A(o,t)}return!1}function g(o,f,a,i,t){if(!o.samplerate){var u=I(f,a,i,t);if(!u)return;o.config=u.config,o.samplerate=u.samplerate,o.channelCount=u.channelCount,o.codec=u.codec,o.manifestCodec=u.manifestCodec,R.logger.log("parsed codec:"+o.codec+", rate:"+u.samplerate+", channels:"+u.channelCount)}}function y(o){return 1024*9e4/o}function s(o,f){var a=O(o,f);if(f+a<=o.length){var i=_(o,f)-a;if(i>0)return{headerLength:a,frameLength:i}}}function e(o,f,a,i,t){var u=y(o.samplerate),c=i+t*u,r=s(f,a),h;if(r){var d=r.frameLength,l=r.headerLength,v=l+d,m=Math.max(0,a+v-f.length);m?(h=new Uint8Array(v-l),h.set(f.subarray(a+l,f.length),0)):h=f.subarray(a+l,a+v);var L={unit:h,pts:c};return m||o.samples.push(L),{sample:L,length:v,missing:m}}var b=f.length-a;h=new Uint8Array(b),h.set(f.subarray(a,f.length),0);var M={unit:h,pts:c};return{sample:M,length:b,missing:-1}}},"./src/demux/base-audio-demuxer.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"initPTSFn",function(){return E});var R=n("./src/polyfills/number.ts"),p=n("./src/demux/id3.ts"),T=n("./src/types/demuxer.ts"),I=n("./src/demux/dummy-demuxed-track.ts"),S=n("./src/utils/mp4-tools.ts"),O=n("./src/utils/typed-array.ts"),_=function(){function A(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null}var D=A.prototype;return D.resetInitSegment=function(g,y,s,e){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},D.resetTimeStamp=function(g){this.initPTS=g,this.resetContiguity()},D.resetContiguity=function(){this.basePTS=null,this.frameIndex=0},D.canParse=function(g,y){return!1},D.appendFrame=function(g,y,s){},D.demux=function(g,y){this.cachedData&&(g=Object(S.appendUint8Array)(this.cachedData,g),this.cachedData=null);var s=p.getID3Data(g,0),e=s?s.length:0,o,f,a=this._audioTrack,i=this._id3Track,t=s?p.getTimeStamp(s):void 0,u=g.length;for((this.basePTS===null||this.frameIndex===0&&Object(R.isFiniteNumber)(t))&&(this.basePTS=E(t,y,this.initPTS)),s&&s.length>0&&i.samples.push({pts:this.basePTS,dts:this.basePTS,data:s,type:T.MetadataSchema.audioId3}),f=this.basePTS;e<u;){if(this.canParse(g,e)){var c=this.appendFrame(a,g,e);c?(this.frameIndex++,f=c.sample.pts,e+=c.length,o=e):e=u}else p.canParse(g,e)?(s=p.getID3Data(g,e),i.samples.push({pts:f,dts:f,data:s,type:T.MetadataSchema.audioId3}),e+=s.length,o=e):e++;if(e===u&&o!==u){var r=Object(O.sliceUint8)(g,o);this.cachedData?this.cachedData=Object(S.appendUint8Array)(this.cachedData,r):this.cachedData=r}}return{audioTrack:a,videoTrack:Object(I.dummyTrack)(),id3Track:i,textTrack:Object(I.dummyTrack)()}},D.demuxSampleAes=function(g,y,s){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},D.flush=function(g){var y=this.cachedData;return y&&(this.cachedData=null,this.demux(y,0)),{audioTrack:this._audioTrack,videoTrack:Object(I.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(I.dummyTrack)()}},D.destroy=function(){},A}(),E=function(D,x,g){return Object(R.isFiniteNumber)(D)?D*90:x*9e4+(g||0)};P.default=_},"./src/demux/chunk-cache.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return R});var R=function(){function T(){this.chunks=[],this.dataLength=0}var I=T.prototype;return I.push=function(O){this.chunks.push(O),this.dataLength+=O.length},I.flush=function(){var O=this.chunks,_=this.dataLength,E;if(O.length)O.length===1?E=O[0]:E=p(O,_);else return new Uint8Array(0);return this.reset(),E},I.reset=function(){this.chunks.length=0,this.dataLength=0},T}();function p(T,I){for(var S=new Uint8Array(I),O=0,_=0;_<T.length;_++){var E=T[_];S.set(E,O),O+=E.length}return S}},"./src/demux/dummy-demuxed-track.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"dummyTrack",function(){return R});function R(p,T){return p===void 0&&(p=""),T===void 0&&(T=9e4),{type:p,id:-1,pid:-1,inputTimeScale:T,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/utils/logger.ts"),p=function(){function T(S){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=S,this.bytesAvailable=S.byteLength,this.word=0,this.bitsAvailable=0}var I=T.prototype;return I.loadWord=function(){var O=this.data,_=this.bytesAvailable,E=O.byteLength-_,A=new Uint8Array(4),D=Math.min(4,_);if(D===0)throw new Error("no bytes available");A.set(O.subarray(E,E+D)),this.word=new DataView(A.buffer).getUint32(0),this.bitsAvailable=D*8,this.bytesAvailable-=D},I.skipBits=function(O){var _;this.bitsAvailable>O?(this.word<<=O,this.bitsAvailable-=O):(O-=this.bitsAvailable,_=O>>3,O-=_>>3,this.bytesAvailable-=_,this.loadWord(),this.word<<=O,this.bitsAvailable-=O)},I.readBits=function(O){var _=Math.min(this.bitsAvailable,O),E=this.word>>>32-_;return O>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(),_=O-_,_>0&&this.bitsAvailable?E<<_|this.readBits(_):E},I.skipLZ=function(){var O;for(O=0;O<this.bitsAvailable;++O)if((this.word&2147483648>>>O)!==0)return this.word<<=O,this.bitsAvailable-=O,O;return this.loadWord(),O+this.skipLZ()},I.skipUEG=function(){this.skipBits(1+this.skipLZ())},I.skipEG=function(){this.skipBits(1+this.skipLZ())},I.readUEG=function(){var O=this.skipLZ();return this.readBits(O+1)-1},I.readEG=function(){var O=this.readUEG();return 1&O?1+O>>>1:-1*(O>>>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(O){for(var _=8,E=8,A,D=0;D<O;D++)E!==0&&(A=this.readEG(),E=(_+A+256)%256),_=E===0?_:E},I.readSPS=function(){var O=0,_=0,E=0,A=0,D,x,g,y=this.readUByte.bind(this),s=this.readBits.bind(this),e=this.readUEG.bind(this),o=this.readBoolean.bind(this),f=this.skipBits.bind(this),a=this.skipEG.bind(this),i=this.skipUEG.bind(this),t=this.skipScalingList.bind(this);y();var u=y();if(s(5),f(3),y(),i(),u===100||u===110||u===122||u===244||u===44||u===83||u===86||u===118||u===128){var c=e();if(c===3&&f(1),i(),i(),f(1),o())for(x=c!==3?8:12,g=0;g<x;g++)o()&&(g<6?t(16):t(64))}i();var r=e();if(r===0)e();else if(r===1)for(f(1),a(),a(),D=e(),g=0;g<D;g++)a();i(),f(1);var h=e(),d=e(),l=s(1);l===0&&f(1),f(1),o()&&(O=e(),_=e(),E=e(),A=e());var v=[1,1];if(o()&&o()){var m=y();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=[y()<<8|y(),y()<<8|y()];break}}}return{width:Math.ceil((h+1)*16-O*2-_*2),height:(2-l)*(d+1)*16-(l?2:4)*(E+A),pixelRatio:v}},I.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},T}();P.default=p},"./src/demux/id3.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"isHeader",function(){return R}),n.d(P,"isFooter",function(){return p}),n.d(P,"getID3Data",function(){return T}),n.d(P,"canParse",function(){return S}),n.d(P,"getTimeStamp",function(){return O}),n.d(P,"isTimeStampFrame",function(){return _}),n.d(P,"getID3Frames",function(){return A}),n.d(P,"decodeFrame",function(){return D}),n.d(P,"utf8ArrayToStr",function(){return e}),n.d(P,"testables",function(){return o});var R=function(t,u){return u+10<=t.length&&t[u]===73&&t[u+1]===68&&t[u+2]===51&&t[u+3]<255&&t[u+4]<255&&t[u+6]<128&&t[u+7]<128&&t[u+8]<128&&t[u+9]<128},p=function(t,u){return u+10<=t.length&&t[u]===51&&t[u+1]===68&&t[u+2]===73&&t[u+3]<255&&t[u+4]<255&&t[u+6]<128&&t[u+7]<128&&t[u+8]<128&&t[u+9]<128},T=function(t,u){for(var c=u,r=0;R(t,u);){r+=10;var h=I(t,u+6);r+=h,p(t,u+10)&&(r+=10),u+=r}if(r>0)return t.subarray(c,c+r)},I=function(t,u){var c=0;return c=(t[u]&127)<<21,c|=(t[u+1]&127)<<14,c|=(t[u+2]&127)<<7,c|=t[u+3]&127,c},S=function(t,u){return R(t,u)&&I(t,u+6)+10<=t.length-u},O=function(t){for(var u=A(t),c=0;c<u.length;c++){var r=u[c];if(_(r))return s(r)}},_=function(t){return t&&t.key==="PRIV"&&t.info==="com.apple.streaming.transportStreamTimestamp"},E=function(t){var u=String.fromCharCode(t[0],t[1],t[2],t[3]),c=I(t,4),r=10;return{type:u,size:c,data:t.subarray(r,r+c)}},A=function(t){for(var u=0,c=[];R(t,u);){var r=I(t,u+6);u+=10;for(var h=u+r;u+8<h;){var d=E(t.subarray(u)),l=D(d);l&&c.push(l),u+=d.size+10}p(t,u)&&(u+=10)}return c},D=function(t){return t.type==="PRIV"?x(t):t.type[0]==="W"?y(t):g(t)},x=function(t){if(!(t.size<2)){var u=e(t.data,!0),c=new Uint8Array(t.data.subarray(u.length+1));return{key:t.type,info:u,data:c.buffer}}},g=function(t){if(!(t.size<2)){if(t.type==="TXXX"){var u=1,c=e(t.data.subarray(u),!0);u+=c.length+1;var r=e(t.data.subarray(u));return{key:t.type,info:c,data:r}}var h=e(t.data.subarray(1));return{key:t.type,data:h}}},y=function(t){if(t.type==="WXXX"){if(t.size<2)return;var u=1,c=e(t.data.subarray(u),!0);u+=c.length+1;var r=e(t.data.subarray(u));return{key:t.type,info:c,data:r}}var h=e(t.data);return{key:t.type,data:h}},s=function(t){if(t.data.byteLength===8){var u=new Uint8Array(t.data),c=u[3]&1,r=(u[4]<<23)+(u[5]<<15)+(u[6]<<7)+u[7];return r/=45,c&&(r+=4772185884e-2),Math.round(r)}},e=function(t,u){u===void 0&&(u=!1);var c=a();if(c){var r=c.decode(t);if(u){var h=r.indexOf("\0");return h!==-1?r.substring(0,h):r}return r.replace(/\0/g,"")}for(var d=t.length,l,v,m,L="",b=0;b<d;){if(l=t[b++],l===0&&u)return L;if(l===0||l===3)continue;switch(l>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:L+=String.fromCharCode(l);break;case 12:case 13:v=t[b++],L+=String.fromCharCode((l&31)<<6|v&63);break;case 14:v=t[b++],m=t[b++],L+=String.fromCharCode((l&15)<<12|(v&63)<<6|(m&63)<<0);break;default:}}return L},o={decodeTextFrame:g},f;function a(){return!f&&typeof self.TextDecoder!="undefined"&&(f=new self.TextDecoder("utf-8")),f}},"./src/demux/mp3demuxer.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/demux/base-audio-demuxer.ts"),p=n("./src/demux/id3.ts"),T=n("./src/utils/logger.ts"),I=n("./src/demux/mpegaudio.ts");function S(E,A){E.prototype=Object.create(A.prototype),E.prototype.constructor=E,O(E,A)}function O(E,A){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(x,g){return x.__proto__=g,x},O(E,A)}var _=function(E){S(A,E);function A(){return E.apply(this,arguments)||this}var D=A.prototype;return D.resetInitSegment=function(g,y,s,e){E.prototype.resetInitSegment.call(this,g,y,s,e),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:y,duration:e,inputTimeScale:9e4,dropped:0}},A.probe=function(g){if(!g)return!1;for(var y=p.getID3Data(g,0)||[],s=y.length,e=g.length;s<e;s++)if(I.probe(g,s))return T.logger.log("MPEG Audio sync word found !"),!0;return!1},D.canParse=function(g,y){return I.canParse(g,y)},D.appendFrame=function(g,y,s){if(this.basePTS!==null)return I.appendFrame(g,y,s,this.basePTS,this.frameIndex)},A}(R.default);P.default=_},"./src/demux/mp4demuxer.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/polyfills/number.ts"),p=n("./src/types/demuxer.ts"),T=n("./src/utils/mp4-tools.ts"),I=n("./src/demux/dummy-demuxed-track.ts"),S=/\/emsg[-/]ID3/i,O=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=D}var E=_.prototype;return E.resetTimeStamp=function(){},E.resetInitSegment=function(D,x,g,y){var s=Object(T.parseInitSegment)(D),e=this.videoTrack=Object(I.dummyTrack)("video",1),o=this.audioTrack=Object(I.dummyTrack)("audio",1),f=this.txtTrack=Object(I.dummyTrack)("text",1);if(this.id3Track=Object(I.dummyTrack)("id3",1),this.timeOffset=0,s.video){var a=s.video,i=a.id,t=a.timescale,u=a.codec;e.id=i,e.timescale=f.timescale=t,e.codec=u}if(s.audio){var c=s.audio,r=c.id,h=c.timescale,d=c.codec;o.id=r,o.timescale=h,o.codec=d}f.id=T.RemuxerTrackIdConfig.text,e.sampleDuration=0,e.duration=o.duration=y},E.resetContiguity=function(){},_.probe=function(D){return D=D.length>16384?D.subarray(0,16384):D,Object(T.findBox)(D,["moof"]).length>0},E.demux=function(D,x){this.timeOffset=x;var g=D,y=this.videoTrack,s=this.txtTrack;if(this.config.progressive){this.remainderData&&(g=Object(T.appendUint8Array)(this.remainderData,D));var e=Object(T.segmentValidRange)(g);this.remainderData=e.remainder,y.samples=e.valid||new Uint8Array}else y.samples=g;var o=this.extractID3Track(y,x);return s.samples=Object(T.parseSamples)(x,y),{videoTrack:y,audioTrack:this.audioTrack,id3Track:o,textTrack:this.txtTrack}},E.flush=function(){var D=this.timeOffset,x=this.videoTrack,g=this.txtTrack;x.samples=this.remainderData||new Uint8Array,this.remainderData=null;var y=this.extractID3Track(x,this.timeOffset);return g.samples=Object(T.parseSamples)(D,x),{videoTrack:x,audioTrack:Object(I.dummyTrack)(),id3Track:y,textTrack:Object(I.dummyTrack)()}},E.extractID3Track=function(D,x){var g=this.id3Track;if(D.samples.length){var y=Object(T.findBox)(D.samples,["emsg"]);y&&y.forEach(function(s){var e=Object(T.parseEmsg)(s);if(S.test(e.schemeIdUri)){var o=Object(R.isFiniteNumber)(e.presentationTime)?e.presentationTime/e.timeScale:x+e.presentationTimeDelta/e.timeScale,f=e.payload;g.samples.push({data:f,len:f.byteLength,dts:o,pts:o,type:p.MetadataSchema.emsg})}})}return g},E.demuxSampleAes=function(D,x,g){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},E.destroy=function(){},_}();P.default=O},"./src/demux/mpegaudio.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"appendFrame",function(){return O}),n.d(P,"parseHeader",function(){return _}),n.d(P,"isHeaderPattern",function(){return E}),n.d(P,"isHeader",function(){return A}),n.d(P,"canParse",function(){return D}),n.d(P,"probe",function(){return x});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],T=[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]],S=[0,1,1,4];function O(g,y,s,e,o){if(!(s+24>y.length)){var f=_(y,s);if(f&&s+f.frameLength<=y.length){var a=f.samplesPerFrame*9e4/f.sampleRate,i=e+o*a,t={unit:y.subarray(s,s+f.frameLength),pts:i,dts:i};return g.config=[],g.channelCount=f.channelCount,g.samplerate=f.sampleRate,g.samples.push(t),{sample:t,length:f.frameLength,missing:0}}}}function _(g,y){var s=g[y+1]>>3&3,e=g[y+1]>>1&3,o=g[y+2]>>4&15,f=g[y+2]>>2&3;if(s!==1&&o!==0&&o!==15&&f!==3){var a=g[y+2]>>1&1,i=g[y+3]>>6,t=s===3?3-e:e===3?3:4,u=p[t*14+o-1]*1e3,c=s===3?0:s===2?1:2,r=T[c*3+f],h=i===3?1:2,d=I[s][e],l=S[e],v=d*8*l,m=Math.floor(d*u/r+a)*l;if(R===null){var L=navigator.userAgent||"",b=L.match(/Chrome\/(\d+)/i);R=b?parseInt(b[1]):0}var M=!!R&&R<=87;return M&&e===2&&u>=224e3&&i===0&&(g[y+3]=g[y+3]|128),{sampleRate:r,channelCount:h,frameLength:m,samplesPerFrame:v}}}function E(g,y){return g[y]===255&&(g[y+1]&224)===224&&(g[y+1]&6)!==0}function A(g,y){return y+1<g.length&&E(g,y)}function D(g,y){var s=4;return E(g,y)&&s<=g.length-y}function x(g,y){if(y+1<g.length&&E(g,y)){var s=4,e=_(g,y),o=s;e!=null&&e.frameLength&&(o=e.frameLength);var f=y+o;return f===g.length||A(g,f)}return!1}},"./src/demux/sample-aes.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/crypt/decrypter.ts"),p=n("./src/demux/tsdemuxer.ts"),T=function(){function I(O,_,E){this.keyData=void 0,this.decrypter=void 0,this.keyData=E,this.decrypter=new R.default(O,_,{removePKCS7Padding:!1})}var S=I.prototype;return S.decryptBuffer=function(_,E){this.decrypter.decrypt(_,this.keyData.key.buffer,this.keyData.iv.buffer,E)},S.decryptAacSample=function(_,E,A,D){var x=_[E].unit;if(!(x.length<=16)){var g=x.subarray(16,x.length-x.length%16),y=g.buffer.slice(g.byteOffset,g.byteOffset+g.length),s=this;this.decryptBuffer(y,function(e){var o=new Uint8Array(e);x.set(o,16),D||s.decryptAacSamples(_,E+1,A)})}},S.decryptAacSamples=function(_,E,A){for(;;E++){if(E>=_.length){A();return}if(!(_[E].unit.length<32)){var D=this.decrypter.isSync();if(this.decryptAacSample(_,E,A,D),!D)return}}},S.getAvcEncryptedData=function(_){for(var E=Math.floor((_.length-48)/160)*16+16,A=new Int8Array(E),D=0,x=32;x<_.length-16;x+=160,D+=16)A.set(_.subarray(x,x+16),D);return A},S.getAvcDecryptedUnit=function(_,E){for(var A=new Uint8Array(E),D=0,x=32;x<_.length-16;x+=160,D+=16)_.set(A.subarray(D,D+16),x);return _},S.decryptAvcSample=function(_,E,A,D,x,g){var y=Object(p.discardEPB)(x.data),s=this.getAvcEncryptedData(y),e=this;this.decryptBuffer(s.buffer,function(o){x.data=e.getAvcDecryptedUnit(y,o),g||e.decryptAvcSamples(_,E,A+1,D)})},S.decryptAvcSamples=function(_,E,A,D){if(_ instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;E++,A=0){if(E>=_.length){D();return}for(var x=_[E].units;!(A>=x.length);A++){var g=x[A];if(!(g.data.length<=48||g.type!==1&&g.type!==5)){var y=this.decrypter.isSync();if(this.decryptAvcSample(_,E,A,D,g,y),!y)return}}}},I}();P.default=T},"./src/demux/transmuxer-interface.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return x});var R=n("./node_modules/webworkify-webpack/index.js"),p=n.n(R),T=n("./src/events.ts"),I=n("./src/demux/transmuxer.ts"),S=n("./src/utils/logger.ts"),O=n("./src/errors.ts"),_=n("./src/utils/mediasource-helper.ts"),E=n("./node_modules/eventemitter3/index.js"),A=n.n(E),D=Object(_.getMediaSource)()||{isTypeSupported:function(){return!1}},x=function(){function g(s,e,o,f){var a=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=o,this.onFlush=f;var i=s.config,t=function(d,l){l=l||{},l.frag=a.frag,l.id=a.id,s.trigger(d,l)};this.observer=new E.EventEmitter,this.observer.on(T.Events.FRAG_DECRYPTED,t),this.observer.on(T.Events.ERROR,t);var u={mp4:D.isTypeSupported("video/mp4"),mpeg:D.isTypeSupported("audio/mpeg"),mp3:D.isTypeSupported('audio/mp4; codecs="mp3"')},c=navigator.vendor;if(i.enableWorker&&typeof Worker!="undefined"){S.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(h){s.trigger(T.Events.ERROR,{type:O.ErrorTypes.OTHER_ERROR,details:O.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(h.message+" ("+h.filename+":"+h.lineno+")")})},r.postMessage({cmd:"init",typeSupported:u,vendor:c,id:e,config:JSON.stringify(i)})}catch(h){S.logger.warn("Error in worker:",h),S.logger.error("Error while initializing DemuxerWorker, fallback to inline"),r&&self.URL.revokeObjectURL(r.objectURL),this.transmuxer=new I.default(this.observer,u,i,c,e),this.worker=null}}else this.transmuxer=new I.default(this.observer,u,i,c,e)}var y=g.prototype;return y.destroy=function(){var e=this.worker;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.worker=null,this.onwmsg=void 0;else{var o=this.transmuxer;o&&(o.destroy(),this.transmuxer=null)}var f=this.observer;f&&f.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},y.push=function(e,o,f,a,i,t,u,c,r,h){var d,l,v=this;r.transmuxing.start=self.performance.now();var m=this.transmuxer,L=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,k=this.part?r.part-this.part.index:-1,j=U===0&&r.id>1&&r.id===(F==null?void 0:F.stats.chunkCount),N=!C&&(U===1||U===0&&(k===1||j&&k<=0)),W=self.performance.now();(C||U||i.stats.parsing.start===0)&&(i.stats.parsing.start=W),t&&(k||!N)&&(t.stats.parsing.start=W);var Y=!(F&&((d=i.initSegment)===null||d===void 0?void 0:d.url)===((l=F.initSegment)===null||l===void 0?void 0:l.url)),K=new I.TransmuxState(w,N,c,C,b,Y);if(!N||w||Y){S.logger.log("[transmuxer-interface, "+i.type+"]: Starting new transmux session for sn: "+r.sn+" p: "+r.part+" level: "+r.level+" id: "+r.id+`
|
|
11
|
+
Time to underbuffer: `+M.toFixed(3)+" s"),o.nextLoadLevel=w,this.bwEstimator.sample(c,t.loaded),this.clearTimer(),s.loader&&(this.fragCurrent=this.partCurrent=null,s.loader.abort()),o.trigger(S.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:s,part:e,stats:t})}}}}}},g.onFragLoaded=function(s,e){var o=e.frag,f=e.part;if(o.type===b.PlaylistLevelType.MAIN&&Object(R.isFiniteNumber)(o.sn)){var a=f?f.stats:o.stats,i=f?f.duration:o.duration;if(this.clearTimer(),this.lastLoadedFragLevel=o.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var t=this.hls.levels[o.level],u=(t.loaded?t.loaded.bytes:0)+a.loaded,c=(t.loaded?t.loaded.duration:0)+i;t.loaded={bytes:u,duration:c},t.realBitrate=Math.round(8*u/c)}if(o.bitrateTest){var r={stats:a,frag:o,part:f,id:o.type};this.onFragBuffered(S.Events.FRAG_BUFFERED,r)}}},g.onFragBuffered=function(s,e){var o=e.frag,f=e.part,a=f?f.stats:o.stats;if(!a.aborted&&!(o.type!==b.PlaylistLevelType.MAIN||o.sn==="initSegment")){var i=a.parsing.end-a.loading.start;this.bwEstimator.sample(i,a.loaded),a.bwEstimate=this.bwEstimator.getEstimate(),o.bitrateTest?this.bitrateTestDelay=i/1e3:this.bitrateTestDelay=0}},g.onError=function(s,e){switch(e.details){case T.ErrorDetails.FRAG_LOAD_ERROR:case T.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},g.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},g.getNextABRAutoLevel=function(){var s=this.fragCurrent,e=this.partCurrent,o=this.hls,f=o.maxAutoLevel,a=o.config,i=o.minAutoLevel,t=o.media,u=e?e.duration:s?s.duration:0,c=t?t.currentTime:0,r=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,h=this.bwEstimator?this.bwEstimator.getEstimate():a.abrEwmaDefaultEstimate,d=(I.BufferHelper.bufferInfo(t,c,a.maxBufferHole).end-c)/r,l=this.findBestLevel(h,i,f,d,a.abrBandWidthFactor,a.abrBandWidthUpFactor);if(l>=0)return l;_.logger.trace((d?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var v=u?Math.min(u,a.maxStarvationDelay):a.maxStarvationDelay,p=a.abrBandWidthFactor,L=a.abrBandWidthUpFactor;if(!d){var O=this.bitrateTestDelay;if(O){var M=u?Math.min(u,a.maxLoadingDelay):a.maxLoadingDelay;v=M-O,_.logger.trace("bitrate test took "+Math.round(1e3*O)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*v)+" ms"),p=L=1}}return l=this.findBestLevel(h,i,f,d+v,p,L),Math.max(l,0)},g.findBestLevel=function(s,e,o,f,a,i){for(var t,u=this.fragCurrent,c=this.partCurrent,r=this.lastLoadedFragLevel,h=this.hls.levels,d=h[r],l=!!(d!=null&&(t=d.details)!==null&&t!==void 0&&t.live),v=d==null?void 0:d.codecSet,p=c?c.duration:u?u.duration:0,L=o;L>=e;L--){var O=h[L];if(!(!O||v&&O.codecSet!==v)){var M=O.details,F=(c?M==null?void 0:M.partTarget:M==null?void 0:M.averagetargetduration)||p,w=void 0;L<=r?w=a*s:w=i*s;var C=h[L].maxBitrate,k=C*F/w;if(_.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+L+"/"+Math.round(w)+"/"+C+"/"+F+"/"+f+"/"+k),w>C&&(!k||l&&!this.bitrateTestDelay||k<f))return L}}return-1},A(x,[{key:"nextAutoLevel",get:function(){var s=this._nextAutoLevel,e=this.bwEstimator;if(s!==-1&&!e.canEstimate())return s;var o=this.getNextABRAutoLevel();return s!==-1&&this.hls.levels[o].loadError?s:(s!==-1&&(o=Math.min(s,o)),o)},set:function(s){this._nextAutoLevel=s}}]),x}();P.default=D},"./src/controller/audio-stream-controller.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/polyfills/number.ts"),m=n("./src/controller/base-stream-controller.ts"),S=n("./src/events.ts"),I=n("./src/utils/buffer-helper.ts"),T=n("./src/controller/fragment-tracker.ts"),b=n("./src/types/level.ts"),_=n("./src/types/loader.ts"),E=n("./src/loader/fragment.ts"),A=n("./src/demux/chunk-cache.ts"),D=n("./src/demux/transmuxer-interface.ts"),x=n("./src/types/transmuxer.ts"),g=n("./src/controller/fragment-finders.ts"),y=n("./src/utils/discontinuities.ts"),s=n("./src/errors.ts");function e(){return e=Object.assign?Object.assign.bind():function(t){for(var u=1;u<arguments.length;u++){var c=arguments[u];for(var r in c)Object.prototype.hasOwnProperty.call(c,r)&&(t[r]=c[r])}return t},e.apply(this,arguments)}function o(t,u){t.prototype=Object.create(u.prototype),t.prototype.constructor=t,f(t,u)}function f(t,u){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,h){return r.__proto__=h,r},f(t,u)}var a=100,i=function(t){o(u,t);function u(r,h){var d;return d=t.call(this,r,h,"[audio-stream-controller]")||this,d.videoBuffer=null,d.videoTrackCC=-1,d.waitingVideoCC=-1,d.audioSwitch=!1,d.trackId=-1,d.waitingData=null,d.mainDetails=null,d.bufferFlushed=!1,d.cachedTrackLoadedData=null,d._registerListeners(),d}var c=u.prototype;return c.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},c._registerListeners=function(){var h=this.hls;h.on(S.Events.MEDIA_ATTACHED,this.onMediaAttached,this),h.on(S.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.on(S.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.on(S.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.on(S.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),h.on(S.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),h.on(S.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),h.on(S.Events.ERROR,this.onError,this),h.on(S.Events.BUFFER_RESET,this.onBufferReset,this),h.on(S.Events.BUFFER_CREATED,this.onBufferCreated,this),h.on(S.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),h.on(S.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.on(S.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c._unregisterListeners=function(){var h=this.hls;h.off(S.Events.MEDIA_ATTACHED,this.onMediaAttached,this),h.off(S.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.off(S.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.off(S.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.off(S.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),h.off(S.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),h.off(S.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),h.off(S.Events.ERROR,this.onError,this),h.off(S.Events.BUFFER_RESET,this.onBufferReset,this),h.off(S.Events.BUFFER_CREATED,this.onBufferCreated,this),h.off(S.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),h.off(S.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.off(S.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c.onInitPtsFound=function(h,d){var l=d.frag,v=d.id,p=d.initPTS;if(v==="main"){var L=l.cc;this.initPTS[l.cc]=p,this.log("InitPTS for cc: "+L+" found from main: "+p),this.videoTrackCC=L,this.state===m.State.WAITING_INIT_PTS&&this.tick()}},c.startLoad=function(h){if(!this.levels){this.startPosition=h,this.state=m.State.STOPPED;return}var d=this.lastCurrentTime;this.stopLoad(),this.setInterval(a),this.fragLoadError=0,d>0&&h===-1?(this.log("Override startPosition with lastCurrentTime @"+d.toFixed(3)),h=d,this.state=m.State.IDLE):(this.loadedmetadata=!1,this.state=m.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=h,this.tick()},c.doTick=function(){switch(this.state){case m.State.IDLE:this.doTickIdle();break;case m.State.WAITING_TRACK:{var h,d=this.levels,l=this.trackId,v=d==null||(h=d[l])===null||h===void 0?void 0:h.details;if(v){if(this.waitForCdnTuneIn(v))break;this.state=m.State.WAITING_INIT_PTS}break}case m.State.FRAG_LOADING_WAITING_RETRY:{var p,L=performance.now(),O=this.retryDate;(!O||L>=O||(p=this.media)!==null&&p!==void 0&&p.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=m.State.IDLE);break}case m.State.WAITING_INIT_PTS:{var M=this.waitingData;if(M){var F=M.frag,w=M.part,C=M.cache,k=M.complete;if(this.initPTS[F.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=m.State.FRAG_LOADING;var U=C.flush(),j={frag:F,part:w,payload:U,networkDetails:null};this._handleFragmentLoadProgress(j),k&&t.prototype._handleFragmentLoadComplete.call(this,j)}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 N=this.getLoadPosition(),W=I.BufferHelper.bufferInfo(this.mediaBuffer,N,this.config.maxBufferHole),Y=Object(g.fragmentWithinToleranceTest)(W.end,this.config.maxFragLookUpTolerance,F);Y<0&&(this.log("Waiting fragment cc ("+F.cc+") @ "+F.start+" cancelled because another fragment at "+W.end+" is needed"),this.clearWaitingFragment())}}else this.state=m.State.IDLE}}this.onTickEnd()},c.clearWaitingFragment=function(){var h=this.waitingData;h&&(this.fragmentTracker.removeFragment(h.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=m.State.IDLE)},c.resetLoadingState=function(){this.clearWaitingFragment(),t.prototype.resetLoadingState.call(this)},c.onTickEnd=function(){var h=this.media;if(!(!h||!h.readyState)){var d=this.mediaBuffer?this.mediaBuffer:h,l=d.buffered;!this.loadedmetadata&&l.length&&(this.loadedmetadata=!0),this.lastCurrentTime=h.currentTime}},c.doTickIdle=function(){var h,d,l=this.hls,v=this.levels,p=this.media,L=this.trackId,O=l.config;if(!(!v||!v[L])&&!(!p&&(this.startFragRequested||!O.startFragPrefetch))){var M=v[L],F=M.details;if(!F||F.live&&this.levelLastLoaded!==L||this.waitForCdnTuneIn(F)){this.state=m.State.WAITING_TRACK;return}var w=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&w&&(this.bufferFlushed=!1,this.afterBufferFlushed(w,E.ElementaryStreamTypes.AUDIO,_.PlaylistLevelType.AUDIO));var C=this.getFwdBufferInfo(w,_.PlaylistLevelType.AUDIO);if(C!==null){var k=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,_.PlaylistLevelType.MAIN),U=C.len,j=this.getMaxBufferLength(k==null?void 0:k.len),N=this.audioSwitch;if(!(U>=j&&!N)){if(!N&&this._streamEnded(C,F)){l.trigger(S.Events.BUFFER_EOS,{type:"audio"}),this.state=m.State.ENDED;return}var W=F.fragments,Y=W[0].start,K=C.end;if(N&&p){var H=this.getLoadPosition();K=H,F.PTSKnown&&H<Y&&(C.end>Y||C.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),p.currentTime=Y+.05)}if(!(k&&K>k.end+F.targetduration)&&!((!k||!k.len)&&C.len)){var z=this.getNextFragment(K,F);if(!z){this.bufferFlushed=!0;return}((h=z.decryptdata)===null||h===void 0?void 0:h.keyFormat)==="identity"&&!((d=z.decryptdata)!==null&&d!==void 0&&d.key)?this.loadKey(z,F):this.loadFragment(z,F,K)}}}}},c.getMaxBufferLength=function(h){var d=t.prototype.getMaxBufferLength.call(this);return h?Math.max(d,h):d},c.onMediaDetaching=function(){this.videoBuffer=null,t.prototype.onMediaDetaching.call(this)},c.onAudioTracksUpdated=function(h,d){var l=d.audioTracks;this.resetTransmuxer(),this.levels=l.map(function(v){return new b.Level(v)})},c.onAudioTrackSwitching=function(h,d){var l=!!d.url;this.trackId=d.id;var v=this.fragCurrent;v!=null&&v.loader&&v.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),l?this.setInterval(a):this.resetTransmuxer(),l?(this.audioSwitch=!0,this.state=m.State.IDLE):this.state=m.State.STOPPED,this.tick()},c.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},c.onLevelLoaded=function(h,d){this.mainDetails=d.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(S.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},c.onAudioTrackLoaded=function(h,d){var l;if(this.mainDetails==null){this.cachedTrackLoadedData=d;return}var v=this.levels,p=d.details,L=d.id;if(!v){this.warn("Audio tracks were reset while loading level "+L);return}this.log("Track "+L+" loaded ["+p.startSN+","+p.endSN+"],duration:"+p.totalduration);var O=v[L],M=0;if(p.live||(l=O.details)!==null&&l!==void 0&&l.live){var F=this.mainDetails;if(p.fragments[0]||(p.deltaUpdateFailed=!0),p.deltaUpdateFailed||!F)return;!O.details&&p.hasProgramDateTime&&F.hasProgramDateTime?(Object(y.alignMediaPlaylistByPDT)(p,F),M=p.fragments[0].start):M=this.alignPlaylists(p,O.details)}O.details=p,this.levelLastLoaded=L,!this.startFragRequested&&(this.mainDetails||!p.live)&&this.setStartPosition(O.details,M),this.state===m.State.WAITING_TRACK&&!this.waitForCdnTuneIn(p)&&(this.state=m.State.IDLE),this.tick()},c._handleFragmentLoadProgress=function(h){var d,l=h.frag,v=h.part,p=h.payload,L=this.config,O=this.trackId,M=this.levels;if(!M){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+l.sn+" of level "+l.level+" will not be buffered");return}var F=M[O];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=L.defaultAudioCodec||F.audioCodec||"mp4a.40.2",k=this.transmuxer;k||(k=this.transmuxer=new D.default(this.hls,_.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var U=this.initPTS[l.cc],j=(d=l.initSegment)===null||d===void 0?void 0:d.data;if(U!==void 0){var N=!1,W=v?v.index:-1,Y=W!==-1,K=new x.ChunkMetadata(l.level,l.sn,l.stats.chunkCount,p.byteLength,W,Y);k.push(p,j,C,"",l,v,w.totalduration,N,K,U)}else{this.log("Unknown video PTS for cc "+l.cc+", waiting for video PTS before demuxing audio frag "+l.sn+" of ["+w.startSN+" ,"+w.endSN+"],track "+O);var H=this.waitingData=this.waitingData||{frag:l,part:v,cache:new A.default,complete:!1},z=H.cache;z.push(new Uint8Array(p)),this.waitingVideoCC=this.videoTrackCC,this.state=m.State.WAITING_INIT_PTS}},c._handleFragmentLoadComplete=function(h){if(this.waitingData){this.waitingData.complete=!0;return}t.prototype._handleFragmentLoadComplete.call(this,h)},c.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},c.onBufferCreated=function(h,d){var l=d.tracks.audio;l&&(this.mediaBuffer=l.buffer||null),d.tracks.video&&(this.videoBuffer=d.tracks.video.buffer||null)},c.onFragBuffered=function(h,d){var l=d.frag,v=d.part;if(l.type===_.PlaylistLevelType.AUDIO){if(this.fragContextChanged(l)){this.warn("Fragment "+l.sn+(v?" p: "+v.index:"")+" of level "+l.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}l.sn!=="initSegment"&&(this.fragPrevious=l,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(S.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(l,v)}},c.onError=function(h,d){switch(d.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,d);break;case s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==m.State.ERROR&&this.state!==m.State.STOPPED&&(this.state=d.fatal?m.State.ERROR:m.State.IDLE,this.warn(d.details+" while loading frag, switching to "+this.state+" state"));break;case s.ErrorDetails.BUFFER_FULL_ERROR:if(d.parent==="audio"&&(this.state===m.State.PARSING||this.state===m.State.PARSED)){var l=!0,v=this.getFwdBufferInfo(this.mediaBuffer,_.PlaylistLevelType.AUDIO);v&&v.len>.5&&(l=!this.reduceMaxBufferLength(v.len)),l&&(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}},c.onBufferFlushed=function(h,d){var l=d.type;l===E.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},c._handleTransmuxComplete=function(h){var d,l="audio",v=this.hls,p=h.remuxResult,L=h.chunkMeta,O=this.getCurrentContext(L);if(!O){this.warn("The loading context changed while buffering fragment "+L.sn+" of level "+L.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(L.level);return}var M=O.frag,F=O.part,w=O.level.details,C=p.audio,k=p.text,U=p.id3,j=p.initSegment;if(!(this.fragContextChanged(M)||!w)){if(this.state=m.State.PARSING,this.audioSwitch&&C&&this.completeAudioSwitch(),j!=null&&j.tracks&&(this._bufferInitSegment(j.tracks,M,L),v.trigger(S.Events.FRAG_PARSING_INIT_SEGMENT,{frag:M,id:l,tracks:j.tracks})),C){var N=C.startPTS,W=C.endPTS,Y=C.startDTS,K=C.endDTS;F&&(F.elementaryStreams[E.ElementaryStreamTypes.AUDIO]={startPTS:N,endPTS:W,startDTS:Y,endDTS:K}),M.setElementaryStreamInfo(E.ElementaryStreamTypes.AUDIO,N,W,Y,K),this.bufferFragmentData(C,M,F,L)}if(U!=null&&(d=U.samples)!==null&&d!==void 0&&d.length){var H=e({id:l,frag:M,details:w},U);v.trigger(S.Events.FRAG_PARSING_METADATA,H)}if(k){var z=e({id:l,frag:M,details:w},k);v.trigger(S.Events.FRAG_PARSING_USERDATA,z)}}},c._bufferInitSegment=function(h,d,l){if(this.state===m.State.PARSING){h.video&&delete h.video;var v=h.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,h);var p=v.initSegment;if(p!=null&&p.byteLength){var L={type:"audio",frag:d,part:null,chunkMeta:l,parent:d.type,data:p};this.hls.trigger(S.Events.BUFFER_APPENDING,L)}this.tick()}}},c.loadFragment=function(h,d,l){var v=this.fragmentTracker.getState(h);this.fragCurrent=h,(this.audioSwitch||v===T.FragmentState.NOT_LOADED||v===T.FragmentState.PARTIAL)&&(h.sn==="initSegment"?this._loadInitSegment(h):d.live&&!Object(R.isFiniteNumber)(this.initPTS[h.cc])?(this.log("Waiting for video PTS in continuity counter "+h.cc+" of live stream before loading audio fragment "+h.sn+" of level "+this.trackId),this.state=m.State.WAITING_INIT_PTS):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,h,d,l)))},c.completeAudioSwitch=function(){var h=this.hls,d=this.media,l=this.trackId;d&&(this.log("Switching audio track : flushing all audio"),t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,h.trigger(S.Events.AUDIO_TRACK_SWITCHED,{id:l})},u}(m.default);P.default=i},"./src/controller/audio-track-controller.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/events.ts"),m=n("./src/errors.ts"),S=n("./src/controller/base-playlist-controller.ts"),I=n("./src/types/loader.ts");function T(D,x){for(var g=0;g<x.length;g++){var y=x[g];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(D,y.key,y)}}function b(D,x,g){return x&&T(D.prototype,x),g&&T(D,g),Object.defineProperty(D,"prototype",{writable:!1}),D}function _(D,x){D.prototype=Object.create(x.prototype),D.prototype.constructor=D,E(D,x)}function E(D,x){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(y,s){return y.__proto__=s,y},E(D,x)}var A=function(D){_(x,D);function x(y){var s;return s=D.call(this,y,"[audio-track-controller]")||this,s.tracks=[],s.groupId=null,s.tracksInGroup=[],s.trackId=-1,s.trackName="",s.selectDefaultTrack=!0,s.registerListeners(),s}var g=x.prototype;return g.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)},g.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)},g.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,D.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(s,e){this.tracks=e.audioTracks||[]},g.onAudioTrackLoaded=function(s,e){var o=e.id,f=e.details,a=this.tracksInGroup[o];if(!a){this.warn("Invalid audio track id "+o);return}var i=a.details;a.details=e.details,this.log("audioTrack "+o+" loaded ["+f.startSN+"-"+f.endSN+"]"),o===this.trackId&&(this.retryCount=0,this.playlistLoaded(o,e,i))},g.onLevelLoading=function(s,e){this.switchLevel(e.level)},g.onLevelSwitching=function(s,e){this.switchLevel(e.level)},g.switchLevel=function(s){var e=this.hls.levels[s];if(!!(e!=null&&e.audioGroupIds)){var o=e.audioGroupIds[e.urlId];if(this.groupId!==o){this.groupId=o;var f=this.tracks.filter(function(i){return!o||i.groupId===o});this.selectDefaultTrack&&!f.some(function(i){return i.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=f;var a={audioTracks:f};this.log("Updating audio tracks, "+f.length+' track(s) found in "'+o+'" group-id'),this.hls.trigger(R.Events.AUDIO_TRACKS_UPDATED,a),this.selectInitialTrack()}}},g.onError=function(s,e){D.prototype.onError.call(this,s,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(s){var e=this.tracksInGroup;if(s<0||s>=e.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var o=e[this.trackId];this.log("Now switching to audio-track index "+s);var f=e[s],a=f.id,i=f.groupId,t=i===void 0?"":i,u=f.name,c=f.type,r=f.url;if(this.trackId=s,this.trackName=u,this.selectDefaultTrack=!1,this.hls.trigger(R.Events.AUDIO_TRACK_SWITCHING,{id:a,groupId:t,name:u,type:c,url:r}),!(f.details&&!f.details.live)){var h=this.switchParams(f.url,o==null?void 0:o.details);this.loadPlaylist(h)}},g.selectInitialTrack=function(){var s=this.tracksInGroup;console.assert(s.length,"Initial audio track should be selected when tracks are known");var e=this.trackName,o=this.findTrackId(e)||this.findTrackId();o!==-1?this.setAudioTrack(o):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(R.Events.ERROR,{type:m.ErrorTypes.MEDIA_ERROR,details:m.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},g.findTrackId=function(s){for(var e=this.tracksInGroup,o=0;o<e.length;o++){var f=e[o];if((!this.selectDefaultTrack||f.default)&&(!s||s===f.name))return f.id}return-1},g.loadPlaylist=function(s){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var o=e.id,f=e.groupId,a=e.url;if(s)try{a=s.addDirectives(a)}catch(i){this.warn("Could not construct new URL with HLS Delivery Directives: "+i)}this.log("loading audio-track playlist for id: "+o),this.clearTimer(),this.hls.trigger(R.Events.AUDIO_TRACK_LOADING,{url:a,id:o,groupId:f,deliveryDirectives:s||null})}},b(x,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(s){this.selectDefaultTrack=!1,this.setAudioTrack(s)}}]),x}(S.default);P.default=A},"./src/controller/base-playlist-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return b});var R=n("./src/polyfills/number.ts"),m=n("./src/types/level.ts"),S=n("./src/controller/level-helper.ts"),I=n("./src/utils/logger.ts"),T=n("./src/errors.ts"),b=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,D+":"),this.warn=I.logger.warn.bind(I.logger,D+":"),this.hls=A}var E=_.prototype;return E.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},E.onError=function(D,x){x.fatal&&x.type===T.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},E.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},E.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},E.stopLoad=function(){this.canLoad=!1,this.clearTimer()},E.switchParams=function(D,x){var g=x==null?void 0:x.renditionReports;if(g)for(var y=0;y<g.length;y++){var s=g[y],e=""+s.URI;if(e===D.slice(-e.length)){var o=parseInt(s["LAST-MSN"]),f=parseInt(s["LAST-PART"]);if(x&&this.hls.config.lowLatencyMode){var a=Math.min(x.age-x.partTarget,x.targetduration);f!==void 0&&a>x.partTarget&&(f+=1)}if(Object(R.isFiniteNumber)(o))return new m.HlsUrlParameters(o,Object(R.isFiniteNumber)(f)?f:void 0,m.HlsSkip.No)}}},E.loadPlaylist=function(D){},E.shouldLoadTrack=function(D){return this.canLoad&&D&&!!D.url&&(!D.details||D.details.live)},E.playlistLoaded=function(D,x,g){var y=this,s=x.details,e=x.stats,o=e.loading.end?Math.max(0,self.performance.now()-e.loading.end):0;if(s.advancedDateTime=Date.now()-o,s.live||g!=null&&g.live){if(s.reloaded(g),g&&this.log("live playlist "+D+" "+(s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:"MISSED")),g&&s.fragments.length>0&&Object(S.mergeDetails)(g,s),!this.canLoad||!s.live)return;var f,a=void 0,i=void 0;if(s.canBlockReload&&s.endSN&&s.advanced){var t=this.hls.config.lowLatencyMode,u=s.lastPartSn,c=s.endSN,r=s.lastPartIndex,h=r!==-1,d=u===c,l=t?0:r;h?(a=d?c+1:u,i=d?l:r+1):a=c+1;var v=s.age,p=v+s.ageHeader,L=Math.min(p-s.partTarget,s.targetduration*1.5);if(L>0){if(g&&L>g.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+g.tuneInGoal+" to: "+L+" with playlist age: "+s.age),L=0;else{var O=Math.floor(L/s.targetduration);if(a+=O,i!==void 0){var M=Math.round(L%s.targetduration/s.partTarget);i+=M}this.log("CDN Tune-in age: "+s.ageHeader+"s last advanced "+v.toFixed(2)+"s goal: "+L+" skip sn "+O+" to part "+i)}s.tuneInGoal=L}if(f=this.getDeliveryDirectives(s,x.deliveryDirectives,a,i),t||!d){this.loadPlaylist(f);return}}else f=this.getDeliveryDirectives(s,x.deliveryDirectives,a,i);var F=Object(S.computeReloadInterval)(s,e);a!==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 y.loadPlaylist(f)},F)}else this.clearTimer()},E.getDeliveryDirectives=function(D,x,g,y){var s=Object(m.getSkipValue)(D,g);return x!=null&&x.skip&&D.deltaUpdateFailed&&(g=x.msn,y=x.part,s=m.HlsSkip.No),new m.HlsUrlParameters(g,y,s)},E.retryLoadingOrFail=function(D){var x=this,g=this.hls.config,y=this.retryCount<g.levelLoadingMaxRetry;if(y){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)*g.levelLoadingRetryDelay,g.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return x.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 y},_}()},"./src/controller/base-stream-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"State",function(){return c}),n.d(P,"default",function(){return r});var R=n("./src/polyfills/number.ts"),m=n("./src/task-loop.ts"),S=n("./src/controller/fragment-tracker.ts"),I=n("./src/utils/buffer-helper.ts"),T=n("./src/utils/logger.ts"),b=n("./src/events.ts"),_=n("./src/errors.ts"),E=n("./src/types/transmuxer.ts"),A=n("./src/utils/mp4-tools.ts"),D=n("./src/utils/discontinuities.ts"),x=n("./src/controller/fragment-finders.ts"),g=n("./src/controller/level-helper.ts"),y=n("./src/loader/fragment-loader.ts"),s=n("./src/crypt/decrypter.ts"),e=n("./src/utils/time-ranges.ts"),o=n("./src/types/loader.ts");function f(h,d){for(var l=0;l<d.length;l++){var v=d[l];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(h,v.key,v)}}function a(h,d,l){return d&&f(h.prototype,d),l&&f(h,l),Object.defineProperty(h,"prototype",{writable:!1}),h}function i(h){if(h===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return h}function t(h,d){h.prototype=Object.create(d.prototype),h.prototype.constructor=h,u(h,d)}function u(h,d){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,p){return v.__proto__=p,v},u(h,d)}var c={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(h){t(d,h);function d(v,p,L){var O;return O=h.call(this)||this,O.hls=void 0,O.fragPrevious=null,O.fragCurrent=null,O.fragmentTracker=void 0,O.transmuxer=null,O._state=c.STOPPED,O.media=null,O.mediaBuffer=null,O.config=void 0,O.bitrateTest=!1,O.lastCurrentTime=0,O.nextLoadPosition=0,O.startPosition=0,O.loadedmetadata=!1,O.fragLoadError=0,O.retryDate=0,O.levels=null,O.fragmentLoader=void 0,O.levelLastLoaded=null,O.startFragRequested=!1,O.decrypter=void 0,O.initPTS=[],O.onvseeking=null,O.onvended=null,O.logPrefix="",O.log=void 0,O.warn=void 0,O.logPrefix=L,O.log=T.logger.log.bind(T.logger,L+":"),O.warn=T.logger.warn.bind(T.logger,L+":"),O.hls=v,O.fragmentLoader=new y.default(v.config),O.fragmentTracker=p,O.config=v.config,O.decrypter=new s.default(v,v.config),v.on(b.Events.KEY_LOADED,O.onKeyLoaded,i(O)),v.on(b.Events.LEVEL_SWITCHING,O.onLevelSwitching,i(O)),O}var l=d.prototype;return l.doTick=function(){this.onTickEnd()},l.onTickEnd=function(){},l.startLoad=function(p){},l.stopLoad=function(){this.fragmentLoader.abort();var p=this.fragCurrent;p&&this.fragmentTracker.removeFragment(p),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=c.STOPPED},l._streamEnded=function(p,L){var O=this.fragCurrent,M=this.fragmentTracker;if(!L.live&&O&&this.media&&O.sn>=L.endSN&&!p.nextStart){var F=L.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 k=M.getState(O);return k===S.FragmentState.PARTIAL||k===S.FragmentState.OK}return!1},l.onMediaAttached=function(p,L){var O=this.media=this.mediaBuffer=L.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),O.addEventListener("seeking",this.onvseeking),O.addEventListener("ended",this.onvended);var M=this.config;this.levels&&M.autoStartLoad&&this.state===c.STOPPED&&this.startLoad(M.startPosition)},l.onMediaDetaching=function(){var p=this.media;p!=null&&p.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),p&&this.onvseeking&&this.onvended&&(p.removeEventListener("seeking",this.onvseeking),p.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},l.onMediaSeeking=function(){var p=this.config,L=this.fragCurrent,O=this.media,M=this.mediaBuffer,F=this.state,w=O?O.currentTime:0,C=I.BufferHelper.bufferInfo(M||O,w,p.maxBufferHole);if(this.log("media seeking to "+(Object(R.isFiniteNumber)(w)?w.toFixed(3):w)+", state: "+F),F===c.ENDED)this.resetLoadingState();else if(L&&!C.len){var k=p.maxFragLookUpTolerance,U=L.start-k,j=L.start+L.duration+k,N=w>j;(w<U||N)&&(N&&L.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),L.loader.abort()),this.resetLoadingState())}O&&(this.lastCurrentTime=w),!this.loadedmetadata&&!C.len&&(this.nextLoadPosition=this.startPosition=w),this.tickImmediate()},l.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},l.onKeyLoaded=function(p,L){if(!(this.state!==c.KEY_LOADING||L.frag!==this.fragCurrent||!this.levels)){this.state=c.IDLE;var O=this.levels[L.frag.level].details;O&&this.loadFragment(L.frag,O,L.frag.start)}},l.onLevelSwitching=function(p,L){this.fragLoadError=0},l.onHandlerDestroying=function(){this.stopLoad(),h.prototype.onHandlerDestroying.call(this)},l.onHandlerDestroyed=function(){this.state=c.STOPPED,this.hls.off(b.Events.KEY_LOADED,this.onKeyLoaded,this),this.hls.off(b.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,h.prototype.onHandlerDestroyed.call(this)},l.loadKey=function(p,L){this.log("Loading key for "+p.sn+" of ["+L.startSN+"-"+L.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+p.level),this.state=c.KEY_LOADING,this.fragCurrent=p,this.hls.trigger(b.Events.KEY_LOADING,{frag:p})},l.loadFragment=function(p,L,O){this._loadFragForPlayback(p,L,O)},l._loadFragForPlayback=function(p,L,O){var M=this,F=function(C){if(M.fragContextChanged(p)){M.warn("Fragment "+p.sn+(C.part?" p: "+C.part.index:"")+" of level "+p.level+" was dropped during download."),M.fragmentTracker.removeFragment(p);return}p.stats.chunkCount++,M._handleFragmentLoadProgress(C)};this._doFragLoad(p,L,O,F).then(function(w){if(!!w){M.fragLoadError=0;var C=M.state;if(M.fragContextChanged(p)){(C===c.FRAG_LOADING||!M.fragCurrent&&C===c.PARSING)&&(M.fragmentTracker.removeFragment(p),M.state=c.IDLE);return}"payload"in w&&(M.log("Loaded fragment "+p.sn+" of level "+p.level),M.hls.trigger(b.Events.FRAG_LOADED,w)),M._handleFragmentLoadComplete(w)}}).catch(function(w){M.state===c.STOPPED||M.state===c.ERROR||(M.warn(w),M.resetFragmentLoading(p))})},l.flushMainBuffer=function(p,L,O){if(O===void 0&&(O=null),!!(p-L)){var M={startOffset:p,endOffset:L,type:O};this.fragLoadError=0,this.hls.trigger(b.Events.BUFFER_FLUSHING,M)}},l._loadInitSegment=function(p){var L=this;this._doFragLoad(p).then(function(O){if(!O||L.fragContextChanged(p)||!L.levels)throw new Error("init load aborted");return O}).then(function(O){var M=L.hls,F=O.payload,w=p.decryptdata;if(F&&F.byteLength>0&&w&&w.key&&w.iv&&w.method==="AES-128"){var C=self.performance.now();return L.decrypter.webCryptoDecrypt(new Uint8Array(F),w.key.buffer,w.iv.buffer).then(function(k){var U=self.performance.now();return M.trigger(b.Events.FRAG_DECRYPTED,{frag:p,payload:k,stats:{tstart:C,tdecrypt:U}}),O.payload=k,O})}return O}).then(function(O){var M=L.fragCurrent,F=L.hls,w=L.levels;if(!w)throw new Error("init load aborted, missing levels");var C=w[p.level].details;console.assert(C,"Level details are defined when init segment is loaded");var k=p.stats;L.state=c.IDLE,L.fragLoadError=0,p.data=new Uint8Array(O.payload),k.parsing.start=k.buffering.start=self.performance.now(),k.parsing.end=k.buffering.end=self.performance.now(),O.frag===M&&F.trigger(b.Events.FRAG_BUFFERED,{stats:k,frag:M,part:null,id:p.type}),L.tick()}).catch(function(O){L.state===c.STOPPED||L.state===c.ERROR||(L.warn(O),L.resetFragmentLoading(p))})},l.fragContextChanged=function(p){var L=this.fragCurrent;return!p||!L||p.level!==L.level||p.sn!==L.sn||p.urlId!==L.urlId},l.fragBufferedComplete=function(p,L){var O=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+p.type+" sn: "+p.sn+(L?" part: "+L.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+p.level+" "+(O?e.default.toString(I.BufferHelper.getBuffered(O)):"(detached)")),this.state=c.IDLE,O&&(!this.loadedmetadata&&O.buffered.length&&this.fragCurrent===this.fragPrevious&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},l.seekToStartPos=function(){},l._handleFragmentLoadComplete=function(p){var L=this.transmuxer;if(!!L){var O=p.frag,M=p.part,F=p.partsLoaded,w=!F||F.length===0||F.some(function(k){return!k}),C=new E.ChunkMetadata(O.level,O.sn,O.stats.chunkCount+1,0,M?M.index:-1,!w);L.flush(C)}},l._handleFragmentLoadProgress=function(p){},l._doFragLoad=function(p,L,O,M){var F=this;if(O===void 0&&(O=null),!this.levels)throw new Error("frag load aborted, missing levels");if(O=Math.max(p.start,O||0),this.config.lowLatencyMode&&L){var w=L.partList;if(w&&M){O>p.end&&L.fragmentHint&&(p=L.fragmentHint);var C=this.getNextPart(w,p,O);if(C>-1){var k=w[C];return this.log("Loading part sn: "+p.sn+" p: "+k.index+" cc: "+p.cc+" of playlist ["+L.startSN+"-"+L.endSN+"] parts [0-"+C+"-"+(w.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+p.level+", target: "+parseFloat(O.toFixed(3))),this.nextLoadPosition=k.start+k.duration,this.state=c.FRAG_LOADING,this.hls.trigger(b.Events.FRAG_LOADING,{frag:p,part:w[C],targetBufferTime:O}),this.doFragPartsLoad(p,w,C,M).catch(function(U){return F.handleFragLoadError(U)})}else if(!p.url||this.loadedEndOfParts(w,O))return Promise.resolve(null)}}return this.log("Loading fragment "+p.sn+" cc: "+p.cc+" "+(L?"of ["+L.startSN+"-"+L.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+p.level+", target: "+parseFloat(O.toFixed(3))),Object(R.isFiniteNumber)(p.sn)&&!this.bitrateTest&&(this.nextLoadPosition=p.start+p.duration),this.state=c.FRAG_LOADING,this.hls.trigger(b.Events.FRAG_LOADING,{frag:p,targetBufferTime:O}),this.fragmentLoader.load(p,M).catch(function(U){return F.handleFragLoadError(U)})},l.doFragPartsLoad=function(p,L,O,M){var F=this;return new Promise(function(w,C){var k=[],U=function j(N){var W=L[N];F.fragmentLoader.loadPart(p,W,M).then(function(Y){k[W.index]=Y;var K=Y.part;F.hls.trigger(b.Events.FRAG_LOADED,Y);var H=L[N+1];if(H&&H.fragment===p)j(N+1);else return w({frag:p,part:K,partsLoaded:k})}).catch(C)};U(O)})},l.handleFragLoadError=function(p){var L=p.data;return L&&L.details===_.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(L.frag,L.part):this.hls.trigger(b.Events.ERROR,L),null},l._handleTransmuxerFlush=function(p){var L=this.getCurrentContext(p);if(!L||this.state!==c.PARSING){this.fragCurrent||(this.state=c.IDLE);return}var O=L.frag,M=L.part,F=L.level,w=self.performance.now();O.stats.parsing.end=w,M&&(M.stats.parsing.end=w),this.updateLevelTiming(O,M,F,p.partial)},l.getCurrentContext=function(p){var L=this.levels,O=p.level,M=p.sn,F=p.part;if(!L||!L[O])return this.warn("Levels object was unset while buffering fragment "+M+" of level "+O+". The current chunk will not be buffered."),null;var w=L[O],C=F>-1?Object(g.getPartWith)(w,M,F):null,k=C?C.fragment:Object(g.getFragmentWithSN)(w,M,this.fragCurrent);return k?{frag:k,part:C,level:w}:null},l.bufferFragmentData=function(p,L,O,M){if(!(!p||this.state!==c.PARSING)){var F=p.data1,w=p.data2,C=F;if(F&&w&&(C=Object(A.appendUint8Array)(F,w)),!(!C||!C.length)){var k={type:p.type,frag:L,part:O,chunkMeta:M,parent:L.type,data:C};this.hls.trigger(b.Events.BUFFER_APPENDING,k),p.dropped&&p.independent&&!O&&this.flushBufferGap(L)}}},l.flushBufferGap=function(p){var L=this.media;if(!!L){if(!I.BufferHelper.isBuffered(L,L.currentTime)){this.flushMainBuffer(0,p.start);return}var O=L.currentTime,M=I.BufferHelper.bufferInfo(L,O,0),F=p.duration,w=Math.min(this.config.maxFragLookUpTolerance*2,F*.25),C=Math.max(Math.min(p.start-w,M.end-w),O+w);p.start-C>w&&this.flushMainBuffer(C,p.start)}},l.getFwdBufferInfo=function(p,L){var O=this.config,M=this.getLoadPosition();if(!Object(R.isFiniteNumber)(M))return null;var F=I.BufferHelper.bufferInfo(p,M,O.maxBufferHole);if(F.len===0&&F.nextStart!==void 0){var w=this.fragmentTracker.getBufferedFrag(M,L);if(w&&F.nextStart<w.end)return I.BufferHelper.bufferInfo(p,M,Math.max(F.nextStart,O.maxBufferHole))}return F},l.getMaxBufferLength=function(p){var L=this.config,O;return p?O=Math.max(8*L.maxBufferSize/p,L.maxBufferLength):O=L.maxBufferLength,Math.min(O,L.maxMaxBufferLength)},l.reduceMaxBufferLength=function(p){var L=this.config,O=p||L.maxBufferLength;return L.maxMaxBufferLength>=O?(L.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+L.maxMaxBufferLength+"s"),!0):!1},l.getNextFragment=function(p,L){var O=L.fragments,M=O.length;if(!M)return null;var F=this.config,w=O[0].start,C;if(L.live){var k=F.initialLiveManifestSize;if(M<k)return this.warn("Not enough fragments to start playback (have: "+M+", need: "+k+")"),null;!L.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(C=this.getInitialLiveFragment(L,O),this.startPosition=C?this.hls.liveSyncPosition||C.start:p)}else p<=w&&(C=O[0]);if(!C){var U=F.lowLatencyMode?L.partEnd:L.fragmentEnd;C=this.getFragmentAtPosition(p,U,L)}return this.mapToInitFragWhenRequired(C)},l.mapToInitFragWhenRequired=function(p){return p!=null&&p.initSegment&&!(p!=null&&p.initSegment.data)&&!this.bitrateTest?p.initSegment:p},l.getNextPart=function(p,L,O){for(var M=-1,F=!1,w=!0,C=0,k=p.length;C<k;C++){var U=p[C];if(w=w&&!U.independent,M>-1&&O<U.start)break;var j=U.loaded;!j&&(F||U.independent||w)&&U.fragment===L&&(M=C),F=j}return M},l.loadedEndOfParts=function(p,L){var O=p[p.length-1];return O&&L>O.start&&O.loaded},l.getInitialLiveFragment=function(p,L){var O=this.fragPrevious,M=null;if(O){if(p.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+O.programDateTime),M=Object(x.findFragmentByPDT)(L,O.endProgramDateTime,this.config.maxFragLookUpTolerance)),!M){var F=O.sn+1;if(F>=p.startSN&&F<=p.endSN){var w=L[F-p.startSN];O.cc===w.cc&&(M=w,this.log("Live playlist, switching playlist, load frag with next SN: "+M.sn))}M||(M=Object(x.findFragWithCC)(L,O.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?p.fragmentEnd:p.edge,p))}return M},l.getFragmentAtPosition=function(p,L,O){var M=this.config,F=this.fragPrevious,w=O.fragments,C=O.endSN,k=O.fragmentHint,U=M.maxFragLookUpTolerance,j=!!(M.lowLatencyMode&&O.partList&&k);j&&k&&!this.bitrateTest&&(w=w.concat(k),C=k.sn);var N;if(p<L){var W=p>L-U?0:U;N=Object(x.findFragmentByPTS)(F,w,p,W)}else N=w[w.length-1];if(N){var Y=N.sn-O.startSN;if(F&&N.sn===F.sn&&!j){var K=F&&N.level===F.level;if(K){var H=w[Y+1];N.sn<C&&this.fragmentTracker.getState(H)!==S.FragmentState.OK?(this.log("SN "+N.sn+" just loaded, load next one: "+H.sn),N=H):N=null}}}return N},l.synchronizeToLiveEdge=function(p){var L=this.config,O=this.media;if(!!O){var M=this.hls.liveSyncPosition,F=O.currentTime,w=p.fragments[0].start,C=p.edge,k=F>=w-L.maxFragLookUpTolerance&&F<=C;if(M!==null&&O.duration>M&&(F<M||!k)){var U=L.liveMaxLatencyDuration!==void 0?L.liveMaxLatencyDuration:L.liveMaxLatencyDurationCount*p.targetduration;(!k&&O.readyState<4||F<C-U)&&(this.loadedmetadata||(this.nextLoadPosition=M),O.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)),O.currentTime=M))}}},l.alignPlaylists=function(p,L){var O=this.levels,M=this.levelLastLoaded,F=this.fragPrevious,w=M!==null?O[M]:null,C=p.fragments.length;if(!C)return this.warn("No fragments in live playlist"),0;var k=p.fragments[0].start,U=!L,j=p.alignedSliding&&Object(R.isFiniteNumber)(k);if(U||!j&&!k){Object(D.alignStream)(F,w,p);var N=p.fragments[0].start;return this.log("Live playlist sliding: "+N.toFixed(2)+" start-sn: "+(L?L.startSN:"na")+"->"+p.startSN+" prev-sn: "+(F?F.sn:"na")+" fragments: "+C),N}return k},l.waitForCdnTuneIn=function(p){var L=3;return p.live&&p.canBlockReload&&p.partTarget&&p.tuneInGoal>Math.max(p.partHoldBack,p.partTarget*L)},l.setStartPosition=function(p,L){var O=this.startPosition;if(O<L&&(O=-1),O===-1||this.lastCurrentTime===-1){var M=p.startTimeOffset;Object(R.isFiniteNumber)(M)?(O=L+M,M<0&&(O+=p.totalduration),O=Math.min(Math.max(L,O),L+p.totalduration),this.log("Start time offset "+M+" found in playlist, adjust startPosition to "+O),this.startPosition=O):p.live?O=this.hls.liveSyncPosition||L:this.startPosition=O=0,this.lastCurrentTime=O}this.nextLoadPosition=O},l.getLoadPosition=function(){var p=this.media,L=0;return this.loadedmetadata&&p?L=p.currentTime:this.nextLoadPosition&&(L=this.nextLoadPosition),L},l.handleFragLoadAborted=function(p,L){this.transmuxer&&p.sn!=="initSegment"&&p.stats.aborted&&(this.warn("Fragment "+p.sn+(L?" part"+L.index:"")+" of level "+p.level+" was aborted"),this.resetFragmentLoading(p))},l.resetFragmentLoading=function(p){(!this.fragCurrent||!this.fragContextChanged(p)&&this.state!==c.FRAG_LOADING_WAITING_RETRY)&&(this.state=c.IDLE)},l.onFragmentOrKeyLoadError=function(p,L){if(!L.fatal){var O=L.frag;if(!(!O||O.type!==p)){var M=this.fragCurrent;console.assert(M&&O.sn===M.sn&&O.level===M.level&&O.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 "+O.sn+" of "+p+" "+O.level+" failed to load, retrying in "+w+"ms"),this.retryDate=self.performance.now()+w,this.fragLoadError++,this.state=c.FRAG_LOADING_WAITING_RETRY}else L.levelRetry?(p===o.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=c.IDLE):(T.logger.error(L.details+" reaches max retry, redispatch as fatal ..."),L.fatal=!0,this.hls.stopLoad(),this.state=c.ERROR)}}},l.afterBufferFlushed=function(p,L,O){if(!!p){var M=I.BufferHelper.getBuffered(p);this.fragmentTracker.detectEvictedFragments(L,M,O),this.state===c.ENDED&&this.resetLoadingState()}},l.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=c.IDLE},l.resetStartWhenNotLoaded=function(p){if(!this.loadedmetadata){this.startFragRequested=!1;var L=this.levels?this.levels[p].details:null;L!=null&&L.live?(this.startPosition=-1,this.setStartPosition(L,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},l.updateLevelTiming=function(p,L,O,M){var F=this,w=O.details;console.assert(!!w,"level.details must be defined");var C=Object.keys(p.elementaryStreams).reduce(function(k,U){var j=p.elementaryStreams[U];if(j){var N=j.endPTS-j.startPTS;if(N<=0)return F.warn("Could not parse fragment "+p.sn+" "+U+" duration reliably ("+N+")"),k||!1;var W=M?0:Object(g.updateFragPTSDTS)(w,p,j.startPTS,j.endPTS,j.startDTS,j.endDTS);return F.hls.trigger(b.Events.LEVEL_PTS_UPDATED,{details:w,level:O,drift:W,type:U,frag:p,start:j.startPTS,end:j.endPTS}),!0}return k},!1);C||(this.warn("Found no media in fragment "+p.sn+" of level "+O.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=c.PARSED,this.hls.trigger(b.Events.FRAG_PARSED,{frag:p,part:L})},l.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},a(d,[{key:"state",get:function(){return this._state},set:function(p){var L=this._state;L!==p&&(this._state=p,this.log(L+"->"+p))}}]),d}(m.default)},"./src/controller/buffer-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return x});var R=n("./src/polyfills/number.ts"),m=n("./src/events.ts"),S=n("./src/utils/logger.ts"),I=n("./src/errors.ts"),T=n("./src/utils/buffer-helper.ts"),b=n("./src/utils/mediasource-helper.ts"),_=n("./src/loader/fragment.ts"),E=n("./src/controller/buffer-operation-queue.ts"),A=Object(b.getMediaSource)(),D=/([ha]vc.)(?:\.[^.,]+)+/,x=function(){function g(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 o=e.hls,f=e.media,a=e.mediaSource;S.logger.log("[buffer-controller]: Media source opened"),f&&(e.updateMediaElementDuration(),o.trigger(m.Events.MEDIA_ATTACHED,{media:f})),a&&a.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=s,this._initSourceBuffer(),this.registerListeners()}var y=g.prototype;return y.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},y.destroy=function(){this.unregisterListeners(),this.details=null},y.registerListeners=function(){var e=this.hls;e.on(m.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(m.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(m.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(m.Events.BUFFER_RESET,this.onBufferReset,this),e.on(m.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(m.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(m.Events.BUFFER_EOS,this.onBufferEos,this),e.on(m.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(m.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(m.Events.FRAG_PARSED,this.onFragParsed,this),e.on(m.Events.FRAG_CHANGED,this.onFragChanged,this)},y.unregisterListeners=function(){var e=this.hls;e.off(m.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(m.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(m.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(m.Events.BUFFER_RESET,this.onBufferReset,this),e.off(m.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(m.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(m.Events.BUFFER_EOS,this.onBufferEos,this),e.off(m.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(m.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(m.Events.FRAG_PARSED,this.onFragParsed,this),e.off(m.Events.FRAG_CHANGED,this.onFragChanged,this)},y._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new E.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},y.onManifestParsed=function(e,o){var f=2;(o.audio&&!o.video||!o.altAudio)&&(f=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=f,this.details=null,S.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},y.onMediaAttaching=function(e,o){var f=this.media=o.media;if(f&&A){var a=this.mediaSource=new A;a.addEventListener("sourceopen",this._onMediaSourceOpen),a.addEventListener("sourceended",this._onMediaSourceEnded),a.addEventListener("sourceclose",this._onMediaSourceClose),f.src=self.URL.createObjectURL(a),this._objectUrl=f.src}},y.onMediaDetaching=function(){var e=this.media,o=this.mediaSource,f=this._objectUrl;if(o){if(S.logger.log("[buffer-controller]: media source detaching"),o.readyState==="open")try{o.endOfStream()}catch(a){S.logger.warn("[buffer-controller]: onMediaDetaching: "+a.message+" while calling endOfStream")}this.onBufferReset(),o.removeEventListener("sourceopen",this._onMediaSourceOpen),o.removeEventListener("sourceended",this._onMediaSourceEnded),o.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(f&&self.URL.revokeObjectURL(f),e.src===f?(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(m.Events.MEDIA_DETACHED,void 0)},y.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(o){var f=e.sourceBuffer[o];try{f&&(e.removeBufferListeners(o),e.mediaSource&&e.mediaSource.removeSourceBuffer(f),e.sourceBuffer[o]=void 0)}catch(a){S.logger.warn("[buffer-controller]: Failed to reset the "+o+" buffer",a)}}),this._initSourceBuffer()},y.onBufferCodecs=function(e,o){var f=this,a=this.getSourceBufferTypes().length;Object.keys(o).forEach(function(i){if(a){var t=f.tracks[i];if(t&&typeof t.buffer.changeType=="function"){var u=o[i],c=u.id,r=u.codec,h=u.levelCodec,d=u.container,l=u.metadata,v=(t.levelCodec||t.codec).replace(D,"$1"),p=(h||r).replace(D,"$1");if(v!==p){var L=d+";codecs="+(h||r);f.appendChangeType(i,L),S.logger.log("[buffer-controller]: switching codec "+v+" to "+p),f.tracks[i]={buffer:t.buffer,codec:r,container:d,levelCodec:h,metadata:l,id:c}}}}else f.pendingTracks[i]=o[i]}),!a&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},y.appendChangeType=function(e,o){var f=this,a=this.operationQueue,i={execute:function(){var u=f.sourceBuffer[e];u&&(S.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+o),u.changeType(o)),a.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(u){S.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",u)}};a.append(i,e)},y.onBufferAppending=function(e,o){var f=this,a=this.hls,i=this.operationQueue,t=this.tracks,u=o.data,c=o.type,r=o.frag,h=o.part,d=o.chunkMeta,l=d.buffering[c],v=self.performance.now();l.start=v;var p=r.stats.buffering,L=h?h.stats.buffering:null;p.start===0&&(p.start=v),L&&L.start===0&&(L.start=v);var O=t.audio,M=c==="audio"&&d.id===1&&(O==null?void 0:O.container)==="audio/mpeg",F={execute:function(){if(l.executeStart=self.performance.now(),M){var C=f.sourceBuffer[c];if(C){var k=r.start-C.timestampOffset;Math.abs(k)>=.1&&(S.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+r.start+" (delta: "+k+") sn: "+r.sn+")"),C.timestampOffset=r.start)}}f.appendExecutor(u,c)},onStart:function(){},onComplete:function(){var C=self.performance.now();l.executeEnd=l.end=C,p.first===0&&(p.first=C),L&&L.first===0&&(L.first=C);var k=f.sourceBuffer,U={};for(var j in k)U[j]=T.BufferHelper.getBuffered(k[j]);f.appendError=0,f.hls.trigger(m.Events.BUFFER_APPENDED,{type:c,frag:r,part:h,chunkMeta:d,parent:r.type,timeRanges:U})},onError:function(C){S.logger.error("[buffer-controller]: Error encountered while trying to append to the "+c+" SourceBuffer",C);var k={type:I.ErrorTypes.MEDIA_ERROR,parent:r.type,details:I.ErrorDetails.BUFFER_APPEND_ERROR,err:C,fatal:!1};C.code===DOMException.QUOTA_EXCEEDED_ERR?k.details=I.ErrorDetails.BUFFER_FULL_ERROR:(f.appendError++,k.details=I.ErrorDetails.BUFFER_APPEND_ERROR,f.appendError>a.config.appendErrorMaxRetry&&(S.logger.error("[buffer-controller]: Failed "+a.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),k.fatal=!0,a.stopLoad())),a.trigger(m.Events.ERROR,k)}};i.append(F,c)},y.onBufferFlushing=function(e,o){var f=this,a=this.operationQueue,i=function(u){return{execute:f.removeExecutor.bind(f,u,o.startOffset,o.endOffset),onStart:function(){},onComplete:function(){f.hls.trigger(m.Events.BUFFER_FLUSHED,{type:u})},onError:function(r){S.logger.warn("[buffer-controller]: Failed to remove from "+u+" SourceBuffer",r)}}};o.type?a.append(i(o.type),o.type):this.getSourceBufferTypes().forEach(function(t){a.append(i(t),t)})},y.onFragParsed=function(e,o){var f=this,a=o.frag,i=o.part,t=[],u=i?i.elementaryStreams:a.elementaryStreams;u[_.ElementaryStreamTypes.AUDIOVIDEO]?t.push("audiovideo"):(u[_.ElementaryStreamTypes.AUDIO]&&t.push("audio"),u[_.ElementaryStreamTypes.VIDEO]&&t.push("video"));var c=function(){var h=self.performance.now();a.stats.buffering.end=h,i&&(i.stats.buffering.end=h);var d=i?i.stats:a.stats;f.hls.trigger(m.Events.FRAG_BUFFERED,{frag:a,part:i,stats:d,id:a.type})};t.length===0&&S.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+a.type+" level: "+a.level+" sn: "+a.sn),this.blockBuffers(c,t)},y.onFragChanged=function(e,o){this.flushBackBuffer()},y.onBufferEos=function(e,o){var f=this,a=this.getSourceBufferTypes().reduce(function(i,t){var u=f.sourceBuffer[t];return(!o.type||o.type===t)&&u&&!u.ended&&(u.ended=!0,S.logger.log("[buffer-controller]: "+t+" sourceBuffer now EOS")),i&&!!(!u||u.ended)},!0);a&&this.blockBuffers(function(){var i=f.mediaSource;!i||i.readyState!=="open"||i.endOfStream()})},y.onLevelUpdated=function(e,o){var f=o.details;!f.fragments.length||(this.details=f,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},y.flushBackBuffer=function(){var e=this.hls,o=this.details,f=this.media,a=this.sourceBuffer;if(!(!f||o===null)){var i=this.getSourceBufferTypes();if(!!i.length){var t=o.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(!(!Object(R.isFiniteNumber)(t)||t<0)){var u=f.currentTime,c=o.levelTargetDuration,r=Math.max(t,c),h=Math.floor(u/c)*c-r;i.forEach(function(d){var l=a[d];if(l){var v=T.BufferHelper.getBuffered(l);v.length>0&&h>v.start(0)&&(e.trigger(m.Events.BACK_BUFFER_REACHED,{bufferEnd:h}),o.live&&e.trigger(m.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:h}),e.trigger(m.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:h,type:d}))}})}}}},y.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var e=this.details,o=this.hls,f=this.media,a=this.mediaSource,i=e.fragments[0].start+e.totalduration,t=f.duration,u=Object(R.isFiniteNumber)(a.duration)?a.duration:0;e.live&&o.config.liveDurationInfinity?(S.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),a.duration=1/0,this.updateSeekableRange(e)):(i>u&&i>t||!Object(R.isFiniteNumber)(t))&&(S.logger.log("[buffer-controller]: Updating Media Source duration to "+i.toFixed(3)),a.duration=i)}},y.updateSeekableRange=function(e){var o=this.mediaSource,f=e.fragments,a=f.length;if(a&&e.live&&o!==null&&o!==void 0&&o.setLiveSeekableRange){var i=Math.max(0,f[0].start),t=Math.max(i,i+e.totalduration);o.setLiveSeekableRange(i,t)}},y.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,o=this.operationQueue,f=this.pendingTracks,a=Object.keys(f).length;if(a&&!e||a===2){this.createSourceBuffers(f),this.pendingTracks={};var i=this.getSourceBufferTypes();if(i.length===0){this.hls.trigger(m.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){o.executeNext(t)})}},y.createSourceBuffers=function(e){var o=this.sourceBuffer,f=this.mediaSource;if(!f)throw Error("createSourceBuffers called when mediaSource was null");var a=0;for(var i in e)if(!o[i]){var t=e[i];if(!t)throw Error("source buffer exists for track "+i+", however track does not");var u=t.levelCodec||t.codec,c=t.container+";codecs="+u;S.logger.log("[buffer-controller]: creating sourceBuffer("+c+")");try{var r=o[i]=f.addSourceBuffer(c),h=i;this.addBufferListener(h,"updatestart",this._onSBUpdateStart),this.addBufferListener(h,"updateend",this._onSBUpdateEnd),this.addBufferListener(h,"error",this._onSBUpdateError),this.tracks[i]={buffer:r,codec:u,container:t.container,levelCodec:t.levelCodec,metadata:t.metadata,id:t.id},a++}catch(d){S.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+d.message),this.hls.trigger(m.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:d,mimeType:c})}}a&&this.hls.trigger(m.Events.BUFFER_CREATED,{tracks:this.tracks})},y._onSBUpdateStart=function(e){var o=this.operationQueue,f=o.current(e);f.onStart()},y._onSBUpdateEnd=function(e){var o=this.operationQueue,f=o.current(e);f.onComplete(),o.shiftAndExecuteNext(e)},y._onSBUpdateError=function(e,o){S.logger.error("[buffer-controller]: "+e+" SourceBuffer error",o),this.hls.trigger(m.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var f=this.operationQueue.current(e);f&&f.onError(o)},y.removeExecutor=function(e,o,f){var a=this.media,i=this.mediaSource,t=this.operationQueue,u=this.sourceBuffer,c=u[e];if(!a||!i||!c){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)(a.duration)?a.duration:1/0,h=Object(R.isFiniteNumber)(i.duration)?i.duration:1/0,d=Math.max(0,o),l=Math.min(f,r,h);l>d?(S.logger.log("[buffer-controller]: Removing ["+d+","+l+"] from the "+e+" SourceBuffer"),console.assert(!c.updating,e+" sourceBuffer must not be updating"),c.remove(d,l)):t.shiftAndExecuteNext(e)},y.appendExecutor=function(e,o){var f=this.operationQueue,a=this.sourceBuffer,i=a[o];if(!i){S.logger.warn("[buffer-controller]: Attempting to append to the "+o+" SourceBuffer, but it does not exist"),f.shiftAndExecuteNext(o);return}i.ended=!1,console.assert(!i.updating,o+" sourceBuffer must not be updating"),i.appendBuffer(e)},y.blockBuffers=function(e,o){var f=this;if(o===void 0&&(o=this.getSourceBufferTypes()),!o.length){S.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}var a=this.operationQueue,i=o.map(function(t){return a.appendBlocker(t)});Promise.all(i).then(function(){e(),o.forEach(function(t){var u=f.sourceBuffer[t];(!u||!u.updating)&&a.shiftAndExecuteNext(t)})})},y.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},y.addBufferListener=function(e,o,f){var a=this.sourceBuffer[e];if(!!a){var i=f.bind(this,e);this.listeners[e].push({event:o,listener:i}),a.addEventListener(o,i)}},y.removeBufferListeners=function(e){var o=this.sourceBuffer[e];!o||this.listeners[e].forEach(function(f){o.removeEventListener(f.event,f.listener)})},g}()},"./src/controller/buffer-operation-queue.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return m});var R=n("./src/utils/logger.ts"),m=function(){function S(T){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=T}var I=S.prototype;return I.append=function(b,_){var E=this.queues[_];E.push(b),E.length===1&&this.buffers[_]&&this.executeNext(_)},I.insertAbort=function(b,_){var E=this.queues[_];E.unshift(b),this.executeNext(_)},I.appendBlocker=function(b){var _,E=new Promise(function(D){_=D}),A={execute:_,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(A,b),E},I.executeNext=function(b){var _=this.buffers,E=this.queues,A=_[b],D=E[b];if(D.length){var x=D[0];try{x.execute()}catch(g){R.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),x.onError(g),(!A||!A.updating)&&(D.shift(),this.executeNext(b))}}},I.shiftAndExecuteNext=function(b){this.queues[b].shift(),this.executeNext(b)},I.current=function(b){return this.queues[b][0]},S}()},"./src/controller/cap-level-controller.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/events.ts");function m(T,b){for(var _=0;_<b.length;_++){var E=b[_];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(T,E.key,E)}}function S(T,b,_){return b&&m(T.prototype,b),_&&m(T,_),Object.defineProperty(T,"prototype",{writable:!1}),T}var I=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 b=T.prototype;return b.setStreamController=function(E){this.streamController=E},b.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},b.registerListeners=function(){var E=this.hls;E.on(R.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),E.on(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),E.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),E.on(R.Events.BUFFER_CODECS,this.onBufferCodecs,this),E.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},b.unregisterListener=function(){var E=this.hls;E.off(R.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),E.off(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),E.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),E.off(R.Events.BUFFER_CODECS,this.onBufferCodecs,this),E.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},b.onFpsDropLevelCapping=function(E,A){T.isLevelAllowed(A.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(A.droppedLevel)},b.onMediaAttaching=function(E,A){this.media=A.media instanceof HTMLVideoElement?A.media:null},b.onManifestParsed=function(E,A){var D=this.hls;this.restrictedLevels=[],this.firstLevel=A.firstLevel,D.config.capLevelToPlayerSize&&A.video&&this.startCapping()},b.onBufferCodecs=function(E,A){var D=this.hls;D.config.capLevelToPlayerSize&&A.video&&this.startCapping()},b.onMediaDetaching=function(){this.stopCapping()},b.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var E=this.hls.levels;if(E.length){var A=this.hls;A.autoLevelCapping=this.getMaxLevel(E.length-1),A.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=A.autoLevelCapping}}},b.getMaxLevel=function(E){var A=this,D=this.hls.levels;if(!D.length)return-1;var x=D.filter(function(g,y){return T.isLevelAllowed(y,A.restrictedLevels)&&y<=E});return this.clientRect=null,T.getMaxLevelByMediaSize(x,this.mediaWidth,this.mediaHeight)},b.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())},b.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},b.getDimensions=function(){if(this.clientRect)return this.clientRect;var E=this.media,A={width:0,height:0};if(E){var D=E.getBoundingClientRect();A.width=D.width,A.height=D.height,!A.width&&!A.height&&(A.width=D.right-D.left||E.width||0,A.height=D.bottom-D.top||E.height||0)}return this.clientRect=A,A},T.isLevelAllowed=function(E,A){return A===void 0&&(A=[]),A.indexOf(E)===-1},T.getMaxLevelByMediaSize=function(E,A,D){if(!E||!E.length)return-1;for(var x=function(o,f){return f?o.width!==f.width||o.height!==f.height:!0},g=E.length-1,y=0;y<E.length;y+=1){var s=E[y];if((s.width>=A||s.height>=D)&&x(s,E[y+1])){g=y;break}}return g},S(T,[{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 E=1;if(!this.hls.config.ignoreDevicePixelRatio)try{E=self.devicePixelRatio}catch{}return E}}]),T}();P.default=I},"./src/controller/cmcd-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return x});var R=n("./src/events.ts"),m=n("./src/types/cmcd.ts"),S=n("./src/utils/buffer-helper.ts"),I=n("./src/utils/logger.ts");function T(g,y){for(var s=0;s<y.length;s++){var e=y[s];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(g,e.key,e)}}function b(g,y,s){return y&&T(g.prototype,y),s&&T(g,s),Object.defineProperty(g,"prototype",{writable:!1}),g}function _(g,y){var s=typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(s)return(s=s.call(g)).next.bind(s);if(Array.isArray(g)||(s=E(g))||y&&g&&typeof g.length=="number"){s&&(g=s);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 E(g,y){if(!!g){if(typeof g=="string")return A(g,y);var s=Object.prototype.toString.call(g).slice(8,-1);if(s==="Object"&&g.constructor&&(s=g.constructor.name),s==="Map"||s==="Set")return Array.from(g);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return A(g,y)}}function A(g,y){(y==null||y>g.length)&&(y=g.length);for(var s=0,e=new Array(y);s<y;s++)e[s]=g[s];return e}function D(){return D=Object.assign?Object.assign.bind():function(g){for(var y=1;y<arguments.length;y++){var s=arguments[y];for(var e in s)Object.prototype.hasOwnProperty.call(s,e)&&(g[e]=s[e])}return g},D.apply(this,arguments)}var x=function(){function g(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(a){try{e.apply(a,{ot:m.CMCDObjectType.MANIFEST,su:!e.initialized})}catch(i){I.logger.warn("Could not generate manifest CMCD data.",i)}},this.applyFragmentData=function(a){try{var i=a.frag,t=e.hls.levels[i.level],u=e.getObjectType(i),c={d:i.duration*1e3,ot:u};(u===m.CMCDObjectType.VIDEO||u===m.CMCDObjectType.AUDIO||u==m.CMCDObjectType.MUXED)&&(c.br=t.bitrate/1e3,c.tb=e.getTopBandwidth(u)/1e3,c.bl=e.getBufferLength(u)),e.apply(a,c)}catch(r){I.logger.warn("Could not generate segment CMCD data.",r)}},this.hls=s;var o=this.config=s.config,f=o.cmcd;f!=null&&(o.pLoader=this.createPlaylistLoader(),o.fLoader=this.createFragmentLoader(),this.sid=f.sessionId||g.uuid(),this.cid=f.contentId,this.useHeaders=f.useHeaders===!0,this.registerListeners())}var y=g.prototype;return y.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)},y.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()},y.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},y.onMediaAttached=function(e,o){this.media=o.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},y.onMediaDetached=function(){!this.media||(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},y.onBufferCreated=function(e,o){var f,a;this.audioBuffer=(f=o.tracks.audio)===null||f===void 0?void 0:f.buffer,this.videoBuffer=(a=o.tracks.video)===null||a===void 0?void 0:a.buffer},y.createData=function(){var e;return{v:m.CMCDVersion,sf:m.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}},y.apply=function(e,o){o===void 0&&(o={}),D(o,this.createData());var f=o.ot===m.CMCDObjectType.INIT||o.ot===m.CMCDObjectType.VIDEO||o.ot===m.CMCDObjectType.MUXED;if(this.starved&&f&&(o.bs=!0,o.su=!0,this.starved=!1),o.su==null&&(o.su=this.buffering),this.useHeaders){var a=g.toHeaders(o);if(!Object.keys(a).length)return;e.headers||(e.headers={}),D(e.headers,a)}else{var i=g.toQuery(o);if(!i)return;e.url=g.appendQueryToUri(e.url,i)}},y.getObjectType=function(e){var o=e.type;if(o==="subtitle")return m.CMCDObjectType.TIMED_TEXT;if(e.sn==="initSegment")return m.CMCDObjectType.INIT;if(o==="audio")return m.CMCDObjectType.AUDIO;if(o==="main")return this.hls.audioTracks.length?m.CMCDObjectType.VIDEO:m.CMCDObjectType.MUXED},y.getTopBandwidth=function(e){var o=0,f,a=this.hls;if(e===m.CMCDObjectType.AUDIO)f=a.audioTracks;else{var i=a.maxAutoLevel,t=i>-1?i+1:a.levels.length;f=a.levels.slice(0,t)}for(var u=_(f),c;!(c=u()).done;){var r=c.value;r.bitrate>o&&(o=r.bitrate)}return o>0?o:NaN},y.getBufferLength=function(e){var o=this.hls.media,f=e===m.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!f||!o)return NaN;var a=S.BufferHelper.bufferInfo(f,o.currentTime,this.config.maxBufferHole);return a.len*1e3},y.createPlaylistLoader=function(){var e=this.config.pLoader,o=this.applyPlaylistData,f=e||this.config.loader;return function(){function a(t){this.loader=void 0,this.loader=new f(t)}var i=a.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(u,c,r){o(u),this.loader.load(u,c,r)},b(a,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),a}()},y.createFragmentLoader=function(){var e=this.config.fLoader,o=this.applyFragmentData,f=e||this.config.loader;return function(){function a(t){this.loader=void 0,this.loader=new f(t)}var i=a.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(u,c,r){o(u),this.loader.load(u,c,r)},b(a,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),a}()},g.uuid=function(){var e=URL.createObjectURL(new Blob),o=e.toString();return URL.revokeObjectURL(e),o.slice(o.lastIndexOf("/")+1)},g.serialize=function(e){for(var o=[],f=function(M){return!Number.isNaN(M)&&M!=null&&M!==""&&M!==!1},a=function(M){return Math.round(M)},i=function(M){return a(M/100)*100},t=function(M){return encodeURIComponent(M)},u={br:a,d:a,bl:i,dl:i,mtp:i,nor:t,rtp:i,tb:a},c=Object.keys(e||{}).sort(),r=_(c),h;!(h=r()).done;){var d=h.value,l=e[d];if(!!f(l)&&!(d==="v"&&l===1)&&!(d=="pr"&&l===1)){var v=u[d];v&&(l=v(l));var p=typeof l,L=void 0;d==="ot"||d==="sf"||d==="st"?L=d+"="+l:p==="boolean"?L=d:p==="number"?L=d+"="+l:L=d+"="+JSON.stringify(l),o.push(L)}}return o.join(",")},g.toHeaders=function(e){for(var o=Object.keys(e),f={},a=["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},u=0,c=o;u<c.length;u++){var r=c[u],h=t[r]!=null?t[r]:1;i[h][r]=e[r]}for(var d=0;d<i.length;d++){var l=g.serialize(i[d]);l&&(f["CMCD-"+a[d]]=l)}return f},g.toQuery=function(e){return"CMCD="+encodeURIComponent(g.serialize(e))},g.appendQueryToUri=function(e,o){if(!o)return e;var f=e.includes("?")?"&":"?";return""+e+f+o},g}()},"./src/controller/eme-controller.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/events.ts"),m=n("./src/errors.ts"),S=n("./src/utils/logger.ts"),I=n("./src/utils/mediakeys-helper.ts");function T(x,g){for(var y=0;y<g.length;y++){var s=g[y];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(x,s.key,s)}}function b(x,g,y){return g&&T(x.prototype,g),y&&T(x,y),Object.defineProperty(x,"prototype",{writable:!1}),x}var _=3,E=function(g,y,s){var e={audioCapabilities:[],videoCapabilities:[]};return g.forEach(function(o){e.audioCapabilities.push({contentType:'audio/mp4; codecs="'+o+'"',robustness:s.audioRobustness||""})}),y.forEach(function(o){e.videoCapabilities.push({contentType:'video/mp4; codecs="'+o+'"',robustness:s.videoRobustness||""})}),[e]},A=function(g,y,s,e){switch(g){case I.KeySystems.WIDEVINE:return E(y,s,e);default:throw new Error("Unknown key-system: "+g)}},D=function(){function x(y){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=y,this._config=y.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=x.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(s){switch(s){case I.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+s+'"')},g._attemptKeySystemAccess=function(s,e,o){var f=this,a=A(s,e,o,this._drmSystemOptions);S.logger.log("Requesting encrypted media key-system access");var i=this.requestMediaKeySystemAccess(s,a);this.mediaKeysPromise=i.then(function(t){return f._onMediaKeySystemAccessObtained(s,t)}),i.catch(function(t){S.logger.error('Failed to obtain key-system "'+s+'" access:',t)})},g._onMediaKeySystemAccessObtained=function(s,e){var o=this;S.logger.log('Access for key-system "'+s+'" obtained');var f={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:e,mediaKeySystemDomain:s};this._mediaKeysList.push(f);var a=Promise.resolve().then(function(){return e.createMediaKeys()}).then(function(i){return f.mediaKeys=i,S.logger.log('Media-keys created for key-system "'+s+'"'),o._onMediaKeysCreated(),i});return a.catch(function(i){S.logger.error("Failed to create media-keys:",i)}),a},g._onMediaKeysCreated=function(){var s=this;this._mediaKeysList.forEach(function(e){e.mediaKeysSession||(e.mediaKeysSession=e.mediaKeys.createSession(),s._onNewMediaKeySession(e.mediaKeysSession))})},g._onNewMediaKeySession=function(s){var e=this;S.logger.log("New key-system session "+s.sessionId),s.addEventListener("message",function(o){e._onKeySessionMessage(s,o.message)},!1)},g._onKeySessionMessage=function(s,e){S.logger.log("Got EME message event, creating license request"),this._requestLicense(e,function(o){S.logger.log("Received license data (length: "+(o&&o.byteLength)+"), updating key-session"),s.update(o).catch(function(f){S.logger.warn("Updating key-session failed: "+f)})})},g.onMediaEncrypted=function(s){var e=this;if(S.logger.log('Media is encrypted using "'+s.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:m.ErrorTypes.KEY_SYSTEM_ERROR,details:m.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var o=function(a){!e._media||(e._attemptSetMediaKeys(a),e._generateRequestWithPreferredKeySession(s.initDataType,s.initData))};this.mediaKeysPromise.then(o).catch(o)},g._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){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:m.ErrorTypes.KEY_SYSTEM_ERROR,details:m.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(s,e){var o=this,f=this._mediaKeysList[0];if(!f){S.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(R.Events.ERROR,{type:m.ErrorTypes.KEY_SYSTEM_ERROR,details:m.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(f.mediaKeysSessionInitialized){S.logger.warn("Key-Session already initialized but requested again");return}var a=f.mediaKeysSession;if(!a){S.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(R.Events.ERROR,{type:m.ErrorTypes.KEY_SYSTEM_ERROR,details:m.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:m.ErrorTypes.KEY_SYSTEM_ERROR,details:m.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}S.logger.log('Generating key-session request for "'+s+'" init data type'),f.mediaKeysSessionInitialized=!0,a.generateRequest(s,e).then(function(){S.logger.debug("Key-session generation succeeded")}).catch(function(i){S.logger.error("Error generating key-session request:",i),o.hls.trigger(R.Events.ERROR,{type:m.ErrorTypes.KEY_SYSTEM_ERROR,details:m.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},g._createLicenseXhr=function(s,e,o){var f=new XMLHttpRequest;f.responseType="arraybuffer",f.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,f,s,e,o);var a=this._licenseXhrSetup;if(a)try{a.call(this.hls,f,s),a=void 0}catch(i){S.logger.error(i)}try{f.readyState||f.open("POST",s,!0),a&&a.call(this.hls,f,s)}catch(i){throw new Error("issue setting up KeySystem license XHR "+i)}return f},g._onLicenseRequestReadyStageChange=function(s,e,o,f){switch(s.readyState){case 4:if(s.status===200){this._requestLicenseFailureCount=0,S.logger.log("License request succeeded");var a=s.response,i=this._licenseResponseCallback;if(i)try{a=i.call(this.hls,s,e)}catch(u){S.logger.error(u)}f(a)}else{if(S.logger.error("License Request XHR failed ("+e+"). Status: "+s.status+" ("+s.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>_){this.hls.trigger(R.Events.ERROR,{type:m.ErrorTypes.KEY_SYSTEM_ERROR,details:m.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var t=_-this._requestLicenseFailureCount+1;S.logger.warn("Retrying license request, "+t+" attempts left"),this._requestLicense(o,f)}break}},g._generateLicenseRequestChallenge=function(s,e){switch(s.mediaKeySystemDomain){case I.KeySystems.WIDEVINE:return e}throw new Error("unsupported key-system: "+s.mediaKeySystemDomain)},g._requestLicense=function(s,e){S.logger.log("Requesting content license for key-system");var o=this._mediaKeysList[0];if(!o){S.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(R.Events.ERROR,{type:m.ErrorTypes.KEY_SYSTEM_ERROR,details:m.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var f=this.getLicenseServerUrl(o.mediaKeySystemDomain),a=this._createLicenseXhr(f,s,e);S.logger.log("Sending license request to URL: "+f);var i=this._generateLicenseRequestChallenge(o,s);a.send(i)}catch(t){S.logger.error("Failure requesting DRM license: "+t),this.hls.trigger(R.Events.ERROR,{type:m.ErrorTypes.KEY_SYSTEM_ERROR,details:m.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},g.onMediaAttached=function(s,e){if(!!this._emeEnabled){var o=e.media;this._media=o,o.addEventListener("encrypted",this._onMediaEncrypted)}},g.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(o){if(o.mediaKeysSession)return o.mediaKeysSession.close().catch(function(){})})).then(function(){return s.setMediaKeys(null)}).catch(function(){}))},g.onManifestParsed=function(s,e){if(!!this._emeEnabled){var o=e.levels.map(function(a){return a.audioCodec}).filter(function(a){return!!a}),f=e.levels.map(function(a){return a.videoCodec}).filter(function(a){return!!a});this._attemptKeySystemAccess(I.KeySystems.WIDEVINE,o,f)}},b(x,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),x}();P.default=D},"./src/controller/fps-controller.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/events.ts"),m=n("./src/utils/logger.ts"),S=function(){function I(b){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=b,this.registerListeners()}var T=I.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(_,E){var A=this.hls.config;if(A.capLevelOnFPSDrop){var D=E.media instanceof self.HTMLVideoElement?E.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(_,E,A){var D=performance.now();if(E){if(this.lastTime){var x=D-this.lastTime,g=A-this.lastDroppedFrames,y=E-this.lastDecodedFrames,s=1e3*g/x,e=this.hls;if(e.trigger(R.Events.FPS_DROP,{currentDropped:g,currentDecoded:y,totalDroppedFrames:A}),s>0&&g>e.config.fpsDroppedMonitoringThreshold*y){var o=e.currentLevel;m.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+o),o>0&&(e.autoLevelCapping===-1||e.autoLevelCapping>=o)&&(o=o-1,e.trigger(R.Events.FPS_DROP_LEVEL_CAPPING,{level:o,droppedLevel:e.currentLevel}),e.autoLevelCapping=o,this.streamController.nextLevelSwitch())}}this.lastTime=D,this.lastDroppedFrames=A,this.lastDecodedFrames=E}},T.checkFPSInterval=function(){var _=this.media;if(_)if(this.isVideoPlaybackQualityAvailable){var E=_.getVideoPlaybackQuality();this.checkFPS(_,E.totalVideoFrames,E.droppedVideoFrames)}else this.checkFPS(_,_.webkitDecodedFrameCount,_.webkitDroppedFrameCount)},I}();P.default=S},"./src/controller/fragment-finders.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"findFragmentByPDT",function(){return S}),n.d(P,"findFragmentByPTS",function(){return I}),n.d(P,"fragmentWithinToleranceTest",function(){return T}),n.d(P,"pdtWithinToleranceTest",function(){return b}),n.d(P,"findFragWithCC",function(){return _});var R=n("./src/polyfills/number.ts"),m=n("./src/utils/binary-search.ts");function S(E,A,D){if(A===null||!Array.isArray(E)||!E.length||!Object(R.isFiniteNumber)(A))return null;var x=E[0].programDateTime;if(A<(x||0))return null;var g=E[E.length-1].endProgramDateTime;if(A>=(g||0))return null;D=D||0;for(var y=0;y<E.length;++y){var s=E[y];if(b(A,D,s))return s}return null}function I(E,A,D,x){D===void 0&&(D=0),x===void 0&&(x=0);var g=null;if(E?g=A[E.sn-A[0].sn+1]||null:D===0&&A[0].start===0&&(g=A[0]),g&&T(D,x,g)===0)return g;var y=m.default.search(A,T.bind(null,D,x));return y||g}function T(E,A,D){E===void 0&&(E=0),A===void 0&&(A=0);var x=Math.min(A,D.duration+(D.deltaPTS?D.deltaPTS:0));return D.start+D.duration-x<=E?1:D.start-x>E&&D.start?-1:0}function b(E,A,D){var x=Math.min(A,D.duration+(D.deltaPTS?D.deltaPTS:0))*1e3,g=D.endProgramDateTime||0;return g-x>E}function _(E,A){return m.default.search(E,function(D){return D.cc<A?1:D.cc>A?-1:0})}},"./src/controller/fragment-tracker.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"FragmentState",function(){return S}),n.d(P,"FragmentTracker",function(){return I});var R=n("./src/events.ts"),m=n("./src/types/loader.ts"),S;(function(_){_.NOT_LOADED="NOT_LOADED",_.APPENDING="APPENDING",_.PARTIAL="PARTIAL",_.OK="OK"})(S||(S={}));var I=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 E=_.prototype;return E._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)},E._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)},E.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},E.getAppendedFrag=function(D,x){if(x===m.PlaylistLevelType.MAIN){var g=this.activeFragment,y=this.activeParts;if(!g)return null;if(y)for(var s=y.length;s--;){var e=y[s],o=e?e.end:g.appendedPTS;if(e.start<=D&&o!==void 0&&D<=o)return s>9&&(this.activeParts=y.slice(s-9)),e}else if(g.start<=D&&g.appendedPTS!==void 0&&D<=g.appendedPTS)return g}return this.getBufferedFrag(D,x)},E.getBufferedFrag=function(D,x){for(var g=this.fragments,y=Object.keys(g),s=y.length;s--;){var e=g[y[s]];if((e==null?void 0:e.body.type)===x&&e.buffered){var o=e.body;if(o.start<=D&&D<=o.end)return o}}return null},E.detectEvictedFragments=function(D,x,g){var y=this;Object.keys(this.fragments).forEach(function(s){var e=y.fragments[s];if(!!e){if(!e.buffered){e.body.type===g&&y.removeFragment(e.body);return}var o=e.range[D];!o||o.time.some(function(f){var a=!y.isTimeBuffered(f.startPTS,f.endPTS,x);return a&&y.removeFragment(e.body),a})}})},E.detectPartialFragments=function(D){var x=this,g=this.timeRanges,y=D.frag,s=D.part;if(!(!g||y.sn==="initSegment")){var e=b(y),o=this.fragments[e];!o||(Object.keys(g).forEach(function(f){var a=y.elementaryStreams[f];if(!!a){var i=g[f],t=s!==null||a.partial===!0;o.range[f]=x.getBufferedTimes(y,s,t,i)}}),o.loaded=null,Object.keys(o.range).length?o.buffered=!0:this.removeFragment(o.body))}},E.fragBuffered=function(D){var x=b(D),g=this.fragments[x];g&&(g.loaded=null,g.buffered=!0)},E.getBufferedTimes=function(D,x,g,y){for(var s={time:[],partial:g},e=x?x.start:D.start,o=x?x.end:D.end,f=D.minEndPTS||o,a=D.maxStartPTS||e,i=0;i<y.length;i++){var t=y.start(i)-this.bufferPadding,u=y.end(i)+this.bufferPadding;if(a>=t&&f<=u){s.time.push({startPTS:Math.max(e,y.start(i)),endPTS:Math.min(o,y.end(i))});break}else if(e<u&&o>t)s.partial=!0,s.time.push({startPTS:Math.max(e,y.start(i)),endPTS:Math.min(o,y.end(i))});else if(o<=t)break}return s},E.getPartialFragment=function(D){var x=null,g,y,s,e=0,o=this.bufferPadding,f=this.fragments;return Object.keys(f).forEach(function(a){var i=f[a];!i||T(i)&&(y=i.body.start-o,s=i.body.end+o,D>=y&&D<=s&&(g=Math.min(D-y,s-D),e<=g&&(x=i.body,e=g)))}),x},E.getState=function(D){var x=b(D),g=this.fragments[x];return g?g.buffered?T(g)?S.PARTIAL:S.OK:S.APPENDING:S.NOT_LOADED},E.isTimeBuffered=function(D,x,g){for(var y,s,e=0;e<g.length;e++){if(y=g.start(e)-this.bufferPadding,s=g.end(e)+this.bufferPadding,D>=y&&x<=s)return!0;if(x<=y)return!1}return!1},E.onFragLoaded=function(D,x){var g=x.frag,y=x.part;if(!(g.sn==="initSegment"||g.bitrateTest||y)){var s=b(g);this.fragments[s]={body:g,loaded:x,buffered:!1,range:Object.create(null)}}},E.onBufferAppended=function(D,x){var g=this,y=x.frag,s=x.part,e=x.timeRanges;if(y.type===m.PlaylistLevelType.MAIN)if(this.activeFragment=y,s){var o=this.activeParts;o||(this.activeParts=o=[]),o.push(s)}else this.activeParts=null;this.timeRanges=e,Object.keys(e).forEach(function(f){var a=e[f];if(g.detectEvictedFragments(f,a),!s)for(var i=0;i<a.length;i++)y.appendedPTS=Math.max(a.end(i),y.appendedPTS||0)})},E.onFragBuffered=function(D,x){this.detectPartialFragments(x)},E.hasFragment=function(D){var x=b(D);return!!this.fragments[x]},E.removeFragmentsInRange=function(D,x,g){var y=this;Object.keys(this.fragments).forEach(function(s){var e=y.fragments[s];if(!!e&&e.buffered){var o=e.body;o.type===g&&o.start<x&&o.end>D&&y.removeFragment(o)}})},E.removeFragment=function(D){var x=b(D);D.stats.loaded=0,D.clearElementaryStreamInfo(),delete this.fragments[x]},E.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},_}();function T(_){var E,A;return _.buffered&&(((E=_.range.video)===null||E===void 0?void 0:E.partial)||((A=_.range.audio)===null||A===void 0?void 0:A.partial))}function b(_){return _.type+"_"+_.level+"_"+_.urlId+"_"+_.sn}},"./src/controller/gap-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"STALL_MINIMUM_DURATION_MS",function(){return T}),n.d(P,"MAX_START_GAP_JUMP",function(){return b}),n.d(P,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return _}),n.d(P,"SKIP_BUFFER_RANGE_START",function(){return E}),n.d(P,"default",function(){return A});var R=n("./src/utils/buffer-helper.ts"),m=n("./src/errors.ts"),S=n("./src/events.ts"),I=n("./src/utils/logger.ts"),T=250,b=2,_=.1,E=.05,A=function(){function D(g,y,s,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=y,this.fragmentTracker=s,this.hls=e}var x=D.prototype;return x.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},x.poll=function(y,s){var e=this.config,o=this.media,f=this.stalled;if(o!==null){var a=o.currentTime,i=o.seeking,t=this.seeking&&!i,u=!this.seeking&&i;if(this.seeking=i,a!==y){if(this.moved=!0,f!==null){if(this.stallReported){var c=self.performance.now()-f;I.logger.warn("playback not stuck anymore @"+a+", after "+Math.round(c)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((u||t)&&(this.stalled=null),!(o.paused&&!i||o.ended||o.playbackRate===0||!R.BufferHelper.getBuffered(o).length)){var r=R.BufferHelper.bufferInfo(o,a,0),h=r.len>0,d=r.nextStart||0;if(!(!h&&!d)){if(i){var l=r.len>b,v=!d||s&&s.start<=a||d-a>b&&!this.fragmentTracker.getPartialFragment(a);if(l||v)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var p,L=Math.max(d,r.start||0)-a,O=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,M=O==null||(p=O.details)===null||p===void 0?void 0:p.live,F=M?O.details.targetduration*2:b;if(L>0&&L<=F){this._trySkipBufferHole(null);return}}var w=self.performance.now();if(f===null){this.stalled=w;return}var C=w-f;if(!(!i&&C>=T&&(this._reportStall(r),!this.media))){var k=R.BufferHelper.bufferInfo(o,a,e.maxBufferHole);this._tryFixBufferStall(k,C)}}}}},x._tryFixBufferStall=function(y,s){var e=this.config,o=this.fragmentTracker,f=this.media;if(f!==null){var a=f.currentTime,i=o.getPartialFragment(a);if(i){var t=this._trySkipBufferHole(i);if(t||!this.media)return}y.len>e.maxBufferHole&&s>e.highBufferWatchdogPeriod*1e3&&(I.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},x._reportStall=function(y){var s=this.hls,e=this.media,o=this.stallReported;!o&&e&&(this.stallReported=!0,I.logger.warn("Playback stalling at @"+e.currentTime+" due to low buffer ("+JSON.stringify(y)+")"),s.trigger(S.Events.ERROR,{type:m.ErrorTypes.MEDIA_ERROR,details:m.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:y.len}))},x._trySkipBufferHole=function(y){var s=this.config,e=this.hls,o=this.media;if(o===null)return 0;for(var f=o.currentTime,a=0,i=R.BufferHelper.getBuffered(o),t=0;t<i.length;t++){var u=i.start(t);if(f+s.maxBufferHole>=a&&f<u){var c=Math.max(u+E,o.currentTime+_);return I.logger.warn("skipping hole, adjusting currentTime from "+f+" to "+c),this.moved=!0,this.stalled=null,o.currentTime=c,y&&e.trigger(S.Events.ERROR,{type:m.ErrorTypes.MEDIA_ERROR,details:m.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+f+" to "+c,frag:y}),c}a=i.end(t)}return 0},x._tryNudgeBuffer=function(){var y=this.config,s=this.hls,e=this.media,o=this.nudgeRetry;if(e!==null){var f=e.currentTime;if(this.nudgeRetry++,o<y.nudgeMaxRetry){var a=f+(o+1)*y.nudgeOffset;I.logger.warn("Nudging 'currentTime' from "+f+" to "+a),e.currentTime=a,s.trigger(S.Events.ERROR,{type:m.ErrorTypes.MEDIA_ERROR,details:m.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else I.logger.error("Playhead still not moving while enough data buffered @"+f+" after "+y.nudgeMaxRetry+" nudges"),s.trigger(S.Events.ERROR,{type:m.ErrorTypes.MEDIA_ERROR,details:m.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},D}()},"./src/controller/id3-track-controller.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/polyfills/number.ts"),m=n("./src/events.ts"),S=n("./src/utils/texttrack-utils.ts"),I=n("./src/demux/id3.ts"),T=n("./src/loader/date-range.ts"),b=n("./src/types/demuxer.ts"),_=.25;function E(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}function A(g,y){return g.getTime()/1e3-y}function D(g){return Uint8Array.from(g.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var x=function(){function g(s){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=s,this._registerListeners()}var y=g.prototype;return y.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},y._registerListeners=function(){var e=this.hls;e.on(m.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(m.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(m.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(m.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(m.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},y._unregisterListeners=function(){var e=this.hls;e.off(m.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(m.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(m.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(m.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(m.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},y.onMediaAttached=function(e,o){this.media=o.media},y.onMediaDetaching=function(){!this.id3Track||(Object(S.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},y.onManifestLoading=function(){this.dateRangeCuesAppended={}},y.createTrack=function(e){var o=this.getID3Track(e.textTracks);return o.mode="hidden",o},y.getID3Track=function(e){if(!!this.media){for(var o=0;o<e.length;o++){var f=e[o];if(f.kind==="metadata"&&f.label==="id3")return Object(S.sendAddTrackEvent)(f,this.media),f}return this.media.addTextTrack("metadata","id3")}},y.onFragParsingMetadata=function(e,o){if(!!this.media){var f=this.hls.config,a=f.enableEmsgMetadataCues,i=f.enableID3MetadataCues;if(!(!a&&!i)){var t=o.frag,u=o.samples,c=o.details;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var r=c.edge||t.end,h=E(),d=!1,l={},v=0;v<u.length;v++){var p=u[v].type;if(!(p===b.MetadataSchema.emsg&&!a||!i)){var L=I.getID3Frames(u[v].data);if(L){var O=u[v].pts,M=r,F=M-O;F<=0&&(M=O+_);for(var w=0;w<L.length;w++){var C=L[w];if(!I.isTimeStampFrame(C)){var k=new h(O,M,"");k.value=C,p&&(k.type=p),this.id3Track.addCue(k),l[C.key]=null,d=!0}}}}}d&&this.updateId3CueEnds(l)}}},y.updateId3CueEnds=function(e){var o,f=(o=this.id3Track)===null||o===void 0?void 0:o.cues;if(f)for(var a=f.length;a--;){var i,t=f[a],u=(i=t.value)===null||i===void 0?void 0:i.key;if(u&&u in e){var c=e[u];c&&t.endTime!==c&&(t.endTime=c),e[u]=t.startTime}}},y.onBufferFlushing=function(e,o){var f=o.startOffset,a=o.endOffset,i=o.type,t=this.id3Track,u=this.hls;if(!!u){var c=u.config,r=c.enableEmsgMetadataCues,h=c.enableID3MetadataCues;if(t&&(r||h)){var d;i==="audio"?d=function(v){return v.type===b.MetadataSchema.audioId3&&h}:i==="video"?d=function(v){return v.type===b.MetadataSchema.emsg&&r}:d=function(v){return v.type===b.MetadataSchema.audioId3&&h||v.type===b.MetadataSchema.emsg&&r},Object(S.removeCuesInRange)(t,f,a,d)}}},y.onLevelUpdated=function(e,o){var f=this,a=o.details;if(!(!this.media||!a.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var i=this.dateRangeCuesAppended,t=this.id3Track,u=a.dateRanges,c=Object.keys(u);if(t)for(var r=Object.keys(i).filter(function(F){return!c.includes(F)}),h=function(w){var C=r[w];Object.keys(i[C].cues).forEach(function(k){t.removeCue(i[C].cues[k])}),delete i[C]},d=r.length;d--;)h(d);var l=a.fragments[a.fragments.length-1];if(!(c.length===0||!Object(R.isFiniteNumber)(l==null?void 0:l.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var v=l.programDateTime/1e3-l.start,p=a.edge||l.end,L=E(),O=function(w){var C=c[w],k=u[C],U=i[C],j=(U==null?void 0:U.cues)||{},N=(U==null?void 0:U.durationKnown)||!1,W=A(k.startDate,v),Y=p,K=k.endDate;if(K)Y=A(K,v),N=!0;else if(k.endOnNext&&!N){var H=c.reduce(function(Q,ae){var se=u[ae];return se.class===k.class&&se.id!==ae&&se.startDate>k.startDate&&Q.push(se),Q},[]).sort(function(Q,ae){return Q.startDate.getTime()-ae.startDate.getTime()})[0];H&&(Y=A(H.startDate,v),N=!0)}for(var z=Object.keys(k.attr),$=0;$<z.length;$++){var X=z[$];if(!(X===T.DateRangeAttribute.ID||X===T.DateRangeAttribute.CLASS||X===T.DateRangeAttribute.START_DATE||X===T.DateRangeAttribute.DURATION||X===T.DateRangeAttribute.END_DATE||X===T.DateRangeAttribute.END_ON_NEXT)){var J=j[X];if(J)N&&!U.durationKnown&&(J.endTime=Y);else{var te=k.attr[X];J=new L(W,Y,""),(X===T.DateRangeAttribute.SCTE35_OUT||X===T.DateRangeAttribute.SCTE35_IN)&&(te=D(te)),J.value={key:X,data:te},J.type=b.MetadataSchema.dateRange,f.id3Track.addCue(J),j[X]=J}}}i[C]={cues:j,dateRange:k,durationKnown:N}},M=0;M<c.length;M++)O(M)}}},g}();P.default=x},"./src/controller/latency-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return b});var R=n("./src/errors.ts"),m=n("./src/events.ts"),S=n("./src/utils/logger.ts");function I(_,E){for(var A=0;A<E.length;A++){var D=E[A];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(_,D.key,D)}}function T(_,E,A){return E&&I(_.prototype,E),A&&I(_,A),Object.defineProperty(_,"prototype",{writable:!1}),_}var b=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 E=_.prototype;return E.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},E.registerListeners=function(){this.hls.on(m.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(m.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(m.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(m.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(m.Events.ERROR,this.onError,this)},E.unregisterListeners=function(){this.hls.off(m.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(m.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(m.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(m.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(m.Events.ERROR,this.onError)},E.onMediaAttached=function(D,x){this.media=x.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},E.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},E.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},E.onLevelUpdated=function(D,x){var g=x.details;this.levelDetails=g,g.advanced&&this.timeupdate(),!g.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},E.onError=function(D,x){x.details===R.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,S.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},E.timeupdate=function(){var D=this.media,x=this.levelDetails;if(!(!D||!x)){this.currentTime=D.currentTime;var g=this.computeLatency();if(g!==null){this._latency=g;var y=this.config,s=y.lowLatencyMode,e=y.maxLiveSyncPlaybackRate;if(!(!s||e===1)){var o=this.targetLatency;if(o!==null){var f=g-o,a=Math.min(this.maxLatency,o+x.targetduration),i=f<a;if(x.live&&i&&f>.05&&this.forwardBufferLength>1){var t=Math.min(2,Math.max(1,e)),u=Math.round(2/(1+Math.exp(-.75*f-this.edgeStalled))*20)/20;D.playbackRate=Math.min(t,Math.max(1,u))}else D.playbackRate!==1&&D.playbackRate!==0&&(D.playbackRate=1)}}}}},E.estimateLiveEdge=function(){var D=this.levelDetails;return D===null?null:D.edge+D.age},E.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,x=this.levelDetails;return D.liveMaxLatencyDuration!==void 0?D.liveMaxLatencyDuration:x?D.liveMaxLatencyDurationCount*x.targetduration:0}},{key:"targetLatency",get:function(){var D=this.levelDetails;if(D===null)return null;var x=D.holdBack,g=D.partHoldBack,y=D.targetduration,s=this.config,e=s.liveSyncDuration,o=s.liveSyncDurationCount,f=s.lowLatencyMode,a=this.hls.userConfig,i=f&&g||x;(a.liveSyncDuration||a.liveSyncDurationCount||i===0)&&(i=e!==void 0?e:o*y);var t=y,u=1;return i+Math.min(this.stallCount*u,t)}},{key:"liveSyncPosition",get:function(){var D=this.estimateLiveEdge(),x=this.targetLatency,g=this.levelDetails;if(D===null||x===null||g===null)return null;var y=g.edge,s=D-x-this.edgeStalled,e=y-g.totalduration,o=y-(this.config.lowLatencyMode&&g.partTarget||g.targetduration);return Math.min(Math.max(e,s),o)}},{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 x=(this.config.lowLatencyMode&&D.partTarget||D.targetduration)*3;return Math.max(D.age-x,0)}},{key:"forwardBufferLength",get:function(){var D=this.media,x=this.levelDetails;if(!D||!x)return 0;var g=D.buffered.length;return(g?D.buffered.end(g-1):x.edge)-this.currentTime}}]),_}()},"./src/controller/level-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return s});var R=n("./src/types/level.ts"),m=n("./src/events.ts"),S=n("./src/errors.ts"),I=n("./src/utils/codecs.ts"),T=n("./src/controller/level-helper.ts"),b=n("./src/controller/base-playlist-controller.ts"),_=n("./src/types/loader.ts");function E(){return E=Object.assign?Object.assign.bind():function(e){for(var o=1;o<arguments.length;o++){var f=arguments[o];for(var a in f)Object.prototype.hasOwnProperty.call(f,a)&&(e[a]=f[a])}return e},E.apply(this,arguments)}function A(e,o){for(var f=0;f<o.length;f++){var a=o[f];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function D(e,o,f){return o&&A(e.prototype,o),f&&A(e,f),Object.defineProperty(e,"prototype",{writable:!1}),e}function x(e,o){e.prototype=Object.create(o.prototype),e.prototype.constructor=e,g(e,o)}function g(e,o){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,i){return a.__proto__=i,a},g(e,o)}var y=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),s=function(e){x(o,e);function o(a){var i;return i=e.call(this,a,"[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 f=o.prototype;return f._registerListeners=function(){var i=this.hls;i.on(m.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.on(m.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.on(m.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.on(m.Events.FRAG_LOADED,this.onFragLoaded,this),i.on(m.Events.ERROR,this.onError,this)},f._unregisterListeners=function(){var i=this.hls;i.off(m.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.off(m.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.off(m.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.off(m.Events.FRAG_LOADED,this.onFragLoaded,this),i.off(m.Events.ERROR,this.onError,this)},f.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,e.prototype.destroy.call(this)},f.startLoad=function(){var i=this._levels;i.forEach(function(t){t.loadError=0}),e.prototype.startLoad.call(this)},f.onManifestLoaded=function(i,t){var u=[],c=[],r=[],h,d={},l,v=!1,p=!1,L=!1;if(t.levels.forEach(function(w){var C=w.attrs;v=v||!!(w.width&&w.height),p=p||!!w.videoCodec,L=L||!!w.audioCodec,y&&w.audioCodec&&w.audioCodec.indexOf("mp4a.40.34")!==-1&&(w.audioCodec=void 0);var k=w.bitrate+"-"+w.attrs.RESOLUTION+"-"+w.attrs.CODECS;l=d[k],l?l.url.push(w.url):(l=new R.Level(w),d[k]=l,u.push(l)),C&&(C.AUDIO&&Object(T.addGroupId)(l,"audio",C.AUDIO),C.SUBTITLES&&Object(T.addGroupId)(l,"text",C.SUBTITLES))}),(v||p)&&L&&(u=u.filter(function(w){var C=w.videoCodec,k=w.width,U=w.height;return!!C||!!(k&&U)})),u=u.filter(function(w){var C=w.audioCodec,k=w.videoCodec;return(!C||Object(I.isCodecSupportedInMp4)(C,"audio"))&&(!k||Object(I.isCodecSupportedInMp4)(k,"video"))}),t.audioTracks&&(c=t.audioTracks.filter(function(w){return!w.audioCodec||Object(I.isCodecSupportedInMp4)(w.audioCodec,"audio")}),Object(T.assignTrackIdsByGroup)(c)),t.subtitles&&(r=t.subtitles,Object(T.assignTrackIdsByGroup)(r)),u.length>0){h=u[0].bitrate,u.sort(function(w,C){return w.bitrate-C.bitrate}),this._levels=u;for(var O=0;O<u.length;O++)if(u[O].bitrate===h){this._firstLevel=O,this.log("manifest loaded, "+u.length+" level(s) found, first bitrate: "+h);break}var M=L&&!p,F={levels:u,audioTracks:c,subtitleTracks:r,firstLevel:this._firstLevel,stats:t.stats,audio:L,video:p,altAudio:!M&&c.some(function(w){return!!w.url})};this.hls.trigger(m.Events.MANIFEST_PARSED,F),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(m.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"})},f.onError=function(i,t){var u;if(e.prototype.onError.call(this,i,t),!t.fatal){var c=t.context,r=this._levels[this.currentLevelIndex];if(c&&(c.type===_.PlaylistContextType.AUDIO_TRACK&&r.audioGroupIds&&c.groupId===r.audioGroupIds[r.urlId]||c.type===_.PlaylistContextType.SUBTITLE_TRACK&&r.textGroupIds&&c.groupId===r.textGroupIds[r.urlId])){this.redundantFailover(this.currentLevelIndex);return}var h=!1,d=!0,l;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===_.PlaylistLevelType.MAIN?t.frag.level:this.currentLevelIndex,p=this._levels[v];p?(p.fragmentError++,p.fragmentError>this.hls.config.fragLoadingMaxRetry&&(l=v)):l=v}break;case S.ErrorDetails.LEVEL_LOAD_ERROR:case S.ErrorDetails.LEVEL_LOAD_TIMEOUT:c&&(c.deliveryDirectives&&(d=!1),l=c.level),h=!0;break;case S.ErrorDetails.REMUX_ALLOC_ERROR:l=(u=t.level)!=null?u:this.currentLevelIndex,h=!0;break}l!==void 0&&this.recoverLevel(t,l,h,d)}},f.recoverLevel=function(i,t,u,c){var r=i.details,h=this._levels[t];if(h.loadError++,u){var d=this.retryLoadingOrFail(i);if(d)i.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(c){var l=h.url.length;if(l>1&&h.loadError<l)i.levelRetry=!0,this.redundantFailover(t);else if(this.manualLevelIndex===-1){for(var v=-1,p=this._levels,L=p.length;L--;){var O=(L+this.currentLevelIndex)%p.length;if(O!==this.currentLevelIndex&&p[O].loadError===0){v=O;break}}v>-1&&this.currentLevelIndex!==v&&(this.warn(r+": switch to "+v),i.levelRetry=!0,this.hls.nextAutoLevel=v)}}},f.redundantFailover=function(i){var t=this._levels[i],u=t.url.length;if(u>1){var c=(t.urlId+1)%u;this.warn("Switching to redundant URL-id "+c),this._levels.forEach(function(r){r.urlId=c}),this.level=i}},f.onFragLoaded=function(i,t){var u=t.frag;if(u!==void 0&&u.type===_.PlaylistLevelType.MAIN){var c=this._levels[u.level];c!==void 0&&(c.fragmentError=0,c.loadError=0)}},f.onLevelLoaded=function(i,t){var u,c=t.level,r=t.details,h=this._levels[c];if(!h){var d;this.warn("Invalid level index "+c),(d=t.deliveryDirectives)!==null&&d!==void 0&&d.skip&&(r.deltaUpdateFailed=!0);return}c===this.currentLevelIndex?(h.fragmentError===0&&(h.loadError=0,this.retryCount=0),this.playlistLoaded(c,t,h.details)):(u=t.deliveryDirectives)!==null&&u!==void 0&&u.skip&&(r.deltaUpdateFailed=!0)},f.onAudioTrackSwitched=function(i,t){var u=this.hls.levels[this.currentLevelIndex];if(!!u&&u.audioGroupIds){for(var c=-1,r=this.hls.audioTracks[t.id].groupId,h=0;h<u.audioGroupIds.length;h++)if(u.audioGroupIds[h]===r){c=h;break}c!==u.urlId&&(u.urlId=c,this.startLoad())}},f.loadPlaylist=function(i){var t=this.currentLevelIndex,u=this._levels[t];if(this.canLoad&&u&&u.url.length>0){var c=u.urlId,r=u.url[c];if(i)try{r=i.addDirectives(r)}catch(h){this.warn("Could not construct new URL with HLS Delivery Directives: "+h)}this.log("Attempt loading level index "+t+(i?" at sn "+i.msn+" part "+i.part:"")+" with URL-id "+c+" "+r),this.clearTimer(),this.hls.trigger(m.Events.LEVEL_LOADING,{url:r,level:t,id:c,deliveryDirectives:i||null})}},f.removeLevel=function(i,t){var u=function(h,d){return d!==t},c=this._levels.filter(function(r,h){return h!==i?!0:r.url.length>1&&t!==void 0?(r.url=r.url.filter(u),r.audioGroupIds&&(r.audioGroupIds=r.audioGroupIds.filter(u)),r.textGroupIds&&(r.textGroupIds=r.textGroupIds.filter(u)),r.urlId=0,!0):!1}).map(function(r,h){var d=r.details;return d!=null&&d.fragments&&d.fragments.forEach(function(l){l.level=h}),r});this._levels=c,this.hls.trigger(m.Events.LEVELS_UPDATED,{levels:c})},D(o,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(i){var t,u=this._levels;if(u.length!==0&&!(this.currentLevelIndex===i&&(t=u[i])!==null&&t!==void 0&&t.details)){if(i<0||i>=u.length){var c=i<0;if(this.hls.trigger(m.Events.ERROR,{type:S.ErrorTypes.OTHER_ERROR,details:S.ErrorDetails.LEVEL_SWITCH_ERROR,level:i,fatal:c,reason:"invalid level idx"}),c)return;i=Math.min(i,u.length-1)}this.clearTimer();var r=this.currentLevelIndex,h=u[r],d=u[i];this.log("switching to level "+i+" from "+r),this.currentLevelIndex=i;var l=E({},d,{level:i,maxBitrate:d.maxBitrate,uri:d.uri,urlId:d.urlId});delete l._urlId,this.hls.trigger(m.Events.LEVEL_SWITCHING,l);var v=d.details;if(!v||v.live){var p=this.switchParams(d.uri,h==null?void 0:h.details);this.loadPlaylist(p)}}}},{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)}}]),o}(b.default)},"./src/controller/level-helper.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"addGroupId",function(){return T}),n.d(P,"assignTrackIdsByGroup",function(){return b}),n.d(P,"updatePTS",function(){return _}),n.d(P,"updateFragPTSDTS",function(){return A}),n.d(P,"mergeDetails",function(){return D}),n.d(P,"mapPartIntersection",function(){return g}),n.d(P,"mapFragmentIntersection",function(){return y}),n.d(P,"adjustSliding",function(){return s}),n.d(P,"addSliding",function(){return e}),n.d(P,"computeReloadInterval",function(){return o}),n.d(P,"getFragmentWithSN",function(){return f}),n.d(P,"getPartWith",function(){return a});var R=n("./src/polyfills/number.ts"),m=n("./src/utils/logger.ts"),S=n("./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 u=arguments[t];for(var c in u)Object.prototype.hasOwnProperty.call(u,c)&&(i[c]=u[c])}return i},I.apply(this,arguments)}function T(i,t,u){switch(t){case"audio":i.audioGroupIds||(i.audioGroupIds=[]),i.audioGroupIds.push(u);break;case"text":i.textGroupIds||(i.textGroupIds=[]),i.textGroupIds.push(u);break}}function b(i){var t={};i.forEach(function(u){var c=u.groupId||"";u.id=t[c]=t[c]||0,t[c]++})}function _(i,t,u){var c=i[t],r=i[u];E(c,r)}function E(i,t){var u=t.startPTS;if(Object(R.isFiniteNumber)(u)){var c=0,r;t.sn>i.sn?(c=u-i.start,r=i):(c=i.start-u,r=t),r.duration!==c&&(r.duration=c)}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 A(i,t,u,c,r,h){var d=c-u;d<=0&&(m.logger.warn("Fragment should have a positive duration",t),c=u+t.duration,h=r+t.duration);var l=u,v=c,p=t.startPTS,L=t.endPTS;if(Object(R.isFiniteNumber)(p)){var O=Math.abs(p-u);Object(R.isFiniteNumber)(t.deltaPTS)?t.deltaPTS=Math.max(O,t.deltaPTS):t.deltaPTS=O,l=Math.max(u,p),u=Math.min(u,p),r=Math.min(r,t.startDTS),v=Math.min(c,L),c=Math.max(c,L),h=Math.max(h,t.endDTS)}t.duration=c-u;var M=u-t.start;t.appendedPTS=c,t.start=t.startPTS=u,t.maxStartPTS=l,t.startDTS=r,t.endPTS=c,t.minEndPTS=v,t.endDTS=h;var F=t.sn;if(!i||F<i.startSN||F>i.endSN)return 0;var w,C=F-i.startSN,k=i.fragments;for(k[C]=t,w=C;w>0;w--)E(k[w],k[w-1]);for(w=C;w<k.length-1;w++)E(k[w],k[w+1]);return i.fragmentHint&&E(k[k.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,M}function D(i,t){for(var u=null,c=i.fragments,r=c.length-1;r>=0;r--){var h=c[r].initSegment;if(h){u=h;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;var d=0,l;if(y(i,t,function(w,C){w.relurl&&(d=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&&(l=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,u=w.initSegment)}),u){var v=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments;v.forEach(function(w){var C;(!w.initSegment||w.initSegment.relurl===((C=u)===null||C===void 0?void 0:C.relurl))&&(w.initSegment=u)})}if(t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some(function(w){return!w}),t.deltaUpdateFailed){m.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var p=t.skippedSegments;p--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=x(i.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));var L=t.fragments;if(d){m.logger.warn("discontinuity sliding from playlist, take drift into account");for(var O=0;O<L.length;O++)L[O].cc+=d}t.skippedSegments&&(t.startCC=t.fragments[0].cc),g(i.partList,t.partList,function(w,C){C.elementaryStreams=w.elementaryStreams,C.stats=w.stats}),l?A(t,l,l.startPTS,l.endPTS,l.startDTS,l.endDTS):s(i,t),L.length&&(t.totalduration=t.edge-L[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 x(i,t,u){var c=I({},i);return u&&u.forEach(function(r){delete c[r]}),Object.keys(t).forEach(function(r){var h=new S.DateRange(t[r].attr,c[r]);h.isValid?c[r]=h:m.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(t[r].attr)+'"')}),c}function g(i,t,u){if(i&&t)for(var c=0,r=0,h=i.length;r<=h;r++){var d=i[r],l=t[r+c];d&&l&&d.index===l.index&&d.fragment.sn===l.fragment.sn?u(d,l):c--}}function y(i,t,u){for(var c=t.skippedSegments,r=Math.max(i.startSN,t.startSN)-t.startSN,h=(i.fragmentHint?1:0)+(c?t.endSN:Math.min(i.endSN,t.endSN))-t.startSN,d=t.startSN-i.startSN,l=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,v=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,p=r;p<=h;p++){var L=v[d+p],O=l[p];c&&!O&&p<c&&(O=t.fragments[p]=L),L&&O&&u(L,O)}}function s(i,t){var u=t.startSN+t.skippedSegments-i.startSN,c=i.fragments;u<0||u>=c.length||e(t,c[u].start)}function e(i,t){if(t){for(var u=i.fragments,c=i.skippedSegments;c<u.length;c++)u[c].start+=t;i.fragmentHint&&(i.fragmentHint.start+=t)}}function o(i,t){var u=1e3*i.levelTargetDuration,c=u/2,r=i.age,h=r>0&&r<u*3,d=t.loading.end-t.loading.start,l,v=i.availabilityDelay;if(i.updated===!1)if(h){var p=333*i.misses;l=Math.max(Math.min(c,d*2),p),i.availabilityDelay=(i.availabilityDelay||0)+l}else l=c;else h?(v=Math.min(v||u/2,r),i.availabilityDelay=v,l=v+u-r):l=u-d;return Math.round(l)}function f(i,t,u){if(!i||!i.details)return null;var c=i.details,r=c.fragments[t-c.startSN];return r||(r=c.fragmentHint,r&&r.sn===t)?r:t<c.startSN&&u&&u.sn===t?u:null}function a(i,t,u){if(!i||!i.details)return null;var c=i.details.partList;if(c)for(var r=c.length;r--;){var h=c[r];if(h.index===u&&h.fragment.sn===t)return h}return null}},"./src/controller/stream-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return a});var R=n("./src/polyfills/number.ts"),m=n("./src/controller/base-stream-controller.ts"),S=n("./src/is-supported.ts"),I=n("./src/events.ts"),T=n("./src/utils/buffer-helper.ts"),b=n("./src/controller/fragment-tracker.ts"),_=n("./src/types/loader.ts"),E=n("./src/loader/fragment.ts"),A=n("./src/demux/transmuxer-interface.ts"),D=n("./src/types/transmuxer.ts"),x=n("./src/controller/gap-controller.ts"),g=n("./src/errors.ts");function y(i,t){for(var u=0;u<t.length;u++){var c=t[u];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(i,c.key,c)}}function s(i,t,u){return t&&y(i.prototype,t),u&&y(i,u),Object.defineProperty(i,"prototype",{writable:!1}),i}function e(i,t){i.prototype=Object.create(t.prototype),i.prototype.constructor=i,o(i,t)}function o(i,t){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(c,r){return c.__proto__=r,c},o(i,t)}var f=100,a=function(i){e(t,i);function t(c,r){var h;return h=i.call(this,c,r,"[stream-controller]")||this,h.audioCodecSwap=!1,h.gapController=null,h.level=-1,h._forceStartLoad=!1,h.altAudio=!1,h.audioOnly=!1,h.fragPlaying=null,h.onvplaying=null,h.onvseeked=null,h.fragLastKbps=0,h.couldBacktrack=!1,h.backtrackFragment=null,h.audioCodecSwitch=!1,h.videoBuffer=null,h._registerListeners(),h}var u=t.prototype;return u._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)},u._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)},u.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},u.startLoad=function(r){if(this.levels){var h=this.lastCurrentTime,d=this.hls;if(this.stopLoad(),this.setInterval(f),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var l=d.startLevel;l===-1&&(d.config.testBandwidth&&this.levels.length>1?(l=0,this.bitrateTest=!0):l=d.nextAutoLevel),this.level=d.nextLoadLevel=l,this.loadedmetadata=!1}h>0&&r===-1&&(this.log("Override startPosition with lastCurrentTime @"+h.toFixed(3)),r=h),this.state=m.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()}else this._forceStartLoad=!0,this.state=m.State.STOPPED},u.stopLoad=function(){this._forceStartLoad=!1,i.prototype.stopLoad.call(this)},u.doTick=function(){switch(this.state){case m.State.IDLE:this.doTickIdle();break;case m.State.WAITING_LEVEL:{var r,h=this.levels,d=this.level,l=h==null||(r=h[d])===null||r===void 0?void 0:r.details;if(l&&(!l.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(l))break;this.state=m.State.IDLE;break}break}case m.State.FRAG_LOADING_WAITING_RETRY:{var v,p=self.performance.now(),L=this.retryDate;(!L||p>=L||(v=this.media)!==null&&v!==void 0&&v.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=m.State.IDLE)}break;default:break}this.onTickEnd()},u.onTickEnd=function(){i.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},u.doTickIdle=function(){var r,h,d=this.hls,l=this.levelLastLoaded,v=this.levels,p=this.media,L=d.config,O=d.nextLoadLevel;if(!(l===null||!p&&(this.startFragRequested||!L.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!v||!v[O])){var M=v[O];this.level=d.nextLoadLevel=O;var F=M.details;if(!F||this.state===m.State.WAITING_LEVEL||F.live&&this.levelLastLoaded!==O){this.state=m.State.WAITING_LEVEL;return}var w=this.getMainFwdBufferInfo();if(w!==null){var C=w.len,k=this.getMaxBufferLength(M.maxBitrate);if(!(C>=k)){if(this._streamEnded(w,F)){var U={};this.altAudio&&(U.type="video"),this.hls.trigger(I.Events.BUFFER_EOS,U),this.state=m.State.ENDED;return}this.backtrackFragment&&this.backtrackFragment.start>w.end&&(this.backtrackFragment=null);var j=this.backtrackFragment?this.backtrackFragment.start:w.end,N=this.getNextFragment(j,F);if(this.couldBacktrack&&!this.fragPrevious&&N&&N.sn!=="initSegment"&&this.fragmentTracker.getState(N)!==b.FragmentState.OK){var W,Y=((W=this.backtrackFragment)!=null?W:N).sn,K=Y-F.startSN,H=F.fragments[K-1];H&&N.cc===H.cc&&(N=H,this.fragmentTracker.removeFragment(H))}else this.backtrackFragment&&w.len&&(this.backtrackFragment=null);if(N&&this.fragmentTracker.getState(N)===b.FragmentState.OK&&this.nextLoadPosition>j){var z=this.audioOnly&&!this.altAudio?E.ElementaryStreamTypes.AUDIO:E.ElementaryStreamTypes.VIDEO;p&&this.afterBufferFlushed(p,z,_.PlaylistLevelType.MAIN),N=this.getNextFragment(this.nextLoadPosition,F)}!N||(N.initSegment&&!N.initSegment.data&&!this.bitrateTest&&(N=N.initSegment),((r=N.decryptdata)===null||r===void 0?void 0:r.keyFormat)==="identity"&&!((h=N.decryptdata)!==null&&h!==void 0&&h.key)?this.loadKey(N,F):this.loadFragment(N,F,j))}}}},u.loadFragment=function(r,h,d){var l,v=this.fragmentTracker.getState(r);this.fragCurrent=r,v===b.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,h,d)):v===b.FragmentState.APPENDING?this.reduceMaxBufferLength(r.duration)&&this.fragmentTracker.removeFragment(r):((l=this.media)===null||l===void 0?void 0:l.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},u.getAppendedFrag=function(r){var h=this.fragmentTracker.getAppendedFrag(r,_.PlaylistLevelType.MAIN);return h&&"fragment"in h?h.fragment:h},u.getBufferedFrag=function(r){return this.fragmentTracker.getBufferedFrag(r,_.PlaylistLevelType.MAIN)},u.followingBufferedFrag=function(r){return r?this.getBufferedFrag(r.end+.5):null},u.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},u.nextLevelSwitch=function(){var r=this.levels,h=this.media;if(h!=null&&h.readyState){var d,l=this.getAppendedFrag(h.currentTime);if(l&&l.start>1&&this.flushMainBuffer(0,l.start-1),!h.paused&&r){var v=this.hls.nextLoadLevel,p=r[v],L=this.fragLastKbps;L&&this.fragCurrent?d=this.fragCurrent.duration*p.maxBitrate/(1e3*L)+1:d=0}else d=0;var O=this.getBufferedFrag(h.currentTime+d);if(O){var M=this.followingBufferedFrag(O);if(M){this.abortCurrentFrag();var F=M.maxStartPTS?M.maxStartPTS:M.start,w=M.duration,C=Math.max(O.end,F+Math.min(Math.max(w-this.config.maxFragLookUpTolerance,w*.5),w*.75));this.flushMainBuffer(C,Number.POSITIVE_INFINITY)}}}},u.abortCurrentFrag=function(){var r=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,r!=null&&r.loader&&r.loader.abort(),this.state){case m.State.KEY_LOADING:case m.State.FRAG_LOADING:case m.State.FRAG_LOADING_WAITING_RETRY:case m.State.PARSING:case m.State.PARSED:this.state=m.State.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},u.flushMainBuffer=function(r,h){i.prototype.flushMainBuffer.call(this,r,h,this.altAudio?"video":null)},u.onMediaAttached=function(r,h){i.prototype.onMediaAttached.call(this,r,h);var d=h.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),d.addEventListener("playing",this.onvplaying),d.addEventListener("seeked",this.onvseeked),this.gapController=new x.default(this.config,d,this.fragmentTracker,this.hls)},u.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)},u.onMediaPlaying=function(){this.tick()},u.onMediaSeeked=function(){var r=this.media,h=r?r.currentTime:null;Object(R.isFiniteNumber)(h)&&this.log("Media seeked to "+h.toFixed(3)),this.tick()},u.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},u.onManifestParsed=function(r,h){var d=!1,l=!1,v;h.levels.forEach(function(p){v=p.audioCodec,v&&(v.indexOf("mp4a.40.2")!==-1&&(d=!0),v.indexOf("mp4a.40.5")!==-1&&(l=!0))}),this.audioCodecSwitch=d&&l&&!Object(S.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=h.levels,this.startFragRequested=!1},u.onLevelLoading=function(r,h){var d=this.levels;if(!(!d||this.state!==m.State.IDLE)){var l=d[h.level];(!l.details||l.details.live&&this.levelLastLoaded!==h.level||this.waitForCdnTuneIn(l.details))&&(this.state=m.State.WAITING_LEVEL)}},u.onLevelLoaded=function(r,h){var d,l=this.levels,v=h.level,p=h.details,L=p.totalduration;if(!l){this.warn("Levels were reset while loading level "+v);return}this.log("Level "+v+" loaded ["+p.startSN+","+p.endSN+"], cc ["+p.startCC+", "+p.endCC+"] duration:"+L);var O=this.fragCurrent;O&&(this.state===m.State.FRAG_LOADING||this.state===m.State.FRAG_LOADING_WAITING_RETRY)&&O.level!==h.level&&O.loader&&(this.state=m.State.IDLE,this.backtrackFragment=null,O.loader.abort());var M=l[v],F=0;if(p.live||(d=M.details)!==null&&d!==void 0&&d.live){if(p.fragments[0]||(p.deltaUpdateFailed=!0),p.deltaUpdateFailed)return;F=this.alignPlaylists(p,M.details)}if(M.details=p,this.levelLastLoaded=v,this.hls.trigger(I.Events.LEVEL_UPDATED,{details:p,level:v}),this.state===m.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(p))return;this.state=m.State.IDLE}this.startFragRequested?p.live&&this.synchronizeToLiveEdge(p):this.setStartPosition(p,F),this.tick()},u._handleFragmentLoadProgress=function(r){var h,d=r.frag,l=r.part,v=r.payload,p=this.levels;if(!p){this.warn("Levels were reset while fragment load was in progress. Fragment "+d.sn+" of level "+d.level+" will not be buffered");return}var L=p[d.level],O=L.details;if(!O){this.warn("Dropping fragment "+d.sn+" of level "+d.level+" after level details were reset");return}var M=L.videoCodec,F=O.PTSKnown||!O.live,w=(h=d.initSegment)===null||h===void 0?void 0:h.data,C=this._getAudioCodec(L),k=this.transmuxer=this.transmuxer||new A.default(this.hls,_.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),U=l?l.index:-1,j=U!==-1,N=new D.ChunkMetadata(d.level,d.sn,d.stats.chunkCount,v.byteLength,U,j),W=this.initPTS[d.cc];k.push(v,w,C,M,d,l,O.totalduration,F,N,W)},u.onAudioTrackSwitching=function(r,h){var d=this.altAudio,l=!!h.url,v=h.id;if(!l){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var p=this.fragCurrent;p!=null&&p.loader&&(this.log("Switching to main audio track, cancel main fragment load"),p.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var L=this.hls;d&&L.trigger(I.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),L.trigger(I.Events.AUDIO_TRACK_SWITCHED,{id:v})}},u.onAudioTrackSwitched=function(r,h){var d=h.id,l=!!this.hls.audioTracks[d].url;if(l){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=l,this.tick()},u.onBufferCreated=function(r,h){var d=h.tracks,l,v,p=!1;for(var L in d){var O=d[L];if(O.id==="main"){if(v=L,l=O,L==="video"){var M=d[L];M&&(this.videoBuffer=M.buffer)}}else p=!0}p&&l?(this.log("Alternate track found, use "+v+".buffered to schedule main fragment loading"),this.mediaBuffer=l.buffer):this.mediaBuffer=this.media},u.onFragBuffered=function(r,h){var d=h.frag,l=h.part;if(!(d&&d.type!==_.PlaylistLevelType.MAIN)){if(this.fragContextChanged(d)){this.warn("Fragment "+d.sn+(l?" p: "+l.index:"")+" of level "+d.level+" finished buffering, but was aborted. state: "+this.state),this.state===m.State.PARSED&&(this.state=m.State.IDLE);return}var v=l?l.stats:d.stats;this.fragLastKbps=Math.round(8*v.total/(v.buffering.end-v.loading.first)),d.sn!=="initSegment"&&(this.fragPrevious=d),this.fragBufferedComplete(d,l)}},u.onError=function(r,h){switch(h.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(_.PlaylistLevelType.MAIN,h);break;case g.ErrorDetails.LEVEL_LOAD_ERROR:case g.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==m.State.ERROR&&(h.fatal?(this.warn(""+h.details),this.state=m.State.ERROR):!h.levelRetry&&this.state===m.State.WAITING_LEVEL&&(this.state=m.State.IDLE));break;case g.ErrorDetails.BUFFER_FULL_ERROR:if(h.parent==="main"&&(this.state===m.State.PARSING||this.state===m.State.PARSED)){var d=!0,l=this.getFwdBufferInfo(this.media,_.PlaylistLevelType.MAIN);l&&l.len>.5&&(d=!this.reduceMaxBufferLength(l.len)),d&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},u.checkBuffer=function(){var r=this.media,h=this.gapController;if(!(!r||!h||!r.readyState)){if(this.loadedmetadata||!T.BufferHelper.getBuffered(r).length){var d=this.state!==m.State.IDLE?this.fragCurrent:null;h.poll(this.lastCurrentTime,d)}this.lastCurrentTime=r.currentTime}},u.onFragLoadEmergencyAborted=function(){this.state=m.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},u.onBufferFlushed=function(r,h){var d=h.type;if(d!==E.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var l=(d===E.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(l,d,_.PlaylistLevelType.MAIN)}},u.onLevelsUpdated=function(r,h){this.levels=h.levels},u.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},u.seekToStartPos=function(){var r=this.media;if(!!r){var h=r.currentTime,d=this.startPosition;if(d>=0&&h<d){if(r.seeking){this.log("could not seek to "+d+", already seeking at "+h);return}var l=T.BufferHelper.getBuffered(r),v=l.length?l.start(0):0,p=v-d;p>0&&(p<this.config.maxBufferHole||p<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+p+" to match buffer start"),d+=p,this.startPosition=d),this.log("seek to target start position "+d+" from current time "+h),r.currentTime=d}}},u._getAudioCodec=function(r){var h=this.config.defaultAudioCodec||r.audioCodec;return this.audioCodecSwap&&h&&(this.log("Swapping audio codec"),h.indexOf("mp4a.40.5")!==-1?h="mp4a.40.2":h="mp4a.40.5"),h},u._loadBitrateTestFrag=function(r){var h=this;r.bitrateTest=!0,this._doFragLoad(r).then(function(d){var l=h.hls;if(!(!d||l.nextLoadLevel||h.fragContextChanged(r))){h.fragLoadError=0,h.state=m.State.IDLE,h.startFragRequested=!1,h.bitrateTest=!1;var v=r.stats;v.parsing.start=v.parsing.end=v.buffering.start=v.buffering.end=self.performance.now(),l.trigger(I.Events.FRAG_LOADED,d),r.bitrateTest=!1}})},u._handleTransmuxComplete=function(r){var h,d="main",l=this.hls,v=r.remuxResult,p=r.chunkMeta,L=this.getCurrentContext(p);if(!L){this.warn("The loading context changed while buffering fragment "+p.sn+" of level "+p.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(p.level);return}var O=L.frag,M=L.part,F=L.level,w=v.video,C=v.text,k=v.id3,U=v.initSegment,j=F.details,N=this.altAudio?void 0:v.audio;if(!this.fragContextChanged(O)){if(this.state=m.State.PARSING,U){U.tracks&&(this._bufferInitSegment(F,U.tracks,O,p),l.trigger(I.Events.FRAG_PARSING_INIT_SEGMENT,{frag:O,id:d,tracks:U.tracks}));var W=U.initPTS,Y=U.timescale;Object(R.isFiniteNumber)(W)&&(this.initPTS[O.cc]=W,l.trigger(I.Events.INIT_PTS_FOUND,{frag:O,id:d,initPTS:W,timescale:Y}))}if(w&&v.independent!==!1){if(j){var K=w.startPTS,H=w.endPTS,z=w.startDTS,$=w.endDTS;if(M)M.elementaryStreams[w.type]={startPTS:K,endPTS:H,startDTS:z,endDTS:$};else if(w.firstKeyFrame&&w.independent&&(this.couldBacktrack=!0),w.dropped&&w.independent){var X=this.getMainFwdBufferInfo(),J=(X?X.end:this.getLoadPosition())+this.config.maxBufferHole,te=w.firstKeyFramePTS?w.firstKeyFramePTS:K;if(J<te-this.config.maxBufferHole){this.backtrack(O);return}O.setElementaryStreamInfo(w.type,O.start,H,O.start,$,!0)}O.setElementaryStreamInfo(w.type,K,H,z,$),this.backtrackFragment&&(this.backtrackFragment=O),this.bufferFragmentData(w,O,M,p)}}else if(v.independent===!1){this.backtrack(O);return}if(N){var Q=N.startPTS,ae=N.endPTS,se=N.startDTS,re=N.endDTS;M&&(M.elementaryStreams[E.ElementaryStreamTypes.AUDIO]={startPTS:Q,endPTS:ae,startDTS:se,endDTS:re}),O.setElementaryStreamInfo(E.ElementaryStreamTypes.AUDIO,Q,ae,se,re),this.bufferFragmentData(N,O,M,p)}if(j&&k!==null&&k!==void 0&&(h=k.samples)!==null&&h!==void 0&&h.length){var ee={id:d,frag:O,details:j,samples:k.samples};l.trigger(I.Events.FRAG_PARSING_METADATA,ee)}if(j&&C){var Z={id:d,frag:O,details:j,samples:C.samples};l.trigger(I.Events.FRAG_PARSING_USERDATA,Z)}}},u._bufferInitSegment=function(r,h,d,l){var v=this;if(this.state===m.State.PARSING){this.audioOnly=!!h.audio&&!h.video,this.altAudio&&!this.audioOnly&&delete h.audio;var p=h.audio,L=h.video,O=h.audiovideo;if(p){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"),p.metadata.channelCount!==1&&F.indexOf("firefox")===-1&&(M="mp4a.40.5")),F.indexOf("android")!==-1&&p.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+'"'),p.levelCodec=M,p.id="main",this.log("Init audio buffer, container:"+p.container+", codecs[selected/level/parsed]=["+(M||"")+"/"+(r.audioCodec||"")+"/"+p.codec+"]")}L&&(L.levelCodec=r.videoCodec,L.id="main",this.log("Init video buffer, container:"+L.container+", codecs[level/parsed]=["+(r.videoCodec||"")+"/"+L.codec+"]")),O&&this.log("Init audiovideo buffer, container:"+O.container+", codecs[level/parsed]=["+(r.attrs.CODECS||"")+"/"+O.codec+"]"),this.hls.trigger(I.Events.BUFFER_CODECS,h),Object.keys(h).forEach(function(w){var C=h[w],k=C.initSegment;k!=null&&k.byteLength&&v.hls.trigger(I.Events.BUFFER_APPENDING,{type:w,data:k,frag:d,part:null,chunkMeta:l,parent:d.type})}),this.tick()}},u.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,_.PlaylistLevelType.MAIN)},u.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=m.State.IDLE},u.checkFragmentChanged=function(){var r=this.media,h=null;if(r&&r.readyState>1&&r.seeking===!1){var d=r.currentTime;if(T.BufferHelper.isBuffered(r,d)?h=this.getAppendedFrag(d):T.BufferHelper.isBuffered(r,d+.1)&&(h=this.getAppendedFrag(d+.1)),h){this.backtrackFragment=null;var l=this.fragPlaying,v=h.level;(!l||h.sn!==l.sn||l.level!==v||h.urlId!==l.urlId)&&(this.hls.trigger(I.Events.FRAG_CHANGED,{frag:h}),(!l||l.level!==v)&&this.hls.trigger(I.Events.LEVEL_SWITCHED,{level:v}),this.fragPlaying=h)}}},s(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 h=r.currentTime,d=this.currentFrag;if(d&&Object(R.isFiniteNumber)(h)&&Object(R.isFiniteNumber)(d.programDateTime)){var l=d.programDateTime+(h-d.start)*1e3;return new Date(l)}}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}(m.default)},"./src/controller/subtitle-stream-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"SubtitleStreamController",function(){return e});var R=n("./src/events.ts"),m=n("./src/utils/buffer-helper.ts"),S=n("./src/controller/fragment-finders.ts"),I=n("./src/utils/discontinuities.ts"),T=n("./src/controller/level-helper.ts"),b=n("./src/controller/fragment-tracker.ts"),_=n("./src/controller/base-stream-controller.ts"),E=n("./src/types/loader.ts"),A=n("./src/types/level.ts");function D(f,a){for(var i=0;i<a.length;i++){var t=a[i];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(f,t.key,t)}}function x(f,a,i){return a&&D(f.prototype,a),i&&D(f,i),Object.defineProperty(f,"prototype",{writable:!1}),f}function g(f,a){f.prototype=Object.create(a.prototype),f.prototype.constructor=f,y(f,a)}function y(f,a){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,u){return t.__proto__=u,t},y(f,a)}var s=500,e=function(f){g(a,f);function a(t,u){var c;return c=f.call(this,t,u,"[subtitle-stream-controller]")||this,c.levels=[],c.currentTrackId=-1,c.tracksBuffered=[],c.mainDetails=null,c._registerListeners(),c}var i=a.prototype;return i.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},i._registerListeners=function(){var u=this.hls;u.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),u.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),u.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.on(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.on(R.Events.ERROR,this.onError,this),u.on(R.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),u.on(R.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),u.on(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),u.on(R.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),u.on(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i._unregisterListeners=function(){var u=this.hls;u.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),u.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),u.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.off(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.off(R.Events.ERROR,this.onError,this),u.off(R.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),u.off(R.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),u.off(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),u.off(R.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),u.off(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i.startLoad=function(){this.stopLoad(),this.state=_.State.IDLE,this.setInterval(s),this.tick()},i.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},i.onLevelLoaded=function(u,c){this.mainDetails=c.details},i.onSubtitleFragProcessed=function(u,c){var r=c.frag,h=c.success;if(this.fragPrevious=r,this.state=_.State.IDLE,!!h){var d=this.tracksBuffered[this.currentTrackId];if(!!d){for(var l,v=r.start,p=0;p<d.length;p++)if(v>=d[p].start&&v<=d[p].end){l=d[p];break}var L=r.start+r.duration;l?l.end=L:(l={start:v,end:L},d.push(l)),this.fragmentTracker.fragBuffered(r)}}},i.onBufferFlushing=function(u,c){var r=c.startOffset,h=c.endOffset;if(r===0&&h!==Number.POSITIVE_INFINITY){var d=this.currentTrackId,l=this.levels;if(!l.length||!l[d]||!l[d].details)return;var v=l[d].details,p=v.targetduration,L=h-p;if(L<=0)return;c.endOffsetSubtitles=Math.max(0,L),this.tracksBuffered.forEach(function(O){for(var M=0;M<O.length;){if(O[M].end<=L){O.shift();continue}else if(O[M].start<L)O[M].start=L;else break;M++}}),this.fragmentTracker.removeFragmentsInRange(r,L,E.PlaylistLevelType.SUBTITLE)}},i.onError=function(u,c){var r,h=c.frag;!h||h.type!==E.PlaylistLevelType.SUBTITLE||((r=this.fragCurrent)!==null&&r!==void 0&&r.loader&&this.fragCurrent.loader.abort(),this.state=_.State.IDLE)},i.onSubtitleTracksUpdated=function(u,c){var r=this,h=c.subtitleTracks;this.tracksBuffered=[],this.levels=h.map(function(d){return new A.Level(d)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(d){r.tracksBuffered[d.id]=[]}),this.mediaBuffer=null},i.onSubtitleTrackSwitch=function(u,c){if(this.currentTrackId=c.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(s)},i.onSubtitleTrackLoaded=function(u,c){var r,h=c.details,d=c.id,l=this.currentTrackId,v=this.levels;if(!!v.length){var p=v[l];if(!(d>=v.length||d!==l||!p)){if(this.mediaBuffer=this.mediaBufferTimeRanges,h.live||(r=p.details)!==null&&r!==void 0&&r.live){var L=this.mainDetails;if(h.deltaUpdateFailed||!L)return;var O=L.fragments[0];if(!p.details)h.hasProgramDateTime&&L.hasProgramDateTime?Object(I.alignMediaPlaylistByPDT)(h,L):O&&Object(T.addSliding)(h,O.start);else{var M=this.alignPlaylists(h,p.details);M===0&&O&&Object(T.addSliding)(h,O.start)}}if(p.details=h,this.levelLastLoaded=d,this.tick(),h.live&&!this.fragCurrent&&this.media&&this.state===_.State.IDLE){var F=Object(S.findFragmentByPTS)(null,h.fragments,this.media.currentTime,0);F||(this.warn("Subtitle playlist not aligned with playback"),p.details=void 0)}}}},i._handleFragmentLoadComplete=function(u){var c=u.frag,r=u.payload,h=c.decryptdata,d=this.hls;if(!this.fragContextChanged(c)&&r&&r.byteLength>0&&h&&h.key&&h.iv&&h.method==="AES-128"){var l=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(r),h.key.buffer,h.iv.buffer).then(function(v){var p=performance.now();d.trigger(R.Events.FRAG_DECRYPTED,{frag:c,payload:v,stats:{tstart:l,tdecrypt:p}})})}},i.doTick=function(){if(!this.media){this.state=_.State.IDLE;return}if(this.state===_.State.IDLE){var u=this.currentTrackId,c=this.levels;if(!c.length||!c[u]||!c[u].details)return;var r=c[u].details,h=r.targetduration,d=this.config,l=this.media,v=m.BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],l.currentTime-h,d.maxBufferHole),p=v.end,L=v.len,O=this.getMaxBufferLength()+h;if(L>O)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,k=this.fragPrevious;if(p<w){var U=d.maxFragLookUpTolerance;C=Object(S.findFragmentByPTS)(k,M,Math.max(M[0].start,p),U),!C&&k&&k.start<M[0].start&&(C=M[0])}else C=M[F-1];if(C=this.mapToInitFragWhenRequired(C),!C||this.fragmentTracker.getState(C)!==b.FragmentState.NOT_LOADED)return;C.encrypted?this.loadKey(C,r):this.loadFragment(C,r,p)}},i.loadFragment=function(u,c,r){this.fragCurrent=u,u.sn==="initSegment"?this._loadInitSegment(u):f.prototype.loadFragment.call(this,u,c,r)},x(a,[{key:"mediaBufferTimeRanges",get:function(){return new o(this.tracksBuffered[this.currentTrackId]||[])}}]),a}(_.default),o=function(a){this.buffered=void 0;var i=function(u,c,r){if(c=c>>>0,c>r-1)throw new DOMException("Failed to execute '"+u+"' on 'TimeRanges': The index provided ("+c+") is greater than the maximum bound ("+r+")");return a[c][u]};this.buffered={get length(){return a.length},end:function(u){return i("end",u,a.length)},start:function(u){return i("start",u,a.length)}}}},"./src/controller/subtitle-track-controller.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/events.ts"),m=n("./src/utils/texttrack-utils.ts"),S=n("./src/controller/base-playlist-controller.ts"),I=n("./src/types/loader.ts");function T(x,g){for(var y=0;y<g.length;y++){var s=g[y];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(x,s.key,s)}}function b(x,g,y){return g&&T(x.prototype,g),y&&T(x,y),Object.defineProperty(x,"prototype",{writable:!1}),x}function _(x,g){x.prototype=Object.create(g.prototype),x.prototype.constructor=x,E(x,g)}function E(x,g){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,e){return s.__proto__=e,s},E(x,g)}var A=function(x){_(g,x);function g(s){var e;return e=x.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 y=g.prototype;return y.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,x.prototype.destroy.call(this)},y.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)},y.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)},y.onMediaAttached=function(e,o){this.media=o.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))},y.pollTrackChange=function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)},y.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(o){Object(m.clearCurrentCues)(o)}),this.subtitleTrack=-1,this.media=null}},y.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},y.onManifestParsed=function(e,o){this.tracks=o.subtitleTracks},y.onSubtitleTrackLoaded=function(e,o){var f=o.id,a=o.details,i=this.trackId,t=this.tracksInGroup[i];if(!t){this.warn("Invalid subtitle track id "+f);return}var u=t.details;t.details=o.details,this.log("subtitle track "+f+" loaded ["+a.startSN+"-"+a.endSN+"]"),f===this.trackId&&(this.retryCount=0,this.playlistLoaded(f,o,u))},y.onLevelLoading=function(e,o){this.switchLevel(o.level)},y.onLevelSwitching=function(e,o){this.switchLevel(o.level)},y.switchLevel=function(e){var o=this.hls.levels[e];if(!!(o!=null&&o.textGroupIds)){var f=o.textGroupIds[o.urlId];if(this.groupId!==f){var a=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,i=this.tracks.filter(function(c){return!f||c.groupId===f});this.tracksInGroup=i;var t=this.findTrackId(a==null?void 0:a.name)||this.findTrackId();this.groupId=f;var u={subtitleTracks:i};this.log("Updating subtitle tracks, "+i.length+' track(s) found in "'+f+'" group-id'),this.hls.trigger(R.Events.SUBTITLE_TRACKS_UPDATED,u),t!==-1&&this.setSubtitleTrack(t,a)}}},y.findTrackId=function(e){for(var o=this.tracksInGroup,f=0;f<o.length;f++){var a=o[f];if((!this.selectDefaultTrack||a.default)&&(!e||e===a.name))return a.id}return-1},y.onError=function(e,o){x.prototype.onError.call(this,e,o),!(o.fatal||!o.context)&&o.context.type===I.PlaylistContextType.SUBTITLE_TRACK&&o.context.id===this.trackId&&o.context.groupId===this.groupId&&this.retryLoadingOrFail(o)},y.loadPlaylist=function(e){var o=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(o)){var f=o.id,a=o.groupId,i=o.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 "+f),this.hls.trigger(R.Events.SUBTITLE_TRACK_LOADING,{url:i,id:f,groupId:a,deliveryDirectives:e||null})}},y.toggleTrackModes=function(e){var o=this,f=this.media,a=this.trackId;if(!!f){var i=D(f.textTracks),t=i.filter(function(r){return r.groupId===o.groupId});if(e===-1)[].slice.call(i).forEach(function(r){r.mode="disabled"});else{var u=t[a];u&&(u.mode="disabled")}var c=t[e];c&&(c.mode=this.subtitleDisplay?"showing":"hidden")}},y.setSubtitleTrack=function(e,o){var f,a=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),!(this.trackId===e&&(e===-1||(f=a[e])!==null&&f!==void 0&&f.details)||e<-1||e>=a.length)){this.clearTimer();var i=a[e];if(this.log("Switching to subtitle track "+e),this.trackId=e,i){var t=i.id,u=i.groupId,c=u===void 0?"":u,r=i.name,h=i.type,d=i.url;this.hls.trigger(R.Events.SUBTITLE_TRACK_SWITCH,{id:t,groupId:c,name:r,type:h,url:d});var l=this.switchParams(i.url,o==null?void 0:o.details);this.loadPlaylist(l)}else this.hls.trigger(R.Events.SUBTITLE_TRACK_SWITCH,{id:e})}},y.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!(!this.media||!this.hls.config.renderTextTracksNatively)){for(var e=-1,o=D(this.media.textTracks),f=0;f<o.length;f++)if(o[f].mode==="hidden")e=f;else if(o[f].mode==="showing"){e=f;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}},b(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 o=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,o)}}]),g}(S.default);function D(x){for(var g=[],y=0;y<x.length;y++){var s=x[y];s.kind==="subtitles"&&s.label&&g.push(x[y])}return g}P.default=A},"./src/controller/timeline-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"TimelineController",function(){return x});var R=n("./src/polyfills/number.ts"),m=n("./src/events.ts"),S=n("./src/utils/cea-608-parser.ts"),I=n("./src/utils/output-filter.ts"),T=n("./src/utils/webvtt-parser.ts"),b=n("./src/utils/texttrack-utils.ts"),_=n("./src/utils/imsc1-ttml-parser.ts"),E=n("./src/utils/mp4-tools.ts"),A=n("./src/types/loader.ts"),D=n("./src/utils/logger.ts"),x=function(){function e(f){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=s(),this.captionsProperties=void 0,this.hls=f,this.config=f.config,this.Cues=f.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 a=new I.default(this,"textTrack1"),i=new I.default(this,"textTrack2"),t=new I.default(this,"textTrack3"),u=new I.default(this,"textTrack4");this.cea608Parser1=new S.default(1,a,i),this.cea608Parser2=new S.default(3,t,u)}f.on(m.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),f.on(m.Events.MEDIA_DETACHING,this.onMediaDetaching,this),f.on(m.Events.MANIFEST_LOADING,this.onManifestLoading,this),f.on(m.Events.MANIFEST_LOADED,this.onManifestLoaded,this),f.on(m.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),f.on(m.Events.FRAG_LOADING,this.onFragLoading,this),f.on(m.Events.FRAG_LOADED,this.onFragLoaded,this),f.on(m.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),f.on(m.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),f.on(m.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),f.on(m.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),f.on(m.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var o=e.prototype;return o.destroy=function(){var a=this.hls;a.off(m.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),a.off(m.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.off(m.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.off(m.Events.MANIFEST_LOADED,this.onManifestLoaded,this),a.off(m.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),a.off(m.Events.FRAG_LOADING,this.onFragLoading,this),a.off(m.Events.FRAG_LOADED,this.onFragLoaded,this),a.off(m.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),a.off(m.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),a.off(m.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),a.off(m.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),a.off(m.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},o.addCues=function(a,i,t,u,c){for(var r=!1,h=c.length;h--;){var d=c[h],l=y(d[0],d[1],i,t);if(l>=0&&(d[0]=Math.min(d[0],i),d[1]=Math.max(d[1],t),r=!0,l/(t-i)>.5))return}if(r||c.push([i,t]),this.config.renderTextTracksNatively){var v=this.captionsTracks[a];this.Cues.newCue(v,i,t,u)}else{var p=this.Cues.newCue(null,i,t,u);this.hls.trigger(m.Events.CUES_PARSED,{type:"captions",cues:p,track:a})}},o.onInitPtsFound=function(a,i){var t=this,u=i.frag,c=i.id,r=i.initPTS,h=i.timescale,d=this.unparsedVttFrags;c==="main"&&(this.initPTS[u.cc]=r,this.timescale[u.cc]=h),d.length&&(this.unparsedVttFrags=[],d.forEach(function(l){t.onFragLoaded(m.Events.FRAG_LOADED,l)}))},o.getExistingTrack=function(a){var i=this.media;if(i)for(var t=0;t<i.textTracks.length;t++){var u=i.textTracks[t];if(u[a])return u}return null},o.createCaptionsTrack=function(a){this.config.renderTextTracksNatively?this.createNativeTrack(a):this.createNonNativeTrack(a)},o.createNativeTrack=function(a){if(!this.captionsTracks[a]){var i=this.captionsProperties,t=this.captionsTracks,u=this.media,c=i[a],r=c.label,h=c.languageCode,d=this.getExistingTrack(a);if(d)t[a]=d,Object(b.clearCurrentCues)(t[a]),Object(b.sendAddTrackEvent)(t[a],u);else{var l=this.createTextTrack("captions",r,h);l&&(l[a]=!0,t[a]=l)}}},o.createNonNativeTrack=function(a){if(!this.nonNativeCaptionsTracks[a]){var i=this.captionsProperties[a];if(!!i){var t=i.label,u={_id:a,label:t,kind:"captions",default:i.media?!!i.media.default:!1,closedCaptions:i.media};this.nonNativeCaptionsTracks[a]=u,this.hls.trigger(m.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[u]})}}},o.createTextTrack=function(a,i,t){var u=this.media;if(!!u)return u.addTextTrack(a,i,t)},o.onMediaAttaching=function(a,i){this.media=i.media,this._cleanTracks()},o.onMediaDetaching=function(){var a=this.captionsTracks;Object.keys(a).forEach(function(i){Object(b.clearCurrentCues)(a[i]),delete a[i]}),this.nonNativeCaptionsTracks={}},o.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=s(),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())},o._cleanTracks=function(){var a=this.media;if(!!a){var i=a.textTracks;if(i)for(var t=0;t<i.length;t++)Object(b.clearCurrentCues)(i[t])}},o.onSubtitleTracksUpdated=function(a,i){var t=this;this.textTracks=[];var u=i.subtitleTracks||[],c=u.some(function(l){return l.textCodec===_.IMSC1_CODEC});if(this.config.enableWebVTT||c&&this.config.enableIMSC1){var r=this.tracks&&u&&this.tracks.length===u.length;if(this.tracks=u||[],this.config.renderTextTracksNatively){var h=this.media?this.media.textTracks:[];this.tracks.forEach(function(l,v){var p;if(v<h.length){for(var L=null,O=0;O<h.length;O++)if(g(h[O],l)){L=h[O];break}L&&(p=L)}if(p)Object(b.clearCurrentCues)(p);else{var M=t._captionsOrSubtitlesFromCharacteristics(l);p=t.createTextTrack(M,l.name,l.lang),p&&(p.mode="disabled")}p&&(p.groupId=l.groupId,t.textTracks.push(p))})}else if(!r&&this.tracks&&this.tracks.length){var d=this.tracks.map(function(l){return{label:l.name,kind:l.type.toLowerCase(),default:l.default,subtitleTrack:l}});this.hls.trigger(m.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:d})}}},o._captionsOrSubtitlesFromCharacteristics=function(a){var i;if((i=a.attrs)!==null&&i!==void 0&&i.CHARACTERISTICS){var t=/transcribes-spoken-dialog/gi.test(a.attrs.CHARACTERISTICS),u=/describes-music-and-sound/gi.test(a.attrs.CHARACTERISTICS);if(t&&u)return"captions"}return"subtitles"},o.onManifestLoaded=function(a,i){var t=this;this.config.enableCEA708Captions&&i.captions&&i.captions.forEach(function(u){var c=/(?:CC|SERVICE)([1-4])/.exec(u.instreamId);if(!!c){var r="textTrack"+c[1],h=t.captionsProperties[r];!h||(h.label=u.name,u.lang&&(h.languageCode=u.lang),h.media=u)}})},o.onFragLoading=function(a,i){var t=this.cea608Parser1,u=this.cea608Parser2,c=this.lastSn,r=this.lastPartIndex;if(!(!this.enabled||!(t&&u))&&i.frag.type===A.PlaylistLevelType.MAIN){var h,d,l=i.frag.sn,v=(h=i==null||(d=i.part)===null||d===void 0?void 0:d.index)!=null?h:-1;l===c+1||l===c&&v===r+1||(t.reset(),u.reset()),this.lastSn=l,this.lastPartIndex=v}},o.onFragLoaded=function(a,i){var t=i.frag,u=i.payload,c=this.initPTS,r=this.unparsedVttFrags;if(t.type===A.PlaylistLevelType.SUBTITLE)if(u.byteLength){if(!Object(R.isFiniteNumber)(c[t.cc])){r.push(i),c.length&&this.hls.trigger(m.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:new Error("Missing initial subtitle PTS")});return}var h=t.decryptdata,d="stats"in i;if(h==null||h.key==null||h.method!=="AES-128"||d){var l=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),l&&l.textCodec===_.IMSC1_CODEC?this._parseIMSC1(t,u):this._parseVTTs(t,u,v)}}else this.hls.trigger(m.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:new Error("Empty subtitle payload")})},o._parseIMSC1=function(a,i){var t=this,u=this.hls;Object(_.parseIMSC1)(i,this.initPTS[a.cc],this.timescale[a.cc],function(c){t._appendCues(c,a.level),u.trigger(m.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:a})},function(c){D.logger.log("Failed to parse IMSC1: "+c),u.trigger(m.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:a,error:c})})},o._parseVTTs=function(a,i,t){var u,c=this,r=this.hls,h=(u=a.initSegment)!==null&&u!==void 0&&u.data?Object(E.appendUint8Array)(a.initSegment.data,new Uint8Array(i)):i;Object(T.parseWebVTT)(h,this.initPTS[a.cc],this.timescale[a.cc],t,a.cc,a.start,function(d){c._appendCues(d,a.level),r.trigger(m.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:a})},function(d){c._fallbackToIMSC1(a,i),D.logger.log("Failed to parse VTT cue: "+d),r.trigger(m.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:a,error:d})})},o._fallbackToIMSC1=function(a,i){var t=this,u=this.tracks[a.level];u.textCodec||Object(_.parseIMSC1)(i,this.initPTS[a.cc],this.timescale[a.cc],function(){u.textCodec=_.IMSC1_CODEC,t._parseIMSC1(a,i)},function(){u.textCodec="wvtt"})},o._appendCues=function(a,i){var t=this.hls;if(this.config.renderTextTracksNatively){var u=this.textTracks[i];if(!u||u.mode==="disabled")return;a.forEach(function(h){return Object(b.addCueToTrack)(u,h)})}else{var c=this.tracks[i];if(!c)return;var r=c.default?"default":"subtitles"+i;t.trigger(m.Events.CUES_PARSED,{type:"subtitles",cues:a,track:r})}},o.onFragDecrypted=function(a,i){var t=i.frag;if(t.type===A.PlaylistLevelType.SUBTITLE){if(!Object(R.isFiniteNumber)(this.initPTS[t.cc])){this.unparsedVttFrags.push(i);return}this.onFragLoaded(m.Events.FRAG_LOADED,i)}},o.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},o.onFragParsingUserdata=function(a,i){var t=this.cea608Parser1,u=this.cea608Parser2;if(!(!this.enabled||!(t&&u)))for(var c=0;c<i.samples.length;c++){var r=i.samples[c].bytes;if(r){var h=this.extractCea608Data(r);t.addData(i.samples[c].pts,h[0]),u.addData(i.samples[c].pts,h[1])}}},o.onBufferFlushing=function(a,i){var t=i.startOffset,u=i.endOffset,c=i.endOffsetSubtitles,r=i.type,h=this.media;if(!(!h||h.currentTime<u)){if(!r||r==="video"){var d=this.captionsTracks;Object.keys(d).forEach(function(v){return Object(b.removeCuesInRange)(d[v],t,u)})}if(this.config.renderTextTracksNatively&&t===0&&c!==void 0){var l=this.textTracks;Object.keys(l).forEach(function(v){return Object(b.removeCuesInRange)(l[v],t,c)})}}},o.extractCea608Data=function(a){for(var i=[[],[]],t=a[0]&31,u=2,c=0;c<t;c++){var r=a[u++],h=127&a[u++],d=127&a[u++];if(!(h===0&&d===0)){var l=(4&r)!==0;if(l){var v=3&r;(v===0||v===1)&&(i[v].push(h),i[v].push(d))}}}return i},e}();function g(e,o){return e&&e.label===o.name&&!(e.textTrack1||e.textTrack2)}function y(e,o,f,a){return Math.min(o,a)-Math.max(e,f)}function s(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}},"./src/crypt/aes-crypto.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return R});var R=function(){function m(I,T){this.subtle=void 0,this.aesIV=void 0,this.subtle=I,this.aesIV=T}var S=m.prototype;return S.decrypt=function(T,b){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},b,T)},m}()},"./src/crypt/aes-decryptor.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"removePadding",function(){return m}),n.d(P,"default",function(){return S});var R=n("./src/utils/typed-array.ts");function m(I){var T=I.byteLength,b=T&&new DataView(I.buffer).getUint8(T-1);return b?Object(R.sliceUint8)(I,0,T-b):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 T=I.prototype;return T.uint8ArrayToUint32Array_=function(_){for(var E=new DataView(_),A=new Uint32Array(4),D=0;D<4;D++)A[D]=E.getUint32(D*4);return A},T.initTable=function(){var _=this.sBox,E=this.invSBox,A=this.subMix,D=A[0],x=A[1],g=A[2],y=A[3],s=this.invSubMix,e=s[0],o=s[1],f=s[2],a=s[3],i=new Uint32Array(256),t=0,u=0,c=0;for(c=0;c<256;c++)c<128?i[c]=c<<1:i[c]=c<<1^283;for(c=0;c<256;c++){var r=u^u<<1^u<<2^u<<3^u<<4;r=r>>>8^r&255^99,_[t]=r,E[r]=t;var h=i[t],d=i[h],l=i[d],v=i[r]*257^r*16843008;D[t]=v<<24|v>>>8,x[t]=v<<16|v>>>16,g[t]=v<<8|v>>>24,y[t]=v,v=l*16843009^d*65537^h*257^t*16843008,e[r]=v<<24|v>>>8,o[r]=v<<16|v>>>16,f[r]=v<<8|v>>>24,a[r]=v,t?(t=h^i[i[i[l^h]]],u^=i[i[u]]):t=u=1}},T.expandKey=function(_){for(var E=this.uint8ArrayToUint32Array_(_),A=!0,D=0;D<E.length&&A;)A=E[D]===this.key[D],D++;if(!A){this.key=E;var x=this.keySize=E.length;if(x!==4&&x!==6&&x!==8)throw new Error("Invalid aes key size="+x);var g=this.ksRows=(x+6+1)*4,y,s,e=this.keySchedule=new Uint32Array(g),o=this.invKeySchedule=new Uint32Array(g),f=this.sBox,a=this.rcon,i=this.invSubMix,t=i[0],u=i[1],c=i[2],r=i[3],h,d;for(y=0;y<g;y++){if(y<x){h=e[y]=E[y];continue}d=h,y%x===0?(d=d<<8|d>>>24,d=f[d>>>24]<<24|f[d>>>16&255]<<16|f[d>>>8&255]<<8|f[d&255],d^=a[y/x|0]<<24):x>6&&y%x===4&&(d=f[d>>>24]<<24|f[d>>>16&255]<<16|f[d>>>8&255]<<8|f[d&255]),e[y]=h=(e[y-x]^d)>>>0}for(s=0;s<g;s++)y=g-s,s&3?d=e[y]:d=e[y-4],s<4||y<=4?o[s]=d:o[s]=t[f[d>>>24]]^u[f[d>>>16&255]]^c[f[d>>>8&255]]^r[f[d&255]],o[s]=o[s]>>>0}},T.networkToHostOrderSwap=function(_){return _<<24|(_&65280)<<8|(_&16711680)>>8|_>>>24},T.decrypt=function(_,E,A){for(var D=this.keySize+6,x=this.invKeySchedule,g=this.invSBox,y=this.invSubMix,s=y[0],e=y[1],o=y[2],f=y[3],a=this.uint8ArrayToUint32Array_(A),i=a[0],t=a[1],u=a[2],c=a[3],r=new Int32Array(_),h=new Int32Array(r.length),d,l,v,p,L,O,M,F,w,C,k,U,j,N,W=this.networkToHostOrderSwap;E<r.length;){for(w=W(r[E]),C=W(r[E+1]),k=W(r[E+2]),U=W(r[E+3]),L=w^x[0],O=U^x[1],M=k^x[2],F=C^x[3],j=4,N=1;N<D;N++)d=s[L>>>24]^e[O>>16&255]^o[M>>8&255]^f[F&255]^x[j],l=s[O>>>24]^e[M>>16&255]^o[F>>8&255]^f[L&255]^x[j+1],v=s[M>>>24]^e[F>>16&255]^o[L>>8&255]^f[O&255]^x[j+2],p=s[F>>>24]^e[L>>16&255]^o[O>>8&255]^f[M&255]^x[j+3],L=d,O=l,M=v,F=p,j=j+4;d=g[L>>>24]<<24^g[O>>16&255]<<16^g[M>>8&255]<<8^g[F&255]^x[j],l=g[O>>>24]<<24^g[M>>16&255]<<16^g[F>>8&255]<<8^g[L&255]^x[j+1],v=g[M>>>24]<<24^g[F>>16&255]<<16^g[L>>8&255]<<8^g[O&255]^x[j+2],p=g[F>>>24]<<24^g[L>>16&255]<<16^g[O>>8&255]<<8^g[M&255]^x[j+3],h[E]=W(d^i),h[E+1]=W(p^t),h[E+2]=W(v^u),h[E+3]=W(l^c),i=w,t=C,u=k,c=U,E=E+4}return h.buffer},I}()},"./src/crypt/decrypter.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return E});var R=n("./src/crypt/aes-crypto.ts"),m=n("./src/crypt/fast-aes-key.ts"),S=n("./src/crypt/aes-decryptor.ts"),I=n("./src/utils/logger.ts"),T=n("./src/utils/mp4-tools.ts"),b=n("./src/utils/typed-array.ts"),_=16,E=function(){function A(x,g,y){var s=y===void 0?{}:y,e=s.removePKCS7Padding,o=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=x,this.config=g,this.removePKCS7Padding=o,o)try{var f=self.crypto;f&&(this.subtle=f.subtle||f.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 g=this.currentResult;if(!g){this.reset();return}var y=new Uint8Array(g);return this.reset(),this.removePKCS7Padding?Object(S.removePadding)(y):y},D.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},D.decrypt=function(g,y,s,e){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(g),y,s);var o=this.flush();o&&e(o.buffer)}else this.webCryptoDecrypt(new Uint8Array(g),y,s).then(e)},D.softwareDecrypt=function(g,y,s){var e=this.currentIV,o=this.currentResult,f=this.remainderData;this.logOnce("JS AES decrypt"),f&&(g=Object(T.appendUint8Array)(f,g),this.remainderData=null);var a=this.getValidChunk(g);if(!a.length)return null;e&&(s=e);var i=this.softwareDecrypter;i||(i=this.softwareDecrypter=new S.default),i.expandKey(y);var t=o;return this.currentResult=i.decrypt(a.buffer,0,s),this.currentIV=Object(b.sliceUint8)(a,-16).buffer,t||null},D.webCryptoDecrypt=function(g,y,s){var e=this,o=this.subtle;return(this.key!==y||!this.fastAesKey)&&(this.key=y,this.fastAesKey=new m.default(o,y)),this.fastAesKey.expandKey().then(function(f){if(!o)return Promise.reject(new Error("web crypto not initialized"));var a=new R.default(o,s);return a.decrypt(g.buffer,f)}).catch(function(f){return e.onWebCryptoError(f,g,y,s)})},D.onWebCryptoError=function(g,y,s,e){return I.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",g),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(y,s,e)},D.getValidChunk=function(g){var y=g,s=g.length-g.length%_;return s!==g.length&&(y=Object(b.sliceUint8)(g,0,s),this.remainderData=Object(b.sliceUint8)(g,s)),y},D.logOnce=function(g){!this.logEnabled||(I.logger.log("[decrypter.ts]: "+g),this.logEnabled=!1)},A}()},"./src/crypt/fast-aes-key.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return R});var R=function(){function m(I,T){this.subtle=void 0,this.key=void 0,this.subtle=I,this.key=T}var S=m.prototype;return S.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},m}()},"./src/demux/aacdemuxer.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/demux/base-audio-demuxer.ts"),m=n("./src/demux/adts.ts"),S=n("./src/utils/logger.ts"),I=n("./src/demux/id3.ts");function T(E,A){E.prototype=Object.create(A.prototype),E.prototype.constructor=E,b(E,A)}function b(E,A){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(x,g){return x.__proto__=g,x},b(E,A)}var _=function(E){T(A,E);function A(x,g){var y;return y=E.call(this)||this,y.observer=void 0,y.config=void 0,y.observer=x,y.config=g,y}var D=A.prototype;return D.resetInitSegment=function(g,y,s,e){E.prototype.resetInitSegment.call(this,g,y,s,e),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:y,duration:e,inputTimeScale:9e4,dropped:0}},A.probe=function(g){if(!g)return!1;for(var y=I.getID3Data(g,0)||[],s=y.length,e=g.length;s<e;s++)if(m.probe(g,s))return S.logger.log("ADTS sync word found !"),!0;return!1},D.canParse=function(g,y){return m.canParse(g,y)},D.appendFrame=function(g,y,s){m.initTrackConfig(g,this.observer,y,s,g.manifestCodec);var e=m.appendFrame(g,y,s,this.basePTS,this.frameIndex);if(e&&e.missing===0)return e},A}(R.default);P.default=_},"./src/demux/adts.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"getAudioConfig",function(){return I}),n.d(P,"isHeaderPattern",function(){return T}),n.d(P,"getHeaderLength",function(){return b}),n.d(P,"getFullFrameLength",function(){return _}),n.d(P,"canGetFrameLength",function(){return E}),n.d(P,"isHeader",function(){return A}),n.d(P,"canParse",function(){return D}),n.d(P,"probe",function(){return x}),n.d(P,"initTrackConfig",function(){return g}),n.d(P,"getFrameDuration",function(){return y}),n.d(P,"parseFrameHeader",function(){return s}),n.d(P,"appendFrame",function(){return e});var R=n("./src/utils/logger.ts"),m=n("./src/errors.ts"),S=n("./src/events.ts");function I(o,f,a,i){var t,u,c,r,h=navigator.userAgent.toLowerCase(),d=i,l=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];t=((f[a+2]&192)>>>6)+1;var v=(f[a+2]&60)>>>2;if(v>l.length-1){o.trigger(S.Events.ERROR,{type:m.ErrorTypes.MEDIA_ERROR,details:m.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+v});return}return c=(f[a+2]&1)<<2,c|=(f[a+3]&192)>>>6,R.logger.log("manifest codec:"+i+", ADTS type:"+t+", samplingIndex:"+v),/firefox/i.test(h)?v>=6?(t=5,r=new Array(4),u=v-3):(t=2,r=new Array(2),u=v):h.indexOf("android")!==-1?(t=2,r=new Array(2),u=v):(t=5,r=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&v>=6?u=v-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(v>=6&&c===1||/vivaldi/i.test(h))||!i&&c===1)&&(t=2,r=new Array(2)),u=v)),r[0]=t<<3,r[0]|=(v&14)>>1,r[1]|=(v&1)<<7,r[1]|=c<<3,t===5&&(r[1]|=(u&14)>>1,r[2]=(u&1)<<7,r[2]|=2<<2,r[3]=0),{config:r,samplerate:l[v],channelCount:c,codec:"mp4a.40."+t,manifestCodec:d}}function T(o,f){return o[f]===255&&(o[f+1]&246)===240}function b(o,f){return o[f+1]&1?7:9}function _(o,f){return(o[f+3]&3)<<11|o[f+4]<<3|(o[f+5]&224)>>>5}function E(o,f){return f+5<o.length}function A(o,f){return f+1<o.length&&T(o,f)}function D(o,f){return E(o,f)&&T(o,f)&&_(o,f)<=o.length-f}function x(o,f){if(A(o,f)){var a=b(o,f);if(f+a>=o.length)return!1;var i=_(o,f);if(i<=a)return!1;var t=f+i;return t===o.length||A(o,t)}return!1}function g(o,f,a,i,t){if(!o.samplerate){var u=I(f,a,i,t);if(!u)return;o.config=u.config,o.samplerate=u.samplerate,o.channelCount=u.channelCount,o.codec=u.codec,o.manifestCodec=u.manifestCodec,R.logger.log("parsed codec:"+o.codec+", rate:"+u.samplerate+", channels:"+u.channelCount)}}function y(o){return 1024*9e4/o}function s(o,f){var a=b(o,f);if(f+a<=o.length){var i=_(o,f)-a;if(i>0)return{headerLength:a,frameLength:i}}}function e(o,f,a,i,t){var u=y(o.samplerate),c=i+t*u,r=s(f,a),h;if(r){var d=r.frameLength,l=r.headerLength,v=l+d,p=Math.max(0,a+v-f.length);p?(h=new Uint8Array(v-l),h.set(f.subarray(a+l,f.length),0)):h=f.subarray(a+l,a+v);var L={unit:h,pts:c};return p||o.samples.push(L),{sample:L,length:v,missing:p}}var O=f.length-a;h=new Uint8Array(O),h.set(f.subarray(a,f.length),0);var M={unit:h,pts:c};return{sample:M,length:O,missing:-1}}},"./src/demux/base-audio-demuxer.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"initPTSFn",function(){return E});var R=n("./src/polyfills/number.ts"),m=n("./src/demux/id3.ts"),S=n("./src/types/demuxer.ts"),I=n("./src/demux/dummy-demuxed-track.ts"),T=n("./src/utils/mp4-tools.ts"),b=n("./src/utils/typed-array.ts"),_=function(){function A(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null}var D=A.prototype;return D.resetInitSegment=function(g,y,s,e){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},D.resetTimeStamp=function(g){this.initPTS=g,this.resetContiguity()},D.resetContiguity=function(){this.basePTS=null,this.frameIndex=0},D.canParse=function(g,y){return!1},D.appendFrame=function(g,y,s){},D.demux=function(g,y){this.cachedData&&(g=Object(T.appendUint8Array)(this.cachedData,g),this.cachedData=null);var s=m.getID3Data(g,0),e=s?s.length:0,o,f,a=this._audioTrack,i=this._id3Track,t=s?m.getTimeStamp(s):void 0,u=g.length;for((this.basePTS===null||this.frameIndex===0&&Object(R.isFiniteNumber)(t))&&(this.basePTS=E(t,y,this.initPTS)),s&&s.length>0&&i.samples.push({pts:this.basePTS,dts:this.basePTS,data:s,type:S.MetadataSchema.audioId3}),f=this.basePTS;e<u;){if(this.canParse(g,e)){var c=this.appendFrame(a,g,e);c?(this.frameIndex++,f=c.sample.pts,e+=c.length,o=e):e=u}else m.canParse(g,e)?(s=m.getID3Data(g,e),i.samples.push({pts:f,dts:f,data:s,type:S.MetadataSchema.audioId3}),e+=s.length,o=e):e++;if(e===u&&o!==u){var r=Object(b.sliceUint8)(g,o);this.cachedData?this.cachedData=Object(T.appendUint8Array)(this.cachedData,r):this.cachedData=r}}return{audioTrack:a,videoTrack:Object(I.dummyTrack)(),id3Track:i,textTrack:Object(I.dummyTrack)()}},D.demuxSampleAes=function(g,y,s){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},D.flush=function(g){var y=this.cachedData;return y&&(this.cachedData=null,this.demux(y,0)),{audioTrack:this._audioTrack,videoTrack:Object(I.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(I.dummyTrack)()}},D.destroy=function(){},A}(),E=function(D,x,g){return Object(R.isFiniteNumber)(D)?D*90:x*9e4+(g||0)};P.default=_},"./src/demux/chunk-cache.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return R});var R=function(){function S(){this.chunks=[],this.dataLength=0}var I=S.prototype;return I.push=function(b){this.chunks.push(b),this.dataLength+=b.length},I.flush=function(){var b=this.chunks,_=this.dataLength,E;if(b.length)b.length===1?E=b[0]:E=m(b,_);else return new Uint8Array(0);return this.reset(),E},I.reset=function(){this.chunks.length=0,this.dataLength=0},S}();function m(S,I){for(var T=new Uint8Array(I),b=0,_=0;_<S.length;_++){var E=S[_];T.set(E,b),b+=E.length}return T}},"./src/demux/dummy-demuxed-track.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"dummyTrack",function(){return R});function R(m,S){return m===void 0&&(m=""),S===void 0&&(S=9e4),{type:m,id:-1,pid:-1,inputTimeScale:S,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/utils/logger.ts"),m=function(){function S(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 I=S.prototype;return I.loadWord=function(){var b=this.data,_=this.bytesAvailable,E=b.byteLength-_,A=new Uint8Array(4),D=Math.min(4,_);if(D===0)throw new Error("no bytes available");A.set(b.subarray(E,E+D)),this.word=new DataView(A.buffer).getUint32(0),this.bitsAvailable=D*8,this.bytesAvailable-=D},I.skipBits=function(b){var _;this.bitsAvailable>b?(this.word<<=b,this.bitsAvailable-=b):(b-=this.bitsAvailable,_=b>>3,b-=_>>3,this.bytesAvailable-=_,this.loadWord(),this.word<<=b,this.bitsAvailable-=b)},I.readBits=function(b){var _=Math.min(this.bitsAvailable,b),E=this.word>>>32-_;return b>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(),_=b-_,_>0&&this.bitsAvailable?E<<_|this.readBits(_):E},I.skipLZ=function(){var b;for(b=0;b<this.bitsAvailable;++b)if((this.word&2147483648>>>b)!==0)return this.word<<=b,this.bitsAvailable-=b,b;return this.loadWord(),b+this.skipLZ()},I.skipUEG=function(){this.skipBits(1+this.skipLZ())},I.skipEG=function(){this.skipBits(1+this.skipLZ())},I.readUEG=function(){var b=this.skipLZ();return this.readBits(b+1)-1},I.readEG=function(){var b=this.readUEG();return 1&b?1+b>>>1:-1*(b>>>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(b){for(var _=8,E=8,A,D=0;D<b;D++)E!==0&&(A=this.readEG(),E=(_+A+256)%256),_=E===0?_:E},I.readSPS=function(){var b=0,_=0,E=0,A=0,D,x,g,y=this.readUByte.bind(this),s=this.readBits.bind(this),e=this.readUEG.bind(this),o=this.readBoolean.bind(this),f=this.skipBits.bind(this),a=this.skipEG.bind(this),i=this.skipUEG.bind(this),t=this.skipScalingList.bind(this);y();var u=y();if(s(5),f(3),y(),i(),u===100||u===110||u===122||u===244||u===44||u===83||u===86||u===118||u===128){var c=e();if(c===3&&f(1),i(),i(),f(1),o())for(x=c!==3?8:12,g=0;g<x;g++)o()&&(g<6?t(16):t(64))}i();var r=e();if(r===0)e();else if(r===1)for(f(1),a(),a(),D=e(),g=0;g<D;g++)a();i(),f(1);var h=e(),d=e(),l=s(1);l===0&&f(1),f(1),o()&&(b=e(),_=e(),E=e(),A=e());var v=[1,1];if(o()&&o()){var p=y();switch(p){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=[y()<<8|y(),y()<<8|y()];break}}}return{width:Math.ceil((h+1)*16-b*2-_*2),height:(2-l)*(d+1)*16-(l?2:4)*(E+A),pixelRatio:v}},I.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},S}();P.default=m},"./src/demux/id3.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"isHeader",function(){return R}),n.d(P,"isFooter",function(){return m}),n.d(P,"getID3Data",function(){return S}),n.d(P,"canParse",function(){return T}),n.d(P,"getTimeStamp",function(){return b}),n.d(P,"isTimeStampFrame",function(){return _}),n.d(P,"getID3Frames",function(){return A}),n.d(P,"decodeFrame",function(){return D}),n.d(P,"utf8ArrayToStr",function(){return e}),n.d(P,"testables",function(){return o});var R=function(t,u){return u+10<=t.length&&t[u]===73&&t[u+1]===68&&t[u+2]===51&&t[u+3]<255&&t[u+4]<255&&t[u+6]<128&&t[u+7]<128&&t[u+8]<128&&t[u+9]<128},m=function(t,u){return u+10<=t.length&&t[u]===51&&t[u+1]===68&&t[u+2]===73&&t[u+3]<255&&t[u+4]<255&&t[u+6]<128&&t[u+7]<128&&t[u+8]<128&&t[u+9]<128},S=function(t,u){for(var c=u,r=0;R(t,u);){r+=10;var h=I(t,u+6);r+=h,m(t,u+10)&&(r+=10),u+=r}if(r>0)return t.subarray(c,c+r)},I=function(t,u){var c=0;return c=(t[u]&127)<<21,c|=(t[u+1]&127)<<14,c|=(t[u+2]&127)<<7,c|=t[u+3]&127,c},T=function(t,u){return R(t,u)&&I(t,u+6)+10<=t.length-u},b=function(t){for(var u=A(t),c=0;c<u.length;c++){var r=u[c];if(_(r))return s(r)}},_=function(t){return t&&t.key==="PRIV"&&t.info==="com.apple.streaming.transportStreamTimestamp"},E=function(t){var u=String.fromCharCode(t[0],t[1],t[2],t[3]),c=I(t,4),r=10;return{type:u,size:c,data:t.subarray(r,r+c)}},A=function(t){for(var u=0,c=[];R(t,u);){var r=I(t,u+6);u+=10;for(var h=u+r;u+8<h;){var d=E(t.subarray(u)),l=D(d);l&&c.push(l),u+=d.size+10}m(t,u)&&(u+=10)}return c},D=function(t){return t.type==="PRIV"?x(t):t.type[0]==="W"?y(t):g(t)},x=function(t){if(!(t.size<2)){var u=e(t.data,!0),c=new Uint8Array(t.data.subarray(u.length+1));return{key:t.type,info:u,data:c.buffer}}},g=function(t){if(!(t.size<2)){if(t.type==="TXXX"){var u=1,c=e(t.data.subarray(u),!0);u+=c.length+1;var r=e(t.data.subarray(u));return{key:t.type,info:c,data:r}}var h=e(t.data.subarray(1));return{key:t.type,data:h}}},y=function(t){if(t.type==="WXXX"){if(t.size<2)return;var u=1,c=e(t.data.subarray(u),!0);u+=c.length+1;var r=e(t.data.subarray(u));return{key:t.type,info:c,data:r}}var h=e(t.data);return{key:t.type,data:h}},s=function(t){if(t.data.byteLength===8){var u=new Uint8Array(t.data),c=u[3]&1,r=(u[4]<<23)+(u[5]<<15)+(u[6]<<7)+u[7];return r/=45,c&&(r+=4772185884e-2),Math.round(r)}},e=function(t,u){u===void 0&&(u=!1);var c=a();if(c){var r=c.decode(t);if(u){var h=r.indexOf("\0");return h!==-1?r.substring(0,h):r}return r.replace(/\0/g,"")}for(var d=t.length,l,v,p,L="",O=0;O<d;){if(l=t[O++],l===0&&u)return L;if(l===0||l===3)continue;switch(l>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:L+=String.fromCharCode(l);break;case 12:case 13:v=t[O++],L+=String.fromCharCode((l&31)<<6|v&63);break;case 14:v=t[O++],p=t[O++],L+=String.fromCharCode((l&15)<<12|(v&63)<<6|(p&63)<<0);break;default:}}return L},o={decodeTextFrame:g},f;function a(){return!f&&typeof self.TextDecoder!="undefined"&&(f=new self.TextDecoder("utf-8")),f}},"./src/demux/mp3demuxer.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/demux/base-audio-demuxer.ts"),m=n("./src/demux/id3.ts"),S=n("./src/utils/logger.ts"),I=n("./src/demux/mpegaudio.ts");function T(E,A){E.prototype=Object.create(A.prototype),E.prototype.constructor=E,b(E,A)}function b(E,A){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(x,g){return x.__proto__=g,x},b(E,A)}var _=function(E){T(A,E);function A(){return E.apply(this,arguments)||this}var D=A.prototype;return D.resetInitSegment=function(g,y,s,e){E.prototype.resetInitSegment.call(this,g,y,s,e),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:y,duration:e,inputTimeScale:9e4,dropped:0}},A.probe=function(g){if(!g)return!1;for(var y=m.getID3Data(g,0)||[],s=y.length,e=g.length;s<e;s++)if(I.probe(g,s))return S.logger.log("MPEG Audio sync word found !"),!0;return!1},D.canParse=function(g,y){return I.canParse(g,y)},D.appendFrame=function(g,y,s){if(this.basePTS!==null)return I.appendFrame(g,y,s,this.basePTS,this.frameIndex)},A}(R.default);P.default=_},"./src/demux/mp4demuxer.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/polyfills/number.ts"),m=n("./src/types/demuxer.ts"),S=n("./src/utils/mp4-tools.ts"),I=n("./src/demux/dummy-demuxed-track.ts"),T=/\/emsg[-/]ID3/i,b=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=D}var E=_.prototype;return E.resetTimeStamp=function(){},E.resetInitSegment=function(D,x,g,y){var s=Object(S.parseInitSegment)(D),e=this.videoTrack=Object(I.dummyTrack)("video",1),o=this.audioTrack=Object(I.dummyTrack)("audio",1),f=this.txtTrack=Object(I.dummyTrack)("text",1);if(this.id3Track=Object(I.dummyTrack)("id3",1),this.timeOffset=0,s.video){var a=s.video,i=a.id,t=a.timescale,u=a.codec;e.id=i,e.timescale=f.timescale=t,e.codec=u}if(s.audio){var c=s.audio,r=c.id,h=c.timescale,d=c.codec;o.id=r,o.timescale=h,o.codec=d}f.id=S.RemuxerTrackIdConfig.text,e.sampleDuration=0,e.duration=o.duration=y},E.resetContiguity=function(){},_.probe=function(D){return D=D.length>16384?D.subarray(0,16384):D,Object(S.findBox)(D,["moof"]).length>0},E.demux=function(D,x){this.timeOffset=x;var g=D,y=this.videoTrack,s=this.txtTrack;if(this.config.progressive){this.remainderData&&(g=Object(S.appendUint8Array)(this.remainderData,D));var e=Object(S.segmentValidRange)(g);this.remainderData=e.remainder,y.samples=e.valid||new Uint8Array}else y.samples=g;var o=this.extractID3Track(y,x);return s.samples=Object(S.parseSamples)(x,y),{videoTrack:y,audioTrack:this.audioTrack,id3Track:o,textTrack:this.txtTrack}},E.flush=function(){var D=this.timeOffset,x=this.videoTrack,g=this.txtTrack;x.samples=this.remainderData||new Uint8Array,this.remainderData=null;var y=this.extractID3Track(x,this.timeOffset);return g.samples=Object(S.parseSamples)(D,x),{videoTrack:x,audioTrack:Object(I.dummyTrack)(),id3Track:y,textTrack:Object(I.dummyTrack)()}},E.extractID3Track=function(D,x){var g=this.id3Track;if(D.samples.length){var y=Object(S.findBox)(D.samples,["emsg"]);y&&y.forEach(function(s){var e=Object(S.parseEmsg)(s);if(T.test(e.schemeIdUri)){var o=Object(R.isFiniteNumber)(e.presentationTime)?e.presentationTime/e.timeScale:x+e.presentationTimeDelta/e.timeScale,f=e.payload;g.samples.push({data:f,len:f.byteLength,dts:o,pts:o,type:m.MetadataSchema.emsg})}})}return g},E.demuxSampleAes=function(D,x,g){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},E.destroy=function(){},_}();P.default=b},"./src/demux/mpegaudio.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"appendFrame",function(){return b}),n.d(P,"parseHeader",function(){return _}),n.d(P,"isHeaderPattern",function(){return E}),n.d(P,"isHeader",function(){return A}),n.d(P,"canParse",function(){return D}),n.d(P,"probe",function(){return x});var R=null,m=[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]],T=[0,1,1,4];function b(g,y,s,e,o){if(!(s+24>y.length)){var f=_(y,s);if(f&&s+f.frameLength<=y.length){var a=f.samplesPerFrame*9e4/f.sampleRate,i=e+o*a,t={unit:y.subarray(s,s+f.frameLength),pts:i,dts:i};return g.config=[],g.channelCount=f.channelCount,g.samplerate=f.sampleRate,g.samples.push(t),{sample:t,length:f.frameLength,missing:0}}}}function _(g,y){var s=g[y+1]>>3&3,e=g[y+1]>>1&3,o=g[y+2]>>4&15,f=g[y+2]>>2&3;if(s!==1&&o!==0&&o!==15&&f!==3){var a=g[y+2]>>1&1,i=g[y+3]>>6,t=s===3?3-e:e===3?3:4,u=m[t*14+o-1]*1e3,c=s===3?0:s===2?1:2,r=S[c*3+f],h=i===3?1:2,d=I[s][e],l=T[e],v=d*8*l,p=Math.floor(d*u/r+a)*l;if(R===null){var L=navigator.userAgent||"",O=L.match(/Chrome\/(\d+)/i);R=O?parseInt(O[1]):0}var M=!!R&&R<=87;return M&&e===2&&u>=224e3&&i===0&&(g[y+3]=g[y+3]|128),{sampleRate:r,channelCount:h,frameLength:p,samplesPerFrame:v}}}function E(g,y){return g[y]===255&&(g[y+1]&224)===224&&(g[y+1]&6)!==0}function A(g,y){return y+1<g.length&&E(g,y)}function D(g,y){var s=4;return E(g,y)&&s<=g.length-y}function x(g,y){if(y+1<g.length&&E(g,y)){var s=4,e=_(g,y),o=s;e!=null&&e.frameLength&&(o=e.frameLength);var f=y+o;return f===g.length||A(g,f)}return!1}},"./src/demux/sample-aes.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/crypt/decrypter.ts"),m=n("./src/demux/tsdemuxer.ts"),S=function(){function I(b,_,E){this.keyData=void 0,this.decrypter=void 0,this.keyData=E,this.decrypter=new R.default(b,_,{removePKCS7Padding:!1})}var T=I.prototype;return T.decryptBuffer=function(_,E){this.decrypter.decrypt(_,this.keyData.key.buffer,this.keyData.iv.buffer,E)},T.decryptAacSample=function(_,E,A,D){var x=_[E].unit;if(!(x.length<=16)){var g=x.subarray(16,x.length-x.length%16),y=g.buffer.slice(g.byteOffset,g.byteOffset+g.length),s=this;this.decryptBuffer(y,function(e){var o=new Uint8Array(e);x.set(o,16),D||s.decryptAacSamples(_,E+1,A)})}},T.decryptAacSamples=function(_,E,A){for(;;E++){if(E>=_.length){A();return}if(!(_[E].unit.length<32)){var D=this.decrypter.isSync();if(this.decryptAacSample(_,E,A,D),!D)return}}},T.getAvcEncryptedData=function(_){for(var E=Math.floor((_.length-48)/160)*16+16,A=new Int8Array(E),D=0,x=32;x<_.length-16;x+=160,D+=16)A.set(_.subarray(x,x+16),D);return A},T.getAvcDecryptedUnit=function(_,E){for(var A=new Uint8Array(E),D=0,x=32;x<_.length-16;x+=160,D+=16)_.set(A.subarray(D,D+16),x);return _},T.decryptAvcSample=function(_,E,A,D,x,g){var y=Object(m.discardEPB)(x.data),s=this.getAvcEncryptedData(y),e=this;this.decryptBuffer(s.buffer,function(o){x.data=e.getAvcDecryptedUnit(y,o),g||e.decryptAvcSamples(_,E,A+1,D)})},T.decryptAvcSamples=function(_,E,A,D){if(_ instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;E++,A=0){if(E>=_.length){D();return}for(var x=_[E].units;!(A>=x.length);A++){var g=x[A];if(!(g.data.length<=48||g.type!==1&&g.type!==5)){var y=this.decrypter.isSync();if(this.decryptAvcSample(_,E,A,D,g,y),!y)return}}}},I}();P.default=S},"./src/demux/transmuxer-interface.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return x});var R=n("./node_modules/webworkify-webpack/index.js"),m=n.n(R),S=n("./src/events.ts"),I=n("./src/demux/transmuxer.ts"),T=n("./src/utils/logger.ts"),b=n("./src/errors.ts"),_=n("./src/utils/mediasource-helper.ts"),E=n("./node_modules/eventemitter3/index.js"),A=n.n(E),D=Object(_.getMediaSource)()||{isTypeSupported:function(){return!1}},x=function(){function g(s,e,o,f){var a=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=o,this.onFlush=f;var i=s.config,t=function(d,l){l=l||{},l.frag=a.frag,l.id=a.id,s.trigger(d,l)};this.observer=new E.EventEmitter,this.observer.on(S.Events.FRAG_DECRYPTED,t),this.observer.on(S.Events.ERROR,t);var u={mp4:D.isTypeSupported("video/mp4"),mpeg:D.isTypeSupported("audio/mpeg"),mp3:D.isTypeSupported('audio/mp4; codecs="mp3"')},c=navigator.vendor;if(i.enableWorker&&typeof Worker!="undefined"){T.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(h){s.trigger(S.Events.ERROR,{type:b.ErrorTypes.OTHER_ERROR,details:b.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(h.message+" ("+h.filename+":"+h.lineno+")")})},r.postMessage({cmd:"init",typeSupported:u,vendor:c,id:e,config:JSON.stringify(i)})}catch(h){T.logger.warn("Error in worker:",h),T.logger.error("Error while initializing DemuxerWorker, fallback to inline"),r&&self.URL.revokeObjectURL(r.objectURL),this.transmuxer=new I.default(this.observer,u,i,c,e),this.worker=null}}else this.transmuxer=new I.default(this.observer,u,i,c,e)}var y=g.prototype;return y.destroy=function(){var e=this.worker;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.worker=null,this.onwmsg=void 0;else{var o=this.transmuxer;o&&(o.destroy(),this.transmuxer=null)}var f=this.observer;f&&f.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},y.push=function(e,o,f,a,i,t,u,c,r,h){var d,l,v=this;r.transmuxing.start=self.performance.now();var p=this.transmuxer,L=this.worker,O=t?t.start:i.start,M=i.decryptdata,F=this.frag,w=!(F&&i.cc===F.cc),C=!(F&&r.level===F.level),k=F?r.sn-F.sn:-1,U=this.part?r.part-this.part.index:-1,j=k===0&&r.id>1&&r.id===(F==null?void 0:F.stats.chunkCount),N=!C&&(k===1||k===0&&(U===1||j&&U<=0)),W=self.performance.now();(C||k||i.stats.parsing.start===0)&&(i.stats.parsing.start=W),t&&(U||!N)&&(t.stats.parsing.start=W);var Y=!(F&&((d=i.initSegment)===null||d===void 0?void 0:d.url)===((l=F.initSegment)===null||l===void 0?void 0:l.url)),K=new I.TransmuxState(w,N,c,C,O,Y);if(!N||w||Y){T.logger.log("[transmuxer-interface, "+i.type+"]: Starting new transmux session for sn: "+r.sn+" p: "+r.part+" level: "+r.level+" id: "+r.id+`
|
|
13
13
|
discontinuity: `+w+`
|
|
14
14
|
trackSwitch: `+C+`
|
|
15
15
|
contiguous: `+N+`
|
|
16
16
|
accurateTimeOffset: `+c+`
|
|
17
|
-
timeOffset: `+
|
|
18
|
-
initSegmentChange: `+Y);var H=new I.TransmuxConfig(f,a,o,u,h);this.configureTransmuxer(H)}if(this.frag=i,this.part=t,L)L.postMessage({cmd:"demux",data:e,decryptdata:M,chunkMeta:r,state:K},e instanceof ArrayBuffer?[e]:[]);else if(m){var z=m.push(e,M,r,K);Object(I.isPromise)(z)?z.then(function($){v.handleTransmuxComplete($)}):this.handleTransmuxComplete(z)}},y.flush=function(e){var o=this;e.transmuxing.start=self.performance.now();var f=this.transmuxer,a=this.worker;if(a)a.postMessage({cmd:"flush",chunkMeta:e});else if(f){var i=f.flush(e);Object(I.isPromise)(i)?i.then(function(t){o.handleFlushResult(t,e)}):this.handleFlushResult(i,e)}},y.handleFlushResult=function(e,o){var f=this;e.forEach(function(a){f.handleTransmuxComplete(a)}),this.onFlush(o)},y.onWorkerMessage=function(e){var o=e.data,f=this.hls;switch(o.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(o.data);break}case"flush":{this.onFlush(o.data);break}case"workerLog":S.logger[o.data.logType]&&S.logger[o.data.logType](o.data.message);break;default:{o.data=o.data||{},o.data.frag=this.frag,o.data.id=this.id,f.trigger(o.event,o.data);break}}},y.configureTransmuxer=function(e){var o=this.worker,f=this.transmuxer;o?o.postMessage({cmd:"configure",config:e}):f&&f.configure(e)},y.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},g}()},"./src/demux/transmuxer-worker.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return O});var R=n("./src/demux/transmuxer.ts"),p=n("./src/events.ts"),T=n("./src/utils/logger.ts"),I=n("./node_modules/eventemitter3/index.js"),S=n.n(I);function O(x){var g=new I.EventEmitter,y=function(o,f){x.postMessage({event:o,data:f})};g.on(p.Events.FRAG_DECRYPTED,y),g.on(p.Events.ERROR,y);var s=function(){var o=function(i){var t=function(c){y("workerLog",{logType:i,message:c})};T.logger[i]=t};for(var f in T.logger)o(f)};x.addEventListener("message",function(e){var o=e.data;switch(o.cmd){case"init":{var f=JSON.parse(o.config);x.transmuxer=new R.default(g,o.typeSupported,f,o.vendor,o.id),Object(T.enableLogs)(f.debug),s(),y("init",null);break}case"configure":{x.transmuxer.configure(o.config);break}case"demux":{var a=x.transmuxer.push(o.data,o.decryptdata,o.chunkMeta,o.state);Object(R.isPromise)(a)?a.then(function(u){_(x,u)}):_(x,a);break}case"flush":{var i=o.chunkMeta,t=x.transmuxer.flush(i);Object(R.isPromise)(t)?t.then(function(u){A(x,u,i)}):A(x,t,i);break}default:break}})}function _(x,g){if(D(g.remuxResult))return!1;var y=[],s=g.remuxResult,e=s.audio,o=s.video;return e&&E(y,e),o&&E(y,o),x.postMessage({event:"transmuxComplete",data:g},y),!0}function E(x,g){g.data1&&x.push(g.data1.buffer),g.data2&&x.push(g.data2.buffer)}function A(x,g,y){var s=g.reduce(function(e,o){return _(x,o)||e},!1);s||x.postMessage({event:"transmuxComplete",data:g[0]}),x.postMessage({event:"flush",data:y})}function D(x){return!x.audio&&!x.video&&!x.text&&!x.id3&&!x.initSegment}},"./src/demux/transmuxer.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return y}),n.d(P,"isPromise",function(){return o}),n.d(P,"TransmuxConfig",function(){return f}),n.d(P,"TransmuxState",function(){return a});var R=n("./src/events.ts"),p=n("./src/errors.ts"),T=n("./src/crypt/decrypter.ts"),I=n("./src/demux/aacdemuxer.ts"),S=n("./src/demux/mp4demuxer.ts"),O=n("./src/demux/tsdemuxer.ts"),_=n("./src/demux/mp3demuxer.ts"),E=n("./src/remux/mp4-remuxer.ts"),A=n("./src/remux/passthrough-remuxer.ts"),D=n("./src/utils/logger.ts"),x;try{x=self.performance.now.bind(self.performance)}catch{D.logger.debug("Unable to use Performance API on this environment"),x=self.Date.now}var g=[{demux:O.default,remux:E.default},{demux:S.default,remux:A.default},{demux:I.default,remux:E.default},{demux:_.default,remux:E.default}],y=function(){function i(u,c,r,h,d){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=u,this.typeSupported=c,this.config=r,this.vendor=h,this.id=d}var t=i.prototype;return t.configure=function(c){this.transmuxConfig=c,this.decrypter&&this.decrypter.reset()},t.push=function(c,r,h,d){var l=this,v=h.transmuxing;v.executeStart=x();var m=new Uint8Array(c),L=this.config,b=this.currentTransmuxState,M=this.transmuxConfig;d&&(this.currentTransmuxState=d);var F=d||b,w=F.contiguous,C=F.discontinuity,U=F.trackSwitch,k=F.accurateTimeOffset,j=F.timeOffset,N=F.initSegmentChange,W=M.audioCodec,Y=M.videoCodec,K=M.defaultInitPts,H=M.duration,z=M.initSegmentData;(C||U||N)&&this.resetInitSegment(z,W,Y,H),(C||N)&&this.resetInitialTimestamp(K),w||this.resetContiguity();var $=s(m,r);if($&&$.method==="AES-128"){var X=this.getDecrypter();if(L.enableSoftwareAES){var J=X.softwareDecrypt(m,$.key.buffer,$.iv.buffer);if(!J)return v.executeEnd=x(),e(h);m=new Uint8Array(J)}else return this.decryptionPromise=X.webCryptoDecrypt(m,$.key.buffer,$.iv.buffer).then(function(ae){var se=l.push(ae,null,h);return l.decryptionPromise=null,se}),this.decryptionPromise}this.needsProbing(m,C,U)&&this.configureTransmuxer(m,M);var te=this.transmux(m,$,j,k,h),Q=this.currentTransmuxState;return Q.contiguous=!0,Q.discontinuity=!1,Q.trackSwitch=!1,v.executeEnd=x(),te},t.flush=function(c){var r=this,h=c.transmuxing;h.executeStart=x();var d=this.decrypter,l=this.currentTransmuxState,v=this.decryptionPromise;if(v)return v.then(function(){return r.flush(c)});var m=[],L=l.timeOffset;if(d){var b=d.flush();b&&m.push(this.push(b,null,c))}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"}),h.executeEnd=x(),[e(c)];var w=M.flush(L);return o(w)?w.then(function(C){return r.flushRemux(m,C,c),m}):(this.flushRemux(m,w,c),m)},t.flushRemux=function(c,r,h){var d=r.audioTrack,l=r.videoTrack,v=r.id3Track,m=r.textTrack,L=this.currentTransmuxState,b=L.accurateTimeOffset,M=L.timeOffset;D.logger.log("[transmuxer.ts]: Flushed fragment "+h.sn+(h.part>-1?" p: "+h.part:"")+" of level "+h.level);var F=this.remuxer.remux(d,l,v,m,M,b,!0,this.id);c.push({remuxResult:F,chunkMeta:h}),h.transmuxing.executeEnd=x()},t.resetInitialTimestamp=function(c){var r=this.demuxer,h=this.remuxer;!r||!h||(r.resetTimeStamp(c),h.resetTimeStamp(c))},t.resetContiguity=function(){var c=this.demuxer,r=this.remuxer;!c||!r||(c.resetContiguity(),r.resetNextTimestamp())},t.resetInitSegment=function(c,r,h,d){var l=this.demuxer,v=this.remuxer;!l||!v||(l.resetInitSegment(c,r,h,d),v.resetInitSegment(c,r,h))},t.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},t.transmux=function(c,r,h,d,l){var v;return r&&r.method==="SAMPLE-AES"?v=this.transmuxSampleAes(c,r,h,d,l):v=this.transmuxUnencrypted(c,h,d,l),v},t.transmuxUnencrypted=function(c,r,h,d){var l=this.demuxer.demux(c,r,!1,!this.config.progressive),v=l.audioTrack,m=l.videoTrack,L=l.id3Track,b=l.textTrack,M=this.remuxer.remux(v,m,L,b,r,h,!1,this.id);return{remuxResult:M,chunkMeta:d}},t.transmuxSampleAes=function(c,r,h,d,l){var v=this;return this.demuxer.demuxSampleAes(c,r,h).then(function(m){var L=v.remuxer.remux(m.audioTrack,m.videoTrack,m.id3Track,m.textTrack,h,d,!1,v.id);return{remuxResult:L,chunkMeta:l}})},t.configureTransmuxer=function(c,r){for(var h=this.config,d=this.observer,l=this.typeSupported,v=this.vendor,m=r.audioCodec,L=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(c)){w=g[C];break}w||(D.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),w={demux:S.default,remux:A.default});var k=this.demuxer,j=this.remuxer,N=w.remux,W=w.demux;(!j||!(j instanceof N))&&(this.remuxer=new N(d,h,l,v)),(!k||!(k instanceof W))&&(this.demuxer=new W(d,h,l),this.probe=W.probe),this.resetInitSegment(M,m,F,b),this.resetInitialTimestamp(L)},t.needsProbing=function(c,r,h){return!this.demuxer||!this.remuxer||r||h},t.getDecrypter=function(){var c=this.decrypter;return c||(c=this.decrypter=new T.default(this.observer,this.config)),c},i}();function s(i,t){var u=null;return i.byteLength>0&&t!=null&&t.key!=null&&t.iv!==null&&t.method!=null&&(u=t),u}var e=function(t){return{remuxResult:{},chunkMeta:t}};function o(i){return"then"in i&&i.then instanceof Function}var f=function(t,u,c,r,h){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=u,this.initSegmentData=c,this.duration=r,this.defaultInitPts=h},a=function(t,u,c,r,h,d){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=u,this.accurateTimeOffset=c,this.trackSwitch=r,this.timeOffset=h,this.initSegmentChange=d}},"./src/demux/tsdemuxer.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"discardEPB",function(){return f});var R=n("./src/demux/adts.ts"),p=n("./src/demux/mpegaudio.ts"),T=n("./src/demux/exp-golomb.ts"),I=n("./src/demux/sample-aes.ts"),S=n("./src/events.ts"),O=n("./src/utils/mp4-tools.ts"),_=n("./src/utils/logger.ts"),E=n("./src/errors.ts"),A=n("./src/types/demuxer.ts");function D(){return D=Object.assign?Object.assign.bind():function(a){for(var i=1;i<arguments.length;i++){var t=arguments[i];for(var u in t)Object.prototype.hasOwnProperty.call(t,u)&&(a[u]=t[u])}return a},D.apply(this,arguments)}var x=function(){function a(t,u,c){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=u,this.typeSupported=c}a.probe=function(u){return u[0]===71&&u[188]===71},a.createTrack=function(u,c){return{container:u==="video"||u==="audio"?"video/mp2t":void 0,type:u,id:O.RemuxerTrackIdConfig[u],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:u==="audio"?c:void 0}};var i=a.prototype;return i.resetInitSegment=function(u,c,r,h){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=a.createTrack("video"),this._audioTrack=a.createTrack("audio",h),this._id3Track=a.createTrack("id3"),this._txtTrack=a.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=c,this.videoCodec=r,this._duration=h},i.resetTimeStamp=function(){},i.resetContiguity=function(){var u=this._audioTrack,c=this._avcTrack,r=this._id3Track;u&&(u.pesData=null),c&&(c.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null},i.demux=function(u,c,r,h){r===void 0&&(r=!1),h===void 0&&(h=!1),r||(this.sampleAes=null);var d,l=this._avcTrack,v=this._audioTrack,m=this._id3Track,L=this._txtTrack,b=l.pid,M=l.pesData,F=v.pid,w=m.pid,C=v.pesData,U=m.pesData,k=null,j=this.pmtParsed,N=this._pmtId,W=u.length;if(this.remainderData&&(u=Object(O.appendUint8Array)(this.remainderData,u),W=u.length,this.remainderData=null),W<188&&!h)return this.remainderData=u,{audioTrack:v,videoTrack:l,id3Track:m,textTrack:L};W-=W%188,W<u.byteLength&&!h&&(this.remainderData=new Uint8Array(u.buffer,W,u.buffer.byteLength-W));for(var Y=0,K=0;K<W;K+=188)if(u[K]===71){var H=!!(u[K+1]&64),z=((u[K+1]&31)<<8)+u[K+2],$=(u[K+3]&48)>>4,X=void 0;if($>1){if(X=K+5+u[K+4],X===K+188)continue}else X=K+4;switch(z){case b:H&&(M&&(d=e(M))&&this.parseAVCPES(l,L,d,!1),M={data:[],size:0}),M&&(M.data.push(u.subarray(X,K+188)),M.size+=K+188-X);break;case F:if(H){if(C&&(d=e(C)))switch(v.segmentCodec){case"aac":this.parseAACPES(v,d);break;case"mp3":this.parseMPEGPES(v,d);break}C={data:[],size:0}}C&&(C.data.push(u.subarray(X,K+188)),C.size+=K+188-X);break;case w:H&&(U&&(d=e(U))&&this.parseID3PES(m,d),U={data:[],size:0}),U&&(U.data.push(u.subarray(X,K+188)),U.size+=K+188-X);break;case 0:H&&(X+=u[X]+1),N=this._pmtId=y(u,X);break;case N:{H&&(X+=u[X]+1);var J=s(u,X,this.typeSupported,r);b=J.avc,b>0&&(l.pid=b),F=J.audio,F>0&&(v.pid=F,v.segmentCodec=J.segmentCodec),w=J.id3,w>0&&(m.pid=w),k!==null&&!j&&(_.logger.log("unknown PID '"+k+"' in TS found"),k=null),j=this.pmtParsed=!0;break}case 17:case 8191:break;default:k=z;break}}else Y++;Y>0&&this.observer.emit(S.Events.ERROR,S.Events.ERROR,{type:E.ErrorTypes.MEDIA_ERROR,details:E.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+Y+" TS packet/s that do not start with 0x47"}),l.pesData=M,v.pesData=C,m.pesData=U;var te={audioTrack:v,videoTrack:l,id3Track:m,textTrack:L};return h&&this.extractRemainingSamples(te),te},i.flush=function(){var u=this.remainderData;this.remainderData=null;var c;return u?c=this.demux(u,-1,!1,!0):c={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(c),this.sampleAes?this.decrypt(c,this.sampleAes):c},i.extractRemainingSamples=function(u){var c=u.audioTrack,r=u.videoTrack,h=u.id3Track,d=u.textTrack,l=r.pesData,v=c.pesData,m=h.pesData,L;if(l&&(L=e(l))?(this.parseAVCPES(r,d,L,!0),r.pesData=null):r.pesData=l,v&&(L=e(v))){switch(c.segmentCodec){case"aac":this.parseAACPES(c,L);break;case"mp3":this.parseMPEGPES(c,L);break}c.pesData=null}else v!=null&&v.size&&_.logger.log("last AAC PES packet truncated,might overlap between fragments"),c.pesData=v;m&&(L=e(m))?(this.parseID3PES(h,L),h.pesData=null):h.pesData=m},i.demuxSampleAes=function(u,c,r){var h=this.demux(u,r,!0,!this.config.progressive),d=this.sampleAes=new I.default(this.observer,this.config,c);return this.decrypt(h,d)},i.decrypt=function(u,c){return new Promise(function(r){var h=u.audioTrack,d=u.videoTrack;h.samples&&h.segmentCodec==="aac"?c.decryptAacSamples(h.samples,0,function(){d.samples?c.decryptAvcSamples(d.samples,0,0,function(){r(u)}):r(u)}):d.samples&&c.decryptAvcSamples(d.samples,0,0,function(){r(u)})})},i.destroy=function(){this._duration=0},i.parseAVCPES=function(u,c,r,h){var d=this,l=this.parseAVCNALu(u,r.data),v=!1,m=this.avcSample,L,b=!1;r.data=null,m&&l.length&&!u.audFound&&(o(m,u),m=this.avcSample=g(!1,r.pts,r.dts,"")),l.forEach(function(M){switch(M.type){case 1:{L=!0,m||(m=d.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 T.default(F).readSliceType();(w===2||w===4||w===7||w===9)&&(m.key=!0)}break}case 5:L=!0,m||(m=d.avcSample=g(!0,r.pts,r.dts,"")),v&&(m.debug+="IDR "),m.key=!0,m.frame=!0;break;case 6:{L=!0,v&&m&&(m.debug+="SEI "),Object(O.parseSEIMessageFromNALu)(f(M.data),r.pts,c.samples);break}case 7:if(L=!0,b=!0,v&&m&&(m.debug+="SPS "),!u.sps){var C=new T.default(M.data),U=C.readSPS();u.width=U.width,u.height=U.height,u.pixelRatio=U.pixelRatio,u.sps=[M.data],u.duration=d._duration;for(var k=M.data.subarray(1,4),j="avc1.",N=0;N<3;N++){var W=k[N].toString(16);W.length<2&&(W="0"+W),j+=W}u.codec=j}break;case 8:L=!0,v&&m&&(m.debug+="PPS "),u.pps||(u.pps=[M.data]);break;case 9:L=!1,u.audFound=!0,m&&o(m,u),m=d.avcSample=g(!1,r.pts,r.dts,v?"AUD ":"");break;case 12:L=!0;break;default:L=!1,m&&(m.debug+="unknown NAL "+M.type+" ");break}if(m&&L){var Y=m.units;Y.push(M)}}),h&&m&&(o(m,u),this.avcSample=null)},i.getLastNalUnit=function(u){var c,r=this.avcSample,h;if((!r||r.units.length===0)&&(r=u[u.length-1]),(c=r)!==null&&c!==void 0&&c.units){var d=r.units;h=d[d.length-1]}return h},i.parseAVCNALu=function(u,c){var r=c.byteLength,h=u.naluState||0,d=h,l=[],v=0,m,L,b,M=-1,F=0;for(h===-1&&(M=0,F=c[0]&31,h=0,v=1);v<r;){if(m=c[v++],!h){h=m?0:1;continue}if(h===1){h=m?0:2;continue}if(!m)h=3;else if(m===1){if(M>=0){var w={data:c.subarray(M,v-h-1),type:F};l.push(w)}else{var C=this.getLastNalUnit(u.samples);if(C&&(d&&v<=4-d&&C.state&&(C.data=C.data.subarray(0,C.data.byteLength-d)),L=v-h-1,L>0)){var U=new Uint8Array(C.data.byteLength+L);U.set(C.data,0),U.set(c.subarray(0,L),C.data.byteLength),C.data=U,C.state=0}}v<r?(b=c[v]&31,M=v,F=b,h=0):h=-1}else h=0}if(M>=0&&h>=0){var k={data:c.subarray(M,r),type:F,state:h};l.push(k)}if(l.length===0){var j=this.getLastNalUnit(u.samples);if(j){var N=new Uint8Array(j.data.byteLength+c.byteLength);N.set(j.data,0),N.set(c,j.data.byteLength),j.data=N}}return u.naluState=h,l},i.parseAACPES=function(u,c){var r=0,h=this.aacOverFlow,d=c.data;if(h){this.aacOverFlow=null;var l=h.missing,v=h.sample.unit.byteLength;if(l===-1){var m=new Uint8Array(v+d.byteLength);m.set(h.sample.unit,0),m.set(d,v),d=m}else{var L=v-l;h.sample.unit.set(d.subarray(0,l),L),u.samples.push(h.sample),r=h.missing}}var b,M;for(b=r,M=d.length;b<M-1&&!R.isHeader(d,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),_.logger.warn("parsing error:"+F),this.observer.emit(S.Events.ERROR,S.Events.ERROR,{type:E.ErrorTypes.MEDIA_ERROR,details:E.ErrorDetails.FRAG_PARSING_ERROR,fatal:w,reason:F}),w)return}R.initTrackConfig(u,this.observer,d,b,this.audioCodec);var C;if(c.pts!==void 0)C=c.pts;else if(h){var U=R.getFrameDuration(u.samplerate);C=h.sample.pts+U}else{_.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var k=0,j;b<M;)if(j=R.appendFrame(u,d,b,C,k),b+=j.length,j.missing){this.aacOverFlow=j;break}else for(k++;b<M-1&&!R.isHeader(d,b);b++);},i.parseMPEGPES=function(u,c){var r=c.data,h=r.length,d=0,l=0,v=c.pts;if(v===void 0){_.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;l<h;)if(p.isHeader(r,l)){var m=p.appendFrame(u,r,l,v,d);if(m)l+=m.length,d++;else break}else l++},i.parseID3PES=function(u,c){if(c.pts===void 0){_.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var r=D({},c,{type:this._avcTrack?A.MetadataSchema.emsg:A.MetadataSchema.audioId3});u.samples.push(r)},a}();function g(a,i,t,u){return{key:a,frame:!1,pts:i,dts:t,units:[],debug:u,length:0}}function y(a,i){return(a[i+10]&31)<<8|a[i+11]}function s(a,i,t,u){var c={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},r=(a[i+1]&15)<<8|a[i+2],h=i+3+r-4,d=(a[i+10]&15)<<8|a[i+11];for(i+=12+d;i<h;){var l=(a[i+1]&31)<<8|a[i+2];switch(a[i]){case 207:if(!u){_.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:c.audio===-1&&(c.audio=l);break;case 21:c.id3===-1&&(c.id3=l);break;case 219:if(!u){_.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:c.avc===-1&&(c.avc=l);break;case 3:case 4:t.mpeg!==!0&&t.mp3!==!0?_.logger.log("MPEG audio found, not supported in this browser"):c.audio===-1&&(c.audio=l,c.segmentCodec="mp3");break;case 36:_.logger.warn("Unsupported HEVC stream type found");break;default:break}i+=((a[i+3]&15)<<8|a[i+4])+5}return c}function e(a){var i=0,t,u,c,r,h,d=a.data;if(!a||a.size===0)return null;for(;d[0].length<19&&d.length>1;){var l=new Uint8Array(d[0].length+d[1].length);l.set(d[0]),l.set(d[1],d[0].length),d[0]=l,d.splice(1,1)}t=d[0];var v=(t[0]<<16)+(t[1]<<8)+t[2];if(v===1){if(u=(t[4]<<8)+t[5],u&&u>a.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?(h=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,r-h>60*9e4&&(_.logger.warn(Math.round((r-h)/9e4)+"s delta between PTS and DTS, align them"),r=h)):h=r),c=t[8];var L=c+9;if(a.size<=L)return null;a.size-=L;for(var b=new Uint8Array(a.size),M=0,F=d.length;M<F;M++){t=d[M];var w=t.byteLength;if(L)if(L>w){L-=w;continue}else t=t.subarray(L),w-=L,L=0;b.set(t,i),i+=w}return u&&(u-=c+3),{data:b,pts:r,dts:h,len:u}}return null}function o(a,i){if(a.units.length&&a.frame){if(a.pts===void 0){var t=i.samples,u=t.length;if(u){var c=t[u-1];a.pts=c.pts,a.dts=c.dts}else{i.dropped++;return}}i.samples.push(a)}a.debug.length&&_.logger.log(a.pts+"/"+a.dts+":"+a.debug)}function f(a){for(var i=a.byteLength,t=[],u=1;u<i-2;)a[u]===0&&a[u+1]===0&&a[u+2]===3?(t.push(u+2),u+=2):u++;if(t.length===0)return a;var c=i-t.length,r=new Uint8Array(c),h=0;for(u=0;u<c;h++,u++)h===t[0]&&(h++,t.shift()),r[u]=a[h];return r}P.default=x},"./src/errors.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"ErrorTypes",function(){return R}),n.d(P,"ErrorDetails",function(){return p});var R;(function(T){T.NETWORK_ERROR="networkError",T.MEDIA_ERROR="mediaError",T.KEY_SYSTEM_ERROR="keySystemError",T.MUX_ERROR="muxError",T.OTHER_ERROR="otherError"})(R||(R={}));var p;(function(T){T.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",T.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",T.KEY_SYSTEM_NO_SESSION="keySystemNoSession",T.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",T.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",T.MANIFEST_LOAD_ERROR="manifestLoadError",T.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",T.MANIFEST_PARSING_ERROR="manifestParsingError",T.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",T.LEVEL_EMPTY_ERROR="levelEmptyError",T.LEVEL_LOAD_ERROR="levelLoadError",T.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",T.LEVEL_SWITCH_ERROR="levelSwitchError",T.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",T.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",T.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",T.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",T.FRAG_LOAD_ERROR="fragLoadError",T.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",T.FRAG_DECRYPT_ERROR="fragDecryptError",T.FRAG_PARSING_ERROR="fragParsingError",T.REMUX_ALLOC_ERROR="remuxAllocError",T.KEY_LOAD_ERROR="keyLoadError",T.KEY_LOAD_TIMEOUT="keyLoadTimeOut",T.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",T.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",T.BUFFER_APPEND_ERROR="bufferAppendError",T.BUFFER_APPENDING_ERROR="bufferAppendingError",T.BUFFER_STALLED_ERROR="bufferStalledError",T.BUFFER_FULL_ERROR="bufferFullError",T.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",T.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",T.INTERNAL_EXCEPTION="internalException",T.INTERNAL_ABORTED="aborted",T.UNKNOWN="unknown"})(p||(p={}))},"./src/events.ts":function(B,P,n){"use strict";n.r(P),n.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(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return i});var R=n("./node_modules/url-toolkit/src/url-toolkit.js"),p=n.n(R),T=n("./src/loader/playlist-loader.ts"),I=n("./src/loader/key-loader.ts"),S=n("./src/controller/id3-track-controller.ts"),O=n("./src/controller/latency-controller.ts"),_=n("./src/controller/level-controller.ts"),E=n("./src/controller/fragment-tracker.ts"),A=n("./src/controller/stream-controller.ts"),D=n("./src/is-supported.ts"),x=n("./src/utils/logger.ts"),g=n("./src/config.ts"),y=n("./node_modules/eventemitter3/index.js"),s=n.n(y),e=n("./src/events.ts"),o=n("./src/errors.ts");function f(t,u){for(var c=0;c<u.length;c++){var r=u[c];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function a(t,u,c){return u&&f(t.prototype,u),c&&f(t,c),Object.defineProperty(t,"prototype",{writable:!1}),t}var i=function(){t.isSupported=function(){return Object(D.isSupported)()};function t(c){c===void 0&&(c={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new y.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,c);this.userConfig=c,Object(x.enableLogs)(r.debug),this._autoLevelCapping=-1,r.progressive&&Object(g.enableStreamingMode)(r);var h=r.abrController,d=r.bufferController,l=r.capLevelController,v=r.fpsController,m=this.abrController=new h(this),L=this.bufferController=new d(this),b=this.capLevelController=new l(this),M=new v(this),F=new T.default(this),w=new I.default(this),C=new S.default(this),U=this.levelController=new _.default(this),k=new E.FragmentTracker(this),j=this.streamController=new A.default(this,k);b.setStreamController(j),M.setStreamController(j);var N=[F,w,U,j];this.networkControllers=N;var W=[m,L,b,M,C,k];this.audioTrackController=this.createController(r.audioTrackController,null,N),this.createController(r.audioStreamController,k,N),this.subtitleTrackController=this.createController(r.subtitleTrackController,null,N),this.createController(r.subtitleStreamController,k,N),this.createController(r.timelineController,null,W),this.emeController=this.createController(r.emeController,null,W),this.cmcdController=this.createController(r.cmcdController,null,W),this.latencyController=this.createController(O.default,null,W),this.coreComponents=W}var u=t.prototype;return u.createController=function(r,h,d){if(r){var l=h?new r(this,h):new r(this);return d&&d.push(l),l}return null},u.on=function(r,h,d){d===void 0&&(d=this),this._emitter.on(r,h,d)},u.once=function(r,h,d){d===void 0&&(d=this),this._emitter.once(r,h,d)},u.removeAllListeners=function(r){this._emitter.removeAllListeners(r)},u.off=function(r,h,d,l){d===void 0&&(d=this),this._emitter.off(r,h,d,l)},u.listeners=function(r){return this._emitter.listeners(r)},u.emit=function(r,h,d){return this._emitter.emit(r,h,d)},u.trigger=function(r,h){if(this.config.debug)return this.emit(r,r,h);try{return this.emit(r,r,h)}catch(d){x.logger.error("An internal error happened while handling event "+r+'. Error message: "'+d.message+'". Here is a stacktrace:',d),this.trigger(e.Events.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:r,error:d})}return!1},u.listenerCount=function(r){return this._emitter.listenerCount(r)},u.destroy=function(){x.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},u.attachMedia=function(r){x.logger.log("attachMedia"),this._media=r,this.trigger(e.Events.MEDIA_ATTACHING,{media:r})},u.detachMedia=function(){x.logger.log("detachMedia"),this.trigger(e.Events.MEDIA_DETACHING,void 0),this._media=null},u.loadSource=function(r){this.stopLoad();var h=this.media,d=this.url,l=this.url=R.buildAbsoluteURL(self.location.href,r,{alwaysNormalize:!0});x.logger.log("loadSource:"+l),h&&d&&d!==l&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(h)),this.trigger(e.Events.MANIFEST_LOADING,{url:r})},u.startLoad=function(r){r===void 0&&(r=-1),x.logger.log("startLoad("+r+")"),this.networkControllers.forEach(function(h){h.startLoad(r)})},u.stopLoad=function(){x.logger.log("stopLoad"),this.networkControllers.forEach(function(r){r.stopLoad()})},u.swapAudioCodec=function(){x.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},u.recoverMediaError=function(){x.logger.log("recoverMediaError");var r=this._media;this.detachMedia(),r&&this.attachMedia(r)},u.removeLevel=function(r,h){h===void 0&&(h=0),this.levelController.removeLevel(r,h)},a(t,[{key:"levels",get:function(){var r=this.levelController.levels;return r||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(r){x.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){x.logger.log("set nextLevel:"+r),this.levelController.manualLevel=r,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(r){x.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){x.logger.log("set firstLevel:"+r),this.levelController.firstLevel=r}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(r){x.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 h=!!r;h!==this.config.capLevelToPlayerSize&&(h?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=h)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(r){this._autoLevelCapping!==r&&(x.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,h=this.config.minAutoBitrate;if(!r)return 0;for(var d=r.length,l=0;l<d;l++)if(r[l].maxBitrate>=h)return l;return 0}},{key:"maxAutoLevel",get:function(){var r=this.levels,h=this.autoLevelCapping,d;return h===-1&&r&&r.length?d=r.length-1:d=h,d}},{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 h=this.audioTrackController;h&&(h.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 h=this.subtitleTrackController;h&&(h.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 h=this.subtitleTrackController;h&&(h.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 o.ErrorTypes}},{key:"ErrorDetails",get:function(){return o.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(B,P,n){"use strict";n.r(P),n.d(P,"isSupported",function(){return T}),n.d(P,"changeTypeSupported",function(){return I});var R=n("./src/utils/mediasource-helper.ts");function p(){return self.SourceBuffer||self.WebKitSourceBuffer}function T(){var S=Object(R.getMediaSource)();if(!S)return!1;var O=p(),_=S&&typeof S.isTypeSupported=="function"&&S.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),E=!O||O.prototype&&typeof O.prototype.appendBuffer=="function"&&typeof O.prototype.remove=="function";return!!_&&!!E}function I(){var S,O=p();return typeof(O==null||(S=O.prototype)===null||S===void 0?void 0:S.changeType)=="function"}},"./src/loader/date-range.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"DateRangeAttribute",function(){return _}),n.d(P,"DateRange",function(){return E});var R=n("./src/polyfills/number.ts"),p=n("./src/utils/attr-list.ts"),T=n("./src/utils/logger.ts");function I(){return I=Object.assign?Object.assign.bind():function(A){for(var D=1;D<arguments.length;D++){var x=arguments[D];for(var g in x)Object.prototype.hasOwnProperty.call(x,g)&&(A[g]=x[g])}return A},I.apply(this,arguments)}function S(A,D){for(var x=0;x<D.length;x++){var g=D[x];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(A,g.key,g)}}function O(A,D,x){return D&&S(A.prototype,D),x&&S(A,x),Object.defineProperty(A,"prototype",{writable:!1}),A}var _;(function(A){A.ID="ID",A.CLASS="CLASS",A.START_DATE="START-DATE",A.DURATION="DURATION",A.END_DATE="END-DATE",A.END_ON_NEXT="END-ON-NEXT",A.PLANNED_DURATION="PLANNED-DURATION",A.SCTE35_OUT="SCTE35-OUT",A.SCTE35_IN="SCTE35-IN"})(_||(_={}));var E=function(){function A(D,x){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,x){var g=x.attr;for(var y in g)if(Object.prototype.hasOwnProperty.call(D,y)&&D[y]!==g[y]){T.logger.warn('DATERANGE tag attribute: "'+y+'" does not match for tags with ID: "'+D.ID+'"'),this._badValueForSameId=y;break}D=I(new p.AttrList({}),g,D)}if(this.attr=D,this._startDate=new Date(D[_.START_DATE]),_.END_DATE in this.attr){var s=new Date(this.attr[_.END_DATE]);Object(R.isFiniteNumber)(s.getTime())&&(this._endDate=s)}}return O(A,[{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 x=this.duration;return x!==null?new Date(this._startDate.getTime()+x*1e3):null}},{key:"duration",get:function(){if(_.DURATION in this.attr){var x=this.attr.decimalFloatingPoint(_.DURATION);if(Object(R.isFiniteNumber)(x))return x}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return _.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(_.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(_.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)}}]),A}()},"./src/loader/fragment-loader.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return x}),n.d(P,"LoadError",function(){return y});var R=n("./src/polyfills/number.ts"),p=n("./src/errors.ts");function T(s,e){s.prototype=Object.create(e.prototype),s.prototype.constructor=s,E(s,e)}function I(s){var e=typeof Map=="function"?new Map:void 0;return I=function(f){if(f===null||!_(f))return f;if(typeof f!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e!="undefined"){if(e.has(f))return e.get(f);e.set(f,a)}function a(){return S(f,arguments,A(this).constructor)}return a.prototype=Object.create(f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),E(a,f)},I(s)}function S(s,e,o){return O()?S=Reflect.construct.bind():S=function(a,i,t){var u=[null];u.push.apply(u,i);var c=Function.bind.apply(a,u),r=new c;return t&&E(r,t.prototype),r},S.apply(null,arguments)}function O(){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 E(s,e){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(f,a){return f.__proto__=a,f},E(s,e)}function A(s){return A=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},A(s)}var D=Math.pow(2,17),x=function(){function s(o){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=o}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(f,a){var i=this,t=f.url;if(!t)return Promise.reject(new y({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:f,networkDetails:null},"Fragment does not have a "+(t?"part list":"url")));this.abort();var u=this.config,c=u.fLoader,r=u.loader;return new Promise(function(h,d){i.loader&&i.loader.destroy();var l=i.loader=f.loader=c?new c(u):new r(u),v=g(f),m={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:f.sn==="initSegment"?1/0:D};f.stats=l.stats,l.load(v,m,{onSuccess:function(b,M,F,w){i.resetLoader(f,l),h({frag:f,part:null,payload:b.data,networkDetails:w})},onError:function(b,M,F){i.resetLoader(f,l),d(new y({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:f,response:b,networkDetails:F}))},onAbort:function(b,M,F){i.resetLoader(f,l),d(new y({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:f,networkDetails:F}))},onTimeout:function(b,M,F){i.resetLoader(f,l),d(new y({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:f,networkDetails:F}))},onProgress:function(b,M,F,w){a&&a({frag:f,part:null,payload:F,networkDetails:w})}})})},e.loadPart=function(f,a,i){var t=this;this.abort();var u=this.config,c=u.fLoader,r=u.loader;return new Promise(function(h,d){t.loader&&t.loader.destroy();var l=t.loader=f.loader=c?new c(u):new r(u),v=g(f,a),m={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:D};a.stats=l.stats,l.load(v,m,{onSuccess:function(b,M,F,w){t.resetLoader(f,l),t.updateStatsFromPart(f,a);var C={frag:f,part:a,payload:b.data,networkDetails:w};i(C),h(C)},onError:function(b,M,F){t.resetLoader(f,l),d(new y({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:f,part:a,response:b,networkDetails:F}))},onAbort:function(b,M,F){f.stats.aborted=a.stats.aborted,t.resetLoader(f,l),d(new y({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:f,part:a,networkDetails:F}))},onTimeout:function(b,M,F){t.resetLoader(f,l),d(new y({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:f,part:a,networkDetails:F}))}})})},e.updateStatsFromPart=function(f,a){var i=f.stats,t=a.stats,u=t.total;if(i.loaded+=t.loaded,u){var c=Math.round(f.duration/a.duration),r=Math.min(Math.round(i.loaded/u),c),h=c-r,d=h*Math.round(i.loaded/r);i.total=i.loaded+d}else i.total=Math.max(i.loaded,i.total);var l=i.loading,v=t.loading;l.start?l.first+=v.first-v.start:(l.start=v.start,l.first=v.first),l.end=v.end},e.resetLoader=function(f,a){f.loader=null,this.loader===a&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),a.destroy()},s}();function g(s,e){e===void 0&&(e=null);var o=e||s,f={frag:s,part:e,responseType:"arraybuffer",url:o.url,headers:{},rangeStart:0,rangeEnd:0},a=o.byteRangeStartOffset,i=o.byteRangeEndOffset;return Object(R.isFiniteNumber)(a)&&Object(R.isFiniteNumber)(i)&&(f.rangeStart=a,f.rangeEnd=i),f}var y=function(s){T(e,s);function e(o){for(var f,a=arguments.length,i=new Array(a>1?a-1:0),t=1;t<a;t++)i[t-1]=arguments[t];return f=s.call.apply(s,[this].concat(i))||this,f.data=void 0,f.data=o,f}return e}(I(Error))},"./src/loader/fragment.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"ElementaryStreamTypes",function(){return x}),n.d(P,"BaseSegment",function(){return g}),n.d(P,"Fragment",function(){return y}),n.d(P,"Part",function(){return s});var R=n("./src/polyfills/number.ts"),p=n("./node_modules/url-toolkit/src/url-toolkit.js"),T=n.n(p),I=n("./src/utils/logger.ts"),S=n("./src/loader/level-key.ts"),O=n("./src/loader/load-stats.ts");function _(e,o){e.prototype=Object.create(o.prototype),e.prototype.constructor=e,E(e,o)}function E(e,o){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,i){return a.__proto__=i,a},E(e,o)}function A(e,o){for(var f=0;f<o.length;f++){var a=o[f];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function D(e,o,f){return o&&A(e.prototype,o),f&&A(e,f),Object.defineProperty(e,"prototype",{writable:!1}),e}var x;(function(e){e.AUDIO="audio",e.VIDEO="video",e.AUDIOVIDEO="audiovideo"})(x||(x={}));var g=function(){function e(f){var a;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(a={},a[x.AUDIO]=null,a[x.VIDEO]=null,a[x.AUDIOVIDEO]=null,a),this.baseurl=f}var o=e.prototype;return o.setByteRange=function(a,i){var t=a.split("@",2),u=[];t.length===1?u[0]=i?i.byteRangeEndOffset:0:u[0]=parseInt(t[1]),u[1]=parseInt(t[0])+u[0],this._byteRange=u},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(p.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(a){this._url=a}}]),e}(),y=function(e){_(o,e);function o(a,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 O.LoadStats,t.urlId=0,t.data=void 0,t.bitrateTest=!1,t.title=null,t.initSegment=null,t.type=a,t}var f=o.prototype;return f.createInitializationVector=function(i){for(var t=new Uint8Array(16),u=12;u<16;u++)t[u]=i>>8*(15-u)&255;return t},f.setDecryptDataFromLevelKey=function(i,t){var u=i;return(i==null?void 0:i.method)==="AES-128"&&i.uri&&!i.iv&&(u=S.LevelKey.fromURI(i.uri),u.method=i.method,u.iv=this.createInitializationVector(t),u.keyFormat="identity"),u},f.setElementaryStreamInfo=function(i,t,u,c,r,h){h===void 0&&(h=!1);var d=this.elementaryStreams,l=d[i];if(!l){d[i]={startPTS:t,endPTS:u,startDTS:c,endDTS:r,partial:h};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,u),l.startDTS=Math.min(l.startDTS,c),l.endDTS=Math.max(l.endDTS,r)},f.clearElementaryStreamInfo=function(){var i=this.elementaryStreams;i[x.AUDIO]=null,i[x.VIDEO]=null,i[x.AUDIOVIDEO]=null},D(o,[{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)}}]),o}(g),s=function(e){_(o,e);function o(f,a,i,t,u){var c;c=e.call(this,i)||this,c.fragOffset=0,c.duration=0,c.gap=!1,c.independent=!1,c.relurl=void 0,c.fragment=void 0,c.index=void 0,c.stats=new O.LoadStats,c.duration=f.decimalFloatingPoint("DURATION"),c.gap=f.bool("GAP"),c.independent=f.bool("INDEPENDENT"),c.relurl=f.enumeratedString("URI"),c.fragment=a,c.index=t;var r=f.enumeratedString("BYTERANGE");return r&&c.setByteRange(r,u),u&&(c.fragOffset=u.fragOffset+u.duration),c}return D(o,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var a=this.elementaryStreams;return!!(a.audio||a.video||a.audiovideo)}}]),o}(g)},"./src/loader/key-loader.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return I});var R=n("./src/events.ts"),p=n("./src/errors.ts"),T=n("./src/utils/logger.ts"),I=function(){function S(_){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=_,this.registerListeners()}var O=S.prototype;return O.startLoad=function(E){},O.stopLoad=function(){this.destroyInternalLoaders()},O.registerListeners=function(){this.hls.on(R.Events.KEY_LOADING,this.onKeyLoading,this)},O.unregisterListeners=function(){this.hls.off(R.Events.KEY_LOADING,this.onKeyLoading)},O.destroyInternalLoaders=function(){for(var E in this.loaders){var A=this.loaders[E];A&&A.destroy()}this.loaders={}},O.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},O.onKeyLoading=function(E,A){var D=A.frag,x=D.type,g=this.loaders[x];if(!D.decryptdata){T.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var y=D.decryptdata.uri;if(y!==this.decrypturl||this.decryptkey===null){var s=this.hls.config;if(g&&(T.logger.warn("abort previous key loader for type:"+x),g.abort()),!y){T.logger.warn("key uri is falsy");return}var e=s.loader,o=D.loader=this.loaders[x]=new e(s);this.decrypturl=y,this.decryptkey=null;var f={url:y,frag:D,responseType:"arraybuffer"},a={timeout:s.fragLoadingTimeOut,maxRetry:0,retryDelay:s.fragLoadingRetryDelay,maxRetryDelay:s.fragLoadingMaxRetryTimeout,highWaterMark:0},i={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};o.load(f,a,i)}else this.decryptkey&&(D.decryptdata.key=this.decryptkey,this.hls.trigger(R.Events.KEY_LOADED,{frag:D}))},O.loadsuccess=function(E,A,D){var x=D.frag;if(!x.decryptdata){T.logger.error("after key load, decryptdata unset");return}this.decryptkey=x.decryptdata.key=new Uint8Array(E.data),x.loader=null,delete this.loaders[x.type],this.hls.trigger(R.Events.KEY_LOADED,{frag:x})},O.loaderror=function(E,A){var D=A.frag,x=D.loader;x&&x.abort(),delete this.loaders[D.type],this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:D,response:E})},O.loadtimeout=function(E,A){var D=A.frag,x=D.loader;x&&x.abort(),delete this.loaders[D.type],this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:D})},S}()},"./src/loader/level-details.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"LevelDetails",function(){return S});var R=n("./src/polyfills/number.ts");function p(O,_){for(var E=0;E<_.length;E++){var A=_[E];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(O,A.key,A)}}function T(O,_,E){return _&&p(O.prototype,_),E&&p(O,E),Object.defineProperty(O,"prototype",{writable:!1}),O}var I=10,S=function(){function O(E){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=E}var _=O.prototype;return _.reloaded=function(A){if(!A){this.advanced=!0,this.updated=!0;return}var D=this.lastPartSn-A.lastPartSn,x=this.lastPartIndex-A.lastPartIndex;this.updated=this.endSN!==A.endSN||!!x||!!D,this.advanced=this.endSN>A.endSN||D>0||D===0&&x>0,this.updated||this.advanced?this.misses=Math.floor(A.misses*.6):this.misses=A.misses+1,this.availabilityDelay=A.availabilityDelay},T(O,[{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 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}}]),O}()},"./src/loader/level-key.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"LevelKey",function(){return S});var R=n("./node_modules/url-toolkit/src/url-toolkit.js"),p=n.n(R);function T(O,_){for(var E=0;E<_.length;E++){var A=_[E];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(O,A.key,A)}}function I(O,_,E){return _&&T(O.prototype,_),E&&T(O,E),Object.defineProperty(O,"prototype",{writable:!1}),O}var S=function(){O.fromURL=function(E,A){return new O(E,A)},O.fromURI=function(E){return new O(E)};function O(_,E){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,E?this._uri=Object(R.buildAbsoluteURL)(_,E,{alwaysNormalize:!0}):this._uri=_}return I(O,[{key:"uri",get:function(){return this._uri}}]),O}()},"./src/loader/load-stats.ts":function(B,P,n){"use strict";n.r(P),n.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(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return f});var R=n("./src/polyfills/number.ts"),p=n("./node_modules/url-toolkit/src/url-toolkit.js"),T=n.n(p),I=n("./src/loader/date-range.ts"),S=n("./src/loader/fragment.ts"),O=n("./src/loader/level-details.ts"),_=n("./src/loader/level-key.ts"),E=n("./src/utils/attr-list.ts"),A=n("./src/utils/logger.ts"),D=n("./src/utils/codecs.ts"),x=/#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,y=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),s=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 o(r){var h,d;return e.test((h=(d=p.parseURL(r))===null||d===void 0?void 0:d.path)!=null?h:"")}var f=function(){function r(){}return r.findGroup=function(d,l){for(var v=0;v<d.length;v++){var m=d[v];if(m.id===l)return m}},r.convertAVC1ToAVCOTI=function(d){var l=d.split(".");if(l.length>2){var v=l.shift()+".";return v+=parseInt(l.shift()).toString(16),v+=("000"+parseInt(l.shift()).toString(16)).slice(-4),v}return d},r.resolve=function(d,l){return p.buildAbsoluteURL(l,d,{alwaysNormalize:!0})},r.parseMasterPlaylist=function(d,l){var v=[],m={},L=!1;x.lastIndex=0;for(var b;(b=x.exec(d))!=null;)if(b[1]){var M=new E.AttrList(b[1]),F={attrs:M,bitrate:M.decimalInteger("AVERAGE-BANDWIDTH")||M.decimalInteger("BANDWIDTH"),name:M.NAME,url:r.resolve(b[2],l)},w=M.decimalResolution("RESOLUTION");w&&(F.width=w.width,F.height=w.height),a((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 E.AttrList(b[3]);C["DATA-ID"]&&(L=!0,m[C["DATA-ID"]]=C)}return{levels:v,sessionData:L?m:null}},r.parseMasterPlaylistMedia=function(d,l,v,m){m===void 0&&(m=[]);var L,b=[],M=0;for(g.lastIndex=0;(L=g.exec(d))!==null;){var F=new E.AttrList(L[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,l):""};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(d,l,v,m,L){var b=new O.LevelDetails(l),M=b.fragments,F=null,w=0,C=0,U=0,k=0,j=null,N=new S.Fragment(m,l),W,Y,K,H=-1,z=!1;for(y.lastIndex=0,b.m3u8=d;(W=y.exec(d))!==null;){z&&(z=!1,N=new S.Fragment(m,l),N.start=U,N.sn=w,N.cc=k,N.level=v,F&&(N.initSegment=F,N.rawProgramDateTime=F.rawProgramDateTime,F.rawProgramDateTime=null));var $=W[1];if($){N.duration=parseFloat($);var X=(" "+W[2]).slice(1);N.title=X||null,N.tagList.push(X?["INF",$,X]:["INF",$])}else if(W[3])Object(R.isFiniteNumber)(N.duration)&&(N.start=U,K&&(N.levelkey=K),N.sn=w,N.level=v,N.cc=k,N.urlId=L,M.push(N),N.relurl=(" "+W[3]).slice(1),u(N,j),j=N,U+=N.duration,w++,C=0,z=!0);else if(W[4]){var J=(" "+W[4]).slice(1);j?N.setByteRange(J,j):N.setByteRange(J)}else if(W[5])N.rawProgramDateTime=(" "+W[5]).slice(1),N.tagList.push(["PROGRAM-DATE-TIME",N.rawProgramDateTime]),H===-1&&(H=M.length);else{if(W=W[0].match(s),!W){A.logger.warn("No matches on slow regex match for level playlist!");continue}for(Y=1;Y<W.length&&typeof W[Y]=="undefined";Y++);var te=(" "+W[Y]).slice(1),Q=(" "+W[Y+1]).slice(1),ae=W[Y+2]?(" "+W[Y+2]).slice(1):"";switch(te){case"PLAYLIST-TYPE":b.type=Q.toUpperCase();break;case"MEDIA-SEQUENCE":w=b.startSN=parseInt(Q);break;case"SKIP":{var se=new E.AttrList(Q),re=se.decimalInteger("SKIPPED-SEGMENTS");if(Object(R.isFiniteNumber)(re)){b.skippedSegments=re;for(var ee=re;ee--;)M.unshift(null);w+=re}var Z=se.enumeratedString("RECENTLY-REMOVED-DATERANGES");Z&&(b.recentlyRemovedDateranges=Z.split(" "));break}case"TARGETDURATION":b.targetduration=parseFloat(Q);break;case"VERSION":b.version=parseInt(Q);break;case"EXTM3U":break;case"ENDLIST":b.live=!1;break;case"#":(Q||ae)&&N.tagList.push(ae?[Q,ae]:[Q]);break;case"DISCONTINUITY":k++,N.tagList.push(["DIS"]);break;case"GAP":N.tagList.push([te]);break;case"BITRATE":N.tagList.push([te,Q]);break;case"DATERANGE":{var q=new E.AttrList(Q),fe=new I.DateRange(q,b.dateRanges[q.ID]);fe.isValid||b.skippedSegments?b.dateRanges[fe.id]=fe:A.logger.warn('Ignoring invalid DATERANGE tag: "'+Q+'"'),N.tagList.push(["EXT-X-DATERANGE",Q]);break}case"DISCONTINUITY-SEQUENCE":k=parseInt(Q);break;case"KEY":{var ge,ie=new E.AttrList(Q),me=ie.enumeratedString("METHOD"),ye=ie.URI,Te=ie.hexadecimalInteger("IV"),oe=ie.enumeratedString("KEYFORMATVERSIONS"),de=ie.enumeratedString("KEYID"),Se=(ge=ie.enumeratedString("KEYFORMAT"))!=null?ge:"identity",Ee=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(Ee.indexOf(Se)>-1){A.logger.warn("Keyformat "+Se+" is not supported from the manifest");continue}else if(Se!=="identity")continue;me&&(K=_.LevelKey.fromURL(l,ye),ye&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(me)>=0&&(K.method=me,K.keyFormat=Se,de&&(K.keyID=de),oe&&(K.keyFormatVersions=oe),K.iv=Te));break}case"START":{var Ae=new E.AttrList(Q),Oe=Ae.decimalFloatingPoint("TIME-OFFSET");Object(R.isFiniteNumber)(Oe)&&(b.startTimeOffset=Oe);break}case"MAP":{var Me=new E.AttrList(Q);if(N.duration){var De=new S.Fragment(m,l);c(De,Me,v,K),F=De,N.initSegment=F,F.rawProgramDateTime&&!N.rawProgramDateTime&&(N.rawProgramDateTime=F.rawProgramDateTime)}else c(N,Me,v,K),F=N,z=!0;break}case"SERVER-CONTROL":{var xe=new E.AttrList(Q);b.canBlockReload=xe.bool("CAN-BLOCK-RELOAD"),b.canSkipUntil=xe.optionalFloat("CAN-SKIP-UNTIL",0),b.canSkipDateRanges=b.canSkipUntil>0&&xe.bool("CAN-SKIP-DATERANGES"),b.partHoldBack=xe.optionalFloat("PART-HOLD-BACK",0),b.holdBack=xe.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var G=new E.AttrList(Q);b.partTarget=G.decimalFloatingPoint("PART-TARGET");break}case"PART":{var V=b.partList;V||(V=b.partList=[]);var ue=C>0?V[V.length-1]:void 0,he=C++,pe=new S.Part(new E.AttrList(Q),N,l,he,ue);V.push(pe),N.duration+=pe.duration;break}case"PRELOAD-HINT":{var _e=new E.AttrList(Q);b.preloadHint=_e;break}case"RENDITION-REPORT":{var le=new E.AttrList(Q);b.renditionReports=b.renditionReports||[],b.renditionReports.push(le);break}default:A.logger.warn("line parsed but not handled: "+W);break}}}j&&!j.relurl?(M.pop(),U-=j.duration,b.partList&&(b.fragmentHint=j)):b.partList&&(u(N,j),N.cc=k,b.fragmentHint=N);var Re=M.length,Le=M[0],Ie=M[Re-1];if(U+=b.skippedSegments*b.targetduration,U>0&&Re&&Ie){b.averagetargetduration=U/Re;var je=Ie.sn;b.endSN=je!=="initSegment"?je:0,Le&&(b.startCC=Le.cc,Le.initSegment||b.fragments.every(function(ke){return ke.relurl&&o(ke.relurl)})&&(A.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),N=new S.Fragment(m,l),N.relurl=Ie.relurl,N.level=v,N.sn="initSegment",Le.initSegment=N,b.needSidxRanges=!0))}else b.endSN=0,b.startCC=0;return b.fragmentHint&&(U+=b.fragmentHint.duration),b.totalduration=U,b.endCC=k,H>0&&t(M,H),b},r}();function a(r,h){["video","audio","text"].forEach(function(d){var l=r.filter(function(m){return Object(D.isCodecType)(m,d)});if(l.length){var v=l.filter(function(m){return m.lastIndexOf("avc1",0)===0||m.lastIndexOf("mp4a",0)===0});h[d+"Codec"]=v.length>0?v[0]:l[0],r=r.filter(function(m){return l.indexOf(m)===-1})}}),h.unknownCodecs=r}function i(r,h,d){var l=h[d];l&&(r[d]=l)}function t(r,h){for(var d=r[h],l=h;l--;){var v=r[l];if(!v)return;v.programDateTime=d.programDateTime-v.duration*1e3,d=v}}function u(r,h){r.rawProgramDateTime?r.programDateTime=Date.parse(r.rawProgramDateTime):h!=null&&h.programDateTime&&(r.programDateTime=h.endProgramDateTime),Object(R.isFiniteNumber)(r.programDateTime)||(r.programDateTime=null,r.rawProgramDateTime=null)}function c(r,h,d,l){r.relurl=h.URI,h.BYTERANGE&&r.setByteRange(h.BYTERANGE),r.level=d,r.sn="initSegment",l&&(r.levelkey=l),r.initSegment=null}},"./src/loader/playlist-loader.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/polyfills/number.ts"),p=n("./src/events.ts"),T=n("./src/errors.ts"),I=n("./src/utils/logger.ts"),S=n("./src/utils/mp4-tools.ts"),O=n("./src/loader/m3u8-parser.ts"),_=n("./src/types/loader.ts"),E=n("./src/utils/attr-list.ts");function A(g){var y=g.type;switch(y){case _.PlaylistContextType.AUDIO_TRACK:return _.PlaylistLevelType.AUDIO;case _.PlaylistContextType.SUBTITLE_TRACK:return _.PlaylistLevelType.SUBTITLE;default:return _.PlaylistLevelType.MAIN}}function D(g,y){var s=g.url;return(s===void 0||s.indexOf("data:")===0)&&(s=y.url),s}var x=function(){function g(s){this.hls=void 0,this.loaders=Object.create(null),this.hls=s,this.registerListeners()}var y=g.prototype;return y.startLoad=function(e){},y.stopLoad=function(){this.destroyInternalLoaders()},y.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)},y.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)},y.createInternalLoader=function(e){var o=this.hls.config,f=o.pLoader,a=o.loader,i=f||a,t=new i(o);return e.loader=t,this.loaders[e.type]=t,t},y.getInternalLoader=function(e){return this.loaders[e.type]},y.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},y.destroyInternalLoaders=function(){for(var e in this.loaders){var o=this.loaders[e];o&&o.destroy(),this.resetInternalLoader(e)}},y.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},y.onManifestLoading=function(e,o){var f=o.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:_.PlaylistContextType.MANIFEST,url:f,deliveryDirectives:null})},y.onLevelLoading=function(e,o){var f=o.id,a=o.level,i=o.url,t=o.deliveryDirectives;this.load({id:f,groupId:null,level:a,responseType:"text",type:_.PlaylistContextType.LEVEL,url:i,deliveryDirectives:t})},y.onAudioTrackLoading=function(e,o){var f=o.id,a=o.groupId,i=o.url,t=o.deliveryDirectives;this.load({id:f,groupId:a,level:null,responseType:"text",type:_.PlaylistContextType.AUDIO_TRACK,url:i,deliveryDirectives:t})},y.onSubtitleTrackLoading=function(e,o){var f=o.id,a=o.groupId,i=o.url,t=o.deliveryDirectives;this.load({id:f,groupId:a,level:null,responseType:"text",type:_.PlaylistContextType.SUBTITLE_TRACK,url:i,deliveryDirectives:t})},y.load=function(e){var o,f=this.hls.config,a=this.getInternalLoader(e);if(a){var i=a.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),a.abort()}var t,u,c,r;switch(e.type){case _.PlaylistContextType.MANIFEST:t=f.manifestLoadingMaxRetry,u=f.manifestLoadingTimeOut,c=f.manifestLoadingRetryDelay,r=f.manifestLoadingMaxRetryTimeout;break;case _.PlaylistContextType.LEVEL:case _.PlaylistContextType.AUDIO_TRACK:case _.PlaylistContextType.SUBTITLE_TRACK:t=0,u=f.levelLoadingTimeOut;break;default:t=f.levelLoadingMaxRetry,u=f.levelLoadingTimeOut,c=f.levelLoadingRetryDelay,r=f.levelLoadingMaxRetryTimeout;break}if(a=this.createInternalLoader(e),(o=e.deliveryDirectives)!==null&&o!==void 0&&o.part){var h;if(e.type===_.PlaylistContextType.LEVEL&&e.level!==null?h=this.hls.levels[e.level].details:e.type===_.PlaylistContextType.AUDIO_TRACK&&e.id!==null?h=this.hls.audioTracks[e.id].details:e.type===_.PlaylistContextType.SUBTITLE_TRACK&&e.id!==null&&(h=this.hls.subtitleTracks[e.id].details),h){var d=h.partTarget,l=h.targetduration;d&&l&&(u=Math.min(Math.max(d*3,l*.8)*1e3,u))}}var v={timeout:u,maxRetry:t,retryDelay:c,maxRetryDelay:r,highWaterMark:0},m={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};a.load(e,v,m)},y.loadsuccess=function(e,o,f,a){if(a===void 0&&(a=null),f.isSidxRequest){this.handleSidxRequest(e,f),this.handlePlaylistLoaded(e,o,f,a);return}this.resetInternalLoader(f.type);var i=e.data;if(i.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(e,f,"no EXTM3U delimiter",a);return}o.parsing.start=performance.now(),i.indexOf("#EXTINF:")>0||i.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,o,f,a):this.handleMasterPlaylist(e,o,f,a)},y.loaderror=function(e,o,f){f===void 0&&(f=null),this.handleNetworkError(o,f,!1,e)},y.loadtimeout=function(e,o,f){f===void 0&&(f=null),this.handleNetworkError(o,f,!0)},y.handleMasterPlaylist=function(e,o,f,a){var i=this.hls,t=e.data,u=D(e,f),c=O.default.parseMasterPlaylist(t,u),r=c.levels,h=c.sessionData;if(!r.length){this.handleManifestParsingError(e,f,"no level found in manifest",a);return}var d=r.map(function(M){return{id:M.attrs.AUDIO,audioCodec:M.audioCodec}}),l=r.map(function(M){return{id:M.attrs.SUBTITLES,textCodec:M.textCodec}}),v=O.default.parseMasterPlaylistMedia(t,u,"AUDIO",d),m=O.default.parseMasterPlaylistMedia(t,u,"SUBTITLES",l),L=O.default.parseMasterPlaylistMedia(t,u,"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 E.AttrList({}),bitrate:0,url:""}))}i.trigger(p.Events.MANIFEST_LOADED,{levels:r,audioTracks:v,subtitles:m,captions:L,url:u,stats:o,networkDetails:a,sessionData:h})},y.handleTrackOrLevelPlaylist=function(e,o,f,a){var i=this.hls,t=f.id,u=f.level,c=f.type,r=D(e,f),h=Object(R.isFiniteNumber)(t)?t:0,d=Object(R.isFiniteNumber)(u)?u:h,l=A(f),v=O.default.parseLevelPlaylist(e.data,r,d,l,h);if(!v.fragments.length){i.trigger(p.Events.ERROR,{type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:r,reason:"no fragments found in level",level:typeof f.level=="number"?f.level:void 0});return}if(c===_.PlaylistContextType.MANIFEST){var m={attrs:new E.AttrList({}),bitrate:0,details:v,name:"",url:r};i.trigger(p.Events.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:r,stats:o,networkDetails:a,sessionData:null})}if(o.parsing.end=performance.now(),v.needSidxRanges){var L,b=(L=v.fragments[0].initSegment)===null||L===void 0?void 0:L.url;this.load({url:b,isSidxRequest:!0,type:c,level:u,levelDetails:v,id:t,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}f.levelDetails=v,this.handlePlaylistLoaded(e,o,f,a)},y.handleSidxRequest=function(e,o){var f=new Uint8Array(e.data),a=Object(S.findBox)(f,["sidx"])[0];if(!!a){var i=Object(S.parseSegmentIndex)(a);if(!!i){var t=i.references,u=o.levelDetails;t.forEach(function(c,r){var h=c.info,d=u.fragments[r];if(d.byteRange.length===0&&d.setByteRange(String(1+h.end-h.start)+"@"+String(h.start)),d.initSegment){var l=Object(S.findBox)(f,["moov"])[0],v=l?l.length:null;d.initSegment.setByteRange(String(v)+"@0")}})}}},y.handleManifestParsingError=function(e,o,f,a){this.hls.trigger(p.Events.ERROR,{type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:o.type===_.PlaylistContextType.MANIFEST,url:e.url,reason:f,response:e,context:o,networkDetails:a})},y.handleNetworkError=function(e,o,f,a){f===void 0&&(f=!1),I.logger.warn("[playlist-loader]: A network "+(f?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var i=T.ErrorDetails.UNKNOWN,t=!1,u=this.getInternalLoader(e);switch(e.type){case _.PlaylistContextType.MANIFEST:i=f?T.ErrorDetails.MANIFEST_LOAD_TIMEOUT:T.ErrorDetails.MANIFEST_LOAD_ERROR,t=!0;break;case _.PlaylistContextType.LEVEL:i=f?T.ErrorDetails.LEVEL_LOAD_TIMEOUT:T.ErrorDetails.LEVEL_LOAD_ERROR,t=!1;break;case _.PlaylistContextType.AUDIO_TRACK:i=f?T.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:T.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,t=!1;break;case _.PlaylistContextType.SUBTITLE_TRACK:i=f?T.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:T.ErrorDetails.SUBTITLE_LOAD_ERROR,t=!1;break}u&&this.resetInternalLoader(e.type);var c={type:T.ErrorTypes.NETWORK_ERROR,details:i,fatal:t,url:e.url,loader:u,context:e,networkDetails:o};a&&(c.response=a),this.hls.trigger(p.Events.ERROR,c)},y.handlePlaylistLoaded=function(e,o,f,a){var i=f.type,t=f.level,u=f.id,c=f.groupId,r=f.loader,h=f.levelDetails,d=f.deliveryDirectives;if(!(h!=null&&h.targetduration)){this.handleManifestParsingError(e,f,"invalid target duration",a);return}if(!!r)switch(h.live&&(r.getCacheAge&&(h.ageHeader=r.getCacheAge()||0),(!r.getCacheAge||isNaN(h.ageHeader))&&(h.ageHeader=0)),i){case _.PlaylistContextType.MANIFEST:case _.PlaylistContextType.LEVEL:this.hls.trigger(p.Events.LEVEL_LOADED,{details:h,level:t||0,id:u||0,stats:o,networkDetails:a,deliveryDirectives:d});break;case _.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(p.Events.AUDIO_TRACK_LOADED,{details:h,id:u||0,groupId:c||"",stats:o,networkDetails:a,deliveryDirectives:d});break;case _.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(p.Events.SUBTITLE_TRACK_LOADED,{details:h,id:u||0,groupId:c||"",stats:o,networkDetails:a,deliveryDirectives:d});break}},g}();P.default=x},"./src/polyfills/number.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"isFiniteNumber",function(){return R}),n.d(P,"MAX_SAFE_INTEGER",function(){return p});var R=Number.isFinite||function(T){return typeof T=="number"&&isFinite(T)},p=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(B,P,n){"use strict";n.r(P);var R=function(){function p(){}return p.getSilentFrame=function(I,S){switch(I){case"mp4a.40.2":if(S===1)return new Uint8Array([0,200,0,128,35,128]);if(S===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(S===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(S===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(S===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(S===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(S===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(S===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(S===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(B,P,n){"use strict";n.r(P);var R=Math.pow(2,32)-1,p=function(){function T(){}return T.init=function(){T.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 S;for(S in T.types)T.types.hasOwnProperty(S)&&(T.types[S]=[S.charCodeAt(0),S.charCodeAt(1),S.charCodeAt(2),S.charCodeAt(3)]);var O=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]);T.HDLR_TYPES={video:O,audio:_};var E=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]);T.STTS=T.STSC=T.STCO=A,T.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),T.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),T.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),T.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var D=new Uint8Array([105,115,111,109]),x=new Uint8Array([97,118,99,49]),g=new Uint8Array([0,0,0,1]);T.FTYP=T.box(T.types.ftyp,D,g,D,x),T.DINF=T.box(T.types.dinf,T.box(T.types.dref,E))},T.box=function(S){for(var O=8,_=arguments.length,E=new Array(_>1?_-1:0),A=1;A<_;A++)E[A-1]=arguments[A];for(var D=E.length,x=D;D--;)O+=E[D].byteLength;var g=new Uint8Array(O);for(g[0]=O>>24&255,g[1]=O>>16&255,g[2]=O>>8&255,g[3]=O&255,g.set(S,4),D=0,O=8;D<x;D++)g.set(E[D],O),O+=E[D].byteLength;return g},T.hdlr=function(S){return T.box(T.types.hdlr,T.HDLR_TYPES[S])},T.mdat=function(S){return T.box(T.types.mdat,S)},T.mdhd=function(S,O){O*=S;var _=Math.floor(O/(R+1)),E=Math.floor(O%(R+1));return T.box(T.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,S>>24&255,S>>16&255,S>>8&255,S&255,_>>24,_>>16&255,_>>8&255,_&255,E>>24,E>>16&255,E>>8&255,E&255,85,196,0,0]))},T.mdia=function(S){return T.box(T.types.mdia,T.mdhd(S.timescale,S.duration),T.hdlr(S.type),T.minf(S))},T.mfhd=function(S){return T.box(T.types.mfhd,new Uint8Array([0,0,0,0,S>>24,S>>16&255,S>>8&255,S&255]))},T.minf=function(S){return S.type==="audio"?T.box(T.types.minf,T.box(T.types.smhd,T.SMHD),T.DINF,T.stbl(S)):T.box(T.types.minf,T.box(T.types.vmhd,T.VMHD),T.DINF,T.stbl(S))},T.moof=function(S,O,_){return T.box(T.types.moof,T.mfhd(S),T.traf(_,O))},T.moov=function(S){for(var O=S.length,_=[];O--;)_[O]=T.trak(S[O]);return T.box.apply(null,[T.types.moov,T.mvhd(S[0].timescale,S[0].duration)].concat(_).concat(T.mvex(S)))},T.mvex=function(S){for(var O=S.length,_=[];O--;)_[O]=T.trex(S[O]);return T.box.apply(null,[T.types.mvex].concat(_))},T.mvhd=function(S,O){O*=S;var _=Math.floor(O/(R+1)),E=Math.floor(O%(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,S>>24&255,S>>16&255,S>>8&255,S&255,_>>24,_>>16&255,_>>8&255,_&255,E>>24,E>>16&255,E>>8&255,E&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return T.box(T.types.mvhd,A)},T.sdtp=function(S){var O=S.samples||[],_=new Uint8Array(4+O.length),E,A;for(E=0;E<O.length;E++)A=O[E].flags,_[E+4]=A.dependsOn<<4|A.isDependedOn<<2|A.hasRedundancy;return T.box(T.types.sdtp,_)},T.stbl=function(S){return T.box(T.types.stbl,T.stsd(S),T.box(T.types.stts,T.STTS),T.box(T.types.stsc,T.STSC),T.box(T.types.stsz,T.STSZ),T.box(T.types.stco,T.STCO))},T.avc1=function(S){var O=[],_=[],E,A,D;for(E=0;E<S.sps.length;E++)A=S.sps[E],D=A.byteLength,O.push(D>>>8&255),O.push(D&255),O=O.concat(Array.prototype.slice.call(A));for(E=0;E<S.pps.length;E++)A=S.pps[E],D=A.byteLength,_.push(D>>>8&255),_.push(D&255),_=_.concat(Array.prototype.slice.call(A));var x=T.box(T.types.avcC,new Uint8Array([1,O[3],O[4],O[5],255,224|S.sps.length].concat(O).concat([S.pps.length]).concat(_))),g=S.width,y=S.height,s=S.pixelRatio[0],e=S.pixelRatio[1];return T.box(T.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,y>>8&255,y&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]),x,T.box(T.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),T.box(T.types.pasp,new Uint8Array([s>>24,s>>16&255,s>>8&255,s&255,e>>24,e>>16&255,e>>8&255,e&255])))},T.esds=function(S){var O=S.config.length;return new Uint8Array([0,0,0,0,3,23+O,0,1,0,4,15+O,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([O]).concat(S.config).concat([6,1,2]))},T.mp4a=function(S){var O=S.samplerate;return T.box(T.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,S.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]),T.box(T.types.esds,T.esds(S)))},T.mp3=function(S){var O=S.samplerate;return T.box(T.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,S.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]))},T.stsd=function(S){return S.type==="audio"?S.segmentCodec==="mp3"&&S.codec==="mp3"?T.box(T.types.stsd,T.STSD,T.mp3(S)):T.box(T.types.stsd,T.STSD,T.mp4a(S)):T.box(T.types.stsd,T.STSD,T.avc1(S))},T.tkhd=function(S){var O=S.id,_=S.duration*S.timescale,E=S.width,A=S.height,D=Math.floor(_/(R+1)),x=Math.floor(_%(R+1));return T.box(T.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,O>>24&255,O>>16&255,O>>8&255,O&255,0,0,0,0,D>>24,D>>16&255,D>>8&255,D&255,x>>24,x>>16&255,x>>8&255,x&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,E>>8&255,E&255,0,0,A>>8&255,A&255,0,0]))},T.traf=function(S,O){var _=T.sdtp(S),E=S.id,A=Math.floor(O/(R+1)),D=Math.floor(O%(R+1));return T.box(T.types.traf,T.box(T.types.tfhd,new Uint8Array([0,0,0,0,E>>24,E>>16&255,E>>8&255,E&255])),T.box(T.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])),T.trun(S,_.length+16+20+8+16+8+8),_)},T.trak=function(S){return S.duration=S.duration||4294967295,T.box(T.types.trak,T.tkhd(S),T.mdia(S))},T.trex=function(S){var O=S.id;return T.box(T.types.trex,new Uint8Array([0,0,0,0,O>>24,O>>16&255,O>>8&255,O&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},T.trun=function(S,O){var _=S.samples||[],E=_.length,A=12+16*E,D=new Uint8Array(A),x,g,y,s,e,o;for(O+=8+A,D.set([S.type==="video"?1:0,0,15,1,E>>>24&255,E>>>16&255,E>>>8&255,E&255,O>>>24&255,O>>>16&255,O>>>8&255,O&255],0),x=0;x<E;x++)g=_[x],y=g.duration,s=g.size,e=g.flags,o=g.cts,D.set([y>>>24&255,y>>>16&255,y>>>8&255,y&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,o>>>24&255,o>>>16&255,o>>>8&255,o&255],12+16*x);return T.box(T.types.trun,D)},T.initSegment=function(S){T.types||T.init();var O=T.moov(S),_=new Uint8Array(T.FTYP.byteLength+O.byteLength);return _.set(T.FTYP),_.set(O,T.FTYP.byteLength),_},T}();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(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return e}),n.d(P,"normalizePts",function(){return o}),n.d(P,"flushTextTrackMetadataCueSamples",function(){return a}),n.d(P,"flushTextTrackUserdataCueSamples",function(){return i});var R=n("./src/polyfills/number.ts"),p=n("./src/remux/aac-helper.ts"),T=n("./src/remux/mp4-generator.ts"),I=n("./src/events.ts"),S=n("./src/errors.ts"),O=n("./src/utils/logger.ts"),_=n("./src/types/loader.ts"),E=n("./src/utils/timescale-conversion.ts");function A(){return A=Object.assign?Object.assign.bind():function(c){for(var r=1;r<arguments.length;r++){var h=arguments[r];for(var d in h)Object.prototype.hasOwnProperty.call(h,d)&&(c[d]=h[d])}return c},A.apply(this,arguments)}var D=10*1e3,x=1024,g=1152,y=null,s=null,e=function(){function c(h,d,l,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=h,this.config=d,this.typeSupported=l,this.ISGenerated=!1,y===null){var m=navigator.userAgent||"",L=m.match(/Chrome\/(\d+)/i);y=L?parseInt(L[1]):0}if(s===null){var b=navigator.userAgent.match(/Safari\/(\d+)/i);s=b?parseInt(b[1]):0}}var r=c.prototype;return r.destroy=function(){},r.resetTimeStamp=function(d){O.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=d},r.resetNextTimestamp=function(){O.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},r.resetInitSegment=function(){O.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},r.getVideoStartPts=function(d){var l=!1,v=d.reduce(function(m,L){var b=L.pts-m;return b<-4294967296?(l=!0,o(m,L.pts)):b>0?m:L.pts},d[0].pts);return l&&O.logger.debug("PTS rollover detected"),v},r.remux=function(d,l,v,m,L,b,M,F){var w,C,U,k,j,N,W=L,Y=L,K=d.pid>-1,H=l.pid>-1,z=l.samples.length,$=d.samples.length>0,X=M&&z>0||z>1,J=(!K||$)&&(!H||X)||this.ISGenerated||M;if(J){this.ISGenerated||(U=this.generateIS(d,l,L));var te=this.isVideoContiguous,Q=-1,ae;if(X&&(Q=f(l.samples),!te&&this.config.forceKeyFrameOnDiscontinuity))if(N=!0,Q>0){O.logger.warn("[mp4-remuxer]: Dropped "+Q+" out of "+z+" video samples due to a missing keyframe");var se=this.getVideoStartPts(l.samples);l.samples=l.samples.slice(Q),l.dropped+=Q,Y+=(l.samples[0].pts-se)/l.inputTimeScale,ae=Y}else Q===-1&&(O.logger.warn("[mp4-remuxer]: No keyframe found out of "+z+" video samples"),N=!1);if(this.ISGenerated){if($&&X){var re=this.getVideoStartPts(l.samples),ee=o(d.samples[0].pts,re)-re,Z=ee/l.inputTimeScale;W+=Math.max(0,Z),Y+=Math.max(0,-Z)}if($){if(d.samplerate||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),U=this.generateIS(d,l,L)),C=this.remuxAudio(d,W,this.isAudioContiguous,b,H||X||F===_.PlaylistLevelType.AUDIO?Y:void 0),X){var q=C?C.endPTS-C.startPTS:0;l.inputTimeScale||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),U=this.generateIS(d,l,L)),w=this.remuxVideo(l,Y,te,q)}}else X&&(w=this.remuxVideo(l,Y,te,0));w&&(w.firstKeyFrame=Q,w.independent=Q!==-1,w.firstKeyFramePTS=ae)}}return this.ISGenerated&&(v.samples.length&&(j=a(v,L,this._initPTS,this._initDTS)),m.samples.length&&(k=i(m,L,this._initPTS))),{audio:C,video:w,initSegment:U,independent:N,text:k,id3:j}},r.generateIS=function(d,l,v){var m=d.samples,L=l.samples,b=this.typeSupported,M={},F=!Object(R.isFiniteNumber)(this._initPTS),w="audio/mp4",C,U,k;if(F&&(C=U=1/0),d.config&&m.length){switch(d.timescale=d.samplerate,d.segmentCodec){case"mp3":b.mpeg?(w="audio/mpeg",d.codec=""):b.mp3&&(d.codec="mp3");break}M.audio={id:"audio",container:w,codec:d.codec,initSegment:d.segmentCodec==="mp3"&&b.mpeg?new Uint8Array(0):T.default.initSegment([d]),metadata:{channelCount:d.channelCount}},F&&(k=d.inputTimeScale,C=U=m[0].pts-Math.round(k*v))}if(l.sps&&l.pps&&L.length&&(l.timescale=l.inputTimeScale,M.video={id:"main",container:"video/mp4",codec:l.codec,initSegment:T.default.initSegment([l]),metadata:{width:l.width,height:l.height}},F)){k=l.inputTimeScale;var j=this.getVideoStartPts(L),N=Math.round(k*v);U=Math.min(U,o(L[0].dts,j)-N),C=Math.min(C,j-N)}if(Object.keys(M).length)return this.ISGenerated=!0,F&&(this._initPTS=C,this._initDTS=U),{tracks:M,initPTS:C,timescale:k}},r.remuxVideo=function(d,l,v,m){var L=d.inputTimeScale,b=d.samples,M=[],F=b.length,w=this._initPTS,C=this.nextAvcDts,U=8,k=this.videoSampleDuration,j,N,W=Number.POSITIVE_INFINITY,Y=Number.NEGATIVE_INFINITY,K=!1;if(!v||C===null){var H=l*L,z=b[0].pts-o(b[0].dts,b[0].pts);C=H-z}for(var $=0;$<F;$++){var X=b[$];X.pts=o(X.pts-w,C),X.dts=o(X.dts-w,C),X.dts<b[$>0?$-1:$].dts&&(K=!0)}K&&b.sort(function(We,it){var nt=We.dts-it.dts,mt=We.pts-it.pts;return nt||mt}),j=b[0].dts,N=b[b.length-1].dts;var J=N-j,te=J?Math.round(J/(F-1)):k||d.inputTimeScale/30;if(v){var Q=j-C,ae=Q>te,se=Q<-1;if(ae||se){ae?O.logger.warn("AVC: "+Object(E.toMsFromMpegTsClock)(Q,!0)+" ms ("+Q+"dts) hole between fragments detected, filling it"):O.logger.warn("AVC: "+Object(E.toMsFromMpegTsClock)(-Q,!0)+" ms ("+Q+"dts) overlapping between fragments detected"),j=C;var re=b[0].pts-Q;b[0].dts=j,b[0].pts=re,O.logger.log("Video: First PTS/DTS adjusted: "+Object(E.toMsFromMpegTsClock)(re,!0)+"/"+Object(E.toMsFromMpegTsClock)(j,!0)+", delta: "+Object(E.toMsFromMpegTsClock)(Q,!0)+" ms")}}j=Math.max(0,j);for(var ee=0,Z=0,q=0;q<F;q++){for(var fe=b[q],ge=fe.units,ie=ge.length,me=0,ye=0;ye<ie;ye++)me+=ge[ye].data.length;Z+=me,ee+=ie,fe.length=me,fe.dts=Math.max(fe.dts,j),W=Math.min(fe.pts,W),Y=Math.max(fe.pts,Y)}N=b[F-1].dts;var Te=Z+4*ee+8,oe;try{oe=new Uint8Array(Te)}catch{this.observer.emit(I.Events.ERROR,I.Events.ERROR,{type:S.ErrorTypes.MUX_ERROR,details:S.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Te,reason:"fail allocating video mdat "+Te});return}var de=new DataView(oe.buffer);de.setUint32(0,Te),oe.set(T.default.types.mdat,4);for(var Se=!1,Ee=Number.POSITIVE_INFINITY,Ae=Number.POSITIVE_INFINITY,Oe=Number.NEGATIVE_INFINITY,Me=Number.NEGATIVE_INFINITY,De=0;De<F;De++){for(var xe=b[De],G=xe.units,V=0,ue=0,he=G.length;ue<he;ue++){var pe=G[ue],_e=pe.data,le=pe.data.byteLength;de.setUint32(U,le),U+=4,oe.set(_e,U),U+=le,V+=4+le}var Re=void 0;if(De<F-1)k=b[De+1].dts-xe.dts,Re=b[De+1].pts-xe.pts;else{var Le=this.config,Ie=De>0?xe.dts-b[De-1].dts:te;if(Re=De>0?xe.pts-b[De-1].pts:te,Le.stretchShortVideoTrack&&this.nextAudioPts!==null){var je=Math.floor(Le.maxBufferHole*L),ke=(m?W+m*L:this.nextAudioPts)-xe.pts;ke>je?(k=ke-Ie,k<0?k=Ie:Se=!0,O.logger.log("[mp4-remuxer]: It is approximately "+ke/90+" ms to the next segment; using duration "+k/90+" ms for the last video frame.")):k=Ie}else k=Ie}var Be=Math.round(xe.pts-xe.dts);Ee=Math.min(Ee,k),Oe=Math.max(Oe,k),Ae=Math.min(Ae,Re),Me=Math.max(Me,Re),M.push(new t(xe.key,k,V,Be))}if(M.length){if(y){if(y<70){var et=M[0].flags;et.dependsOn=2,et.isNonSync=0}}else if(s&&Me-Ae<Oe-Ee&&te/Oe<.025&&M[0].cts===0){O.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var He=j,Ce=0,Ke=M.length;Ce<Ke;Ce++){var Ve=He+M[Ce].duration,Ye=He+M[Ce].cts;if(Ce<Ke-1){var tt=Ve+M[Ce+1].cts;M[Ce].duration=tt-Ye}else M[Ce].duration=Ce?M[Ce-1].duration:te;M[Ce].cts=0,He=Ve}}}console.assert(k!==null,"mp4SampleDuration must be computed"),k=Se||!k?te:k,this.nextAvcDts=C=N+k,this.videoSampleDuration=k,this.isVideoContiguous=!0;var rt=T.default.moof(d.sequenceNumber++,j,A({},d,{samples:M})),vt="video",gt={data1:rt,data2:oe,startPTS:W/L,endPTS:(Y+k)/L,startDTS:j/L,endDTS:C/L,type:vt,hasAudio:!1,hasVideo:!0,nb:M.length,dropped:d.dropped};return d.samples=[],d.dropped=0,console.assert(oe.length,"MDAT length must not be zero"),gt},r.remuxAudio=function(d,l,v,m,L){var b=d.inputTimeScale,M=d.samplerate?d.samplerate:b,F=b/M,w=d.segmentCodec==="aac"?x:g,C=w*F,U=this._initPTS,k=d.segmentCodec==="mp3"&&this.typeSupported.mpeg,j=[],N=L!==void 0,W=d.samples,Y=k?0:8,K=this.nextAudioPts||-1,H=l*b;if(this.isAudioContiguous=v=v||W.length&&K>0&&(m&&Math.abs(H-K)<9e3||Math.abs(o(W[0].pts-U,H)-K)<20*C),W.forEach(function(pe){pe.pts=o(pe.pts-U,H)}),!v||K<0){if(W=W.filter(function(pe){return pe.pts>=0}),!W.length)return;L===0?K=0:m&&!N?K=Math.max(0,H):K=W[0].pts}if(d.segmentCodec==="aac")for(var z=this.config.maxAudioFramesDrift,$=0,X=K;$<W.length;$++){var J=W[$],te=J.pts,Q=te-X,ae=Math.abs(1e3*Q/b);if(Q<=-z*C&&N)$===0&&(O.logger.warn("Audio frame @ "+(te/b).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*Q/b)+" ms."),this.nextAudioPts=K=X=te);else if(Q>=z*C&&ae<D&&N){var se=Math.round(Q/C);X=te-se*C,X<0&&(se--,X+=C),$===0&&(this.nextAudioPts=K=X),O.logger.warn("[mp4-remuxer]: Injecting "+se+" audio frame @ "+(X/b).toFixed(3)+"s due to "+Math.round(1e3*Q/b)+" ms gap.");for(var re=0;re<se;re++){var ee=Math.max(X,0),Z=p.default.getSilentFrame(d.manifestCodec||d.codec,d.channelCount);Z||(O.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Z=J.unit.subarray()),W.splice($,0,{unit:Z,pts:ee}),X+=C,$++}}J.pts=X,X+=C}for(var q=null,fe=null,ge,ie=0,me=W.length;me--;)ie+=W[me].unit.byteLength;for(var ye=0,Te=W.length;ye<Te;ye++){var oe=W[ye],de=oe.unit,Se=oe.pts;if(fe!==null){var Ee=j[ye-1];Ee.duration=Math.round((Se-fe)/F)}else if(v&&d.segmentCodec==="aac"&&(Se=K),q=Se,ie>0){ie+=Y;try{ge=new Uint8Array(ie)}catch{this.observer.emit(I.Events.ERROR,I.Events.ERROR,{type:S.ErrorTypes.MUX_ERROR,details:S.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:ie,reason:"fail allocating audio mdat "+ie});return}if(!k){var Ae=new DataView(ge.buffer);Ae.setUint32(0,ie),ge.set(T.default.types.mdat,4)}}else return;ge.set(de,Y);var Oe=de.byteLength;Y+=Oe,j.push(new t(!0,w,Oe,0)),fe=Se}var Me=j.length;if(!!Me){var De=j[j.length-1];this.nextAudioPts=K=fe+F*De.duration;var xe=k?new Uint8Array(0):T.default.moof(d.sequenceNumber++,q/F,A({},d,{samples:j}));d.samples=[];var G=q/b,V=K/b,ue="audio",he={data1:xe,data2:ge,startPTS:G,endPTS:V,startDTS:G,endDTS:V,type:ue,hasAudio:!0,hasVideo:!1,nb:Me};return this.isAudioContiguous=!0,console.assert(ge.length,"MDAT length must not be zero"),he}},r.remuxEmptyAudio=function(d,l,v,m){var L=d.inputTimeScale,b=d.samplerate?d.samplerate:L,M=L/b,F=this.nextAudioPts,w=(F!==null?F:m.startDTS*L)+this._initDTS,C=m.endDTS*L+this._initDTS,U=M*x,k=Math.ceil((C-w)/U),j=p.default.getSilentFrame(d.manifestCodec||d.codec,d.channelCount);if(O.logger.warn("[mp4-remuxer]: remux empty Audio"),!j){O.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var N=[],W=0;W<k;W++){var Y=w+W*U;N.push({unit:j,pts:Y,dts:Y})}return d.samples=N,this.remuxAudio(d,l,v,!1)},c}();function o(c,r){var h;if(r===null)return c;for(r<c?h=-8589934592:h=8589934592;Math.abs(c-r)>4294967296;)c+=h;return c}function f(c){for(var r=0;r<c.length;r++)if(c[r].key)return r;return-1}function a(c,r,h,d){var l=c.samples.length;if(!!l){for(var v=c.inputTimeScale,m=0;m<l;m++){var L=c.samples[m];L.pts=o(L.pts-h,r*v)/v,L.dts=o(L.dts-d,r*v)/v}var b=c.samples;return c.samples=[],{samples:b}}}function i(c,r,h){var d=c.samples.length;if(!!d){for(var l=c.inputTimeScale,v=0;v<d;v++){var m=c.samples[v];m.pts=o(m.pts-h,r*l)/l}c.samples.sort(function(b,M){return b.pts-M.pts});var L=c.samples;return c.samples=[],{samples:L}}}var t=function(r,h,d,l){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=h,this.size=d,this.cts=l,this.flags=new u(r)},u=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(B,P,n){"use strict";n.r(P);var R=n("./src/polyfills/number.ts"),p=n("./src/remux/mp4-remuxer.ts"),T=n("./src/utils/mp4-tools.ts"),I=n("./src/loader/fragment.ts"),S=n("./src/utils/logger.ts"),O=function(){function E(){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 A=E.prototype;return A.destroy=function(){},A.resetTimeStamp=function(x){this.initPTS=x,this.lastEndTime=null},A.resetNextTimestamp=function(){this.lastEndTime=null},A.resetInitSegment=function(x,g,y){this.audioCodec=g,this.videoCodec=y,this.generateInitSegment(x),this.emitInitSegment=!0},A.generateInitSegment=function(x){var g=this.audioCodec,y=this.videoCodec;if(!x||!x.byteLength){this.initTracks=void 0,this.initData=void 0;return}var s=this.initData=Object(T.parseInitSegment)(x);g||(g=_(s.audio,I.ElementaryStreamTypes.AUDIO)),y||(y=_(s.video,I.ElementaryStreamTypes.VIDEO));var e={};s.audio&&s.video?e.audiovideo={container:"video/mp4",codec:g+","+y,initSegment:x,id:"main"}:s.audio?e.audio={container:"audio/mp4",codec:g,initSegment:x,id:"audio"}:s.video?e.video={container:"video/mp4",codec:y,initSegment:x,id:"main"}:S.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=e},A.remux=function(x,g,y,s,e){var o,f=this.initPTS,a=this.lastEndTime,i={audio:void 0,video:void 0,text:s,id3:y,initSegment:void 0};Object(R.isFiniteNumber)(a)||(a=this.lastEndTime=e||0);var t=g.samples;if(!t||!t.length)return i;var u={initPTS:void 0,timescale:1},c=this.initData;if((!c||!c.length)&&(this.generateInitSegment(t),c=this.initData),!c||!c.length)return S.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),i;this.emitInitSegment&&(u.tracks=this.initTracks,this.emitInitSegment=!1);var r=Object(T.getStartDTS)(c,t);Object(R.isFiniteNumber)(f)||(this.initPTS=u.initPTS=f=r-e);var h=Object(T.getDuration)(t,c),d=x?r-f:a,l=d+h;Object(T.offsetStartDTS)(c,t,f),h>0?this.lastEndTime=l:(S.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var v=!!c.audio,m=!!c.video,L="";v&&(L+="audio"),m&&(L+="video");var b={data1:t,startPTS:d,startDTS:d,endPTS:l,endDTS:l,type:L,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=u;var M=(o=this.initPTS)!=null?o:0;return i.id3=Object(p.flushTextTrackMetadataCueSamples)(y,e,M,M),s.samples.length&&(i.text=Object(p.flushTextTrackUserdataCueSamples)(s,e,M)),i},E}();function _(E,A){var D=E==null?void 0:E.codec;return D&&D.length>4?D:D==="hvc1"||D==="hev1"?"hvc1.1.c.L120.90":D==="av01"?"av01.0.04M.08":D==="avc1"||A===I.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}P.default=O},"./src/task-loop.ts":function(B,P,n){"use strict";n.r(P),n.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 T=p.prototype;return T.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},T.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},T.onHandlerDestroyed=function(){},T.hasInterval=function(){return!!this._tickInterval},T.hasNextTick=function(){return!!this._tickTimer},T.setInterval=function(S){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,S),!0)},T.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},T.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},T.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},T.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},T.doTick=function(){},p}()},"./src/types/cmcd.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"CMCDVersion",function(){return R}),n.d(P,"CMCDObjectType",function(){return p}),n.d(P,"CMCDStreamingFormat",function(){return T}),n.d(P,"CMCDStreamType",function(){return I});var R=1,p;(function(S){S.MANIFEST="m",S.AUDIO="a",S.VIDEO="v",S.MUXED="av",S.INIT="i",S.CAPTION="c",S.TIMED_TEXT="tt",S.KEY="k",S.OTHER="o"})(p||(p={}));var T;(function(S){S.DASH="d",S.HLS="h",S.SMOOTH="s",S.OTHER="o"})(T||(T={}));var I;(function(S){S.VOD="v",S.LIVE="l"})(I||(I={}))},"./src/types/demuxer.ts":function(B,P,n){"use strict";n.r(P),n.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(B,P,n){"use strict";n.r(P),n.d(P,"HlsSkip",function(){return T}),n.d(P,"getSkipValue",function(){return I}),n.d(P,"HlsUrlParameters",function(){return S}),n.d(P,"Level",function(){return O});function R(_,E){for(var A=0;A<E.length;A++){var D=E[A];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(_,D.key,D)}}function p(_,E,A){return E&&R(_.prototype,E),A&&R(_,A),Object.defineProperty(_,"prototype",{writable:!1}),_}var T;(function(_){_.No="",_.Yes="YES",_.v2="v2"})(T||(T={}));function I(_,E){var A=_.canSkipUntil,D=_.canSkipDateRanges,x=_.endSN,g=E!==void 0?E-x:0;return A&&g<A?D?T.v2:T.Yes:T.No}var S=function(){function _(A,D,x){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=A,this.part=D,this.skip=x}var E=_.prototype;return E.addDirectives=function(D){var x=new self.URL(D);return this.msn!==void 0&&x.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&x.searchParams.set("_HLS_part",this.part.toString()),this.skip&&x.searchParams.set("_HLS_skip",this.skip),x.toString()},_}(),O=function(){function _(E){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=[E.url],this.attrs=E.attrs,this.bitrate=E.bitrate,E.details&&(this.details=E.details),this.id=E.id||0,this.name=E.name,this.width=E.width||0,this.height=E.height||0,this.audioCodec=E.audioCodec,this.videoCodec=E.videoCodec,this.unknownCodecs=E.unknownCodecs,this.codecSet=[E.videoCodec,E.audioCodec].filter(function(A){return A}).join(",").replace(/\.[^.,]+/g,"")}return p(_,[{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(B,P,n){"use strict";n.r(P),n.d(P,"PlaylistContextType",function(){return R}),n.d(P,"PlaylistLevelType",function(){return p});var R;(function(T){T.MANIFEST="manifest",T.LEVEL="level",T.AUDIO_TRACK="audioTrack",T.SUBTITLE_TRACK="subtitleTrack"})(R||(R={}));var p;(function(T){T.MAIN="main",T.AUDIO="audio",T.SUBTITLE="subtitle"})(p||(p={}))},"./src/types/transmuxer.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"ChunkMetadata",function(){return R});var R=function(I,S,O,_,E,A){_===void 0&&(_=0),E===void 0&&(E=-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=p(),this.buffering={audio:p(),video:p(),audiovideo:p()},this.level=I,this.sn=S,this.id=O,this.size=_,this.part=E,this.partial=A};function p(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"AttrList",function(){return T});var R=/^(\d+)x(\d+)$/,p=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,T=function(){function I(O){typeof O=="string"&&(O=I.parseAttrList(O));for(var _ in O)O.hasOwnProperty(_)&&(this[_]=O[_])}var S=I.prototype;return S.decimalInteger=function(_){var E=parseInt(this[_],10);return E>Number.MAX_SAFE_INTEGER?1/0:E},S.hexadecimalInteger=function(_){if(this[_]){var E=(this[_]||"0x").slice(2);E=(E.length&1?"0":"")+E;for(var A=new Uint8Array(E.length/2),D=0;D<E.length/2;D++)A[D]=parseInt(E.slice(D*2,D*2+2),16);return A}else return null},S.hexadecimalIntegerAsNumber=function(_){var E=parseInt(this[_],16);return E>Number.MAX_SAFE_INTEGER?1/0:E},S.decimalFloatingPoint=function(_){return parseFloat(this[_])},S.optionalFloat=function(_,E){var A=this[_];return A?parseFloat(A):E},S.enumeratedString=function(_){return this[_]},S.bool=function(_){return this[_]==="YES"},S.decimalResolution=function(_){var E=R.exec(this[_]);if(E!==null)return{width:parseInt(E[1],10),height:parseInt(E[2],10)}},I.parseAttrList=function(_){var E,A={},D='"';for(p.lastIndex=0;(E=p.exec(_))!==null;){var x=E[2];x.indexOf(D)===0&&x.lastIndexOf(D)===x.length-1&&(x=x.slice(1,-1)),A[E[1]]=x}return A},I}()},"./src/utils/binary-search.ts":function(B,P,n){"use strict";n.r(P);var R={search:function(T,I){for(var S=0,O=T.length-1,_=null,E=null;S<=O;){_=(S+O)/2|0,E=T[_];var A=I(E);if(A>0)S=_+1;else if(A<0)O=_-1;else return E}return null}};P.default=R},"./src/utils/buffer-helper.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"BufferHelper",function(){return T});var R=n("./src/utils/logger.ts"),p={length:0,start:function(){return 0},end:function(){return 0}},T=function(){function I(){}return I.isBuffered=function(O,_){try{if(O){for(var E=I.getBuffered(O),A=0;A<E.length;A++)if(_>=E.start(A)&&_<=E.end(A))return!0}}catch{}return!1},I.bufferInfo=function(O,_,E){try{if(O){var A=I.getBuffered(O),D=[],x;for(x=0;x<A.length;x++)D.push({start:A.start(x),end:A.end(x)});return this.bufferedInfo(D,_,E)}}catch{}return{len:0,start:_,end:_,nextStart:void 0}},I.bufferedInfo=function(O,_,E){_=Math.max(0,_),O.sort(function(t,u){var c=t.start-u.start;return c||u.end-t.end});var A=[];if(E)for(var D=0;D<O.length;D++){var x=A.length;if(x){var g=A[x-1].end;O[D].start-g<E?O[D].end>g&&(A[x-1].end=O[D].end):A.push(O[D])}else A.push(O[D])}else A=O;for(var y=0,s,e=_,o=_,f=0;f<A.length;f++){var a=A[f].start,i=A[f].end;if(_+E>=a&&_<i)e=a,o=i,y=o-_;else if(_+E<a){s=a;break}}return{len:y,start:e||0,end:o||0,nextStart:s}},I.getBuffered=function(O){try{return O.buffered}catch(_){return R.logger.log("failed to get media.buffered",_),p}},I}()},"./src/utils/cea-608-parser.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"Row",function(){return o}),n.d(P,"CaptionScreen",function(){return f});var R=n("./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},T=function(h){var d=h;return p.hasOwnProperty(h)&&(d=p[h]),String.fromCharCode(d)},I=15,S=100,O={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},E={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"],x;(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"})(x||(x={}));var g=function(){function r(){this.time=null,this.verboseLevel=x.ERROR}var h=r.prototype;return h.log=function(l,v){this.verboseLevel>=l&&R.logger.log(this.time+" ["+l+"] "+v)},r}(),y=function(h){for(var d=[],l=0;l<h.length;l++)d.push(h[l].toString(16));return d},s=function(){function r(d,l,v,m,L){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=d||"white",this.underline=l||!1,this.italics=v||!1,this.background=m||"black",this.flash=L||!1}var h=r.prototype;return h.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},h.setStyles=function(l){for(var v=["foreground","underline","italics","background","flash"],m=0;m<v.length;m++){var L=v[m];l.hasOwnProperty(L)&&(this[L]=l[L])}},h.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},h.equals=function(l){return this.foreground===l.foreground&&this.underline===l.underline&&this.italics===l.italics&&this.background===l.background&&this.flash===l.flash},h.copy=function(l){this.foreground=l.foreground,this.underline=l.underline,this.italics=l.italics,this.background=l.background,this.flash=l.flash},h.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},r}(),e=function(){function r(d,l,v,m,L,b){this.uchar=void 0,this.penState=void 0,this.uchar=d||" ",this.penState=new s(l,v,m,L,b)}var h=r.prototype;return h.reset=function(){this.uchar=" ",this.penState.reset()},h.setChar=function(l,v){this.uchar=l,this.penState.copy(v)},h.setPenState=function(l){this.penState.copy(l)},h.equals=function(l){return this.uchar===l.uchar&&this.penState.equals(l.penState)},h.copy=function(l){this.uchar=l.uchar,this.penState.copy(l.penState)},h.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},r}(),o=function(){function r(d){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var l=0;l<S;l++)this.chars.push(new e);this.logger=d,this.pos=0,this.currPenState=new s}var h=r.prototype;return h.equals=function(l){for(var v=!0,m=0;m<S;m++)if(!this.chars[m].equals(l.chars[m])){v=!1;break}return v},h.copy=function(l){for(var v=0;v<S;v++)this.chars[v].copy(l.chars[v])},h.isEmpty=function(){for(var l=!0,v=0;v<S;v++)if(!this.chars[v].isEmpty()){l=!1;break}return l},h.setCursor=function(l){this.pos!==l&&(this.pos=l),this.pos<0?(this.logger.log(x.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>S&&(this.logger.log(x.DEBUG,"Too large cursor position "+this.pos),this.pos=S)},h.moveCursor=function(l){var v=this.pos+l;if(l>1)for(var m=this.pos+1;m<v+1;m++)this.chars[m].setPenState(this.currPenState);this.setCursor(v)},h.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},h.insertChar=function(l){l>=144&&this.backSpace();var v=T(l);if(this.pos>=S){this.logger.log(x.ERROR,"Cannot insert "+l.toString(16)+" ("+v+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(v,this.currPenState),this.moveCursor(1)},h.clearFromPos=function(l){var v;for(v=l;v<S;v++)this.chars[v].reset()},h.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},h.clearToEndOfRow=function(){this.clearFromPos(this.pos)},h.getTextString=function(){for(var l=[],v=!0,m=0;m<S;m++){var L=this.chars[m].uchar;L!==" "&&(v=!1),l.push(L)}return v?"":l.join("")},h.setPenStyles=function(l){this.currPenState.setStyles(l);var v=this.chars[this.pos];v.setPenState(this.currPenState)},r}(),f=function(){function r(d){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var l=0;l<I;l++)this.rows.push(new o(d));this.logger=d,this.currRow=I-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var h=r.prototype;return h.reset=function(){for(var l=0;l<I;l++)this.rows[l].clear();this.currRow=I-1},h.equals=function(l){for(var v=!0,m=0;m<I;m++)if(!this.rows[m].equals(l.rows[m])){v=!1;break}return v},h.copy=function(l){for(var v=0;v<I;v++)this.rows[v].copy(l.rows[v])},h.isEmpty=function(){for(var l=!0,v=0;v<I;v++)if(!this.rows[v].isEmpty()){l=!1;break}return l},h.backSpace=function(){var l=this.rows[this.currRow];l.backSpace()},h.clearToEndOfRow=function(){var l=this.rows[this.currRow];l.clearToEndOfRow()},h.insertChar=function(l){var v=this.rows[this.currRow];v.insertChar(l)},h.setPen=function(l){var v=this.rows[this.currRow];v.setPenStyles(l)},h.moveCursor=function(l){var v=this.rows[this.currRow];v.moveCursor(l)},h.setCursor=function(l){this.logger.log(x.INFO,"setCursor: "+l);var v=this.rows[this.currRow];v.setCursor(l)},h.setPAC=function(l){this.logger.log(x.INFO,"pacData = "+JSON.stringify(l));var v=l.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 L=this.currRow+1-this.nrRollUpRows,b=this.lastOutputScreen;if(b){var M=b.rows[L].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[L+w])}}this.currRow=v;var C=this.rows[this.currRow];if(l.indent!==null){var U=l.indent,k=Math.max(U-1,0);C.setCursor(l.indent),l.color=C.chars[k].penState.foreground}var j={foreground:l.color,underline:l.underline,italics:l.italics,background:"black",flash:!1};this.setPen(j)},h.setBkgData=function(l){this.logger.log(x.INFO,"bkgData = "+JSON.stringify(l)),this.backSpace(),this.setPen(l),this.insertChar(32)},h.setRollUpRows=function(l){this.nrRollUpRows=l},h.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(x.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(x.TEXT,this.getDisplayText());var l=this.currRow+1-this.nrRollUpRows,v=this.rows.splice(l,1)[0];v.clear(),this.rows.splice(this.currRow,0,v),this.logger.log(x.INFO,"Rolling up")},h.getDisplayText=function(l){l=l||!1;for(var v=[],m="",L=-1,b=0;b<I;b++){var M=this.rows[b].getTextString();M&&(L=b+1,l?v.push("Row "+L+": '"+M+"'"):v.push(M.trim()))}return v.length>0&&(l?m="["+v.join(" | ")+"]":m=v.join(`
|
|
19
|
-
`)),m},h.getTextAndFormat=function(){return this.rows},r}(),a=function(){function r(d,l,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=d,this.outputFilter=l,this.mode=null,this.verbose=0,this.displayedMemory=new f(v),this.nonDisplayedMemory=new f(v),this.lastOutputScreen=new f(v),this.currRollUpRow=this.displayedMemory.rows[I-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=v}var h=r.prototype;return h.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},h.getHandler=function(){return this.outputFilter},h.setHandler=function(l){this.outputFilter=l},h.setPAC=function(l){this.writeScreen.setPAC(l)},h.setBkgData=function(l){this.writeScreen.setBkgData(l)},h.setMode=function(l){l!==this.mode&&(this.mode=l,this.logger.log(x.INFO,"MODE="+l),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=l)},h.insertChars=function(l){for(var v=0;v<l.length;v++)this.writeScreen.insertChar(l[v]);var m=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(x.INFO,m+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(x.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},h.ccRCL=function(){this.logger.log(x.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},h.ccBS=function(){this.logger.log(x.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},h.ccAOF=function(){},h.ccAON=function(){},h.ccDER=function(){this.logger.log(x.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},h.ccRU=function(l){this.logger.log(x.INFO,"RU("+l+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(l)},h.ccFON=function(){this.logger.log(x.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},h.ccRDC=function(){this.logger.log(x.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},h.ccTR=function(){this.logger.log(x.INFO,"TR"),this.setMode("MODE_TEXT")},h.ccRTD=function(){this.logger.log(x.INFO,"RTD"),this.setMode("MODE_TEXT")},h.ccEDM=function(){this.logger.log(x.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},h.ccCR=function(){this.logger.log(x.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},h.ccENM=function(){this.logger.log(x.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},h.ccEOC=function(){if(this.logger.log(x.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var l=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=l,this.writeScreen=this.nonDisplayedMemory,this.logger.log(x.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},h.ccTO=function(l){this.logger.log(x.INFO,"TO("+l+") - Tab Offset"),this.writeScreen.moveCursor(l)},h.ccMIDROW=function(l){var v={flash:!1};if(v.underline=l%2===1,v.italics=l>=46,v.italics)v.foreground="white";else{var m=Math.floor(l/2)-16,L=["white","green","blue","cyan","red","yellow","magenta"];v.foreground=L[m]}this.logger.log(x.INFO,"MIDROW: "+JSON.stringify(v)),this.writeScreen.setPen(v)},h.outputDataUpdate=function(l){l===void 0&&(l=!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),l&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:v),this.lastOutputScreen.copy(this.displayedMemory))},h.cueSplitAtTime=function(l){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,l,this.displayedMemory),this.cueStartTime=l))},r}(),i=function(){function r(d,l,v){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var m=new g;this.channels=[null,new a(d,l,m),new a(d+1,v,m)],this.cmdHistory=c(),this.logger=m}var h=r.prototype;return h.getHandler=function(l){return this.channels[l].getHandler()},h.setHandler=function(l,v){this.channels[l].setHandler(v)},h.addData=function(l,v){var m,L,b,M=!1;this.logger.time=l;for(var F=0;F<v.length;F+=2)if(L=v[F]&127,b=v[F+1]&127,!(L===0&&b===0)){if(this.logger.log(x.DATA,"["+y([v[F],v[F+1]])+"] -> ("+y([L,b])+")"),m=this.parseCmd(L,b),m||(m=this.parseMidrow(L,b)),m||(m=this.parsePAC(L,b)),m||(m=this.parseBackgroundAttributes(L,b)),!m&&(M=this.parseChars(L,b),M)){var w=this.currentChannel;if(w&&w>0){var C=this.channels[w];C.insertChars(M)}else this.logger.log(x.WARNING,"No channel found yet. TEXT-MODE?")}!m&&!M&&this.logger.log(x.WARNING,"Couldn't parse cleaned data "+y([L,b])+" orig: "+y([v[F],v[F+1]]))}},h.parseCmd=function(l,v){var m=this.cmdHistory,L=(l===20||l===28||l===21||l===29)&&v>=32&&v<=47,b=(l===23||l===31)&&v>=33&&v<=35;if(!(L||b))return!1;if(u(l,v,m))return t(null,null,m),this.logger.log(x.DEBUG,"Repeated command ("+y([l,v])+") is dropped"),!0;var M=l===20||l===21||l===23?1:2,F=this.channels[M];return l===20||l===21||l===28||l===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(l,v,m),this.currentChannel=M,!0},h.parseMidrow=function(l,v){var m=0;if((l===17||l===25)&&v>=32&&v<=47){if(l===17?m=1:m=2,m!==this.currentChannel)return this.logger.log(x.ERROR,"Mismatch channel in midrow parsing"),!1;var L=this.channels[m];return L?(L.ccMIDROW(v),this.logger.log(x.DEBUG,"MIDROW ("+y([l,v])+")"),!0):!1}return!1},h.parsePAC=function(l,v){var m,L=this.cmdHistory,b=(l>=17&&l<=23||l>=25&&l<=31)&&v>=64&&v<=127,M=(l===16||l===24)&&v>=64&&v<=95;if(!(b||M))return!1;if(u(l,v,L))return t(null,null,L),!0;var F=l<=23?1:2;v>=64&&v<=95?m=F===1?O[l]:E[l]:m=F===1?_[l]:A[l];var w=this.channels[F];return w?(w.setPAC(this.interpretPAC(m,v)),t(l,v,L),this.currentChannel=F,!0):!1},h.interpretPAC=function(l,v){var m,L={color:null,italics:!1,indent:null,underline:!1,row:l};return v>95?m=v-96:m=v-64,L.underline=(m&1)===1,m<=13?L.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(m/2)]:m<=15?(L.italics=!0,L.color="white"):L.indent=Math.floor((m-16)/2)*4,L},h.parseChars=function(l,v){var m,L=null,b=null;if(l>=25?(m=2,b=l-8):(m=1,b=l),b>=17&&b<=19){var M;b===17?M=v+80:b===18?M=v+112:M=v+144,this.logger.log(x.INFO,"Special char '"+T(M)+"' in channel "+m),L=[M]}else l>=32&&l<=127&&(L=v===0?[l]:[l,v]);if(L){var F=y(L);this.logger.log(x.DEBUG,"Char codes = "+F.join(",")),t(l,v,this.cmdHistory)}return L},h.parseBackgroundAttributes=function(l,v){var m=(l===16||l===24)&&v>=32&&v<=47,L=(l===23||l===31)&&v>=45&&v<=47;if(!(m||L))return!1;var b,M={};l===16||l===24?(b=Math.floor((v-32)/2),M.background=D[b],v%2===1&&(M.background=M.background+"_semi")):v===45?M.background="transparent":(M.foreground="black",v===47&&(M.underline=!0));var F=l<=23?1:2,w=this.channels[F];return w.setBkgData(M),t(l,v,this.cmdHistory),!0},h.reset=function(){for(var l=0;l<Object.keys(this.channels).length;l++){var v=this.channels[l];v&&v.reset()}this.cmdHistory=c()},h.cueSplitAtTime=function(l){for(var v=0;v<this.channels.length;v++){var m=this.channels[v];m&&m.cueSplitAtTime(l)}},r}();function t(r,h,d){d.a=r,d.b=h}function u(r,h,d){return d.a===r&&d.b===h}function c(){return{a:null,b:null}}P.default=i},"./src/utils/codecs.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"isCodecType",function(){return p}),n.d(P,"isCodecSupportedInMp4",function(){return T});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,S){var O=R[S];return!!O&&O[I.slice(0,4)]===!0}function T(I,S){return MediaSource.isTypeSupported((S||"video")+'/mp4;codecs="'+I+'"')}},"./src/utils/cues.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/utils/vttparser.ts"),p=n("./src/utils/webvtt-parser.ts"),T=n("./src/utils/texttrack-utils.ts"),I=/\s/,S={newCue:function(_,E,A,D){for(var x=[],g,y,s,e,o,f=self.VTTCue||self.TextTrackCue,a=0;a<D.rows.length;a++)if(g=D.rows[a],s=!0,e=0,o="",!g.isEmpty()){for(var i=0;i<g.chars.length;i++)I.test(g.chars[i].uchar)&&s?e++:(o+=g.chars[i].uchar,s=!1);g.cueStartTime=E,E===A&&(A+=1e-4),e>=16?e--:e++;var t=Object(R.fixLineBreaks)(o.trim()),u=Object(p.generateCueId)(E,A,t);(!_||!_.cues||!_.cues.getCueById(u))&&(y=new f(E,A,t),y.id=u,y.line=a+1,y.align="left",y.position=10+Math.min(80,Math.floor(e*8/32)*10),x.push(y))}return _&&x.length&&(x.sort(function(c,r){return c.line==="auto"||r.line==="auto"?0:c.line>8&&r.line>8?r.line-c.line:c.line-r.line}),x.forEach(function(c){return Object(T.addCueToTrack)(_,c)})),x}};P.default=S},"./src/utils/discontinuities.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"findFirstFragWithCC",function(){return I}),n.d(P,"shouldAlignOnDiscontinuities",function(){return S}),n.d(P,"findDiscontinuousReferenceFrag",function(){return O}),n.d(P,"adjustSlidingStart",function(){return E}),n.d(P,"alignStream",function(){return A}),n.d(P,"alignPDT",function(){return x}),n.d(P,"alignFragmentByPDTDelta",function(){return g}),n.d(P,"alignMediaPlaylistByPDT",function(){return y});var R=n("./src/polyfills/number.ts"),p=n("./src/utils/logger.ts"),T=n("./src/controller/level-helper.ts");function I(s,e){for(var o=null,f=0,a=s.length;f<a;f++){var i=s[f];if(i&&i.cc===e){o=i;break}}return o}function S(s,e,o){return!!(e.details&&(o.endCC>o.startCC||s&&s.cc<o.startCC))}function O(s,e){var o=s.fragments,f=e.fragments;if(!f.length||!o.length){p.logger.log("No fragments to align");return}var a=I(o,f[0].cc);if(!a||a&&!a.startPTS){p.logger.log("No frag in previous level to align on");return}return a}function _(s,e){if(s){var o=s.start+e;s.start=s.startPTS=o,s.endPTS=o+s.duration}}function E(s,e){for(var o=e.fragments,f=0,a=o.length;f<a;f++)_(o[f],s);e.fragmentHint&&_(e.fragmentHint,s),e.alignedSliding=!0}function A(s,e,o){!e||(D(s,o,e),!o.alignedSliding&&e.details&&x(o,e.details),!o.alignedSliding&&e.details&&!o.skippedSegments&&Object(T.adjustSliding)(e.details,o))}function D(s,e,o){if(S(s,o,e)){var f=O(o.details,e);f&&Object(R.isFiniteNumber)(f.start)&&(p.logger.log("Adjusting PTS using last level due to CC increase within current level "+e.url),E(f.start,e))}}function x(s,e){if(!(!e.fragments.length||!s.hasProgramDateTime||!e.hasProgramDateTime)){var o=e.fragments[0].programDateTime,f=s.fragments[0].programDateTime,a=(f-o)/1e3+e.fragments[0].start;a&&Object(R.isFiniteNumber)(a)&&(p.logger.log("Adjusting PTS using programDateTime delta "+(f-o)+"ms, sliding:"+a.toFixed(3)+" "+s.url+" "),E(a,s))}}function g(s,e){var o=s.programDateTime;if(!!o){var f=(o-e)/1e3;s.start=s.startPTS=f,s.endPTS=f+s.duration}}function y(s,e){if(!(!e.fragments.length||!s.hasProgramDateTime||!e.hasProgramDateTime)){var o=e.fragments[0].programDateTime,f=e.fragments[0].start,a=o-f*1e3;s.fragments.forEach(function(i){g(i,a)}),s.fragmentHint&&g(s.fragmentHint,a),s.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/utils/ewma.ts"),p=function(){function T(S,O,_){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(S),this.fast_=new R.default(O)}var I=T.prototype;return I.update=function(O,_){var E=this.slow_,A=this.fast_;this.slow_.halfLife!==O&&(this.slow_=new R.default(O,E.getEstimate(),E.getTotalWeight())),this.fast_.halfLife!==_&&(this.fast_=new R.default(_,A.getEstimate(),A.getTotalWeight()))},I.sample=function(O,_){O=Math.max(O,this.minDelayMs_);var E=8*_,A=O/1e3,D=E/A;this.fast_.sample(A,D),this.slow_.sample(A,D)},I.canEstimate=function(){var O=this.fast_;return O&&O.getTotalWeight()>=this.minWeight_},I.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},I.destroy=function(){},T}();P.default=p},"./src/utils/ewma.ts":function(B,P,n){"use strict";n.r(P);var R=function(){function p(I,S,O){S===void 0&&(S=0),O===void 0&&(O=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_=S,this.totalWeight_=O}var T=p.prototype;return T.sample=function(S,O){var _=Math.pow(this.alpha_,S);this.estimate_=O*(1-_)+_*this.estimate_,this.totalWeight_+=S},T.getTotalWeight=function(){return this.totalWeight_},T.getEstimate=function(){if(this.alpha_){var S=1-Math.pow(this.alpha_,this.totalWeight_);if(S)return this.estimate_/S}return this.estimate_},p}();P.default=R},"./src/utils/fetch-loader.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"fetchSupported",function(){return g});var R=n("./src/polyfills/number.ts"),p=n("./src/loader/load-stats.ts"),T=n("./src/demux/chunk-cache.ts");function I(f,a){f.prototype=Object.create(a.prototype),f.prototype.constructor=f,A(f,a)}function S(f){var a=typeof Map=="function"?new Map:void 0;return S=function(t){if(t===null||!E(t))return t;if(typeof t!="function")throw new TypeError("Super expression must either be null or a function");if(typeof a!="undefined"){if(a.has(t))return a.get(t);a.set(t,u)}function u(){return O(t,arguments,D(this).constructor)}return u.prototype=Object.create(t.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),A(u,t)},S(f)}function O(f,a,i){return _()?O=Reflect.construct.bind():O=function(u,c,r){var h=[null];h.push.apply(h,c);var d=Function.bind.apply(u,h),l=new d;return r&&A(l,r.prototype),l},O.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 E(f){return Function.toString.call(f).indexOf("[native code]")!==-1}function A(f,a){return A=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,u){return t.__proto__=u,t},A(f,a)}function D(f){return D=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},D(f)}function x(){return x=Object.assign?Object.assign.bind():function(f){for(var a=1;a<arguments.length;a++){var i=arguments[a];for(var t in i)Object.prototype.hasOwnProperty.call(i,t)&&(f[t]=i[t])}return f},x.apply(this,arguments)}function g(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var y=function(){function f(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 a=f.prototype;return a.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},a.abortInternal=function(){var t=this.response;(!t||!t.ok)&&(this.stats.aborted=!0,this.controller.abort())},a.abort=function(){var t;this.abortInternal(),(t=this.callbacks)!==null&&t!==void 0&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},a.load=function(t,u,c){var r=this,h=this.stats;if(h.loading.start)throw new Error("Loader can only be used once.");h.loading.start=self.performance.now();var d=s(t,this.controller.signal),l=c.onProgress,v=t.responseType==="arraybuffer",m=v?"byteLength":"length";this.context=t,this.config=u,this.callbacks=c,this.request=this.fetchSetup(t,d),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){r.abortInternal(),c.onTimeout(h,t,r.response)},u.timeout),self.fetch(this.request).then(function(L){if(r.response=r.loader=L,!L.ok){var b=L.status,M=L.statusText;throw new o(M||"fetch, bad network response",b,L)}return h.loading.first=Math.max(self.performance.now(),h.loading.start),h.total=parseInt(L.headers.get("Content-Length")||"0"),l&&Object(R.isFiniteNumber)(u.highWaterMark)?r.loadProgressively(L,h,t,u.highWaterMark,l):v?L.arrayBuffer():L.text()}).then(function(L){var b=r.response;self.clearTimeout(r.requestTimeout),h.loading.end=Math.max(self.performance.now(),h.loading.first),h.loaded=h.total=L[m];var M={url:b.url,data:L};l&&!Object(R.isFiniteNumber)(u.highWaterMark)&&l(h,t,L,b),c.onSuccess(M,h,t,b)}).catch(function(L){if(self.clearTimeout(r.requestTimeout),!h.aborted){var b=L&&L.code||0,M=L?L.message:null;c.onError({code:b,text:M},t,L?L.details:null)}})},a.getCacheAge=function(){var t=null;if(this.response){var u=this.response.headers.get("age");t=u?parseFloat(u):null}return t},a.loadProgressively=function(t,u,c,r,h){r===void 0&&(r=0);var d=new T.default,l=t.body.getReader(),v=function m(){return l.read().then(function(L){if(L.done)return d.dataLength&&h(u,c,d.flush(),t),Promise.resolve(new ArrayBuffer(0));var b=L.value,M=b.length;return u.loaded+=M,M<r||d.dataLength?(d.push(b),d.dataLength>=r&&h(u,c,d.flush(),t)):h(u,c,b,t),m()}).catch(function(){return Promise.reject()})};return v()},f}();function s(f,a){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:a,headers:new self.Headers(x({},f.headers))};return f.rangeEnd&&i.headers.set("Range","bytes="+f.rangeStart+"-"+String(f.rangeEnd-1)),i}function e(f,a){return new self.Request(f.url,a)}var o=function(f){I(a,f);function a(i,t,u){var c;return c=f.call(this,i)||this,c.code=void 0,c.details=void 0,c.code=t,c.details=u,c}return a}(S(Error));P.default=y},"./src/utils/imsc1-ttml-parser.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"IMSC1_CODEC",function(){return E}),n.d(P,"parseIMSC1",function(){return g});var R=n("./src/utils/mp4-tools.ts"),p=n("./src/utils/vttparser.ts"),T=n("./src/utils/vttcue.ts"),I=n("./src/demux/id3.ts"),S=n("./src/utils/timescale-conversion.ts"),O=n("./src/utils/webvtt-parser.ts");function _(){return _=Object.assign?Object.assign.bind():function(r){for(var h=1;h<arguments.length;h++){var d=arguments[h];for(var l in d)Object.prototype.hasOwnProperty.call(d,l)&&(r[l]=d[l])}return r},_.apply(this,arguments)}var E="stpp.ttml.im1t",A=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,D=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,x={left:"start",center:"center",right:"end",start:"start",end:"end"};function g(r,h,d,l,v){var m=Object(R.findBox)(new Uint8Array(r),["mdat"]);if(m.length===0){v(new Error("Could not parse IMSC1 mdat"));return}var L=m.map(function(M){return Object(I.utf8ArrayToStr)(M)}),b=Object(S.toTimescaleFromScale)(h,1,d);try{L.forEach(function(M){return l(y(M,b))})}catch(M){v(M)}}function y(r,h){var d=new DOMParser,l=d.parseFromString(r,"text/xml"),v=l.getElementsByTagName("tt")[0];if(!v)throw new Error("Invalid ttml");var m={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},L=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(s(v,"styling","style")),F=e(s(v,"layout","region")),w=s(v,"body","[begin]");return[].map.call(w,function(C){var U=o(C,b);if(!U||!C.hasAttribute("begin"))return null;var k=t(C.getAttribute("begin"),L),j=t(C.getAttribute("dur"),L),N=t(C.getAttribute("end"),L);if(k===null)throw i(C);if(N===null){if(j===null)throw i(C);N=k+j}var W=new T.default(k-h,N-h,U);W.id=Object(O.generateCueId)(W.startTime,W.endTime,W.text);var Y=F[C.getAttribute("region")],K=M[C.getAttribute("style")];W.position=10,W.size=80;var H=f(Y,K,M),z=H.textAlign;if(z){var $=x[z];$&&(W.lineAlign=$),W.align=z}return _(W,H),W}).filter(function(C){return C!==null})}function s(r,h,d){var l=r.getElementsByTagName(h)[0];return l?[].slice.call(l.querySelectorAll(d)):[]}function e(r){return r.reduce(function(h,d){var l=d.getAttribute("xml:id");return l&&(h[l]=d),h},{})}function o(r,h){return[].slice.call(r.childNodes).reduce(function(d,l,v){var m;return l.nodeName==="br"&&v?d+`
|
|
20
|
-
`:(m=l.childNodes)!==null&&m!==void 0&&m.length?o(l,h):h?d+l.textContent.trim().replace(/\s+/g," "):d+l.textContent},"")}function f(r,h,d){var l="http://www.w3.org/ns/ttml#styling",v=null,m=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],L=r!=null&&r.hasAttribute("style")?r.getAttribute("style"):null;return L&&d.hasOwnProperty(L)&&(v=d[L]),m.reduce(function(b,M){var F=a(h,l,M)||a(r,l,M)||a(v,l,M);return F&&(b[M]=F),b},{})}function a(r,h,d){return r&&r.hasAttributeNS(h,d)?r.getAttributeNS(h,d):null}function i(r){return new Error("Could not parse ttml timestamp "+r)}function t(r,h){if(!r)return null;var d=Object(p.parseTimeStamp)(r);return d===null&&(A.test(r)?d=u(r,h):D.test(r)&&(d=c(r,h))),d}function u(r,h){var d=A.exec(r),l=(d[4]|0)+(d[5]|0)/h.subFrameRate;return(d[1]|0)*3600+(d[2]|0)*60+(d[3]|0)+l/h.frameRate}function c(r,h){var d=D.exec(r),l=Number(d[1]),v=d[2];switch(v){case"h":return l*3600;case"m":return l*60;case"ms":return l*1e3;case"f":return l/h.frameRate;case"t":return l/h.tickRate}return l}},"./src/utils/logger.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"enableLogs",function(){return O}),n.d(P,"logger",function(){return _});var R=function(){},p={trace:R,debug:R,log:R,warn:R,info:R,error:R},T=p;function I(E){var A=self.console[E];return A?A.bind(self.console,"["+E+"] >"):R}function S(E){for(var A=arguments.length,D=new Array(A>1?A-1:0),x=1;x<A;x++)D[x-1]=arguments[x];D.forEach(function(g){T[g]=E[g]?E[g].bind(E):I(g)})}function O(E){if(self.console&&E===!0||typeof E=="object"){S(E,"debug","log","info","warn","error");try{T.log()}catch{T=p}}else T=p}var _=T},"./src/utils/mediakeys-helper.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"KeySystems",function(){return R}),n.d(P,"requestMediaKeySystemAccess",function(){return p});var R;(function(T){T.WIDEVINE="com.widevine.alpha",T.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(B,P,n){"use strict";n.r(P),n.d(P,"getMediaSource",function(){return R});function R(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"RemuxerTrackIdConfig",function(){return O}),n.d(P,"bin2str",function(){return _}),n.d(P,"readUint16",function(){return E}),n.d(P,"readUint32",function(){return A}),n.d(P,"readSint32",function(){return D}),n.d(P,"writeUint32",function(){return x}),n.d(P,"findBox",function(){return g}),n.d(P,"parseSegmentIndex",function(){return y}),n.d(P,"parseInitSegment",function(){return s}),n.d(P,"getStartDTS",function(){return e}),n.d(P,"getDuration",function(){return o}),n.d(P,"computeRawDurationFromSamples",function(){return f}),n.d(P,"offsetStartDTS",function(){return a}),n.d(P,"segmentValidRange",function(){return i}),n.d(P,"appendUint8Array",function(){return t}),n.d(P,"parseSamples",function(){return u}),n.d(P,"parseSEIMessageFromNALu",function(){return h}),n.d(P,"parseEmsg",function(){return l});var R=n("./src/utils/typed-array.ts"),p=n("./src/loader/fragment.ts"),T=n("./src/demux/id3.ts"),I=Math.pow(2,32)-1,S=[].push,O={video:1,audio:2,id3:3,text:4};function _(v){return String.fromCharCode.apply(null,v)}function E(v,m){var L=v[m]<<8|v[m+1];return L<0?65536+L:L}function A(v,m){var L=D(v,m);return L<0?4294967296+L:L}function D(v,m){return v[m]<<24|v[m+1]<<16|v[m+2]<<8|v[m+3]}function x(v,m,L){v[m]=L>>24,v[m+1]=L>>16&255,v[m+2]=L>>8&255,v[m+3]=L&255}function g(v,m){var L=[];if(!m.length)return L;for(var b=v.byteLength,M=0;M<b;){var F=A(v,M),w=_(v.subarray(M+4,M+8)),C=F>1?M+F:b;if(w===m[0])if(m.length===1)L.push(v.subarray(M+8,C));else{var U=g(v.subarray(M+8,C),m.slice(1));U.length&&S.apply(L,U)}M=C}return L}function y(v){var m=[],L=v[0],b=8,M=A(v,b);b+=4;var F=0,w=0;L===0?b+=8:b+=16,b+=2;var C=v.length+w,U=E(v,b);b+=2;for(var k=0;k<U;k++){var j=b,N=A(v,j);j+=4;var W=N&2147483647,Y=(N&2147483648)>>>31;if(Y===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var K=A(v,j);j+=4,m.push({referenceSize:W,subsegmentDuration:K,info:{duration:K/M,start:C,end:C+W-1}}),C+=W,j+=4,b=j}return{earliestPresentationTime:F,timescale:M,version:L,referencesCount:U,references:m}}function s(v){for(var m=[],L=g(v,["moov","trak"]),b=0;b<L.length;b++){var M=L[b],F=g(M,["tkhd"])[0];if(F){var w=F[0],C=w===0?12:20,U=A(F,C),k=g(M,["mdia","mdhd"])[0];if(k){w=k[0],C=w===0?12:20;var j=A(k,C),N=g(M,["mdia","hdlr"])[0];if(N){var W=_(N.subarray(8,12)),Y={soun:p.ElementaryStreamTypes.AUDIO,vide:p.ElementaryStreamTypes.VIDEO}[W];if(Y){var K=g(M,["mdia","minf","stbl","stsd"])[0],H=void 0;K&&(H=_(K.subarray(12,16))),m[U]={timescale:j,type:Y},m[Y]={timescale:j,id:U,codec:H}}}}}}var z=g(v,["moov","mvex","trex"]);return z.forEach(function($){var X=A($,4),J=m[X];J&&(J.default={duration:A($,12),flags:A($,20)})}),m}function e(v,m){return g(m,["moof","traf"]).reduce(function(L,b){var M=g(b,["tfdt"])[0],F=M[0],w=g(b,["tfhd"]).reduce(function(C,U){var k=A(U,4),j=v[k];if(j){var N=A(M,4);F===1&&(N*=Math.pow(2,32),N+=A(M,8));var W=j.timescale||9e4,Y=N/W;if(isFinite(Y)&&(C===null||Y<C))return Y}return C},null);return w!==null&&isFinite(w)&&(L===null||w<L)?w:L},null)||0}function o(v,m){for(var L=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],k=A(U,4),j=m[k];if(!!j){var N=j.default,W=A(U,0)|(N==null?void 0:N.flags),Y=N==null?void 0:N.duration;W&8&&(W&2?Y=A(U,12):Y=A(U,8));for(var K=j.timescale||9e4,H=g(C,["trun"]),z=0;z<H.length;z++){if(L=f(H[z]),!L&&Y){var $=A(H[z],4);L=Y*$}j.type===p.ElementaryStreamTypes.VIDEO?b+=L/K:j.type===p.ElementaryStreamTypes.AUDIO&&(M+=L/K)}}}if(b===0&&M===0){for(var X=0,J=g(v,["sidx"]),te=0;te<J.length;te++){var Q=y(J[te]);Q!=null&&Q.references&&(X+=Q.references.reduce(function(ae,se){return ae+se.info.duration||0},0))}return X}return b||M}function f(v){var m=A(v,0),L=8;m&1&&(L+=4),m&4&&(L+=4);for(var b=0,M=A(v,4),F=0;F<M;F++){if(m&256){var w=A(v,L);b+=w,L+=4}m&512&&(L+=4),m&1024&&(L+=4),m&2048&&(L+=4)}return b}function a(v,m,L){g(m,["moof","traf"]).forEach(function(b){g(b,["tfhd"]).forEach(function(M){var F=A(M,4),w=v[F];if(!!w){var C=w.timescale||9e4;g(b,["tfdt"]).forEach(function(U){var k=U[0],j=A(U,4);if(k===0)j-=L*C,j=Math.max(j,0),x(U,4,j);else{j*=Math.pow(2,32),j+=A(U,8),j-=L*C,j=Math.max(j,0);var N=Math.floor(j/(I+1)),W=Math.floor(j%(I+1));x(U,4,N),x(U,8,W)}})}})})}function i(v){var m={valid:null,remainder:null},L=g(v,["moof"]);if(L){if(L.length<2)return m.remainder=v,m}else return m;var b=L[L.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 L=new Uint8Array(v.length+m.length);return L.set(v),L.set(m,v.length),L}function u(v,m){var L=[],b=m.samples,M=m.timescale,F=m.id,w=!1,C=g(b,["moof"]);return C.map(function(U){var k=U.byteOffset-8,j=g(U,["traf"]);j.map(function(N){var W=g(N,["tfdt"]).map(function(Y){var K=Y[0],H=A(Y,4);return K===1&&(H*=Math.pow(2,32),H+=A(Y,8)),H/M})[0];return W!==void 0&&(v=W),g(N,["tfhd"]).map(function(Y){var K=A(Y,4),H=A(Y,0)&16777215,z=(H&1)!==0,$=(H&2)!==0,X=(H&8)!==0,J=0,te=(H&16)!==0,Q=0,ae=(H&32)!==0,se=8;K===F&&(z&&(se+=8),$&&(se+=4),X&&(J=A(Y,se),se+=4),te&&(Q=A(Y,se),se+=4),ae&&(se+=4),m.type==="video"&&(w=c(m.codec)),g(N,["trun"]).map(function(re){var ee=re[0],Z=A(re,0)&16777215,q=(Z&1)!==0,fe=0,ge=(Z&4)!==0,ie=(Z&256)!==0,me=0,ye=(Z&512)!==0,Te=0,oe=(Z&1024)!==0,de=(Z&2048)!==0,Se=0,Ee=A(re,4),Ae=8;q&&(fe=A(re,Ae),Ae+=4),ge&&(Ae+=4);for(var Oe=fe+k,Me=0;Me<Ee;Me++){if(ie?(me=A(re,Ae),Ae+=4):me=J,ye?(Te=A(re,Ae),Ae+=4):Te=Q,oe&&(Ae+=4),de&&(ee===0?Se=A(re,Ae):Se=D(re,Ae),Ae+=4),m.type===p.ElementaryStreamTypes.VIDEO)for(var De=0;De<Te;){var xe=A(b,Oe);Oe+=4;var G=b[Oe]&31;if(r(w,G)){var V=b.subarray(Oe,Oe+xe);h(V,v+Se/M,L)}Oe+=xe,De+=xe+4}v+=me/M}}))})})}),L}function c(v){if(!v)return!1;var m=v.indexOf("."),L=m<0?v:v.substring(0,m);return L==="hvc1"||L==="hev1"||L==="dvh1"||L==="dvhe"}function r(v,m){return v?m===39||m===40:m===6}function h(v,m,L){var b=d(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 k=b.length-M;if(!C&&F===4&&M<b.length){C=!0;var j=b[M++];if(j===181){var N=E(b,M);if(M+=2,N===49){var W=A(b,M);if(M+=4,W===1195456820){var Y=b[M++];if(Y===3){var K=b[M++],H=31&K,z=64&K,$=z?2+H*3:0,X=new Uint8Array($);if(z){X[0]=K;for(var J=1;J<$;J++)X[J]=b[M++]}L.push({type:Y,payloadType:F,pts:m,bytes:X})}}}}}else if(F===5&&w<k){if(C=!0,w>16){for(var te=[],Q=0;Q<16;Q++){var ae=b[M++].toString(16);te.push(ae.length==1?"0"+ae:ae),(Q===3||Q===5||Q===7||Q===9)&&te.push("-")}for(var se=w-16,re=new Uint8Array(se),ee=0;ee<se;ee++)re[ee]=b[M++];L.push({payloadType:F,pts:m,uuid:te.join(""),userData:Object(T.utf8ArrayToStr)(re),userDataBytes:re})}}else if(w<k)M+=w;else if(w>k)break}}function d(v){for(var m=v.byteLength,L=[],b=1;b<m-2;)v[b]===0&&v[b+1]===0&&v[b+2]===3?(L.push(b+2),b+=2):b++;if(L.length===0)return v;var M=m-L.length,F=new Uint8Array(M),w=0;for(b=0;b<M;w++,b++)w===L[0]&&(w++,L.shift()),F[b]=v[w];return F}function l(v){var m=v[0],L="",b="",M=0,F=0,w=0,C=0,U=0,k=0;if(m===0){for(;_(v.subarray(k,k+1))!=="\0";)L+=_(v.subarray(k,k+1)),k+=1;for(L+=_(v.subarray(k,k+1)),k+=1;_(v.subarray(k,k+1))!=="\0";)b+=_(v.subarray(k,k+1)),k+=1;b+=_(v.subarray(k,k+1)),k+=1,M=A(v,12),F=A(v,16),C=A(v,20),U=A(v,24),k=28}else if(m===1){k+=4,M=A(v,k),k+=4;var j=A(v,k);k+=4;var N=A(v,k);for(k+=4,w=Math.pow(2,32)*j+N,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=A(v,k),k+=4,U=A(v,k),k+=4;_(v.subarray(k,k+1))!=="\0";)L+=_(v.subarray(k,k+1)),k+=1;for(L+=_(v.subarray(k,k+1)),k+=1;_(v.subarray(k,k+1))!=="\0";)b+=_(v.subarray(k,k+1)),k+=1;b+=_(v.subarray(k,k+1)),k+=1}var W=v.subarray(k,v.byteLength);return{schemeIdUri:L,value:b,timeScale:M,presentationTime:w,presentationTimeDelta:F,eventDuration:C,id:U,payload:W}}},"./src/utils/output-filter.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return R});var R=function(){function p(I,S){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=I,this.trackName=S}var T=p.prototype;return T.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},T.newCue=function(S,O,_){(this.startTime===null||this.startTime>S)&&(this.startTime=S),this.endTime=O,this.screen=_,this.timelineController.createCaptionsTrack(this.trackName)},T.reset=function(){this.cueRanges=[],this.startTime=null},p}()},"./src/utils/texttrack-utils.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"sendAddTrackEvent",function(){return p}),n.d(P,"addCueToTrack",function(){return T}),n.d(P,"clearCurrentCues",function(){return I}),n.d(P,"removeCuesInRange",function(){return S}),n.d(P,"getCuesInRange",function(){return _});var R=n("./src/utils/logger.ts");function p(E,A){var D;try{D=new Event("addtrack")}catch{D=document.createEvent("Event"),D.initEvent("addtrack",!1,!1)}D.track=E,A.dispatchEvent(D)}function T(E,A){var D=E.mode;if(D==="disabled"&&(E.mode="hidden"),E.cues&&!E.cues.getCueById(A.id))try{if(E.addCue(A),!E.cues.getCueById(A.id))throw new Error("addCue is failed for: "+A)}catch(g){R.logger.debug("[texttrack-utils]: "+g);var x=new self.TextTrackCue(A.startTime,A.endTime,A.text);x.id=A.id,E.addCue(x)}D==="disabled"&&(E.mode=D)}function I(E){var A=E.mode;if(A==="disabled"&&(E.mode="hidden"),E.cues)for(var D=E.cues.length;D--;)E.removeCue(E.cues[D]);A==="disabled"&&(E.mode=A)}function S(E,A,D,x){var g=E.mode;if(g==="disabled"&&(E.mode="hidden"),E.cues&&E.cues.length>0)for(var y=_(E.cues,A,D),s=0;s<y.length;s++)(!x||x(y[s]))&&E.removeCue(y[s]);g==="disabled"&&(E.mode=g)}function O(E,A){if(A<E[0].startTime)return 0;var D=E.length-1;if(A>E[D].endTime)return-1;for(var x=0,g=D;x<=g;){var y=Math.floor((g+x)/2);if(A<E[y].startTime)g=y-1;else if(A>E[y].startTime&&x<D)x=y+1;else return y}return E[x].startTime-A<A-E[g].startTime?x:g}function _(E,A,D){var x=[],g=O(E,A);if(g>-1)for(var y=g,s=E.length;y<s;y++){var e=E[y];if(e.startTime>=A&&e.endTime<=D)x.push(e);else if(e.startTime>D)return x}return x}},"./src/utils/time-ranges.ts":function(B,P,n){"use strict";n.r(P);var R={toString:function(T){for(var I="",S=T.length,O=0;O<S;O++)I+="["+T.start(O).toFixed(3)+","+T.end(O).toFixed(3)+"]";return I}};P.default=R},"./src/utils/timescale-conversion.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"toTimescaleFromBase",function(){return p}),n.d(P,"toTimescaleFromScale",function(){return T}),n.d(P,"toMsFromMpegTsClock",function(){return I}),n.d(P,"toMpegTsClockFromTimescale",function(){return S});var R=9e4;function p(O,_,E,A){E===void 0&&(E=1),A===void 0&&(A=!1);var D=O*_*E;return A?Math.round(D):D}function T(O,_,E,A){return E===void 0&&(E=1),A===void 0&&(A=!1),p(O,_,1/E,A)}function I(O,_){return _===void 0&&(_=!1),p(O,1e3,1/R,_)}function S(O,_){return _===void 0&&(_=1),p(O,R,1/_)}},"./src/utils/typed-array.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"sliceUint8",function(){return R});function R(p,T,I){return Uint8Array.prototype.slice?p.slice(T,I):new Uint8Array(Array.prototype.slice.call(p,T,I))}},"./src/utils/vttcue.ts":function(B,P,n){"use strict";n.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 T(E,A){if(typeof A!="string"||!Array.isArray(E))return!1;var D=A.toLowerCase();return~E.indexOf(D)?D:!1}function I(E){return T(R,E)}function S(E){return T(p,E)}function O(E){for(var A=arguments.length,D=new Array(A>1?A-1:0),x=1;x<A;x++)D[x-1]=arguments[x];for(var g=1;g<arguments.length;g++){var y=arguments[g];for(var s in y)E[s]=y[s]}return E}function _(E,A,D){var x=this,g={enumerable:!0};x.hasBeenReset=!1;var y="",s=!1,e=E,o=A,f=D,a=null,i="",t=!0,u="auto",c="start",r=50,h="middle",d=50,l="middle";Object.defineProperty(x,"id",O({},g,{get:function(){return y},set:function(m){y=""+m}})),Object.defineProperty(x,"pauseOnExit",O({},g,{get:function(){return s},set:function(m){s=!!m}})),Object.defineProperty(x,"startTime",O({},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(x,"endTime",O({},g,{get:function(){return o},set:function(m){if(typeof m!="number")throw new TypeError("End time must be set to a number.");o=m,this.hasBeenReset=!0}})),Object.defineProperty(x,"text",O({},g,{get:function(){return f},set:function(m){f=""+m,this.hasBeenReset=!0}})),Object.defineProperty(x,"region",O({},g,{get:function(){return a},set:function(m){a=m,this.hasBeenReset=!0}})),Object.defineProperty(x,"vertical",O({},g,{get:function(){return i},set:function(m){var L=I(m);if(L===!1)throw new SyntaxError("An invalid or illegal string was specified.");i=L,this.hasBeenReset=!0}})),Object.defineProperty(x,"snapToLines",O({},g,{get:function(){return t},set:function(m){t=!!m,this.hasBeenReset=!0}})),Object.defineProperty(x,"line",O({},g,{get:function(){return u},set:function(m){if(typeof m!="number"&&m!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");u=m,this.hasBeenReset=!0}})),Object.defineProperty(x,"lineAlign",O({},g,{get:function(){return c},set:function(m){var L=S(m);if(!L)throw new SyntaxError("An invalid or illegal string was specified.");c=L,this.hasBeenReset=!0}})),Object.defineProperty(x,"position",O({},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(x,"positionAlign",O({},g,{get:function(){return h},set:function(m){var L=S(m);if(!L)throw new SyntaxError("An invalid or illegal string was specified.");h=L,this.hasBeenReset=!0}})),Object.defineProperty(x,"size",O({},g,{get:function(){return d},set:function(m){if(m<0||m>100)throw new Error("Size must be between 0 and 100.");d=m,this.hasBeenReset=!0}})),Object.defineProperty(x,"align",O({},g,{get:function(){return l},set:function(m){var L=S(m);if(!L)throw new SyntaxError("An invalid or illegal string was specified.");l=L,this.hasBeenReset=!0}})),x.displayState=void 0}return _.prototype.getCueAsHTML=function(){var E=self.WebVTT;return E.convertCueToDOMTree(self,this.text)},_}()},"./src/utils/vttparser.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"parseTimeStamp",function(){return T}),n.d(P,"fixLineBreaks",function(){return A}),n.d(P,"VTTParser",function(){return D});var R=n("./src/utils/vttcue.ts"),p=function(){function x(){}var g=x.prototype;return g.decode=function(s,e){if(!s)return"";if(typeof s!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(s))},x}();function T(x){function g(s,e,o,f){return(s|0)*3600+(e|0)*60+(o|0)+parseFloat(f||0)}var y=x.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return y?parseFloat(y[2])>59?g(y[2],y[3],0,y[4]):g(y[1],y[2],y[3],y[4]):null}var I=function(){function x(){this.values=Object.create(null)}var g=x.prototype;return g.set=function(s,e){!this.get(s)&&e!==""&&(this.values[s]=e)},g.get=function(s,e,o){return o?this.has(s)?this.values[s]:e[o]:this.has(s)?this.values[s]:e},g.has=function(s){return s in this.values},g.alt=function(s,e,o){for(var f=0;f<o.length;++f)if(e===o[f]){this.set(s,e);break}},g.integer=function(s,e){/^-?\d+$/.test(e)&&this.set(s,parseInt(e,10))},g.percent=function(s,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){var o=parseFloat(e);if(o>=0&&o<=100)return this.set(s,o),!0}return!1},x}();function S(x,g,y,s){var e=s?x.split(s):[x];for(var o in e)if(typeof e[o]=="string"){var f=e[o].split(y);if(f.length===2){var a=f[0],i=f[1];g(a,i)}}}var O=new R.default(0,0,""),_=O.align==="middle"?"middle":"center";function E(x,g,y){var s=x;function e(){var a=T(x);if(a===null)throw new Error("Malformed timestamp: "+s);return x=x.replace(/^[^\sa-zA-Z-]+/,""),a}function o(a,i){var t=new I;S(a,function(r,h){var d;switch(r){case"region":for(var l=y.length-1;l>=0;l--)if(y[l].id===h){t.set(r,y[l].region);break}break;case"vertical":t.alt(r,h,["rl","lr"]);break;case"line":d=h.split(","),t.integer(r,d[0]),t.percent(r,d[0])&&t.set("snapToLines",!1),t.alt(r,d[0],["auto"]),d.length===2&&t.alt("lineAlign",d[1],["start",_,"end"]);break;case"position":d=h.split(","),t.percent(r,d[0]),d.length===2&&t.alt("positionAlign",d[1],["start",_,"end","line-left","line-right","auto"]);break;case"size":t.percent(r,h);break;case"align":t.alt(r,h,["start",_,"end","left","right"]);break}},/:/,/\s/),i.region=t.get("region",null),i.vertical=t.get("vertical","");var u=t.get("line","auto");u==="auto"&&O.line===-1&&(u=-1),i.line=u,i.lineAlign=t.get("lineAlign","start"),i.snapToLines=t.get("snapToLines",!0),i.size=t.get("size",100),i.align=t.get("align",_);var c=t.get("position","auto");c==="auto"&&O.position===50&&(c=i.align==="start"||i.align==="left"?0:i.align==="end"||i.align==="right"?100:50),i.position=c}function f(){x=x.replace(/^\s+/,"")}if(f(),g.startTime=e(),f(),x.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+s);x=x.slice(3),f(),g.endTime=e(),f(),o(x,g)}function A(x){return x.replace(/<br(?: \/)?>/gi,`
|
|
21
|
-
`)}var D=function(){function x(){this.state="INITIAL",this.buffer="",this.decoder=new
|
|
17
|
+
timeOffset: `+O+`
|
|
18
|
+
initSegmentChange: `+Y);var H=new I.TransmuxConfig(f,a,o,u,h);this.configureTransmuxer(H)}if(this.frag=i,this.part=t,L)L.postMessage({cmd:"demux",data:e,decryptdata:M,chunkMeta:r,state:K},e instanceof ArrayBuffer?[e]:[]);else if(p){var z=p.push(e,M,r,K);Object(I.isPromise)(z)?z.then(function($){v.handleTransmuxComplete($)}):this.handleTransmuxComplete(z)}},y.flush=function(e){var o=this;e.transmuxing.start=self.performance.now();var f=this.transmuxer,a=this.worker;if(a)a.postMessage({cmd:"flush",chunkMeta:e});else if(f){var i=f.flush(e);Object(I.isPromise)(i)?i.then(function(t){o.handleFlushResult(t,e)}):this.handleFlushResult(i,e)}},y.handleFlushResult=function(e,o){var f=this;e.forEach(function(a){f.handleTransmuxComplete(a)}),this.onFlush(o)},y.onWorkerMessage=function(e){var o=e.data,f=this.hls;switch(o.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(o.data);break}case"flush":{this.onFlush(o.data);break}case"workerLog":T.logger[o.data.logType]&&T.logger[o.data.logType](o.data.message);break;default:{o.data=o.data||{},o.data.frag=this.frag,o.data.id=this.id,f.trigger(o.event,o.data);break}}},y.configureTransmuxer=function(e){var o=this.worker,f=this.transmuxer;o?o.postMessage({cmd:"configure",config:e}):f&&f.configure(e)},y.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},g}()},"./src/demux/transmuxer-worker.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return b});var R=n("./src/demux/transmuxer.ts"),m=n("./src/events.ts"),S=n("./src/utils/logger.ts"),I=n("./node_modules/eventemitter3/index.js"),T=n.n(I);function b(x){var g=new I.EventEmitter,y=function(o,f){x.postMessage({event:o,data:f})};g.on(m.Events.FRAG_DECRYPTED,y),g.on(m.Events.ERROR,y);var s=function(){var o=function(i){var t=function(c){y("workerLog",{logType:i,message:c})};S.logger[i]=t};for(var f in S.logger)o(f)};x.addEventListener("message",function(e){var o=e.data;switch(o.cmd){case"init":{var f=JSON.parse(o.config);x.transmuxer=new R.default(g,o.typeSupported,f,o.vendor,o.id),Object(S.enableLogs)(f.debug),s(),y("init",null);break}case"configure":{x.transmuxer.configure(o.config);break}case"demux":{var a=x.transmuxer.push(o.data,o.decryptdata,o.chunkMeta,o.state);Object(R.isPromise)(a)?a.then(function(u){_(x,u)}):_(x,a);break}case"flush":{var i=o.chunkMeta,t=x.transmuxer.flush(i);Object(R.isPromise)(t)?t.then(function(u){A(x,u,i)}):A(x,t,i);break}default:break}})}function _(x,g){if(D(g.remuxResult))return!1;var y=[],s=g.remuxResult,e=s.audio,o=s.video;return e&&E(y,e),o&&E(y,o),x.postMessage({event:"transmuxComplete",data:g},y),!0}function E(x,g){g.data1&&x.push(g.data1.buffer),g.data2&&x.push(g.data2.buffer)}function A(x,g,y){var s=g.reduce(function(e,o){return _(x,o)||e},!1);s||x.postMessage({event:"transmuxComplete",data:g[0]}),x.postMessage({event:"flush",data:y})}function D(x){return!x.audio&&!x.video&&!x.text&&!x.id3&&!x.initSegment}},"./src/demux/transmuxer.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return y}),n.d(P,"isPromise",function(){return o}),n.d(P,"TransmuxConfig",function(){return f}),n.d(P,"TransmuxState",function(){return a});var R=n("./src/events.ts"),m=n("./src/errors.ts"),S=n("./src/crypt/decrypter.ts"),I=n("./src/demux/aacdemuxer.ts"),T=n("./src/demux/mp4demuxer.ts"),b=n("./src/demux/tsdemuxer.ts"),_=n("./src/demux/mp3demuxer.ts"),E=n("./src/remux/mp4-remuxer.ts"),A=n("./src/remux/passthrough-remuxer.ts"),D=n("./src/utils/logger.ts"),x;try{x=self.performance.now.bind(self.performance)}catch{D.logger.debug("Unable to use Performance API on this environment"),x=self.Date.now}var g=[{demux:b.default,remux:E.default},{demux:T.default,remux:A.default},{demux:I.default,remux:E.default},{demux:_.default,remux:E.default}],y=function(){function i(u,c,r,h,d){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=u,this.typeSupported=c,this.config=r,this.vendor=h,this.id=d}var t=i.prototype;return t.configure=function(c){this.transmuxConfig=c,this.decrypter&&this.decrypter.reset()},t.push=function(c,r,h,d){var l=this,v=h.transmuxing;v.executeStart=x();var p=new Uint8Array(c),L=this.config,O=this.currentTransmuxState,M=this.transmuxConfig;d&&(this.currentTransmuxState=d);var F=d||O,w=F.contiguous,C=F.discontinuity,k=F.trackSwitch,U=F.accurateTimeOffset,j=F.timeOffset,N=F.initSegmentChange,W=M.audioCodec,Y=M.videoCodec,K=M.defaultInitPts,H=M.duration,z=M.initSegmentData;(C||k||N)&&this.resetInitSegment(z,W,Y,H),(C||N)&&this.resetInitialTimestamp(K),w||this.resetContiguity();var $=s(p,r);if($&&$.method==="AES-128"){var X=this.getDecrypter();if(L.enableSoftwareAES){var J=X.softwareDecrypt(p,$.key.buffer,$.iv.buffer);if(!J)return v.executeEnd=x(),e(h);p=new Uint8Array(J)}else return this.decryptionPromise=X.webCryptoDecrypt(p,$.key.buffer,$.iv.buffer).then(function(ae){var se=l.push(ae,null,h);return l.decryptionPromise=null,se}),this.decryptionPromise}this.needsProbing(p,C,k)&&this.configureTransmuxer(p,M);var te=this.transmux(p,$,j,U,h),Q=this.currentTransmuxState;return Q.contiguous=!0,Q.discontinuity=!1,Q.trackSwitch=!1,v.executeEnd=x(),te},t.flush=function(c){var r=this,h=c.transmuxing;h.executeStart=x();var d=this.decrypter,l=this.currentTransmuxState,v=this.decryptionPromise;if(v)return v.then(function(){return r.flush(c)});var p=[],L=l.timeOffset;if(d){var O=d.flush();O&&p.push(this.push(O,null,c))}var M=this.demuxer,F=this.remuxer;if(!M||!F)return this.observer.emit(R.Events.ERROR,R.Events.ERROR,{type:m.ErrorTypes.MEDIA_ERROR,details:m.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),h.executeEnd=x(),[e(c)];var w=M.flush(L);return o(w)?w.then(function(C){return r.flushRemux(p,C,c),p}):(this.flushRemux(p,w,c),p)},t.flushRemux=function(c,r,h){var d=r.audioTrack,l=r.videoTrack,v=r.id3Track,p=r.textTrack,L=this.currentTransmuxState,O=L.accurateTimeOffset,M=L.timeOffset;D.logger.log("[transmuxer.ts]: Flushed fragment "+h.sn+(h.part>-1?" p: "+h.part:"")+" of level "+h.level);var F=this.remuxer.remux(d,l,v,p,M,O,!0,this.id);c.push({remuxResult:F,chunkMeta:h}),h.transmuxing.executeEnd=x()},t.resetInitialTimestamp=function(c){var r=this.demuxer,h=this.remuxer;!r||!h||(r.resetTimeStamp(c),h.resetTimeStamp(c))},t.resetContiguity=function(){var c=this.demuxer,r=this.remuxer;!c||!r||(c.resetContiguity(),r.resetNextTimestamp())},t.resetInitSegment=function(c,r,h,d){var l=this.demuxer,v=this.remuxer;!l||!v||(l.resetInitSegment(c,r,h,d),v.resetInitSegment(c,r,h))},t.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},t.transmux=function(c,r,h,d,l){var v;return r&&r.method==="SAMPLE-AES"?v=this.transmuxSampleAes(c,r,h,d,l):v=this.transmuxUnencrypted(c,h,d,l),v},t.transmuxUnencrypted=function(c,r,h,d){var l=this.demuxer.demux(c,r,!1,!this.config.progressive),v=l.audioTrack,p=l.videoTrack,L=l.id3Track,O=l.textTrack,M=this.remuxer.remux(v,p,L,O,r,h,!1,this.id);return{remuxResult:M,chunkMeta:d}},t.transmuxSampleAes=function(c,r,h,d,l){var v=this;return this.demuxer.demuxSampleAes(c,r,h).then(function(p){var L=v.remuxer.remux(p.audioTrack,p.videoTrack,p.id3Track,p.textTrack,h,d,!1,v.id);return{remuxResult:L,chunkMeta:l}})},t.configureTransmuxer=function(c,r){for(var h=this.config,d=this.observer,l=this.typeSupported,v=this.vendor,p=r.audioCodec,L=r.defaultInitPts,O=r.duration,M=r.initSegmentData,F=r.videoCodec,w,C=0,k=g.length;C<k;C++)if(g[C].demux.probe(c)){w=g[C];break}w||(D.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),w={demux:T.default,remux:A.default});var U=this.demuxer,j=this.remuxer,N=w.remux,W=w.demux;(!j||!(j instanceof N))&&(this.remuxer=new N(d,h,l,v)),(!U||!(U instanceof W))&&(this.demuxer=new W(d,h,l),this.probe=W.probe),this.resetInitSegment(M,p,F,O),this.resetInitialTimestamp(L)},t.needsProbing=function(c,r,h){return!this.demuxer||!this.remuxer||r||h},t.getDecrypter=function(){var c=this.decrypter;return c||(c=this.decrypter=new S.default(this.observer,this.config)),c},i}();function s(i,t){var u=null;return i.byteLength>0&&t!=null&&t.key!=null&&t.iv!==null&&t.method!=null&&(u=t),u}var e=function(t){return{remuxResult:{},chunkMeta:t}};function o(i){return"then"in i&&i.then instanceof Function}var f=function(t,u,c,r,h){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=u,this.initSegmentData=c,this.duration=r,this.defaultInitPts=h},a=function(t,u,c,r,h,d){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=u,this.accurateTimeOffset=c,this.trackSwitch=r,this.timeOffset=h,this.initSegmentChange=d}},"./src/demux/tsdemuxer.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"discardEPB",function(){return f});var R=n("./src/demux/adts.ts"),m=n("./src/demux/mpegaudio.ts"),S=n("./src/demux/exp-golomb.ts"),I=n("./src/demux/sample-aes.ts"),T=n("./src/events.ts"),b=n("./src/utils/mp4-tools.ts"),_=n("./src/utils/logger.ts"),E=n("./src/errors.ts"),A=n("./src/types/demuxer.ts");function D(){return D=Object.assign?Object.assign.bind():function(a){for(var i=1;i<arguments.length;i++){var t=arguments[i];for(var u in t)Object.prototype.hasOwnProperty.call(t,u)&&(a[u]=t[u])}return a},D.apply(this,arguments)}var x=function(){function a(t,u,c){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=u,this.typeSupported=c}a.probe=function(u){return u[0]===71&&u[188]===71},a.createTrack=function(u,c){return{container:u==="video"||u==="audio"?"video/mp2t":void 0,type:u,id:b.RemuxerTrackIdConfig[u],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:u==="audio"?c:void 0}};var i=a.prototype;return i.resetInitSegment=function(u,c,r,h){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=a.createTrack("video"),this._audioTrack=a.createTrack("audio",h),this._id3Track=a.createTrack("id3"),this._txtTrack=a.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=c,this.videoCodec=r,this._duration=h},i.resetTimeStamp=function(){},i.resetContiguity=function(){var u=this._audioTrack,c=this._avcTrack,r=this._id3Track;u&&(u.pesData=null),c&&(c.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null},i.demux=function(u,c,r,h){r===void 0&&(r=!1),h===void 0&&(h=!1),r||(this.sampleAes=null);var d,l=this._avcTrack,v=this._audioTrack,p=this._id3Track,L=this._txtTrack,O=l.pid,M=l.pesData,F=v.pid,w=p.pid,C=v.pesData,k=p.pesData,U=null,j=this.pmtParsed,N=this._pmtId,W=u.length;if(this.remainderData&&(u=Object(b.appendUint8Array)(this.remainderData,u),W=u.length,this.remainderData=null),W<188&&!h)return this.remainderData=u,{audioTrack:v,videoTrack:l,id3Track:p,textTrack:L};W-=W%188,W<u.byteLength&&!h&&(this.remainderData=new Uint8Array(u.buffer,W,u.buffer.byteLength-W));for(var Y=0,K=0;K<W;K+=188)if(u[K]===71){var H=!!(u[K+1]&64),z=((u[K+1]&31)<<8)+u[K+2],$=(u[K+3]&48)>>4,X=void 0;if($>1){if(X=K+5+u[K+4],X===K+188)continue}else X=K+4;switch(z){case O:H&&(M&&(d=e(M))&&this.parseAVCPES(l,L,d,!1),M={data:[],size:0}),M&&(M.data.push(u.subarray(X,K+188)),M.size+=K+188-X);break;case F:if(H){if(C&&(d=e(C)))switch(v.segmentCodec){case"aac":this.parseAACPES(v,d);break;case"mp3":this.parseMPEGPES(v,d);break}C={data:[],size:0}}C&&(C.data.push(u.subarray(X,K+188)),C.size+=K+188-X);break;case w:H&&(k&&(d=e(k))&&this.parseID3PES(p,d),k={data:[],size:0}),k&&(k.data.push(u.subarray(X,K+188)),k.size+=K+188-X);break;case 0:H&&(X+=u[X]+1),N=this._pmtId=y(u,X);break;case N:{H&&(X+=u[X]+1);var J=s(u,X,this.typeSupported,r);O=J.avc,O>0&&(l.pid=O),F=J.audio,F>0&&(v.pid=F,v.segmentCodec=J.segmentCodec),w=J.id3,w>0&&(p.pid=w),U!==null&&!j&&(_.logger.log("unknown PID '"+U+"' in TS found"),U=null),j=this.pmtParsed=!0;break}case 17:case 8191:break;default:U=z;break}}else Y++;Y>0&&this.observer.emit(T.Events.ERROR,T.Events.ERROR,{type:E.ErrorTypes.MEDIA_ERROR,details:E.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+Y+" TS packet/s that do not start with 0x47"}),l.pesData=M,v.pesData=C,p.pesData=k;var te={audioTrack:v,videoTrack:l,id3Track:p,textTrack:L};return h&&this.extractRemainingSamples(te),te},i.flush=function(){var u=this.remainderData;this.remainderData=null;var c;return u?c=this.demux(u,-1,!1,!0):c={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(c),this.sampleAes?this.decrypt(c,this.sampleAes):c},i.extractRemainingSamples=function(u){var c=u.audioTrack,r=u.videoTrack,h=u.id3Track,d=u.textTrack,l=r.pesData,v=c.pesData,p=h.pesData,L;if(l&&(L=e(l))?(this.parseAVCPES(r,d,L,!0),r.pesData=null):r.pesData=l,v&&(L=e(v))){switch(c.segmentCodec){case"aac":this.parseAACPES(c,L);break;case"mp3":this.parseMPEGPES(c,L);break}c.pesData=null}else v!=null&&v.size&&_.logger.log("last AAC PES packet truncated,might overlap between fragments"),c.pesData=v;p&&(L=e(p))?(this.parseID3PES(h,L),h.pesData=null):h.pesData=p},i.demuxSampleAes=function(u,c,r){var h=this.demux(u,r,!0,!this.config.progressive),d=this.sampleAes=new I.default(this.observer,this.config,c);return this.decrypt(h,d)},i.decrypt=function(u,c){return new Promise(function(r){var h=u.audioTrack,d=u.videoTrack;h.samples&&h.segmentCodec==="aac"?c.decryptAacSamples(h.samples,0,function(){d.samples?c.decryptAvcSamples(d.samples,0,0,function(){r(u)}):r(u)}):d.samples&&c.decryptAvcSamples(d.samples,0,0,function(){r(u)})})},i.destroy=function(){this._duration=0},i.parseAVCPES=function(u,c,r,h){var d=this,l=this.parseAVCNALu(u,r.data),v=!1,p=this.avcSample,L,O=!1;r.data=null,p&&l.length&&!u.audFound&&(o(p,u),p=this.avcSample=g(!1,r.pts,r.dts,"")),l.forEach(function(M){switch(M.type){case 1:{L=!0,p||(p=d.avcSample=g(!0,r.pts,r.dts,"")),v&&(p.debug+="NDR "),p.frame=!0;var F=M.data;if(O&&F.length>4){var w=new S.default(F).readSliceType();(w===2||w===4||w===7||w===9)&&(p.key=!0)}break}case 5:L=!0,p||(p=d.avcSample=g(!0,r.pts,r.dts,"")),v&&(p.debug+="IDR "),p.key=!0,p.frame=!0;break;case 6:{L=!0,v&&p&&(p.debug+="SEI "),Object(b.parseSEIMessageFromNALu)(f(M.data),r.pts,c.samples);break}case 7:if(L=!0,O=!0,v&&p&&(p.debug+="SPS "),!u.sps){var C=new S.default(M.data),k=C.readSPS();u.width=k.width,u.height=k.height,u.pixelRatio=k.pixelRatio,u.sps=[M.data],u.duration=d._duration;for(var U=M.data.subarray(1,4),j="avc1.",N=0;N<3;N++){var W=U[N].toString(16);W.length<2&&(W="0"+W),j+=W}u.codec=j}break;case 8:L=!0,v&&p&&(p.debug+="PPS "),u.pps||(u.pps=[M.data]);break;case 9:L=!1,u.audFound=!0,p&&o(p,u),p=d.avcSample=g(!1,r.pts,r.dts,v?"AUD ":"");break;case 12:L=!0;break;default:L=!1,p&&(p.debug+="unknown NAL "+M.type+" ");break}if(p&&L){var Y=p.units;Y.push(M)}}),h&&p&&(o(p,u),this.avcSample=null)},i.getLastNalUnit=function(u){var c,r=this.avcSample,h;if((!r||r.units.length===0)&&(r=u[u.length-1]),(c=r)!==null&&c!==void 0&&c.units){var d=r.units;h=d[d.length-1]}return h},i.parseAVCNALu=function(u,c){var r=c.byteLength,h=u.naluState||0,d=h,l=[],v=0,p,L,O,M=-1,F=0;for(h===-1&&(M=0,F=c[0]&31,h=0,v=1);v<r;){if(p=c[v++],!h){h=p?0:1;continue}if(h===1){h=p?0:2;continue}if(!p)h=3;else if(p===1){if(M>=0){var w={data:c.subarray(M,v-h-1),type:F};l.push(w)}else{var C=this.getLastNalUnit(u.samples);if(C&&(d&&v<=4-d&&C.state&&(C.data=C.data.subarray(0,C.data.byteLength-d)),L=v-h-1,L>0)){var k=new Uint8Array(C.data.byteLength+L);k.set(C.data,0),k.set(c.subarray(0,L),C.data.byteLength),C.data=k,C.state=0}}v<r?(O=c[v]&31,M=v,F=O,h=0):h=-1}else h=0}if(M>=0&&h>=0){var U={data:c.subarray(M,r),type:F,state:h};l.push(U)}if(l.length===0){var j=this.getLastNalUnit(u.samples);if(j){var N=new Uint8Array(j.data.byteLength+c.byteLength);N.set(j.data,0),N.set(c,j.data.byteLength),j.data=N}}return u.naluState=h,l},i.parseAACPES=function(u,c){var r=0,h=this.aacOverFlow,d=c.data;if(h){this.aacOverFlow=null;var l=h.missing,v=h.sample.unit.byteLength;if(l===-1){var p=new Uint8Array(v+d.byteLength);p.set(h.sample.unit,0),p.set(d,v),d=p}else{var L=v-l;h.sample.unit.set(d.subarray(0,l),L),u.samples.push(h.sample),r=h.missing}}var O,M;for(O=r,M=d.length;O<M-1&&!R.isHeader(d,O);O++);if(O!==r){var F,w;if(O<M-1?(F="AAC PES did not start with ADTS header,offset:"+O,w=!1):(F="no ADTS header found in AAC PES",w=!0),_.logger.warn("parsing error:"+F),this.observer.emit(T.Events.ERROR,T.Events.ERROR,{type:E.ErrorTypes.MEDIA_ERROR,details:E.ErrorDetails.FRAG_PARSING_ERROR,fatal:w,reason:F}),w)return}R.initTrackConfig(u,this.observer,d,O,this.audioCodec);var C;if(c.pts!==void 0)C=c.pts;else if(h){var k=R.getFrameDuration(u.samplerate);C=h.sample.pts+k}else{_.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var U=0,j;O<M;)if(j=R.appendFrame(u,d,O,C,U),O+=j.length,j.missing){this.aacOverFlow=j;break}else for(U++;O<M-1&&!R.isHeader(d,O);O++);},i.parseMPEGPES=function(u,c){var r=c.data,h=r.length,d=0,l=0,v=c.pts;if(v===void 0){_.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;l<h;)if(m.isHeader(r,l)){var p=m.appendFrame(u,r,l,v,d);if(p)l+=p.length,d++;else break}else l++},i.parseID3PES=function(u,c){if(c.pts===void 0){_.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var r=D({},c,{type:this._avcTrack?A.MetadataSchema.emsg:A.MetadataSchema.audioId3});u.samples.push(r)},a}();function g(a,i,t,u){return{key:a,frame:!1,pts:i,dts:t,units:[],debug:u,length:0}}function y(a,i){return(a[i+10]&31)<<8|a[i+11]}function s(a,i,t,u){var c={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},r=(a[i+1]&15)<<8|a[i+2],h=i+3+r-4,d=(a[i+10]&15)<<8|a[i+11];for(i+=12+d;i<h;){var l=(a[i+1]&31)<<8|a[i+2];switch(a[i]){case 207:if(!u){_.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:c.audio===-1&&(c.audio=l);break;case 21:c.id3===-1&&(c.id3=l);break;case 219:if(!u){_.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:c.avc===-1&&(c.avc=l);break;case 3:case 4:t.mpeg!==!0&&t.mp3!==!0?_.logger.log("MPEG audio found, not supported in this browser"):c.audio===-1&&(c.audio=l,c.segmentCodec="mp3");break;case 36:_.logger.warn("Unsupported HEVC stream type found");break;default:break}i+=((a[i+3]&15)<<8|a[i+4])+5}return c}function e(a){var i=0,t,u,c,r,h,d=a.data;if(!a||a.size===0)return null;for(;d[0].length<19&&d.length>1;){var l=new Uint8Array(d[0].length+d[1].length);l.set(d[0]),l.set(d[1],d[0].length),d[0]=l,d.splice(1,1)}t=d[0];var v=(t[0]<<16)+(t[1]<<8)+t[2];if(v===1){if(u=(t[4]<<8)+t[5],u&&u>a.size-6)return null;var p=t[7];p&192&&(r=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,p&64?(h=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,r-h>60*9e4&&(_.logger.warn(Math.round((r-h)/9e4)+"s delta between PTS and DTS, align them"),r=h)):h=r),c=t[8];var L=c+9;if(a.size<=L)return null;a.size-=L;for(var O=new Uint8Array(a.size),M=0,F=d.length;M<F;M++){t=d[M];var w=t.byteLength;if(L)if(L>w){L-=w;continue}else t=t.subarray(L),w-=L,L=0;O.set(t,i),i+=w}return u&&(u-=c+3),{data:O,pts:r,dts:h,len:u}}return null}function o(a,i){if(a.units.length&&a.frame){if(a.pts===void 0){var t=i.samples,u=t.length;if(u){var c=t[u-1];a.pts=c.pts,a.dts=c.dts}else{i.dropped++;return}}i.samples.push(a)}a.debug.length&&_.logger.log(a.pts+"/"+a.dts+":"+a.debug)}function f(a){for(var i=a.byteLength,t=[],u=1;u<i-2;)a[u]===0&&a[u+1]===0&&a[u+2]===3?(t.push(u+2),u+=2):u++;if(t.length===0)return a;var c=i-t.length,r=new Uint8Array(c),h=0;for(u=0;u<c;h++,u++)h===t[0]&&(h++,t.shift()),r[u]=a[h];return r}P.default=x},"./src/errors.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"ErrorTypes",function(){return R}),n.d(P,"ErrorDetails",function(){return m});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 m;(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"})(m||(m={}))},"./src/events.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"Events",function(){return R});var R;(function(m){m.MEDIA_ATTACHING="hlsMediaAttaching",m.MEDIA_ATTACHED="hlsMediaAttached",m.MEDIA_DETACHING="hlsMediaDetaching",m.MEDIA_DETACHED="hlsMediaDetached",m.BUFFER_RESET="hlsBufferReset",m.BUFFER_CODECS="hlsBufferCodecs",m.BUFFER_CREATED="hlsBufferCreated",m.BUFFER_APPENDING="hlsBufferAppending",m.BUFFER_APPENDED="hlsBufferAppended",m.BUFFER_EOS="hlsBufferEos",m.BUFFER_FLUSHING="hlsBufferFlushing",m.BUFFER_FLUSHED="hlsBufferFlushed",m.MANIFEST_LOADING="hlsManifestLoading",m.MANIFEST_LOADED="hlsManifestLoaded",m.MANIFEST_PARSED="hlsManifestParsed",m.LEVEL_SWITCHING="hlsLevelSwitching",m.LEVEL_SWITCHED="hlsLevelSwitched",m.LEVEL_LOADING="hlsLevelLoading",m.LEVEL_LOADED="hlsLevelLoaded",m.LEVEL_UPDATED="hlsLevelUpdated",m.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",m.LEVELS_UPDATED="hlsLevelsUpdated",m.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",m.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",m.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",m.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",m.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",m.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",m.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",m.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",m.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",m.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",m.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",m.CUES_PARSED="hlsCuesParsed",m.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",m.INIT_PTS_FOUND="hlsInitPtsFound",m.FRAG_LOADING="hlsFragLoading",m.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",m.FRAG_LOADED="hlsFragLoaded",m.FRAG_DECRYPTED="hlsFragDecrypted",m.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",m.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",m.FRAG_PARSING_METADATA="hlsFragParsingMetadata",m.FRAG_PARSED="hlsFragParsed",m.FRAG_BUFFERED="hlsFragBuffered",m.FRAG_CHANGED="hlsFragChanged",m.FPS_DROP="hlsFpsDrop",m.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",m.ERROR="hlsError",m.DESTROYING="hlsDestroying",m.KEY_LOADING="hlsKeyLoading",m.KEY_LOADED="hlsKeyLoaded",m.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",m.BACK_BUFFER_REACHED="hlsBackBufferReached"})(R||(R={}))},"./src/hls.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return i});var R=n("./node_modules/url-toolkit/src/url-toolkit.js"),m=n.n(R),S=n("./src/loader/playlist-loader.ts"),I=n("./src/loader/key-loader.ts"),T=n("./src/controller/id3-track-controller.ts"),b=n("./src/controller/latency-controller.ts"),_=n("./src/controller/level-controller.ts"),E=n("./src/controller/fragment-tracker.ts"),A=n("./src/controller/stream-controller.ts"),D=n("./src/is-supported.ts"),x=n("./src/utils/logger.ts"),g=n("./src/config.ts"),y=n("./node_modules/eventemitter3/index.js"),s=n.n(y),e=n("./src/events.ts"),o=n("./src/errors.ts");function f(t,u){for(var c=0;c<u.length;c++){var r=u[c];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function a(t,u,c){return u&&f(t.prototype,u),c&&f(t,c),Object.defineProperty(t,"prototype",{writable:!1}),t}var i=function(){t.isSupported=function(){return Object(D.isSupported)()};function t(c){c===void 0&&(c={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new y.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,c);this.userConfig=c,Object(x.enableLogs)(r.debug),this._autoLevelCapping=-1,r.progressive&&Object(g.enableStreamingMode)(r);var h=r.abrController,d=r.bufferController,l=r.capLevelController,v=r.fpsController,p=this.abrController=new h(this),L=this.bufferController=new d(this),O=this.capLevelController=new l(this),M=new v(this),F=new S.default(this),w=new I.default(this),C=new T.default(this),k=this.levelController=new _.default(this),U=new E.FragmentTracker(this),j=this.streamController=new A.default(this,U);O.setStreamController(j),M.setStreamController(j);var N=[F,w,k,j];this.networkControllers=N;var W=[p,L,O,M,C,U];this.audioTrackController=this.createController(r.audioTrackController,null,N),this.createController(r.audioStreamController,U,N),this.subtitleTrackController=this.createController(r.subtitleTrackController,null,N),this.createController(r.subtitleStreamController,U,N),this.createController(r.timelineController,null,W),this.emeController=this.createController(r.emeController,null,W),this.cmcdController=this.createController(r.cmcdController,null,W),this.latencyController=this.createController(b.default,null,W),this.coreComponents=W}var u=t.prototype;return u.createController=function(r,h,d){if(r){var l=h?new r(this,h):new r(this);return d&&d.push(l),l}return null},u.on=function(r,h,d){d===void 0&&(d=this),this._emitter.on(r,h,d)},u.once=function(r,h,d){d===void 0&&(d=this),this._emitter.once(r,h,d)},u.removeAllListeners=function(r){this._emitter.removeAllListeners(r)},u.off=function(r,h,d,l){d===void 0&&(d=this),this._emitter.off(r,h,d,l)},u.listeners=function(r){return this._emitter.listeners(r)},u.emit=function(r,h,d){return this._emitter.emit(r,h,d)},u.trigger=function(r,h){if(this.config.debug)return this.emit(r,r,h);try{return this.emit(r,r,h)}catch(d){x.logger.error("An internal error happened while handling event "+r+'. Error message: "'+d.message+'". Here is a stacktrace:',d),this.trigger(e.Events.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:r,error:d})}return!1},u.listenerCount=function(r){return this._emitter.listenerCount(r)},u.destroy=function(){x.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},u.attachMedia=function(r){x.logger.log("attachMedia"),this._media=r,this.trigger(e.Events.MEDIA_ATTACHING,{media:r})},u.detachMedia=function(){x.logger.log("detachMedia"),this.trigger(e.Events.MEDIA_DETACHING,void 0),this._media=null},u.loadSource=function(r){this.stopLoad();var h=this.media,d=this.url,l=this.url=R.buildAbsoluteURL(self.location.href,r,{alwaysNormalize:!0});x.logger.log("loadSource:"+l),h&&d&&d!==l&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(h)),this.trigger(e.Events.MANIFEST_LOADING,{url:r})},u.startLoad=function(r){r===void 0&&(r=-1),x.logger.log("startLoad("+r+")"),this.networkControllers.forEach(function(h){h.startLoad(r)})},u.stopLoad=function(){x.logger.log("stopLoad"),this.networkControllers.forEach(function(r){r.stopLoad()})},u.swapAudioCodec=function(){x.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},u.recoverMediaError=function(){x.logger.log("recoverMediaError");var r=this._media;this.detachMedia(),r&&this.attachMedia(r)},u.removeLevel=function(r,h){h===void 0&&(h=0),this.levelController.removeLevel(r,h)},a(t,[{key:"levels",get:function(){var r=this.levelController.levels;return r||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(r){x.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){x.logger.log("set nextLevel:"+r),this.levelController.manualLevel=r,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(r){x.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){x.logger.log("set firstLevel:"+r),this.levelController.firstLevel=r}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(r){x.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 h=!!r;h!==this.config.capLevelToPlayerSize&&(h?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=h)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(r){this._autoLevelCapping!==r&&(x.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,h=this.config.minAutoBitrate;if(!r)return 0;for(var d=r.length,l=0;l<d;l++)if(r[l].maxBitrate>=h)return l;return 0}},{key:"maxAutoLevel",get:function(){var r=this.levels,h=this.autoLevelCapping,d;return h===-1&&r&&r.length?d=r.length-1:d=h,d}},{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 h=this.audioTrackController;h&&(h.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 h=this.subtitleTrackController;h&&(h.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 h=this.subtitleTrackController;h&&(h.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 o.ErrorTypes}},{key:"ErrorDetails",get:function(){return o.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(B,P,n){"use strict";n.r(P),n.d(P,"isSupported",function(){return S}),n.d(P,"changeTypeSupported",function(){return I});var R=n("./src/utils/mediasource-helper.ts");function m(){return self.SourceBuffer||self.WebKitSourceBuffer}function S(){var T=Object(R.getMediaSource)();if(!T)return!1;var b=m(),_=T&&typeof T.isTypeSupported=="function"&&T.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),E=!b||b.prototype&&typeof b.prototype.appendBuffer=="function"&&typeof b.prototype.remove=="function";return!!_&&!!E}function I(){var T,b=m();return typeof(b==null||(T=b.prototype)===null||T===void 0?void 0:T.changeType)=="function"}},"./src/loader/date-range.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"DateRangeAttribute",function(){return _}),n.d(P,"DateRange",function(){return E});var R=n("./src/polyfills/number.ts"),m=n("./src/utils/attr-list.ts"),S=n("./src/utils/logger.ts");function I(){return I=Object.assign?Object.assign.bind():function(A){for(var D=1;D<arguments.length;D++){var x=arguments[D];for(var g in x)Object.prototype.hasOwnProperty.call(x,g)&&(A[g]=x[g])}return A},I.apply(this,arguments)}function T(A,D){for(var x=0;x<D.length;x++){var g=D[x];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(A,g.key,g)}}function b(A,D,x){return D&&T(A.prototype,D),x&&T(A,x),Object.defineProperty(A,"prototype",{writable:!1}),A}var _;(function(A){A.ID="ID",A.CLASS="CLASS",A.START_DATE="START-DATE",A.DURATION="DURATION",A.END_DATE="END-DATE",A.END_ON_NEXT="END-ON-NEXT",A.PLANNED_DURATION="PLANNED-DURATION",A.SCTE35_OUT="SCTE35-OUT",A.SCTE35_IN="SCTE35-IN"})(_||(_={}));var E=function(){function A(D,x){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,x){var g=x.attr;for(var y in g)if(Object.prototype.hasOwnProperty.call(D,y)&&D[y]!==g[y]){S.logger.warn('DATERANGE tag attribute: "'+y+'" does not match for tags with ID: "'+D.ID+'"'),this._badValueForSameId=y;break}D=I(new m.AttrList({}),g,D)}if(this.attr=D,this._startDate=new Date(D[_.START_DATE]),_.END_DATE in this.attr){var s=new Date(this.attr[_.END_DATE]);Object(R.isFiniteNumber)(s.getTime())&&(this._endDate=s)}}return b(A,[{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 x=this.duration;return x!==null?new Date(this._startDate.getTime()+x*1e3):null}},{key:"duration",get:function(){if(_.DURATION in this.attr){var x=this.attr.decimalFloatingPoint(_.DURATION);if(Object(R.isFiniteNumber)(x))return x}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return _.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(_.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(_.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)}}]),A}()},"./src/loader/fragment-loader.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return x}),n.d(P,"LoadError",function(){return y});var R=n("./src/polyfills/number.ts"),m=n("./src/errors.ts");function S(s,e){s.prototype=Object.create(e.prototype),s.prototype.constructor=s,E(s,e)}function I(s){var e=typeof Map=="function"?new Map:void 0;return I=function(f){if(f===null||!_(f))return f;if(typeof f!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e!="undefined"){if(e.has(f))return e.get(f);e.set(f,a)}function a(){return T(f,arguments,A(this).constructor)}return a.prototype=Object.create(f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),E(a,f)},I(s)}function T(s,e,o){return b()?T=Reflect.construct.bind():T=function(a,i,t){var u=[null];u.push.apply(u,i);var c=Function.bind.apply(a,u),r=new c;return t&&E(r,t.prototype),r},T.apply(null,arguments)}function b(){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 E(s,e){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(f,a){return f.__proto__=a,f},E(s,e)}function A(s){return A=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},A(s)}var D=Math.pow(2,17),x=function(){function s(o){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=o}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(f,a){var i=this,t=f.url;if(!t)return Promise.reject(new y({type:m.ErrorTypes.NETWORK_ERROR,details:m.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:f,networkDetails:null},"Fragment does not have a "+(t?"part list":"url")));this.abort();var u=this.config,c=u.fLoader,r=u.loader;return new Promise(function(h,d){i.loader&&i.loader.destroy();var l=i.loader=f.loader=c?new c(u):new r(u),v=g(f),p={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:f.sn==="initSegment"?1/0:D};f.stats=l.stats,l.load(v,p,{onSuccess:function(O,M,F,w){i.resetLoader(f,l),h({frag:f,part:null,payload:O.data,networkDetails:w})},onError:function(O,M,F){i.resetLoader(f,l),d(new y({type:m.ErrorTypes.NETWORK_ERROR,details:m.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:f,response:O,networkDetails:F}))},onAbort:function(O,M,F){i.resetLoader(f,l),d(new y({type:m.ErrorTypes.NETWORK_ERROR,details:m.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:f,networkDetails:F}))},onTimeout:function(O,M,F){i.resetLoader(f,l),d(new y({type:m.ErrorTypes.NETWORK_ERROR,details:m.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:f,networkDetails:F}))},onProgress:function(O,M,F,w){a&&a({frag:f,part:null,payload:F,networkDetails:w})}})})},e.loadPart=function(f,a,i){var t=this;this.abort();var u=this.config,c=u.fLoader,r=u.loader;return new Promise(function(h,d){t.loader&&t.loader.destroy();var l=t.loader=f.loader=c?new c(u):new r(u),v=g(f,a),p={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:D};a.stats=l.stats,l.load(v,p,{onSuccess:function(O,M,F,w){t.resetLoader(f,l),t.updateStatsFromPart(f,a);var C={frag:f,part:a,payload:O.data,networkDetails:w};i(C),h(C)},onError:function(O,M,F){t.resetLoader(f,l),d(new y({type:m.ErrorTypes.NETWORK_ERROR,details:m.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:f,part:a,response:O,networkDetails:F}))},onAbort:function(O,M,F){f.stats.aborted=a.stats.aborted,t.resetLoader(f,l),d(new y({type:m.ErrorTypes.NETWORK_ERROR,details:m.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:f,part:a,networkDetails:F}))},onTimeout:function(O,M,F){t.resetLoader(f,l),d(new y({type:m.ErrorTypes.NETWORK_ERROR,details:m.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:f,part:a,networkDetails:F}))}})})},e.updateStatsFromPart=function(f,a){var i=f.stats,t=a.stats,u=t.total;if(i.loaded+=t.loaded,u){var c=Math.round(f.duration/a.duration),r=Math.min(Math.round(i.loaded/u),c),h=c-r,d=h*Math.round(i.loaded/r);i.total=i.loaded+d}else i.total=Math.max(i.loaded,i.total);var l=i.loading,v=t.loading;l.start?l.first+=v.first-v.start:(l.start=v.start,l.first=v.first),l.end=v.end},e.resetLoader=function(f,a){f.loader=null,this.loader===a&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),a.destroy()},s}();function g(s,e){e===void 0&&(e=null);var o=e||s,f={frag:s,part:e,responseType:"arraybuffer",url:o.url,headers:{},rangeStart:0,rangeEnd:0},a=o.byteRangeStartOffset,i=o.byteRangeEndOffset;return Object(R.isFiniteNumber)(a)&&Object(R.isFiniteNumber)(i)&&(f.rangeStart=a,f.rangeEnd=i),f}var y=function(s){S(e,s);function e(o){for(var f,a=arguments.length,i=new Array(a>1?a-1:0),t=1;t<a;t++)i[t-1]=arguments[t];return f=s.call.apply(s,[this].concat(i))||this,f.data=void 0,f.data=o,f}return e}(I(Error))},"./src/loader/fragment.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"ElementaryStreamTypes",function(){return x}),n.d(P,"BaseSegment",function(){return g}),n.d(P,"Fragment",function(){return y}),n.d(P,"Part",function(){return s});var R=n("./src/polyfills/number.ts"),m=n("./node_modules/url-toolkit/src/url-toolkit.js"),S=n.n(m),I=n("./src/utils/logger.ts"),T=n("./src/loader/level-key.ts"),b=n("./src/loader/load-stats.ts");function _(e,o){e.prototype=Object.create(o.prototype),e.prototype.constructor=e,E(e,o)}function E(e,o){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,i){return a.__proto__=i,a},E(e,o)}function A(e,o){for(var f=0;f<o.length;f++){var a=o[f];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function D(e,o,f){return o&&A(e.prototype,o),f&&A(e,f),Object.defineProperty(e,"prototype",{writable:!1}),e}var x;(function(e){e.AUDIO="audio",e.VIDEO="video",e.AUDIOVIDEO="audiovideo"})(x||(x={}));var g=function(){function e(f){var a;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(a={},a[x.AUDIO]=null,a[x.VIDEO]=null,a[x.AUDIOVIDEO]=null,a),this.baseurl=f}var o=e.prototype;return o.setByteRange=function(a,i){var t=a.split("@",2),u=[];t.length===1?u[0]=i?i.byteRangeEndOffset:0:u[0]=parseInt(t[1]),u[1]=parseInt(t[0])+u[0],this._byteRange=u},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(m.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(a){this._url=a}}]),e}(),y=function(e){_(o,e);function o(a,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 b.LoadStats,t.urlId=0,t.data=void 0,t.bitrateTest=!1,t.title=null,t.initSegment=null,t.type=a,t}var f=o.prototype;return f.createInitializationVector=function(i){for(var t=new Uint8Array(16),u=12;u<16;u++)t[u]=i>>8*(15-u)&255;return t},f.setDecryptDataFromLevelKey=function(i,t){var u=i;return(i==null?void 0:i.method)==="AES-128"&&i.uri&&!i.iv&&(u=T.LevelKey.fromURI(i.uri),u.method=i.method,u.iv=this.createInitializationVector(t),u.keyFormat="identity"),u},f.setElementaryStreamInfo=function(i,t,u,c,r,h){h===void 0&&(h=!1);var d=this.elementaryStreams,l=d[i];if(!l){d[i]={startPTS:t,endPTS:u,startDTS:c,endDTS:r,partial:h};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,u),l.startDTS=Math.min(l.startDTS,c),l.endDTS=Math.max(l.endDTS,r)},f.clearElementaryStreamInfo=function(){var i=this.elementaryStreams;i[x.AUDIO]=null,i[x.VIDEO]=null,i[x.AUDIOVIDEO]=null},D(o,[{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)}}]),o}(g),s=function(e){_(o,e);function o(f,a,i,t,u){var c;c=e.call(this,i)||this,c.fragOffset=0,c.duration=0,c.gap=!1,c.independent=!1,c.relurl=void 0,c.fragment=void 0,c.index=void 0,c.stats=new b.LoadStats,c.duration=f.decimalFloatingPoint("DURATION"),c.gap=f.bool("GAP"),c.independent=f.bool("INDEPENDENT"),c.relurl=f.enumeratedString("URI"),c.fragment=a,c.index=t;var r=f.enumeratedString("BYTERANGE");return r&&c.setByteRange(r,u),u&&(c.fragOffset=u.fragOffset+u.duration),c}return D(o,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var a=this.elementaryStreams;return!!(a.audio||a.video||a.audiovideo)}}]),o}(g)},"./src/loader/key-loader.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return I});var R=n("./src/events.ts"),m=n("./src/errors.ts"),S=n("./src/utils/logger.ts"),I=function(){function T(_){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=_,this.registerListeners()}var b=T.prototype;return b.startLoad=function(E){},b.stopLoad=function(){this.destroyInternalLoaders()},b.registerListeners=function(){this.hls.on(R.Events.KEY_LOADING,this.onKeyLoading,this)},b.unregisterListeners=function(){this.hls.off(R.Events.KEY_LOADING,this.onKeyLoading)},b.destroyInternalLoaders=function(){for(var E in this.loaders){var A=this.loaders[E];A&&A.destroy()}this.loaders={}},b.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},b.onKeyLoading=function(E,A){var D=A.frag,x=D.type,g=this.loaders[x];if(!D.decryptdata){S.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var y=D.decryptdata.uri;if(y!==this.decrypturl||this.decryptkey===null){var s=this.hls.config;if(g&&(S.logger.warn("abort previous key loader for type:"+x),g.abort()),!y){S.logger.warn("key uri is falsy");return}var e=s.loader,o=D.loader=this.loaders[x]=new e(s);this.decrypturl=y,this.decryptkey=null;var f={url:y,frag:D,responseType:"arraybuffer"},a={timeout:s.fragLoadingTimeOut,maxRetry:0,retryDelay:s.fragLoadingRetryDelay,maxRetryDelay:s.fragLoadingMaxRetryTimeout,highWaterMark:0},i={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};o.load(f,a,i)}else this.decryptkey&&(D.decryptdata.key=this.decryptkey,this.hls.trigger(R.Events.KEY_LOADED,{frag:D}))},b.loadsuccess=function(E,A,D){var x=D.frag;if(!x.decryptdata){S.logger.error("after key load, decryptdata unset");return}this.decryptkey=x.decryptdata.key=new Uint8Array(E.data),x.loader=null,delete this.loaders[x.type],this.hls.trigger(R.Events.KEY_LOADED,{frag:x})},b.loaderror=function(E,A){var D=A.frag,x=D.loader;x&&x.abort(),delete this.loaders[D.type],this.hls.trigger(R.Events.ERROR,{type:m.ErrorTypes.NETWORK_ERROR,details:m.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:D,response:E})},b.loadtimeout=function(E,A){var D=A.frag,x=D.loader;x&&x.abort(),delete this.loaders[D.type],this.hls.trigger(R.Events.ERROR,{type:m.ErrorTypes.NETWORK_ERROR,details:m.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:D})},T}()},"./src/loader/level-details.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"LevelDetails",function(){return T});var R=n("./src/polyfills/number.ts");function m(b,_){for(var E=0;E<_.length;E++){var A=_[E];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(b,A.key,A)}}function S(b,_,E){return _&&m(b.prototype,_),E&&m(b,E),Object.defineProperty(b,"prototype",{writable:!1}),b}var I=10,T=function(){function b(E){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=E}var _=b.prototype;return _.reloaded=function(A){if(!A){this.advanced=!0,this.updated=!0;return}var D=this.lastPartSn-A.lastPartSn,x=this.lastPartIndex-A.lastPartIndex;this.updated=this.endSN!==A.endSN||!!x||!!D,this.advanced=this.endSN>A.endSN||D>0||D===0&&x>0,this.updated||this.advanced?this.misses=Math.floor(A.misses*.6):this.misses=A.misses+1,this.availabilityDelay=A.availabilityDelay},S(b,[{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 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}}]),b}()},"./src/loader/level-key.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"LevelKey",function(){return T});var R=n("./node_modules/url-toolkit/src/url-toolkit.js"),m=n.n(R);function S(b,_){for(var E=0;E<_.length;E++){var A=_[E];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(b,A.key,A)}}function I(b,_,E){return _&&S(b.prototype,_),E&&S(b,E),Object.defineProperty(b,"prototype",{writable:!1}),b}var T=function(){b.fromURL=function(E,A){return new b(E,A)},b.fromURI=function(E){return new b(E)};function b(_,E){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,E?this._uri=Object(R.buildAbsoluteURL)(_,E,{alwaysNormalize:!0}):this._uri=_}return I(b,[{key:"uri",get:function(){return this._uri}}]),b}()},"./src/loader/load-stats.ts":function(B,P,n){"use strict";n.r(P),n.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(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return f});var R=n("./src/polyfills/number.ts"),m=n("./node_modules/url-toolkit/src/url-toolkit.js"),S=n.n(m),I=n("./src/loader/date-range.ts"),T=n("./src/loader/fragment.ts"),b=n("./src/loader/level-details.ts"),_=n("./src/loader/level-key.ts"),E=n("./src/utils/attr-list.ts"),A=n("./src/utils/logger.ts"),D=n("./src/utils/codecs.ts"),x=/#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,y=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),s=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 o(r){var h,d;return e.test((h=(d=m.parseURL(r))===null||d===void 0?void 0:d.path)!=null?h:"")}var f=function(){function r(){}return r.findGroup=function(d,l){for(var v=0;v<d.length;v++){var p=d[v];if(p.id===l)return p}},r.convertAVC1ToAVCOTI=function(d){var l=d.split(".");if(l.length>2){var v=l.shift()+".";return v+=parseInt(l.shift()).toString(16),v+=("000"+parseInt(l.shift()).toString(16)).slice(-4),v}return d},r.resolve=function(d,l){return m.buildAbsoluteURL(l,d,{alwaysNormalize:!0})},r.parseMasterPlaylist=function(d,l){var v=[],p={},L=!1;x.lastIndex=0;for(var O;(O=x.exec(d))!=null;)if(O[1]){var M=new E.AttrList(O[1]),F={attrs:M,bitrate:M.decimalInteger("AVERAGE-BANDWIDTH")||M.decimalInteger("BANDWIDTH"),name:M.NAME,url:r.resolve(O[2],l)},w=M.decimalResolution("RESOLUTION");w&&(F.width=w.width,F.height=w.height),a((M.CODECS||"").split(/[ ,]+/).filter(function(k){return k}),F),F.videoCodec&&F.videoCodec.indexOf("avc1")!==-1&&(F.videoCodec=r.convertAVC1ToAVCOTI(F.videoCodec)),v.push(F)}else if(O[3]){var C=new E.AttrList(O[3]);C["DATA-ID"]&&(L=!0,p[C["DATA-ID"]]=C)}return{levels:v,sessionData:L?p:null}},r.parseMasterPlaylistMedia=function(d,l,v,p){p===void 0&&(p=[]);var L,O=[],M=0;for(g.lastIndex=0;(L=g.exec(d))!==null;){var F=new E.AttrList(L[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,l):""};if(p.length){var C=r.findGroup(p,w.groupId)||p[0];i(w,C,"audioCodec"),i(w,C,"textCodec")}O.push(w)}}return O},r.parseLevelPlaylist=function(d,l,v,p,L){var O=new b.LevelDetails(l),M=O.fragments,F=null,w=0,C=0,k=0,U=0,j=null,N=new T.Fragment(p,l),W,Y,K,H=-1,z=!1;for(y.lastIndex=0,O.m3u8=d;(W=y.exec(d))!==null;){z&&(z=!1,N=new T.Fragment(p,l),N.start=k,N.sn=w,N.cc=U,N.level=v,F&&(N.initSegment=F,N.rawProgramDateTime=F.rawProgramDateTime,F.rawProgramDateTime=null));var $=W[1];if($){N.duration=parseFloat($);var X=(" "+W[2]).slice(1);N.title=X||null,N.tagList.push(X?["INF",$,X]:["INF",$])}else if(W[3])Object(R.isFiniteNumber)(N.duration)&&(N.start=k,K&&(N.levelkey=K),N.sn=w,N.level=v,N.cc=U,N.urlId=L,M.push(N),N.relurl=(" "+W[3]).slice(1),u(N,j),j=N,k+=N.duration,w++,C=0,z=!0);else if(W[4]){var J=(" "+W[4]).slice(1);j?N.setByteRange(J,j):N.setByteRange(J)}else if(W[5])N.rawProgramDateTime=(" "+W[5]).slice(1),N.tagList.push(["PROGRAM-DATE-TIME",N.rawProgramDateTime]),H===-1&&(H=M.length);else{if(W=W[0].match(s),!W){A.logger.warn("No matches on slow regex match for level playlist!");continue}for(Y=1;Y<W.length&&typeof W[Y]=="undefined";Y++);var te=(" "+W[Y]).slice(1),Q=(" "+W[Y+1]).slice(1),ae=W[Y+2]?(" "+W[Y+2]).slice(1):"";switch(te){case"PLAYLIST-TYPE":O.type=Q.toUpperCase();break;case"MEDIA-SEQUENCE":w=O.startSN=parseInt(Q);break;case"SKIP":{var se=new E.AttrList(Q),re=se.decimalInteger("SKIPPED-SEGMENTS");if(Object(R.isFiniteNumber)(re)){O.skippedSegments=re;for(var ee=re;ee--;)M.unshift(null);w+=re}var Z=se.enumeratedString("RECENTLY-REMOVED-DATERANGES");Z&&(O.recentlyRemovedDateranges=Z.split(" "));break}case"TARGETDURATION":O.targetduration=parseFloat(Q);break;case"VERSION":O.version=parseInt(Q);break;case"EXTM3U":break;case"ENDLIST":O.live=!1;break;case"#":(Q||ae)&&N.tagList.push(ae?[Q,ae]:[Q]);break;case"DISCONTINUITY":U++,N.tagList.push(["DIS"]);break;case"GAP":N.tagList.push([te]);break;case"BITRATE":N.tagList.push([te,Q]);break;case"DATERANGE":{var q=new E.AttrList(Q),fe=new I.DateRange(q,O.dateRanges[q.ID]);fe.isValid||O.skippedSegments?O.dateRanges[fe.id]=fe:A.logger.warn('Ignoring invalid DATERANGE tag: "'+Q+'"'),N.tagList.push(["EXT-X-DATERANGE",Q]);break}case"DISCONTINUITY-SEQUENCE":U=parseInt(Q);break;case"KEY":{var ge,ie=new E.AttrList(Q),me=ie.enumeratedString("METHOD"),ye=ie.URI,Te=ie.hexadecimalInteger("IV"),oe=ie.enumeratedString("KEYFORMATVERSIONS"),de=ie.enumeratedString("KEYID"),Se=(ge=ie.enumeratedString("KEYFORMAT"))!=null?ge:"identity",Ee=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(Ee.indexOf(Se)>-1){A.logger.warn("Keyformat "+Se+" is not supported from the manifest");continue}else if(Se!=="identity")continue;me&&(K=_.LevelKey.fromURL(l,ye),ye&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(me)>=0&&(K.method=me,K.keyFormat=Se,de&&(K.keyID=de),oe&&(K.keyFormatVersions=oe),K.iv=Te));break}case"START":{var Ae=new E.AttrList(Q),be=Ae.decimalFloatingPoint("TIME-OFFSET");Object(R.isFiniteNumber)(be)&&(O.startTimeOffset=be);break}case"MAP":{var Me=new E.AttrList(Q);if(N.duration){var De=new T.Fragment(p,l);c(De,Me,v,K),F=De,N.initSegment=F,F.rawProgramDateTime&&!N.rawProgramDateTime&&(N.rawProgramDateTime=F.rawProgramDateTime)}else c(N,Me,v,K),F=N,z=!0;break}case"SERVER-CONTROL":{var xe=new E.AttrList(Q);O.canBlockReload=xe.bool("CAN-BLOCK-RELOAD"),O.canSkipUntil=xe.optionalFloat("CAN-SKIP-UNTIL",0),O.canSkipDateRanges=O.canSkipUntil>0&&xe.bool("CAN-SKIP-DATERANGES"),O.partHoldBack=xe.optionalFloat("PART-HOLD-BACK",0),O.holdBack=xe.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var G=new E.AttrList(Q);O.partTarget=G.decimalFloatingPoint("PART-TARGET");break}case"PART":{var V=O.partList;V||(V=O.partList=[]);var ue=C>0?V[V.length-1]:void 0,he=C++,pe=new T.Part(new E.AttrList(Q),N,l,he,ue);V.push(pe),N.duration+=pe.duration;break}case"PRELOAD-HINT":{var _e=new E.AttrList(Q);O.preloadHint=_e;break}case"RENDITION-REPORT":{var le=new E.AttrList(Q);O.renditionReports=O.renditionReports||[],O.renditionReports.push(le);break}default:A.logger.warn("line parsed but not handled: "+W);break}}}j&&!j.relurl?(M.pop(),k-=j.duration,O.partList&&(O.fragmentHint=j)):O.partList&&(u(N,j),N.cc=U,O.fragmentHint=N);var Re=M.length,Le=M[0],Ie=M[Re-1];if(k+=O.skippedSegments*O.targetduration,k>0&&Re&&Ie){O.averagetargetduration=k/Re;var je=Ie.sn;O.endSN=je!=="initSegment"?je:0,Le&&(O.startCC=Le.cc,Le.initSegment||O.fragments.every(function(Ue){return Ue.relurl&&o(Ue.relurl)})&&(A.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),N=new T.Fragment(p,l),N.relurl=Ie.relurl,N.level=v,N.sn="initSegment",Le.initSegment=N,O.needSidxRanges=!0))}else O.endSN=0,O.startCC=0;return O.fragmentHint&&(k+=O.fragmentHint.duration),O.totalduration=k,O.endCC=U,H>0&&t(M,H),O},r}();function a(r,h){["video","audio","text"].forEach(function(d){var l=r.filter(function(p){return Object(D.isCodecType)(p,d)});if(l.length){var v=l.filter(function(p){return p.lastIndexOf("avc1",0)===0||p.lastIndexOf("mp4a",0)===0});h[d+"Codec"]=v.length>0?v[0]:l[0],r=r.filter(function(p){return l.indexOf(p)===-1})}}),h.unknownCodecs=r}function i(r,h,d){var l=h[d];l&&(r[d]=l)}function t(r,h){for(var d=r[h],l=h;l--;){var v=r[l];if(!v)return;v.programDateTime=d.programDateTime-v.duration*1e3,d=v}}function u(r,h){r.rawProgramDateTime?r.programDateTime=Date.parse(r.rawProgramDateTime):h!=null&&h.programDateTime&&(r.programDateTime=h.endProgramDateTime),Object(R.isFiniteNumber)(r.programDateTime)||(r.programDateTime=null,r.rawProgramDateTime=null)}function c(r,h,d,l){r.relurl=h.URI,h.BYTERANGE&&r.setByteRange(h.BYTERANGE),r.level=d,r.sn="initSegment",l&&(r.levelkey=l),r.initSegment=null}},"./src/loader/playlist-loader.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/polyfills/number.ts"),m=n("./src/events.ts"),S=n("./src/errors.ts"),I=n("./src/utils/logger.ts"),T=n("./src/utils/mp4-tools.ts"),b=n("./src/loader/m3u8-parser.ts"),_=n("./src/types/loader.ts"),E=n("./src/utils/attr-list.ts");function A(g){var y=g.type;switch(y){case _.PlaylistContextType.AUDIO_TRACK:return _.PlaylistLevelType.AUDIO;case _.PlaylistContextType.SUBTITLE_TRACK:return _.PlaylistLevelType.SUBTITLE;default:return _.PlaylistLevelType.MAIN}}function D(g,y){var s=g.url;return(s===void 0||s.indexOf("data:")===0)&&(s=y.url),s}var x=function(){function g(s){this.hls=void 0,this.loaders=Object.create(null),this.hls=s,this.registerListeners()}var y=g.prototype;return y.startLoad=function(e){},y.stopLoad=function(){this.destroyInternalLoaders()},y.registerListeners=function(){var e=this.hls;e.on(m.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(m.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(m.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},y.unregisterListeners=function(){var e=this.hls;e.off(m.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(m.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(m.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},y.createInternalLoader=function(e){var o=this.hls.config,f=o.pLoader,a=o.loader,i=f||a,t=new i(o);return e.loader=t,this.loaders[e.type]=t,t},y.getInternalLoader=function(e){return this.loaders[e.type]},y.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},y.destroyInternalLoaders=function(){for(var e in this.loaders){var o=this.loaders[e];o&&o.destroy(),this.resetInternalLoader(e)}},y.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},y.onManifestLoading=function(e,o){var f=o.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:_.PlaylistContextType.MANIFEST,url:f,deliveryDirectives:null})},y.onLevelLoading=function(e,o){var f=o.id,a=o.level,i=o.url,t=o.deliveryDirectives;this.load({id:f,groupId:null,level:a,responseType:"text",type:_.PlaylistContextType.LEVEL,url:i,deliveryDirectives:t})},y.onAudioTrackLoading=function(e,o){var f=o.id,a=o.groupId,i=o.url,t=o.deliveryDirectives;this.load({id:f,groupId:a,level:null,responseType:"text",type:_.PlaylistContextType.AUDIO_TRACK,url:i,deliveryDirectives:t})},y.onSubtitleTrackLoading=function(e,o){var f=o.id,a=o.groupId,i=o.url,t=o.deliveryDirectives;this.load({id:f,groupId:a,level:null,responseType:"text",type:_.PlaylistContextType.SUBTITLE_TRACK,url:i,deliveryDirectives:t})},y.load=function(e){var o,f=this.hls.config,a=this.getInternalLoader(e);if(a){var i=a.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),a.abort()}var t,u,c,r;switch(e.type){case _.PlaylistContextType.MANIFEST:t=f.manifestLoadingMaxRetry,u=f.manifestLoadingTimeOut,c=f.manifestLoadingRetryDelay,r=f.manifestLoadingMaxRetryTimeout;break;case _.PlaylistContextType.LEVEL:case _.PlaylistContextType.AUDIO_TRACK:case _.PlaylistContextType.SUBTITLE_TRACK:t=0,u=f.levelLoadingTimeOut;break;default:t=f.levelLoadingMaxRetry,u=f.levelLoadingTimeOut,c=f.levelLoadingRetryDelay,r=f.levelLoadingMaxRetryTimeout;break}if(a=this.createInternalLoader(e),(o=e.deliveryDirectives)!==null&&o!==void 0&&o.part){var h;if(e.type===_.PlaylistContextType.LEVEL&&e.level!==null?h=this.hls.levels[e.level].details:e.type===_.PlaylistContextType.AUDIO_TRACK&&e.id!==null?h=this.hls.audioTracks[e.id].details:e.type===_.PlaylistContextType.SUBTITLE_TRACK&&e.id!==null&&(h=this.hls.subtitleTracks[e.id].details),h){var d=h.partTarget,l=h.targetduration;d&&l&&(u=Math.min(Math.max(d*3,l*.8)*1e3,u))}}var v={timeout:u,maxRetry:t,retryDelay:c,maxRetryDelay:r,highWaterMark:0},p={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};a.load(e,v,p)},y.loadsuccess=function(e,o,f,a){if(a===void 0&&(a=null),f.isSidxRequest){this.handleSidxRequest(e,f),this.handlePlaylistLoaded(e,o,f,a);return}this.resetInternalLoader(f.type);var i=e.data;if(i.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(e,f,"no EXTM3U delimiter",a);return}o.parsing.start=performance.now(),i.indexOf("#EXTINF:")>0||i.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,o,f,a):this.handleMasterPlaylist(e,o,f,a)},y.loaderror=function(e,o,f){f===void 0&&(f=null),this.handleNetworkError(o,f,!1,e)},y.loadtimeout=function(e,o,f){f===void 0&&(f=null),this.handleNetworkError(o,f,!0)},y.handleMasterPlaylist=function(e,o,f,a){var i=this.hls,t=e.data,u=D(e,f),c=b.default.parseMasterPlaylist(t,u),r=c.levels,h=c.sessionData;if(!r.length){this.handleManifestParsingError(e,f,"no level found in manifest",a);return}var d=r.map(function(M){return{id:M.attrs.AUDIO,audioCodec:M.audioCodec}}),l=r.map(function(M){return{id:M.attrs.SUBTITLES,textCodec:M.textCodec}}),v=b.default.parseMasterPlaylistMedia(t,u,"AUDIO",d),p=b.default.parseMasterPlaylistMedia(t,u,"SUBTITLES",l),L=b.default.parseMasterPlaylistMedia(t,u,"CLOSED-CAPTIONS");if(v.length){var O=v.some(function(M){return!M.url});!O&&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 E.AttrList({}),bitrate:0,url:""}))}i.trigger(m.Events.MANIFEST_LOADED,{levels:r,audioTracks:v,subtitles:p,captions:L,url:u,stats:o,networkDetails:a,sessionData:h})},y.handleTrackOrLevelPlaylist=function(e,o,f,a){var i=this.hls,t=f.id,u=f.level,c=f.type,r=D(e,f),h=Object(R.isFiniteNumber)(t)?t:0,d=Object(R.isFiniteNumber)(u)?u:h,l=A(f),v=b.default.parseLevelPlaylist(e.data,r,d,l,h);if(!v.fragments.length){i.trigger(m.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 f.level=="number"?f.level:void 0});return}if(c===_.PlaylistContextType.MANIFEST){var p={attrs:new E.AttrList({}),bitrate:0,details:v,name:"",url:r};i.trigger(m.Events.MANIFEST_LOADED,{levels:[p],audioTracks:[],url:r,stats:o,networkDetails:a,sessionData:null})}if(o.parsing.end=performance.now(),v.needSidxRanges){var L,O=(L=v.fragments[0].initSegment)===null||L===void 0?void 0:L.url;this.load({url:O,isSidxRequest:!0,type:c,level:u,levelDetails:v,id:t,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}f.levelDetails=v,this.handlePlaylistLoaded(e,o,f,a)},y.handleSidxRequest=function(e,o){var f=new Uint8Array(e.data),a=Object(T.findBox)(f,["sidx"])[0];if(!!a){var i=Object(T.parseSegmentIndex)(a);if(!!i){var t=i.references,u=o.levelDetails;t.forEach(function(c,r){var h=c.info,d=u.fragments[r];if(d.byteRange.length===0&&d.setByteRange(String(1+h.end-h.start)+"@"+String(h.start)),d.initSegment){var l=Object(T.findBox)(f,["moov"])[0],v=l?l.length:null;d.initSegment.setByteRange(String(v)+"@0")}})}}},y.handleManifestParsingError=function(e,o,f,a){this.hls.trigger(m.Events.ERROR,{type:S.ErrorTypes.NETWORK_ERROR,details:S.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:o.type===_.PlaylistContextType.MANIFEST,url:e.url,reason:f,response:e,context:o,networkDetails:a})},y.handleNetworkError=function(e,o,f,a){f===void 0&&(f=!1),I.logger.warn("[playlist-loader]: A network "+(f?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var i=S.ErrorDetails.UNKNOWN,t=!1,u=this.getInternalLoader(e);switch(e.type){case _.PlaylistContextType.MANIFEST:i=f?S.ErrorDetails.MANIFEST_LOAD_TIMEOUT:S.ErrorDetails.MANIFEST_LOAD_ERROR,t=!0;break;case _.PlaylistContextType.LEVEL:i=f?S.ErrorDetails.LEVEL_LOAD_TIMEOUT:S.ErrorDetails.LEVEL_LOAD_ERROR,t=!1;break;case _.PlaylistContextType.AUDIO_TRACK:i=f?S.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:S.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,t=!1;break;case _.PlaylistContextType.SUBTITLE_TRACK:i=f?S.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:S.ErrorDetails.SUBTITLE_LOAD_ERROR,t=!1;break}u&&this.resetInternalLoader(e.type);var c={type:S.ErrorTypes.NETWORK_ERROR,details:i,fatal:t,url:e.url,loader:u,context:e,networkDetails:o};a&&(c.response=a),this.hls.trigger(m.Events.ERROR,c)},y.handlePlaylistLoaded=function(e,o,f,a){var i=f.type,t=f.level,u=f.id,c=f.groupId,r=f.loader,h=f.levelDetails,d=f.deliveryDirectives;if(!(h!=null&&h.targetduration)){this.handleManifestParsingError(e,f,"invalid target duration",a);return}if(!!r)switch(h.live&&(r.getCacheAge&&(h.ageHeader=r.getCacheAge()||0),(!r.getCacheAge||isNaN(h.ageHeader))&&(h.ageHeader=0)),i){case _.PlaylistContextType.MANIFEST:case _.PlaylistContextType.LEVEL:this.hls.trigger(m.Events.LEVEL_LOADED,{details:h,level:t||0,id:u||0,stats:o,networkDetails:a,deliveryDirectives:d});break;case _.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(m.Events.AUDIO_TRACK_LOADED,{details:h,id:u||0,groupId:c||"",stats:o,networkDetails:a,deliveryDirectives:d});break;case _.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(m.Events.SUBTITLE_TRACK_LOADED,{details:h,id:u||0,groupId:c||"",stats:o,networkDetails:a,deliveryDirectives:d});break}},g}();P.default=x},"./src/polyfills/number.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"isFiniteNumber",function(){return R}),n.d(P,"MAX_SAFE_INTEGER",function(){return m});var R=Number.isFinite||function(S){return typeof S=="number"&&isFinite(S)},m=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(B,P,n){"use strict";n.r(P);var R=function(){function m(){}return m.getSilentFrame=function(I,T){switch(I){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}},m}();P.default=R},"./src/remux/mp4-generator.ts":function(B,P,n){"use strict";n.r(P);var R=Math.pow(2,32)-1,m=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 T;for(T in S.types)S.types.hasOwnProperty(T)&&(S.types[T]=[T.charCodeAt(0),T.charCodeAt(1),T.charCodeAt(2),T.charCodeAt(3)]);var b=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]);S.HDLR_TYPES={video:b,audio:_};var E=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]);S.STTS=S.STSC=S.STCO=A,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 D=new Uint8Array([105,115,111,109]),x=new Uint8Array([97,118,99,49]),g=new Uint8Array([0,0,0,1]);S.FTYP=S.box(S.types.ftyp,D,g,D,x),S.DINF=S.box(S.types.dinf,S.box(S.types.dref,E))},S.box=function(T){for(var b=8,_=arguments.length,E=new Array(_>1?_-1:0),A=1;A<_;A++)E[A-1]=arguments[A];for(var D=E.length,x=D;D--;)b+=E[D].byteLength;var g=new Uint8Array(b);for(g[0]=b>>24&255,g[1]=b>>16&255,g[2]=b>>8&255,g[3]=b&255,g.set(T,4),D=0,b=8;D<x;D++)g.set(E[D],b),b+=E[D].byteLength;return g},S.hdlr=function(T){return S.box(S.types.hdlr,S.HDLR_TYPES[T])},S.mdat=function(T){return S.box(S.types.mdat,T)},S.mdhd=function(T,b){b*=T;var _=Math.floor(b/(R+1)),E=Math.floor(b%(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,T>>24&255,T>>16&255,T>>8&255,T&255,_>>24,_>>16&255,_>>8&255,_&255,E>>24,E>>16&255,E>>8&255,E&255,85,196,0,0]))},S.mdia=function(T){return S.box(S.types.mdia,S.mdhd(T.timescale,T.duration),S.hdlr(T.type),S.minf(T))},S.mfhd=function(T){return S.box(S.types.mfhd,new Uint8Array([0,0,0,0,T>>24,T>>16&255,T>>8&255,T&255]))},S.minf=function(T){return T.type==="audio"?S.box(S.types.minf,S.box(S.types.smhd,S.SMHD),S.DINF,S.stbl(T)):S.box(S.types.minf,S.box(S.types.vmhd,S.VMHD),S.DINF,S.stbl(T))},S.moof=function(T,b,_){return S.box(S.types.moof,S.mfhd(T),S.traf(_,b))},S.moov=function(T){for(var b=T.length,_=[];b--;)_[b]=S.trak(T[b]);return S.box.apply(null,[S.types.moov,S.mvhd(T[0].timescale,T[0].duration)].concat(_).concat(S.mvex(T)))},S.mvex=function(T){for(var b=T.length,_=[];b--;)_[b]=S.trex(T[b]);return S.box.apply(null,[S.types.mvex].concat(_))},S.mvhd=function(T,b){b*=T;var _=Math.floor(b/(R+1)),E=Math.floor(b%(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,E>>24,E>>16&255,E>>8&255,E&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return S.box(S.types.mvhd,A)},S.sdtp=function(T){var b=T.samples||[],_=new Uint8Array(4+b.length),E,A;for(E=0;E<b.length;E++)A=b[E].flags,_[E+4]=A.dependsOn<<4|A.isDependedOn<<2|A.hasRedundancy;return S.box(S.types.sdtp,_)},S.stbl=function(T){return S.box(S.types.stbl,S.stsd(T),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(T){var b=[],_=[],E,A,D;for(E=0;E<T.sps.length;E++)A=T.sps[E],D=A.byteLength,b.push(D>>>8&255),b.push(D&255),b=b.concat(Array.prototype.slice.call(A));for(E=0;E<T.pps.length;E++)A=T.pps[E],D=A.byteLength,_.push(D>>>8&255),_.push(D&255),_=_.concat(Array.prototype.slice.call(A));var x=S.box(S.types.avcC,new Uint8Array([1,b[3],b[4],b[5],255,224|T.sps.length].concat(b).concat([T.pps.length]).concat(_))),g=T.width,y=T.height,s=T.pixelRatio[0],e=T.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,y>>8&255,y&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]),x,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([s>>24,s>>16&255,s>>8&255,s&255,e>>24,e>>16&255,e>>8&255,e&255])))},S.esds=function(T){var b=T.config.length;return new Uint8Array([0,0,0,0,3,23+b,0,1,0,4,15+b,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([b]).concat(T.config).concat([6,1,2]))},S.mp4a=function(T){var b=T.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,T.channelCount,0,16,0,0,0,0,b>>8&255,b&255,0,0]),S.box(S.types.esds,S.esds(T)))},S.mp3=function(T){var b=T.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,T.channelCount,0,16,0,0,0,0,b>>8&255,b&255,0,0]))},S.stsd=function(T){return T.type==="audio"?T.segmentCodec==="mp3"&&T.codec==="mp3"?S.box(S.types.stsd,S.STSD,S.mp3(T)):S.box(S.types.stsd,S.STSD,S.mp4a(T)):S.box(S.types.stsd,S.STSD,S.avc1(T))},S.tkhd=function(T){var b=T.id,_=T.duration*T.timescale,E=T.width,A=T.height,D=Math.floor(_/(R+1)),x=Math.floor(_%(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,b>>24&255,b>>16&255,b>>8&255,b&255,0,0,0,0,D>>24,D>>16&255,D>>8&255,D&255,x>>24,x>>16&255,x>>8&255,x&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,E>>8&255,E&255,0,0,A>>8&255,A&255,0,0]))},S.traf=function(T,b){var _=S.sdtp(T),E=T.id,A=Math.floor(b/(R+1)),D=Math.floor(b%(R+1));return S.box(S.types.traf,S.box(S.types.tfhd,new Uint8Array([0,0,0,0,E>>24,E>>16&255,E>>8&255,E&255])),S.box(S.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])),S.trun(T,_.length+16+20+8+16+8+8),_)},S.trak=function(T){return T.duration=T.duration||4294967295,S.box(S.types.trak,S.tkhd(T),S.mdia(T))},S.trex=function(T){var b=T.id;return S.box(S.types.trex,new Uint8Array([0,0,0,0,b>>24,b>>16&255,b>>8&255,b&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},S.trun=function(T,b){var _=T.samples||[],E=_.length,A=12+16*E,D=new Uint8Array(A),x,g,y,s,e,o;for(b+=8+A,D.set([T.type==="video"?1:0,0,15,1,E>>>24&255,E>>>16&255,E>>>8&255,E&255,b>>>24&255,b>>>16&255,b>>>8&255,b&255],0),x=0;x<E;x++)g=_[x],y=g.duration,s=g.size,e=g.flags,o=g.cts,D.set([y>>>24&255,y>>>16&255,y>>>8&255,y&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,o>>>24&255,o>>>16&255,o>>>8&255,o&255],12+16*x);return S.box(S.types.trun,D)},S.initSegment=function(T){S.types||S.init();var b=S.moov(T),_=new Uint8Array(S.FTYP.byteLength+b.byteLength);return _.set(S.FTYP),_.set(b,S.FTYP.byteLength),_},S}();m.types=void 0,m.HDLR_TYPES=void 0,m.STTS=void 0,m.STSC=void 0,m.STCO=void 0,m.STSZ=void 0,m.VMHD=void 0,m.SMHD=void 0,m.STSD=void 0,m.FTYP=void 0,m.DINF=void 0,P.default=m},"./src/remux/mp4-remuxer.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return e}),n.d(P,"normalizePts",function(){return o}),n.d(P,"flushTextTrackMetadataCueSamples",function(){return a}),n.d(P,"flushTextTrackUserdataCueSamples",function(){return i});var R=n("./src/polyfills/number.ts"),m=n("./src/remux/aac-helper.ts"),S=n("./src/remux/mp4-generator.ts"),I=n("./src/events.ts"),T=n("./src/errors.ts"),b=n("./src/utils/logger.ts"),_=n("./src/types/loader.ts"),E=n("./src/utils/timescale-conversion.ts");function A(){return A=Object.assign?Object.assign.bind():function(c){for(var r=1;r<arguments.length;r++){var h=arguments[r];for(var d in h)Object.prototype.hasOwnProperty.call(h,d)&&(c[d]=h[d])}return c},A.apply(this,arguments)}var D=10*1e3,x=1024,g=1152,y=null,s=null,e=function(){function c(h,d,l,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=h,this.config=d,this.typeSupported=l,this.ISGenerated=!1,y===null){var p=navigator.userAgent||"",L=p.match(/Chrome\/(\d+)/i);y=L?parseInt(L[1]):0}if(s===null){var O=navigator.userAgent.match(/Safari\/(\d+)/i);s=O?parseInt(O[1]):0}}var r=c.prototype;return r.destroy=function(){},r.resetTimeStamp=function(d){b.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=d},r.resetNextTimestamp=function(){b.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},r.resetInitSegment=function(){b.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},r.getVideoStartPts=function(d){var l=!1,v=d.reduce(function(p,L){var O=L.pts-p;return O<-4294967296?(l=!0,o(p,L.pts)):O>0?p:L.pts},d[0].pts);return l&&b.logger.debug("PTS rollover detected"),v},r.remux=function(d,l,v,p,L,O,M,F){var w,C,k,U,j,N,W=L,Y=L,K=d.pid>-1,H=l.pid>-1,z=l.samples.length,$=d.samples.length>0,X=M&&z>0||z>1,J=(!K||$)&&(!H||X)||this.ISGenerated||M;if(J){this.ISGenerated||(k=this.generateIS(d,l,L));var te=this.isVideoContiguous,Q=-1,ae;if(X&&(Q=f(l.samples),!te&&this.config.forceKeyFrameOnDiscontinuity))if(N=!0,Q>0){b.logger.warn("[mp4-remuxer]: Dropped "+Q+" out of "+z+" video samples due to a missing keyframe");var se=this.getVideoStartPts(l.samples);l.samples=l.samples.slice(Q),l.dropped+=Q,Y+=(l.samples[0].pts-se)/l.inputTimeScale,ae=Y}else Q===-1&&(b.logger.warn("[mp4-remuxer]: No keyframe found out of "+z+" video samples"),N=!1);if(this.ISGenerated){if($&&X){var re=this.getVideoStartPts(l.samples),ee=o(d.samples[0].pts,re)-re,Z=ee/l.inputTimeScale;W+=Math.max(0,Z),Y+=Math.max(0,-Z)}if($){if(d.samplerate||(b.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),k=this.generateIS(d,l,L)),C=this.remuxAudio(d,W,this.isAudioContiguous,O,H||X||F===_.PlaylistLevelType.AUDIO?Y:void 0),X){var q=C?C.endPTS-C.startPTS:0;l.inputTimeScale||(b.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),k=this.generateIS(d,l,L)),w=this.remuxVideo(l,Y,te,q)}}else X&&(w=this.remuxVideo(l,Y,te,0));w&&(w.firstKeyFrame=Q,w.independent=Q!==-1,w.firstKeyFramePTS=ae)}}return this.ISGenerated&&(v.samples.length&&(j=a(v,L,this._initPTS,this._initDTS)),p.samples.length&&(U=i(p,L,this._initPTS))),{audio:C,video:w,initSegment:k,independent:N,text:U,id3:j}},r.generateIS=function(d,l,v){var p=d.samples,L=l.samples,O=this.typeSupported,M={},F=!Object(R.isFiniteNumber)(this._initPTS),w="audio/mp4",C,k,U;if(F&&(C=k=1/0),d.config&&p.length){switch(d.timescale=d.samplerate,d.segmentCodec){case"mp3":O.mpeg?(w="audio/mpeg",d.codec=""):O.mp3&&(d.codec="mp3");break}M.audio={id:"audio",container:w,codec:d.codec,initSegment:d.segmentCodec==="mp3"&&O.mpeg?new Uint8Array(0):S.default.initSegment([d]),metadata:{channelCount:d.channelCount}},F&&(U=d.inputTimeScale,C=k=p[0].pts-Math.round(U*v))}if(l.sps&&l.pps&&L.length&&(l.timescale=l.inputTimeScale,M.video={id:"main",container:"video/mp4",codec:l.codec,initSegment:S.default.initSegment([l]),metadata:{width:l.width,height:l.height}},F)){U=l.inputTimeScale;var j=this.getVideoStartPts(L),N=Math.round(U*v);k=Math.min(k,o(L[0].dts,j)-N),C=Math.min(C,j-N)}if(Object.keys(M).length)return this.ISGenerated=!0,F&&(this._initPTS=C,this._initDTS=k),{tracks:M,initPTS:C,timescale:U}},r.remuxVideo=function(d,l,v,p){var L=d.inputTimeScale,O=d.samples,M=[],F=O.length,w=this._initPTS,C=this.nextAvcDts,k=8,U=this.videoSampleDuration,j,N,W=Number.POSITIVE_INFINITY,Y=Number.NEGATIVE_INFINITY,K=!1;if(!v||C===null){var H=l*L,z=O[0].pts-o(O[0].dts,O[0].pts);C=H-z}for(var $=0;$<F;$++){var X=O[$];X.pts=o(X.pts-w,C),X.dts=o(X.dts-w,C),X.dts<O[$>0?$-1:$].dts&&(K=!0)}K&&O.sort(function(We,it){var nt=We.dts-it.dts,pt=We.pts-it.pts;return nt||pt}),j=O[0].dts,N=O[O.length-1].dts;var J=N-j,te=J?Math.round(J/(F-1)):U||d.inputTimeScale/30;if(v){var Q=j-C,ae=Q>te,se=Q<-1;if(ae||se){ae?b.logger.warn("AVC: "+Object(E.toMsFromMpegTsClock)(Q,!0)+" ms ("+Q+"dts) hole between fragments detected, filling it"):b.logger.warn("AVC: "+Object(E.toMsFromMpegTsClock)(-Q,!0)+" ms ("+Q+"dts) overlapping between fragments detected"),j=C;var re=O[0].pts-Q;O[0].dts=j,O[0].pts=re,b.logger.log("Video: First PTS/DTS adjusted: "+Object(E.toMsFromMpegTsClock)(re,!0)+"/"+Object(E.toMsFromMpegTsClock)(j,!0)+", delta: "+Object(E.toMsFromMpegTsClock)(Q,!0)+" ms")}}j=Math.max(0,j);for(var ee=0,Z=0,q=0;q<F;q++){for(var fe=O[q],ge=fe.units,ie=ge.length,me=0,ye=0;ye<ie;ye++)me+=ge[ye].data.length;Z+=me,ee+=ie,fe.length=me,fe.dts=Math.max(fe.dts,j),W=Math.min(fe.pts,W),Y=Math.max(fe.pts,Y)}N=O[F-1].dts;var Te=Z+4*ee+8,oe;try{oe=new Uint8Array(Te)}catch{this.observer.emit(I.Events.ERROR,I.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(oe.buffer);de.setUint32(0,Te),oe.set(S.default.types.mdat,4);for(var Se=!1,Ee=Number.POSITIVE_INFINITY,Ae=Number.POSITIVE_INFINITY,be=Number.NEGATIVE_INFINITY,Me=Number.NEGATIVE_INFINITY,De=0;De<F;De++){for(var xe=O[De],G=xe.units,V=0,ue=0,he=G.length;ue<he;ue++){var pe=G[ue],_e=pe.data,le=pe.data.byteLength;de.setUint32(k,le),k+=4,oe.set(_e,k),k+=le,V+=4+le}var Re=void 0;if(De<F-1)U=O[De+1].dts-xe.dts,Re=O[De+1].pts-xe.pts;else{var Le=this.config,Ie=De>0?xe.dts-O[De-1].dts:te;if(Re=De>0?xe.pts-O[De-1].pts:te,Le.stretchShortVideoTrack&&this.nextAudioPts!==null){var je=Math.floor(Le.maxBufferHole*L),Ue=(p?W+p*L:this.nextAudioPts)-xe.pts;Ue>je?(U=Ue-Ie,U<0?U=Ie:Se=!0,b.logger.log("[mp4-remuxer]: It is approximately "+Ue/90+" ms to the next segment; using duration "+U/90+" ms for the last video frame.")):U=Ie}else U=Ie}var Be=Math.round(xe.pts-xe.dts);Ee=Math.min(Ee,U),be=Math.max(be,U),Ae=Math.min(Ae,Re),Me=Math.max(Me,Re),M.push(new t(xe.key,U,V,Be))}if(M.length){if(y){if(y<70){var et=M[0].flags;et.dependsOn=2,et.isNonSync=0}}else if(s&&Me-Ae<be-Ee&&te/be<.025&&M[0].cts===0){b.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var Ve=j,Ce=0,Ke=M.length;Ce<Ke;Ce++){var Ye=Ve+M[Ce].duration,ze=Ve+M[Ce].cts;if(Ce<Ke-1){var tt=Ye+M[Ce+1].cts;M[Ce].duration=tt-ze}else M[Ce].duration=Ce?M[Ce-1].duration:te;M[Ce].cts=0,Ve=Ye}}}console.assert(U!==null,"mp4SampleDuration must be computed"),U=Se||!U?te:U,this.nextAvcDts=C=N+U,this.videoSampleDuration=U,this.isVideoContiguous=!0;var rt=S.default.moof(d.sequenceNumber++,j,A({},d,{samples:M})),gt="video",mt={data1:rt,data2:oe,startPTS:W/L,endPTS:(Y+U)/L,startDTS:j/L,endDTS:C/L,type:gt,hasAudio:!1,hasVideo:!0,nb:M.length,dropped:d.dropped};return d.samples=[],d.dropped=0,console.assert(oe.length,"MDAT length must not be zero"),mt},r.remuxAudio=function(d,l,v,p,L){var O=d.inputTimeScale,M=d.samplerate?d.samplerate:O,F=O/M,w=d.segmentCodec==="aac"?x:g,C=w*F,k=this._initPTS,U=d.segmentCodec==="mp3"&&this.typeSupported.mpeg,j=[],N=L!==void 0,W=d.samples,Y=U?0:8,K=this.nextAudioPts||-1,H=l*O;if(this.isAudioContiguous=v=v||W.length&&K>0&&(p&&Math.abs(H-K)<9e3||Math.abs(o(W[0].pts-k,H)-K)<20*C),W.forEach(function(pe){pe.pts=o(pe.pts-k,H)}),!v||K<0){if(W=W.filter(function(pe){return pe.pts>=0}),!W.length)return;L===0?K=0:p&&!N?K=Math.max(0,H):K=W[0].pts}if(d.segmentCodec==="aac")for(var z=this.config.maxAudioFramesDrift,$=0,X=K;$<W.length;$++){var J=W[$],te=J.pts,Q=te-X,ae=Math.abs(1e3*Q/O);if(Q<=-z*C&&N)$===0&&(b.logger.warn("Audio frame @ "+(te/O).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*Q/O)+" ms."),this.nextAudioPts=K=X=te);else if(Q>=z*C&&ae<D&&N){var se=Math.round(Q/C);X=te-se*C,X<0&&(se--,X+=C),$===0&&(this.nextAudioPts=K=X),b.logger.warn("[mp4-remuxer]: Injecting "+se+" audio frame @ "+(X/O).toFixed(3)+"s due to "+Math.round(1e3*Q/O)+" ms gap.");for(var re=0;re<se;re++){var ee=Math.max(X,0),Z=m.default.getSilentFrame(d.manifestCodec||d.codec,d.channelCount);Z||(b.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Z=J.unit.subarray()),W.splice($,0,{unit:Z,pts:ee}),X+=C,$++}}J.pts=X,X+=C}for(var q=null,fe=null,ge,ie=0,me=W.length;me--;)ie+=W[me].unit.byteLength;for(var ye=0,Te=W.length;ye<Te;ye++){var oe=W[ye],de=oe.unit,Se=oe.pts;if(fe!==null){var Ee=j[ye-1];Ee.duration=Math.round((Se-fe)/F)}else if(v&&d.segmentCodec==="aac"&&(Se=K),q=Se,ie>0){ie+=Y;try{ge=new Uint8Array(ie)}catch{this.observer.emit(I.Events.ERROR,I.Events.ERROR,{type:T.ErrorTypes.MUX_ERROR,details:T.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:ie,reason:"fail allocating audio mdat "+ie});return}if(!U){var Ae=new DataView(ge.buffer);Ae.setUint32(0,ie),ge.set(S.default.types.mdat,4)}}else return;ge.set(de,Y);var be=de.byteLength;Y+=be,j.push(new t(!0,w,be,0)),fe=Se}var Me=j.length;if(!!Me){var De=j[j.length-1];this.nextAudioPts=K=fe+F*De.duration;var xe=U?new Uint8Array(0):S.default.moof(d.sequenceNumber++,q/F,A({},d,{samples:j}));d.samples=[];var G=q/O,V=K/O,ue="audio",he={data1:xe,data2:ge,startPTS:G,endPTS:V,startDTS:G,endDTS:V,type:ue,hasAudio:!0,hasVideo:!1,nb:Me};return this.isAudioContiguous=!0,console.assert(ge.length,"MDAT length must not be zero"),he}},r.remuxEmptyAudio=function(d,l,v,p){var L=d.inputTimeScale,O=d.samplerate?d.samplerate:L,M=L/O,F=this.nextAudioPts,w=(F!==null?F:p.startDTS*L)+this._initDTS,C=p.endDTS*L+this._initDTS,k=M*x,U=Math.ceil((C-w)/k),j=m.default.getSilentFrame(d.manifestCodec||d.codec,d.channelCount);if(b.logger.warn("[mp4-remuxer]: remux empty Audio"),!j){b.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var N=[],W=0;W<U;W++){var Y=w+W*k;N.push({unit:j,pts:Y,dts:Y})}return d.samples=N,this.remuxAudio(d,l,v,!1)},c}();function o(c,r){var h;if(r===null)return c;for(r<c?h=-8589934592:h=8589934592;Math.abs(c-r)>4294967296;)c+=h;return c}function f(c){for(var r=0;r<c.length;r++)if(c[r].key)return r;return-1}function a(c,r,h,d){var l=c.samples.length;if(!!l){for(var v=c.inputTimeScale,p=0;p<l;p++){var L=c.samples[p];L.pts=o(L.pts-h,r*v)/v,L.dts=o(L.dts-d,r*v)/v}var O=c.samples;return c.samples=[],{samples:O}}}function i(c,r,h){var d=c.samples.length;if(!!d){for(var l=c.inputTimeScale,v=0;v<d;v++){var p=c.samples[v];p.pts=o(p.pts-h,r*l)/l}c.samples.sort(function(O,M){return O.pts-M.pts});var L=c.samples;return c.samples=[],{samples:L}}}var t=function(r,h,d,l){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=h,this.size=d,this.cts=l,this.flags=new u(r)},u=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(B,P,n){"use strict";n.r(P);var R=n("./src/polyfills/number.ts"),m=n("./src/remux/mp4-remuxer.ts"),S=n("./src/utils/mp4-tools.ts"),I=n("./src/loader/fragment.ts"),T=n("./src/utils/logger.ts"),b=function(){function E(){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 A=E.prototype;return A.destroy=function(){},A.resetTimeStamp=function(x){this.initPTS=x,this.lastEndTime=null},A.resetNextTimestamp=function(){this.lastEndTime=null},A.resetInitSegment=function(x,g,y){this.audioCodec=g,this.videoCodec=y,this.generateInitSegment(x),this.emitInitSegment=!0},A.generateInitSegment=function(x){var g=this.audioCodec,y=this.videoCodec;if(!x||!x.byteLength){this.initTracks=void 0,this.initData=void 0;return}var s=this.initData=Object(S.parseInitSegment)(x);g||(g=_(s.audio,I.ElementaryStreamTypes.AUDIO)),y||(y=_(s.video,I.ElementaryStreamTypes.VIDEO));var e={};s.audio&&s.video?e.audiovideo={container:"video/mp4",codec:g+","+y,initSegment:x,id:"main"}:s.audio?e.audio={container:"audio/mp4",codec:g,initSegment:x,id:"audio"}:s.video?e.video={container:"video/mp4",codec:y,initSegment:x,id:"main"}:T.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=e},A.remux=function(x,g,y,s,e){var o,f=this.initPTS,a=this.lastEndTime,i={audio:void 0,video:void 0,text:s,id3:y,initSegment:void 0};Object(R.isFiniteNumber)(a)||(a=this.lastEndTime=e||0);var t=g.samples;if(!t||!t.length)return i;var u={initPTS:void 0,timescale:1},c=this.initData;if((!c||!c.length)&&(this.generateInitSegment(t),c=this.initData),!c||!c.length)return T.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),i;this.emitInitSegment&&(u.tracks=this.initTracks,this.emitInitSegment=!1);var r=Object(S.getStartDTS)(c,t);Object(R.isFiniteNumber)(f)||(this.initPTS=u.initPTS=f=r-e);var h=Object(S.getDuration)(t,c),d=x?r-f:a,l=d+h;Object(S.offsetStartDTS)(c,t,f),h>0?this.lastEndTime=l:(T.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var v=!!c.audio,p=!!c.video,L="";v&&(L+="audio"),p&&(L+="video");var O={data1:t,startPTS:d,startDTS:d,endPTS:l,endDTS:l,type:L,hasAudio:v,hasVideo:p,nb:1,dropped:0};i.audio=O.type==="audio"?O:void 0,i.video=O.type!=="audio"?O:void 0,i.initSegment=u;var M=(o=this.initPTS)!=null?o:0;return i.id3=Object(m.flushTextTrackMetadataCueSamples)(y,e,M,M),s.samples.length&&(i.text=Object(m.flushTextTrackUserdataCueSamples)(s,e,M)),i},E}();function _(E,A){var D=E==null?void 0:E.codec;return D&&D.length>4?D:D==="hvc1"||D==="hev1"?"hvc1.1.c.L120.90":D==="av01"?"av01.0.04M.08":D==="avc1"||A===I.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}P.default=b},"./src/task-loop.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return R});var R=function(){function m(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var S=m.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(T){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,T),!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(){},m}()},"./src/types/cmcd.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"CMCDVersion",function(){return R}),n.d(P,"CMCDObjectType",function(){return m}),n.d(P,"CMCDStreamingFormat",function(){return S}),n.d(P,"CMCDStreamType",function(){return I});var R=1,m;(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"})(m||(m={}));var S;(function(T){T.DASH="d",T.HLS="h",T.SMOOTH="s",T.OTHER="o"})(S||(S={}));var I;(function(T){T.VOD="v",T.LIVE="l"})(I||(I={}))},"./src/types/demuxer.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"MetadataSchema",function(){return R});var R;(function(m){m.audioId3="org.id3",m.dateRange="com.apple.quicktime.HLS",m.emsg="https://aomedia.org/emsg/ID3"})(R||(R={}))},"./src/types/level.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"HlsSkip",function(){return S}),n.d(P,"getSkipValue",function(){return I}),n.d(P,"HlsUrlParameters",function(){return T}),n.d(P,"Level",function(){return b});function R(_,E){for(var A=0;A<E.length;A++){var D=E[A];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(_,D.key,D)}}function m(_,E,A){return E&&R(_.prototype,E),A&&R(_,A),Object.defineProperty(_,"prototype",{writable:!1}),_}var S;(function(_){_.No="",_.Yes="YES",_.v2="v2"})(S||(S={}));function I(_,E){var A=_.canSkipUntil,D=_.canSkipDateRanges,x=_.endSN,g=E!==void 0?E-x:0;return A&&g<A?D?S.v2:S.Yes:S.No}var T=function(){function _(A,D,x){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=A,this.part=D,this.skip=x}var E=_.prototype;return E.addDirectives=function(D){var x=new self.URL(D);return this.msn!==void 0&&x.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&x.searchParams.set("_HLS_part",this.part.toString()),this.skip&&x.searchParams.set("_HLS_skip",this.skip),x.toString()},_}(),b=function(){function _(E){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=[E.url],this.attrs=E.attrs,this.bitrate=E.bitrate,E.details&&(this.details=E.details),this.id=E.id||0,this.name=E.name,this.width=E.width||0,this.height=E.height||0,this.audioCodec=E.audioCodec,this.videoCodec=E.videoCodec,this.unknownCodecs=E.unknownCodecs,this.codecSet=[E.videoCodec,E.audioCodec].filter(function(A){return A}).join(",").replace(/\.[^.,]+/g,"")}return m(_,[{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(B,P,n){"use strict";n.r(P),n.d(P,"PlaylistContextType",function(){return R}),n.d(P,"PlaylistLevelType",function(){return m});var R;(function(S){S.MANIFEST="manifest",S.LEVEL="level",S.AUDIO_TRACK="audioTrack",S.SUBTITLE_TRACK="subtitleTrack"})(R||(R={}));var m;(function(S){S.MAIN="main",S.AUDIO="audio",S.SUBTITLE="subtitle"})(m||(m={}))},"./src/types/transmuxer.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"ChunkMetadata",function(){return R});var R=function(I,T,b,_,E,A){_===void 0&&(_=0),E===void 0&&(E=-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=m(),this.buffering={audio:m(),video:m(),audiovideo:m()},this.level=I,this.sn=T,this.id=b,this.size=_,this.part=E,this.partial=A};function m(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"AttrList",function(){return S});var R=/^(\d+)x(\d+)$/,m=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,S=function(){function I(b){typeof b=="string"&&(b=I.parseAttrList(b));for(var _ in b)b.hasOwnProperty(_)&&(this[_]=b[_])}var T=I.prototype;return T.decimalInteger=function(_){var E=parseInt(this[_],10);return E>Number.MAX_SAFE_INTEGER?1/0:E},T.hexadecimalInteger=function(_){if(this[_]){var E=(this[_]||"0x").slice(2);E=(E.length&1?"0":"")+E;for(var A=new Uint8Array(E.length/2),D=0;D<E.length/2;D++)A[D]=parseInt(E.slice(D*2,D*2+2),16);return A}else return null},T.hexadecimalIntegerAsNumber=function(_){var E=parseInt(this[_],16);return E>Number.MAX_SAFE_INTEGER?1/0:E},T.decimalFloatingPoint=function(_){return parseFloat(this[_])},T.optionalFloat=function(_,E){var A=this[_];return A?parseFloat(A):E},T.enumeratedString=function(_){return this[_]},T.bool=function(_){return this[_]==="YES"},T.decimalResolution=function(_){var E=R.exec(this[_]);if(E!==null)return{width:parseInt(E[1],10),height:parseInt(E[2],10)}},I.parseAttrList=function(_){var E,A={},D='"';for(m.lastIndex=0;(E=m.exec(_))!==null;){var x=E[2];x.indexOf(D)===0&&x.lastIndexOf(D)===x.length-1&&(x=x.slice(1,-1)),A[E[1]]=x}return A},I}()},"./src/utils/binary-search.ts":function(B,P,n){"use strict";n.r(P);var R={search:function(S,I){for(var T=0,b=S.length-1,_=null,E=null;T<=b;){_=(T+b)/2|0,E=S[_];var A=I(E);if(A>0)T=_+1;else if(A<0)b=_-1;else return E}return null}};P.default=R},"./src/utils/buffer-helper.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"BufferHelper",function(){return S});var R=n("./src/utils/logger.ts"),m={length:0,start:function(){return 0},end:function(){return 0}},S=function(){function I(){}return I.isBuffered=function(b,_){try{if(b){for(var E=I.getBuffered(b),A=0;A<E.length;A++)if(_>=E.start(A)&&_<=E.end(A))return!0}}catch{}return!1},I.bufferInfo=function(b,_,E){try{if(b){var A=I.getBuffered(b),D=[],x;for(x=0;x<A.length;x++)D.push({start:A.start(x),end:A.end(x)});return this.bufferedInfo(D,_,E)}}catch{}return{len:0,start:_,end:_,nextStart:void 0}},I.bufferedInfo=function(b,_,E){_=Math.max(0,_),b.sort(function(t,u){var c=t.start-u.start;return c||u.end-t.end});var A=[];if(E)for(var D=0;D<b.length;D++){var x=A.length;if(x){var g=A[x-1].end;b[D].start-g<E?b[D].end>g&&(A[x-1].end=b[D].end):A.push(b[D])}else A.push(b[D])}else A=b;for(var y=0,s,e=_,o=_,f=0;f<A.length;f++){var a=A[f].start,i=A[f].end;if(_+E>=a&&_<i)e=a,o=i,y=o-_;else if(_+E<a){s=a;break}}return{len:y,start:e||0,end:o||0,nextStart:s}},I.getBuffered=function(b){try{return b.buffered}catch(_){return R.logger.log("failed to get media.buffered",_),m}},I}()},"./src/utils/cea-608-parser.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"Row",function(){return o}),n.d(P,"CaptionScreen",function(){return f});var R=n("./src/utils/logger.ts"),m={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(h){var d=h;return m.hasOwnProperty(h)&&(d=m[h]),String.fromCharCode(d)},I=15,T=100,b={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},E={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"],x;(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"})(x||(x={}));var g=function(){function r(){this.time=null,this.verboseLevel=x.ERROR}var h=r.prototype;return h.log=function(l,v){this.verboseLevel>=l&&R.logger.log(this.time+" ["+l+"] "+v)},r}(),y=function(h){for(var d=[],l=0;l<h.length;l++)d.push(h[l].toString(16));return d},s=function(){function r(d,l,v,p,L){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=d||"white",this.underline=l||!1,this.italics=v||!1,this.background=p||"black",this.flash=L||!1}var h=r.prototype;return h.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},h.setStyles=function(l){for(var v=["foreground","underline","italics","background","flash"],p=0;p<v.length;p++){var L=v[p];l.hasOwnProperty(L)&&(this[L]=l[L])}},h.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},h.equals=function(l){return this.foreground===l.foreground&&this.underline===l.underline&&this.italics===l.italics&&this.background===l.background&&this.flash===l.flash},h.copy=function(l){this.foreground=l.foreground,this.underline=l.underline,this.italics=l.italics,this.background=l.background,this.flash=l.flash},h.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},r}(),e=function(){function r(d,l,v,p,L,O){this.uchar=void 0,this.penState=void 0,this.uchar=d||" ",this.penState=new s(l,v,p,L,O)}var h=r.prototype;return h.reset=function(){this.uchar=" ",this.penState.reset()},h.setChar=function(l,v){this.uchar=l,this.penState.copy(v)},h.setPenState=function(l){this.penState.copy(l)},h.equals=function(l){return this.uchar===l.uchar&&this.penState.equals(l.penState)},h.copy=function(l){this.uchar=l.uchar,this.penState.copy(l.penState)},h.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},r}(),o=function(){function r(d){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var l=0;l<T;l++)this.chars.push(new e);this.logger=d,this.pos=0,this.currPenState=new s}var h=r.prototype;return h.equals=function(l){for(var v=!0,p=0;p<T;p++)if(!this.chars[p].equals(l.chars[p])){v=!1;break}return v},h.copy=function(l){for(var v=0;v<T;v++)this.chars[v].copy(l.chars[v])},h.isEmpty=function(){for(var l=!0,v=0;v<T;v++)if(!this.chars[v].isEmpty()){l=!1;break}return l},h.setCursor=function(l){this.pos!==l&&(this.pos=l),this.pos<0?(this.logger.log(x.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>T&&(this.logger.log(x.DEBUG,"Too large cursor position "+this.pos),this.pos=T)},h.moveCursor=function(l){var v=this.pos+l;if(l>1)for(var p=this.pos+1;p<v+1;p++)this.chars[p].setPenState(this.currPenState);this.setCursor(v)},h.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},h.insertChar=function(l){l>=144&&this.backSpace();var v=S(l);if(this.pos>=T){this.logger.log(x.ERROR,"Cannot insert "+l.toString(16)+" ("+v+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(v,this.currPenState),this.moveCursor(1)},h.clearFromPos=function(l){var v;for(v=l;v<T;v++)this.chars[v].reset()},h.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},h.clearToEndOfRow=function(){this.clearFromPos(this.pos)},h.getTextString=function(){for(var l=[],v=!0,p=0;p<T;p++){var L=this.chars[p].uchar;L!==" "&&(v=!1),l.push(L)}return v?"":l.join("")},h.setPenStyles=function(l){this.currPenState.setStyles(l);var v=this.chars[this.pos];v.setPenState(this.currPenState)},r}(),f=function(){function r(d){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var l=0;l<I;l++)this.rows.push(new o(d));this.logger=d,this.currRow=I-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var h=r.prototype;return h.reset=function(){for(var l=0;l<I;l++)this.rows[l].clear();this.currRow=I-1},h.equals=function(l){for(var v=!0,p=0;p<I;p++)if(!this.rows[p].equals(l.rows[p])){v=!1;break}return v},h.copy=function(l){for(var v=0;v<I;v++)this.rows[v].copy(l.rows[v])},h.isEmpty=function(){for(var l=!0,v=0;v<I;v++)if(!this.rows[v].isEmpty()){l=!1;break}return l},h.backSpace=function(){var l=this.rows[this.currRow];l.backSpace()},h.clearToEndOfRow=function(){var l=this.rows[this.currRow];l.clearToEndOfRow()},h.insertChar=function(l){var v=this.rows[this.currRow];v.insertChar(l)},h.setPen=function(l){var v=this.rows[this.currRow];v.setPenStyles(l)},h.moveCursor=function(l){var v=this.rows[this.currRow];v.moveCursor(l)},h.setCursor=function(l){this.logger.log(x.INFO,"setCursor: "+l);var v=this.rows[this.currRow];v.setCursor(l)},h.setPAC=function(l){this.logger.log(x.INFO,"pacData = "+JSON.stringify(l));var v=l.row-1;if(this.nrRollUpRows&&v<this.nrRollUpRows-1&&(v=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==v){for(var p=0;p<I;p++)this.rows[p].clear();var L=this.currRow+1-this.nrRollUpRows,O=this.lastOutputScreen;if(O){var M=O.rows[L].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(O.rows[L+w])}}this.currRow=v;var C=this.rows[this.currRow];if(l.indent!==null){var k=l.indent,U=Math.max(k-1,0);C.setCursor(l.indent),l.color=C.chars[U].penState.foreground}var j={foreground:l.color,underline:l.underline,italics:l.italics,background:"black",flash:!1};this.setPen(j)},h.setBkgData=function(l){this.logger.log(x.INFO,"bkgData = "+JSON.stringify(l)),this.backSpace(),this.setPen(l),this.insertChar(32)},h.setRollUpRows=function(l){this.nrRollUpRows=l},h.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(x.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(x.TEXT,this.getDisplayText());var l=this.currRow+1-this.nrRollUpRows,v=this.rows.splice(l,1)[0];v.clear(),this.rows.splice(this.currRow,0,v),this.logger.log(x.INFO,"Rolling up")},h.getDisplayText=function(l){l=l||!1;for(var v=[],p="",L=-1,O=0;O<I;O++){var M=this.rows[O].getTextString();M&&(L=O+1,l?v.push("Row "+L+": '"+M+"'"):v.push(M.trim()))}return v.length>0&&(l?p="["+v.join(" | ")+"]":p=v.join(`
|
|
19
|
+
`)),p},h.getTextAndFormat=function(){return this.rows},r}(),a=function(){function r(d,l,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=d,this.outputFilter=l,this.mode=null,this.verbose=0,this.displayedMemory=new f(v),this.nonDisplayedMemory=new f(v),this.lastOutputScreen=new f(v),this.currRollUpRow=this.displayedMemory.rows[I-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=v}var h=r.prototype;return h.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},h.getHandler=function(){return this.outputFilter},h.setHandler=function(l){this.outputFilter=l},h.setPAC=function(l){this.writeScreen.setPAC(l)},h.setBkgData=function(l){this.writeScreen.setBkgData(l)},h.setMode=function(l){l!==this.mode&&(this.mode=l,this.logger.log(x.INFO,"MODE="+l),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=l)},h.insertChars=function(l){for(var v=0;v<l.length;v++)this.writeScreen.insertChar(l[v]);var p=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(x.INFO,p+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(x.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},h.ccRCL=function(){this.logger.log(x.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},h.ccBS=function(){this.logger.log(x.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},h.ccAOF=function(){},h.ccAON=function(){},h.ccDER=function(){this.logger.log(x.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},h.ccRU=function(l){this.logger.log(x.INFO,"RU("+l+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(l)},h.ccFON=function(){this.logger.log(x.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},h.ccRDC=function(){this.logger.log(x.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},h.ccTR=function(){this.logger.log(x.INFO,"TR"),this.setMode("MODE_TEXT")},h.ccRTD=function(){this.logger.log(x.INFO,"RTD"),this.setMode("MODE_TEXT")},h.ccEDM=function(){this.logger.log(x.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},h.ccCR=function(){this.logger.log(x.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},h.ccENM=function(){this.logger.log(x.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},h.ccEOC=function(){if(this.logger.log(x.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var l=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=l,this.writeScreen=this.nonDisplayedMemory,this.logger.log(x.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},h.ccTO=function(l){this.logger.log(x.INFO,"TO("+l+") - Tab Offset"),this.writeScreen.moveCursor(l)},h.ccMIDROW=function(l){var v={flash:!1};if(v.underline=l%2===1,v.italics=l>=46,v.italics)v.foreground="white";else{var p=Math.floor(l/2)-16,L=["white","green","blue","cyan","red","yellow","magenta"];v.foreground=L[p]}this.logger.log(x.INFO,"MIDROW: "+JSON.stringify(v)),this.writeScreen.setPen(v)},h.outputDataUpdate=function(l){l===void 0&&(l=!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),l&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:v),this.lastOutputScreen.copy(this.displayedMemory))},h.cueSplitAtTime=function(l){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,l,this.displayedMemory),this.cueStartTime=l))},r}(),i=function(){function r(d,l,v){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var p=new g;this.channels=[null,new a(d,l,p),new a(d+1,v,p)],this.cmdHistory=c(),this.logger=p}var h=r.prototype;return h.getHandler=function(l){return this.channels[l].getHandler()},h.setHandler=function(l,v){this.channels[l].setHandler(v)},h.addData=function(l,v){var p,L,O,M=!1;this.logger.time=l;for(var F=0;F<v.length;F+=2)if(L=v[F]&127,O=v[F+1]&127,!(L===0&&O===0)){if(this.logger.log(x.DATA,"["+y([v[F],v[F+1]])+"] -> ("+y([L,O])+")"),p=this.parseCmd(L,O),p||(p=this.parseMidrow(L,O)),p||(p=this.parsePAC(L,O)),p||(p=this.parseBackgroundAttributes(L,O)),!p&&(M=this.parseChars(L,O),M)){var w=this.currentChannel;if(w&&w>0){var C=this.channels[w];C.insertChars(M)}else this.logger.log(x.WARNING,"No channel found yet. TEXT-MODE?")}!p&&!M&&this.logger.log(x.WARNING,"Couldn't parse cleaned data "+y([L,O])+" orig: "+y([v[F],v[F+1]]))}},h.parseCmd=function(l,v){var p=this.cmdHistory,L=(l===20||l===28||l===21||l===29)&&v>=32&&v<=47,O=(l===23||l===31)&&v>=33&&v<=35;if(!(L||O))return!1;if(u(l,v,p))return t(null,null,p),this.logger.log(x.DEBUG,"Repeated command ("+y([l,v])+") is dropped"),!0;var M=l===20||l===21||l===23?1:2,F=this.channels[M];return l===20||l===21||l===28||l===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(l,v,p),this.currentChannel=M,!0},h.parseMidrow=function(l,v){var p=0;if((l===17||l===25)&&v>=32&&v<=47){if(l===17?p=1:p=2,p!==this.currentChannel)return this.logger.log(x.ERROR,"Mismatch channel in midrow parsing"),!1;var L=this.channels[p];return L?(L.ccMIDROW(v),this.logger.log(x.DEBUG,"MIDROW ("+y([l,v])+")"),!0):!1}return!1},h.parsePAC=function(l,v){var p,L=this.cmdHistory,O=(l>=17&&l<=23||l>=25&&l<=31)&&v>=64&&v<=127,M=(l===16||l===24)&&v>=64&&v<=95;if(!(O||M))return!1;if(u(l,v,L))return t(null,null,L),!0;var F=l<=23?1:2;v>=64&&v<=95?p=F===1?b[l]:E[l]:p=F===1?_[l]:A[l];var w=this.channels[F];return w?(w.setPAC(this.interpretPAC(p,v)),t(l,v,L),this.currentChannel=F,!0):!1},h.interpretPAC=function(l,v){var p,L={color:null,italics:!1,indent:null,underline:!1,row:l};return v>95?p=v-96:p=v-64,L.underline=(p&1)===1,p<=13?L.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(p/2)]:p<=15?(L.italics=!0,L.color="white"):L.indent=Math.floor((p-16)/2)*4,L},h.parseChars=function(l,v){var p,L=null,O=null;if(l>=25?(p=2,O=l-8):(p=1,O=l),O>=17&&O<=19){var M;O===17?M=v+80:O===18?M=v+112:M=v+144,this.logger.log(x.INFO,"Special char '"+S(M)+"' in channel "+p),L=[M]}else l>=32&&l<=127&&(L=v===0?[l]:[l,v]);if(L){var F=y(L);this.logger.log(x.DEBUG,"Char codes = "+F.join(",")),t(l,v,this.cmdHistory)}return L},h.parseBackgroundAttributes=function(l,v){var p=(l===16||l===24)&&v>=32&&v<=47,L=(l===23||l===31)&&v>=45&&v<=47;if(!(p||L))return!1;var O,M={};l===16||l===24?(O=Math.floor((v-32)/2),M.background=D[O],v%2===1&&(M.background=M.background+"_semi")):v===45?M.background="transparent":(M.foreground="black",v===47&&(M.underline=!0));var F=l<=23?1:2,w=this.channels[F];return w.setBkgData(M),t(l,v,this.cmdHistory),!0},h.reset=function(){for(var l=0;l<Object.keys(this.channels).length;l++){var v=this.channels[l];v&&v.reset()}this.cmdHistory=c()},h.cueSplitAtTime=function(l){for(var v=0;v<this.channels.length;v++){var p=this.channels[v];p&&p.cueSplitAtTime(l)}},r}();function t(r,h,d){d.a=r,d.b=h}function u(r,h,d){return d.a===r&&d.b===h}function c(){return{a:null,b:null}}P.default=i},"./src/utils/codecs.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"isCodecType",function(){return m}),n.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 m(I,T){var b=R[T];return!!b&&b[I.slice(0,4)]===!0}function S(I,T){return MediaSource.isTypeSupported((T||"video")+'/mp4;codecs="'+I+'"')}},"./src/utils/cues.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/utils/vttparser.ts"),m=n("./src/utils/webvtt-parser.ts"),S=n("./src/utils/texttrack-utils.ts"),I=/\s/,T={newCue:function(_,E,A,D){for(var x=[],g,y,s,e,o,f=self.VTTCue||self.TextTrackCue,a=0;a<D.rows.length;a++)if(g=D.rows[a],s=!0,e=0,o="",!g.isEmpty()){for(var i=0;i<g.chars.length;i++)I.test(g.chars[i].uchar)&&s?e++:(o+=g.chars[i].uchar,s=!1);g.cueStartTime=E,E===A&&(A+=1e-4),e>=16?e--:e++;var t=Object(R.fixLineBreaks)(o.trim()),u=Object(m.generateCueId)(E,A,t);(!_||!_.cues||!_.cues.getCueById(u))&&(y=new f(E,A,t),y.id=u,y.line=a+1,y.align="left",y.position=10+Math.min(80,Math.floor(e*8/32)*10),x.push(y))}return _&&x.length&&(x.sort(function(c,r){return c.line==="auto"||r.line==="auto"?0:c.line>8&&r.line>8?r.line-c.line:c.line-r.line}),x.forEach(function(c){return Object(S.addCueToTrack)(_,c)})),x}};P.default=T},"./src/utils/discontinuities.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"findFirstFragWithCC",function(){return I}),n.d(P,"shouldAlignOnDiscontinuities",function(){return T}),n.d(P,"findDiscontinuousReferenceFrag",function(){return b}),n.d(P,"adjustSlidingStart",function(){return E}),n.d(P,"alignStream",function(){return A}),n.d(P,"alignPDT",function(){return x}),n.d(P,"alignFragmentByPDTDelta",function(){return g}),n.d(P,"alignMediaPlaylistByPDT",function(){return y});var R=n("./src/polyfills/number.ts"),m=n("./src/utils/logger.ts"),S=n("./src/controller/level-helper.ts");function I(s,e){for(var o=null,f=0,a=s.length;f<a;f++){var i=s[f];if(i&&i.cc===e){o=i;break}}return o}function T(s,e,o){return!!(e.details&&(o.endCC>o.startCC||s&&s.cc<o.startCC))}function b(s,e){var o=s.fragments,f=e.fragments;if(!f.length||!o.length){m.logger.log("No fragments to align");return}var a=I(o,f[0].cc);if(!a||a&&!a.startPTS){m.logger.log("No frag in previous level to align on");return}return a}function _(s,e){if(s){var o=s.start+e;s.start=s.startPTS=o,s.endPTS=o+s.duration}}function E(s,e){for(var o=e.fragments,f=0,a=o.length;f<a;f++)_(o[f],s);e.fragmentHint&&_(e.fragmentHint,s),e.alignedSliding=!0}function A(s,e,o){!e||(D(s,o,e),!o.alignedSliding&&e.details&&x(o,e.details),!o.alignedSliding&&e.details&&!o.skippedSegments&&Object(S.adjustSliding)(e.details,o))}function D(s,e,o){if(T(s,o,e)){var f=b(o.details,e);f&&Object(R.isFiniteNumber)(f.start)&&(m.logger.log("Adjusting PTS using last level due to CC increase within current level "+e.url),E(f.start,e))}}function x(s,e){if(!(!e.fragments.length||!s.hasProgramDateTime||!e.hasProgramDateTime)){var o=e.fragments[0].programDateTime,f=s.fragments[0].programDateTime,a=(f-o)/1e3+e.fragments[0].start;a&&Object(R.isFiniteNumber)(a)&&(m.logger.log("Adjusting PTS using programDateTime delta "+(f-o)+"ms, sliding:"+a.toFixed(3)+" "+s.url+" "),E(a,s))}}function g(s,e){var o=s.programDateTime;if(!!o){var f=(o-e)/1e3;s.start=s.startPTS=f,s.endPTS=f+s.duration}}function y(s,e){if(!(!e.fragments.length||!s.hasProgramDateTime||!e.hasProgramDateTime)){var o=e.fragments[0].programDateTime,f=e.fragments[0].start,a=o-f*1e3;s.fragments.forEach(function(i){g(i,a)}),s.fragmentHint&&g(s.fragmentHint,a),s.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/utils/ewma.ts"),m=function(){function S(T,b,_){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(b)}var I=S.prototype;return I.update=function(b,_){var E=this.slow_,A=this.fast_;this.slow_.halfLife!==b&&(this.slow_=new R.default(b,E.getEstimate(),E.getTotalWeight())),this.fast_.halfLife!==_&&(this.fast_=new R.default(_,A.getEstimate(),A.getTotalWeight()))},I.sample=function(b,_){b=Math.max(b,this.minDelayMs_);var E=8*_,A=b/1e3,D=E/A;this.fast_.sample(A,D),this.slow_.sample(A,D)},I.canEstimate=function(){var b=this.fast_;return b&&b.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=m},"./src/utils/ewma.ts":function(B,P,n){"use strict";n.r(P);var R=function(){function m(I,T,b){T===void 0&&(T=0),b===void 0&&(b=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_=T,this.totalWeight_=b}var S=m.prototype;return S.sample=function(T,b){var _=Math.pow(this.alpha_,T);this.estimate_=b*(1-_)+_*this.estimate_,this.totalWeight_+=T},S.getTotalWeight=function(){return this.totalWeight_},S.getEstimate=function(){if(this.alpha_){var T=1-Math.pow(this.alpha_,this.totalWeight_);if(T)return this.estimate_/T}return this.estimate_},m}();P.default=R},"./src/utils/fetch-loader.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"fetchSupported",function(){return g});var R=n("./src/polyfills/number.ts"),m=n("./src/loader/load-stats.ts"),S=n("./src/demux/chunk-cache.ts");function I(f,a){f.prototype=Object.create(a.prototype),f.prototype.constructor=f,A(f,a)}function T(f){var a=typeof Map=="function"?new Map:void 0;return T=function(t){if(t===null||!E(t))return t;if(typeof t!="function")throw new TypeError("Super expression must either be null or a function");if(typeof a!="undefined"){if(a.has(t))return a.get(t);a.set(t,u)}function u(){return b(t,arguments,D(this).constructor)}return u.prototype=Object.create(t.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),A(u,t)},T(f)}function b(f,a,i){return _()?b=Reflect.construct.bind():b=function(u,c,r){var h=[null];h.push.apply(h,c);var d=Function.bind.apply(u,h),l=new d;return r&&A(l,r.prototype),l},b.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 E(f){return Function.toString.call(f).indexOf("[native code]")!==-1}function A(f,a){return A=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,u){return t.__proto__=u,t},A(f,a)}function D(f){return D=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},D(f)}function x(){return x=Object.assign?Object.assign.bind():function(f){for(var a=1;a<arguments.length;a++){var i=arguments[a];for(var t in i)Object.prototype.hasOwnProperty.call(i,t)&&(f[t]=i[t])}return f},x.apply(this,arguments)}function g(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var y=function(){function f(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 m.LoadStats}var a=f.prototype;return a.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},a.abortInternal=function(){var t=this.response;(!t||!t.ok)&&(this.stats.aborted=!0,this.controller.abort())},a.abort=function(){var t;this.abortInternal(),(t=this.callbacks)!==null&&t!==void 0&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},a.load=function(t,u,c){var r=this,h=this.stats;if(h.loading.start)throw new Error("Loader can only be used once.");h.loading.start=self.performance.now();var d=s(t,this.controller.signal),l=c.onProgress,v=t.responseType==="arraybuffer",p=v?"byteLength":"length";this.context=t,this.config=u,this.callbacks=c,this.request=this.fetchSetup(t,d),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){r.abortInternal(),c.onTimeout(h,t,r.response)},u.timeout),self.fetch(this.request).then(function(L){if(r.response=r.loader=L,!L.ok){var O=L.status,M=L.statusText;throw new o(M||"fetch, bad network response",O,L)}return h.loading.first=Math.max(self.performance.now(),h.loading.start),h.total=parseInt(L.headers.get("Content-Length")||"0"),l&&Object(R.isFiniteNumber)(u.highWaterMark)?r.loadProgressively(L,h,t,u.highWaterMark,l):v?L.arrayBuffer():L.text()}).then(function(L){var O=r.response;self.clearTimeout(r.requestTimeout),h.loading.end=Math.max(self.performance.now(),h.loading.first),h.loaded=h.total=L[p];var M={url:O.url,data:L};l&&!Object(R.isFiniteNumber)(u.highWaterMark)&&l(h,t,L,O),c.onSuccess(M,h,t,O)}).catch(function(L){if(self.clearTimeout(r.requestTimeout),!h.aborted){var O=L&&L.code||0,M=L?L.message:null;c.onError({code:O,text:M},t,L?L.details:null)}})},a.getCacheAge=function(){var t=null;if(this.response){var u=this.response.headers.get("age");t=u?parseFloat(u):null}return t},a.loadProgressively=function(t,u,c,r,h){r===void 0&&(r=0);var d=new S.default,l=t.body.getReader(),v=function p(){return l.read().then(function(L){if(L.done)return d.dataLength&&h(u,c,d.flush(),t),Promise.resolve(new ArrayBuffer(0));var O=L.value,M=O.length;return u.loaded+=M,M<r||d.dataLength?(d.push(O),d.dataLength>=r&&h(u,c,d.flush(),t)):h(u,c,O,t),p()}).catch(function(){return Promise.reject()})};return v()},f}();function s(f,a){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:a,headers:new self.Headers(x({},f.headers))};return f.rangeEnd&&i.headers.set("Range","bytes="+f.rangeStart+"-"+String(f.rangeEnd-1)),i}function e(f,a){return new self.Request(f.url,a)}var o=function(f){I(a,f);function a(i,t,u){var c;return c=f.call(this,i)||this,c.code=void 0,c.details=void 0,c.code=t,c.details=u,c}return a}(T(Error));P.default=y},"./src/utils/imsc1-ttml-parser.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"IMSC1_CODEC",function(){return E}),n.d(P,"parseIMSC1",function(){return g});var R=n("./src/utils/mp4-tools.ts"),m=n("./src/utils/vttparser.ts"),S=n("./src/utils/vttcue.ts"),I=n("./src/demux/id3.ts"),T=n("./src/utils/timescale-conversion.ts"),b=n("./src/utils/webvtt-parser.ts");function _(){return _=Object.assign?Object.assign.bind():function(r){for(var h=1;h<arguments.length;h++){var d=arguments[h];for(var l in d)Object.prototype.hasOwnProperty.call(d,l)&&(r[l]=d[l])}return r},_.apply(this,arguments)}var E="stpp.ttml.im1t",A=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,D=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,x={left:"start",center:"center",right:"end",start:"start",end:"end"};function g(r,h,d,l,v){var p=Object(R.findBox)(new Uint8Array(r),["mdat"]);if(p.length===0){v(new Error("Could not parse IMSC1 mdat"));return}var L=p.map(function(M){return Object(I.utf8ArrayToStr)(M)}),O=Object(T.toTimescaleFromScale)(h,1,d);try{L.forEach(function(M){return l(y(M,O))})}catch(M){v(M)}}function y(r,h){var d=new DOMParser,l=d.parseFromString(r,"text/xml"),v=l.getElementsByTagName("tt")[0];if(!v)throw new Error("Invalid ttml");var p={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},L=Object.keys(p).reduce(function(C,k){return C[k]=v.getAttribute("ttp:"+k)||p[k],C},{}),O=v.getAttribute("xml:space")!=="preserve",M=e(s(v,"styling","style")),F=e(s(v,"layout","region")),w=s(v,"body","[begin]");return[].map.call(w,function(C){var k=o(C,O);if(!k||!C.hasAttribute("begin"))return null;var U=t(C.getAttribute("begin"),L),j=t(C.getAttribute("dur"),L),N=t(C.getAttribute("end"),L);if(U===null)throw i(C);if(N===null){if(j===null)throw i(C);N=U+j}var W=new S.default(U-h,N-h,k);W.id=Object(b.generateCueId)(W.startTime,W.endTime,W.text);var Y=F[C.getAttribute("region")],K=M[C.getAttribute("style")];W.position=10,W.size=80;var H=f(Y,K,M),z=H.textAlign;if(z){var $=x[z];$&&(W.lineAlign=$),W.align=z}return _(W,H),W}).filter(function(C){return C!==null})}function s(r,h,d){var l=r.getElementsByTagName(h)[0];return l?[].slice.call(l.querySelectorAll(d)):[]}function e(r){return r.reduce(function(h,d){var l=d.getAttribute("xml:id");return l&&(h[l]=d),h},{})}function o(r,h){return[].slice.call(r.childNodes).reduce(function(d,l,v){var p;return l.nodeName==="br"&&v?d+`
|
|
20
|
+
`:(p=l.childNodes)!==null&&p!==void 0&&p.length?o(l,h):h?d+l.textContent.trim().replace(/\s+/g," "):d+l.textContent},"")}function f(r,h,d){var l="http://www.w3.org/ns/ttml#styling",v=null,p=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],L=r!=null&&r.hasAttribute("style")?r.getAttribute("style"):null;return L&&d.hasOwnProperty(L)&&(v=d[L]),p.reduce(function(O,M){var F=a(h,l,M)||a(r,l,M)||a(v,l,M);return F&&(O[M]=F),O},{})}function a(r,h,d){return r&&r.hasAttributeNS(h,d)?r.getAttributeNS(h,d):null}function i(r){return new Error("Could not parse ttml timestamp "+r)}function t(r,h){if(!r)return null;var d=Object(m.parseTimeStamp)(r);return d===null&&(A.test(r)?d=u(r,h):D.test(r)&&(d=c(r,h))),d}function u(r,h){var d=A.exec(r),l=(d[4]|0)+(d[5]|0)/h.subFrameRate;return(d[1]|0)*3600+(d[2]|0)*60+(d[3]|0)+l/h.frameRate}function c(r,h){var d=D.exec(r),l=Number(d[1]),v=d[2];switch(v){case"h":return l*3600;case"m":return l*60;case"ms":return l*1e3;case"f":return l/h.frameRate;case"t":return l/h.tickRate}return l}},"./src/utils/logger.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"enableLogs",function(){return b}),n.d(P,"logger",function(){return _});var R=function(){},m={trace:R,debug:R,log:R,warn:R,info:R,error:R},S=m;function I(E){var A=self.console[E];return A?A.bind(self.console,"["+E+"] >"):R}function T(E){for(var A=arguments.length,D=new Array(A>1?A-1:0),x=1;x<A;x++)D[x-1]=arguments[x];D.forEach(function(g){S[g]=E[g]?E[g].bind(E):I(g)})}function b(E){if(self.console&&E===!0||typeof E=="object"){T(E,"debug","log","info","warn","error");try{S.log()}catch{S=m}}else S=m}var _=S},"./src/utils/mediakeys-helper.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"KeySystems",function(){return R}),n.d(P,"requestMediaKeySystemAccess",function(){return m});var R;(function(S){S.WIDEVINE="com.widevine.alpha",S.PLAYREADY="com.microsoft.playready"})(R||(R={}));var m=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"getMediaSource",function(){return R});function R(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"RemuxerTrackIdConfig",function(){return b}),n.d(P,"bin2str",function(){return _}),n.d(P,"readUint16",function(){return E}),n.d(P,"readUint32",function(){return A}),n.d(P,"readSint32",function(){return D}),n.d(P,"writeUint32",function(){return x}),n.d(P,"findBox",function(){return g}),n.d(P,"parseSegmentIndex",function(){return y}),n.d(P,"parseInitSegment",function(){return s}),n.d(P,"getStartDTS",function(){return e}),n.d(P,"getDuration",function(){return o}),n.d(P,"computeRawDurationFromSamples",function(){return f}),n.d(P,"offsetStartDTS",function(){return a}),n.d(P,"segmentValidRange",function(){return i}),n.d(P,"appendUint8Array",function(){return t}),n.d(P,"parseSamples",function(){return u}),n.d(P,"parseSEIMessageFromNALu",function(){return h}),n.d(P,"parseEmsg",function(){return l});var R=n("./src/utils/typed-array.ts"),m=n("./src/loader/fragment.ts"),S=n("./src/demux/id3.ts"),I=Math.pow(2,32)-1,T=[].push,b={video:1,audio:2,id3:3,text:4};function _(v){return String.fromCharCode.apply(null,v)}function E(v,p){var L=v[p]<<8|v[p+1];return L<0?65536+L:L}function A(v,p){var L=D(v,p);return L<0?4294967296+L:L}function D(v,p){return v[p]<<24|v[p+1]<<16|v[p+2]<<8|v[p+3]}function x(v,p,L){v[p]=L>>24,v[p+1]=L>>16&255,v[p+2]=L>>8&255,v[p+3]=L&255}function g(v,p){var L=[];if(!p.length)return L;for(var O=v.byteLength,M=0;M<O;){var F=A(v,M),w=_(v.subarray(M+4,M+8)),C=F>1?M+F:O;if(w===p[0])if(p.length===1)L.push(v.subarray(M+8,C));else{var k=g(v.subarray(M+8,C),p.slice(1));k.length&&T.apply(L,k)}M=C}return L}function y(v){var p=[],L=v[0],O=8,M=A(v,O);O+=4;var F=0,w=0;L===0?O+=8:O+=16,O+=2;var C=v.length+w,k=E(v,O);O+=2;for(var U=0;U<k;U++){var j=O,N=A(v,j);j+=4;var W=N&2147483647,Y=(N&2147483648)>>>31;if(Y===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var K=A(v,j);j+=4,p.push({referenceSize:W,subsegmentDuration:K,info:{duration:K/M,start:C,end:C+W-1}}),C+=W,j+=4,O=j}return{earliestPresentationTime:F,timescale:M,version:L,referencesCount:k,references:p}}function s(v){for(var p=[],L=g(v,["moov","trak"]),O=0;O<L.length;O++){var M=L[O],F=g(M,["tkhd"])[0];if(F){var w=F[0],C=w===0?12:20,k=A(F,C),U=g(M,["mdia","mdhd"])[0];if(U){w=U[0],C=w===0?12:20;var j=A(U,C),N=g(M,["mdia","hdlr"])[0];if(N){var W=_(N.subarray(8,12)),Y={soun:m.ElementaryStreamTypes.AUDIO,vide:m.ElementaryStreamTypes.VIDEO}[W];if(Y){var K=g(M,["mdia","minf","stbl","stsd"])[0],H=void 0;K&&(H=_(K.subarray(12,16))),p[k]={timescale:j,type:Y},p[Y]={timescale:j,id:k,codec:H}}}}}}var z=g(v,["moov","mvex","trex"]);return z.forEach(function($){var X=A($,4),J=p[X];J&&(J.default={duration:A($,12),flags:A($,20)})}),p}function e(v,p){return g(p,["moof","traf"]).reduce(function(L,O){var M=g(O,["tfdt"])[0],F=M[0],w=g(O,["tfhd"]).reduce(function(C,k){var U=A(k,4),j=v[U];if(j){var N=A(M,4);F===1&&(N*=Math.pow(2,32),N+=A(M,8));var W=j.timescale||9e4,Y=N/W;if(isFinite(Y)&&(C===null||Y<C))return Y}return C},null);return w!==null&&isFinite(w)&&(L===null||w<L)?w:L},null)||0}function o(v,p){for(var L=0,O=0,M=0,F=g(v,["moof","traf"]),w=0;w<F.length;w++){var C=F[w],k=g(C,["tfhd"])[0],U=A(k,4),j=p[U];if(!!j){var N=j.default,W=A(k,0)|(N==null?void 0:N.flags),Y=N==null?void 0:N.duration;W&8&&(W&2?Y=A(k,12):Y=A(k,8));for(var K=j.timescale||9e4,H=g(C,["trun"]),z=0;z<H.length;z++){if(L=f(H[z]),!L&&Y){var $=A(H[z],4);L=Y*$}j.type===m.ElementaryStreamTypes.VIDEO?O+=L/K:j.type===m.ElementaryStreamTypes.AUDIO&&(M+=L/K)}}}if(O===0&&M===0){for(var X=0,J=g(v,["sidx"]),te=0;te<J.length;te++){var Q=y(J[te]);Q!=null&&Q.references&&(X+=Q.references.reduce(function(ae,se){return ae+se.info.duration||0},0))}return X}return O||M}function f(v){var p=A(v,0),L=8;p&1&&(L+=4),p&4&&(L+=4);for(var O=0,M=A(v,4),F=0;F<M;F++){if(p&256){var w=A(v,L);O+=w,L+=4}p&512&&(L+=4),p&1024&&(L+=4),p&2048&&(L+=4)}return O}function a(v,p,L){g(p,["moof","traf"]).forEach(function(O){g(O,["tfhd"]).forEach(function(M){var F=A(M,4),w=v[F];if(!!w){var C=w.timescale||9e4;g(O,["tfdt"]).forEach(function(k){var U=k[0],j=A(k,4);if(U===0)j-=L*C,j=Math.max(j,0),x(k,4,j);else{j*=Math.pow(2,32),j+=A(k,8),j-=L*C,j=Math.max(j,0);var N=Math.floor(j/(I+1)),W=Math.floor(j%(I+1));x(k,4,N),x(k,8,W)}})}})})}function i(v){var p={valid:null,remainder:null},L=g(v,["moof"]);if(L){if(L.length<2)return p.remainder=v,p}else return p;var O=L[L.length-1];return p.valid=Object(R.sliceUint8)(v,0,O.byteOffset-8),p.remainder=Object(R.sliceUint8)(v,O.byteOffset-8),p}function t(v,p){var L=new Uint8Array(v.length+p.length);return L.set(v),L.set(p,v.length),L}function u(v,p){var L=[],O=p.samples,M=p.timescale,F=p.id,w=!1,C=g(O,["moof"]);return C.map(function(k){var U=k.byteOffset-8,j=g(k,["traf"]);j.map(function(N){var W=g(N,["tfdt"]).map(function(Y){var K=Y[0],H=A(Y,4);return K===1&&(H*=Math.pow(2,32),H+=A(Y,8)),H/M})[0];return W!==void 0&&(v=W),g(N,["tfhd"]).map(function(Y){var K=A(Y,4),H=A(Y,0)&16777215,z=(H&1)!==0,$=(H&2)!==0,X=(H&8)!==0,J=0,te=(H&16)!==0,Q=0,ae=(H&32)!==0,se=8;K===F&&(z&&(se+=8),$&&(se+=4),X&&(J=A(Y,se),se+=4),te&&(Q=A(Y,se),se+=4),ae&&(se+=4),p.type==="video"&&(w=c(p.codec)),g(N,["trun"]).map(function(re){var ee=re[0],Z=A(re,0)&16777215,q=(Z&1)!==0,fe=0,ge=(Z&4)!==0,ie=(Z&256)!==0,me=0,ye=(Z&512)!==0,Te=0,oe=(Z&1024)!==0,de=(Z&2048)!==0,Se=0,Ee=A(re,4),Ae=8;q&&(fe=A(re,Ae),Ae+=4),ge&&(Ae+=4);for(var be=fe+U,Me=0;Me<Ee;Me++){if(ie?(me=A(re,Ae),Ae+=4):me=J,ye?(Te=A(re,Ae),Ae+=4):Te=Q,oe&&(Ae+=4),de&&(ee===0?Se=A(re,Ae):Se=D(re,Ae),Ae+=4),p.type===m.ElementaryStreamTypes.VIDEO)for(var De=0;De<Te;){var xe=A(O,be);be+=4;var G=O[be]&31;if(r(w,G)){var V=O.subarray(be,be+xe);h(V,v+Se/M,L)}be+=xe,De+=xe+4}v+=me/M}}))})})}),L}function c(v){if(!v)return!1;var p=v.indexOf("."),L=p<0?v:v.substring(0,p);return L==="hvc1"||L==="hev1"||L==="dvh1"||L==="dvhe"}function r(v,p){return v?p===39||p===40:p===6}function h(v,p,L){var O=d(v),M=0;M++;for(var F=0,w=0,C=!1,k=0;M<O.length;){F=0;do{if(M>=O.length)break;k=O[M++],F+=k}while(k===255);w=0;do{if(M>=O.length)break;k=O[M++],w+=k}while(k===255);var U=O.length-M;if(!C&&F===4&&M<O.length){C=!0;var j=O[M++];if(j===181){var N=E(O,M);if(M+=2,N===49){var W=A(O,M);if(M+=4,W===1195456820){var Y=O[M++];if(Y===3){var K=O[M++],H=31&K,z=64&K,$=z?2+H*3:0,X=new Uint8Array($);if(z){X[0]=K;for(var J=1;J<$;J++)X[J]=O[M++]}L.push({type:Y,payloadType:F,pts:p,bytes:X})}}}}}else if(F===5&&w<U){if(C=!0,w>16){for(var te=[],Q=0;Q<16;Q++){var ae=O[M++].toString(16);te.push(ae.length==1?"0"+ae:ae),(Q===3||Q===5||Q===7||Q===9)&&te.push("-")}for(var se=w-16,re=new Uint8Array(se),ee=0;ee<se;ee++)re[ee]=O[M++];L.push({payloadType:F,pts:p,uuid:te.join(""),userData:Object(S.utf8ArrayToStr)(re),userDataBytes:re})}}else if(w<U)M+=w;else if(w>U)break}}function d(v){for(var p=v.byteLength,L=[],O=1;O<p-2;)v[O]===0&&v[O+1]===0&&v[O+2]===3?(L.push(O+2),O+=2):O++;if(L.length===0)return v;var M=p-L.length,F=new Uint8Array(M),w=0;for(O=0;O<M;w++,O++)w===L[0]&&(w++,L.shift()),F[O]=v[w];return F}function l(v){var p=v[0],L="",O="",M=0,F=0,w=0,C=0,k=0,U=0;if(p===0){for(;_(v.subarray(U,U+1))!=="\0";)L+=_(v.subarray(U,U+1)),U+=1;for(L+=_(v.subarray(U,U+1)),U+=1;_(v.subarray(U,U+1))!=="\0";)O+=_(v.subarray(U,U+1)),U+=1;O+=_(v.subarray(U,U+1)),U+=1,M=A(v,12),F=A(v,16),C=A(v,20),k=A(v,24),U=28}else if(p===1){U+=4,M=A(v,U),U+=4;var j=A(v,U);U+=4;var N=A(v,U);for(U+=4,w=Math.pow(2,32)*j+N,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=A(v,U),U+=4,k=A(v,U),U+=4;_(v.subarray(U,U+1))!=="\0";)L+=_(v.subarray(U,U+1)),U+=1;for(L+=_(v.subarray(U,U+1)),U+=1;_(v.subarray(U,U+1))!=="\0";)O+=_(v.subarray(U,U+1)),U+=1;O+=_(v.subarray(U,U+1)),U+=1}var W=v.subarray(U,v.byteLength);return{schemeIdUri:L,value:O,timeScale:M,presentationTime:w,presentationTimeDelta:F,eventDuration:C,id:k,payload:W}}},"./src/utils/output-filter.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return R});var R=function(){function m(I,T){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=I,this.trackName=T}var S=m.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(T,b,_){(this.startTime===null||this.startTime>T)&&(this.startTime=T),this.endTime=b,this.screen=_,this.timelineController.createCaptionsTrack(this.trackName)},S.reset=function(){this.cueRanges=[],this.startTime=null},m}()},"./src/utils/texttrack-utils.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"sendAddTrackEvent",function(){return m}),n.d(P,"addCueToTrack",function(){return S}),n.d(P,"clearCurrentCues",function(){return I}),n.d(P,"removeCuesInRange",function(){return T}),n.d(P,"getCuesInRange",function(){return _});var R=n("./src/utils/logger.ts");function m(E,A){var D;try{D=new Event("addtrack")}catch{D=document.createEvent("Event"),D.initEvent("addtrack",!1,!1)}D.track=E,A.dispatchEvent(D)}function S(E,A){var D=E.mode;if(D==="disabled"&&(E.mode="hidden"),E.cues&&!E.cues.getCueById(A.id))try{if(E.addCue(A),!E.cues.getCueById(A.id))throw new Error("addCue is failed for: "+A)}catch(g){R.logger.debug("[texttrack-utils]: "+g);var x=new self.TextTrackCue(A.startTime,A.endTime,A.text);x.id=A.id,E.addCue(x)}D==="disabled"&&(E.mode=D)}function I(E){var A=E.mode;if(A==="disabled"&&(E.mode="hidden"),E.cues)for(var D=E.cues.length;D--;)E.removeCue(E.cues[D]);A==="disabled"&&(E.mode=A)}function T(E,A,D,x){var g=E.mode;if(g==="disabled"&&(E.mode="hidden"),E.cues&&E.cues.length>0)for(var y=_(E.cues,A,D),s=0;s<y.length;s++)(!x||x(y[s]))&&E.removeCue(y[s]);g==="disabled"&&(E.mode=g)}function b(E,A){if(A<E[0].startTime)return 0;var D=E.length-1;if(A>E[D].endTime)return-1;for(var x=0,g=D;x<=g;){var y=Math.floor((g+x)/2);if(A<E[y].startTime)g=y-1;else if(A>E[y].startTime&&x<D)x=y+1;else return y}return E[x].startTime-A<A-E[g].startTime?x:g}function _(E,A,D){var x=[],g=b(E,A);if(g>-1)for(var y=g,s=E.length;y<s;y++){var e=E[y];if(e.startTime>=A&&e.endTime<=D)x.push(e);else if(e.startTime>D)return x}return x}},"./src/utils/time-ranges.ts":function(B,P,n){"use strict";n.r(P);var R={toString:function(S){for(var I="",T=S.length,b=0;b<T;b++)I+="["+S.start(b).toFixed(3)+","+S.end(b).toFixed(3)+"]";return I}};P.default=R},"./src/utils/timescale-conversion.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"toTimescaleFromBase",function(){return m}),n.d(P,"toTimescaleFromScale",function(){return S}),n.d(P,"toMsFromMpegTsClock",function(){return I}),n.d(P,"toMpegTsClockFromTimescale",function(){return T});var R=9e4;function m(b,_,E,A){E===void 0&&(E=1),A===void 0&&(A=!1);var D=b*_*E;return A?Math.round(D):D}function S(b,_,E,A){return E===void 0&&(E=1),A===void 0&&(A=!1),m(b,_,1/E,A)}function I(b,_){return _===void 0&&(_=!1),m(b,1e3,1/R,_)}function T(b,_){return _===void 0&&(_=1),m(b,R,1/_)}},"./src/utils/typed-array.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"sliceUint8",function(){return R});function R(m,S,I){return Uint8Array.prototype.slice?m.slice(S,I):new Uint8Array(Array.prototype.slice.call(m,S,I))}},"./src/utils/vttcue.ts":function(B,P,n){"use strict";n.r(P),P.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var R=["","lr","rl"],m=["start","middle","end","left","right"];function S(E,A){if(typeof A!="string"||!Array.isArray(E))return!1;var D=A.toLowerCase();return~E.indexOf(D)?D:!1}function I(E){return S(R,E)}function T(E){return S(m,E)}function b(E){for(var A=arguments.length,D=new Array(A>1?A-1:0),x=1;x<A;x++)D[x-1]=arguments[x];for(var g=1;g<arguments.length;g++){var y=arguments[g];for(var s in y)E[s]=y[s]}return E}function _(E,A,D){var x=this,g={enumerable:!0};x.hasBeenReset=!1;var y="",s=!1,e=E,o=A,f=D,a=null,i="",t=!0,u="auto",c="start",r=50,h="middle",d=50,l="middle";Object.defineProperty(x,"id",b({},g,{get:function(){return y},set:function(p){y=""+p}})),Object.defineProperty(x,"pauseOnExit",b({},g,{get:function(){return s},set:function(p){s=!!p}})),Object.defineProperty(x,"startTime",b({},g,{get:function(){return e},set:function(p){if(typeof p!="number")throw new TypeError("Start time must be set to a number.");e=p,this.hasBeenReset=!0}})),Object.defineProperty(x,"endTime",b({},g,{get:function(){return o},set:function(p){if(typeof p!="number")throw new TypeError("End time must be set to a number.");o=p,this.hasBeenReset=!0}})),Object.defineProperty(x,"text",b({},g,{get:function(){return f},set:function(p){f=""+p,this.hasBeenReset=!0}})),Object.defineProperty(x,"region",b({},g,{get:function(){return a},set:function(p){a=p,this.hasBeenReset=!0}})),Object.defineProperty(x,"vertical",b({},g,{get:function(){return i},set:function(p){var L=I(p);if(L===!1)throw new SyntaxError("An invalid or illegal string was specified.");i=L,this.hasBeenReset=!0}})),Object.defineProperty(x,"snapToLines",b({},g,{get:function(){return t},set:function(p){t=!!p,this.hasBeenReset=!0}})),Object.defineProperty(x,"line",b({},g,{get:function(){return u},set:function(p){if(typeof p!="number"&&p!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");u=p,this.hasBeenReset=!0}})),Object.defineProperty(x,"lineAlign",b({},g,{get:function(){return c},set:function(p){var L=T(p);if(!L)throw new SyntaxError("An invalid or illegal string was specified.");c=L,this.hasBeenReset=!0}})),Object.defineProperty(x,"position",b({},g,{get:function(){return r},set:function(p){if(p<0||p>100)throw new Error("Position must be between 0 and 100.");r=p,this.hasBeenReset=!0}})),Object.defineProperty(x,"positionAlign",b({},g,{get:function(){return h},set:function(p){var L=T(p);if(!L)throw new SyntaxError("An invalid or illegal string was specified.");h=L,this.hasBeenReset=!0}})),Object.defineProperty(x,"size",b({},g,{get:function(){return d},set:function(p){if(p<0||p>100)throw new Error("Size must be between 0 and 100.");d=p,this.hasBeenReset=!0}})),Object.defineProperty(x,"align",b({},g,{get:function(){return l},set:function(p){var L=T(p);if(!L)throw new SyntaxError("An invalid or illegal string was specified.");l=L,this.hasBeenReset=!0}})),x.displayState=void 0}return _.prototype.getCueAsHTML=function(){var E=self.WebVTT;return E.convertCueToDOMTree(self,this.text)},_}()},"./src/utils/vttparser.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"parseTimeStamp",function(){return S}),n.d(P,"fixLineBreaks",function(){return A}),n.d(P,"VTTParser",function(){return D});var R=n("./src/utils/vttcue.ts"),m=function(){function x(){}var g=x.prototype;return g.decode=function(s,e){if(!s)return"";if(typeof s!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(s))},x}();function S(x){function g(s,e,o,f){return(s|0)*3600+(e|0)*60+(o|0)+parseFloat(f||0)}var y=x.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return y?parseFloat(y[2])>59?g(y[2],y[3],0,y[4]):g(y[1],y[2],y[3],y[4]):null}var I=function(){function x(){this.values=Object.create(null)}var g=x.prototype;return g.set=function(s,e){!this.get(s)&&e!==""&&(this.values[s]=e)},g.get=function(s,e,o){return o?this.has(s)?this.values[s]:e[o]:this.has(s)?this.values[s]:e},g.has=function(s){return s in this.values},g.alt=function(s,e,o){for(var f=0;f<o.length;++f)if(e===o[f]){this.set(s,e);break}},g.integer=function(s,e){/^-?\d+$/.test(e)&&this.set(s,parseInt(e,10))},g.percent=function(s,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){var o=parseFloat(e);if(o>=0&&o<=100)return this.set(s,o),!0}return!1},x}();function T(x,g,y,s){var e=s?x.split(s):[x];for(var o in e)if(typeof e[o]=="string"){var f=e[o].split(y);if(f.length===2){var a=f[0],i=f[1];g(a,i)}}}var b=new R.default(0,0,""),_=b.align==="middle"?"middle":"center";function E(x,g,y){var s=x;function e(){var a=S(x);if(a===null)throw new Error("Malformed timestamp: "+s);return x=x.replace(/^[^\sa-zA-Z-]+/,""),a}function o(a,i){var t=new I;T(a,function(r,h){var d;switch(r){case"region":for(var l=y.length-1;l>=0;l--)if(y[l].id===h){t.set(r,y[l].region);break}break;case"vertical":t.alt(r,h,["rl","lr"]);break;case"line":d=h.split(","),t.integer(r,d[0]),t.percent(r,d[0])&&t.set("snapToLines",!1),t.alt(r,d[0],["auto"]),d.length===2&&t.alt("lineAlign",d[1],["start",_,"end"]);break;case"position":d=h.split(","),t.percent(r,d[0]),d.length===2&&t.alt("positionAlign",d[1],["start",_,"end","line-left","line-right","auto"]);break;case"size":t.percent(r,h);break;case"align":t.alt(r,h,["start",_,"end","left","right"]);break}},/:/,/\s/),i.region=t.get("region",null),i.vertical=t.get("vertical","");var u=t.get("line","auto");u==="auto"&&b.line===-1&&(u=-1),i.line=u,i.lineAlign=t.get("lineAlign","start"),i.snapToLines=t.get("snapToLines",!0),i.size=t.get("size",100),i.align=t.get("align",_);var c=t.get("position","auto");c==="auto"&&b.position===50&&(c=i.align==="start"||i.align==="left"?0:i.align==="end"||i.align==="right"?100:50),i.position=c}function f(){x=x.replace(/^\s+/,"")}if(f(),g.startTime=e(),f(),x.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+s);x=x.slice(3),f(),g.endTime=e(),f(),o(x,g)}function A(x){return x.replace(/<br(?: \/)?>/gi,`
|
|
21
|
+
`)}var D=function(){function x(){this.state="INITIAL",this.buffer="",this.decoder=new m,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var g=x.prototype;return g.parse=function(s){var e=this;s&&(e.buffer+=e.decoder.decode(s,{stream:!0}));function o(){var c=e.buffer,r=0;for(c=A(c);r<c.length&&c[r]!=="\r"&&c[r]!==`
|
|
22
22
|
`;)++r;var h=c.slice(0,r);return c[r]==="\r"&&++r,c[r]===`
|
|
23
|
-
`&&++r,e.buffer=c.slice(r),h}function f(c){
|
|
23
|
+
`&&++r,e.buffer=c.slice(r),h}function f(c){T(c,function(r,h){},/:/)}try{var a="";if(e.state==="INITIAL"){if(!/\r\n|\n/.test(e.buffer))return this;a=o();var i=a.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:a=o(),e.state){case"HEADER":/:/.test(a)?f(a):a||(e.state="ID");continue;case"NOTE":a||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(a)){e.state="NOTE";break}if(!a)continue;if(e.cue=new R.default(0,0,""),e.state="CUE",a.indexOf("-->")===-1){e.cue.id=a;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{E(a,e.cue,e.regionList)}catch{e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":{var u=a.indexOf("-->")!==-1;if(!a||u&&(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
24
|
`),e.cue.text+=a}continue;case"BADCUE":a||(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 s=this;try{if((s.cue||s.state==="HEADER")&&(s.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},x}()},"./src/utils/webvtt-parser.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"generateCueId",function(){return D}),n.d(P,"parseWebVTT",function(){return g});var R=n("./src/polyfills/number.ts"),
|
|
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},x}()},"./src/utils/webvtt-parser.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"generateCueId",function(){return D}),n.d(P,"parseWebVTT",function(){return g});var R=n("./src/polyfills/number.ts"),m=n("./src/utils/vttparser.ts"),S=n("./src/demux/id3.ts"),I=n("./src/utils/timescale-conversion.ts"),T=n("./src/remux/mp4-remuxer.ts"),b=/\r\n|\n\r|\n|\r/g,_=function(s,e,o){return o===void 0&&(o=0),s.slice(o,o+e.length)===e},E=function(s){var e=parseInt(s.slice(-3)),o=parseInt(s.slice(-6,-4)),f=parseInt(s.slice(-9,-7)),a=s.length>9?parseInt(s.substring(0,s.indexOf(":"))):0;if(!Object(R.isFiniteNumber)(e)||!Object(R.isFiniteNumber)(o)||!Object(R.isFiniteNumber)(f)||!Object(R.isFiniteNumber)(a))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+s);return e+=1e3*o,e+=60*1e3*f,e+=60*60*1e3*a,e},A=function(s){for(var e=5381,o=s.length;o;)e=e*33^s.charCodeAt(--o);return(e>>>0).toString()};function D(y,s,e){return A(y.toString())+A(s.toString())+A(e)}var x=function(s,e,o){var f=s[e],a=s[f.prevCC];if(!a||!a.new&&f.new){s.ccOffset=s.presentationOffset=f.start,f.new=!1;return}for(;(i=a)!==null&&i!==void 0&&i.new;){var i;s.ccOffset+=f.start-a.start,f.new=!1,f=a,a=s[f.prevCC]}s.presentationOffset=o};function g(y,s,e,o,f,a,i,t){var u=new m.VTTParser,c=Object(S.utf8ArrayToStr)(new Uint8Array(y)).trim().replace(b,`
|
|
27
27
|
`).split(`
|
|
28
|
-
`),r=[],h=Object(I.toMpegTsClockFromTimescale)(s,e),d="00:00.000",l=0,v=0,
|
|
29
|
-
`)}),u.flush()}},"./src/utils/xhr-loader.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/utils/logger.ts"),p=n("./src/loader/load-stats.ts"),T=/^age:\s*[\d.]+\s*$/m,I=function(){function S(_){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 p.LoadStats,this.retryDelay=0}var O=S.prototype;return O.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},O.abortInternal=function(){var E=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),E&&(E.onreadystatechange=null,E.onprogress=null,E.readyState!==4&&(this.stats.aborted=!0,E.abort()))},O.abort=function(){var E;this.abortInternal(),(E=this.callbacks)!==null&&E!==void 0&&E.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},O.load=function(E,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=E,this.config=A,this.callbacks=D,this.retryDelay=A.retryDelay,this.loadInternal()},O.loadInternal=function(){var E=this.config,A=this.context;if(!!E){var D=this.loader=new self.XMLHttpRequest,x=this.stats;x.loading.first=0,x.loaded=0;var g=this.xhrSetup;try{if(g)try{g(D,A.url)}catch{D.open("GET",A.url,!0),g(D,A.url)}D.readyState||D.open("GET",A.url,!0);var y=this.context.headers;if(y)for(var s in y)D.setRequestHeader(s,y[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),E.timeout),D.send()}},O.readystatechange=function(){var E=this.context,A=this.loader,D=this.stats;if(!(!E||!A)){var x=A.readyState,g=this.config;if(!D.aborted&&x>=2)if(self.clearTimeout(this.requestTimeout),D.loading.first===0&&(D.loading.first=Math.max(self.performance.now(),D.loading.start)),x===4){A.onreadystatechange=null,A.onprogress=null;var y=A.status;if(y>=200&&y<300){D.loading.end=Math.max(self.performance.now(),D.loading.first);var s,e;if(E.responseType==="arraybuffer"?(s=A.response,e=s.byteLength):(s=A.responseText,e=s.length),D.loaded=D.total=e,!this.callbacks)return;var o=this.callbacks.onProgress;if(o&&o(D,E,s,A),!this.callbacks)return;var f={url:A.responseURL,data:s};this.callbacks.onSuccess(f,D,E,A)}else D.retry>=g.maxRetry||y>=400&&y<499?(R.logger.error(y+" while loading "+E.url),this.callbacks.onError({code:y,text:A.statusText},E,A)):(R.logger.warn(y+" while loading "+E.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),D.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),g.timeout)}},O.loadtimeout=function(){R.logger.warn("timeout while loading "+this.context.url);var E=this.callbacks;E&&(this.abortInternal(),E.onTimeout(this.stats,this.context,this.loader))},O.loadprogress=function(E){var A=this.stats;A.loaded=E.loaded,E.lengthComputable&&(A.total=E.total)},O.getCacheAge=function(){var E=null;if(this.loader&&T.test(this.loader.getAllResponseHeaders())){var A=this.loader.getResponseHeader("age");E=A?parseFloat(A):null}return E},S}();P.default=I}}).default})});var Xe=class{addEventListener(){}removeEventListener(){}dispatchEvent(P){return!0}};if(typeof DocumentFragment=="undefined"){class B extends Xe{}globalThis.DocumentFragment=B}var st=class extends Xe{},bt=class extends Xe{},wr={get(B){},define(B,P,n){},upgrade(B){},whenDefined(B){return Promise.resolve(st)}},ot,Rt=class{constructor(P,n={}){ve(this,ot,void 0);Pe(this,ot,n==null?void 0:n.detail)}get detail(){return ne(this,ot)}initCustomEvent(){}};ot=new WeakMap;function Ur(B,P){return new st}var $t={document:{createElement:Ur},DocumentFragment,customElements:wr,CustomEvent:Rt,EventTarget:Xe,HTMLElement:st,HTMLVideoElement:bt},Jt=typeof window=="undefined"||typeof globalThis.customElements=="undefined",we=Jt?$t:globalThis,Pt=Jt?$t.document:globalThis.document;var jt=yt(Zt(),1),Ge=yt(Tt(),1),wt=yt(Tt(),1),Qe=yt(Tt(),1),$e=(B,P,n,R)=>{B.addEventListener(P,n,R),B.addEventListener("teardown",()=>{B.removeEventListener(P,n)},{once:!0})},nr=(B,P)=>B in P;function kr(B,P,n){P&&n>P&&(n=P);for(let R=0;R<B.length;R++)if(B.start(R)<=n&&B.end(R)>=n)return!0;return!1}var Ut={ANY:"any",MUTED:"muted"},Br=Object.values(Ut),qt=B=>typeof B=="boolean"||typeof B=="string"&&Br.includes(B),ar=(B,P,n)=>{let R=!1,p=!1,T=qt(P)?P:!!P,I=()=>{R||$e(B,"playing",()=>{R=!0},{once:!0})};if(I(),$e(B,"loadstart",()=>{R=!1,I(),Ct(B,T)},{once:!0}),$e(B,"loadstart",()=>{n||(p=!Number.isFinite(B.duration)),Ct(B,T)},{once:!0}),n&&n.once(wt.default.Events.LEVEL_LOADED,(S,O)=>{var _;p=(_=O.details.live)!=null?_:!1}),!T){let S=()=>{!p||(n!=null&&n.liveSyncPosition?B.currentTime=n.liveSyncPosition:Number.isFinite(B.seekable.end(0))&&(B.currentTime=B.seekable.end(0)))};n&&$e(B,"play",()=>{B.preload==="metadata"?n.once(wt.default.Events.LEVEL_UPDATED,S):S()},{once:!0})}return S=>{R||(T=qt(S)?S:!!S,Ct(B,T))}},Ct=(B,P)=>{if(!P)return;let n=B.muted,R=()=>B.muted=n;switch(P){case Ut.ANY:B.play().catch(p=>{B.muted=!0,B.play().catch(R)});break;case Ut.MUTED:B.muted=!0,B.play().catch(R);break;default:B.play().catch(()=>{});break}},ut=class extends Error{constructor(B,P=ut.MEDIA_ERR_CUSTOM,n){var R;super(B),this.name="MediaError",this.code=P,this.fatal=n!=null?n:P>=ut.MEDIA_ERR_NETWORK&&P<=ut.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(R=ut.defaultMessages[this.code])!=null?R:"")}},Fe=ut;Fe.MEDIA_ERR_ABORTED=1,Fe.MEDIA_ERR_NETWORK=2,Fe.MEDIA_ERR_DECODE=3,Fe.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Fe.MEDIA_ERR_ENCRYPTED=5,Fe.MEDIA_ERR_CUSTOM=100,Fe.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."};function Nr(B,P){P.on(Qe.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(p,{tracks:T})=>{T.forEach(I=>{var S;let O=(S=I.subtitleTrack)!=null?S:I.closedCaptions,_=P.subtitleTracks.findIndex(({lang:E,name:A,type:D})=>E==(O==null?void 0:O.lang)&&A===I.label&&D.toLowerCase()===I.kind);jr(B,I.kind,I.label,O==null?void 0:O.lang,`${I.kind}${_}`)})});let n=()=>{var p;if(!P.subtitleTracks.length)return;let T=Array.from(B.textTracks).find(S=>S.id&&S.mode==="showing"&&["subtitles","captions"].includes(S.kind)),I=`${(p=P.subtitleTracks[P.subtitleTrack])==null?void 0:p.type.toLowerCase()}${P.subtitleTrack}`;if(T&&(P.subtitleTrack<0||(T==null?void 0:T.id)!==I)){let S=P.subtitleTracks.findIndex(({lang:O,name:_,type:E})=>O==T.language&&_===T.label&&E.toLowerCase()===T.kind);P.subtitleTrack=S}T&&(T==null?void 0:T.id)===I&&T.cues&&Array.from(T.cues).forEach(S=>{T.addCue(S)})};B.textTracks.addEventListener("change",n),P.on(Qe.default.Events.CUES_PARSED,(p,{track:T,type:I,cues:S})=>{let O=B.textTracks.getTrackById(T);if(!O)return;let _=O.mode==="disabled";_&&(O.mode="hidden"),S.forEach(E=>{var A;(A=O.cues)!=null&&A.getCueById(E.id)||O.addCue(E)}),_&&(O.mode="disabled")}),P.once(Qe.default.Events.DESTROYING,()=>{B.textTracks.removeEventListener("change",n),B.querySelectorAll("track[data-removeondestroy]").forEach(p=>{p.remove()})});let R=()=>{Array.from(B.textTracks).forEach(p=>{var T,I;if(!["subtitles","caption"].includes(p.kind)&&p.label==="thumbnails"){if(!((T=p.cues)!=null&&T.length)){let S=B.querySelector('track[label="thumbnails"]'),O=(I=S==null?void 0:S.getAttribute("src"))!=null?I:"";S==null||S.removeAttribute("src"),setTimeout(()=>{S==null||S.setAttribute("src",O)},0)}p.mode!=="hidden"&&(p.mode="hidden")}})};P.once(Qe.default.Events.MANIFEST_LOADED,R),P.once(Qe.default.Events.MEDIA_ATTACHED,R)}function jr(B,P,n,R,p){let T=document.createElement("track");return T.kind=P,T.label=n,R&&(T.srclang=R),p&&(T.id=p),T.track.mode="disabled",T.setAttribute("data-removeondestroy",""),B.append(T),T.track}var er,tr,Kr=(tr=(er=globalThis==null?void 0:globalThis.navigator)==null?void 0:er.userAgent)!=null?tr:"",Wr=Kr.toLowerCase().indexOf("android")!==-1,sr="mux.com",rr,ir,kt=(ir=(rr=Ge.default).isSupported)==null?void 0:ir.call(rr),or=Wr,lr=()=>jt.default.utils.now(),Ft={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},Je={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},Bt={HLS:Je.M3U8},si=Object.keys(Bt),oi=[...Object.values(Je),"hls","HLS"],Gr=B=>{let P=B.indexOf("?");if(P<0)return[B];let n=B.slice(0,P),R=B.slice(P);return[n,R]},ur=(B,{domain:P=sr}={})=>{if(!B)return;let[n,R=""]=Gr(B);return`https://stream.${P}/${n}.m3u8${R}`},Hr=B=>{let P="";try{P=new URL(B).pathname}catch{console.error("invalid url")}let n=P.lastIndexOf(".");if(n<0)return"";let R=P.slice(n+1).toUpperCase();return nr(R,Je)?Je[R]:""},fr=B=>{let P=B.type;if(P){let R=P.toUpperCase();return nr(R,Bt)?Bt[R]:P}let{src:n}=B;return n?Hr(n):""},Vr=B=>{if([Ft.LIVE,Ft.LL_LIVE].includes(B)){let P={backBufferLength:12};return B===Ft.LL_LIVE?{...P,maxFragLookUpTolerance:.001}:P}return{}},Ze=new WeakMap,dr=B=>{var P;return(P=Ze.get(B))==null?void 0:P.error},Kt=(B,P)=>{P&&(P.detachMedia(),P.destroy()),(B==null?void 0:B.mux)&&!B.mux.deleted&&(B.mux.destroy(),delete B.mux),B&&(B.removeAttribute("src"),B.load(),B.removeEventListener("error",hr),B.removeEventListener("error",Nt),B.removeEventListener("durationchange",cr),Ze.delete(B),B.dispatchEvent(new Event("teardown")))},Yr=(B,P)=>{var n;let{debug:R,preferMse:p,streamType:T,startTime:I=-1}=B,S=fr(B),O=S===Je.M3U8,_=!S||((n=P==null?void 0:P.canPlayType(S))!=null?n:!0);if(O&&!(!O||_&&!((p||or)&&kt))&&kt){let E={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},A=Vr(T);return new Ge.default({debug:R,startPosition:I,...E,...A})}},zr=({playbackId:B,src:P,customDomain:n})=>{if(B)return!0;if(typeof P!="string")return!1;let R=new URL(P).hostname.toLocaleLowerCase();return R.includes(sr)||!!n&&R.includes(n.toLocaleLowerCase())},Xr=(B,P,n)=>{let{envKey:R}=B,p=zr(B);if((R||p)&&P){let{playerInitTime:T,playerSoftwareName:I,playerSoftwareVersion:S,beaconCollectionDomain:O,metadata:_,debug:E}=B,A=D=>typeof D.player_error_code=="string"?!1:typeof B.errorTranslator=="function"?B.errorTranslator(D):D;jt.default.monitor(P,{debug:E,beaconCollectionDomain:O,hlsjs:n,Hls:n?Ge.default:void 0,automaticErrorTracking:!1,errorTranslator:A,data:{...R?{env_key:R}:{},player_software_name:I,player_software:I,player_software_version:S,player_init_time:T,..._}})}},Qr=(B,P,n)=>{var R,p;if(!P){console.warn("attempting to load media before mediaEl exists");return}let{preferMse:T,streamType:I}=B,S=fr(B),O=S===Je.M3U8,_=!S||((R=P==null?void 0:P.canPlayType(S))!=null?R:!0),E=!O||_&&!((T||or)&&kt),{src:A}=B;if(P&&_&&E)typeof A=="string"?(P.setAttribute("src",A),B.startTime&&(((p=Ze.get(P))!=null?p:{}).startTime=B.startTime,P.addEventListener("durationchange",cr,{once:!0}))):P.removeAttribute("src"),P.addEventListener("error",hr),P.addEventListener("error",Nt);else if(n&&A){switch(n.on(Ge.default.Events.ERROR,(D,x)=>{let g={[Ge.default.ErrorTypes.NETWORK_ERROR]:Fe.MEDIA_ERR_NETWORK,[Ge.default.ErrorTypes.MEDIA_ERROR]:Fe.MEDIA_ERR_DECODE},y=new Fe("",g[x.type]);y.fatal=x.fatal,y.data=x,P.dispatchEvent(new CustomEvent("error",{detail:y}))}),P.addEventListener("error",Nt),Nr(P,n),P.preload){case"none":$e(P,"play",()=>n.loadSource(A),{once:!0});break;case"metadata":let D=n.config.maxBufferLength,x=n.config.maxBufferSize;n.config.maxBufferLength=1,n.config.maxBufferSize=1,$e(P,"play",()=>{n.config.maxBufferLength=D,n.config.maxBufferSize=x},{once:!0}),n.loadSource(A);break;default:n.loadSource(A)}n.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 cr(B){var P;let n=B.target,R=(P=Ze.get(n))==null?void 0:P.startTime;if(!!R&&kr(n.seekable,n.duration,R)){let p=n.preload==="auto";p&&(n.preload="none"),n.currentTime=R,p&&(n.preload="auto")}}async function hr(B){if(!B.isTrusted)return;B.stopImmediatePropagation();let P=B.target;if(!(P!=null&&P.error))return;let{message:n,code:R}=P.error,p=new Fe(n,R);if(P.src&&(R!==Fe.MEDIA_ERR_DECODE||R!==void 0)){let{status:T}=await fetch(P.src);p.data={response:{code:T}}}P.dispatchEvent(new CustomEvent("error",{detail:p}))}function Nt(B){var P,n;if(!(B instanceof CustomEvent)||!(B.detail instanceof Fe))return;let R=B.target,p=B.detail;!p||!p.fatal||(((P=Ze.get(R))!=null?P:{}).error=p,(n=R.mux)==null||n.emit("error",{player_error_code:p.code,player_error_message:p.message}))}var vr=(B,P,n)=>{Kt(P,n),Ze.set(P,{});let R=Yr(B,P);return Xr(B,P,R),Qr(B,P,R),R};var $r=()=>{try{return"0.8.6"}catch{}return"UNKNOWN"},Jr=$r(),gr=()=>Jr;var Zr=B=>{var P,n,R,p,T,mr,S,St,_,Ue,A,xt,x,At,y,pr,e,yr,f,Wt,i,t,u,c,r,h,d,ft,v,Er,L,Gt,M,Tr,w,Ht,U,Sr,j,Vt;return P=class extends B{constructor(){super();ve(this,d);ve(this,v);ve(this,L);ve(this,M);ve(this,w);ve(this,U);ve(this,j);at(this,"castEnabled",!1);ve(this,i,{paused:!1});ve(this,t,void 0);ve(this,u,{});ve(this,c,void 0);ve(this,r,void 0);ve(this,h,void 0);P.instances.add(this),be(this,w,Ht).call(this)}static get castElement(){return ne(P,n)}static get castEnabled(){return ne(P,R)}static get castState(){var K;return(K=ne(P,_,Ue))==null?void 0:K.getCastState()}static async exitCast(){try{await ne(P,_,Ue).endCurrentSession(!0)}catch(H){console.error(H);return}}get castPlayer(){if(P.castElement===this)return ne(this,t)}attributeChangedCallback(K){if(!!this.castPlayer)switch(K){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(K={}){var H;be(H=P,f,Wt).call(H,K),Pe(P,n,this),Object.entries(ne(this,u)).forEach(([z,$])=>{ne(this,t).controller.addEventListener(z,$)});try{await ne(P,_,Ue).requestSession()}catch{Pe(P,n,void 0);return}ne(this,i).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(z){console.error(z)}}async load(){var J,te;if(!this.castPlayer)return super.load();let K=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),H=[...this.querySelectorAll("track")].filter(({kind:Q,src:ae})=>ae&&(Q==="subtitles"||Q==="captions")),z=[],$=0;H.length&&(K.tracks=H.map(Q=>{let ae=++$;z.length===0&&Q.track.mode==="showing"&&z.push(ae);let se=new chrome.cast.media.Track(ae,chrome.cast.media.TrackType.TEXT);return se.trackContentId=Q.src,se.trackContentType="text/vtt",se.subtype=Q.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,se.name=Q.label,se.language=Q.srclang,se})),this.castStreamType==="live"?K.streamType=chrome.cast.media.StreamType.LIVE:K.streamType=chrome.cast.media.StreamType.BUFFERED,K.metadata=new chrome.cast.media.GenericMediaMetadata,K.metadata.title=this.title,K.metadata.images=[{url:this.poster}];let X=new chrome.cast.media.LoadRequest(K);X.currentTime=(J=super.currentTime)!=null?J:0,X.autoplay=!ne(this,i).paused,X.activeTrackIds=z,await((te=ne(P,A,xt))==null?void 0:te.loadMedia(X)),this.dispatchEvent(new Event("volumechange"))}play(){var K;if(this.castPlayer){this.castPlayer.isPaused&&((K=this.castPlayer.controller)==null||K.playOrPause());return}return super.play()}pause(){var K;if(this.castPlayer){this.castPlayer.isPaused||(K=this.castPlayer.controller)==null||K.playOrPause();return}super.pause()}get castSrc(){var K,H,z;return(z=(H=this.getAttribute("cast-src"))!=null?H:(K=this.querySelector("source"))==null?void 0:K.src)!=null?z:this.currentSrc}set castSrc(K){this.castSrc!=K&&this.setAttribute("cast-src",`${K}`)}get castContentType(){var K;return(K=this.getAttribute("cast-content-type"))!=null?K:void 0}set castContentType(K){this.setAttribute("cast-content-type",`${K}`)}get castStreamType(){var K;return(K=this.getAttribute("cast-stream-type"))!=null?K:void 0}set castStreamType(K){this.setAttribute("cast-stream-type",`${K}`)}get readyState(){if(this.castPlayer)switch(this.castPlayer.playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return this.castPlayer?this.castPlayer.isPaused:super.paused}get muted(){var K;return this.castPlayer?(K=this.castPlayer)==null?void 0:K.isMuted:super.muted}set muted(K){var H;if(this.castPlayer){(K&&!this.castPlayer.isMuted||!K&&this.castPlayer.isMuted)&&((H=this.castPlayer.controller)==null||H.muteOrUnmute());return}super.muted=K}get volume(){var K,H;return this.castPlayer?(H=(K=this.castPlayer)==null?void 0:K.volumeLevel)!=null?H:1:super.volume}set volume(K){var H;if(this.castPlayer){this.castPlayer.volumeLevel=K,(H=this.castPlayer.controller)==null||H.setVolumeLevel();return}super.volume=K}get duration(){var K,H;return this.castPlayer&&ne(this,d,ft)?(H=(K=this.castPlayer)==null?void 0:K.duration)!=null?H:NaN:super.duration}get currentTime(){var K,H;return this.castPlayer&&ne(this,d,ft)?(H=(K=this.castPlayer)==null?void 0:K.currentTime)!=null?H:0:super.currentTime}set currentTime(K){var H;if(this.castPlayer){this.castPlayer.currentTime=K,(H=this.castPlayer.controller)==null||H.seek();return}super.currentTime=K}get onentercast(){return ne(this,c)}set onentercast(K){ne(this,c)&&(this.removeEventListener("entercast",ne(this,c)),Pe(this,c,null)),typeof K=="function"&&(Pe(this,c,K),this.addEventListener("entercast",K))}get onleavecast(){return ne(this,r)}set onleavecast(K){ne(this,r)&&(this.removeEventListener("leavecast",ne(this,r)),Pe(this,r,null)),typeof K=="function"&&(Pe(this,r,K),this.addEventListener("leavecast",K))}get oncastchange(){return ne(this,h)}set oncastchange(K){ne(this,h)&&(this.removeEventListener("castchange",ne(this,h)),Pe(this,h,null)),typeof K=="function"&&(Pe(this,h,K),this.addEventListener("castchange",K))}},n=new WeakMap,R=new WeakMap,p=new WeakMap,T=new WeakSet,mr=function(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable},S=new WeakSet,St=function(){return typeof cast!="undefined"&&cast.framework},_=new WeakSet,Ue=function(){if(ne(P,S,St))return cast.framework.CastContext.getInstance()},A=new WeakSet,xt=function(){var K;return(K=ne(P,_,Ue))==null?void 0:K.getCurrentSession()},x=new WeakSet,At=function(){var K;return(K=ne(P,A,xt))==null?void 0:K.getSessionObj().media[0]},y=new WeakSet,pr=function(K){return new Promise((H,z)=>{ne(P,x,At).editTracksInfo(K,H,z)})},e=new WeakSet,yr=function(K){return new Promise((H,z)=>{ne(P,x,At).getStatus(K,H,z)})},f=new WeakSet,Wt=function(K){return ne(P,_,Ue).setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...K})},i=new WeakMap,t=new WeakMap,u=new WeakMap,c=new WeakMap,r=new WeakMap,h=new WeakMap,d=new WeakSet,ft=function(){var K;return(K=this.castPlayer)==null?void 0:K.isMediaLoaded},v=new WeakSet,Er=function(){ne(P,n)===this&&(Object.entries(ne(this,u)).forEach(([K,H])=>{ne(this,t).controller.removeEventListener(K,H)}),Pe(P,n,void 0),this.muted=ne(this,t).isMuted,this.currentTime=ne(this,t).savedPlayerState.currentTime,ne(this,t).savedPlayerState.isPaused===!1&&this.play())},L=new WeakSet,Gt=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:ne(P,_,Ue).getCastState()}))},M=new WeakSet,Tr=async function(){var H,z;let{SESSION_RESUMED:K}=cast.framework.SessionState;if(ne(P,_,Ue).getSessionState()===K&&this.castSrc===((H=ne(P,x,At))==null?void 0:H.media.contentId)){Pe(P,n,this),Object.entries(ne(this,u)).forEach(([$,X])=>{ne(this,t).controller.addEventListener($,X)});try{await be(z=P,e,yr).call(z,new chrome.cast.media.GetStatusRequest)}catch($){console.error($)}ne(this,u)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),ne(this,u)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},w=new WeakSet,Ht=function(){var K;!ne(P,S,St)||this.castEnabled||(this.castEnabled=!0,be(K=P,f,Wt).call(K),this.textTracks.addEventListener("change",be(this,j,Vt).bind(this)),be(this,L,Gt).call(this),Pe(this,t,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(ne(this,t)),Pe(this,u,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:H})=>{H===!1&&be(this,v,Er).call(this),this.dispatchEvent(new Event(H?"entercast":"leavecast"))},[cast.framework.RemotePlayerEventType.DURATION_CHANGED]:()=>{this.dispatchEvent(new Event("durationchange"))},[cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{!ne(this,d,ft)||this.dispatchEvent(new Event("timeupdate"))},[cast.framework.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{this.dispatchEvent(new Event("resize"))},[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{this.dispatchEvent(new Event(this.paused?"pause":"play"))},[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var H,z;((H=this.castPlayer)==null?void 0:H.playerState)!==chrome.cast.media.PlayerState.PAUSED&&this.dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(z=this.castPlayer)==null?void 0:z.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!ne(this,d,ft)||(await Promise.resolve(),be(this,U,Sr).call(this))}}))},U=new WeakSet,Sr=function(){be(this,j,Vt).call(this)},j=new WeakSet,Vt=async function(){var re,ee,Z,q,fe,ge;if(!this.castPlayer)return;let H=((ee=(re=ne(this,t).mediaInfo)==null?void 0:re.tracks)!=null?ee:[]).filter(({type:ie})=>ie===chrome.cast.media.TrackType.TEXT),z=[...this.textTracks].filter(({kind:ie})=>ie==="subtitles"||ie==="captions"),$=H.map(({language:ie,name:me,trackId:ye})=>{var oe;let{mode:Te}=(oe=z.find(de=>de.language===ie&&de.label===me))!=null?oe:{};return Te?{mode:Te,trackId:ye}:!1}).filter(Boolean),J=$.filter(({mode:ie})=>ie!=="showing").map(({trackId:ie})=>ie),te=$.find(({mode:ie})=>ie==="showing"),Q=(fe=(q=(Z=ne(P,A,xt))==null?void 0:Z.getSessionObj().media[0])==null?void 0:q.activeTrackIds)!=null?fe:[],ae=Q;if(Q.length&&(ae=ae.filter(ie=>!J.includes(ie))),te!=null&&te.trackId&&(ae=[...ae,te.trackId]),ae=[...new Set(ae)],!((ie,me)=>ie.length===me.length&&ie.every(ye=>me.includes(ye)))(Q,ae))try{let ie=new chrome.cast.media.EditTracksInfoRequest(ae);await be(ge=P,y,pr).call(ge,ie)}catch(ie){console.error(ie)}},ve(P,T),ve(P,S),ve(P,_),ve(P,A),ve(P,x),ve(P,y),ve(P,e),ve(P,f),at(P,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),at(P,"instances",new Set),ve(P,n,void 0),ve(P,R,!1),at(P,"initCast",()=>{var K;ne(P,T,mr)?ne(P,S,St)?ne(K=P,p).call(K,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var H;return ne(H=P,p).call(H,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var H;return ne(H=P,p).call(H,chrome.cast.isAvailable)})}}),ve(P,p,K=>{if(K){Pe(P,R,!0);let{CAST_STATE_CHANGED:H}=cast.framework.CastContextEventType;ne(P,_,Ue).addEventListener(H,$=>{P.instances.forEach(X=>{var J;return be(J=X,L,Gt).call(J,$)})});let{SESSION_STATE_CHANGED:z}=cast.framework.CastContextEventType;ne(P,_,Ue).addEventListener(z,$=>{P.instances.forEach(X=>{var J;return be(J=X,M,Tr).call(J,$)})}),P.instances.forEach($=>{var X;return be(X=$,w,Ht).call(X)})}}),P};if(globalThis.HTMLVideoElement&&globalThis.customElements){let B=Zr(HTMLVideoElement);globalThis.customElements.get("castable-video")||(globalThis.customElements.define("castable-video",B,{extends:"video"}),globalThis.CastableVideoElement=B),B.initCast()}var xr=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","castchange","entercast","leavecast"],Ar=Pt.createElement("template");Ar.innerHTML=`
|
|
28
|
+
`),r=[],h=Object(I.toMpegTsClockFromTimescale)(s,e),d="00:00.000",l=0,v=0,p,L=!0;u.oncue=function(O){var M=o[f],F=o.ccOffset,w=(l-h)/9e4;M!=null&&M.new&&(v!==void 0?F=o.ccOffset=M.start:x(o,f,w)),w&&(F=w-o.presentationOffset);var C=O.endTime-O.startTime,k=Object(T.normalizePts)((O.startTime+F-v)*9e4,a*9e4)/9e4;O.startTime=Math.max(k,0),O.endTime=Math.max(k+C,0);var U=O.text.trim();O.text=decodeURIComponent(encodeURIComponent(U)),O.id||(O.id=D(O.startTime,O.endTime,U)),O.endTime>0&&r.push(O)},u.onparsingerror=function(O){p=O},u.onflush=function(){if(p){t(p);return}i(r)},c.forEach(function(O){if(L)if(_(O,"X-TIMESTAMP-MAP=")){L=!1,O.slice(16).split(",").forEach(function(M){_(M,"LOCAL:")?d=M.slice(6):_(M,"MPEGTS:")&&(l=parseInt(M.slice(7)))});try{v=E(d)/1e3}catch(M){p=M}return}else O===""&&(L=!1);u.parse(O+`
|
|
29
|
+
`)}),u.flush()}},"./src/utils/xhr-loader.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/utils/logger.ts"),m=n("./src/loader/load-stats.ts"),S=/^age:\s*[\d.]+\s*$/m,I=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 m.LoadStats,this.retryDelay=0}var b=T.prototype;return b.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},b.abortInternal=function(){var E=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),E&&(E.onreadystatechange=null,E.onprogress=null,E.readyState!==4&&(this.stats.aborted=!0,E.abort()))},b.abort=function(){var E;this.abortInternal(),(E=this.callbacks)!==null&&E!==void 0&&E.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},b.load=function(E,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=E,this.config=A,this.callbacks=D,this.retryDelay=A.retryDelay,this.loadInternal()},b.loadInternal=function(){var E=this.config,A=this.context;if(!!E){var D=this.loader=new self.XMLHttpRequest,x=this.stats;x.loading.first=0,x.loaded=0;var g=this.xhrSetup;try{if(g)try{g(D,A.url)}catch{D.open("GET",A.url,!0),g(D,A.url)}D.readyState||D.open("GET",A.url,!0);var y=this.context.headers;if(y)for(var s in y)D.setRequestHeader(s,y[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),E.timeout),D.send()}},b.readystatechange=function(){var E=this.context,A=this.loader,D=this.stats;if(!(!E||!A)){var x=A.readyState,g=this.config;if(!D.aborted&&x>=2)if(self.clearTimeout(this.requestTimeout),D.loading.first===0&&(D.loading.first=Math.max(self.performance.now(),D.loading.start)),x===4){A.onreadystatechange=null,A.onprogress=null;var y=A.status;if(y>=200&&y<300){D.loading.end=Math.max(self.performance.now(),D.loading.first);var s,e;if(E.responseType==="arraybuffer"?(s=A.response,e=s.byteLength):(s=A.responseText,e=s.length),D.loaded=D.total=e,!this.callbacks)return;var o=this.callbacks.onProgress;if(o&&o(D,E,s,A),!this.callbacks)return;var f={url:A.responseURL,data:s};this.callbacks.onSuccess(f,D,E,A)}else D.retry>=g.maxRetry||y>=400&&y<499?(R.logger.error(y+" while loading "+E.url),this.callbacks.onError({code:y,text:A.statusText},E,A)):(R.logger.warn(y+" while loading "+E.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),D.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),g.timeout)}},b.loadtimeout=function(){R.logger.warn("timeout while loading "+this.context.url);var E=this.callbacks;E&&(this.abortInternal(),E.onTimeout(this.stats,this.context,this.loader))},b.loadprogress=function(E){var A=this.stats;A.loaded=E.loaded,E.lengthComputable&&(A.total=E.total)},b.getCacheAge=function(){var E=null;if(this.loader&&S.test(this.loader.getAllResponseHeaders())){var A=this.loader.getResponseHeader("age");E=A?parseFloat(A):null}return E},T}();P.default=I}}).default})});var Qe=class{addEventListener(){}removeEventListener(){}dispatchEvent(P){return!0}};if(typeof DocumentFragment=="undefined"){class B extends Qe{}globalThis.DocumentFragment=B}var st=class extends Qe{},Pt=class extends Qe{},wr={get(B){},define(B,P,n){},upgrade(B){},whenDefined(B){return Promise.resolve(st)}},ot,It=class{constructor(P,n={}){ve(this,ot,void 0);Pe(this,ot,n==null?void 0:n.detail)}get detail(){return ne(this,ot)}initCustomEvent(){}};ot=new WeakMap;function kr(B,P){return new st}var $t={document:{createElement:kr},DocumentFragment,customElements:wr,CustomEvent:It,EventTarget:Qe,HTMLElement:st,HTMLVideoElement:Pt},Jt=typeof window=="undefined"||typeof globalThis.customElements=="undefined",we=Jt?$t:globalThis,Mt=Jt?$t.document:globalThis.document;var jt=Et(Zt(),1),Ge=Et(St(),1),kt=Et(St(),1),$e=Et(St(),1),ut=class extends Error{constructor(B,P=ut.MEDIA_ERR_CUSTOM,n){var R;super(B),this.name="MediaError",this.code=P,this.fatal=n!=null?n:P>=ut.MEDIA_ERR_NETWORK&&P<=ut.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(R=ut.defaultMessages[this.code])!=null?R:"")}},Fe=ut;Fe.MEDIA_ERR_ABORTED=1,Fe.MEDIA_ERR_NETWORK=2,Fe.MEDIA_ERR_DECODE=3,Fe.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Fe.MEDIA_ERR_ENCRYPTED=5,Fe.MEDIA_ERR_CUSTOM=100,Fe.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 nr=(B,P)=>B in P,Ut={ANY:"any",MUTED:"muted"},xt={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},He={MSE:"mse",NATIVE:"native"},Je={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},Bt={HLS:Je.M3U8},ui=Object.keys(Bt),fi=[...Object.values(Je),"hls","HLS"],ft=(B,P,n,R)=>{B.addEventListener(P,n,R),B.addEventListener("teardown",()=>{B.removeEventListener(P,n)},{once:!0})};function Ur(B,P,n){P&&n>P&&(n=P);for(let R=0;R<B.length;R++)if(B.start(R)<=n&&B.end(R)>=n)return!0;return!1}var Br=B=>{let P=B.indexOf("?");if(P<0)return[B];let n=B.slice(0,P),R=B.slice(P);return[n,R]},ar=B=>{let P=B.type;if(P){let R=P.toUpperCase();return nr(R,Bt)?Bt[R]:P}let{src:n}=B;return n?Nr(n):""},Nr=B=>{let P="";try{P=new URL(B).pathname}catch{console.error("invalid url")}let n=P.lastIndexOf(".");if(n<0)return"";let R=P.slice(n+1).toUpperCase();return nr(R,Je)?Je[R]:""},jr=Object.values(Ut),qt=B=>typeof B=="boolean"||typeof B=="string"&&jr.includes(B),Kr=({autoplay:B},P,n)=>{if(!P)return()=>{};let R=!1,m=!1,S=qt(B)?B:!!B,I=()=>{R||ft(P,"playing",()=>{R=!0},{once:!0})};if(I(),ft(P,"loadstart",()=>{R=!1,I(),wt(P,S)},{once:!0}),ft(P,"loadstart",()=>{n||(m=!Number.isFinite(P.duration)),wt(P,S)},{once:!0}),n&&n.once(kt.default.Events.LEVEL_LOADED,(T,b)=>{var _;m=(_=b.details.live)!=null?_:!1}),!S){let T=()=>{!m||(n!=null&&n.liveSyncPosition?P.currentTime=n.liveSyncPosition:Number.isFinite(P.seekable.end(0))&&(P.currentTime=P.seekable.end(0)))};n&&ft(P,"play",()=>{P.preload==="metadata"?n.once(kt.default.Events.LEVEL_UPDATED,T):T()},{once:!0})}return T=>{R||(S=qt(T)?T:!!T,wt(P,S))}},wt=(B,P)=>{if(!P)return;let n=B.muted,R=()=>B.muted=n;switch(P){case Ut.ANY:B.play().catch(()=>{B.muted=!0,B.play().catch(R)});break;case Ut.MUTED:B.muted=!0,B.play().catch(R);break;default:B.play().catch(()=>{});break}},Wr=({preload:B,src:P},n,R)=>{if(!n)return()=>{};let m=A=>{A!=null&&["","none","metadata","auto"].includes(A)?n.setAttribute("preload",A):n.removeAttribute("preload")};if(!R)return m(B),m;let S=!1,I=!1,T=R.config.maxBufferLength,b=R.config.maxBufferSize,_=A=>{m(A);let D=A!=null?A:n.preload;I||D==="none"||(D==="metadata"?(R.config.maxBufferLength=1,R.config.maxBufferSize=1):(R.config.maxBufferLength=T,R.config.maxBufferSize=b),E())},E=()=>{!S&&P&&(S=!0,R.loadSource(P))};return ft(n,"play",()=>{I=!0,R.config.maxBufferLength=T,R.config.maxBufferSize=b,E()},{once:!0}),_(B),_};function Gr(B,P){P.on($e.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(m,{tracks:S})=>{S.forEach(I=>{var T;let b=(T=I.subtitleTrack)!=null?T:I.closedCaptions,_=P.subtitleTracks.findIndex(({lang:E,name:A,type:D})=>E==(b==null?void 0:b.lang)&&A===I.label&&D.toLowerCase()===I.kind);Hr(B,I.kind,I.label,b==null?void 0:b.lang,`${I.kind}${_}`)})});let n=()=>{var m;if(!P.subtitleTracks.length)return;let S=Array.from(B.textTracks).find(T=>T.id&&T.mode==="showing"&&["subtitles","captions"].includes(T.kind)),I=`${(m=P.subtitleTracks[P.subtitleTrack])==null?void 0:m.type.toLowerCase()}${P.subtitleTrack}`;if(S&&(P.subtitleTrack<0||(S==null?void 0:S.id)!==I)){let T=P.subtitleTracks.findIndex(({lang:b,name:_,type:E})=>b==S.language&&_===S.label&&E.toLowerCase()===S.kind);P.subtitleTrack=T}S&&(S==null?void 0:S.id)===I&&S.cues&&Array.from(S.cues).forEach(T=>{S.addCue(T)})};B.textTracks.addEventListener("change",n),P.on($e.default.Events.CUES_PARSED,(m,{track:S,cues:I})=>{let T=B.textTracks.getTrackById(S);if(!T)return;let b=T.mode==="disabled";b&&(T.mode="hidden"),I.forEach(_=>{var E;(E=T.cues)!=null&&E.getCueById(_.id)||T.addCue(_)}),b&&(T.mode="disabled")}),P.once($e.default.Events.DESTROYING,()=>{B.textTracks.removeEventListener("change",n),B.querySelectorAll("track[data-removeondestroy]").forEach(m=>{m.remove()})});let R=()=>{Array.from(B.textTracks).forEach(m=>{var S,I;if(!["subtitles","caption"].includes(m.kind)&&m.label==="thumbnails"){if(!((S=m.cues)!=null&&S.length)){let T=B.querySelector('track[label="thumbnails"]'),b=(I=T==null?void 0:T.getAttribute("src"))!=null?I:"";T==null||T.removeAttribute("src"),setTimeout(()=>{T==null||T.setAttribute("src",b)},0)}m.mode!=="hidden"&&(m.mode="hidden")}})};P.once($e.default.Events.MANIFEST_LOADED,R),P.once($e.default.Events.MEDIA_ATTACHED,R)}function Hr(B,P,n,R,m){let S=document.createElement("track");return S.kind=P,S.label=n,R&&(S.srclang=R),m&&(S.id=m),S.track.mode="disabled",S.setAttribute("data-removeondestroy",""),B.append(S),S.track}var er,tr,Vr=(tr=(er=globalThis==null?void 0:globalThis.navigator)==null?void 0:er.userAgent)!=null?tr:"",Yr=Vr.toLowerCase().indexOf("android")!==-1,Ze=new WeakMap,sr="mux.com",rr,ir,or=(ir=(rr=Ge.default).isSupported)==null?void 0:ir.call(rr),zr=Yr,lr=()=>jt.default.utils.now(),ur=(B,{domain:P=sr}={})=>{if(!B)return;let[n,R=""]=Br(B);return`https://stream.${P}/${n}.m3u8${R}`},fr=B=>{var P;return(P=Ze.get(B))==null?void 0:P.error},dr=(B,P,n)=>{Kt(P,n),Ze.set(P,{});let R=Xr(B,P);Jr(B,P,R),Zr(B,P,R);let m=Kr(B,P,R),S=Wr(B,P,R);return{engine:R,setAutoplay:m,setPreload:S}},Kt=(B,P)=>{let n=P==null?void 0:P.engine;n&&(n.detachMedia(),n.destroy()),(B==null?void 0:B.mux)&&!B.mux.deleted&&(B.mux.destroy(),delete B.mux),B&&(B.removeAttribute("src"),B.load(),B.removeEventListener("error",vr),B.removeEventListener("error",Nt),B.removeEventListener("durationchange",hr),Ze.delete(B),B.dispatchEvent(new Event("teardown")))};function cr(B,P){var n;let R=ar(B);if(R!==Je.M3U8)return!0;let m=!R||((n=P==null?void 0:P.canPlayType(R))!=null?n:!0),{preferPlayback:S}=B,I=S===He.MSE,T=S===He.NATIVE;return m&&(T||!(or&&(I||zr)))}var Xr=(B,P)=>{let{debug:n,streamType:R,startTime:m=-1}=B,S=ar(B)===Je.M3U8,I=cr(B,P);if(S&&!I&&or){let T={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},b=Qr(R);return new Ge.default({debug:n,startPosition:m,...T,...b})}},Qr=B=>[xt.LIVE,xt.DVR].includes(B)?{backBufferLength:8}:[xt.LL_LIVE,xt.LL_DVR].includes(B)?{backBufferLength:4,maxFragLookUpTolerance:.001}:{},$r=({playbackId:B,src:P,customDomain:n})=>{if(B)return!0;if(typeof P!="string")return!1;let R=window==null?void 0:window.location.href,m=new URL(P,R).hostname.toLocaleLowerCase();return m.includes(sr)||!!n&&m.includes(n.toLocaleLowerCase())},Jr=(B,P,n)=>{let{envKey:R}=B,m=$r(B);if((R||m)&&P){let{playerInitTime:S,playerSoftwareName:I,playerSoftwareVersion:T,beaconCollectionDomain:b,metadata:_,debug:E}=B,A=D=>typeof D.player_error_code=="string"?!1:typeof B.errorTranslator=="function"?B.errorTranslator(D):D;jt.default.monitor(P,{debug:E,beaconCollectionDomain:b,hlsjs:n,Hls:n?Ge.default:void 0,automaticErrorTracking:!1,errorTranslator:A,data:{...R?{env_key:R}:{},player_software_name:I,player_software:I,player_software_version:T,player_init_time:S,..._}})}},Zr=(B,P,n)=>{var R;if(!P){console.warn("attempting to load media before mediaEl exists");return}let m=cr(B,P),{src:S}=B;P&&m?(typeof S=="string"?(P.setAttribute("src",S),B.startTime&&(((R=Ze.get(P))!=null?R:{}).startTime=B.startTime,P.addEventListener("durationchange",hr,{once:!0}))):P.removeAttribute("src"),P.addEventListener("error",vr),P.addEventListener("error",Nt)):n&&S?(n.on(Ge.default.Events.ERROR,(I,T)=>{let b={[Ge.default.ErrorTypes.NETWORK_ERROR]:Fe.MEDIA_ERR_NETWORK,[Ge.default.ErrorTypes.MEDIA_ERROR]:Fe.MEDIA_ERR_DECODE},_=new Fe("",b[T.type]);_.fatal=T.fatal,_.data=T,P.dispatchEvent(new CustomEvent("error",{detail:_}))}),P.addEventListener("error",Nt),Gr(P,n),n.attachMedia(P)):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 hr(B){var P;let n=B.target,R=(P=Ze.get(n))==null?void 0:P.startTime;if(!!R&&Ur(n.seekable,n.duration,R)){let m=n.preload==="auto";m&&(n.preload="none"),n.currentTime=R,m&&(n.preload="auto")}}async function vr(B){if(!B.isTrusted)return;B.stopImmediatePropagation();let P=B.target;if(!(P!=null&&P.error))return;let{message:n,code:R}=P.error,m=new Fe(n,R);if(P.src&&(R!==Fe.MEDIA_ERR_DECODE||R!==void 0))try{let{status:S}=await fetch(P.src);m.data={response:{code:S}}}catch{}P.dispatchEvent(new CustomEvent("error",{detail:m}))}function Nt(B){var P,n;if(!(B instanceof CustomEvent)||!(B.detail instanceof Fe))return;let R=B.target,m=B.detail;!m||!m.fatal||(((P=Ze.get(R))!=null?P:{}).error=m,(n=R.mux)==null||n.emit("error",{player_error_code:m.code,player_error_message:m.message}))}var qr=()=>{try{return"0.9.0"}catch{}return"UNKNOWN"},ei=qr(),gr=()=>ei;var ti=B=>{var P,n,R,m,S,mr,T,At,_,ke,A,Dt,x,_t,y,pr,e,yr,f,Wt,i,t,u,c,r,h,d,dt,v,Er,L,Gt,M,Tr,w,Ht,k,Sr,j,Vt;return P=class extends B{constructor(){super();ve(this,d);ve(this,v);ve(this,L);ve(this,M);ve(this,w);ve(this,k);ve(this,j);at(this,"castEnabled",!1);ve(this,i,{paused:!1});ve(this,t,void 0);ve(this,u,{});ve(this,c,void 0);ve(this,r,void 0);ve(this,h,void 0);P.instances.add(this),Oe(this,w,Ht).call(this)}static get castElement(){return ne(P,n)}static get castEnabled(){return ne(P,R)}static get castState(){var K;return(K=ne(P,_,ke))==null?void 0:K.getCastState()}static async exitCast(){try{await ne(P,_,ke).endCurrentSession(!0)}catch(H){console.error(H);return}}get castPlayer(){if(P.castElement===this)return ne(this,t)}attributeChangedCallback(K){if(!!this.castPlayer)switch(K){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(K={}){var H;Oe(H=P,f,Wt).call(H,K),Pe(P,n,this),Object.entries(ne(this,u)).forEach(([z,$])=>{ne(this,t).controller.addEventListener(z,$)});try{await ne(P,_,ke).requestSession()}catch{Pe(P,n,void 0);return}ne(this,i).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(z){console.error(z)}}async load(){var J,te;if(!this.castPlayer)return super.load();let K=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),H=[...this.querySelectorAll("track")].filter(({kind:Q,src:ae})=>ae&&(Q==="subtitles"||Q==="captions")),z=[],$=0;H.length&&(K.tracks=H.map(Q=>{let ae=++$;z.length===0&&Q.track.mode==="showing"&&z.push(ae);let se=new chrome.cast.media.Track(ae,chrome.cast.media.TrackType.TEXT);return se.trackContentId=Q.src,se.trackContentType="text/vtt",se.subtype=Q.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,se.name=Q.label,se.language=Q.srclang,se})),this.castStreamType==="live"?K.streamType=chrome.cast.media.StreamType.LIVE:K.streamType=chrome.cast.media.StreamType.BUFFERED,K.metadata=new chrome.cast.media.GenericMediaMetadata,K.metadata.title=this.title,K.metadata.images=[{url:this.poster}];let X=new chrome.cast.media.LoadRequest(K);X.currentTime=(J=super.currentTime)!=null?J:0,X.autoplay=!ne(this,i).paused,X.activeTrackIds=z,await((te=ne(P,A,Dt))==null?void 0:te.loadMedia(X)),this.dispatchEvent(new Event("volumechange"))}play(){var K;if(this.castPlayer){this.castPlayer.isPaused&&((K=this.castPlayer.controller)==null||K.playOrPause());return}return super.play()}pause(){var K;if(this.castPlayer){this.castPlayer.isPaused||(K=this.castPlayer.controller)==null||K.playOrPause();return}super.pause()}get castSrc(){var K,H,z;return(z=(H=this.getAttribute("cast-src"))!=null?H:(K=this.querySelector("source"))==null?void 0:K.src)!=null?z:this.currentSrc}set castSrc(K){this.castSrc!=K&&this.setAttribute("cast-src",`${K}`)}get castContentType(){var K;return(K=this.getAttribute("cast-content-type"))!=null?K:void 0}set castContentType(K){this.setAttribute("cast-content-type",`${K}`)}get castStreamType(){var K;return(K=this.getAttribute("cast-stream-type"))!=null?K:void 0}set castStreamType(K){this.setAttribute("cast-stream-type",`${K}`)}get readyState(){if(this.castPlayer)switch(this.castPlayer.playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return this.castPlayer?this.castPlayer.isPaused:super.paused}get muted(){var K;return this.castPlayer?(K=this.castPlayer)==null?void 0:K.isMuted:super.muted}set muted(K){var H;if(this.castPlayer){(K&&!this.castPlayer.isMuted||!K&&this.castPlayer.isMuted)&&((H=this.castPlayer.controller)==null||H.muteOrUnmute());return}super.muted=K}get volume(){var K,H;return this.castPlayer?(H=(K=this.castPlayer)==null?void 0:K.volumeLevel)!=null?H:1:super.volume}set volume(K){var H;if(this.castPlayer){this.castPlayer.volumeLevel=K,(H=this.castPlayer.controller)==null||H.setVolumeLevel();return}super.volume=K}get duration(){var K,H;return this.castPlayer&&ne(this,d,dt)?(H=(K=this.castPlayer)==null?void 0:K.duration)!=null?H:NaN:super.duration}get currentTime(){var K,H;return this.castPlayer&&ne(this,d,dt)?(H=(K=this.castPlayer)==null?void 0:K.currentTime)!=null?H:0:super.currentTime}set currentTime(K){var H;if(this.castPlayer){this.castPlayer.currentTime=K,(H=this.castPlayer.controller)==null||H.seek();return}super.currentTime=K}get onentercast(){return ne(this,c)}set onentercast(K){ne(this,c)&&(this.removeEventListener("entercast",ne(this,c)),Pe(this,c,null)),typeof K=="function"&&(Pe(this,c,K),this.addEventListener("entercast",K))}get onleavecast(){return ne(this,r)}set onleavecast(K){ne(this,r)&&(this.removeEventListener("leavecast",ne(this,r)),Pe(this,r,null)),typeof K=="function"&&(Pe(this,r,K),this.addEventListener("leavecast",K))}get oncastchange(){return ne(this,h)}set oncastchange(K){ne(this,h)&&(this.removeEventListener("castchange",ne(this,h)),Pe(this,h,null)),typeof K=="function"&&(Pe(this,h,K),this.addEventListener("castchange",K))}},n=new WeakMap,R=new WeakMap,m=new WeakMap,S=new WeakSet,mr=function(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable},T=new WeakSet,At=function(){return typeof cast!="undefined"&&cast.framework},_=new WeakSet,ke=function(){if(ne(P,T,At))return cast.framework.CastContext.getInstance()},A=new WeakSet,Dt=function(){var K;return(K=ne(P,_,ke))==null?void 0:K.getCurrentSession()},x=new WeakSet,_t=function(){var K;return(K=ne(P,A,Dt))==null?void 0:K.getSessionObj().media[0]},y=new WeakSet,pr=function(K){return new Promise((H,z)=>{ne(P,x,_t).editTracksInfo(K,H,z)})},e=new WeakSet,yr=function(K){return new Promise((H,z)=>{ne(P,x,_t).getStatus(K,H,z)})},f=new WeakSet,Wt=function(K){return ne(P,_,ke).setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...K})},i=new WeakMap,t=new WeakMap,u=new WeakMap,c=new WeakMap,r=new WeakMap,h=new WeakMap,d=new WeakSet,dt=function(){var K;return(K=this.castPlayer)==null?void 0:K.isMediaLoaded},v=new WeakSet,Er=function(){ne(P,n)===this&&(Object.entries(ne(this,u)).forEach(([K,H])=>{ne(this,t).controller.removeEventListener(K,H)}),Pe(P,n,void 0),this.muted=ne(this,t).isMuted,this.currentTime=ne(this,t).savedPlayerState.currentTime,ne(this,t).savedPlayerState.isPaused===!1&&this.play())},L=new WeakSet,Gt=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:ne(P,_,ke).getCastState()}))},M=new WeakSet,Tr=async function(){var H,z;let{SESSION_RESUMED:K}=cast.framework.SessionState;if(ne(P,_,ke).getSessionState()===K&&this.castSrc===((H=ne(P,x,_t))==null?void 0:H.media.contentId)){Pe(P,n,this),Object.entries(ne(this,u)).forEach(([$,X])=>{ne(this,t).controller.addEventListener($,X)});try{await Oe(z=P,e,yr).call(z,new chrome.cast.media.GetStatusRequest)}catch($){console.error($)}ne(this,u)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),ne(this,u)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},w=new WeakSet,Ht=function(){var K;!ne(P,T,At)||this.castEnabled||(this.castEnabled=!0,Oe(K=P,f,Wt).call(K),this.textTracks.addEventListener("change",Oe(this,j,Vt).bind(this)),Oe(this,L,Gt).call(this),Pe(this,t,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(ne(this,t)),Pe(this,u,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:H})=>{H===!1&&Oe(this,v,Er).call(this),this.dispatchEvent(new Event(H?"entercast":"leavecast"))},[cast.framework.RemotePlayerEventType.DURATION_CHANGED]:()=>{this.dispatchEvent(new Event("durationchange"))},[cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{!ne(this,d,dt)||this.dispatchEvent(new Event("timeupdate"))},[cast.framework.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{this.dispatchEvent(new Event("resize"))},[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{this.dispatchEvent(new Event(this.paused?"pause":"play"))},[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var H,z;((H=this.castPlayer)==null?void 0:H.playerState)!==chrome.cast.media.PlayerState.PAUSED&&this.dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(z=this.castPlayer)==null?void 0:z.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!ne(this,d,dt)||(await Promise.resolve(),Oe(this,k,Sr).call(this))}}))},k=new WeakSet,Sr=function(){Oe(this,j,Vt).call(this)},j=new WeakSet,Vt=async function(){var re,ee,Z,q,fe,ge;if(!this.castPlayer)return;let H=((ee=(re=ne(this,t).mediaInfo)==null?void 0:re.tracks)!=null?ee:[]).filter(({type:ie})=>ie===chrome.cast.media.TrackType.TEXT),z=[...this.textTracks].filter(({kind:ie})=>ie==="subtitles"||ie==="captions"),$=H.map(({language:ie,name:me,trackId:ye})=>{var oe;let{mode:Te}=(oe=z.find(de=>de.language===ie&&de.label===me))!=null?oe:{};return Te?{mode:Te,trackId:ye}:!1}).filter(Boolean),J=$.filter(({mode:ie})=>ie!=="showing").map(({trackId:ie})=>ie),te=$.find(({mode:ie})=>ie==="showing"),Q=(fe=(q=(Z=ne(P,A,Dt))==null?void 0:Z.getSessionObj().media[0])==null?void 0:q.activeTrackIds)!=null?fe:[],ae=Q;if(Q.length&&(ae=ae.filter(ie=>!J.includes(ie))),te!=null&&te.trackId&&(ae=[...ae,te.trackId]),ae=[...new Set(ae)],!((ie,me)=>ie.length===me.length&&ie.every(ye=>me.includes(ye)))(Q,ae))try{let ie=new chrome.cast.media.EditTracksInfoRequest(ae);await Oe(ge=P,y,pr).call(ge,ie)}catch(ie){console.error(ie)}},ve(P,S),ve(P,T),ve(P,_),ve(P,A),ve(P,x),ve(P,y),ve(P,e),ve(P,f),at(P,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),at(P,"instances",new Set),ve(P,n,void 0),ve(P,R,!1),at(P,"initCast",()=>{var K;ne(P,S,mr)?ne(P,T,At)?ne(K=P,m).call(K,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var H;return ne(H=P,m).call(H,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var H;return ne(H=P,m).call(H,chrome.cast.isAvailable)})}}),ve(P,m,K=>{if(K){Pe(P,R,!0);let{CAST_STATE_CHANGED:H}=cast.framework.CastContextEventType;ne(P,_,ke).addEventListener(H,$=>{P.instances.forEach(X=>{var J;return Oe(J=X,L,Gt).call(J,$)})});let{SESSION_STATE_CHANGED:z}=cast.framework.CastContextEventType;ne(P,_,ke).addEventListener(z,$=>{P.instances.forEach(X=>{var J;return Oe(J=X,M,Tr).call(J,$)})}),P.instances.forEach($=>{var X;return Oe(X=$,w,Ht).call(X)})}}),P};if(globalThis.HTMLVideoElement&&globalThis.customElements){let B=ti(HTMLVideoElement);globalThis.customElements.get("castable-video")||(globalThis.customElements.define("castable-video",B,{extends:"video"}),globalThis.CastableVideoElement=B),B.initCast()}var xr=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","castchange","entercast","leavecast"],Ar=Mt.createElement("template");Ar.innerHTML=`
|
|
30
30
|
<style>
|
|
31
31
|
:host {
|
|
32
32
|
display: inline-block;
|
|
@@ -44,5 +44,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
44
44
|
</style>
|
|
45
45
|
<video is="castable-video" part="video" crossorigin></video>
|
|
46
46
|
<slot></slot>
|
|
47
|
-
`;var
|
|
47
|
+
`;var ct,qe,Lt,ht,Yt,Ne=class extends we.HTMLElement{constructor(){super();ve(this,qe);ve(this,ht);ve(this,ct,void 0);this.attachShadow({mode:"open"}),this.isConnected&&Oe(this,qe,Lt).call(this)}static get observedAttributes(){let n=[],R=S=>S.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();Object.getOwnPropertyNames(this.prototype).forEach(S=>{let I=!1;try{typeof this.prototype[S]=="function"&&(I=!0)}catch{}!I&&S!==S.toUpperCase()&&n.push(S.toLowerCase(),R(S))});let m=Object.getPrototypeOf(this).observedAttributes;return m&&(n=n.concat(m)),n}attributeChangedCallback(n,R,m){Oe(this,qe,Lt).call(this),Oe(this,ht,Yt).call(this,n,R,m)}connectedCallback(){Oe(this,qe,Lt).call(this)}};ct=new WeakMap,qe=new WeakSet,Lt=function(){if(ne(this,ct))return;Pe(this,ct,!0),this.shadowRoot.append(Ar.content.cloneNode(!0)),this.nativeEl=this.shadowRoot.querySelector("video"),xr.forEach(R=>{this.nativeEl.addEventListener(R,m=>{this.dispatchEvent(new CustomEvent(m.type,{detail:m.detail}))})});let n=this.shadowRoot.querySelector("slot");n.addEventListener("slotchange",()=>{n.assignedElements().forEach(R=>{!["track","source"].includes(R.localName)||this.nativeEl.append(R)})}),Array.prototype.forEach.call(this.attributes,R=>{Oe(this,ht,Yt).call(this,R.name,null,R.value)}),this.nativeEl.defaultMuted&&(this.nativeEl.muted=!0)},ht=new WeakSet,Yt=function(n,R,m){let S=Object.getOwnPropertyNames(Object.getPrototypeOf(this)),I=ii(S,n),T=Object.getPrototypeOf(this.constructor).toString().indexOf("function HTMLElement")===0;I&&!T?typeof this[I]=="boolean"?m===null?this[I]=!1:this[I]=!0:this[I]=m:m===null?this.nativeEl.removeAttribute(n):["id","class"].indexOf(n)===-1&&this.nativeEl.setAttribute(n,m)};var Dr=[],_r=Mt.createElement("video",{is:"castable-video"}),ri=["webkitDisplayingFullscreen","webkitSupportsFullscreen"];for(let B=Object.getPrototypeOf(_r);B&&B!==we.HTMLElement.prototype;B=Object.getPrototypeOf(B))Object.getOwnPropertyNames(B).forEach(P=>{ri.indexOf(P)===-1&&Dr.push(P)});Dr.forEach(B=>{if(B in Ne.prototype)return;if(typeof _r[B]=="function")Ne.prototype[B]=function(){return this.nativeEl[B].apply(this.nativeEl,arguments)};else{let n={get(){return this.nativeEl[B]}};B!==B.toUpperCase()&&(n.set=function(R){this.nativeEl[B]=R}),Object.defineProperty(Ne.prototype,B,n)}});function ii(B,P){let n=null;return B.forEach(R=>{R.toLowerCase()==P.toLowerCase()&&(n=R)}),n}we.customElements.get("custom-video")||(we.customElements.define("custom-video",Ne),we.CustomVideoElement=Ne);var zt=Ne;var ce={ENV_KEY:"env-key",DEBUG:"debug",PLAYBACK_ID:"playback-id",METADATA_URL:"metadata-url",PREFER_PLAYBACK:"prefer-playback",PLAYER_SOFTWARE_VERSION:"player-software-version",PLAYER_SOFTWARE_NAME:"player-software-name",METADATA_VIDEO_ID:"metadata-video-id",METADATA_VIDEO_TITLE:"metadata-video-title",METADATA_VIEWER_USER_ID:"metadata-viewer-user-id",BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",TYPE:"type",STREAM_TYPE:"stream-type",START_TIME:"start-time"},ni=Object.values(ce),ai=gr(),si="mux-video",vt=class extends zt{constructor(){super();this.__metadata={};this.__playerInitTime=lr()}static get observedAttributes(){var n;return[...ni,...(n=zt.observedAttributes)!=null?n:[]]}get playerInitTime(){return this.__playerInitTime}get playerSoftwareName(){var n;return(n=this.__playerSoftwareName)!=null?n:si}set playerSoftwareName(n){this.__playerSoftwareName=n}get playerSoftwareVersion(){var n;return(n=this.__playerSoftwareVersion)!=null?n:ai}set playerSoftwareVersion(n){this.__playerSoftwareVersion=n}get _hls(){var n;return(n=this.__core)==null?void 0:n.engine}get mux(){return this.nativeEl.mux}get error(){var n;return(n=fr(this.nativeEl))!=null?n:null}get errorTranslator(){return this.__errorTranslator}set errorTranslator(n){this.__errorTranslator=n}get src(){return this.getAttribute("src")}set src(n){n!==this.src&&(n==null?this.removeAttribute("src"):this.setAttribute("src",n))}get type(){var n;return(n=this.getAttribute(ce.TYPE))!=null?n:void 0}set type(n){n!==this.type&&(n?this.setAttribute(ce.TYPE,n):this.removeAttribute(ce.TYPE))}get autoplay(){let n=this.getAttribute("autoplay");return n===null?!1:n===""?!0:n}set autoplay(n){let R=this.autoplay;n!==R&&(n?this.setAttribute("autoplay",typeof n=="string"?n:""):this.removeAttribute("autoplay"))}get preload(){let n=this.getAttribute("preload");return n===""?"auto":["none","metadata","auto"].includes(n)?n:super.preload}set preload(n){n!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(n)?this.setAttribute("preload",n):this.removeAttribute("preload"))}get debug(){return this.getAttribute(ce.DEBUG)!=null}set debug(n){n!==this.debug&&(n?this.setAttribute(ce.DEBUG,""):this.removeAttribute(ce.DEBUG))}get startTime(){let n=this.getAttribute(ce.START_TIME);if(n==null)return;let R=+n;return Number.isNaN(R)?void 0:R}set startTime(n){n!==this.startTime&&(n==null?this.removeAttribute(ce.START_TIME):this.setAttribute(ce.START_TIME,`${n}`))}get playbackId(){var n;return(n=this.getAttribute(ce.PLAYBACK_ID))!=null?n:void 0}set playbackId(n){n!==this.playbackId&&(n?this.setAttribute(ce.PLAYBACK_ID,n):this.removeAttribute(ce.PLAYBACK_ID))}get customDomain(){var n;return(n=this.getAttribute(ce.CUSTOM_DOMAIN))!=null?n:void 0}set customDomain(n){n!==this.customDomain&&(n?this.setAttribute(ce.CUSTOM_DOMAIN,n):this.removeAttribute(ce.CUSTOM_DOMAIN))}get envKey(){var n;return(n=this.getAttribute(ce.ENV_KEY))!=null?n:void 0}set envKey(n){n!==this.envKey&&(n?this.setAttribute(ce.ENV_KEY,n):this.removeAttribute(ce.ENV_KEY))}get beaconCollectionDomain(){var n;return(n=this.getAttribute(ce.BEACON_COLLECTION_DOMAIN))!=null?n:void 0}set beaconCollectionDomain(n){n!==this.beaconCollectionDomain&&(n?this.setAttribute(ce.BEACON_COLLECTION_DOMAIN,n):this.removeAttribute(ce.BEACON_COLLECTION_DOMAIN))}get streamType(){var n;return(n=this.getAttribute(ce.STREAM_TYPE))!=null?n:void 0}set streamType(n){n!==this.streamType&&(n?this.setAttribute(ce.STREAM_TYPE,n):this.removeAttribute(ce.STREAM_TYPE))}get preferPlayback(){let n=this.getAttribute(ce.PREFER_PLAYBACK);if(n===He.MSE||n===He.NATIVE)return n}set preferPlayback(n){n!==this.preferPlayback&&(n===He.MSE||n===He.NATIVE?this.setAttribute(ce.PREFER_PLAYBACK,n):this.removeAttribute(ce.PREFER_PLAYBACK))}get metadata(){let n=this.getAttribute(ce.METADATA_VIDEO_ID),R=this.getAttribute(ce.METADATA_VIDEO_TITLE),m=this.getAttribute(ce.METADATA_VIEWER_USER_ID);return{...this.__metadata,...n!=null?{video_id:n}:{},...R!=null?{video_title:R}:{},...m!=null?{viewer_user_id:m}:{}}}set metadata(n){this.__metadata=n!=null?n:{},this.mux&&this.mux.emit("hb",this.__metadata)}load(){this.__core=dr(this,this.nativeEl,this.__core)}unload(){Kt(this.nativeEl,this.__core),this.__core=void 0}attributeChangedCallback(n,R,m){var S,I;switch(super.attributeChangedCallback(n,R,m),n){case ce.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=m!=null?m:void 0;break;case ce.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=m!=null?m:void 0;break;case"src":{let T=!!R,b=!!m;!T&&b?this.load():T&&!b?this.unload():T&&b&&(this.unload(),this.load());break}case"autoplay":if(m===R)break;(S=this.__core)==null||S.setAutoplay(this.autoplay);break;case"preload":if(m===R)break;(I=this.__core)==null||I.setPreload(m);break;case ce.PLAYBACK_ID:this.src=ur(m!=null?m:void 0,{domain:this.customDomain});break;case ce.DEBUG:{let T=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=T);break}case ce.METADATA_URL:m&&fetch(m).then(T=>T.json()).then(T=>this.metadata=T).catch(T=>console.error(`Unable to load or parse metadata JSON from metadata-url ${m}!`));break;default:break}}disconnectedCallback(){this.unload()}};we.customElements.get("mux-video")||(we.customElements.define("mux-video",vt),we.MuxVideoElement=vt);var _i=vt;export{ce as Attributes,Fe as MediaError,xr as VideoEvents,_i as default};
|
|
48
48
|
//# sourceMappingURL=mux-video.mjs.map
|