@mux/mux-audio 0.7.0 → 0.8.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 +2 -2
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +2 -2
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +2 -2
- package/dist/mux-audio.js +40 -27
- package/dist/mux-audio.js.map +3 -3
- package/dist/mux-audio.mjs +40 -27
- package/dist/mux-audio.mjs.map +3 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types-ts3.4/index.d.ts +1 -1
- package/package.json +4 -3
package/dist/mux-audio.mjs
CHANGED
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
var ur=Object.create;var Bt=Object.defineProperty;var fr=Object.getOwnPropertyDescriptor;var dr=Object.getOwnPropertyNames;var cr=Object.getPrototypeOf,hr=Object.prototype.hasOwnProperty;var Ut=(k,P)=>()=>(P||k((P={exports:{}}).exports,P),P.exports);var vr=(k,P,s,R)=>{if(P&&typeof P=="object"||typeof P=="function")for(let p of dr(P))!hr.call(k,p)&&p!==s&&Bt(k,p,{get:()=>P[p],enumerable:!(R=fr(P,p))||R.enumerable});return k};var ct=(k,P,s)=>(s=k!=null?ur(cr(k)):{},vr(P||!k||!k.__esModule?Bt(s,"default",{value:k,enumerable:!0}):s,k));var xt=(k,P,s)=>{if(!P.has(k))throw TypeError("Cannot "+s)};var ht=(k,P,s)=>(xt(k,P,"read from private field"),s?s.call(k):P.get(k)),qe=(k,P,s)=>{if(P.has(k))throw TypeError("Cannot add the same private member more than once");P instanceof WeakSet?P.add(k):P.set(k,s)},vt=(k,P,s,R)=>(xt(k,P,"write to private field"),R?R.call(k,s):P.set(k,s),s);var gt=(k,P,s)=>(xt(k,P,"access private method"),s);var jt=Ut((mt,_t)=>{(function(){var k=!1;(function(P,s){typeof mt=="object"&&typeof _t=="object"?_t.exports=s():typeof k=="function"&&k.amd?k("mux",[],s):typeof mt=="object"?mt.mux=s():P.mux=s()})(typeof self!="undefined"?self:this,function(){return function(P){function s(p){if(R[p])return R[p].exports;var x=R[p]={i:p,l:!1,exports:{}};return P[p].call(x.exports,x,x.exports,s),x.l=!0,x.exports}var R={};return s.m=P,s.c=R,s.d=function(p,x,I){s.o(p,x)||Object.defineProperty(p,x,{configurable:!1,enumerable:!0,get:I})},s.n=function(p){var x=p&&p.__esModule?function(){return p.default}:function(){return p};return s.d(x,"a",x),x},s.o=function(p,x){return Object.prototype.hasOwnProperty.call(p,x)},s.p="",s(s.s=18)}([function(P,s,R){(function(p){var x;x=typeof window!="undefined"?window:p!==void 0?p:typeof self!="undefined"?self:{},P.exports=x}).call(s,R(20))},function(P,s){function R(C,B,U){switch(U.length){case 0:return C.call(B);case 1:return C.call(B,U[0]);case 2:return C.call(B,U[0],U[1]);case 3:return C.call(B,U[0],U[1],U[2])}return C.apply(B,U)}function p(C,B){for(var U=-1,j=Array(C);++U<C;)j[U]=B(U);return j}function x(C,B){var U=F(C)||g(C)?p(C.length,String):[],j=U.length,N=!!j;for(var K in C)!B&&!l.call(C,K)||N&&(K=="length"||y(K,j))||U.push(K);return U}function I(C,B,U){var j=C[B];l.call(C,B)&&S(j,U)&&(U!==void 0||B in C)||(C[B]=U)}function T(C){if(!A(C))return O(C);var B=[];for(var U in Object(C))l.call(C,U)&&U!="constructor"&&B.push(U);return B}function L(C,B){return B=b(B===void 0?C.length-1:B,0),function(){for(var U=arguments,j=-1,N=b(U.length-B,0),K=Array(N);++j<N;)K[j]=U[B+j];j=-1;for(var H=Array(B+1);++j<B;)H[j]=U[j];return H[B]=K,R(C,this,H)}}function _(C,B,U,j){U||(U={});for(var N=-1,K=B.length;++N<K;){var H=B[N],V=j?j(U[H],C[H],H,U,C):void 0;I(U,H,V===void 0?C[H]:V)}return U}function y(C,B){return!!(B=B==null?t:B)&&(typeof C=="number"||h.test(C))&&C>-1&&C%1==0&&C<B}function D(C,B,U){if(!f(U))return!1;var j=typeof B;return!!(j=="number"?E(U)&&y(B,U.length):j=="string"&&B in U)&&S(U[B],C)}function A(C){var B=C&&C.constructor;return C===(typeof B=="function"&&B.prototype||d)}function S(C,B){return C===B||C!==C&&B!==B}function g(C){return a(C)&&l.call(C,"callee")&&(!m.call(C,"callee")||v.call(C)==u)}function E(C){return C!=null&&o(C.length)&&!e(C)}function a(C){return n(C)&&E(C)}function e(C){var B=f(C)?v.call(C):"";return B==c||B==r}function o(C){return typeof C=="number"&&C>-1&&C%1==0&&C<=t}function f(C){var B=typeof C;return!!C&&(B=="object"||B=="function")}function n(C){return!!C&&typeof C=="object"}function i(C){return E(C)?x(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,m=d.propertyIsEnumerable,O=function(C,B){return function(U){return C(B(U))}}(Object.keys,Object),b=Math.max,M=!m.call({valueOf:1},"valueOf"),F=Array.isArray,w=function(C){return L(function(B,U){var j=-1,N=U.length,K=N>1?U[N-1]:void 0,H=N>2?U[2]:void 0;for(K=C.length>3&&typeof K=="function"?(N--,K):void 0,H&&D(U[0],U[1],H)&&(K=N<3?void 0:K,N=1),B=Object(B);++j<N;){var V=U[j];V&&C(B,V,j,K)}return B})}(function(C,B){if(M||A(B)||E(B))return void _(B,i(B),C);for(var U in B)l.call(B,U)&&I(C,U,B[U])});P.exports=w},function(P,s,R){"use strict";Object.defineProperty(s,"__esModule",{value:!0});var p=R(0),x=function(T){return T&&T.__esModule?T:{default:T}}(p),I={};I.now=function(){var T=x.default.performance,L=T&&T.timing;return L&&typeof L.navigationStart=="number"&&typeof T.now=="function"?L.navigationStart+T.now():Date.now()},s.default=I},function(P,s,R){"use strict";function p(x,I,T){T=T===void 0?1:T,x[I]=x[I]||0,x[I]+=T}Object.defineProperty(s,"__esModule",{value:!0}),s.default=p},function(P,s,R){"use strict";Object.defineProperty(s,"__esModule",{value:!0});var p=R(21),x=function(T){return T&&T.__esModule?T:{default:T}}(p),I=x.default.methodFactory;x.default.methodFactory=function(T,L,_){var y=I(T,L,_);return function(){for(var D=["[mux]"],A=0;A<arguments.length;A++)D.push(arguments[A]);y.apply(void 0,D)}},x.default.setLevel(x.default.getLevel()),s.default=x.default},function(P,s,R){"use strict";Object.defineProperty(s,"__esModule",{value:!0});var p=function(T){return I(T)[0]},x=function(T){return I(T)[1]},I=function(T){if(typeof T!="string"||T==="")return["localhost"];var L=/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,_=T.match(L)||[],y=_[4],D=void 0;return y&&(D=(y.match(/[^\.]+\.[^\.]+$/)||[])[0]),[y,D]};s.extractHostnameAndDomain=I,s.extractHostname=p,s.extractDomain=x},function(P,s,R){"use strict";Object.defineProperty(s,"__esModule",{value:!0});var p=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)})},x=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)};s.generateUUID=p,s.generateShortID=x},function(P,s,R){"use strict";function p(I){I=I||"";var T={};return I.trim().split(/[\r\n]+/).forEach(function(L){if(L){var _=L.split(": "),y=_.shift();y&&(x.indexOf(y.toLowerCase())>=0||y.toLowerCase().indexOf("x-litix-")===0)&&(T[y]=_.join(": "))}}),T}Object.defineProperty(s,"__esModule",{value:!0}),s.default=p;var x=["x-cdn","content-type"]},function(P,s,R){"use strict";var p=SyntaxError,x=Function,I=TypeError,T=function(l){try{return x('"use strict"; return ('+l+").constructor;")()}catch{}},L=Object.getOwnPropertyDescriptor;if(L)try{L({},"")}catch{L=null}var _=function(){throw new I},y=L?function(){try{return arguments.callee,_}catch{try{return L(arguments,"callee").get}catch{return _}}}():_,D=R(43)(),A=Object.getPrototypeOf||function(l){return l.__proto__},S={},g=typeof Uint8Array=="undefined"?void 0:A(Uint8Array),E={"%AggregateError%":typeof AggregateError=="undefined"?void 0:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer=="undefined"?void 0:ArrayBuffer,"%ArrayIteratorPrototype%":D?A([][Symbol.iterator]()):void 0,"%AsyncFromSyncIteratorPrototype%":void 0,"%AsyncFunction%":S,"%AsyncGenerator%":S,"%AsyncGeneratorFunction%":S,"%AsyncIteratorPrototype%":S,"%Atomics%":typeof Atomics=="undefined"?void 0:Atomics,"%BigInt%":typeof BigInt=="undefined"?void 0:BigInt,"%Boolean%":Boolean,"%DataView%":typeof DataView=="undefined"?void 0:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array=="undefined"?void 0:Float32Array,"%Float64Array%":typeof Float64Array=="undefined"?void 0:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry=="undefined"?void 0:FinalizationRegistry,"%Function%":x,"%GeneratorFunction%":S,"%Int8Array%":typeof Int8Array=="undefined"?void 0:Int8Array,"%Int16Array%":typeof Int16Array=="undefined"?void 0:Int16Array,"%Int32Array%":typeof Int32Array=="undefined"?void 0:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":D?A(A([][Symbol.iterator]())):void 0,"%JSON%":typeof JSON=="object"?JSON:void 0,"%Map%":typeof Map=="undefined"?void 0:Map,"%MapIteratorPrototype%":typeof Map!="undefined"&&D?A(new Map()[Symbol.iterator]()):void 0,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise=="undefined"?void 0:Promise,"%Proxy%":typeof Proxy=="undefined"?void 0:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect=="undefined"?void 0:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set=="undefined"?void 0:Set,"%SetIteratorPrototype%":typeof Set!="undefined"&&D?A(new Set()[Symbol.iterator]()):void 0,"%SharedArrayBuffer%":typeof SharedArrayBuffer=="undefined"?void 0:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":D?A(""[Symbol.iterator]()):void 0,"%Symbol%":D?Symbol:void 0,"%SyntaxError%":p,"%ThrowTypeError%":y,"%TypedArray%":g,"%TypeError%":I,"%Uint8Array%":typeof Uint8Array=="undefined"?void 0:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray=="undefined"?void 0:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array=="undefined"?void 0:Uint16Array,"%Uint32Array%":typeof Uint32Array=="undefined"?void 0:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap=="undefined"?void 0:WeakMap,"%WeakRef%":typeof WeakRef=="undefined"?void 0:WeakRef,"%WeakSet%":typeof WeakSet=="undefined"?void 0:WeakSet},a=function l(v){var m;if(v==="%AsyncFunction%")m=T("async function () {}");else if(v==="%GeneratorFunction%")m=T("function* () {}");else if(v==="%AsyncGeneratorFunction%")m=T("async function* () {}");else if(v==="%AsyncGenerator%"){var O=l("%AsyncGeneratorFunction%");O&&(m=O.prototype)}else if(v==="%AsyncIteratorPrototype%"){var b=l("%AsyncGenerator%");b&&(m=A(b.prototype))}return E[v]=m,m},e={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},o=R(9),f=R(46),n=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 O=[];return t(l,c,function(b,M,F,w){O[O.length]=F?t(w,r,"$1"):M||b}),O},d=function(l,v){var m,O=l;if(f(e,O)&&(m=e[O],O="%"+m[0]+"%"),f(E,O)){var b=E[O];if(b===S&&(b=a(O)),b===void 0&&!v)throw new I("intrinsic "+l+" exists, but is not available. Please file an issue!");return{alias:m,name:O,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),O=m.length>0?m[0]:"",b=d("%"+O+"%",v),M=b.name,F=b.value,w=!1,C=b.alias;C&&(O=C[0],i(m,n([0,1],C)));for(var B=1,U=!0;B<m.length;B+=1){var j=m[B],N=u(j,0,1),K=u(j,-1);if((N==='"'||N==="'"||N==="`"||K==='"'||K==="'"||K==="`")&&N!==K)throw new p("property names with quotes must have matching quotes");if(j!=="constructor"&&U||(w=!0),O+="."+j,M="%"+O+"%",f(E,M))F=E[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(L&&B+1>=m.length){var H=L(F,j);U=!!H,F=U&&"get"in H&&!("originalValue"in H.get)?H.get:F[j]}else U=f(F,j),F=F[j];U&&!w&&(E[M]=F)}}return F}},function(P,s,R){"use strict";var p=R(45);P.exports=Function.prototype.bind||p},function(P,s,R){"use strict";var p=String.prototype.replace,x=/%20/g,I={RFC1738:"RFC1738",RFC3986:"RFC3986"};P.exports={default:I.RFC3986,formatters:{RFC1738:function(T){return p.call(T,x,"+")},RFC3986:function(T){return String(T)}},RFC1738:I.RFC1738,RFC3986:I.RFC3986}},function(P,s,R){"use strict";Object.defineProperty(s,"__esModule",{value:!0}),s.findMediaElement=s.getMuxPlayerId=void 0;var p=R(6),x=function(T){return T&&T.nodeName!==void 0?(T.muxId||(T.muxId=T.id||(0,p.generateShortID)()),T.muxId):T},I=function(T){var L=void 0;return T&&T.nodeName!==void 0?(L=T,T=x(L)):L=document.querySelector(T),[L,T,L&&L.nodeName?L.nodeName.toLowerCase():""]};s.getMuxPlayerId=x,s.findMediaElement=I},function(P,s,R){"use strict";function p(){return(I.default.doNotTrack||I.default.navigator&&(I.default.navigator.doNotTrack||I.default.navigator.msDoNotTrack))==="1"}Object.defineProperty(s,"__esModule",{value:!0}),s.default=p;var x=R(0),I=function(T){return T&&T.__esModule?T:{default:T}}(x)},function(P,s,R){"use strict";Object.defineProperty(s,"__esModule",{value:!0});var p=R(0),x=function(T){return T&&T.__esModule?T:{default:T}}(p),I={};I.exists=function(){var T=x.default.performance;return(T&&T.timing)!==void 0},I.domContentLoadedEventEnd=function(){var T=x.default.performance,L=T&&T.timing;return L&&L.domContentLoadedEventEnd},I.navigationStart=function(){var T=x.default.performance,L=T&&T.timing;return L&&L.navigationStart},s.default=I},function(P,s,R){"use strict";Object.defineProperty(s,"__esModule",{value:!0});var p=function(x){var I={};for(var T in x){var L=x[T];L["DATA-ID"].search("io.litix.data.")!==-1&&(I[L["DATA-ID"].replace("io.litix.data.","")]=L.VALUE)}return I};s.default=p},function(P,s,R){"use strict";var p=R(41),x=R(51),I=R(10);P.exports={formats:I,parse:x,stringify:p}},function(P,s,R){"use strict";var p=R(10),x=Object.prototype.hasOwnProperty,I=Array.isArray,T=function(){for(var f=[],n=0;n<256;++n)f.push("%"+((n<16?"0":"")+n.toString(16)).toUpperCase());return f}(),L=function(f){for(;f.length>1;){var n=f.pop(),i=n.obj[n.prop];if(I(i)){for(var t=[],u=0;u<i.length;++u)i[u]!==void 0&&t.push(i[u]);n.obj[n.prop]=t}}},_=function(f,n){for(var i=n&&n.plainObjects?Object.create(null):{},t=0;t<f.length;++t)f[t]!==void 0&&(i[t]=f[t]);return i},y=function f(n,i,t){if(!i)return n;if(typeof i!="object"){if(I(n))n.push(i);else{if(!n||typeof n!="object")return[n,i];(t&&(t.plainObjects||t.allowPrototypes)||!x.call(Object.prototype,i))&&(n[i]=!0)}return n}if(!n||typeof n!="object")return[n].concat(i);var u=n;return I(n)&&!I(i)&&(u=_(n,t)),I(n)&&I(i)?(i.forEach(function(c,r){if(x.call(n,r)){var h=n[r];h&&typeof h=="object"&&c&&typeof c=="object"?n[r]=f(h,c,t):n.push(c)}else n[r]=c}),n):Object.keys(i).reduce(function(c,r){var h=i[r];return x.call(c,r)?c[r]=f(c[r],h,t):c[r]=h,c},u)},D=function(f,n){return Object.keys(n).reduce(function(i,t){return i[t]=n[t],i},f)},A=function(f,n,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}},S=function(f,n,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+=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 n=[{obj:{o:f},prop:"o"}],i=[],t=0;t<n.length;++t)for(var u=n[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&&(n.push({obj:c,prop:d}),i.push(l))}return L(n),f},E=function(f){return Object.prototype.toString.call(f)==="[object RegExp]"},a=function(f){return!(!f||typeof f!="object")&&!!(f.constructor&&f.constructor.isBuffer&&f.constructor.isBuffer(f))},e=function(f,n){return[].concat(f,n)},o=function(f,n){if(I(f)){for(var i=[],t=0;t<f.length;t+=1)i.push(n(f[t]));return i}return n(f)};P.exports={arrayToObject:_,assign:D,combine:e,compact:g,decode:A,encode:S,isBuffer:a,isRegExp:E,maybeMap:o,merge:y}},function(P,s,R){"use strict";function p(E){return E&&E.__esModule?E:{default:E}}function x(E){var a={};for(var e in E)E.hasOwnProperty(e)&&(a[E[e]]=e);return a}function I(E){var a={},e={};return Object.keys(E).forEach(function(o){var f=!1;if(E.hasOwnProperty(o)&&E[o]!==void 0){var n=o.split("_"),i=n[0],t=A[i];t||(L.default.info("Data key word `"+n[0]+"` not expected in "+o),t=i+"_"),n.splice(1).forEach(function(u){u==="url"&&(f=!0),g[u]?t+=g[u]:Number(u)&&Math.floor(Number(u))===Number(u)?t+=u:(L.default.info("Data key word `"+u+"` not expected in "+o),t+="_"+u+"_")}),f?e[t]=E[o]:a[t]=E[o]}}),(0,y.default)(a,e)}Object.defineProperty(s,"__esModule",{value:!0}),s.default=I;var T=R(4),L=p(T),_=R(1),y=p(_),D={a:"env",b:"beacon",c:"custom",d:"ad",e:"event",f:"experiment",i:"internal",m:"mux",n:"response",p:"player",q:"request",r:"retry",s:"session",t:"timestamp",u:"viewer",v:"video",w:"page",x:"view",y:"sub"},A=x(D),S={ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",ca:"cached",cb:"cancel",cd:"code",cg:"category",ch:"changed",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ep:"experiments",fi:"first",fm:"family",ft:"format",fq:"frequency",fr:"frame",fs:"fullscreen",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"},g=x(S)},function(P,s,R){"use strict";P.exports=R(19).default},function(P,s,R){"use strict";function p(r){return r&&r.__esModule?r:{default:r}}Object.defineProperty(s,"__esModule",{value:!0});var x=function(){function r(h,d){var l=[],v=!0,m=!1,O=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,O=F}finally{try{!v&&M.return&&M.return()}finally{if(m)throw O}}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=p(I),L=R(11),_=R(4),y=p(_),D=R(12),A=p(D),S=R(2),g=p(S),E=R(22),a=p(E),e=R(58),o=p(e),f=R(59),n=p(f),i=R(64),t=p(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):y.default.warn("`"+h+"` is an unknown task"):typeof h=="function"?T.default.setTimeout(function(){h(r)},0):y.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,L.findMediaElement)(r),d=x(h,1),l=d[0];l&&l.mux&&typeof l.mux.destroy=="function"?l.mux.destroy():y.default.error("A video element monitor for `"+r+"` has not been initialized via `mux.monitor`.")},c.addHLSJS=function(r,h){var d=(0,L.getMuxPlayerId)(r);u[d]?u[d].addHLSJS(h):y.default.error("A monitor for `"+d+"` has not been initialized.")},c.addDashJS=function(r,h){var d=(0,L.getMuxPlayerId)(r);u[d]?u[d].addDashJS(h):y.default.error("A monitor for `"+d+"` has not been initialized.")},c.removeHLSJS=function(r){var h=(0,L.getMuxPlayerId)(r);u[h]?u[h].removeHLSJS():y.default.error("A monitor for `"+h+"` has not been initialized.")},c.removeDashJS=function(r){var h=(0,L.getMuxPlayerId)(r);u[h]?u[h].removeDashJS():y.default.error("A monitor for `"+h+"` has not been initialized.")},c.init=function(r,h){(0,A.default)()&&h&&h.respectDoNotTrack&&y.default.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var d=(0,L.getMuxPlayerId)(r);u[d]=new a.default(c,d,h)},c.emit=function(r,h,d){var l=(0,L.getMuxPlayerId)(r);u[l]?(u[l].emit(h,d),h==="destroy"&&delete u[l]):y.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=A.default,c.log=y.default,c.utils=n.default,c.events=t.default,s.default=c},function(P,s){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,s,R){var p,x;(function(I,T){"use strict";p=T,(x=typeof p=="function"?p.call(s,R,s,P):p)!==void 0&&(P.exports=x)})(0,function(){"use strict";function I(n,i){var t=n[i];if(typeof t.bind=="function")return t.bind(n);try{return Function.prototype.bind.call(t,n)}catch{return function(){return Function.prototype.apply.apply(t,[n,arguments])}}}function T(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function L(n){return n==="debug"&&(n="log"),typeof console!==g&&(n==="trace"&&E?T:console[n]!==void 0?I(console,n):console.log!==void 0?I(console,"log"):S)}function _(n,i){for(var t=0;t<a.length;t++){var u=a[t];this[u]=t<n?S:this.methodFactory(u,n,i)}this.log=this.debug}function y(n,i,t){return function(){typeof console!==g&&(_.call(this,i,t),this[n].apply(this,arguments))}}function D(n,i,t){return L(n)||y.apply(this,arguments)}function A(n,i,t){function u(m){var O=(a[m]||"silent").toUpperCase();if(typeof window!==g&&l){try{return void(window.localStorage[l]=O)}catch{}try{window.document.cookie=encodeURIComponent(l)+"="+O+";"}catch{}}}function c(){var m;if(typeof window!==g&&l){try{m=window.localStorage[l]}catch{}if(typeof m===g)try{var O=window.document.cookie,b=O.indexOf(encodeURIComponent(l)+"=");b!==-1&&(m=/^([^;]+)/.exec(O.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 n=="string"?l+=":"+n:typeof n=="symbol"&&(l=void 0),d.name=n,d.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},d.methodFactory=t||D,d.getLevel=function(){return h},d.setLevel=function(m,O){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,O!==!1&&u(m),_.call(d,m,n),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 S=function(){},g="undefined",E=typeof window!==g&&typeof window.navigator!==g&&/Trident\/|MSIE /.test(window.navigator.userAgent),a=["trace","debug","info","warn","error"],e=new A,o={};e.getLogger=function(n){if(typeof n!="symbol"&&typeof n!="string"||n==="")throw new TypeError("You must supply a name when creating a logger.");var i=o[n];return i||(i=o[n]=new A(n,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,s,R){"use strict";function p(ee){return ee&&ee.__esModule?ee:{default:ee}}Object.defineProperty(s,"__esModule",{value:!0});var x=function(){function ee($,Z){var ue=[],he=!0,se=!1,pe=void 0;try{for(var ye,Te=$[Symbol.iterator]();!(he=(ye=Te.next()).done)&&(ue.push(ye.value),!Z||ue.length!==Z);he=!0);}catch(ae){se=!0,pe=ae}finally{try{!he&&Te.return&&Te.return()}finally{if(se)throw pe}}return ue}return function($,Z){if(Array.isArray($))return $;if(Symbol.iterator in Object($))return ee($,Z);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),I=R(4),T=p(I),L=R(1),_=p(L),y=R(6),D=R(5),A=R(0),S=p(A),g=R(13),E=p(g),a=R(3),e=p(a),o=R(23),f=R(24),n=R(25),i=p(n),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),O=p(m),b=R(31),M=p(b),F=R(32),w=p(F),C=R(33),B=p(C),U=R(34),j=p(U),N=R(35),K=p(N),H=R(36),V=p(H),Y=R(37),Q=p(Y),J=R(38),z=p(J),q=R(39),re=p(q),X=R(57),le=p(X),ne=["viewstart","ended","loadstart","pause","play","playing","ratechange","waiting","adplay","adpause","adended","aderror","adplaying","adrequest","adresponse","adbreakstart","adbreakend","adfirstquartile","admidpoint","adthirdquartile","rebufferstart","rebufferend","seeked","error","hb","requestcompleted","requestfailed","requestcanceled","renditionchange"],te=function(ee,$,Z){var ue=this;this.DOM_CONTENT_LOADED_EVENT_END=E.default.domContentLoadedEventEnd(),this.NAVIGATION_START=E.default.navigationStart();var he={debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(ae){return ae}};this.mux=ee,this.id=$,Z=(0,_.default)(he,Z),Z.data=Z.data||{},Z.data.property_key&&(Z.data.env_key=Z.data.property_key,delete Z.data.property_key),T.default.setLevel(Z.debug?"debug":"warn"),this.getPlayheadTime=Z.getPlayheadTime,this.getStateData=Z.getStateData||function(){},this.getAdData=Z.getAdData||function(){},this.minimumRebufferDuration=Z.minimumRebufferDuration,this.sustainedRebufferThreshold=Z.sustainedRebufferThreshold,this.playbackHeartbeatTime=Z.playbackHeartbeatTime,this.disableRebufferTracking=Z.disableRebufferTracking,this.disableRebufferTracking&&this.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."),this.errorTranslator=Z.errorTranslator,this.playbackEventDispatcher=new re.default(ee,Z.data.env_key,Z),this.data={player_instance_id:(0,y.generateUUID)(),mux_sample_rate:Z.sampleRate,beacon_domain:Z.beaconCollectionDomain?Z.beaconCollectionDomain:Z.beaconDomain},this.data.view_sequence_number=1,this.data.player_sequence_number=1,this.oldEmit=this.emit,this.emit=function(ae,fe){fe=(0,_.default)({viewer_time:this.mux.utils.now()},fe),this.oldEmit(ae,fe)};var se=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(this);this.on("viewinit",function(ae,fe){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),(0,_.default)(this.data,fe),this._initializeViewData(),this.one("play",se),this.one("adbreakstart",se)});var pe=function(ae){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",ae)}.bind(this);if(this.on("videochange",function(ae,fe){pe(fe)}),this.on("programchange",function(ae,fe){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),pe((0,_.default)(fe,{view_program_changed:!0})),se(),this.emit("play"),this.emit("playing")}),this.on("fragmentchange",function(ae,fe){this.currentFragmentPDT=fe.currentFragmentPDT,this.currentFragmentStart=fe.currentFragmentStart}),this.on("destroy",this.destroy),S.default!==void 0&&typeof S.default.addEventListener=="function"&&typeof S.default.removeEventListener=="function"){var ye=function(ae){ae.persisted||ue.destroy()};S.default.addEventListener("pagehide",ye,!1),this.on("destroy",function(){S.default.removeEventListener("pagehide",ye)})}this.on("playerready",function(ae,fe){(0,_.default)(this.data,fe)}),ne.forEach(function(ae){ue.on(ae,function(fe,ge){ae.indexOf("ad")!==0&&this._updateStateData(),(0,_.default)(this.data,ge),this._sanitizeData()}),ue.on("after"+ae,function(){(ae!=="error"||this.viewErrored)&&this.send(ae)})}),this.on("viewend",function(ae,fe){(0,_.default)(ue.data,fe)});var Te=function(ae){var fe=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=fe-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time};this.one("playerready",Te),r.default.apply(this),z.default.apply(this),K.default.apply(this),O.default.apply(this),u.default.apply(this),j.default.apply(this),d.default.apply(this),v.default.apply(this),V.default.apply(this),M.default.apply(this),w.default.apply(this),B.default.apply(this),Q.default.apply(this),le.default.apply(this),Z.hlsjs&&this.addHLSJS(Z),Z.dashjs&&this.addDashJS(Z),this.emit("viewinit",Z.data)};(0,_.default)(te.prototype,i.default.prototype),(0,_.default)(te.prototype,O.default.prototype),(0,_.default)(te.prototype,K.default.prototype),(0,_.default)(te.prototype,u.default.prototype),(0,_.default)(te.prototype,d.default.prototype),(0,_.default)(te.prototype,v.default.prototype),(0,_.default)(te.prototype,V.default.prototype),(0,_.default)(te.prototype,w.default.prototype),(0,_.default)(te.prototype,B.default.prototype),te.prototype.destroy=function(){this._destroyed||(this._destroyed=!0,this.data.view_start!==void 0&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),S.default.clearTimeout(this._heartBeatTimeout))},te.prototype.send=function(ee){var $=(0,_.default)({},this.data),Z=["player_program_time","player_manifest_newest_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"];if($.video_source_is_live===void 0&&($.player_source_duration===1/0||$.video_source_duration===1/0?$.video_source_is_live=!0:($.player_source_duration>0||$.video_source_duration>0)&&($.video_source_is_live=!1)),$.video_source_is_live||Z.forEach(function(ye){$[ye]=void 0}),$.video_source_url=$.video_source_url||$.player_source_url,$.video_source_url){var ue=(0,D.extractHostnameAndDomain)($.video_source_url),he=x(ue,2),se=he[0],pe=he[1];$.video_source_domain=pe,$.video_source_hostname=se}delete $.ad_request_id,this.playbackEventDispatcher.send(ee,$),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()},te.prototype._updateStateData=function(){(0,_.default)(this.data,this.getStateData()),this._updatePlayheadTime(),this._sanitizeData()},te.prototype._sanitizeData=function(){var ee=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function($){var Z=parseInt(ee.data[$],10);ee.data[$]=isNaN(Z)?void 0:Z}),["player_source_url","video_source_url"].forEach(function($){if(ee.data[$]){var Z=ee.data[$].toLowerCase();Z.indexOf("data:")!==0&&Z.indexOf("blob:")!==0||(ee.data[$]="MSE style URL")}})},te.prototype._resetVideoData=function(ee,$){var Z=this;Object.keys(this.data).forEach(function(ue){ue.indexOf("video_")===0&&delete Z.data[ue]})},te.prototype._resetViewData=function(){var ee=this;Object.keys(this.data).forEach(function($){$.indexOf("view_")===0&&delete ee.data[$]}),this.data.view_sequence_number=1},te.prototype._resetErrorData=function(ee,$){delete this.data.player_error_code,delete this.data.player_error_message},te.prototype._initializeViewData=function(){var ee=this,$=this.data.view_id=(0,y.generateUUID)(),Z=function(){$===ee.data.view_id&&(0,e.default)(ee.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",Z):Z()},te.prototype._restartHeartBeat=function(){var ee=this;S.default.clearTimeout(this._heartBeatTimeout),this.viewErrored||(this._heartBeatTimeout=S.default.setTimeout(function(){ee.data.player_is_paused||ee.emit("hb")},1e4))},te.prototype.addHLSJS=function(ee){return ee.hlsjs?this.hlsjs?void this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=ee.hlsjs,void(0,o.monitorHlsJs)(this.mux,this.id,ee.hlsjs,{},ee.Hls||S.default.Hls)):void this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")},te.prototype.removeHLSJS=function(){this.hlsjs&&((0,o.stopMonitoringHlsJs)(this.hlsjs),this.hlsjs=void 0)},te.prototype.addDashJS=function(ee){return ee.dashjs?this.dashjs?void this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=ee.dashjs,void(0,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.")},te.prototype.removeDashJS=function(){this.dashjs&&((0,f.stopMonitoringDashJS)(this.dashjs),this.dashjs=void 0)},s.default=te},function(P,s,R){"use strict";function p(a){return a&&a.__esModule?a:{default:a}}Object.defineProperty(s,"__esModule",{value:!0}),s.stopMonitoringHlsJs=s.monitorHlsJs=void 0;var x=R(7),I=p(x),T=R(13),L=p(T),_=R(5),y=R(14),D=p(y),A=function(a){if(!a)return{};var e=L.default.navigationStart(),o=a.loading,f=o?o.start:a.trequest,n=o?o.first:a.tfirst,i=o?o.end:a.tload;return{bytesLoaded:a.total,requestStart:Math.round(e+f),responseStart:Math.round(e+n),responseEnd:Math.round(e+i)}},S=function(a){if(a&&typeof a.getAllResponseHeaders=="function")return(0,I.default)(a.getAllResponseHeaders())},g=function(a,e,o){var f=(arguments.length>3&&arguments[3]!==void 0&&arguments[3],arguments[4]),n=a.log,i=a.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(!L.default.exists())return void n.warn("performance timing not supported. Not tracking HLS.js.");var u=function(b,M){return a.emit(e,b,M)},c=function(b,M){var F=M.levels,w=M.audioTracks,C=M.url,B=M.stats,U=M.networkDetails,j=M.sessionData,N={},K={},H={};H=(0,D.default)(j),F.forEach(function(q,re){N[re]={width:q.width,height:q.height,bitrate:q.bitrate,attrs:q.attrs}}),w.forEach(function(q,re){K[re]={name:q.name,language:q.lang,bitrate:q.bitrate}});var V=A(B),Y=V.bytesLoaded,Q=V.requestStart,J=V.responseStart,z=V.responseEnd;H.request_event_type=b,H.request_bytes_loaded=Y,H.request_start=Q,H.request_response_start=J,H.request_response_end=z,H.request_type="manifest",H.request_hostname=(0,_.extractHostname)(C),H.request_response_headers=S(U),H.request_rendition_lists={media:N,audio:K,video:{}},u("requestcompleted",H)};o.on(f.Events.MANIFEST_LOADED,c);var r=function(b,M){var F=M.details,w=M.level,C=M.networkDetails,B=M.stats,U=A(B),j=U.bytesLoaded,N=U.requestStart,K=U.responseStart,H=U.responseEnd,V=F.fragments[F.fragments.length-1],Y=t(V)+i(V.duration);u("requestcompleted",{request_event_type:b,request_bytes_loaded:j,request_start:N,request_response_start:K,request_response_end:H,request_current_level:w,request_type:"manifest",request_hostname:(0,_.extractHostname)(F.url),request_response_headers:S(C),video_holdback:F.holdBack&&i(F.holdBack),video_part_holdback:F.partHoldBack&&i(F.partHoldBack),video_part_target_duration:F.partTarget&&i(F.partTarget),video_target_duration:F.targetduration&&i(F.targetduration),video_source_is_live:F.live,player_manifest_newest_program_time:isNaN(Y)?void 0:Y})};o.on(f.Events.LEVEL_LOADED,r);var h=function(b,M){var F=M.details,w=M.networkDetails,C=M.stats,B=A(C),U=B.bytesLoaded,j=B.requestStart,N=B.responseStart,K=B.responseEnd;u("requestcompleted",{request_event_type:b,request_bytes_loaded:U,request_start:j,request_response_start:N,request_response_end:K,request_type:"manifest",request_hostname:(0,_.extractHostname)(F.url),request_response_headers:S(w)})};o.on(f.Events.AUDIO_TRACK_LOADED,h);var d=function(b,M){var F=M.stats,w=M.networkDetails,C=M.frag,B=A(F),U=B.bytesLoaded,j=B.requestStart,N=B.responseStart,K=B.responseEnd,H={request_event_type:b,request_bytes_loaded:U,request_start:j,request_response_start:N,request_response_end:K,request_hostname:w?(0,_.extractHostname)(w.responseURL):void 0,request_response_headers:S(w),request_media_duration:C.duration};C.type==="main"?(H.request_type="media",H.request_current_level=C.level,H.request_video_width=(o.levels[C.level]||{}).width,H.request_video_height=(o.levels[C.level]||{}).height):H.request_type=C.type,u("requestcompleted",H)};o.on(f.Events.FRAG_LOADED,d);var l=function(b,M){var F=M.frag,w=F.start,C=t(F),B={currentFragmentPDT:C,currentFragmentStart:i(w)};u("fragmentchange",B)};o.on(f.Events.FRAG_CHANGED,l);var v=function(b,M){var F=M.type,w=M.details,C=M.response,B=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})}B&&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 O=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}):n.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};o.on(f.Events.LEVEL_SWITCHED,O),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,O),o.off(f.Events.DESTROYING,o._stopMuxMonitor),delete o._stopMuxMonitor},o.on(f.Events.DESTROYING,o._stopMuxMonitor)},E=function(a){a&&typeof a._stopMuxMonitor=="function"&&a._stopMuxMonitor()};s.monitorHlsJs=g,s.stopMonitoringHlsJs=E},function(P,s,R){"use strict";function p(g){return g&&g.__esModule?g:{default:g}}Object.defineProperty(s,"__esModule",{value:!0}),s.stopMonitoringDashJS=s.monitorDashJS=void 0;var x=R(0),I=p(x),T=R(7),L=p(T),_=R(5),y=function(g,E){if(!g||typeof g.getRequests!="function")return{};var a=g.getRequests({state:"executed"});if(a.length===0)return{};var e=a[a.length-1],o=(0,_.extractHostname)(e.url),f=e.bytesLoaded,n=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 E.getMetricsFor=="function"?E.getMetricsFor(e.mediaType).HttpList:E.getDashMetrics().getHttpRequests(e.mediaType),r=void 0;return c.length>0&&(r=(0,L.default)(c[c.length-1]._responseHeaders||"")),{requestStart:n,requestResponseStart:i,requestResponseEnd:t,requestBytesLoaded:f,requestResponseHeaders:r,requestMediaDuration:u,requestHostname:o}},D=function(g,E){var a=E.getQualityFor(g),e=E.getCurrentTrackFor(g),o=e.bitrateList;return o?{currentLevel:a,renditionWidth:o[a].width||null,renditionHeight:o[a].height||null,renditionBitrate:o[a].bandwidth}:{}},A=function(g,E,a){var e=(arguments.length>3&&arguments[3]!==void 0&&arguments[3],g.log);if(!a||!a.on)return void e.warn("Invalid dash.js player reference. Monitoring blocked.");var o=function(d,l){return g.emit(E,d,l)},f=function(d){var l=d.type,v=d.data,m=v||{},O=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)(O)})};a.on("manifestLoaded",f);var n={},i=function(d){var l=d.type,v=d.fragmentModel,m=d.chunk,O=m||{},b=O.mediaInfo,M=b||{},F=M.type,w=M.bitrateList;w=w||[];var C={};w.forEach(function(Y,Q){C[Q]={},C[Q].width=Y.width,C[Q].height=Y.height,C[Q].bitrate=Y.bandwidth,C[Q].attrs={}}),F==="video"?n.video=C:F==="audio"?n.audio=C:n.media=C;var B=y(v,a),U=B.requestStart,j=B.requestResponseStart,N=B.requestResponseEnd,K=B.requestResponseHeaders,H=B.requestMediaDuration,V=B.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:K,request_hostname:V,request_media_duration:H,request_rendition_lists:n})};a.on("initFragmentLoaded",i);var t=function(d){var l=d.type,v=d.fragmentModel,m=d.chunk,O=m||{},b=O.mediaInfo,M=O.start,F=b||{},w=F.type,C=y(v,a),B=C.requestStart,U=C.requestResponseStart,j=C.requestResponseEnd,N=C.requestBytesLoaded,K=C.requestResponseHeaders,H=C.requestMediaDuration,V=C.requestHostname,Y=D(w,a),Q=Y.currentLevel,J=Y.renditionWidth,z=Y.renditionHeight,q=Y.renditionBitrate;o("requestcompleted",{request_event_type:l,request_start:B,request_response_start:U,request_response_end:j,request_bytes_loaded:N,request_type:w,request_response_headers:K,request_hostname:V,request_media_start_time:M,request_media_duration:H,request_current_level:Q,request_labeled_bitrate:q,request_video_width:J,request_video_height:z})};a.on("mediaFragmentLoaded",t);var 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 O=a.getBitrateInfoListFor(m).find(function(M){return M.qualityIndex===d.newQuality});if(!O||typeof O.bitrate!="number")return void e.warn("missing bitrate info for "+m);u[m]=O;var b=c();b&&o("renditionchange",b)}};a.on("qualityChangeRendered",r);var h=function(d){var l=d.error,v=d.event;v=v||{};var m=v.request||{},O=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:O.status,request_error_type:O.statusText})};a.on("error",h),a._stopMuxMonitor=function(){a.off("manifestLoaded",f),a.off("initFragmentLoaded",i),a.off("mediaFragmentLoaded",t),a.off("qualityChangeRendered",r),a.off("error",h),delete a._stopMuxMonitor}},S=function(g){g&&typeof g._stopMuxMonitor=="function"&&g._stopMuxMonitor()};s.monitorDashJS=A,s.stopMonitoringDashJS=S},function(P,s,R){"use strict";Object.defineProperty(s,"__esModule",{value:!0});var p=function(){},x=0;p.prototype.on=function(I,T,L){return T._eventEmitterGuid=T._eventEmitterGuid||++x,this._listeners=this._listeners||{},this._listeners[I]=this._listeners[I]||[],L&&(T=T.bind(L)),this._listeners[I].push(T),T},p.prototype.off=function(I,T){var L=this._listeners&&this._listeners[I];L&&L.forEach(function(_,y){_._eventEmitterGuid===T._eventEmitterGuid&&L.splice(y,1)})},p.prototype.one=function(I,T,L){var _=this;T._eventEmitterGuid=T._eventEmitterGuid||++x;var y=function D(){_.off(I,D),T.apply(L||this,arguments)};y._eventEmitterGuid=T._eventEmitterGuid,this.on(I,y)},p.prototype.emit=function(I,T){var L=this;if(this._listeners){T=T||{};var _=this._listeners["before*"]||[],y=this._listeners[I]||[],D=this._listeners["after"+I]||[],A=function(S,g){S=S.slice(),S.forEach(function(E){E.call(L,{type:I},g)})};A(_,T),A(y,T),A(D,T)}},s.default=p},function(P,s,R){"use strict";Object.defineProperty(s,"__esModule",{value:!0});var p=R(0),x=function(T){return T&&T.__esModule?T:{default:T}}(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(T,L){this._playbackHeartbeatInterval!==null&&(x.default.clearInterval(this._playbackHeartbeatInterval),this.emit("playbackheartbeatend",{viewer_time:L.viewer_time}),this._playbackHeartbeatInterval=null)})};I.prototype._startPlaybackHeartbeatInterval=function(){var T=this;this._playbackHeartbeatInterval===null&&(this.emit("playbackheartbeat"),this._playbackHeartbeatInterval=x.default.setInterval(function(){T.emit("playbackheartbeat")},this.playbackHeartbeatTime))},I.prototype._stopPlaybackHeartbeatInterval=function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(x.default.clearInterval(this._playbackHeartbeatInterval),this.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)},s.default=I},function(P,s,R){"use strict";function p(){var x=this;this.on("viewinit",function(){x.viewErrored=!1}),this.on("error",function(){try{var I=x.errorTranslator({player_error_code:x.data.player_error_code,player_error_message:x.data.player_error_message});I?(x.data.player_error_code=I.player_error_code,x.data.player_error_message=I.player_error_message,x.viewErrored=!0):(delete x.data.player_error_code,delete x.data.player_error_message)}catch(T){x.mux.log.warn("Exception in error translator callback.",T),x.viewErrored=!0}})}Object.defineProperty(s,"__esModule",{value:!0}),s.default=p},function(P,s,R){"use strict";Object.defineProperty(s,"__esModule",{value:!0});var p=R(3),x=function(T){return T&&T.__esModule?T:{default:T}}(p),I=function(){this._watchTimeTrackerLastCheckedTime=null,this.on("playbackheartbeat",this._updateWatchTime),this.on("playbackheartbeatend",this._clearWatchTimeState)};I.prototype._updateWatchTime=function(T,L){var _=L.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=_),(0,x.default)(this.data,"view_watch_time",_-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=_},I.prototype._clearWatchTimeState=function(T,L){this._updateWatchTime(T,L),this._watchTimeTrackerLastCheckedTime=null},s.default=I},function(P,s,R){"use strict";Object.defineProperty(s,"__esModule",{value:!0});var p=R(3),x=function(T){return T&&T.__esModule?T:{default:T}}(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 T=this.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&T>this._playbackTimeTrackerLastPlayheadPosition){var L=T-this._playbackTimeTrackerLastPlayheadPosition;L<=1e3&&(0,x.default)(this.data,"view_content_playback_time",L)}this._playbackTimeTrackerLastPlayheadPosition=T},I.prototype._clearPlaybackTimeState=function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1},s.default=I},function(P,s,R){"use strict";Object.defineProperty(s,"__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(x,I){var T=this,L=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,L(),this._updateMaxPlayheadPosition();else if(this.getPlayheadTime){var _=this.getPlayheadTime();_!==void 0&&(this.data.player_playhead_time=_,L(),this._updateMaxPlayheadPosition())}},s.default=p},function(P,s,R){"use strict";function p(){var T=this;if(!this.disableRebufferTracking){var L=void 0,_=function(){if(L){var y=T.data.viewer_time-L;(0,I.default)(T.data,"view_rebuffer_duration",y),L=T.data.viewer_time}T.data.view_watch_time>=0&&T.data.view_rebuffer_count>0&&(T.data.view_rebuffer_frequency=T.data.view_rebuffer_count/T.data.view_watch_time,T.data.view_rebuffer_percentage=T.data.view_rebuffer_duration/T.data.view_watch_time)};this.on("playbackheartbeat",function(){return _()}),this.on("rebufferstart",function(){L||((0,I.default)(T.data,"view_rebuffer_count",1),L=T.data.viewer_time,T.one("rebufferend",function(){_(),L=void 0}))})}}Object.defineProperty(s,"__esModule",{value:!0}),s.default=p;var x=R(3),I=function(T){return T&&T.__esModule?T:{default:T}}(x)},function(P,s,R){"use strict";Object.defineProperty(s,"__esModule",{value:!0});var p=R(2),x=function(T){return T&&T.__esModule?T:{default:T}}(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:x.default.now()})}))};I.prototype._checkIfRebuffering=function(T,L){return this.isSeeking||this.isAdBreak||!this._playheadShouldBeProgressing?void this._cleanupRebufferTracker(T,L):this._lastCheckedTime===null?void this._prepareRebufferTrackerState(L.viewer_time):this._lastPlayheadTime!==this.data.player_playhead_time?void this._cleanupRebufferTracker(T,L,!0):(L.viewer_time-this._lastPlayheadTimeUpdatedTime>=this.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),void(this._lastCheckedTime=L.viewer_time))},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,L){var _=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.emit("rebufferend",{viewer_time:L.viewer_time});else{if(this._lastCheckedTime===null)return;var y=this.data.player_playhead_time-this._lastPlayheadTime,D=L.viewer_time-this._lastPlayheadTimeUpdatedTime;y>0&&D-y>this.minimumRebufferDuration&&(this.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+D-y}))}_?this._prepareRebufferTrackerState(L.viewer_time):this._clearRebufferTrackerState()},s.default=I},function(P,s,R){"use strict";Object.defineProperty(s,"__esModule",{value:!0});var p=R(2),x=function(T){return T&&T.__esModule?T:{default:T}}(p),I=function(){this.on("viewinit",function(){var T=this.data,L=T.view_id;if(!T.view_program_changed){var _=function(y,D){var A=D.viewer_time;y.type==="playing"&&this.data.view_time_to_first_frame===void 0?this.calculateTimeToFirstFrame(A||x.default.now(),L):y.type!=="adplaying"||this.data.view_time_to_first_frame!==void 0&&!this.inPrerollPosition()||this.calculateTimeToFirstFrame(A||x.default.now(),L)};this.one("playing",_),this.one("adplaying",_),this.one("viewend",function(){this.off("playing",_),this.off("adplaying",_)})}})};I.prototype.calculateTimeToFirstFrame=function(T,L){L===this.data.view_id&&(this._updateWatchTime(null,{viewer_time:T}),this.data.view_time_to_first_frame=this.data.view_watch_time,(this.data.player_autoplay_on||this.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.data.view_aggregate_startup_time=this.data.view_start+this.data.view_watch_time-this.NAVIGATION_START))},s.default=I},function(P,s,R){"use strict";function p(){var T=this;this.on("viewinit",function(){this._lastPlayheadPosition=-1});var L=["pause","rebufferstart","seeking","error","adbreakstart","hb"],_=["playing","hb"];L.forEach(function(y){T.on(y,function(){if(this._lastPlayheadPosition>=0&&this.data.player_playhead_time>=0&&this._lastPlayerWidth>=0&&this._lastSourceWidth>0&&this._lastPlayerHeight>=0&&this._lastSourceHeight>0){var D=this.data.player_playhead_time-this._lastPlayheadPosition;if(D<0)return void(this._lastPlayheadPosition=-1);var A=Math.min(this._lastPlayerWidth/this._lastSourceWidth,this._lastPlayerHeight/this._lastSourceHeight),S=Math.max(0,A-1),g=Math.max(0,1-A);this.data.view_max_upscale_percentage=Math.max(this.data.view_max_upscale_percentage||0,S),this.data.view_max_downscale_percentage=Math.max(this.data.view_max_downscale_percentage||0,g),(0,I.default)(this.data,"view_total_content_playback_time",D),(0,I.default)(this.data,"view_total_upscaling",S*D),(0,I.default)(this.data,"view_total_downscaling",g*D)}this._lastPlayheadPosition=-1})}),_.forEach(function(y){T.on(y,function(){this._lastPlayheadPosition=this.data.player_playhead_time,this._lastPlayerWidth=this.data.player_width,this._lastPlayerHeight=this.data.player_height,this._lastSourceWidth=this.data.video_source_width,this._lastSourceHeight=this.data.video_source_height})})}Object.defineProperty(s,"__esModule",{value:!0}),s.default=p;var x=R(3),I=function(T){return T&&T.__esModule?T:{default:T}}(x)},function(P,s,R){"use strict";function p(A){return A&&A.__esModule?A:{default:A}}function x(){this.isSeeking=!1,this.on("seeking",function(A,S){(0,D.default)(this.data,S),this._lastSeekingTime=T.default.now(),this.isSeeking===!1&&(this.isSeeking=!0,this.send("seeking"))}),this.on("seeked",function(){this.isSeeking=!1;var A=this._lastSeekingTime||T.default.now(),S=T.default.now()-A;(0,_.default)(this.data,"view_seek_count",1),(0,_.default)(this.data,"view_seek_duration",S);var g=this.data.view_max_seek_time||0;this.data.view_max_seek_time=Math.max(g,S)}),this.on("viewend",function(){this.isSeeking=!1})}Object.defineProperty(s,"__esModule",{value:!0}),s.default=x;var I=R(2),T=p(I),L=R(3),_=p(L),y=R(1),D=p(y)},function(P,s,R){"use strict";function p(g){return g&&g.__esModule?g:{default:g}}Object.defineProperty(s,"__esModule",{value:!0});var x=function(){function g(E,a){var e=[],o=!0,f=!1,n=void 0;try{for(var i,t=E[Symbol.iterator]();!(o=(i=t.next()).done)&&(e.push(i.value),!a||e.length!==a);o=!0);}catch(u){f=!0,n=u}finally{try{!o&&t.return&&t.return()}finally{if(f)throw n}}return e}return function(E,a){if(Array.isArray(E))return E;if(Symbol.iterator in Object(E))return g(E,a);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),I=R(3),T=p(I),L=R(5),_=R(1),y=p(_),D=function(g,E){g.push(E),g.sort(function(a,e){return a.viewer_time-e.viewer_time})},A=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],S=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}),A.forEach(function(a){return g.on(a,g._updateAdData)});var E=function(){g.isAdBreak=!1};this.on("adbreakstart",function(){this.isAdBreak=!0}),this.on("play",E),this.on("playing",E),this.on("viewend",E),this.on("adrequest",function(a,e){e=(0,y.default)({ad_request_id:"generatedAdRequestId"+this._currentAdRequestNumber++},e),D(this._adRequests,e),(0,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(a,e){e=(0,y.default)({ad_request_id:"generatedAdRequestId"+this._currentAdResponseNumber++},e),D(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(a,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(a,e){this.inPrerollPosition()&&this.data.view_preroll_load_time===void 0&&this._prerollPlayTime!==void 0&&(this.data.view_preroll_load_time=e.viewer_time-this._prerollPlayTime,this.data.view_startup_preroll_load_time=e.viewer_time-this._prerollPlayTime)}),this.on("adended",function(){this._wouldBeNewAdPlay=!0}),this.on("aderror",function(){this._wouldBeNewAdPlay=!0})};S.prototype.inPrerollPosition=function(){return this.data.view_content_playback_time===void 0||this.data.view_content_playback_time<=1e3},S.prototype.findAdRequest=function(g){for(var E=0;E<this._adRequests.length;E++)if(this._adRequests[E].ad_request_id===g)return this._adRequests[E]},S.prototype._updateAdData=function(g,E){if(this.inPrerollPosition()){if(!this.data.view_preroll_ad_tag_hostname&&E.ad_tag_url){var a=(0,L.extractHostnameAndDomain)(E.ad_tag_url),e=x(a,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&&E.ad_asset_url){var n=(0,L.extractHostnameAndDomain)(E.ad_asset_url),i=x(n,2),t=i[0],u=i[1];this.data.view_preroll_ad_asset_domain=u,this.data.view_preroll_ad_asset_hostname=t}}},s.default=S},function(P,s,R){"use strict";function p(y){return y&&y.__esModule?y:{default:y}}function x(){var y=this,D=void 0,A=void 0,S=function(){y.disableRebufferTracking||((0,_.default)(y.data,"view_waiting_rebuffer_count",1),D=T.default.now(),A=window.setInterval(function(){if(D){var o=T.default.now();(0,_.default)(y.data,"view_waiting_rebuffer_duration",o-D),D=o}},250))},g=function(){y.disableRebufferTracking||D&&((0,_.default)(y.data,"view_waiting_rebuffer_duration",T.default.now()-D),D=!1,window.clearInterval(A))},E=!1,a=function(){E=!0},e=function(){E=!1,g()};this.on("waiting",function(){E&&S()}),this.on("playing",function(){g(),a()}),this.on("pause",e),this.on("seeking",e)}Object.defineProperty(s,"__esModule",{value:!0}),s.default=x;var I=R(2),T=p(I),L=R(3),_=p(L)},function(P,s,R){"use strict";function p(A){return A&&A.__esModule?A:{default:A}}function x(){var A=this;this.one("playbackheartbeat",y),this.on("playbackheartbeatend",function(){A.off("before*",D),A.one("playbackheartbeat",y)})}Object.defineProperty(s,"__esModule",{value:!0}),s.default=x;var I=R(1),T=p(I),L=R(2),_=p(L),y=function(){this.lastWallClockTime=_.default.now(),this.on("before*",D)},D=function(A){var S=_.default.now(),g=this.lastWallClockTime;this.lastWallClockTime=S,S-g>3e4&&(this.emit("devicesleep",{viewer_time:g}),(0,T.default)(this.data,{viewer_time:g}),this.send("devicesleep"),this.emit("devicewake",{viewer_time:S}),(0,T.default)(this.data,{viewer_time:S}),this.send("devicewake"))}},function(P,s,R){"use strict";function p(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(s,"__esModule",{value:!0});var x=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=p(I),L=R(40),_=R(4),y=p(_),D=R(53),A=p(D),S=R(12),g=p(S),E=R(54),a=p(E),e=R(17),o=p(e),f=R(55),n=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 n.default((0,A.default)(v,m)),this.previousBeaconData=null,this.lastEventTime=null,this.sampleRate=m.sampleRate,this.disableCookies=m.disableCookies,this.respectDoNotTrack=m.respectDoNotTrack;var O=m.platform||{};this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:O.name,viewer_application_version:O.version,viewer_application_engine:O.layout,viewer_device_name:O.product,viewer_device_category:"",viewer_device_manufacturer:O.manufacturer,viewer_os_family:O.os&&O.os.family,viewer_os_architecture:O.os&&O.os.architecture,viewer_os_version:O.os&&O.os.version};var b=(0,a.default)();b&&(this.pageLevelData=(0,t.default)(this.pageLevelData,{viewer_connection_type:b})),T.default!==void 0&&T.default.location&&T.default.location.href&&(this.pageLevelData.page_url=T.default.location.href),this.viewerData=this.disableCookies?{}:(0,L.getAndUpdateViewerData)()};r.prototype.send=function(l,v){if(l){if(this.respectDoNotTrack&&(0,g.default)())return y.default.info("Not sending `"+l+"` because Do Not Track is enabled");if(!v||(v===void 0?"undefined":x(v))!=="object")return y.default.error("A data object was expected in send() but was not provided");var m=this.disableCookies?{}:(0,L.getAndUpdateSessionData)(),O={};(0,t.default)(O,this.pageLevelData),(0,t.default)(O,v),(0,t.default)(O,m),(0,t.default)(O,this.viewerData),O.event=l,O.env_key=this.envKey,O.user_id&&(O.viewer_user_id=O.user_id,delete O.user_id);var b=O.mux_sample_number>=this.sampleRate,M=this._deduplicateBeaconData(l,O),F=(0,o.default)(M);if(this.lastEventTime=this.mux.utils.now(),b)return y.default.info("Not sending event due to sample rate restriction",l,O,F);if(this.envKey||y.default.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",l,O,F),!this.rateLimited){if(y.default.info("Sending event",l,O,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 O.event="eventrateexceeded",F=(0,o.default)(O),this.eventQueue.queueEvent(O.event,F),y.default.error("Beaconing disabled due to rate limit.")}}},r.prototype.destroy=function(){this.eventQueue.destroy(!1)};var h=function(l,v,m,O){return!(!l||v.indexOf("request_")!==0)&&(v==="request_response_headers"||(m===void 0?"undefined":x(m))!=="object"||(O===void 0?"undefined":x(O))!=="object"||Object.keys(m||{}).length!==Object.keys(O||{}).length)},d=function(l,v){return l==="renditionchange"&&v.indexOf("video_source_")===0};r.prototype._deduplicateBeaconData=function(l,v){var m=this,O={},b=v.view_id;if(!b||l==="viewstart"||l==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)O=(0,t.default)({},v),b&&(this.previousBeaconData=O),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))&&(O[F]=w,m.previousBeaconData[F]=w)})}return O},s.default=r},function(P,s,R){"use strict";function p(a){return a&&a.__esModule?a:{default:a}}Object.defineProperty(s,"__esModule",{value:!0}),s.getAndUpdateSessionData=s.getAndUpdateViewerData=void 0;var x=R(15),I=p(x),T=R(52),L=p(T),_=R(6),y=R(2),D=p(y),A=function(){var a=void 0;try{a=I.default.parse(L.default.get("muxData")||"")}catch{a={}}return a},S=function(a){try{L.default.set("muxData",I.default.stringify(a),{expires:7300})}catch{}},g=function(){var a=A();return a.mux_viewer_id=a.mux_viewer_id||(0,_.generateUUID)(),a.msn=a.msn||Math.random(),S(a),{mux_viewer_id:a.mux_viewer_id,mux_sample_number:a.msn}},E=function(){var a=A(),e=D.default.now();return a.session_start&&(a.sst=a.session_start,delete a.session_start),a.session_id&&(a.sid=a.session_id,delete a.session_id),a.session_expires&&(a.sex=a.session_expires,delete a.session_expires),(!a.sex||a.sex<e)&&(a.sid=(0,_.generateUUID)(),a.sst=e),a.sex=e+15e5,S(a),{session_id:a.sid,session_start:a.sst,session_expires:a.sex}};s.getAndUpdateViewerData=g,s.getAndUpdateSessionData=E},function(P,s,R){"use strict";var p=R(42),x=R(16),I=R(10),T=Object.prototype.hasOwnProperty,L={brackets:function(n){return n+"[]"},comma:"comma",indices:function(n,i){return n+"["+i+"]"},repeat:function(n){return n}},_=Array.isArray,y=String.prototype.split,D=Array.prototype.push,A=function(n,i){D.apply(n,_(i)?i:[i])},S=Date.prototype.toISOString,g=I.default,E={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:x.encode,encodeValuesOnly:!1,format:g,formatter:I.formatters[g],indices:!1,serializeDate:function(n){return S.call(n)},skipNulls:!1,strictNullHandling:!1},a=function(n){return typeof n=="string"||typeof n=="number"||typeof n=="boolean"||typeof n=="symbol"||typeof n=="bigint"},e={},o=function n(i,t,u,c,r,h,d,l,v,m,O,b,M,F,w){for(var C=i,B=w,U=0,j=!1;(B=B.get(e))!==void 0&&!j;){var N=B.get(i);if(U+=1,N!==void 0){if(N===U)throw new RangeError("Cyclic object value");j=!0}B.get(e)===void 0&&(U=0)}if(typeof d=="function"?C=d(t,C):C instanceof Date?C=m(C):u==="comma"&&_(C)&&(C=x.maybeMap(C,function(te){return te instanceof Date?m(te):te})),C===null){if(c)return h&&!M?h(t,E.encoder,F,"key",O):t;C=""}if(a(C)||x.isBuffer(C)){if(h){var K=M?t:h(t,E.encoder,F,"key",O);if(u==="comma"&&M){for(var H=y.call(String(C),","),V="",Y=0;Y<H.length;++Y)V+=(Y===0?"":",")+b(h(H[Y],E.encoder,F,"value",O));return[b(K)+"="+V]}return[b(K)+"="+b(h(C,E.encoder,F,"value",O))]}return[b(t)+"="+b(String(C))]}var Q=[];if(C===void 0)return Q;var J;if(u==="comma"&&_(C))J=[{value:C.length>0?C.join(",")||null:void 0}];else if(_(d))J=d;else{var z=Object.keys(C);J=l?z.sort(l):z}for(var q=0;q<J.length;++q){var re=J[q],X=typeof re=="object"&&re.value!==void 0?re.value:C[re];if(!r||X!==null){var le=_(C)?typeof u=="function"?u(t,re):t:t+(v?"."+re:"["+re+"]");w.set(i,U);var ne=p();ne.set(e,w),A(Q,n(X,le,u,c,r,h,d,l,v,m,O,b,M,F,ne))}}return Q},f=function(n){if(!n)return E;if(n.encoder!==null&&n.encoder!==void 0&&typeof n.encoder!="function")throw new TypeError("Encoder has to be a function.");var i=n.charset||E.charset;if(n.charset!==void 0&&n.charset!=="utf-8"&&n.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=I.default;if(n.format!==void 0){if(!T.call(I.formatters,n.format))throw new TypeError("Unknown format option provided.");t=n.format}var u=I.formatters[t],c=E.filter;return(typeof n.filter=="function"||_(n.filter))&&(c=n.filter),{addQueryPrefix:typeof n.addQueryPrefix=="boolean"?n.addQueryPrefix:E.addQueryPrefix,allowDots:n.allowDots===void 0?E.allowDots:!!n.allowDots,charset:i,charsetSentinel:typeof n.charsetSentinel=="boolean"?n.charsetSentinel:E.charsetSentinel,delimiter:n.delimiter===void 0?E.delimiter:n.delimiter,encode:typeof n.encode=="boolean"?n.encode:E.encode,encoder:typeof n.encoder=="function"?n.encoder:E.encoder,encodeValuesOnly:typeof n.encodeValuesOnly=="boolean"?n.encodeValuesOnly:E.encodeValuesOnly,filter:c,format:t,formatter:u,serializeDate:typeof n.serializeDate=="function"?n.serializeDate:E.serializeDate,skipNulls:typeof n.skipNulls=="boolean"?n.skipNulls:E.skipNulls,sort:typeof n.sort=="function"?n.sort:null,strictNullHandling:typeof n.strictNullHandling=="boolean"?n.strictNullHandling:E.strictNullHandling}};P.exports=function(n,i){var t,u,c=n,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 L?i.arrayFormat:i&&"indices"in i?i.indices?"indices":"repeat":"indices";var l=L[d];t||(t=Object.keys(c)),r.sort&&t.sort(r.sort);for(var v=p(),m=0;m<t.length;++m){var O=t[m];r.skipNulls&&c[O]===null||A(h,o(c[O],O,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,s,R){"use strict";var p=R(8),x=R(47),I=R(49),T=p("%TypeError%"),L=p("%WeakMap%",!0),_=p("%Map%",!0),y=x("WeakMap.prototype.get",!0),D=x("WeakMap.prototype.set",!0),A=x("WeakMap.prototype.has",!0),S=x("Map.prototype.get",!0),g=x("Map.prototype.set",!0),E=x("Map.prototype.has",!0),a=function(n,i){for(var t,u=n;(t=u.next)!==null;u=t)if(t.key===i)return u.next=t.next,t.next=n.next,n.next=t,t},e=function(n,i){var t=a(n,i);return t&&t.value},o=function(n,i,t){var u=a(n,i);u?u.value=t:n.next={key:i,next:n.next,value:t}},f=function(n,i){return!!a(n,i)};P.exports=function(){var n,i,t,u={assert:function(c){if(!u.has(c))throw new T("Side channel does not contain "+I(c))},get:function(c){if(L&&c&&(typeof c=="object"||typeof c=="function")){if(n)return y(n,c)}else if(_){if(i)return S(i,c)}else if(t)return e(t,c)},has:function(c){if(L&&c&&(typeof c=="object"||typeof c=="function")){if(n)return A(n,c)}else if(_){if(i)return E(i,c)}else if(t)return f(t,c);return!1},set:function(c,r){L&&c&&(typeof c=="object"||typeof c=="function")?(n||(n=new L),D(n,c,r)):_?(i||(i=new _),g(i,c,r)):(t||(t={key:{},next:null}),o(t,c,r))}};return u}},function(P,s,R){"use strict";var p=typeof Symbol!="undefined"&&Symbol,x=R(44);P.exports=function(){return typeof p=="function"&&typeof Symbol=="function"&&typeof p("foo")=="symbol"&&typeof Symbol("bar")=="symbol"&&x()}},function(P,s,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={},x=Symbol("test"),I=Object(x);if(typeof x=="string"||Object.prototype.toString.call(x)!=="[object Symbol]"||Object.prototype.toString.call(I)!=="[object Symbol]")return!1;p[x]=42;for(x 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 T=Object.getOwnPropertySymbols(p);if(T.length!==1||T[0]!==x||!Object.prototype.propertyIsEnumerable.call(p,x))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var L=Object.getOwnPropertyDescriptor(p,x);if(L.value!==42||L.enumerable!==!0)return!1}return!0}},function(P,s,R){"use strict";var p=Array.prototype.slice,x=Object.prototype.toString;P.exports=function(I){var T=this;if(typeof T!="function"||x.call(T)!=="[object Function]")throw new TypeError("Function.prototype.bind called on incompatible "+T);for(var L,_=p.call(arguments,1),y=function(){if(this instanceof L){var E=T.apply(this,_.concat(p.call(arguments)));return Object(E)===E?E:this}return T.apply(I,_.concat(p.call(arguments)))},D=Math.max(0,T.length-_.length),A=[],S=0;S<D;S++)A.push("$"+S);if(L=Function("binder","return function ("+A.join(",")+"){ return binder.apply(this,arguments); }")(y),T.prototype){var g=function(){};g.prototype=T.prototype,L.prototype=new g,g.prototype=null}return L}},function(P,s,R){"use strict";var p=R(9);P.exports=p.call(Function.call,Object.prototype.hasOwnProperty)},function(P,s,R){"use strict";var p=R(8),x=R(48),I=x(p("String.prototype.indexOf"));P.exports=function(T,L){var _=p(T,!!L);return typeof _=="function"&&I(T,".prototype.")>-1?x(_):_}},function(P,s,R){"use strict";var p=R(9),x=R(8),I=x("%Function.prototype.apply%"),T=x("%Function.prototype.call%"),L=x("%Reflect.apply%",!0)||p.call(T,I),_=x("%Object.getOwnPropertyDescriptor%",!0),y=x("%Object.defineProperty%",!0),D=x("%Math.max%");if(y)try{y({},"a",{value:1})}catch{y=null}P.exports=function(S){var g=L(p,T,arguments);return _&&y&&_(g,"length").configurable&&y(g,"length",{value:1+D(0,S.length-(arguments.length-1))}),g};var A=function(){return L(p,I,arguments)};y?y(P.exports,"apply",{value:A}):P.exports.apply=A},function(P,s,R){function p(W,G){if(W===1/0||W===-1/0||W!==W||W&&W>-1e3&&W<1e3||ue.call(/e/,G))return G;var oe=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof W=="number"){var de=W<0?-ye(-W):ye(W);if(de!==W){var ce=String(de),De=te.call(G,ce.length+1);return ee.call(ce,oe,"$&_")+"."+ee.call(ee.call(De,/([0-9]{3})/g,"$&_"),/_$/,"")}}return ee.call(G,oe,"$&_")}function x(W,G,oe){var de=(oe.quoteStyle||G)==="double"?'"':"'";return de+W+de}function I(W){return ee.call(String(W),/"/g,""")}function T(W){return!(e(W)!=="[object Array]"||ve&&typeof W=="object"&&ve in W)}function L(W){return!(e(W)!=="[object Date]"||ve&&typeof W=="object"&&ve in W)}function _(W){return!(e(W)!=="[object RegExp]"||ve&&typeof W=="object"&&ve in W)}function y(W){return!(e(W)!=="[object Error]"||ve&&typeof W=="object"&&ve in W)}function D(W){return!(e(W)!=="[object String]"||ve&&typeof W=="object"&&ve in W)}function A(W){return!(e(W)!=="[object Number]"||ve&&typeof W=="object"&&ve in W)}function S(W){return!(e(W)!=="[object Boolean]"||ve&&typeof W=="object"&&ve in W)}function g(W){if(ge)return W&&typeof W=="object"&&W instanceof Symbol;if(typeof W=="symbol")return!0;if(!W||typeof W!="object"||!fe)return!1;try{return fe.call(W),!0}catch{}return!1}function E(W){if(!W||typeof W!="object"||!Te)return!1;try{return Te.call(W),!0}catch{}return!1}function a(W,G){return Ee.call(W,G)}function e(W){return X.call(W)}function o(W){if(W.name)return W.name;var G=ne.call(le.call(W),/^function\s*([\w$]+)/);return G?G[1]:null}function f(W,G){if(W.indexOf)return W.indexOf(G);for(var oe=0,de=W.length;oe<de;oe++)if(W[oe]===G)return oe;return-1}function n(W){if(!B||!W||typeof W!="object")return!1;try{B.call(W);try{K.call(W)}catch{return!0}return W instanceof Map}catch{}return!1}function i(W){if(!Y||!W||typeof W!="object")return!1;try{Y.call(W,Y);try{J.call(W,J)}catch{return!0}return W instanceof WeakMap}catch{}return!1}function t(W){if(!q||!W||typeof W!="object")return!1;try{return q.call(W),!0}catch{}return!1}function u(W){if(!K||!W||typeof W!="object")return!1;try{K.call(W);try{B.call(W)}catch{return!0}return W instanceof Set}catch{}return!1}function c(W){if(!J||!W||typeof W!="object")return!1;try{J.call(W,J);try{Y.call(W,Y)}catch{return!0}return W instanceof WeakSet}catch{}return!1}function r(W){return!(!W||typeof W!="object")&&(typeof HTMLElement!="undefined"&&W instanceof HTMLElement||typeof W.nodeName=="string"&&typeof W.getAttribute=="function")}function h(W,G){if(W.length>G.maxStringLength){var oe=W.length-G.maxStringLength,de="... "+oe+" more character"+(oe>1?"s":"");return h(te.call(W,0,G.maxStringLength),G)+de}return x(ee.call(ee.call(W,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,d),"single",G)}function d(W){var G=W.charCodeAt(0),oe={8:"b",9:"t",10:"n",12:"f",13:"r"}[G];return oe?"\\"+oe:"\\x"+(G<16?"0":"")+$.call(G.toString(16))}function l(W){return"Object("+W+")"}function v(W){return W+" { ? }"}function m(W,G,oe,de){return W+" ("+G+") {"+(de?M(oe,de):se.call(oe,", "))+"}"}function O(W){for(var G=0;G<W.length;G++)if(f(W[G],`
|
|
2
|
-
`)>=0)return!1;return!0}function b(W,G){var oe;if(W.indent===" ")oe=" ";else{if(!(typeof W.indent=="number"&&W.indent>0))return null;oe=se.call(Array(W.indent+1)," ")}return{base:oe,prev:se.call(Array(G+1),oe)}}function M(W,G){if(W.length===0)return"";var oe=`
|
|
3
|
-
`+G.prev+G.base;return oe+se.call(W,","+oe)+`
|
|
4
|
-
`+G.prev}function F(W,G){var oe=T(W),de=[];if(oe){de.length=W.length;for(var ce=0;ce<W.length;ce++)de[ce]=a(W,ce)?G(W[ce],W):""}var De,ie=typeof ae=="function"?ae(W):[];if(ge){De={};for(var Le=0;Le<ie.length;Le++)De["$"+ie[Le]]=ie[Le]}for(var Ae in W)a(W,Ae)&&(oe&&String(Number(Ae))===Ae&&Ae<W.length||ge&&De["$"+Ae]instanceof Symbol||(ue.call(/[^\w$]/,Ae)?de.push(G(Ae,W)+": "+G(W[Ae],W)):de.push(Ae+": "+G(W[Ae],W))));if(typeof ae=="function")for(var Oe=0;Oe<ie.length;Oe++)xe.call(W,ie[Oe])&&de.push("["+G(ie[Oe])+"]: "+G(W[ie[Oe]],W));return de}var w=typeof Map=="function"&&Map.prototype,C=Object.getOwnPropertyDescriptor&&w?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,B=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,K=j&&N&&typeof N.get=="function"?N.get:null,H=j&&Set.prototype.forEach,V=typeof WeakMap=="function"&&WeakMap.prototype,Y=V?WeakMap.prototype.has:null,Q=typeof WeakSet=="function"&&WeakSet.prototype,J=Q?WeakSet.prototype.has:null,z=typeof WeakRef=="function"&&WeakRef.prototype,q=z?WeakRef.prototype.deref:null,re=Boolean.prototype.valueOf,X=Object.prototype.toString,le=Function.prototype.toString,ne=String.prototype.match,te=String.prototype.slice,ee=String.prototype.replace,$=String.prototype.toUpperCase,Z=String.prototype.toLowerCase,ue=RegExp.prototype.test,he=Array.prototype.concat,se=Array.prototype.join,pe=Array.prototype.slice,ye=Math.floor,Te=typeof BigInt=="function"?BigInt.prototype.valueOf:null,ae=Object.getOwnPropertySymbols,fe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,ge=typeof Symbol=="function"&&typeof Symbol.iterator=="object",ve=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===ge?"object":"symbol")?Symbol.toStringTag:null,xe=Object.prototype.propertyIsEnumerable,_e=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(W){return W.__proto__}:null),be=R(50).custom,Se=be&&g(be)?be:null;P.exports=function W(G,oe,de,ce){function De(Ge,dt,lr){if(dt&&(ce=pe.call(ce),ce.push(dt)),lr){var wt={depth:ie.depth};return a(ie,"quoteStyle")&&(wt.quoteStyle=ie.quoteStyle),W(Ge,wt,de+1,ce)}return W(Ge,ie,de+1,ce)}var ie=oe||{};if(a(ie,"quoteStyle")&&ie.quoteStyle!=="single"&&ie.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(a(ie,"maxStringLength")&&(typeof ie.maxStringLength=="number"?ie.maxStringLength<0&&ie.maxStringLength!==1/0:ie.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var Le=!a(ie,"customInspect")||ie.customInspect;if(typeof Le!="boolean"&&Le!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(a(ie,"indent")&&ie.indent!==null&&ie.indent!==" "&&!(parseInt(ie.indent,10)===ie.indent&&ie.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(a(ie,"numericSeparator")&&typeof ie.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var Ae=ie.numericSeparator;if(G===void 0)return"undefined";if(G===null)return"null";if(typeof G=="boolean")return G?"true":"false";if(typeof G=="string")return h(G,ie);if(typeof G=="number"){if(G===0)return 1/0/G>0?"0":"-0";var Oe=String(G);return Ae?p(G,Oe):Oe}if(typeof G=="bigint"){var Fe=String(G)+"n";return Ae?p(G,Fe):Fe}var Me=ie.depth===void 0?5:ie.depth;if(de===void 0&&(de=0),de>=Me&&Me>0&&typeof G=="object")return T(G)?"[Array]":"[Object]";var Ce=b(ie,de);if(ce===void 0)ce=[];else if(f(ce,G)>=0)return"[Circular]";if(typeof G=="function"){var Xe=o(G),je=F(G,De);return"[Function"+(Xe?": "+Xe:" (anonymous)")+"]"+(je.length>0?" { "+se.call(je,", ")+" }":"")}if(g(G)){var Re=ge?ee.call(String(G),/^(Symbol\(.*\))_[^)]*$/,"$1"):fe.call(G);return typeof G!="object"||ge?Re:l(Re)}if(r(G)){for(var we="<"+Z.call(String(G.nodeName)),Ke=G.attributes||[],We=0;We<Ke.length;We++)we+=" "+Ke[We].name+"="+x(I(Ke[We].value),"double",ie);return we+=">",G.childNodes&&G.childNodes.length&&(we+="..."),we+="</"+Z.call(String(G.nodeName))+">"}if(T(G)){if(G.length===0)return"[]";var Qe=F(G,De);return Ce&&!O(Qe)?"["+M(Qe,Ce)+"]":"[ "+se.call(Qe,", ")+" ]"}if(y(G)){var Je=F(G,De);return"cause"in G&&!xe.call(G,"cause")?"{ ["+String(G)+"] "+se.call(he.call("[cause]: "+De(G.cause),Je),", ")+" }":Je.length===0?"["+String(G)+"]":"{ ["+String(G)+"] "+se.call(Je,", ")+" }"}if(typeof G=="object"&&Le){if(Se&&typeof G[Se]=="function")return G[Se]();if(Le!=="symbol"&&typeof G.inspect=="function")return G.inspect()}if(n(G)){var lt=[];return U.call(G,function(Ge,dt){lt.push(De(dt,G,!0)+" => "+De(Ge,G))}),m("Map",B.call(G),lt,Ce)}if(u(G)){var ut=[];return H.call(G,function(Ge){ut.push(De(Ge,G))}),m("Set",K.call(G),ut,Ce)}if(i(G))return v("WeakMap");if(c(G))return v("WeakSet");if(t(G))return v("WeakRef");if(A(G))return l(De(Number(G)));if(E(G))return l(De(Te.call(G)));if(S(G))return l(re.call(G));if(D(G))return l(De(String(G)));if(!L(G)&&!_(G)){var Be=F(G,De),$e=_e?_e(G)===Object.prototype:G instanceof Object||G.constructor===Object,Ze=G instanceof Object?"":"null prototype",ft=!$e&&ve&&Object(G)===G&&ve in G?te.call(e(G),8,-1):Ze?"Object":"",or=$e||typeof G.constructor!="function"?"":G.constructor.name?G.constructor.name+" ":"",Tt=or+(ft||Ze?"["+se.call(he.call([],ft||[],Ze||[]),": ")+"] ":"");return Be.length===0?Tt+"{}":Ce?Tt+"{"+M(Be,Ce)+"}":Tt+"{ "+se.call(Be,", ")+" }"}return String(G)};var Ee=Object.prototype.hasOwnProperty||function(W){return W in this}},function(P,s){},function(P,s,R){"use strict";var p=R(16),x=Object.prototype.hasOwnProperty,I=Array.isArray,T={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:p.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},L=function(g){return g.replace(/&#(\d+);/g,function(E,a){return String.fromCharCode(parseInt(a,10))})},_=function(g,E){return g&&typeof g=="string"&&E.comma&&g.indexOf(",")>-1?g.split(","):g},y=function(g,E){var a,e={},o=E.ignoreQueryPrefix?g.replace(/^\?/,""):g,f=E.parameterLimit===1/0?void 0:E.parameterLimit,n=o.split(E.delimiter,f),i=-1,t=E.charset;if(E.charsetSentinel)for(a=0;a<n.length;++a)n[a].indexOf("utf8=")===0&&(n[a]==="utf8=%E2%9C%93"?t="utf-8":n[a]==="utf8=%26%2310003%3B"&&(t="iso-8859-1"),i=a,a=n.length);for(a=0;a<n.length;++a)if(a!==i){var u,c,r=n[a],h=r.indexOf("]="),d=h===-1?r.indexOf("="):h+1;d===-1?(u=E.decoder(r,T.decoder,t,"key"),c=E.strictNullHandling?null:""):(u=E.decoder(r.slice(0,d),T.decoder,t,"key"),c=p.maybeMap(_(r.slice(d+1),E),function(l){return E.decoder(l,T.decoder,t,"value")})),c&&E.interpretNumericEntities&&t==="iso-8859-1"&&(c=L(c)),r.indexOf("[]=")>-1&&(c=I(c)?[c]:c),x.call(e,u)?e[u]=p.combine(e[u],c):e[u]=c}return e},D=function(g,E,a,e){for(var o=e?E:_(E,a),f=g.length-1;f>=0;--f){var n,i=g[f];if(i==="[]"&&a.parseArrays)n=[].concat(o);else{n=a.plainObjects?Object.create(null):{};var t=i.charAt(0)==="["&&i.charAt(i.length-1)==="]"?i.slice(1,-1):i,u=parseInt(t,10);a.parseArrays||t!==""?!isNaN(u)&&i!==t&&String(u)===t&&u>=0&&a.parseArrays&&u<=a.arrayLimit?(n=[],n[u]=o):t!=="__proto__"&&(n[t]=o):n={0:o}}o=n}return o},A=function(g,E,a,e){if(g){var o=a.allowDots?g.replace(/\.([^.[]+)/g,"[$1]"):g,f=/(\[[^[\]]*])/,n=/(\[[^[\]]*])/g,i=a.depth>0&&f.exec(o),t=i?o.slice(0,i.index):o,u=[];if(t){if(!a.plainObjects&&x.call(Object.prototype,t)&&!a.allowPrototypes)return;u.push(t)}for(var c=0;a.depth>0&&(i=n.exec(o))!==null&&c<a.depth;){if(c+=1,!a.plainObjects&&x.call(Object.prototype,i[1].slice(1,-1))&&!a.allowPrototypes)return;u.push(i[1])}return i&&u.push("["+o.slice(i.index)+"]"),D(u,E,a,e)}},S=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 E=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:E,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"||p.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,E){var a=S(E);if(g===""||g===null||g===void 0)return a.plainObjects?Object.create(null):{};for(var e=typeof g=="string"?y(g,a):g,o=a.plainObjects?Object.create(null):{},f=Object.keys(e),n=0;n<f.length;++n){var i=f[n],t=A(i,e[i],a,typeof g=="string");o=p.merge(o,t,a)}return a.allowSparse===!0?o:p.compact(o)}},function(P,s,R){"use strict";var p,x,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 L=!1;if(p=T,(x=typeof p=="function"?p.call(s,R,s,P):p)!==void 0&&(P.exports=x),L=!0,I(s)==="object"&&(P.exports=T(),L=!0),!L){var _=window.Cookies,y=window.Cookies=T();y.noConflict=function(){return window.Cookies=_,y}}})(function(){function T(_){function y(D,A,S){var g;if(typeof document!="undefined"){if(arguments.length>1){if(S=L({path:"/"},y.defaults,S),typeof S.expires=="number"){var E=new Date;E.setMilliseconds(E.getMilliseconds()+864e5*S.expires),S.expires=E}try{g=JSON.stringify(A),/^[\{\[]/.test(g)&&(A=g)}catch{}return A=_.write?_.write(A,D):encodeURIComponent(String(A)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),D=encodeURIComponent(String(D)),D=D.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),D=D.replace(/[\(\)]/g,escape),document.cookie=[D,"=",A,S.expires?"; expires="+S.expires.toUTCString():"",S.path?"; path="+S.path:"",S.domain?"; domain="+S.domain:"",S.secure?"; secure":""].join("")}D||(g={});for(var a=document.cookie?document.cookie.split("; "):[],e=/(%[0-9A-Z]{2})+/g,o=0;o<a.length;o++){var f=a[o].split("="),n=f.slice(1).join("=");n.charAt(0)==='"'&&(n=n.slice(1,-1));try{var i=f[0].replace(e,decodeURIComponent);if(n=_.read?_.read(n,i):_(n,i)||n.replace(e,decodeURIComponent),this.json)try{n=JSON.parse(n)}catch{}if(D===i){g=n;break}D||(g[i]=n)}catch{}}return g}}return y.set=y,y.get=function(D){return y.call(y,D)},y.getJSON=function(){return y.apply({json:!0},[].slice.call(arguments))},y.defaults={},y.remove=function(D,A){y(D,"",L(A,{expires:-1}))},y.withConverter=T,y}var L=function(){for(var _=0,y={};_<arguments.length;_++){var D=arguments[_];for(var A in D)y[A]=D[A]}return y};return T(function(){})})},function(P,s,R){"use strict";function p(x,I){var T=I.beaconCollectionDomain,L=I.beaconDomain;if(T)return"https://"+T;x=x||"inferred";var _=L||"litix.io";return x.match(/^[a-z0-9]+$/)?"https://"+x+"."+_:"https://img.litix.io/a.gif"}Object.defineProperty(s,"__esModule",{value:!0}),s.default=p},function(P,s,R){"use strict";Object.defineProperty(s,"__esModule",{value:!0});var p=R(0),x=function(L){return L&&L.__esModule?L:{default:L}}(p),I=function(){var L=void 0;switch(T()){case"cellular":L="cellular";break;case"ethernet":L="wired";break;case"wifi":L="wifi";break;case void 0:break;default:L="other"}return L},T=function(){var L=x.default.navigator,_=L&&(L.connection||L.mozConnection||L.webkitConnection);return _&&_.type};s.default=I},function(P,s,R){"use strict";function p(n){return n&&n.__esModule?n:{default:n}}Object.defineProperty(s,"__esModule",{value:!0});var x=R(0),I=p(x),T=R(4),L=p(T),_=R(56),y=p(_),D=R(1),A=p(D),S=R(17),g=p(S),E=R(2),a=p(E),e=!!I.default.XMLHttpRequest&&"withCredentials"in new I.default.XMLHttpRequest,o={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4},f=function(n,i){this._beaconUrl=n||"https://img.litix.io",this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=(0,A.default)({},o,i)};f.prototype.queueEvent=function(n,i){var t=(0,A.default)({},i);return e?(this._eventQueue.length<=this._options.maxQueueLength||n==="eventrateexceeded")&&(this._eventQueue.push(t),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength):(y.default.send(this._beaconUrl,t),!0)},f.prototype.flushEvents=function(){e&&(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},f.prototype.destroy=function(){var n=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,n?this._clearBeaconQueue():this.flushEvents(),I.default.clearTimeout(this._sendTimeout)},f.prototype._clearBeaconQueue=function(){var n=I.default.navigator,i=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,t=this._eventQueue.slice(i);i>0&&(0,A.default)(t[t.length-1],(0,g.default)({mux_view_message:"event queue truncated"}));var u=this._createPayload(t);if(n.sendBeacon)n.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 y.default.send(this._beaconUrl,t[t.length-1])},f.prototype._sendBeaconQueue=function(){var n=this;if(I.default.XMLHttpRequest&&!this._postInFlight){var i=new I.default.XMLHttpRequest,t=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0,i.onreadystatechange=function(){i.readyState===4&&(i.status!==200?(n._eventQueue=t.concat(n._eventQueue),n._failureCount+=1,L.default.info("Error sending beacon: "+i.status),L.default.info(i.responseText)):n._failureCount=0,n._roundTripTime=a.default.now()-c,n._postInFlight=!1)},i.open("POST",this._beaconUrl),i.setRequestHeader("Content-Type","application/json");var u=this._createPayload(t),c=a.default.now();i.send(u)}},f.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var n=Math.pow(2,this._failureCount-1);return(1+(n*=Math.random()))*this._options.baseTimeBetweenBeacons},f.prototype._startBeaconSending=function(){var n=this;I.default.clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=I.default.setTimeout(function(){n._eventQueue.length&&n._sendBeaconQueue(),n._startBeaconSending()},this._getNextBeaconTime()))},f.prototype._createPayload=function(n){var i={transmission_timestamp:Math.round(a.default.now())};return this._roundTripTime&&(i.rtt_ms=Math.round(this._roundTripTime)),JSON.stringify({metadata:i,events:n})},s.default=f},function(P,s,R){"use strict";function p(y){return y&&y.__esModule?y:{default:y}}Object.defineProperty(s,"__esModule",{value:!0});var x=R(15),I=p(x),T=R(0),L=p(T),_={};_.send=function(y,D){function A(){S.src=E+(g?"&rc="+g:"")}var S=new Image,g=0,E=y+"?"+I.default.stringify(D);return S.addEventListener("error",function(){g>3||L.default.setTimeout(function(){g++,A()},5e3*g)}),A(),S},s.default=_},function(P,s,R){"use strict";function p(){function x(E,a){var e=a.request_start,o=a.request_response_start,f=a.request_response_end,n=a.request_bytes_loaded;D++;var i=void 0,t=void 0;if(o?(i=o-e,t=f-o):t=f-e,t>0&&n>0){var u=n/t*8e3;A++,_+=n,y+=t,this.data.view_min_request_throughput=Math.min(this.data.view_min_request_throughput||1/0,u),this.data.view_average_request_throughput=_/y*8e3,this.data.view_request_count=D,i>0&&(L+=i,this.data.view_max_request_latency=Math.max(this.data.view_max_request_latency||0,i),this.data.view_average_request_latency=L/A)}}function I(E,a){D++,S++,this.data.view_request_count=D,this.data.view_request_failed_count=S}function T(E,a){D++,g++,this.data.view_request_count=D,this.data.view_request_canceled_count=g}var L=0,_=0,y=0,D=0,A=0,S=0,g=0;this.on("requestcompleted",x),this.on("requestfailed",I),this.on("requestcanceled",T)}Object.defineProperty(s,"__esModule",{value:!0}),s.default=p},function(P,s,R){"use strict";function p(A,S,g){var E=(0,_.findMediaElement)(S),a=I(E,3),e=a[0],o=a[1],f=a[2],n=A.log,i=A.utils.getComputedStyle,t=A.utils.secondsToMs,u={automaticErrorTracking:!0};if(!e)return n.error("No element was found with the `"+o+"` query selector.");if(f!=="video"&&f!=="audio")return n.error("The element of `"+o+"` was not a media element.");g=(0,L.default)(u,g),g.data=(0,L.default)({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:"4.8.0"},g.data),g.getPlayheadTime=function(){return t(e.currentTime)},g.getStateData=function(){var r=this.hlsjs&&this.hlsjs.url,h=this.dashjs&&x(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){A.emit(o,r,h)};var c=function(){n.error("The monitor for this video element has already been destroyed.")};e.mux.destroy=function(){Object.keys(e.mux.listeners).forEach(function(r){e.removeEventListener(r,e.mux.listeners[r],!1)}),delete e.mux.listeners,e.mux.destroy=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,A.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"?A.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,L.default)({},e.mux.listeners),delete e.mux.listeners,Object.keys(l.mux.listeners).forEach(function(O){e.removeEventListener(O,l.mux.listeners[O],!1),l.addEventListener(O,l.mux.listeners[O],!1)}),l.mux.swapElement=e.mux.swapElement,l.mux.destroy=e.mux.destroy,delete e.mux,void(e=l)):A.log.error("No element was found with the `"+v+"` query selector.")},e.mux.addHLSJS=function(r){A.addHLSJS(o,r)},e.mux.addDashJS=function(r){A.addDashJS(o,r)},e.mux.removeHLSJS=function(){A.removeHLSJS(o)},e.mux.removeDashJS=function(){A.removeDashJS(o)},A.init(o,g),A.emit(o,"playerready"),e.paused||(A.emit(o,"play"),e.readyState>2&&A.emit(o,"playing")),e.mux.listeners={},y.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=D[e.error.code]||e.error.message}A.emit(o,r,h)},e.addEventListener(r,e.mux.listeners[r],!1))})}Object.defineProperty(s,"__esModule",{value:!0});var x=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(A){return typeof A}:function(A){return A&&typeof Symbol=="function"&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A},I=function(){function A(S,g){var E=[],a=!0,e=!1,o=void 0;try{for(var f,n=S[Symbol.iterator]();!(a=(f=n.next()).done)&&(E.push(f.value),!g||E.length!==g);a=!0);}catch(i){e=!0,o=i}finally{try{!a&&n.return&&n.return()}finally{if(e)throw o}}return E}return function(S,g){if(Array.isArray(S))return S;if(Symbol.iterator in Object(S))return A(S,g);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();s.default=p;var T=R(1),L=function(A){return A&&A.__esModule?A:{default:A}}(T),_=R(11),y=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],D={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"}},function(P,s,R){"use strict";function p(u){return u&&u.__esModule?u:{default:u}}Object.defineProperty(s,"__esModule",{value:!0});var x=R(60),I=p(x),T=R(3),L=p(T),_=R(61),y=p(_),D=R(62),A=p(D),S=R(1),g=p(S),E=R(7),a=p(E),e=R(5),o=R(2),f=p(o),n=R(63),i=p(n),t={};t.safeCall=I.default,t.safeIncrement=L.default,t.getComputedStyle=y.default,t.secondsToMs=A.default,t.assign=g.default,t.headersStringToObject=a.default,t.extractHostnameAndDomain=e.extractHostnameAndDomain,t.extractHostname=e.extractHostname,t.now=f.default.now,t.manifestParser=i.default,s.default=t},function(P,s,R){"use strict";function p(T,L,_,y){var D=y;if(T&&typeof T[L]=="function")try{D=T[L].apply(T,_)}catch(A){I.default.info("safeCall error",A)}return D}Object.defineProperty(s,"__esModule",{value:!0}),s.default=p;var x=R(4),I=function(T){return T&&T.__esModule?T:{default:T}}(x)},function(P,s,R){"use strict";function p(L,_){if(L&&_&&I.default&&typeof I.default.getComputedStyle=="function"){var y=void 0;return T&&T.has(L)&&(y=T.get(L)),y||(y=I.default.getComputedStyle(L,null),T&&T.set(L,y)),y.getPropertyValue(_)}}Object.defineProperty(s,"__esModule",{value:!0}),s.default=p;var x=R(0),I=function(L){return L&&L.__esModule?L:{default:L}}(x),T=void 0;I.default&&I.default.WeakMap&&(T=new WeakMap)},function(P,s,R){"use strict";function p(x){return Math.floor(1e3*x)}Object.defineProperty(s,"__esModule",{value:!0}),s.default=p},function(P,s,R){"use strict";function p(f){return f&&f.__esModule?f:{default:f}}Object.defineProperty(s,"__esModule",{value:!0});var x=R(1),I=p(x),T=R(14),L=p(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"},y=function(f){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(f),this.manifest};y.prototype.process=function(f){var n=void 0;for(this.buffer+=f,n=this.buffer.indexOf(`
|
|
5
|
-
`);
|
|
6
|
-
`))this.processLine(this.buffer.substring(0,n)),this.buffer=this.buffer.substring(n+1)},y.prototype.processLine=function(f){var n=f.indexOf(":"),i=e(f,n),t=i[0],u=i.length===2?S(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:D(this.manifest,i),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case _.SERVER_CONTROL:D(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:D(this.manifest,i);break;case _.SESSION_DATA:var h=o(i[1]),d=(0,L.default)(h);(0,I.default)(this.manifest.sessionData,d)}},y.prototype.setHoldBack=function(){var f=this.manifest,n=f.serverControl,i=f.targetDuration,t=f.partTargetDuration;if(n){var u="holdBack",c="partHoldBack",r=i&&3*i,h=t&&2*t;i&&!n.hasOwnProperty(u)&&(n[u]=r),r&&n[u]<r&&(n[u]=r),t&&!n.hasOwnProperty(c)&&(n[c]=3*t),t&&n[c]<h&&(n[c]=h)}};var D=function(f,n){var i=A(n[0].replace("#EXT-X-","")),t=void 0;a(n[1])?(t={},t=(0,I.default)(E(n[1]),t)):t=S(n[1]),f[i]=t},A=function(f){return f.toLowerCase().replace(/-(\w)/g,function(n){return n[1].toUpperCase()})},S=function(f){if(f.toLowerCase()==="yes"||f.toLowerCase()==="no")return f.toLowerCase()==="yes";var n=f.indexOf(":")!==-1?f:parseFloat(f);return isNaN(n)?f:n},g=function(f){var n={},i=f.split("=");return i.length>1&&(n[A(i[0])]=S(i[1])),n},E=function(f){for(var n=f.split(","),i={},t=0;n.length>t;t++){var u=n[t],c=g(u);i=(0,I.default)(c,i)}return i},a=function(f){return f.indexOf("=")>-1},e=function(f,n){return n===-1?[f]:[f.substring(0,n),f.substring(n+1)]},o=function(f){var n={};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"&&(n["DATA-ID"]=c[1-r]),c[r]==="VALUE"&&(n.VALUE=c[1-r])}),{data:n}}};s.default=y},function(P,s,R){"use strict";Object.defineProperty(s,"__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"};s.default=p}])})})()});var pt=Ut((rt,Lt)=>{typeof window!="undefined"&&function(P,s){typeof rt=="object"&&typeof Lt=="object"?Lt.exports=s():typeof define=="function"&&define.amd?define([],s):typeof rt=="object"?rt.Hls=s():P.Hls=s()}(rt,function(){return function(k){var P={};function s(R){if(P[R])return P[R].exports;var p=P[R]={i:R,l:!1,exports:{}};return k[R].call(p.exports,p,p.exports,s),p.l=!0,p.exports}return s.m=k,s.c=P,s.d=function(R,p,x){s.o(R,p)||Object.defineProperty(R,p,{enumerable:!0,get:x})},s.r=function(R){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(R,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(R,"__esModule",{value:!0})},s.t=function(R,p){if(p&1&&(R=s(R)),p&8||p&4&&typeof R=="object"&&R&&R.__esModule)return R;var x=Object.create(null);if(s.r(x),Object.defineProperty(x,"default",{enumerable:!0,value:R}),p&2&&typeof R!="string")for(var I in R)s.d(x,I,function(T){return R[T]}.bind(null,I));return x},s.n=function(R){var p=R&&R.__esModule?function(){return R.default}:function(){return R};return s.d(p,"a",p),p},s.o=function(R,p){return Object.prototype.hasOwnProperty.call(R,p)},s.p="/dist/",s(s.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(k,P,s){"use strict";var R=Object.prototype.hasOwnProperty,p="~";function x(){}Object.create&&(x.prototype=Object.create(null),new x().__proto__||(p=!1));function I(y,D,A){this.fn=y,this.context=D,this.once=A||!1}function T(y,D,A,S,g){if(typeof A!="function")throw new TypeError("The listener must be a function");var E=new I(A,S||y,g),a=p?p+D:D;return y._events[a]?y._events[a].fn?y._events[a]=[y._events[a],E]:y._events[a].push(E):(y._events[a]=E,y._eventsCount++),y}function L(y,D){--y._eventsCount===0?y._events=new x:delete y._events[D]}function _(){this._events=new x,this._eventsCount=0}_.prototype.eventNames=function(){var D=[],A,S;if(this._eventsCount===0)return D;for(S in A=this._events)R.call(A,S)&&D.push(p?S.slice(1):S);return Object.getOwnPropertySymbols?D.concat(Object.getOwnPropertySymbols(A)):D},_.prototype.listeners=function(D){var A=p?p+D:D,S=this._events[A];if(!S)return[];if(S.fn)return[S.fn];for(var g=0,E=S.length,a=new Array(E);g<E;g++)a[g]=S[g].fn;return a},_.prototype.listenerCount=function(D){var A=p?p+D:D,S=this._events[A];return S?S.fn?1:S.length:0},_.prototype.emit=function(D,A,S,g,E,a){var e=p?p+D:D;if(!this._events[e])return!1;var o=this._events[e],f=arguments.length,n,i;if(o.fn){switch(o.once&&this.removeListener(D,o.fn,void 0,!0),f){case 1:return o.fn.call(o.context),!0;case 2:return o.fn.call(o.context,A),!0;case 3:return o.fn.call(o.context,A,S),!0;case 4:return o.fn.call(o.context,A,S,g),!0;case 5:return o.fn.call(o.context,A,S,g,E),!0;case 6:return o.fn.call(o.context,A,S,g,E,a),!0}for(i=1,n=new Array(f-1);i<f;i++)n[i-1]=arguments[i];o.fn.apply(o.context,n)}else{var t=o.length,u;for(i=0;i<t;i++)switch(o[i].once&&this.removeListener(D,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,A);break;case 3:o[i].fn.call(o[i].context,A,S);break;case 4:o[i].fn.call(o[i].context,A,S,g);break;default:if(!n)for(u=1,n=new Array(f-1);u<f;u++)n[u-1]=arguments[u];o[i].fn.apply(o[i].context,n)}}return!0},_.prototype.on=function(D,A,S){return T(this,D,A,S,!1)},_.prototype.once=function(D,A,S){return T(this,D,A,S,!0)},_.prototype.removeListener=function(D,A,S,g){var E=p?p+D:D;if(!this._events[E])return this;if(!A)return L(this,E),this;var a=this._events[E];if(a.fn)a.fn===A&&(!g||a.once)&&(!S||a.context===S)&&L(this,E);else{for(var e=0,o=[],f=a.length;e<f;e++)(a[e].fn!==A||g&&!a[e].once||S&&a[e].context!==S)&&o.push(a[e]);o.length?this._events[E]=o.length===1?o[0]:o:L(this,E)}return this},_.prototype.removeAllListeners=function(D){var A;return D?(A=p?p+D:D,this._events[A]&&L(this,A)):(this._events=new x,this._eventsCount=0),this},_.prototype.off=_.prototype.removeListener,_.prototype.addListener=_.prototype.on,_.prefixed=p,_.EventEmitter=_,k.exports=_},"./node_modules/url-toolkit/src/url-toolkit.js":function(k,P,s){(function(R){var p=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,x=/^(?=([^\/?#]*))\1([^]*)$/,I=/(?:\/|^)\.(?=\/)/g,T=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,L={buildAbsoluteURL:function(_,y,D){if(D=D||{},_=_.trim(),y=y.trim(),!y){if(!D.alwaysNormalize)return _;var A=L.parseURL(_);if(!A)throw new Error("Error trying to parse base URL.");return A.path=L.normalizePath(A.path),L.buildURLFromParts(A)}var S=L.parseURL(y);if(!S)throw new Error("Error trying to parse relative URL.");if(S.scheme)return D.alwaysNormalize?(S.path=L.normalizePath(S.path),L.buildURLFromParts(S)):y;var g=L.parseURL(_);if(!g)throw new Error("Error trying to parse base URL.");if(!g.netLoc&&g.path&&g.path[0]!=="/"){var E=x.exec(g.path);g.netLoc=E[1],g.path=E[2]}g.netLoc&&!g.path&&(g.path="/");var a={scheme:g.scheme,netLoc:S.netLoc,path:null,params:S.params,query:S.query,fragment:S.fragment};if(!S.netLoc&&(a.netLoc=g.netLoc,S.path[0]!=="/"))if(!S.path)a.path=g.path,S.params||(a.params=g.params,S.query||(a.query=g.query));else{var e=g.path,o=e.substring(0,e.lastIndexOf("/")+1)+S.path;a.path=L.normalizePath(o)}return a.path===null&&(a.path=D.alwaysNormalize?L.normalizePath(S.path):S.path),L.buildURLFromParts(a)},parseURL:function(_){var y=p.exec(_);return y?{scheme:y[1]||"",netLoc:y[2]||"",path:y[3]||"",params:y[4]||"",query:y[5]||"",fragment:y[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}};k.exports=L})(this)},"./node_modules/webworkify-webpack/index.js":function(k,P,s){function R(D){var A={};function S(E){if(A[E])return A[E].exports;var a=A[E]={i:E,l:!1,exports:{}};return D[E].call(a.exports,a,a.exports,S),a.l=!0,a.exports}S.m=D,S.c=A,S.i=function(E){return E},S.d=function(E,a,e){S.o(E,a)||Object.defineProperty(E,a,{configurable:!1,enumerable:!0,get:e})},S.r=function(E){Object.defineProperty(E,"__esModule",{value:!0})},S.n=function(E){var a=E&&E.__esModule?function(){return E.default}:function(){return E};return S.d(a,"a",a),a},S.o=function(E,a){return Object.prototype.hasOwnProperty.call(E,a)},S.p="/",S.oe=function(E){throw console.error(E),E};var g=S(S.s=ENTRY_MODULE);return g.default||g}var p="[\\.|\\-|\\+|\\w|/|@]+",x="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+p+").*?\\)";function I(D){return(D+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function T(D){return!isNaN(1*D)}function L(D,A,S){var g={};g[S]=[];var E=A.toString(),a=E.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!a)return g;for(var e=a[1],o=new RegExp("(\\\\n|\\W)"+I(e)+x,"g"),f;f=o.exec(E);)f[3]!=="dll-reference"&&g[S].push(f[3]);for(o=new RegExp("\\("+I(e)+'\\("(dll-reference\\s('+p+'))"\\)\\)'+x,"g");f=o.exec(E);)D[f[2]]||(g[S].push(f[1]),D[f[2]]=s(f[1]).m),g[f[2]]=g[f[2]]||[],g[f[2]].push(f[4]);for(var n=Object.keys(g),i=0;i<n.length;i++)for(var t=0;t<g[n[i]].length;t++)T(g[n[i]][t])&&(g[n[i]][t]=1*g[n[i]][t]);return g}function _(D){var A=Object.keys(D);return A.reduce(function(S,g){return S||D[g].length>0},!1)}function y(D,A){for(var S={main:[A]},g={main:[]},E={main:{}};_(S);)for(var a=Object.keys(S),e=0;e<a.length;e++){var o=a[e],f=S[o],n=f.pop();if(E[o]=E[o]||{},!(E[o][n]||!D[o][n])){E[o][n]=!0,g[o]=g[o]||[],g[o].push(n);for(var i=L(D,D[o][n],o),t=Object.keys(i),u=0;u<t.length;u++)S[t[u]]=S[t[u]]||[],S[t[u]]=S[t[u]].concat(i[t[u]])}}return g}k.exports=function(D,A){A=A||{};var S={main:s.m},g=A.all?{main:Object.keys(S.main)}:y(S,D),E="";Object.keys(g).filter(function(n){return n!=="main"}).forEach(function(n){for(var i=0;g[n][i];)i++;g[n].push(i),S[n][i]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",E=E+"var "+n+" = ("+R.toString().replace("ENTRY_MODULE",JSON.stringify(i))+")({"+g[n].map(function(t){return""+JSON.stringify(t)+": "+S[n][t].toString()}).join(",")+`});
|
|
7
|
-
`}),E=E+"new (("+R.toString().replace("ENTRY_MODULE",JSON.stringify(D))+")({"+g.main.map(function(n){return""+JSON.stringify(n)+": "+S.main[n].toString()}).join(",")+"}))(self);";var a=new window.Blob([E],{type:"text/javascript"});if(A.bare)return a;var e=window.URL||window.webkitURL||window.mozURL||window.msURL,o=e.createObjectURL(a),f=new window.Worker(o);return f.objectURL=o,f}},"./src/config.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"hlsDefaultConfig",function(){return u}),s.d(P,"mergeConfig",function(){return r}),s.d(P,"enableStreamingMode",function(){return h});var R=s("./src/controller/abr-controller.ts"),p=s("./src/controller/audio-stream-controller.ts"),x=s("./src/controller/audio-track-controller.ts"),I=s("./src/controller/subtitle-stream-controller.ts"),T=s("./src/controller/subtitle-track-controller.ts"),L=s("./src/controller/buffer-controller.ts"),_=s("./src/controller/timeline-controller.ts"),y=s("./src/controller/cap-level-controller.ts"),D=s("./src/controller/fps-controller.ts"),A=s("./src/controller/eme-controller.ts"),S=s("./src/controller/cmcd-controller.ts"),g=s("./src/utils/xhr-loader.ts"),E=s("./src/utils/fetch-loader.ts"),a=s("./src/utils/cues.ts"),e=s("./src/utils/mediakeys-helper.ts"),o=s("./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 m in v)Object.prototype.hasOwnProperty.call(v,m)&&(d[m]=v[m])}return d},f.apply(this,arguments)}function n(d,l){var v=Object.keys(d);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(d);l&&(m=m.filter(function(O){return Object.getOwnPropertyDescriptor(d,O).enumerable})),v.push.apply(v,m)}return v}function i(d){for(var l=1;l<arguments.length;l++){var v=arguments[l]!=null?arguments[l]:{};l%2?n(Object(v),!0).forEach(function(m){t(d,m,v[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(v)):n(Object(v)).forEach(function(m){Object.defineProperty(d,m,Object.getOwnPropertyDescriptor(v,m))})}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:L.default,capLevelController:y.default,fpsController:D.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:e.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},c()),{},{subtitleStreamController:I.SubtitleStreamController,subtitleTrackController:T.default,timelineController:_.TimelineController,audioStreamController:p.default,audioTrackController:x.default,emeController:A.default,cmcdController:S.default});function c(){return{cueHandler:a.default,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function r(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!==E.default&&l!==g.default)o.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),d.progressive=!1;else{var v=Object(E.fetchSupported)();v&&(d.loader=E.default,d.progressive=!0,d.enableSoftwareAES=!0,o.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(k,P,s){"use strict";s.r(P);var R=s("./src/polyfills/number.ts"),p=s("./src/utils/ewma-bandwidth-estimator.ts"),x=s("./src/events.ts"),I=s("./src/utils/buffer-helper.ts"),T=s("./src/errors.ts"),L=s("./src/types/loader.ts"),_=s("./src/utils/logger.ts");function y(S,g){for(var E=0;E<g.length;E++){var a=g[E];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(S,a.key,a)}}function D(S,g,E){return g&&y(S.prototype,g),E&&y(S,E),Object.defineProperty(S,"prototype",{writable:!1}),S}var A=function(){function S(E){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=E;var a=E.config;this.bwEstimator=new p.default(a.abrEwmaSlowVoD,a.abrEwmaFastVoD,a.abrEwmaDefaultEstimate),this.registerListeners()}var g=S.prototype;return g.registerListeners=function(){var a=this.hls;a.on(x.Events.FRAG_LOADING,this.onFragLoading,this),a.on(x.Events.FRAG_LOADED,this.onFragLoaded,this),a.on(x.Events.FRAG_BUFFERED,this.onFragBuffered,this),a.on(x.Events.LEVEL_LOADED,this.onLevelLoaded,this),a.on(x.Events.ERROR,this.onError,this)},g.unregisterListeners=function(){var a=this.hls;a.off(x.Events.FRAG_LOADING,this.onFragLoading,this),a.off(x.Events.FRAG_LOADED,this.onFragLoaded,this),a.off(x.Events.FRAG_BUFFERED,this.onFragBuffered,this),a.off(x.Events.LEVEL_LOADED,this.onLevelLoaded,this),a.off(x.Events.ERROR,this.onError,this)},g.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},g.onFragLoading=function(a,e){var o=e.frag;if(o.type===L.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(a,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 a=this.fragCurrent,e=this.partCurrent,o=this.hls,f=o.autoLevelEnabled,n=o.config,i=o.media;if(!(!a||!i)){var t=e?e.stats:a.stats,u=e?e.duration:a.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[a.level],v=t.total||Math.max(t.loaded,Math.round(u*l.maxBitrate/8)),m=Math.max(1,t.bwEstimate?t.bwEstimate/8:t.loaded*1e3/c),O=(v-t.loaded)/m,b=i.currentTime,M=(I.BufferHelper.bufferInfo(i,b,n.maxBufferHole).end-b)/r;if(!(M>=2*u/r||O<=M)){var F=Number.POSITIVE_INFINITY,w;for(w=a.level-1;w>d;w--){var C=h[w].maxBitrate;if(F=u*C/(8*.8*m),F<M)break}if(!(F>=O)){var B=this.bwEstimator.getEstimate();_.logger.warn("Fragment "+a.sn+(e?" part "+e.index:"")+" of level "+a.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+w+`
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Estimated load time for
|
|
11
|
-
Time to underbuffer: `+M.toFixed(3)+" s"),o.nextLoadLevel=w,this.bwEstimator.sample(c,t.loaded),this.clearTimer(),a.loader&&(this.fragCurrent=this.partCurrent=null,a.loader.abort()),o.trigger(x.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:a,part:e,stats:t})}}}}}},g.onFragLoaded=function(a,e){var o=e.frag,f=e.part;if(o.type===L.PlaylistLevelType.MAIN&&Object(R.isFiniteNumber)(o.sn)){var n=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)+n.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:n,frag:o,part:f,id:o.type};this.onFragBuffered(x.Events.FRAG_BUFFERED,r)}}},g.onFragBuffered=function(a,e){var o=e.frag,f=e.part,n=f?f.stats:o.stats;if(!n.aborted&&!(o.type!==L.PlaylistLevelType.MAIN||o.sn==="initSegment")){var i=n.parsing.end-n.loading.start;this.bwEstimator.sample(i,n.loaded),n.bwEstimate=this.bwEstimator.getEstimate(),o.bitrateTest?this.bitrateTestDelay=i/1e3:this.bitrateTestDelay=0}},g.onError=function(a,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 a=this.fragCurrent,e=this.partCurrent,o=this.hls,f=o.maxAutoLevel,n=o.config,i=o.minAutoLevel,t=o.media,u=e?e.duration:a?a.duration:0,c=t?t.currentTime:0,r=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,h=this.bwEstimator?this.bwEstimator.getEstimate():n.abrEwmaDefaultEstimate,d=(I.BufferHelper.bufferInfo(t,c,n.maxBufferHole).end-c)/r,l=this.findBestLevel(h,i,f,d,n.abrBandWidthFactor,n.abrBandWidthUpFactor);if(l>=0)return l;_.logger.trace((d?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var v=u?Math.min(u,n.maxStarvationDelay):n.maxStarvationDelay,m=n.abrBandWidthFactor,O=n.abrBandWidthUpFactor;if(!d){var b=this.bitrateTestDelay;if(b){var M=u?Math.min(u,n.maxLoadingDelay):n.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=O=1}}return l=this.findBestLevel(h,i,f,d+v,m,O),Math.max(l,0)},g.findBestLevel=function(a,e,o,f,n,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,O=o;O>=e;O--){var b=h[O];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;O<=r?w=n*a:w=i*a;var C=h[O].maxBitrate,B=C*F/w;if(_.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+O+"/"+Math.round(w)+"/"+C+"/"+F+"/"+f+"/"+B),w>C&&(!B||l&&!this.bitrateTestDelay||B<f))return O}}return-1},D(S,[{key:"nextAutoLevel",get:function(){var a=this._nextAutoLevel,e=this.bwEstimator;if(a!==-1&&!e.canEstimate())return a;var o=this.getNextABRAutoLevel();return a!==-1&&this.hls.levels[o].loadError?a:(a!==-1&&(o=Math.min(a,o)),o)},set:function(a){this._nextAutoLevel=a}}]),S}();P.default=A},"./src/controller/audio-stream-controller.ts":function(k,P,s){"use strict";s.r(P);var R=s("./src/polyfills/number.ts"),p=s("./src/controller/base-stream-controller.ts"),x=s("./src/events.ts"),I=s("./src/utils/buffer-helper.ts"),T=s("./src/controller/fragment-tracker.ts"),L=s("./src/types/level.ts"),_=s("./src/types/loader.ts"),y=s("./src/loader/fragment.ts"),D=s("./src/demux/chunk-cache.ts"),A=s("./src/demux/transmuxer-interface.ts"),S=s("./src/types/transmuxer.ts"),g=s("./src/controller/fragment-finders.ts"),E=s("./src/utils/discontinuities.ts"),a=s("./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 n=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(x.Events.MEDIA_ATTACHED,this.onMediaAttached,this),h.on(x.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.on(x.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.on(x.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.on(x.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),h.on(x.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),h.on(x.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),h.on(x.Events.ERROR,this.onError,this),h.on(x.Events.BUFFER_RESET,this.onBufferReset,this),h.on(x.Events.BUFFER_CREATED,this.onBufferCreated,this),h.on(x.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),h.on(x.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.on(x.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c._unregisterListeners=function(){var h=this.hls;h.off(x.Events.MEDIA_ATTACHED,this.onMediaAttached,this),h.off(x.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.off(x.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.off(x.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.off(x.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),h.off(x.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),h.off(x.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),h.off(x.Events.ERROR,this.onError,this),h.off(x.Events.BUFFER_RESET,this.onBufferReset,this),h.off(x.Events.BUFFER_CREATED,this.onBufferCreated,this),h.off(x.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),h.off(x.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.off(x.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 O=l.cc;this.initPTS[l.cc]=m,this.log("InitPTS for cc: "+O+" found from main: "+m),this.videoTrackCC=O,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(n),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,O=performance.now(),b=this.retryDate;(!b||O>=b||(m=this.media)!==null&&m!==void 0&&m.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=p.State.IDLE);break}case p.State.WAITING_INIT_PTS:{var M=this.waitingData;if(M){var F=M.frag,w=M.part,C=M.cache,B=M.complete;if(this.initPTS[F.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=p.State.FRAG_LOADING;var U=C.flush(),j={frag:F,part:w,payload:U,networkDetails:null};this._handleFragmentLoadProgress(j),B&&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(),K=I.BufferHelper.bufferInfo(this.mediaBuffer,N,this.config.maxBufferHole),H=Object(g.fragmentWithinToleranceTest)(K.end,this.config.maxFragLookUpTolerance,F);H<0&&(this.log("Waiting fragment cc ("+F.cc+") @ "+F.start+" cancelled because another fragment at "+K.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,O=this.trackId,b=l.config;if(!(!v||!v[O])&&!(!m&&(this.startFragRequested||!b.startFragPrefetch))){var M=v[O],F=M.details;if(!F||F.live&&this.levelLastLoaded!==O||this.waitForCdnTuneIn(F)){this.state=p.State.WAITING_TRACK;return}var w=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&w&&(this.bufferFlushed=!1,this.afterBufferFlushed(w,y.ElementaryStreamTypes.AUDIO,_.PlaylistLevelType.AUDIO));var C=this.getFwdBufferInfo(w,_.PlaylistLevelType.AUDIO);if(C!==null){var B=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,_.PlaylistLevelType.MAIN),U=C.len,j=this.getMaxBufferLength(B==null?void 0:B.len),N=this.audioSwitch;if(!(U>=j&&!N)){if(!N&&this._streamEnded(C,F)){l.trigger(x.Events.BUFFER_EOS,{type:"audio"}),this.state=p.State.ENDED;return}var K=F.fragments,H=K[0].start,V=C.end;if(N&&m){var Y=this.getLoadPosition();V=Y,F.PTSKnown&&Y<H&&(C.end>H||C.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),m.currentTime=H+.05)}if(!(B&&V>B.end+F.targetduration)&&!((!B||!B.len)&&C.len)){var Q=this.getNextFragment(V,F);if(!Q){this.bufferFlushed=!0;return}((h=Q.decryptdata)===null||h===void 0?void 0:h.keyFormat)==="identity"&&!((d=Q.decryptdata)!==null&&d!==void 0&&d.key)?this.loadKey(Q,F):this.loadFragment(Q,F,V)}}}}},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 L.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(n):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(x.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,O=d.id;if(!v){this.warn("Audio tracks were reset while loading level "+O);return}this.log("Track "+O+" loaded ["+m.startSN+","+m.endSN+"],duration:"+m.totalduration);var b=v[O],M=0;if(m.live||(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(E.alignMediaPlaylistByPDT)(m,F),M=m.fragments[0].start):M=this.alignPlaylists(m,b.details)}b.details=m,this.levelLastLoaded=O,!this.startFragRequested&&(this.mainDetails||!m.live)&&this.setStartPosition(b.details,M),this.state===p.State.WAITING_TRACK&&!this.waitForCdnTuneIn(m)&&(this.state=p.State.IDLE),this.tick()},c._handleFragmentLoadProgress=function(h){var d,l=h.frag,v=h.part,m=h.payload,O=this.config,b=this.trackId,M=this.levels;if(!M){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+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=O.defaultAudioCodec||F.audioCodec||"mp4a.40.2",B=this.transmuxer;B||(B=this.transmuxer=new A.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,K=v?v.index:-1,H=K!==-1,V=new S.ChunkMetadata(l.level,l.sn,l.stats.chunkCount,m.byteLength,K,H);B.push(m,j,C,"",l,v,w.totalduration,N,V,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 "+b);var Y=this.waitingData=this.waitingData||{frag:l,part:v,cache:new D.default,complete:!1},Q=Y.cache;Q.push(new Uint8Array(m)),this.waitingVideoCC=this.videoTrackCC,this.state=p.State.WAITING_INIT_PTS}},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(x.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(l,v)}},c.onError=function(h,d){switch(d.details){case a.ErrorDetails.FRAG_LOAD_ERROR:case a.ErrorDetails.FRAG_LOAD_TIMEOUT:case a.ErrorDetails.KEY_LOAD_ERROR:case a.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_.PlaylistLevelType.AUDIO,d);break;case a.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case a.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==p.State.ERROR&&this.state!==p.State.STOPPED&&(this.state=d.fatal?p.State.ERROR:p.State.IDLE,this.warn(d.details+" while loading frag, switching to "+this.state+" state"));break;case a.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===y.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},c._handleTransmuxComplete=function(h){var d,l="audio",v=this.hls,m=h.remuxResult,O=h.chunkMeta,b=this.getCurrentContext(O);if(!b){this.warn("The loading context changed while buffering fragment "+O.sn+" of level "+O.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(O.level);return}var M=b.frag,F=b.part,w=b.level.details,C=m.audio,B=m.text,U=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,O),v.trigger(x.Events.FRAG_PARSING_INIT_SEGMENT,{frag:M,id:l,tracks:j.tracks})),C){var N=C.startPTS,K=C.endPTS,H=C.startDTS,V=C.endDTS;F&&(F.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:N,endPTS:K,startDTS:H,endDTS:V}),M.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,N,K,H,V),this.bufferFragmentData(C,M,F,O)}if(U!=null&&(d=U.samples)!==null&&d!==void 0&&d.length){var Y=e({id:l,frag:M,details:w},U);v.trigger(x.Events.FRAG_PARSING_METADATA,Y)}if(B){var Q=e({id:l,frag:M,details:w},B);v.trigger(x.Events.FRAG_PARSING_USERDATA,Q)}}},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(x.Events.BUFFER_CODECS,h);var m=v.initSegment;if(m!=null&&m.byteLength){var O={type:"audio",frag:d,part:null,chunkMeta:l,parent:d.type,data:m};this.hls.trigger(x.Events.BUFFER_APPENDING,O)}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=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(x.Events.AUDIO_TRACK_SWITCHED,{id:l})},u}(p.default);P.default=i},"./src/controller/audio-track-controller.ts":function(k,P,s){"use strict";s.r(P);var R=s("./src/events.ts"),p=s("./src/errors.ts"),x=s("./src/controller/base-playlist-controller.ts"),I=s("./src/types/loader.ts");function T(A,S){for(var g=0;g<S.length;g++){var E=S[g];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(A,E.key,E)}}function L(A,S,g){return S&&T(A.prototype,S),g&&T(A,g),Object.defineProperty(A,"prototype",{writable:!1}),A}function _(A,S){A.prototype=Object.create(S.prototype),A.prototype.constructor=A,y(A,S)}function y(A,S){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(E,a){return E.__proto__=a,E},y(A,S)}var D=function(A){_(S,A);function S(E){var a;return a=A.call(this,E,"[audio-track-controller]")||this,a.tracks=[],a.groupId=null,a.tracksInGroup=[],a.trackId=-1,a.trackName="",a.selectDefaultTrack=!0,a.registerListeners(),a}var g=S.prototype;return g.registerListeners=function(){var a=this.hls;a.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.on(R.Events.LEVEL_LOADING,this.onLevelLoading,this),a.on(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),a.on(R.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),a.on(R.Events.ERROR,this.onError,this)},g.unregisterListeners=function(){var a=this.hls;a.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.off(R.Events.LEVEL_LOADING,this.onLevelLoading,this),a.off(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),a.off(R.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),a.off(R.Events.ERROR,this.onError,this)},g.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,A.prototype.destroy.call(this)},g.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},g.onManifestParsed=function(a,e){this.tracks=e.audioTracks||[]},g.onAudioTrackLoaded=function(a,e){var o=e.id,f=e.details,n=this.tracksInGroup[o];if(!n){this.warn("Invalid audio track id "+o);return}var i=n.details;n.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(a,e){this.switchLevel(e.level)},g.onLevelSwitching=function(a,e){this.switchLevel(e.level)},g.switchLevel=function(a){var e=this.hls.levels[a];if(!!(e!=null&&e.audioGroupIds)){var 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 n={audioTracks:f};this.log("Updating audio tracks, "+f.length+' track(s) found in "'+o+'" group-id'),this.hls.trigger(R.Events.AUDIO_TRACKS_UPDATED,n),this.selectInitialTrack()}}},g.onError=function(a,e){A.prototype.onError.call(this,a,e),!(e.fatal||!e.context)&&e.context.type===I.PlaylistContextType.AUDIO_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.retryLoadingOrFail(e)},g.setAudioTrack=function(a){var e=this.tracksInGroup;if(a<0||a>=e.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var o=e[this.trackId];this.log("Now switching to audio-track index "+a);var f=e[a],n=f.id,i=f.groupId,t=i===void 0?"":i,u=f.name,c=f.type,r=f.url;if(this.trackId=a,this.trackName=u,this.selectDefaultTrack=!1,this.hls.trigger(R.Events.AUDIO_TRACK_SWITCHING,{id:n,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 a=this.tracksInGroup;console.assert(a.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(a){for(var e=this.tracksInGroup,o=0;o<e.length;o++){var f=e[o];if((!this.selectDefaultTrack||f.default)&&(!a||a===f.name))return f.id}return-1},g.loadPlaylist=function(a){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var o=e.id,f=e.groupId,n=e.url;if(a)try{n=a.addDirectives(n)}catch(i){this.warn("Could not construct new URL with HLS Delivery Directives: "+i)}this.log("loading audio-track playlist for id: "+o),this.clearTimer(),this.hls.trigger(R.Events.AUDIO_TRACK_LOADING,{url:n,id:o,groupId:f,deliveryDirectives:a||null})}},L(S,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(a){this.selectDefaultTrack=!1,this.setAudioTrack(a)}}]),S}(x.default);P.default=D},"./src/controller/base-playlist-controller.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"default",function(){return L});var R=s("./src/polyfills/number.ts"),p=s("./src/types/level.ts"),x=s("./src/controller/level-helper.ts"),I=s("./src/utils/logger.ts"),T=s("./src/errors.ts"),L=function(){function _(D,A){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,A+":"),this.warn=I.logger.warn.bind(I.logger,A+":"),this.hls=D}var y=_.prototype;return y.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},y.onError=function(A,S){S.fatal&&S.type===T.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},y.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},y.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},y.stopLoad=function(){this.canLoad=!1,this.clearTimer()},y.switchParams=function(A,S){var g=S==null?void 0:S.renditionReports;if(g)for(var E=0;E<g.length;E++){var a=g[E],e=""+a.URI;if(e===A.slice(-e.length)){var o=parseInt(a["LAST-MSN"]),f=parseInt(a["LAST-PART"]);if(S&&this.hls.config.lowLatencyMode){var n=Math.min(S.age-S.partTarget,S.targetduration);f!==void 0&&n>S.partTarget&&(f+=1)}if(Object(R.isFiniteNumber)(o))return new p.HlsUrlParameters(o,Object(R.isFiniteNumber)(f)?f:void 0,p.HlsSkip.No)}}},y.loadPlaylist=function(A){},y.shouldLoadTrack=function(A){return this.canLoad&&A&&!!A.url&&(!A.details||A.details.live)},y.playlistLoaded=function(A,S,g){var E=this,a=S.details,e=S.stats,o=e.loading.end?Math.max(0,self.performance.now()-e.loading.end):0;if(a.advancedDateTime=Date.now()-o,a.live||g!=null&&g.live){if(a.reloaded(g),g&&this.log("live playlist "+A+" "+(a.advanced?"REFRESHED "+a.lastPartSn+"-"+a.lastPartIndex:"MISSED")),g&&a.fragments.length>0&&Object(x.mergeDetails)(g,a),!this.canLoad||!a.live)return;var f,n=void 0,i=void 0;if(a.canBlockReload&&a.endSN&&a.advanced){var t=this.hls.config.lowLatencyMode,u=a.lastPartSn,c=a.endSN,r=a.lastPartIndex,h=r!==-1,d=u===c,l=t?0:r;h?(n=d?c+1:u,i=d?l:r+1):n=c+1;var v=a.age,m=v+a.ageHeader,O=Math.min(m-a.partTarget,a.targetduration*1.5);if(O>0){if(g&&O>g.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+g.tuneInGoal+" to: "+O+" with playlist age: "+a.age),O=0;else{var b=Math.floor(O/a.targetduration);if(n+=b,i!==void 0){var M=Math.round(O%a.targetduration/a.partTarget);i+=M}this.log("CDN Tune-in age: "+a.ageHeader+"s last advanced "+v.toFixed(2)+"s goal: "+O+" skip sn "+b+" to part "+i)}a.tuneInGoal=O}if(f=this.getDeliveryDirectives(a,S.deliveryDirectives,n,i),t||!d){this.loadPlaylist(f);return}}else f=this.getDeliveryDirectives(a,S.deliveryDirectives,n,i);var F=Object(x.computeReloadInterval)(a,e);n!==void 0&&a.canBlockReload&&(F-=a.partTarget||1),this.log("reload live playlist "+A+" in "+Math.round(F)+" ms"),this.timer=self.setTimeout(function(){return E.loadPlaylist(f)},F)}else this.clearTimer()},y.getDeliveryDirectives=function(A,S,g,E){var a=Object(p.getSkipValue)(A,g);return S!=null&&S.skip&&A.deltaUpdateFailed&&(g=S.msn,E=S.part,a=p.HlsSkip.No),new p.HlsUrlParameters(g,E,a)},y.retryLoadingOrFail=function(A){var S=this,g=this.hls.config,E=this.retryCount<g.levelLoadingMaxRetry;if(E){var a;if(this.retryCount++,A.details.indexOf("LoadTimeOut")>-1&&(a=A.context)!==null&&a!==void 0&&a.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+A.details+'"'),this.loadPlaylist();else{var e=Math.min(Math.pow(2,this.retryCount)*g.levelLoadingRetryDelay,g.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return S.loadPlaylist()},e),this.warn("retry playlist loading #"+this.retryCount+" in "+e+' ms after "'+A.details+'"')}}else this.warn('cannot recover from error "'+A.details+'"'),this.clearTimer(),A.fatal=!0;return E},_}()},"./src/controller/base-stream-controller.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"State",function(){return c}),s.d(P,"default",function(){return r});var R=s("./src/polyfills/number.ts"),p=s("./src/task-loop.ts"),x=s("./src/controller/fragment-tracker.ts"),I=s("./src/utils/buffer-helper.ts"),T=s("./src/utils/logger.ts"),L=s("./src/events.ts"),_=s("./src/errors.ts"),y=s("./src/types/transmuxer.ts"),D=s("./src/utils/mp4-tools.ts"),A=s("./src/utils/discontinuities.ts"),S=s("./src/controller/fragment-finders.ts"),g=s("./src/controller/level-helper.ts"),E=s("./src/loader/fragment-loader.ts"),a=s("./src/crypt/decrypter.ts"),e=s("./src/utils/time-ranges.ts"),o=s("./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 n(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,O){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=O,b.log=T.logger.log.bind(T.logger,O+":"),b.warn=T.logger.warn.bind(T.logger,O+":"),b.hls=v,b.fragmentLoader=new E.default(v.config),b.fragmentTracker=m,b.config=v.config,b.decrypter=new a.default(v,v.config),v.on(L.Events.KEY_LOADED,b.onKeyLoaded,i(b)),v.on(L.Events.LEVEL_SWITCHING,b.onLevelSwitching,i(b)),b}var 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,O){var b=this.fragCurrent,M=this.fragmentTracker;if(!O.live&&b&&this.media&&b.sn>=O.endSN&&!m.nextStart){var F=O.partList;if(F!=null&&F.length){var w=F[F.length-1],C=I.BufferHelper.isBuffered(this.media,w.start+w.duration/2);return C}var B=M.getState(b);return B===x.FragmentState.PARTIAL||B===x.FragmentState.OK}return!1},l.onMediaAttached=function(m,O){var b=this.media=this.mediaBuffer=O.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),b.addEventListener("seeking",this.onvseeking),b.addEventListener("ended",this.onvended);var M=this.config;this.levels&&M.autoStartLoad&&this.state===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,O=this.fragCurrent,b=this.media,M=this.mediaBuffer,F=this.state,w=b?b.currentTime:0,C=I.BufferHelper.bufferInfo(M||b,w,m.maxBufferHole);if(this.log("media seeking to "+(Object(R.isFiniteNumber)(w)?w.toFixed(3):w)+", state: "+F),F===c.ENDED)this.resetLoadingState();else if(O&&!C.len){var B=m.maxFragLookUpTolerance,U=O.start-B,j=O.start+O.duration+B,N=w>j;(w<U||N)&&(N&&O.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),O.loader.abort()),this.resetLoadingState())}b&&(this.lastCurrentTime=w),!this.loadedmetadata&&!C.len&&(this.nextLoadPosition=this.startPosition=w),this.tickImmediate()},l.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},l.onKeyLoaded=function(m,O){if(!(this.state!==c.KEY_LOADING||O.frag!==this.fragCurrent||!this.levels)){this.state=c.IDLE;var b=this.levels[O.frag.level].details;b&&this.loadFragment(O.frag,b,O.frag.start)}},l.onLevelSwitching=function(m,O){this.fragLoadError=0},l.onHandlerDestroying=function(){this.stopLoad(),h.prototype.onHandlerDestroying.call(this)},l.onHandlerDestroyed=function(){this.state=c.STOPPED,this.hls.off(L.Events.KEY_LOADED,this.onKeyLoaded,this),this.hls.off(L.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,h.prototype.onHandlerDestroyed.call(this)},l.loadKey=function(m,O){this.log("Loading key for "+m.sn+" of ["+O.startSN+"-"+O.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+m.level),this.state=c.KEY_LOADING,this.fragCurrent=m,this.hls.trigger(L.Events.KEY_LOADING,{frag:m})},l.loadFragment=function(m,O,b){this._loadFragForPlayback(m,O,b)},l._loadFragForPlayback=function(m,O,b){var M=this,F=function(C){if(M.fragContextChanged(m)){M.warn("Fragment "+m.sn+(C.part?" p: "+C.part.index:"")+" of level "+m.level+" was dropped during download."),M.fragmentTracker.removeFragment(m);return}m.stats.chunkCount++,M._handleFragmentLoadProgress(C)};this._doFragLoad(m,O,b,F).then(function(w){if(!!w){M.fragLoadError=0;var C=M.state;if(M.fragContextChanged(m)){(C===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(L.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,O,b){if(b===void 0&&(b=null),!!(m-O)){var M={startOffset:m,endOffset:O,type:b};this.fragLoadError=0,this.hls.trigger(L.Events.BUFFER_FLUSHING,M)}},l._loadInitSegment=function(m){var O=this;this._doFragLoad(m).then(function(b){if(!b||O.fragContextChanged(m)||!O.levels)throw new Error("init load aborted");return b}).then(function(b){var M=O.hls,F=b.payload,w=m.decryptdata;if(F&&F.byteLength>0&&w&&w.key&&w.iv&&w.method==="AES-128"){var C=self.performance.now();return O.decrypter.webCryptoDecrypt(new Uint8Array(F),w.key.buffer,w.iv.buffer).then(function(B){var U=self.performance.now();return M.trigger(L.Events.FRAG_DECRYPTED,{frag:m,payload:B,stats:{tstart:C,tdecrypt:U}}),b.payload=B,b})}return b}).then(function(b){var M=O.fragCurrent,F=O.hls,w=O.levels;if(!w)throw new Error("init load aborted, missing levels");var C=w[m.level].details;console.assert(C,"Level details are defined when init segment is loaded");var B=m.stats;O.state=c.IDLE,O.fragLoadError=0,m.data=new Uint8Array(b.payload),B.parsing.start=B.buffering.start=self.performance.now(),B.parsing.end=B.buffering.end=self.performance.now(),b.frag===M&&F.trigger(L.Events.FRAG_BUFFERED,{stats:B,frag:M,part:null,id:m.type}),O.tick()}).catch(function(b){O.state===c.STOPPED||O.state===c.ERROR||(O.warn(b),O.resetFragmentLoading(m))})},l.fragContextChanged=function(m){var O=this.fragCurrent;return!m||!O||m.level!==O.level||m.sn!==O.sn||m.urlId!==O.urlId},l.fragBufferedComplete=function(m,O){var b=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+m.type+" sn: "+m.sn+(O?" part: "+O.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+m.level+" "+(b?e.default.toString(I.BufferHelper.getBuffered(b)):"(detached)")),this.state=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 O=this.transmuxer;if(!!O){var b=m.frag,M=m.part,F=m.partsLoaded,w=!F||F.length===0||F.some(function(B){return!B}),C=new y.ChunkMetadata(b.level,b.sn,b.stats.chunkCount+1,0,M?M.index:-1,!w);O.flush(C)}},l._handleFragmentLoadProgress=function(m){},l._doFragLoad=function(m,O,b,M){var F=this;if(b===void 0&&(b=null),!this.levels)throw new Error("frag load aborted, missing levels");if(b=Math.max(m.start,b||0),this.config.lowLatencyMode&&O){var w=O.partList;if(w&&M){b>m.end&&O.fragmentHint&&(m=O.fragmentHint);var C=this.getNextPart(w,m,b);if(C>-1){var B=w[C];return this.log("Loading part sn: "+m.sn+" p: "+B.index+" cc: "+m.cc+" of playlist ["+O.startSN+"-"+O.endSN+"] parts [0-"+C+"-"+(w.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+m.level+", target: "+parseFloat(b.toFixed(3))),this.nextLoadPosition=B.start+B.duration,this.state=c.FRAG_LOADING,this.hls.trigger(L.Events.FRAG_LOADING,{frag:m,part:w[C],targetBufferTime:b}),this.doFragPartsLoad(m,w,C,M).catch(function(U){return F.handleFragLoadError(U)})}else if(!m.url||this.loadedEndOfParts(w,b))return Promise.resolve(null)}}return this.log("Loading fragment "+m.sn+" cc: "+m.cc+" "+(O?"of ["+O.startSN+"-"+O.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+m.level+", target: "+parseFloat(b.toFixed(3))),Object(R.isFiniteNumber)(m.sn)&&!this.bitrateTest&&(this.nextLoadPosition=m.start+m.duration),this.state=c.FRAG_LOADING,this.hls.trigger(L.Events.FRAG_LOADING,{frag:m,targetBufferTime:b}),this.fragmentLoader.load(m,M).catch(function(U){return F.handleFragLoadError(U)})},l.doFragPartsLoad=function(m,O,b,M){var F=this;return new Promise(function(w,C){var B=[],U=function j(N){var K=O[N];F.fragmentLoader.loadPart(m,K,M).then(function(H){B[K.index]=H;var V=H.part;F.hls.trigger(L.Events.FRAG_LOADED,H);var Y=O[N+1];if(Y&&Y.fragment===m)j(N+1);else return w({frag:m,part:V,partsLoaded:B})}).catch(C)};U(b)})},l.handleFragLoadError=function(m){var O=m.data;return O&&O.details===_.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(O.frag,O.part):this.hls.trigger(L.Events.ERROR,O),null},l._handleTransmuxerFlush=function(m){var O=this.getCurrentContext(m);if(!O||this.state!==c.PARSING){this.fragCurrent||(this.state=c.IDLE);return}var b=O.frag,M=O.part,F=O.level,w=self.performance.now();b.stats.parsing.end=w,M&&(M.stats.parsing.end=w),this.updateLevelTiming(b,M,F,m.partial)},l.getCurrentContext=function(m){var O=this.levels,b=m.level,M=m.sn,F=m.part;if(!O||!O[b])return this.warn("Levels object was unset while buffering fragment "+M+" of level "+b+". The current chunk will not be buffered."),null;var w=O[b],C=F>-1?Object(g.getPartWith)(w,M,F):null,B=C?C.fragment:Object(g.getFragmentWithSN)(w,M,this.fragCurrent);return B?{frag:B,part:C,level:w}:null},l.bufferFragmentData=function(m,O,b,M){if(!(!m||this.state!==c.PARSING)){var F=m.data1,w=m.data2,C=F;if(F&&w&&(C=Object(D.appendUint8Array)(F,w)),!(!C||!C.length)){var B={type:m.type,frag:O,part:b,chunkMeta:M,parent:O.type,data:C};this.hls.trigger(L.Events.BUFFER_APPENDING,B),m.dropped&&m.independent&&!b&&this.flushBufferGap(O)}}},l.flushBufferGap=function(m){var O=this.media;if(!!O){if(!I.BufferHelper.isBuffered(O,O.currentTime)){this.flushMainBuffer(0,m.start);return}var b=O.currentTime,M=I.BufferHelper.bufferInfo(O,b,0),F=m.duration,w=Math.min(this.config.maxFragLookUpTolerance*2,F*.25),C=Math.max(Math.min(m.start-w,M.end-w),b+w);m.start-C>w&&this.flushMainBuffer(C,m.start)}},l.getFwdBufferInfo=function(m,O){var b=this.config,M=this.getLoadPosition();if(!Object(R.isFiniteNumber)(M))return null;var F=I.BufferHelper.bufferInfo(m,M,b.maxBufferHole);if(F.len===0&&F.nextStart!==void 0){var w=this.fragmentTracker.getBufferedFrag(M,O);if(w&&F.nextStart<w.end)return I.BufferHelper.bufferInfo(m,M,Math.max(F.nextStart,b.maxBufferHole))}return F},l.getMaxBufferLength=function(m){var O=this.config,b;return m?b=Math.max(8*O.maxBufferSize/m,O.maxBufferLength):b=O.maxBufferLength,Math.min(b,O.maxMaxBufferLength)},l.reduceMaxBufferLength=function(m){var O=this.config,b=m||O.maxBufferLength;return O.maxMaxBufferLength>=b?(O.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+O.maxMaxBufferLength+"s"),!0):!1},l.getNextFragment=function(m,O){var b=O.fragments,M=b.length;if(!M)return null;var F=this.config,w=b[0].start,C;if(O.live){var B=F.initialLiveManifestSize;if(M<B)return this.warn("Not enough fragments to start playback (have: "+M+", need: "+B+")"),null;!O.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(C=this.getInitialLiveFragment(O,b),this.startPosition=C?this.hls.liveSyncPosition||C.start:m)}else m<=w&&(C=b[0]);if(!C){var U=F.lowLatencyMode?O.partEnd:O.fragmentEnd;C=this.getFragmentAtPosition(m,U,O)}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,O,b){for(var M=-1,F=!1,w=!0,C=0,B=m.length;C<B;C++){var U=m[C];if(w=w&&!U.independent,M>-1&&b<U.start)break;var j=U.loaded;!j&&(F||U.independent||w)&&U.fragment===O&&(M=C),F=j}return M},l.loadedEndOfParts=function(m,O){var b=m[m.length-1];return b&&O>b.start&&b.loaded},l.getInitialLiveFragment=function(m,O){var b=this.fragPrevious,M=null;if(b){if(m.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+b.programDateTime),M=Object(S.findFragmentByPDT)(O,b.endProgramDateTime,this.config.maxFragLookUpTolerance)),!M){var F=b.sn+1;if(F>=m.startSN&&F<=m.endSN){var w=O[F-m.startSN];b.cc===w.cc&&(M=w,this.log("Live playlist, switching playlist, load frag with next SN: "+M.sn))}M||(M=Object(S.findFragWithCC)(O,b.cc),M&&this.log("Live playlist, switching playlist, load frag with same CC: "+M.sn))}}else{var C=this.hls.liveSyncPosition;C!==null&&(M=this.getFragmentAtPosition(C,this.bitrateTest?m.fragmentEnd:m.edge,m))}return M},l.getFragmentAtPosition=function(m,O,b){var M=this.config,F=this.fragPrevious,w=b.fragments,C=b.endSN,B=b.fragmentHint,U=M.maxFragLookUpTolerance,j=!!(M.lowLatencyMode&&b.partList&&B);j&&B&&!this.bitrateTest&&(w=w.concat(B),C=B.sn);var N;if(m<O){var K=m>O-U?0:U;N=Object(S.findFragmentByPTS)(F,w,m,K)}else N=w[w.length-1];if(N){var H=N.sn-b.startSN;if(F&&N.sn===F.sn&&!j){var V=F&&N.level===F.level;if(V){var Y=w[H+1];N.sn<C&&this.fragmentTracker.getState(Y)!==x.FragmentState.OK?(this.log("SN "+N.sn+" just loaded, load next one: "+Y.sn),N=Y):N=null}}}return N},l.synchronizeToLiveEdge=function(m){var O=this.config,b=this.media;if(!!b){var M=this.hls.liveSyncPosition,F=b.currentTime,w=m.fragments[0].start,C=m.edge,B=F>=w-O.maxFragLookUpTolerance&&F<=C;if(M!==null&&b.duration>M&&(F<M||!B)){var U=O.liveMaxLatencyDuration!==void 0?O.liveMaxLatencyDuration:O.liveMaxLatencyDurationCount*m.targetduration;(!B&&b.readyState<4||F<C-U)&&(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,O){var b=this.levels,M=this.levelLastLoaded,F=this.fragPrevious,w=M!==null?b[M]:null,C=m.fragments.length;if(!C)return this.warn("No fragments in live playlist"),0;var B=m.fragments[0].start,U=!O,j=m.alignedSliding&&Object(R.isFiniteNumber)(B);if(U||!j&&!B){Object(A.alignStream)(F,w,m);var N=m.fragments[0].start;return this.log("Live playlist sliding: "+N.toFixed(2)+" start-sn: "+(O?O.startSN:"na")+"->"+m.startSN+" prev-sn: "+(F?F.sn:"na")+" fragments: "+C),N}return B},l.waitForCdnTuneIn=function(m){var O=3;return m.live&&m.canBlockReload&&m.partTarget&&m.tuneInGoal>Math.max(m.partHoldBack,m.partTarget*O)},l.setStartPosition=function(m,O){var b=this.startPosition;if(b<O&&(b=-1),b===-1||this.lastCurrentTime===-1){var M=m.startTimeOffset;Object(R.isFiniteNumber)(M)?(b=O+M,M<0&&(b+=m.totalduration),b=Math.min(Math.max(O,b),O+m.totalduration),this.log("Start time offset "+M+" found in playlist, adjust startPosition to "+b),this.startPosition=b):m.live?b=this.hls.liveSyncPosition||O:this.startPosition=b=0,this.lastCurrentTime=b}this.nextLoadPosition=b},l.getLoadPosition=function(){var m=this.media,O=0;return this.loadedmetadata&&m?O=m.currentTime:this.nextLoadPosition&&(O=this.nextLoadPosition),O},l.handleFragLoadAborted=function(m,O){this.transmuxer&&m.sn!=="initSegment"&&m.stats.aborted&&(this.warn("Fragment "+m.sn+(O?" part"+O.index:"")+" of level "+m.level+" was aborted"),this.resetFragmentLoading(m))},l.resetFragmentLoading=function(m){(!this.fragCurrent||!this.fragContextChanged(m)&&this.state!==c.FRAG_LOADING_WAITING_RETRY)&&(this.state=c.IDLE)},l.onFragmentOrKeyLoadError=function(m,O){if(!O.fatal){var b=O.frag;if(!(!b||b.type!==m)){var M=this.fragCurrent;console.assert(M&&b.sn===M.sn&&b.level===M.level&&b.urlId===M.urlId,"Frag load error must match current frag to retry");var F=this.config;if(this.fragLoadError+1<=F.fragLoadingMaxRetry){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var w=Math.min(Math.pow(2,this.fragLoadError)*F.fragLoadingRetryDelay,F.fragLoadingMaxRetryTimeout);this.warn("Fragment "+b.sn+" of "+m+" "+b.level+" failed to load, retrying in "+w+"ms"),this.retryDate=self.performance.now()+w,this.fragLoadError++,this.state=c.FRAG_LOADING_WAITING_RETRY}else O.levelRetry?(m===o.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=c.IDLE):(T.logger.error(O.details+" reaches max retry, redispatch as fatal ..."),O.fatal=!0,this.hls.stopLoad(),this.state=c.ERROR)}}},l.afterBufferFlushed=function(m,O,b){if(!!m){var M=I.BufferHelper.getBuffered(m);this.fragmentTracker.detectEvictedFragments(O,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 O=this.levels?this.levels[m].details:null;O!=null&&O.live?(this.startPosition=-1,this.setStartPosition(O,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},l.updateLevelTiming=function(m,O,b,M){var F=this,w=b.details;console.assert(!!w,"level.details must be defined");var C=Object.keys(m.elementaryStreams).reduce(function(B,U){var j=m.elementaryStreams[U];if(j){var N=j.endPTS-j.startPTS;if(N<=0)return F.warn("Could not parse fragment "+m.sn+" "+U+" duration reliably ("+N+")"),B||!1;var K=M?0:Object(g.updateFragPTSDTS)(w,m,j.startPTS,j.endPTS,j.startDTS,j.endDTS);return F.hls.trigger(L.Events.LEVEL_PTS_UPDATED,{details:w,level:b,drift:K,type:U,frag:m,start:j.startPTS,end:j.endPTS}),!0}return B},!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(L.Events.FRAG_PARSED,{frag:m,part:O})},l.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},n(d,[{key:"state",get:function(){return this._state},set:function(m){var O=this._state;O!==m&&(this._state=m,this.log(O+"->"+m))}}]),d}(p.default)},"./src/controller/buffer-controller.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"default",function(){return S});var R=s("./src/polyfills/number.ts"),p=s("./src/events.ts"),x=s("./src/utils/logger.ts"),I=s("./src/errors.ts"),T=s("./src/utils/buffer-helper.ts"),L=s("./src/utils/mediasource-helper.ts"),_=s("./src/loader/fragment.ts"),y=s("./src/controller/buffer-operation-queue.ts"),D=Object(L.getMediaSource)(),A=/([ha]vc.)(?:\.[^.,]+)+/,S=function(){function g(a){var e=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var o=e.hls,f=e.media,n=e.mediaSource;x.logger.log("[buffer-controller]: Media source opened"),f&&(e.updateMediaElementDuration(),o.trigger(p.Events.MEDIA_ATTACHED,{media:f})),n&&n.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){x.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){x.logger.log("[buffer-controller]: Media source ended")},this.hls=a,this._initSourceBuffer(),this.registerListeners()}var E=g.prototype;return E.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},E.destroy=function(){this.unregisterListeners(),this.details=null},E.registerListeners=function(){var e=this.hls;e.on(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.Events.BUFFER_RESET,this.onBufferReset,this),e.on(p.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(p.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(p.Events.BUFFER_EOS,this.onBufferEos,this),e.on(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(p.Events.FRAG_PARSED,this.onFragParsed,this),e.on(p.Events.FRAG_CHANGED,this.onFragChanged,this)},E.unregisterListeners=function(){var e=this.hls;e.off(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.Events.BUFFER_RESET,this.onBufferReset,this),e.off(p.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(p.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(p.Events.BUFFER_EOS,this.onBufferEos,this),e.off(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(p.Events.FRAG_PARSED,this.onFragParsed,this),e.off(p.Events.FRAG_CHANGED,this.onFragChanged,this)},E._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new y.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},E.onManifestParsed=function(e,o){var f=2;(o.audio&&!o.video||!o.altAudio)&&(f=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=f,this.details=null,x.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},E.onMediaAttaching=function(e,o){var f=this.media=o.media;if(f&&D){var n=this.mediaSource=new D;n.addEventListener("sourceopen",this._onMediaSourceOpen),n.addEventListener("sourceended",this._onMediaSourceEnded),n.addEventListener("sourceclose",this._onMediaSourceClose),f.src=self.URL.createObjectURL(n),this._objectUrl=f.src}},E.onMediaDetaching=function(){var e=this.media,o=this.mediaSource,f=this._objectUrl;if(o){if(x.logger.log("[buffer-controller]: media source detaching"),o.readyState==="open")try{o.endOfStream()}catch(n){x.logger.warn("[buffer-controller]: onMediaDetaching: "+n.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()):x.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(p.Events.MEDIA_DETACHED,void 0)},E.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(n){x.logger.warn("[buffer-controller]: Failed to reset the "+o+" buffer",n)}}),this._initSourceBuffer()},E.onBufferCodecs=function(e,o){var f=this,n=this.getSourceBufferTypes().length;Object.keys(o).forEach(function(i){if(n){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(A,"$1"),m=(h||r).replace(A,"$1");if(v!==m){var O=d+";codecs="+(h||r);f.appendChangeType(i,O),x.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]}),!n&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},E.appendChangeType=function(e,o){var f=this,n=this.operationQueue,i={execute:function(){var u=f.sourceBuffer[e];u&&(x.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+o),u.changeType(o)),n.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(u){x.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",u)}};n.append(i,e)},E.onBufferAppending=function(e,o){var f=this,n=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,O=h?h.stats.buffering:null;m.start===0&&(m.start=v),O&&O.start===0&&(O.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 B=r.start-C.timestampOffset;Math.abs(B)>=.1&&(x.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+r.start+" (delta: "+B+") 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),O&&O.first===0&&(O.first=C);var B=f.sourceBuffer,U={};for(var j in B)U[j]=T.BufferHelper.getBuffered(B[j]);f.appendError=0,f.hls.trigger(p.Events.BUFFER_APPENDED,{type:c,frag:r,part:h,chunkMeta:d,parent:r.type,timeRanges:U})},onError:function(C){x.logger.error("[buffer-controller]: Error encountered while trying to append to the "+c+" SourceBuffer",C);var B={type:I.ErrorTypes.MEDIA_ERROR,parent:r.type,details:I.ErrorDetails.BUFFER_APPEND_ERROR,err:C,fatal:!1};C.code===DOMException.QUOTA_EXCEEDED_ERR?B.details=I.ErrorDetails.BUFFER_FULL_ERROR:(f.appendError++,B.details=I.ErrorDetails.BUFFER_APPEND_ERROR,f.appendError>n.config.appendErrorMaxRetry&&(x.logger.error("[buffer-controller]: Failed "+n.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),B.fatal=!0,n.stopLoad())),n.trigger(p.Events.ERROR,B)}};i.append(F,c)},E.onBufferFlushing=function(e,o){var f=this,n=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){x.logger.warn("[buffer-controller]: Failed to remove from "+u+" SourceBuffer",r)}}};o.type?n.append(i(o.type),o.type):this.getSourceBufferTypes().forEach(function(t){n.append(i(t),t)})},E.onFragParsed=function(e,o){var f=this,n=o.frag,i=o.part,t=[],u=i?i.elementaryStreams:n.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();n.stats.buffering.end=h,i&&(i.stats.buffering.end=h);var d=i?i.stats:n.stats;f.hls.trigger(p.Events.FRAG_BUFFERED,{frag:n,part:i,stats:d,id:n.type})};t.length===0&&x.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+n.type+" level: "+n.level+" sn: "+n.sn),this.blockBuffers(c,t)},E.onFragChanged=function(e,o){this.flushBackBuffer()},E.onBufferEos=function(e,o){var f=this,n=this.getSourceBufferTypes().reduce(function(i,t){var u=f.sourceBuffer[t];return(!o.type||o.type===t)&&u&&!u.ended&&(u.ended=!0,x.logger.log("[buffer-controller]: "+t+" sourceBuffer now EOS")),i&&!!(!u||u.ended)},!0);n&&this.blockBuffers(function(){var i=f.mediaSource;!i||i.readyState!=="open"||i.endOfStream()})},E.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())},E.flushBackBuffer=function(){var e=this.hls,o=this.details,f=this.media,n=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=n[d];if(l){var v=T.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}))}})}}}},E.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var e=this.details,o=this.hls,f=this.media,n=this.mediaSource,i=e.fragments[0].start+e.totalduration,t=f.duration,u=Object(R.isFiniteNumber)(n.duration)?n.duration:0;e.live&&o.config.liveDurationInfinity?(x.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(e)):(i>u&&i>t||!Object(R.isFiniteNumber)(t))&&(x.logger.log("[buffer-controller]: Updating Media Source duration to "+i.toFixed(3)),n.duration=i)}},E.updateSeekableRange=function(e){var o=this.mediaSource,f=e.fragments,n=f.length;if(n&&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)}},E.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,o=this.operationQueue,f=this.pendingTracks,n=Object.keys(f).length;if(n&&!e||n===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)})}},E.createSourceBuffers=function(e){var o=this.sourceBuffer,f=this.mediaSource;if(!f)throw Error("createSourceBuffers called when mediaSource was null");var n=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;x.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},n++}catch(d){x.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})}}n&&this.hls.trigger(p.Events.BUFFER_CREATED,{tracks:this.tracks})},E._onSBUpdateStart=function(e){var o=this.operationQueue,f=o.current(e);f.onStart()},E._onSBUpdateEnd=function(e){var o=this.operationQueue,f=o.current(e);f.onComplete(),o.shiftAndExecuteNext(e)},E._onSBUpdateError=function(e,o){x.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)},E.removeExecutor=function(e,o,f){var n=this.media,i=this.mediaSource,t=this.operationQueue,u=this.sourceBuffer,c=u[e];if(!n||!i||!c){x.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),t.shiftAndExecuteNext(e);return}var r=Object(R.isFiniteNumber)(n.duration)?n.duration:1/0,h=Object(R.isFiniteNumber)(i.duration)?i.duration:1/0,d=Math.max(0,o),l=Math.min(f,r,h);l>d?(x.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)},E.appendExecutor=function(e,o){var f=this.operationQueue,n=this.sourceBuffer,i=n[o];if(!i){x.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)},E.blockBuffers=function(e,o){var f=this;if(o===void 0&&(o=this.getSourceBufferTypes()),!o.length){x.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}var n=this.operationQueue,i=o.map(function(t){return n.appendBlocker(t)});Promise.all(i).then(function(){e(),o.forEach(function(t){var u=f.sourceBuffer[t];(!u||!u.updating)&&n.shiftAndExecuteNext(t)})})},E.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},E.addBufferListener=function(e,o,f){var n=this.sourceBuffer[e];if(!!n){var i=f.bind(this,e);this.listeners[e].push({event:o,listener:i}),n.addEventListener(o,i)}},E.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(k,P,s){"use strict";s.r(P),s.d(P,"default",function(){return p});var R=s("./src/utils/logger.ts"),p=function(){function x(T){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=T}var I=x.prototype;return I.append=function(L,_){var y=this.queues[_];y.push(L),y.length===1&&this.buffers[_]&&this.executeNext(_)},I.insertAbort=function(L,_){var y=this.queues[_];y.unshift(L),this.executeNext(_)},I.appendBlocker=function(L){var _,y=new Promise(function(A){_=A}),D={execute:_,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(D,L),y},I.executeNext=function(L){var _=this.buffers,y=this.queues,D=_[L],A=y[L];if(A.length){var S=A[0];try{S.execute()}catch(g){R.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),S.onError(g),(!D||!D.updating)&&(A.shift(),this.executeNext(L))}}},I.shiftAndExecuteNext=function(L){this.queues[L].shift(),this.executeNext(L)},I.current=function(L){return this.queues[L][0]},x}()},"./src/controller/cap-level-controller.ts":function(k,P,s){"use strict";s.r(P);var R=s("./src/events.ts");function p(T,L){for(var _=0;_<L.length;_++){var y=L[_];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(T,y.key,y)}}function x(T,L,_){return L&&p(T.prototype,L),_&&p(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 L=T.prototype;return L.setStreamController=function(y){this.streamController=y},L.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},L.registerListeners=function(){var y=this.hls;y.on(R.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.on(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.on(R.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},L.unregisterListener=function(){var y=this.hls;y.off(R.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.off(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.off(R.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},L.onFpsDropLevelCapping=function(y,D){T.isLevelAllowed(D.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(D.droppedLevel)},L.onMediaAttaching=function(y,D){this.media=D.media instanceof HTMLVideoElement?D.media:null},L.onManifestParsed=function(y,D){var A=this.hls;this.restrictedLevels=[],this.firstLevel=D.firstLevel,A.config.capLevelToPlayerSize&&D.video&&this.startCapping()},L.onBufferCodecs=function(y,D){var A=this.hls;A.config.capLevelToPlayerSize&&D.video&&this.startCapping()},L.onMediaDetaching=function(){this.stopCapping()},L.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var y=this.hls.levels;if(y.length){var D=this.hls;D.autoLevelCapping=this.getMaxLevel(y.length-1),D.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=D.autoLevelCapping}}},L.getMaxLevel=function(y){var D=this,A=this.hls.levels;if(!A.length)return-1;var S=A.filter(function(g,E){return T.isLevelAllowed(E,D.restrictedLevels)&&E<=y});return this.clientRect=null,T.getMaxLevelByMediaSize(S,this.mediaWidth,this.mediaHeight)},L.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},L.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},L.getDimensions=function(){if(this.clientRect)return this.clientRect;var y=this.media,D={width:0,height:0};if(y){var A=y.getBoundingClientRect();D.width=A.width,D.height=A.height,!D.width&&!D.height&&(D.width=A.right-A.left||y.width||0,D.height=A.bottom-A.top||y.height||0)}return this.clientRect=D,D},T.isLevelAllowed=function(y,D){return D===void 0&&(D=[]),D.indexOf(y)===-1},T.getMaxLevelByMediaSize=function(y,D,A){if(!y||!y.length)return-1;for(var S=function(o,f){return f?o.width!==f.width||o.height!==f.height:!0},g=y.length-1,E=0;E<y.length;E+=1){var a=y[E];if((a.width>=D||a.height>=A)&&S(a,y[E+1])){g=E;break}}return g},x(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 y=1;if(!this.hls.config.ignoreDevicePixelRatio)try{y=self.devicePixelRatio}catch{}return y}}]),T}();P.default=I},"./src/controller/cmcd-controller.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"default",function(){return S});var R=s("./src/events.ts"),p=s("./src/types/cmcd.ts"),x=s("./src/utils/buffer-helper.ts"),I=s("./src/utils/logger.ts");function T(g,E){for(var a=0;a<E.length;a++){var e=E[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(g,e.key,e)}}function L(g,E,a){return E&&T(g.prototype,E),a&&T(g,a),Object.defineProperty(g,"prototype",{writable:!1}),g}function _(g,E){var a=typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(a)return(a=a.call(g)).next.bind(a);if(Array.isArray(g)||(a=y(g))||E&&g&&typeof g.length=="number"){a&&(g=a);var e=0;return function(){return e>=g.length?{done:!0}:{done:!1,value:g[e++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
12
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function y(g,E){if(!!g){if(typeof g=="string")return D(g,E);var a=Object.prototype.toString.call(g).slice(8,-1);if(a==="Object"&&g.constructor&&(a=g.constructor.name),a==="Map"||a==="Set")return Array.from(g);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return D(g,E)}}function D(g,E){(E==null||E>g.length)&&(E=g.length);for(var a=0,e=new Array(E);a<E;a++)e[a]=g[a];return e}function A(){return A=Object.assign?Object.assign.bind():function(g){for(var E=1;E<arguments.length;E++){var a=arguments[E];for(var e in a)Object.prototype.hasOwnProperty.call(a,e)&&(g[e]=a[e])}return g},A.apply(this,arguments)}var S=function(){function g(a){var e=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){e.initialized&&(e.starved=!0),e.buffering=!0},this.onPlaying=function(){e.initialized||(e.initialized=!0),e.buffering=!1},this.applyPlaylistData=function(n){try{e.apply(n,{ot:p.CMCDObjectType.MANIFEST,su:!e.initialized})}catch(i){I.logger.warn("Could not generate manifest CMCD data.",i)}},this.applyFragmentData=function(n){try{var i=n.frag,t=e.hls.levels[i.level],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(n,c)}catch(r){I.logger.warn("Could not generate segment CMCD data.",r)}},this.hls=a;var o=this.config=a.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 E=g.prototype;return E.registerListeners=function(){var e=this.hls;e.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(R.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(R.Events.BUFFER_CREATED,this.onBufferCreated,this)},E.unregisterListeners=function(){var e=this.hls;e.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(R.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(R.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},E.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},E.onMediaAttached=function(e,o){this.media=o.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},E.onMediaDetached=function(){!this.media||(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},E.onBufferCreated=function(e,o){var f,n;this.audioBuffer=(f=o.tracks.audio)===null||f===void 0?void 0:f.buffer,this.videoBuffer=(n=o.tracks.video)===null||n===void 0?void 0:n.buffer},E.createData=function(){var e;return{v:p.CMCDVersion,sf:p.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)===null||e===void 0?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},E.apply=function(e,o){o===void 0&&(o={}),A(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 n=g.toHeaders(o);if(!Object.keys(n).length)return;e.headers||(e.headers={}),A(e.headers,n)}else{var i=g.toQuery(o);if(!i)return;e.url=g.appendQueryToUri(e.url,i)}},E.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},E.getTopBandwidth=function(e){var o=0,f,n=this.hls;if(e===p.CMCDObjectType.AUDIO)f=n.audioTracks;else{var i=n.maxAutoLevel,t=i>-1?i+1:n.levels.length;f=n.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},E.getBufferLength=function(e){var o=this.hls.media,f=e===p.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!f||!o)return NaN;var n=x.BufferHelper.bufferInfo(f,o.currentTime,this.config.maxBufferHole);return n.len*1e3},E.createPlaylistLoader=function(){var e=this.config.pLoader,o=this.applyPlaylistData,f=e||this.config.loader;return function(){function n(t){this.loader=void 0,this.loader=new f(t)}var i=n.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)},L(n,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),n}()},E.createFragmentLoader=function(){var e=this.config.fLoader,o=this.applyFragmentData,f=e||this.config.loader;return function(){function n(t){this.loader=void 0,this.loader=new f(t)}var i=n.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)},L(n,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),n}()},g.uuid=function(){var e=URL.createObjectURL(new Blob),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},n=function(M){return Math.round(M)},i=function(M){return n(M/100)*100},t=function(M){return encodeURIComponent(M)},u={br:n,d:n,bl:i,dl:i,mtp:i,nor:t,rtp:i,tb:n},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,O=void 0;d==="ot"||d==="sf"||d==="st"?O=d+"="+l:m==="boolean"?O=d:m==="number"?O=d+"="+l:O=d+"="+JSON.stringify(l),o.push(O)}}return o.join(",")},g.toHeaders=function(e){for(var o=Object.keys(e),f={},n=["Object","Request","Session","Status"],i=[{},{},{},{}],t={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},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-"+n[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(k,P,s){"use strict";s.r(P);var R=s("./src/events.ts"),p=s("./src/errors.ts"),x=s("./src/utils/logger.ts"),I=s("./src/utils/mediakeys-helper.ts");function T(S,g){for(var E=0;E<g.length;E++){var a=g[E];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(S,a.key,a)}}function L(S,g,E){return g&&T(S.prototype,g),E&&T(S,E),Object.defineProperty(S,"prototype",{writable:!1}),S}var _=3,y=function(g,E,a){var e={audioCapabilities:[],videoCapabilities:[]};return g.forEach(function(o){e.audioCapabilities.push({contentType:'audio/mp4; codecs="'+o+'"',robustness:a.audioRobustness||""})}),E.forEach(function(o){e.videoCapabilities.push({contentType:'video/mp4; codecs="'+o+'"',robustness:a.videoRobustness||""})}),[e]},D=function(g,E,a,e){switch(g){case I.KeySystems.WIDEVINE:return y(E,a,e);default:throw new Error("Unknown key-system: "+g)}},A=function(){function S(E){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=E,this._config=E.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var g=S.prototype;return g.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},g._registerListeners=function(){this.hls.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(R.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this)},g._unregisterListeners=function(){this.hls.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(R.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this)},g.getLicenseServerUrl=function(a){switch(a){case I.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+a+'"')},g._attemptKeySystemAccess=function(a,e,o){var f=this,n=D(a,e,o,this._drmSystemOptions);x.logger.log("Requesting encrypted media key-system access");var i=this.requestMediaKeySystemAccess(a,n);this.mediaKeysPromise=i.then(function(t){return f._onMediaKeySystemAccessObtained(a,t)}),i.catch(function(t){x.logger.error('Failed to obtain key-system "'+a+'" access:',t)})},g._onMediaKeySystemAccessObtained=function(a,e){var o=this;x.logger.log('Access for key-system "'+a+'" obtained');var f={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:e,mediaKeySystemDomain:a};this._mediaKeysList.push(f);var n=Promise.resolve().then(function(){return e.createMediaKeys()}).then(function(i){return f.mediaKeys=i,x.logger.log('Media-keys created for key-system "'+a+'"'),o._onMediaKeysCreated(),i});return n.catch(function(i){x.logger.error("Failed to create media-keys:",i)}),n},g._onMediaKeysCreated=function(){var a=this;this._mediaKeysList.forEach(function(e){e.mediaKeysSession||(e.mediaKeysSession=e.mediaKeys.createSession(),a._onNewMediaKeySession(e.mediaKeysSession))})},g._onNewMediaKeySession=function(a){var e=this;x.logger.log("New key-system session "+a.sessionId),a.addEventListener("message",function(o){e._onKeySessionMessage(a,o.message)},!1)},g._onKeySessionMessage=function(a,e){x.logger.log("Got EME message event, creating license request"),this._requestLicense(e,function(o){x.logger.log("Received license data (length: "+(o&&o.byteLength)+"), updating key-session"),a.update(o).catch(function(f){x.logger.warn("Updating key-session failed: "+f)})})},g.onMediaEncrypted=function(a){var e=this;if(x.logger.log('Media is encrypted using "'+a.initDataType+'" init data type'),!this.mediaKeysPromise){x.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var o=function(n){!e._media||(e._attemptSetMediaKeys(n),e._generateRequestWithPreferredKeySession(a.initDataType,a.initData))};this.mediaKeysPromise.then(o).catch(o)},g._attemptSetMediaKeys=function(a){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var e=this._mediaKeysList[0];if(!e||!e.mediaKeys){x.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}x.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}},g._generateRequestWithPreferredKeySession=function(a,e){var o=this,f=this._mediaKeysList[0];if(!f){x.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){x.logger.warn("Key-Session already initialized but requested again");return}var n=f.mediaKeysSession;if(!n){x.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){x.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}x.logger.log('Generating key-session request for "'+a+'" init data type'),f.mediaKeysSessionInitialized=!0,n.generateRequest(a,e).then(function(){x.logger.debug("Key-session generation succeeded")}).catch(function(i){x.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(a,e,o){var f=new XMLHttpRequest;f.responseType="arraybuffer",f.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,f,a,e,o);var n=this._licenseXhrSetup;if(n)try{n.call(this.hls,f,a),n=void 0}catch(i){x.logger.error(i)}try{f.readyState||f.open("POST",a,!0),n&&n.call(this.hls,f,a)}catch(i){throw new Error("issue setting up KeySystem license XHR "+i)}return f},g._onLicenseRequestReadyStageChange=function(a,e,o,f){switch(a.readyState){case 4:if(a.status===200){this._requestLicenseFailureCount=0,x.logger.log("License request succeeded");var n=a.response,i=this._licenseResponseCallback;if(i)try{n=i.call(this.hls,a,e)}catch(u){x.logger.error(u)}f(n)}else{if(x.logger.error("License Request XHR failed ("+e+"). Status: "+a.status+" ("+a.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;x.logger.warn("Retrying license request, "+t+" attempts left"),this._requestLicense(o,f)}break}},g._generateLicenseRequestChallenge=function(a,e){switch(a.mediaKeySystemDomain){case I.KeySystems.WIDEVINE:return e}throw new Error("unsupported key-system: "+a.mediaKeySystemDomain)},g._requestLicense=function(a,e){x.logger.log("Requesting content license for key-system");var o=this._mediaKeysList[0];if(!o){x.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),n=this._createLicenseXhr(f,a,e);x.logger.log("Sending license request to URL: "+f);var i=this._generateLicenseRequestChallenge(o,a);n.send(i)}catch(t){x.logger.error("Failure requesting DRM license: "+t),this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},g.onMediaAttached=function(a,e){if(!!this._emeEnabled){var o=e.media;this._media=o,o.addEventListener("encrypted",this._onMediaEncrypted)}},g.onMediaDetached=function(){var a=this._media,e=this._mediaKeysList;!a||(a.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(e.map(function(o){if(o.mediaKeysSession)return o.mediaKeysSession.close().catch(function(){})})).then(function(){return a.setMediaKeys(null)}).catch(function(){}))},g.onManifestParsed=function(a,e){if(!!this._emeEnabled){var o=e.levels.map(function(n){return n.audioCodec}).filter(function(n){return!!n}),f=e.levels.map(function(n){return n.videoCodec}).filter(function(n){return!!n});this._attemptKeySystemAccess(I.KeySystems.WIDEVINE,o,f)}},L(S,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),S}();P.default=A},"./src/controller/fps-controller.ts":function(k,P,s){"use strict";s.r(P);var R=s("./src/events.ts"),p=s("./src/utils/logger.ts"),x=function(){function I(L){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=L,this.registerListeners()}var 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(_,y){var D=this.hls.config;if(D.capLevelOnFPSDrop){var A=y.media instanceof self.HTMLVideoElement?y.media:null;this.media=A,A&&typeof A.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),D.fpsDroppedMonitoringPeriod)}},T.checkFPS=function(_,y,D){var A=performance.now();if(y){if(this.lastTime){var S=A-this.lastTime,g=D-this.lastDroppedFrames,E=y-this.lastDecodedFrames,a=1e3*g/S,e=this.hls;if(e.trigger(R.Events.FPS_DROP,{currentDropped:g,currentDecoded:E,totalDroppedFrames:D}),a>0&&g>e.config.fpsDroppedMonitoringThreshold*E){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=A,this.lastDroppedFrames=D,this.lastDecodedFrames=y}},T.checkFPSInterval=function(){var _=this.media;if(_)if(this.isVideoPlaybackQualityAvailable){var y=_.getVideoPlaybackQuality();this.checkFPS(_,y.totalVideoFrames,y.droppedVideoFrames)}else this.checkFPS(_,_.webkitDecodedFrameCount,_.webkitDroppedFrameCount)},I}();P.default=x},"./src/controller/fragment-finders.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"findFragmentByPDT",function(){return x}),s.d(P,"findFragmentByPTS",function(){return I}),s.d(P,"fragmentWithinToleranceTest",function(){return T}),s.d(P,"pdtWithinToleranceTest",function(){return L}),s.d(P,"findFragWithCC",function(){return _});var R=s("./src/polyfills/number.ts"),p=s("./src/utils/binary-search.ts");function x(y,D,A){if(D===null||!Array.isArray(y)||!y.length||!Object(R.isFiniteNumber)(D))return null;var S=y[0].programDateTime;if(D<(S||0))return null;var g=y[y.length-1].endProgramDateTime;if(D>=(g||0))return null;A=A||0;for(var E=0;E<y.length;++E){var a=y[E];if(L(D,A,a))return a}return null}function I(y,D,A,S){A===void 0&&(A=0),S===void 0&&(S=0);var g=null;if(y?g=D[y.sn-D[0].sn+1]||null:A===0&&D[0].start===0&&(g=D[0]),g&&T(A,S,g)===0)return g;var E=p.default.search(D,T.bind(null,A,S));return E||g}function T(y,D,A){y===void 0&&(y=0),D===void 0&&(D=0);var S=Math.min(D,A.duration+(A.deltaPTS?A.deltaPTS:0));return A.start+A.duration-S<=y?1:A.start-S>y&&A.start?-1:0}function L(y,D,A){var S=Math.min(D,A.duration+(A.deltaPTS?A.deltaPTS:0))*1e3,g=A.endProgramDateTime||0;return g-S>y}function _(y,D){return p.default.search(y,function(A){return A.cc<D?1:A.cc>D?-1:0})}},"./src/controller/fragment-tracker.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"FragmentState",function(){return x}),s.d(P,"FragmentTracker",function(){return I});var R=s("./src/events.ts"),p=s("./src/types/loader.ts"),x;(function(_){_.NOT_LOADED="NOT_LOADED",_.APPENDING="APPENDING",_.PARTIAL="PARTIAL",_.OK="OK"})(x||(x={}));var I=function(){function _(D){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=D,this._registerListeners()}var y=_.prototype;return y._registerListeners=function(){var A=this.hls;A.on(R.Events.BUFFER_APPENDED,this.onBufferAppended,this),A.on(R.Events.FRAG_BUFFERED,this.onFragBuffered,this),A.on(R.Events.FRAG_LOADED,this.onFragLoaded,this)},y._unregisterListeners=function(){var A=this.hls;A.off(R.Events.BUFFER_APPENDED,this.onBufferAppended,this),A.off(R.Events.FRAG_BUFFERED,this.onFragBuffered,this),A.off(R.Events.FRAG_LOADED,this.onFragLoaded,this)},y.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},y.getAppendedFrag=function(A,S){if(S===p.PlaylistLevelType.MAIN){var g=this.activeFragment,E=this.activeParts;if(!g)return null;if(E)for(var a=E.length;a--;){var e=E[a],o=e?e.end:g.appendedPTS;if(e.start<=A&&o!==void 0&&A<=o)return a>9&&(this.activeParts=E.slice(a-9)),e}else if(g.start<=A&&g.appendedPTS!==void 0&&A<=g.appendedPTS)return g}return this.getBufferedFrag(A,S)},y.getBufferedFrag=function(A,S){for(var g=this.fragments,E=Object.keys(g),a=E.length;a--;){var e=g[E[a]];if((e==null?void 0:e.body.type)===S&&e.buffered){var o=e.body;if(o.start<=A&&A<=o.end)return o}}return null},y.detectEvictedFragments=function(A,S,g){var E=this;Object.keys(this.fragments).forEach(function(a){var e=E.fragments[a];if(!!e){if(!e.buffered){e.body.type===g&&E.removeFragment(e.body);return}var o=e.range[A];!o||o.time.some(function(f){var n=!E.isTimeBuffered(f.startPTS,f.endPTS,S);return n&&E.removeFragment(e.body),n})}})},y.detectPartialFragments=function(A){var S=this,g=this.timeRanges,E=A.frag,a=A.part;if(!(!g||E.sn==="initSegment")){var e=L(E),o=this.fragments[e];!o||(Object.keys(g).forEach(function(f){var n=E.elementaryStreams[f];if(!!n){var i=g[f],t=a!==null||n.partial===!0;o.range[f]=S.getBufferedTimes(E,a,t,i)}}),o.loaded=null,Object.keys(o.range).length?o.buffered=!0:this.removeFragment(o.body))}},y.fragBuffered=function(A){var S=L(A),g=this.fragments[S];g&&(g.loaded=null,g.buffered=!0)},y.getBufferedTimes=function(A,S,g,E){for(var a={time:[],partial:g},e=S?S.start:A.start,o=S?S.end:A.end,f=A.minEndPTS||o,n=A.maxStartPTS||e,i=0;i<E.length;i++){var t=E.start(i)-this.bufferPadding,u=E.end(i)+this.bufferPadding;if(n>=t&&f<=u){a.time.push({startPTS:Math.max(e,E.start(i)),endPTS:Math.min(o,E.end(i))});break}else if(e<u&&o>t)a.partial=!0,a.time.push({startPTS:Math.max(e,E.start(i)),endPTS:Math.min(o,E.end(i))});else if(o<=t)break}return a},y.getPartialFragment=function(A){var S=null,g,E,a,e=0,o=this.bufferPadding,f=this.fragments;return Object.keys(f).forEach(function(n){var i=f[n];!i||T(i)&&(E=i.body.start-o,a=i.body.end+o,A>=E&&A<=a&&(g=Math.min(A-E,a-A),e<=g&&(S=i.body,e=g)))}),S},y.getState=function(A){var S=L(A),g=this.fragments[S];return g?g.buffered?T(g)?x.PARTIAL:x.OK:x.APPENDING:x.NOT_LOADED},y.isTimeBuffered=function(A,S,g){for(var E,a,e=0;e<g.length;e++){if(E=g.start(e)-this.bufferPadding,a=g.end(e)+this.bufferPadding,A>=E&&S<=a)return!0;if(S<=E)return!1}return!1},y.onFragLoaded=function(A,S){var g=S.frag,E=S.part;if(!(g.sn==="initSegment"||g.bitrateTest||E)){var a=L(g);this.fragments[a]={body:g,loaded:S,buffered:!1,range:Object.create(null)}}},y.onBufferAppended=function(A,S){var g=this,E=S.frag,a=S.part,e=S.timeRanges;if(E.type===p.PlaylistLevelType.MAIN)if(this.activeFragment=E,a){var o=this.activeParts;o||(this.activeParts=o=[]),o.push(a)}else this.activeParts=null;this.timeRanges=e,Object.keys(e).forEach(function(f){var n=e[f];if(g.detectEvictedFragments(f,n),!a)for(var i=0;i<n.length;i++)E.appendedPTS=Math.max(n.end(i),E.appendedPTS||0)})},y.onFragBuffered=function(A,S){this.detectPartialFragments(S)},y.hasFragment=function(A){var S=L(A);return!!this.fragments[S]},y.removeFragmentsInRange=function(A,S,g){var E=this;Object.keys(this.fragments).forEach(function(a){var e=E.fragments[a];if(!!e&&e.buffered){var o=e.body;o.type===g&&o.start<S&&o.end>A&&E.removeFragment(o)}})},y.removeFragment=function(A){var S=L(A);A.stats.loaded=0,A.clearElementaryStreamInfo(),delete this.fragments[S]},y.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},_}();function T(_){var y,D;return _.buffered&&(((y=_.range.video)===null||y===void 0?void 0:y.partial)||((D=_.range.audio)===null||D===void 0?void 0:D.partial))}function L(_){return _.type+"_"+_.level+"_"+_.urlId+"_"+_.sn}},"./src/controller/gap-controller.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"STALL_MINIMUM_DURATION_MS",function(){return T}),s.d(P,"MAX_START_GAP_JUMP",function(){return L}),s.d(P,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return _}),s.d(P,"SKIP_BUFFER_RANGE_START",function(){return y}),s.d(P,"default",function(){return D});var R=s("./src/utils/buffer-helper.ts"),p=s("./src/errors.ts"),x=s("./src/events.ts"),I=s("./src/utils/logger.ts"),T=250,L=2,_=.1,y=.05,D=function(){function A(g,E,a,e){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=g,this.media=E,this.fragmentTracker=a,this.hls=e}var S=A.prototype;return S.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},S.poll=function(E,a){var e=this.config,o=this.media,f=this.stalled;if(o!==null){var n=o.currentTime,i=o.seeking,t=this.seeking&&!i,u=!this.seeking&&i;if(this.seeking=i,n!==E){if(this.moved=!0,f!==null){if(this.stallReported){var c=self.performance.now()-f;I.logger.warn("playback not stuck anymore @"+n+", 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,n,0),h=r.len>0,d=r.nextStart||0;if(!(!h&&!d)){if(i){var l=r.len>L,v=!d||a&&a.start<=n||d-n>L&&!this.fragmentTracker.getPartialFragment(n);if(l||v)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var m,O=Math.max(d,r.start||0)-n,b=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,M=b==null||(m=b.details)===null||m===void 0?void 0:m.live,F=M?b.details.targetduration*2:L;if(O>0&&O<=F){this._trySkipBufferHole(null);return}}var w=self.performance.now();if(f===null){this.stalled=w;return}var C=w-f;if(!(!i&&C>=T&&(this._reportStall(r),!this.media))){var B=R.BufferHelper.bufferInfo(o,n,e.maxBufferHole);this._tryFixBufferStall(B,C)}}}}},S._tryFixBufferStall=function(E,a){var e=this.config,o=this.fragmentTracker,f=this.media;if(f!==null){var n=f.currentTime,i=o.getPartialFragment(n);if(i){var t=this._trySkipBufferHole(i);if(t||!this.media)return}E.len>e.maxBufferHole&&a>e.highBufferWatchdogPeriod*1e3&&(I.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},S._reportStall=function(E){var a=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(E)+")"),a.trigger(x.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:E.len}))},S._trySkipBufferHole=function(E){var a=this.config,e=this.hls,o=this.media;if(o===null)return 0;for(var f=o.currentTime,n=0,i=R.BufferHelper.getBuffered(o),t=0;t<i.length;t++){var u=i.start(t);if(f+a.maxBufferHole>=n&&f<u){var c=Math.max(u+y,o.currentTime+_);return I.logger.warn("skipping hole, adjusting currentTime from "+f+" to "+c),this.moved=!0,this.stalled=null,o.currentTime=c,E&&e.trigger(x.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:E}),c}n=i.end(t)}return 0},S._tryNudgeBuffer=function(){var E=this.config,a=this.hls,e=this.media,o=this.nudgeRetry;if(e!==null){var f=e.currentTime;if(this.nudgeRetry++,o<E.nudgeMaxRetry){var n=f+(o+1)*E.nudgeOffset;I.logger.warn("Nudging 'currentTime' from "+f+" to "+n),e.currentTime=n,a.trigger(x.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 "+E.nudgeMaxRetry+" nudges"),a.trigger(x.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},A}()},"./src/controller/id3-track-controller.ts":function(k,P,s){"use strict";s.r(P);var R=s("./src/polyfills/number.ts"),p=s("./src/events.ts"),x=s("./src/utils/texttrack-utils.ts"),I=s("./src/demux/id3.ts"),T=s("./src/loader/date-range.ts"),L=s("./src/types/demuxer.ts"),_=.25;function y(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}function D(g,E){return g.getTime()/1e3-E}function A(g){return Uint8Array.from(g.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var S=function(){function g(a){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=a,this._registerListeners()}var E=g.prototype;return E.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},E._registerListeners=function(){var e=this.hls;e.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},E._unregisterListeners=function(){var e=this.hls;e.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},E.onMediaAttached=function(e,o){this.media=o.media},E.onMediaDetaching=function(){!this.id3Track||(Object(x.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},E.onManifestLoading=function(){this.dateRangeCuesAppended={}},E.createTrack=function(e){var o=this.getID3Track(e.textTracks);return o.mode="hidden",o},E.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(x.sendAddTrackEvent)(f,this.media),f}return this.media.addTextTrack("metadata","id3")}},E.onFragParsingMetadata=function(e,o){if(!!this.media){var f=this.hls.config,n=f.enableEmsgMetadataCues,i=f.enableID3MetadataCues;if(!(!n&&!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=y(),d=!1,l={},v=0;v<u.length;v++){var m=u[v].type;if(!(m===L.MetadataSchema.emsg&&!n||!i)){var O=I.getID3Frames(u[v].data);if(O){var b=u[v].pts,M=r,F=M-b;F<=0&&(M=b+_);for(var w=0;w<O.length;w++){var C=O[w];if(!I.isTimeStampFrame(C)){var B=new h(b,M,"");B.value=C,m&&(B.type=m),this.id3Track.addCue(B),l[C.key]=null,d=!0}}}}}d&&this.updateId3CueEnds(l)}}},E.updateId3CueEnds=function(e){var o,f=(o=this.id3Track)===null||o===void 0?void 0:o.cues;if(f)for(var n=f.length;n--;){var i,t=f[n],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}}},E.onBufferFlushing=function(e,o){var f=o.startOffset,n=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===L.MetadataSchema.audioId3&&h}:i==="video"?d=function(v){return v.type===L.MetadataSchema.emsg&&r}:d=function(v){return v.type===L.MetadataSchema.audioId3&&h||v.type===L.MetadataSchema.emsg&&r},Object(x.removeCuesInRange)(t,f,n,d)}}},E.onLevelUpdated=function(e,o){var f=this,n=o.details;if(!(!this.media||!n.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var i=this.dateRangeCuesAppended,t=this.id3Track,u=n.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(B){t.removeCue(i[C].cues[B])}),delete i[C]},d=r.length;d--;)h(d);var l=n.fragments[n.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=n.edge||l.end,O=y(),b=function(w){var C=c[w],B=u[C],U=i[C],j=(U==null?void 0:U.cues)||{},N=(U==null?void 0:U.durationKnown)||!1,K=D(B.startDate,v),H=m,V=B.endDate;if(V)H=D(V,v),N=!0;else if(B.endOnNext&&!N){var Y=c.reduce(function(X,le){var ne=u[le];return ne.class===B.class&&ne.id!==le&&ne.startDate>B.startDate&&X.push(ne),X},[]).sort(function(X,le){return X.startDate.getTime()-le.startDate.getTime()})[0];Y&&(H=D(Y.startDate,v),N=!0)}for(var Q=Object.keys(B.attr),J=0;J<Q.length;J++){var z=Q[J];if(!(z===T.DateRangeAttribute.ID||z===T.DateRangeAttribute.CLASS||z===T.DateRangeAttribute.START_DATE||z===T.DateRangeAttribute.DURATION||z===T.DateRangeAttribute.END_DATE||z===T.DateRangeAttribute.END_ON_NEXT)){var q=j[z];if(q)N&&!U.durationKnown&&(q.endTime=H);else{var re=B.attr[z];q=new O(K,H,""),(z===T.DateRangeAttribute.SCTE35_OUT||z===T.DateRangeAttribute.SCTE35_IN)&&(re=A(re)),q.value={key:z,data:re},q.type=L.MetadataSchema.dateRange,f.id3Track.addCue(q),j[z]=q}}}i[C]={cues:j,dateRange:B,durationKnown:N}},M=0;M<c.length;M++)b(M)}}},g}();P.default=S},"./src/controller/latency-controller.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"default",function(){return L});var R=s("./src/errors.ts"),p=s("./src/events.ts"),x=s("./src/utils/logger.ts");function I(_,y){for(var D=0;D<y.length;D++){var A=y[D];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(_,A.key,A)}}function T(_,y,D){return y&&I(_.prototype,y),D&&I(_,D),Object.defineProperty(_,"prototype",{writable:!1}),_}var L=function(){function _(D){var A=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 A.timeupdate()},this.hls=D,this.config=D.config,this.registerListeners()}var y=_.prototype;return y.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},y.registerListeners=function(){this.hls.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(p.Events.ERROR,this.onError,this)},y.unregisterListeners=function(){this.hls.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(p.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(p.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(p.Events.ERROR,this.onError)},y.onMediaAttached=function(A,S){this.media=S.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},y.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},y.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},y.onLevelUpdated=function(A,S){var g=S.details;this.levelDetails=g,g.advanced&&this.timeupdate(),!g.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},y.onError=function(A,S){S.details===R.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,x.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},y.timeupdate=function(){var A=this.media,S=this.levelDetails;if(!(!A||!S)){this.currentTime=A.currentTime;var g=this.computeLatency();if(g!==null){this._latency=g;var E=this.config,a=E.lowLatencyMode,e=E.maxLiveSyncPlaybackRate;if(!(!a||e===1)){var o=this.targetLatency;if(o!==null){var f=g-o,n=Math.min(this.maxLatency,o+S.targetduration),i=f<n;if(S.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;A.playbackRate=Math.min(t,Math.max(1,u))}else A.playbackRate!==1&&A.playbackRate!==0&&(A.playbackRate=1)}}}}},y.estimateLiveEdge=function(){var A=this.levelDetails;return A===null?null:A.edge+A.age},y.computeLatency=function(){var A=this.estimateLiveEdge();return A===null?null:A-this.currentTime},T(_,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var A=this.config,S=this.levelDetails;return A.liveMaxLatencyDuration!==void 0?A.liveMaxLatencyDuration:S?A.liveMaxLatencyDurationCount*S.targetduration:0}},{key:"targetLatency",get:function(){var A=this.levelDetails;if(A===null)return null;var S=A.holdBack,g=A.partHoldBack,E=A.targetduration,a=this.config,e=a.liveSyncDuration,o=a.liveSyncDurationCount,f=a.lowLatencyMode,n=this.hls.userConfig,i=f&&g||S;(n.liveSyncDuration||n.liveSyncDurationCount||i===0)&&(i=e!==void 0?e:o*E);var t=E,u=1;return i+Math.min(this.stallCount*u,t)}},{key:"liveSyncPosition",get:function(){var A=this.estimateLiveEdge(),S=this.targetLatency,g=this.levelDetails;if(A===null||S===null||g===null)return null;var E=g.edge,a=A-S-this.edgeStalled,e=E-g.totalduration,o=E-(this.config.lowLatencyMode&&g.partTarget||g.targetduration);return Math.min(Math.max(e,a),o)}},{key:"drift",get:function(){var A=this.levelDetails;return A===null?1:A.drift}},{key:"edgeStalled",get:function(){var A=this.levelDetails;if(A===null)return 0;var S=(this.config.lowLatencyMode&&A.partTarget||A.targetduration)*3;return Math.max(A.age-S,0)}},{key:"forwardBufferLength",get:function(){var A=this.media,S=this.levelDetails;if(!A||!S)return 0;var g=A.buffered.length;return(g?A.buffered.end(g-1):S.edge)-this.currentTime}}]),_}()},"./src/controller/level-controller.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"default",function(){return a});var R=s("./src/types/level.ts"),p=s("./src/events.ts"),x=s("./src/errors.ts"),I=s("./src/utils/codecs.ts"),T=s("./src/controller/level-helper.ts"),L=s("./src/controller/base-playlist-controller.ts"),_=s("./src/types/loader.ts");function y(){return y=Object.assign?Object.assign.bind():function(e){for(var o=1;o<arguments.length;o++){var f=arguments[o];for(var n in f)Object.prototype.hasOwnProperty.call(f,n)&&(e[n]=f[n])}return e},y.apply(this,arguments)}function D(e,o){for(var f=0;f<o.length;f++){var n=o[f];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function A(e,o,f){return o&&D(e.prototype,o),f&&D(e,f),Object.defineProperty(e,"prototype",{writable:!1}),e}function S(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(n,i){return n.__proto__=i,n},g(e,o)}var E=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),a=function(e){S(o,e);function o(n){var i;return i=e.call(this,n,"[level-controller]")||this,i._levels=[],i._firstLevel=-1,i._startLevel=void 0,i.currentLevelIndex=-1,i.manualLevelIndex=-1,i.onParsedComplete=void 0,i._registerListeners(),i}var 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,O=!1;if(t.levels.forEach(function(w){var C=w.attrs;v=v||!!(w.width&&w.height),m=m||!!w.videoCodec,O=O||!!w.audioCodec,E&&w.audioCodec&&w.audioCodec.indexOf("mp4a.40.34")!==-1&&(w.audioCodec=void 0);var B=w.bitrate+"-"+w.attrs.RESOLUTION+"-"+w.attrs.CODECS;l=d[B],l?l.url.push(w.url):(l=new R.Level(w),d[B]=l,u.push(l)),C&&(C.AUDIO&&Object(T.addGroupId)(l,"audio",C.AUDIO),C.SUBTITLES&&Object(T.addGroupId)(l,"text",C.SUBTITLES))}),(v||m)&&O&&(u=u.filter(function(w){var C=w.videoCodec,B=w.width,U=w.height;return!!C||!!(B&&U)})),u=u.filter(function(w){var C=w.audioCodec,B=w.videoCodec;return(!C||Object(I.isCodecSupportedInMp4)(C,"audio"))&&(!B||Object(I.isCodecSupportedInMp4)(B,"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 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=O&&!m,F={levels:u,audioTracks:c,subtitleTracks:r,firstLevel:this._firstLevel,stats:t.stats,audio:O,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:x.ErrorTypes.MEDIA_ERROR,details:x.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 x.ErrorDetails.FRAG_LOAD_ERROR:case x.ErrorDetails.FRAG_LOAD_TIMEOUT:case x.ErrorDetails.KEY_LOAD_ERROR:case x.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 x.ErrorDetails.LEVEL_LOAD_ERROR:case x.ErrorDetails.LEVEL_LOAD_TIMEOUT:c&&(c.deliveryDirectives&&(d=!1),l=c.level),h=!0;break;case x.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,O=m.length;O--;){var b=(O+this.currentLevelIndex)%m.length;if(b!==this.currentLevelIndex&&m[b].loadError===0){v=b;break}}v>-1&&this.currentLevelIndex!==v&&(this.warn(r+": switch to "+v),i.levelRetry=!0,this.hls.nextAutoLevel=v)}}},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})},A(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:x.ErrorTypes.OTHER_ERROR,details:x.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=y({},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}(L.default)},"./src/controller/level-helper.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"addGroupId",function(){return T}),s.d(P,"assignTrackIdsByGroup",function(){return L}),s.d(P,"updatePTS",function(){return _}),s.d(P,"updateFragPTSDTS",function(){return D}),s.d(P,"mergeDetails",function(){return A}),s.d(P,"mapPartIntersection",function(){return g}),s.d(P,"mapFragmentIntersection",function(){return E}),s.d(P,"adjustSliding",function(){return a}),s.d(P,"addSliding",function(){return e}),s.d(P,"computeReloadInterval",function(){return o}),s.d(P,"getFragmentWithSN",function(){return f}),s.d(P,"getPartWith",function(){return n});var R=s("./src/polyfills/number.ts"),p=s("./src/utils/logger.ts"),x=s("./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 L(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];y(c,r)}function y(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 D(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,O=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,O),c=Math.max(c,O),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,B=i.fragments;for(B[C]=t,w=C;w>0;w--)y(B[w],B[w-1]);for(w=C;w<B.length-1;w++)y(B[w],B[w+1]);return i.fragmentHint&&y(B[B.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,M}function A(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(E(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=S(i.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));var O=t.fragments;if(d){p.logger.warn("discontinuity sliding from playlist, take drift into account");for(var b=0;b<O.length;b++)O[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?D(t,l,l.startPTS,l.endPTS,l.startDTS,l.endDTS):a(i,t),O.length&&(t.totalduration=t.edge-O[0].start),t.driftStartTime=i.driftStartTime,t.driftStart=i.driftStart;var M=t.advancedDateTime;if(t.advanced&&M){var F=t.edge;t.driftStart||(t.driftStartTime=M,t.driftStart=F),t.driftEndTime=M,t.driftEnd=F}else t.driftEndTime=i.driftEndTime,t.driftEnd=i.driftEnd,t.advancedDateTime=i.advancedDateTime}function S(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 x.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 E(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 O=v[d+m],b=l[m];c&&!b&&m<c&&(b=t.fragments[m]=O),O&&b&&u(O,b)}}function a(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 n(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(k,P,s){"use strict";s.r(P),s.d(P,"default",function(){return n});var R=s("./src/polyfills/number.ts"),p=s("./src/controller/base-stream-controller.ts"),x=s("./src/is-supported.ts"),I=s("./src/events.ts"),T=s("./src/utils/buffer-helper.ts"),L=s("./src/controller/fragment-tracker.ts"),_=s("./src/types/loader.ts"),y=s("./src/loader/fragment.ts"),D=s("./src/demux/transmuxer-interface.ts"),A=s("./src/types/transmuxer.ts"),S=s("./src/controller/gap-controller.ts"),g=s("./src/errors.ts");function E(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 a(i,t,u){return t&&E(i.prototype,t),u&&E(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,n=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(),O=this.retryDate;(!O||m>=O||(v=this.media)!==null&&v!==void 0&&v.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=p.State.IDLE)}break;default:break}this.onTickEnd()},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,O=d.config,b=d.nextLoadLevel;if(!(l===null||!m&&(this.startFragRequested||!O.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,B=this.getMaxBufferLength(M.maxBitrate);if(!(C>=B)){if(this._streamEnded(w,F)){var U={};this.altAudio&&(U.type="video"),this.hls.trigger(I.Events.BUFFER_EOS,U),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)!==L.FragmentState.OK){var K,H=((K=this.backtrackFragment)!=null?K:N).sn,V=H-F.startSN,Y=F.fragments[V-1];Y&&N.cc===Y.cc&&(N=Y,this.fragmentTracker.removeFragment(Y))}else this.backtrackFragment&&w.len&&(this.backtrackFragment=null);if(N&&this.fragmentTracker.getState(N)===L.FragmentState.OK&&this.nextLoadPosition>j){var Q=this.audioOnly&&!this.altAudio?y.ElementaryStreamTypes.AUDIO:y.ElementaryStreamTypes.VIDEO;m&&this.afterBufferFlushed(m,Q,_.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===L.FragmentState.NOT_LOADED?r.sn==="initSegment"?this._loadInitSegment(r):this.bitrateTest?(this.log("Fragment "+r.sn+" of level "+r.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(r)):(this.startFragRequested=!0,i.prototype.loadFragment.call(this,r,h,d)):v===L.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],O=this.fragLastKbps;O&&this.fragCurrent?d=this.fragCurrent.duration*m.maxBitrate/(1e3*O)+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 S.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(x.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,O=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:"+O);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 O=m[d.level],b=O.details;if(!b){this.warn("Dropping fragment "+d.sn+" of level "+d.level+" after level details were reset");return}var M=O.videoCodec,F=b.PTSKnown||!b.live,w=(h=d.initSegment)===null||h===void 0?void 0:h.data,C=this._getAudioCodec(O),B=this.transmuxer=this.transmuxer||new D.default(this.hls,_.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),U=l?l.index:-1,j=U!==-1,N=new A.ChunkMetadata(d.level,d.sn,d.stats.chunkCount,v.byteLength,U,j),K=this.initPTS[d.cc];B.push(v,w,C,M,d,l,b.totalduration,F,N,K)},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 O=this.hls;d&&O.trigger(I.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),O.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 O in d){var b=d[O];if(b.id==="main"){if(v=O,l=b,O==="video"){var M=d[O];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||!T.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!==y.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var l=(d===y.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,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,O=this.getCurrentContext(m);if(!O){this.warn("The loading context changed while buffering fragment "+m.sn+" of level "+m.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(m.level);return}var b=O.frag,M=O.part,F=O.level,w=v.video,C=v.text,B=v.id3,U=v.initSegment,j=F.details,N=this.altAudio?void 0:v.audio;if(!this.fragContextChanged(b)){if(this.state=p.State.PARSING,U){U.tracks&&(this._bufferInitSegment(F,U.tracks,b,m),l.trigger(I.Events.FRAG_PARSING_INIT_SEGMENT,{frag:b,id:d,tracks:U.tracks}));var K=U.initPTS,H=U.timescale;Object(R.isFiniteNumber)(K)&&(this.initPTS[b.cc]=K,l.trigger(I.Events.INIT_PTS_FOUND,{frag:b,id:d,initPTS:K,timescale:H}))}if(w&&v.independent!==!1){if(j){var V=w.startPTS,Y=w.endPTS,Q=w.startDTS,J=w.endDTS;if(M)M.elementaryStreams[w.type]={startPTS:V,endPTS:Y,startDTS:Q,endDTS:J};else if(w.firstKeyFrame&&w.independent&&(this.couldBacktrack=!0),w.dropped&&w.independent){var z=this.getMainFwdBufferInfo(),q=(z?z.end:this.getLoadPosition())+this.config.maxBufferHole,re=w.firstKeyFramePTS?w.firstKeyFramePTS:V;if(q<re-this.config.maxBufferHole){this.backtrack(b);return}b.setElementaryStreamInfo(w.type,b.start,Y,b.start,J,!0)}b.setElementaryStreamInfo(w.type,V,Y,Q,J),this.backtrackFragment&&(this.backtrackFragment=b),this.bufferFragmentData(w,b,M,m)}}else if(v.independent===!1){this.backtrack(b);return}if(N){var X=N.startPTS,le=N.endPTS,ne=N.startDTS,te=N.endDTS;M&&(M.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:X,endPTS:le,startDTS:ne,endDTS:te}),b.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,X,le,ne,te),this.bufferFragmentData(N,b,M,m)}if(j&&B!==null&&B!==void 0&&(h=B.samples)!==null&&h!==void 0&&h.length){var ee={id:d,frag:b,details:j,samples:B.samples};l.trigger(I.Events.FRAG_PARSING_METADATA,ee)}if(j&&C){var $={id:d,frag:b,details:j,samples:C.samples};l.trigger(I.Events.FRAG_PARSING_USERDATA,$)}}},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,O=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+"]")}O&&(O.levelCodec=r.videoCodec,O.id="main",this.log("Init video buffer, container:"+O.container+", codecs[level/parsed]=["+(r.videoCodec||"")+"/"+O.codec+"]")),b&&this.log("Init audiovideo buffer, container:"+b.container+", codecs[level/parsed]=["+(r.attrs.CODECS||"")+"/"+b.codec+"]"),this.hls.trigger(I.Events.BUFFER_CODECS,h),Object.keys(h).forEach(function(w){var C=h[w],B=C.initSegment;B!=null&&B.byteLength&&v.hls.trigger(I.Events.BUFFER_APPENDING,{type:w,data:B,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(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)}}},a(t,[{key:"nextLevel",get:function(){var r=this.nextBufferedFrag;return r?r.level:-1}},{key:"currentFrag",get:function(){var r=this.media;return r?this.fragPlaying||this.getAppendedFrag(r.currentTime):null}},{key:"currentProgramDateTime",get:function(){var r=this.media;if(r){var 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(k,P,s){"use strict";s.r(P),s.d(P,"SubtitleStreamController",function(){return e});var R=s("./src/events.ts"),p=s("./src/utils/buffer-helper.ts"),x=s("./src/controller/fragment-finders.ts"),I=s("./src/utils/discontinuities.ts"),T=s("./src/controller/level-helper.ts"),L=s("./src/controller/fragment-tracker.ts"),_=s("./src/controller/base-stream-controller.ts"),y=s("./src/types/loader.ts"),D=s("./src/types/level.ts");function A(f,n){for(var i=0;i<n.length;i++){var t=n[i];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(f,t.key,t)}}function S(f,n,i){return n&&A(f.prototype,n),i&&A(f,i),Object.defineProperty(f,"prototype",{writable:!1}),f}function g(f,n){f.prototype=Object.create(n.prototype),f.prototype.constructor=f,E(f,n)}function E(f,n){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,u){return t.__proto__=u,t},E(f,n)}var a=500,e=function(f){g(n,f);function n(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=n.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(a),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 O=r.start+r.duration;l?l.end=O:(l={start:v,end:O},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,O=h-m;if(O<=0)return;c.endOffsetSubtitles=Math.max(0,O),this.tracksBuffered.forEach(function(b){for(var M=0;M<b.length;){if(b[M].end<=O){b.shift();continue}else if(b[M].start<O)b[M].start=O;else break;M++}}),this.fragmentTracker.removeFragmentsInRange(r,O,y.PlaylistLevelType.SUBTITLE)}},i.onError=function(u,c){var r,h=c.frag;!h||h.type!==y.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 D.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(a)},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 O=this.mainDetails;if(h.deltaUpdateFailed||!O)return;var b=O.fragments[0];if(!m.details)h.hasProgramDateTime&&O.hasProgramDateTime?Object(I.alignMediaPlaylistByPDT)(h,O):b&&Object(T.addSliding)(h,b.start);else{var M=this.alignPlaylists(h,m.details);M===0&&b&&Object(T.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(x.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,O=v.len,b=this.getMaxBufferLength()+h;if(O>b)return;console.assert(r,"Subtitle track details are defined on idle subtitle stream controller tick");var M=r.fragments,F=M.length,w=r.edge,C,B=this.fragPrevious;if(m<w){var U=d.maxFragLookUpTolerance;C=Object(x.findFragmentByPTS)(B,M,Math.max(M[0].start,m),U),!C&&B&&B.start<M[0].start&&(C=M[0])}else C=M[F-1];if(C=this.mapToInitFragWhenRequired(C),!C||this.fragmentTracker.getState(C)!==L.FragmentState.NOT_LOADED)return;C.encrypted?this.loadKey(C,r):this.loadFragment(C,r,m)}},i.loadFragment=function(u,c,r){this.fragCurrent=u,u.sn==="initSegment"?this._loadInitSegment(u):f.prototype.loadFragment.call(this,u,c,r)},S(n,[{key:"mediaBufferTimeRanges",get:function(){return new o(this.tracksBuffered[this.currentTrackId]||[])}}]),n}(_.default),o=function(n){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 n[c][u]};this.buffered={get length(){return n.length},end:function(u){return i("end",u,n.length)},start:function(u){return i("start",u,n.length)}}}},"./src/controller/subtitle-track-controller.ts":function(k,P,s){"use strict";s.r(P);var R=s("./src/events.ts"),p=s("./src/utils/texttrack-utils.ts"),x=s("./src/controller/base-playlist-controller.ts"),I=s("./src/types/loader.ts");function T(S,g){for(var E=0;E<g.length;E++){var a=g[E];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(S,a.key,a)}}function L(S,g,E){return g&&T(S.prototype,g),E&&T(S,E),Object.defineProperty(S,"prototype",{writable:!1}),S}function _(S,g){S.prototype=Object.create(g.prototype),S.prototype.constructor=S,y(S,g)}function y(S,g){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,e){return a.__proto__=e,a},y(S,g)}var D=function(S){_(g,S);function g(a){var e;return e=S.call(this,a,"[subtitle-track-controller]")||this,e.media=null,e.tracks=[],e.groupId=null,e.tracksInGroup=[],e.trackId=-1,e.selectDefaultTrack=!0,e.queuedDefaultTrack=-1,e.trackChangeListener=function(){return e.onTextTracksChanged()},e.asyncPollTrackChange=function(){return e.pollTrackChange(0)},e.useTextTrackPolling=!1,e.subtitlePollingInterval=-1,e._subtitleDisplay=!0,e.registerListeners(),e}var E=g.prototype;return E.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,S.prototype.destroy.call(this)},E.registerListeners=function(){var e=this.hls;e.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(R.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(R.Events.ERROR,this.onError,this)},E.unregisterListeners=function(){var e=this.hls;e.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(R.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(R.Events.ERROR,this.onError,this)},E.onMediaAttached=function(e,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))},E.pollTrackChange=function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)},E.onMediaDetaching=function(){if(!!this.media){self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var e=A(this.media.textTracks);e.forEach(function(o){Object(p.clearCurrentCues)(o)}),this.subtitleTrack=-1,this.media=null}},E.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},E.onManifestParsed=function(e,o){this.tracks=o.subtitleTracks},E.onSubtitleTrackLoaded=function(e,o){var f=o.id,n=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 ["+n.startSN+"-"+n.endSN+"]"),f===this.trackId&&(this.retryCount=0,this.playlistLoaded(f,o,u))},E.onLevelLoading=function(e,o){this.switchLevel(o.level)},E.onLevelSwitching=function(e,o){this.switchLevel(o.level)},E.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 n=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(n==null?void 0:n.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,n)}}},E.findTrackId=function(e){for(var o=this.tracksInGroup,f=0;f<o.length;f++){var n=o[f];if((!this.selectDefaultTrack||n.default)&&(!e||e===n.name))return n.id}return-1},E.onError=function(e,o){S.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)},E.loadPlaylist=function(e){var o=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(o)){var f=o.id,n=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:n,deliveryDirectives:e||null})}},E.toggleTrackModes=function(e){var o=this,f=this.media,n=this.trackId;if(!!f){var i=A(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[n];u&&(u.mode="disabled")}var c=t[e];c&&(c.mode=this.subtitleDisplay?"showing":"hidden")}},E.setSubtitleTrack=function(e,o){var f,n=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),!(this.trackId===e&&(e===-1||(f=n[e])!==null&&f!==void 0&&f.details)||e<-1||e>=n.length)){this.clearTimer();var i=n[e];if(this.log("Switching to subtitle track "+e),this.trackId=e,i){var t=i.id,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})}},E.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!(!this.media||!this.hls.config.renderTextTracksNatively)){for(var e=-1,o=A(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)}},L(g,[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1;var o=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,o)}}]),g}(x.default);function A(S){for(var g=[],E=0;E<S.length;E++){var a=S[E];a.kind==="subtitles"&&a.label&&g.push(S[E])}return g}P.default=D},"./src/controller/timeline-controller.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"TimelineController",function(){return S});var R=s("./src/polyfills/number.ts"),p=s("./src/events.ts"),x=s("./src/utils/cea-608-parser.ts"),I=s("./src/utils/output-filter.ts"),T=s("./src/utils/webvtt-parser.ts"),L=s("./src/utils/texttrack-utils.ts"),_=s("./src/utils/imsc1-ttml-parser.ts"),y=s("./src/utils/mp4-tools.ts"),D=s("./src/types/loader.ts"),A=s("./src/utils/logger.ts"),S=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=a(),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 n=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 x.default(1,n,i),this.cea608Parser2=new x.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 n=this.hls;n.off(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),n.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),n.off(p.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),n.off(p.Events.FRAG_LOADING,this.onFragLoading,this),n.off(p.Events.FRAG_LOADED,this.onFragLoaded,this),n.off(p.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),n.off(p.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),n.off(p.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.off(p.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),n.off(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},o.addCues=function(n,i,t,u,c){for(var r=!1,h=c.length;h--;){var d=c[h],l=E(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[n];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:n})}},o.onInitPtsFound=function(n,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(n){var i=this.media;if(i)for(var t=0;t<i.textTracks.length;t++){var u=i.textTracks[t];if(u[n])return u}return null},o.createCaptionsTrack=function(n){this.config.renderTextTracksNatively?this.createNativeTrack(n):this.createNonNativeTrack(n)},o.createNativeTrack=function(n){if(!this.captionsTracks[n]){var i=this.captionsProperties,t=this.captionsTracks,u=this.media,c=i[n],r=c.label,h=c.languageCode,d=this.getExistingTrack(n);if(d)t[n]=d,Object(L.clearCurrentCues)(t[n]),Object(L.sendAddTrackEvent)(t[n],u);else{var l=this.createTextTrack("captions",r,h);l&&(l[n]=!0,t[n]=l)}}},o.createNonNativeTrack=function(n){if(!this.nonNativeCaptionsTracks[n]){var i=this.captionsProperties[n];if(!!i){var t=i.label,u={_id:n,label:t,kind:"captions",default:i.media?!!i.media.default:!1,closedCaptions:i.media};this.nonNativeCaptionsTracks[n]=u,this.hls.trigger(p.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[u]})}}},o.createTextTrack=function(n,i,t){var u=this.media;if(!!u)return u.addTextTrack(n,i,t)},o.onMediaAttaching=function(n,i){this.media=i.media,this._cleanTracks()},o.onMediaDetaching=function(){var n=this.captionsTracks;Object.keys(n).forEach(function(i){Object(L.clearCurrentCues)(n[i]),delete n[i]}),this.nonNativeCaptionsTracks={}},o.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=a(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},o._cleanTracks=function(){var n=this.media;if(!!n){var i=n.textTracks;if(i)for(var t=0;t<i.length;t++)Object(L.clearCurrentCues)(i[t])}},o.onSubtitleTracksUpdated=function(n,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 O=null,b=0;b<h.length;b++)if(g(h[b],l)){O=h[b];break}O&&(m=O)}if(m)Object(L.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(n){var i;if((i=n.attrs)!==null&&i!==void 0&&i.CHARACTERISTICS){var t=/transcribes-spoken-dialog/gi.test(n.attrs.CHARACTERISTICS),u=/describes-music-and-sound/gi.test(n.attrs.CHARACTERISTICS);if(t&&u)return"captions"}return"subtitles"},o.onManifestLoaded=function(n,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(n,i){var t=this.cea608Parser1,u=this.cea608Parser2,c=this.lastSn,r=this.lastPartIndex;if(!(!this.enabled||!(t&&u))&&i.frag.type===D.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(n,i){var t=i.frag,u=i.payload,c=this.initPTS,r=this.unparsedVttFrags;if(t.type===D.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(n,i){var t=this,u=this.hls;Object(_.parseIMSC1)(i,this.initPTS[n.cc],this.timescale[n.cc],function(c){t._appendCues(c,n.level),u.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:n})},function(c){A.logger.log("Failed to parse IMSC1: "+c),u.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:c})})},o._parseVTTs=function(n,i,t){var u,c=this,r=this.hls,h=(u=n.initSegment)!==null&&u!==void 0&&u.data?Object(y.appendUint8Array)(n.initSegment.data,new Uint8Array(i)):i;Object(T.parseWebVTT)(h,this.initPTS[n.cc],this.timescale[n.cc],t,n.cc,n.start,function(d){c._appendCues(d,n.level),r.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:n})},function(d){c._fallbackToIMSC1(n,i),A.logger.log("Failed to parse VTT cue: "+d),r.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:d})})},o._fallbackToIMSC1=function(n,i){var t=this,u=this.tracks[n.level];u.textCodec||Object(_.parseIMSC1)(i,this.initPTS[n.cc],this.timescale[n.cc],function(){u.textCodec=_.IMSC1_CODEC,t._parseIMSC1(n,i)},function(){u.textCodec="wvtt"})},o._appendCues=function(n,i){var t=this.hls;if(this.config.renderTextTracksNatively){var u=this.textTracks[i];if(!u||u.mode==="disabled")return;n.forEach(function(h){return Object(L.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:n,track:r})}},o.onFragDecrypted=function(n,i){var t=i.frag;if(t.type===D.PlaylistLevelType.SUBTITLE){if(!Object(R.isFiniteNumber)(this.initPTS[t.cc])){this.unparsedVttFrags.push(i);return}this.onFragLoaded(p.Events.FRAG_LOADED,i)}},o.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},o.onFragParsingUserdata=function(n,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(n,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(L.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(L.removeCuesInRange)(l[v],t,c)})}}},o.extractCea608Data=function(n){for(var i=[[],[]],t=n[0]&31,u=2,c=0;c<t;c++){var r=n[u++],h=127&n[u++],d=127&n[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 E(e,o,f,n){return Math.min(o,n)-Math.max(e,f)}function a(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}},"./src/crypt/aes-crypto.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"default",function(){return R});var R=function(){function p(I,T){this.subtle=void 0,this.aesIV=void 0,this.subtle=I,this.aesIV=T}var x=p.prototype;return x.decrypt=function(T,L){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},L,T)},p}()},"./src/crypt/aes-decryptor.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"removePadding",function(){return p}),s.d(P,"default",function(){return x});var R=s("./src/utils/typed-array.ts");function p(I){var T=I.byteLength,L=T&&new DataView(I.buffer).getUint8(T-1);return L?Object(R.sliceUint8)(I,0,T-L):I}var x=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 y=new DataView(_),D=new Uint32Array(4),A=0;A<4;A++)D[A]=y.getUint32(A*4);return D},T.initTable=function(){var _=this.sBox,y=this.invSBox,D=this.subMix,A=D[0],S=D[1],g=D[2],E=D[3],a=this.invSubMix,e=a[0],o=a[1],f=a[2],n=a[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,y[r]=t;var h=i[t],d=i[h],l=i[d],v=i[r]*257^r*16843008;A[t]=v<<24|v>>>8,S[t]=v<<16|v>>>16,g[t]=v<<8|v>>>24,E[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,n[r]=v,t?(t=h^i[i[i[l^h]]],u^=i[i[u]]):t=u=1}},T.expandKey=function(_){for(var y=this.uint8ArrayToUint32Array_(_),D=!0,A=0;A<y.length&&D;)D=y[A]===this.key[A],A++;if(!D){this.key=y;var S=this.keySize=y.length;if(S!==4&&S!==6&&S!==8)throw new Error("Invalid aes key size="+S);var g=this.ksRows=(S+6+1)*4,E,a,e=this.keySchedule=new Uint32Array(g),o=this.invKeySchedule=new Uint32Array(g),f=this.sBox,n=this.rcon,i=this.invSubMix,t=i[0],u=i[1],c=i[2],r=i[3],h,d;for(E=0;E<g;E++){if(E<S){h=e[E]=y[E];continue}d=h,E%S===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^=n[E/S|0]<<24):S>6&&E%S===4&&(d=f[d>>>24]<<24|f[d>>>16&255]<<16|f[d>>>8&255]<<8|f[d&255]),e[E]=h=(e[E-S]^d)>>>0}for(a=0;a<g;a++)E=g-a,a&3?d=e[E]:d=e[E-4],a<4||E<=4?o[a]=d:o[a]=t[f[d>>>24]]^u[f[d>>>16&255]]^c[f[d>>>8&255]]^r[f[d&255]],o[a]=o[a]>>>0}},T.networkToHostOrderSwap=function(_){return _<<24|(_&65280)<<8|(_&16711680)>>8|_>>>24},T.decrypt=function(_,y,D){for(var A=this.keySize+6,S=this.invKeySchedule,g=this.invSBox,E=this.invSubMix,a=E[0],e=E[1],o=E[2],f=E[3],n=this.uint8ArrayToUint32Array_(D),i=n[0],t=n[1],u=n[2],c=n[3],r=new Int32Array(_),h=new Int32Array(r.length),d,l,v,m,O,b,M,F,w,C,B,U,j,N,K=this.networkToHostOrderSwap;y<r.length;){for(w=K(r[y]),C=K(r[y+1]),B=K(r[y+2]),U=K(r[y+3]),O=w^S[0],b=U^S[1],M=B^S[2],F=C^S[3],j=4,N=1;N<A;N++)d=a[O>>>24]^e[b>>16&255]^o[M>>8&255]^f[F&255]^S[j],l=a[b>>>24]^e[M>>16&255]^o[F>>8&255]^f[O&255]^S[j+1],v=a[M>>>24]^e[F>>16&255]^o[O>>8&255]^f[b&255]^S[j+2],m=a[F>>>24]^e[O>>16&255]^o[b>>8&255]^f[M&255]^S[j+3],O=d,b=l,M=v,F=m,j=j+4;d=g[O>>>24]<<24^g[b>>16&255]<<16^g[M>>8&255]<<8^g[F&255]^S[j],l=g[b>>>24]<<24^g[M>>16&255]<<16^g[F>>8&255]<<8^g[O&255]^S[j+1],v=g[M>>>24]<<24^g[F>>16&255]<<16^g[O>>8&255]<<8^g[b&255]^S[j+2],m=g[F>>>24]<<24^g[O>>16&255]<<16^g[b>>8&255]<<8^g[M&255]^S[j+3],h[y]=K(d^i),h[y+1]=K(m^t),h[y+2]=K(v^u),h[y+3]=K(l^c),i=w,t=C,u=B,c=U,y=y+4}return h.buffer},I}()},"./src/crypt/decrypter.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"default",function(){return y});var R=s("./src/crypt/aes-crypto.ts"),p=s("./src/crypt/fast-aes-key.ts"),x=s("./src/crypt/aes-decryptor.ts"),I=s("./src/utils/logger.ts"),T=s("./src/utils/mp4-tools.ts"),L=s("./src/utils/typed-array.ts"),_=16,y=function(){function D(S,g,E){var a=E===void 0?{}:E,e=a.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=S,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 A=D.prototype;return A.destroy=function(){this.observer=null},A.isSync=function(){return this.config.enableSoftwareAES},A.flush=function(){var g=this.currentResult;if(!g){this.reset();return}var E=new Uint8Array(g);return this.reset(),this.removePKCS7Padding?Object(x.removePadding)(E):E},A.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},A.decrypt=function(g,E,a,e){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(g),E,a);var o=this.flush();o&&e(o.buffer)}else this.webCryptoDecrypt(new Uint8Array(g),E,a).then(e)},A.softwareDecrypt=function(g,E,a){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 n=this.getValidChunk(g);if(!n.length)return null;e&&(a=e);var i=this.softwareDecrypter;i||(i=this.softwareDecrypter=new x.default),i.expandKey(E);var t=o;return this.currentResult=i.decrypt(n.buffer,0,a),this.currentIV=Object(L.sliceUint8)(n,-16).buffer,t||null},A.webCryptoDecrypt=function(g,E,a){var e=this,o=this.subtle;return(this.key!==E||!this.fastAesKey)&&(this.key=E,this.fastAesKey=new p.default(o,E)),this.fastAesKey.expandKey().then(function(f){if(!o)return Promise.reject(new Error("web crypto not initialized"));var n=new R.default(o,a);return n.decrypt(g.buffer,f)}).catch(function(f){return e.onWebCryptoError(f,g,E,a)})},A.onWebCryptoError=function(g,E,a,e){return I.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",g),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(E,a,e)},A.getValidChunk=function(g){var E=g,a=g.length-g.length%_;return a!==g.length&&(E=Object(L.sliceUint8)(g,0,a),this.remainderData=Object(L.sliceUint8)(g,a)),E},A.logOnce=function(g){!this.logEnabled||(I.logger.log("[decrypter.ts]: "+g),this.logEnabled=!1)},D}()},"./src/crypt/fast-aes-key.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"default",function(){return R});var R=function(){function p(I,T){this.subtle=void 0,this.key=void 0,this.subtle=I,this.key=T}var x=p.prototype;return x.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},p}()},"./src/demux/aacdemuxer.ts":function(k,P,s){"use strict";s.r(P);var R=s("./src/demux/base-audio-demuxer.ts"),p=s("./src/demux/adts.ts"),x=s("./src/utils/logger.ts"),I=s("./src/demux/id3.ts");function T(y,D){y.prototype=Object.create(D.prototype),y.prototype.constructor=y,L(y,D)}function L(y,D){return L=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(S,g){return S.__proto__=g,S},L(y,D)}var _=function(y){T(D,y);function D(S,g){var E;return E=y.call(this)||this,E.observer=void 0,E.config=void 0,E.observer=S,E.config=g,E}var A=D.prototype;return A.resetInitSegment=function(g,E,a,e){y.prototype.resetInitSegment.call(this,g,E,a,e),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:E,duration:e,inputTimeScale:9e4,dropped:0}},D.probe=function(g){if(!g)return!1;for(var E=I.getID3Data(g,0)||[],a=E.length,e=g.length;a<e;a++)if(p.probe(g,a))return x.logger.log("ADTS sync word found !"),!0;return!1},A.canParse=function(g,E){return p.canParse(g,E)},A.appendFrame=function(g,E,a){p.initTrackConfig(g,this.observer,E,a,g.manifestCodec);var e=p.appendFrame(g,E,a,this.basePTS,this.frameIndex);if(e&&e.missing===0)return e},D}(R.default);P.default=_},"./src/demux/adts.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"getAudioConfig",function(){return I}),s.d(P,"isHeaderPattern",function(){return T}),s.d(P,"getHeaderLength",function(){return L}),s.d(P,"getFullFrameLength",function(){return _}),s.d(P,"canGetFrameLength",function(){return y}),s.d(P,"isHeader",function(){return D}),s.d(P,"canParse",function(){return A}),s.d(P,"probe",function(){return S}),s.d(P,"initTrackConfig",function(){return g}),s.d(P,"getFrameDuration",function(){return E}),s.d(P,"parseFrameHeader",function(){return a}),s.d(P,"appendFrame",function(){return e});var R=s("./src/utils/logger.ts"),p=s("./src/errors.ts"),x=s("./src/events.ts");function I(o,f,n,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[n+2]&192)>>>6)+1;var v=(f[n+2]&60)>>>2;if(v>l.length-1){o.trigger(x.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[n+2]&1)<<2,c|=(f[n+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 L(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 y(o,f){return f+5<o.length}function D(o,f){return f+1<o.length&&T(o,f)}function A(o,f){return y(o,f)&&T(o,f)&&_(o,f)<=o.length-f}function S(o,f){if(D(o,f)){var n=L(o,f);if(f+n>=o.length)return!1;var i=_(o,f);if(i<=n)return!1;var t=f+i;return t===o.length||D(o,t)}return!1}function g(o,f,n,i,t){if(!o.samplerate){var u=I(f,n,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 E(o){return 1024*9e4/o}function a(o,f){var n=L(o,f);if(f+n<=o.length){var i=_(o,f)-n;if(i>0)return{headerLength:n,frameLength:i}}}function e(o,f,n,i,t){var u=E(o.samplerate),c=i+t*u,r=a(f,n),h;if(r){var d=r.frameLength,l=r.headerLength,v=l+d,m=Math.max(0,n+v-f.length);m?(h=new Uint8Array(v-l),h.set(f.subarray(n+l,f.length),0)):h=f.subarray(n+l,n+v);var O={unit:h,pts:c};return m||o.samples.push(O),{sample:O,length:v,missing:m}}var b=f.length-n;h=new Uint8Array(b),h.set(f.subarray(n,f.length),0);var M={unit:h,pts:c};return{sample:M,length:b,missing:-1}}},"./src/demux/base-audio-demuxer.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"initPTSFn",function(){return y});var R=s("./src/polyfills/number.ts"),p=s("./src/demux/id3.ts"),x=s("./src/types/demuxer.ts"),I=s("./src/demux/dummy-demuxed-track.ts"),T=s("./src/utils/mp4-tools.ts"),L=s("./src/utils/typed-array.ts"),_=function(){function D(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null}var A=D.prototype;return A.resetInitSegment=function(g,E,a,e){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},A.resetTimeStamp=function(g){this.initPTS=g,this.resetContiguity()},A.resetContiguity=function(){this.basePTS=null,this.frameIndex=0},A.canParse=function(g,E){return!1},A.appendFrame=function(g,E,a){},A.demux=function(g,E){this.cachedData&&(g=Object(T.appendUint8Array)(this.cachedData,g),this.cachedData=null);var a=p.getID3Data(g,0),e=a?a.length:0,o,f,n=this._audioTrack,i=this._id3Track,t=a?p.getTimeStamp(a):void 0,u=g.length;for((this.basePTS===null||this.frameIndex===0&&Object(R.isFiniteNumber)(t))&&(this.basePTS=y(t,E,this.initPTS)),a&&a.length>0&&i.samples.push({pts:this.basePTS,dts:this.basePTS,data:a,type:x.MetadataSchema.audioId3}),f=this.basePTS;e<u;){if(this.canParse(g,e)){var c=this.appendFrame(n,g,e);c?(this.frameIndex++,f=c.sample.pts,e+=c.length,o=e):e=u}else p.canParse(g,e)?(a=p.getID3Data(g,e),i.samples.push({pts:f,dts:f,data:a,type:x.MetadataSchema.audioId3}),e+=a.length,o=e):e++;if(e===u&&o!==u){var r=Object(L.sliceUint8)(g,o);this.cachedData?this.cachedData=Object(T.appendUint8Array)(this.cachedData,r):this.cachedData=r}}return{audioTrack:n,videoTrack:Object(I.dummyTrack)(),id3Track:i,textTrack:Object(I.dummyTrack)()}},A.demuxSampleAes=function(g,E,a){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},A.flush=function(g){var E=this.cachedData;return E&&(this.cachedData=null,this.demux(E,0)),{audioTrack:this._audioTrack,videoTrack:Object(I.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(I.dummyTrack)()}},A.destroy=function(){},D}(),y=function(A,S,g){return Object(R.isFiniteNumber)(A)?A*90:S*9e4+(g||0)};P.default=_},"./src/demux/chunk-cache.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"default",function(){return R});var R=function(){function x(){this.chunks=[],this.dataLength=0}var I=x.prototype;return I.push=function(L){this.chunks.push(L),this.dataLength+=L.length},I.flush=function(){var L=this.chunks,_=this.dataLength,y;if(L.length)L.length===1?y=L[0]:y=p(L,_);else return new Uint8Array(0);return this.reset(),y},I.reset=function(){this.chunks.length=0,this.dataLength=0},x}();function p(x,I){for(var T=new Uint8Array(I),L=0,_=0;_<x.length;_++){var y=x[_];T.set(y,L),L+=y.length}return T}},"./src/demux/dummy-demuxed-track.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"dummyTrack",function(){return R});function R(p,x){return p===void 0&&(p=""),x===void 0&&(x=9e4),{type:p,id:-1,pid:-1,inputTimeScale:x,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(k,P,s){"use strict";s.r(P);var R=s("./src/utils/logger.ts"),p=function(){function x(T){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=T,this.bytesAvailable=T.byteLength,this.word=0,this.bitsAvailable=0}var I=x.prototype;return I.loadWord=function(){var L=this.data,_=this.bytesAvailable,y=L.byteLength-_,D=new Uint8Array(4),A=Math.min(4,_);if(A===0)throw new Error("no bytes available");D.set(L.subarray(y,y+A)),this.word=new DataView(D.buffer).getUint32(0),this.bitsAvailable=A*8,this.bytesAvailable-=A},I.skipBits=function(L){var _;this.bitsAvailable>L?(this.word<<=L,this.bitsAvailable-=L):(L-=this.bitsAvailable,_=L>>3,L-=_>>3,this.bytesAvailable-=_,this.loadWord(),this.word<<=L,this.bitsAvailable-=L)},I.readBits=function(L){var _=Math.min(this.bitsAvailable,L),y=this.word>>>32-_;return L>32&&R.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=_,this.bitsAvailable>0?this.word<<=_:this.bytesAvailable>0&&this.loadWord(),_=L-_,_>0&&this.bitsAvailable?y<<_|this.readBits(_):y},I.skipLZ=function(){var L;for(L=0;L<this.bitsAvailable;++L)if((this.word&2147483648>>>L)!==0)return this.word<<=L,this.bitsAvailable-=L,L;return this.loadWord(),L+this.skipLZ()},I.skipUEG=function(){this.skipBits(1+this.skipLZ())},I.skipEG=function(){this.skipBits(1+this.skipLZ())},I.readUEG=function(){var L=this.skipLZ();return this.readBits(L+1)-1},I.readEG=function(){var L=this.readUEG();return 1&L?1+L>>>1:-1*(L>>>1)},I.readBoolean=function(){return this.readBits(1)===1},I.readUByte=function(){return this.readBits(8)},I.readUShort=function(){return this.readBits(16)},I.readUInt=function(){return this.readBits(32)},I.skipScalingList=function(L){for(var _=8,y=8,D,A=0;A<L;A++)y!==0&&(D=this.readEG(),y=(_+D+256)%256),_=y===0?_:y},I.readSPS=function(){var L=0,_=0,y=0,D=0,A,S,g,E=this.readUByte.bind(this),a=this.readBits.bind(this),e=this.readUEG.bind(this),o=this.readBoolean.bind(this),f=this.skipBits.bind(this),n=this.skipEG.bind(this),i=this.skipUEG.bind(this),t=this.skipScalingList.bind(this);E();var u=E();if(a(5),f(3),E(),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(S=c!==3?8:12,g=0;g<S;g++)o()&&(g<6?t(16):t(64))}i();var r=e();if(r===0)e();else if(r===1)for(f(1),n(),n(),A=e(),g=0;g<A;g++)n();i(),f(1);var h=e(),d=e(),l=a(1);l===0&&f(1),f(1),o()&&(L=e(),_=e(),y=e(),D=e());var v=[1,1];if(o()&&o()){var m=E();switch(m){case 1:v=[1,1];break;case 2:v=[12,11];break;case 3:v=[10,11];break;case 4:v=[16,11];break;case 5:v=[40,33];break;case 6:v=[24,11];break;case 7:v=[20,11];break;case 8:v=[32,11];break;case 9:v=[80,33];break;case 10:v=[18,11];break;case 11:v=[15,11];break;case 12:v=[64,33];break;case 13:v=[160,99];break;case 14:v=[4,3];break;case 15:v=[3,2];break;case 16:v=[2,1];break;case 255:{v=[E()<<8|E(),E()<<8|E()];break}}}return{width:Math.ceil((h+1)*16-L*2-_*2),height:(2-l)*(d+1)*16-(l?2:4)*(y+D),pixelRatio:v}},I.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},x}();P.default=p},"./src/demux/id3.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"isHeader",function(){return R}),s.d(P,"isFooter",function(){return p}),s.d(P,"getID3Data",function(){return x}),s.d(P,"canParse",function(){return T}),s.d(P,"getTimeStamp",function(){return L}),s.d(P,"isTimeStampFrame",function(){return _}),s.d(P,"getID3Frames",function(){return D}),s.d(P,"decodeFrame",function(){return A}),s.d(P,"utf8ArrayToStr",function(){return e}),s.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},x=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},T=function(t,u){return R(t,u)&&I(t,u+6)+10<=t.length-u},L=function(t){for(var u=D(t),c=0;c<u.length;c++){var r=u[c];if(_(r))return a(r)}},_=function(t){return t&&t.key==="PRIV"&&t.info==="com.apple.streaming.transportStreamTimestamp"},y=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)}},D=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=y(t.subarray(u)),l=A(d);l&&c.push(l),u+=d.size+10}p(t,u)&&(u+=10)}return c},A=function(t){return t.type==="PRIV"?S(t):t.type[0]==="W"?E(t):g(t)},S=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}}},E=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}},a=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=n();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,O="",b=0;b<d;){if(l=t[b++],l===0&&u)return O;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:O+=String.fromCharCode(l);break;case 12:case 13:v=t[b++],O+=String.fromCharCode((l&31)<<6|v&63);break;case 14:v=t[b++],m=t[b++],O+=String.fromCharCode((l&15)<<12|(v&63)<<6|(m&63)<<0);break;default:}}return O},o={decodeTextFrame:g},f;function n(){return!f&&typeof self.TextDecoder!="undefined"&&(f=new self.TextDecoder("utf-8")),f}},"./src/demux/mp3demuxer.ts":function(k,P,s){"use strict";s.r(P);var R=s("./src/demux/base-audio-demuxer.ts"),p=s("./src/demux/id3.ts"),x=s("./src/utils/logger.ts"),I=s("./src/demux/mpegaudio.ts");function T(y,D){y.prototype=Object.create(D.prototype),y.prototype.constructor=y,L(y,D)}function L(y,D){return L=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(S,g){return S.__proto__=g,S},L(y,D)}var _=function(y){T(D,y);function D(){return y.apply(this,arguments)||this}var A=D.prototype;return A.resetInitSegment=function(g,E,a,e){y.prototype.resetInitSegment.call(this,g,E,a,e),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:E,duration:e,inputTimeScale:9e4,dropped:0}},D.probe=function(g){if(!g)return!1;for(var E=p.getID3Data(g,0)||[],a=E.length,e=g.length;a<e;a++)if(I.probe(g,a))return x.logger.log("MPEG Audio sync word found !"),!0;return!1},A.canParse=function(g,E){return I.canParse(g,E)},A.appendFrame=function(g,E,a){if(this.basePTS!==null)return I.appendFrame(g,E,a,this.basePTS,this.frameIndex)},D}(R.default);P.default=_},"./src/demux/mp4demuxer.ts":function(k,P,s){"use strict";s.r(P);var R=s("./src/polyfills/number.ts"),p=s("./src/types/demuxer.ts"),x=s("./src/utils/mp4-tools.ts"),I=s("./src/demux/dummy-demuxed-track.ts"),T=/\/emsg[-/]ID3/i,L=function(){function _(D,A){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=A}var y=_.prototype;return y.resetTimeStamp=function(){},y.resetInitSegment=function(A,S,g,E){var a=Object(x.parseInitSegment)(A),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,a.video){var n=a.video,i=n.id,t=n.timescale,u=n.codec;e.id=i,e.timescale=f.timescale=t,e.codec=u}if(a.audio){var c=a.audio,r=c.id,h=c.timescale,d=c.codec;o.id=r,o.timescale=h,o.codec=d}f.id=x.RemuxerTrackIdConfig.text,e.sampleDuration=0,e.duration=o.duration=E},y.resetContiguity=function(){},_.probe=function(A){return A=A.length>16384?A.subarray(0,16384):A,Object(x.findBox)(A,["moof"]).length>0},y.demux=function(A,S){this.timeOffset=S;var g=A,E=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(g=Object(x.appendUint8Array)(this.remainderData,A));var e=Object(x.segmentValidRange)(g);this.remainderData=e.remainder,E.samples=e.valid||new Uint8Array}else E.samples=g;var o=this.extractID3Track(E,S);return a.samples=Object(x.parseSamples)(S,E),{videoTrack:E,audioTrack:this.audioTrack,id3Track:o,textTrack:this.txtTrack}},y.flush=function(){var A=this.timeOffset,S=this.videoTrack,g=this.txtTrack;S.samples=this.remainderData||new Uint8Array,this.remainderData=null;var E=this.extractID3Track(S,this.timeOffset);return g.samples=Object(x.parseSamples)(A,S),{videoTrack:S,audioTrack:Object(I.dummyTrack)(),id3Track:E,textTrack:Object(I.dummyTrack)()}},y.extractID3Track=function(A,S){var g=this.id3Track;if(A.samples.length){var E=Object(x.findBox)(A.samples,["emsg"]);E&&E.forEach(function(a){var e=Object(x.parseEmsg)(a);if(T.test(e.schemeIdUri)){var o=Object(R.isFiniteNumber)(e.presentationTime)?e.presentationTime/e.timeScale:S+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},y.demuxSampleAes=function(A,S,g){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},y.destroy=function(){},_}();P.default=L},"./src/demux/mpegaudio.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"appendFrame",function(){return L}),s.d(P,"parseHeader",function(){return _}),s.d(P,"isHeaderPattern",function(){return y}),s.d(P,"isHeader",function(){return D}),s.d(P,"canParse",function(){return A}),s.d(P,"probe",function(){return S});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],x=[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 L(g,E,a,e,o){if(!(a+24>E.length)){var f=_(E,a);if(f&&a+f.frameLength<=E.length){var n=f.samplesPerFrame*9e4/f.sampleRate,i=e+o*n,t={unit:E.subarray(a,a+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,E){var a=g[E+1]>>3&3,e=g[E+1]>>1&3,o=g[E+2]>>4&15,f=g[E+2]>>2&3;if(a!==1&&o!==0&&o!==15&&f!==3){var n=g[E+2]>>1&1,i=g[E+3]>>6,t=a===3?3-e:e===3?3:4,u=p[t*14+o-1]*1e3,c=a===3?0:a===2?1:2,r=x[c*3+f],h=i===3?1:2,d=I[a][e],l=T[e],v=d*8*l,m=Math.floor(d*u/r+n)*l;if(R===null){var O=navigator.userAgent||"",b=O.match(/Chrome\/(\d+)/i);R=b?parseInt(b[1]):0}var M=!!R&&R<=87;return M&&e===2&&u>=224e3&&i===0&&(g[E+3]=g[E+3]|128),{sampleRate:r,channelCount:h,frameLength:m,samplesPerFrame:v}}}function y(g,E){return g[E]===255&&(g[E+1]&224)===224&&(g[E+1]&6)!==0}function D(g,E){return E+1<g.length&&y(g,E)}function A(g,E){var a=4;return y(g,E)&&a<=g.length-E}function S(g,E){if(E+1<g.length&&y(g,E)){var a=4,e=_(g,E),o=a;e!=null&&e.frameLength&&(o=e.frameLength);var f=E+o;return f===g.length||D(g,f)}return!1}},"./src/demux/sample-aes.ts":function(k,P,s){"use strict";s.r(P);var R=s("./src/crypt/decrypter.ts"),p=s("./src/demux/tsdemuxer.ts"),x=function(){function I(L,_,y){this.keyData=void 0,this.decrypter=void 0,this.keyData=y,this.decrypter=new R.default(L,_,{removePKCS7Padding:!1})}var T=I.prototype;return T.decryptBuffer=function(_,y){this.decrypter.decrypt(_,this.keyData.key.buffer,this.keyData.iv.buffer,y)},T.decryptAacSample=function(_,y,D,A){var S=_[y].unit;if(!(S.length<=16)){var g=S.subarray(16,S.length-S.length%16),E=g.buffer.slice(g.byteOffset,g.byteOffset+g.length),a=this;this.decryptBuffer(E,function(e){var o=new Uint8Array(e);S.set(o,16),A||a.decryptAacSamples(_,y+1,D)})}},T.decryptAacSamples=function(_,y,D){for(;;y++){if(y>=_.length){D();return}if(!(_[y].unit.length<32)){var A=this.decrypter.isSync();if(this.decryptAacSample(_,y,D,A),!A)return}}},T.getAvcEncryptedData=function(_){for(var y=Math.floor((_.length-48)/160)*16+16,D=new Int8Array(y),A=0,S=32;S<_.length-16;S+=160,A+=16)D.set(_.subarray(S,S+16),A);return D},T.getAvcDecryptedUnit=function(_,y){for(var D=new Uint8Array(y),A=0,S=32;S<_.length-16;S+=160,A+=16)_.set(D.subarray(A,A+16),S);return _},T.decryptAvcSample=function(_,y,D,A,S,g){var E=Object(p.discardEPB)(S.data),a=this.getAvcEncryptedData(E),e=this;this.decryptBuffer(a.buffer,function(o){S.data=e.getAvcDecryptedUnit(E,o),g||e.decryptAvcSamples(_,y,D+1,A)})},T.decryptAvcSamples=function(_,y,D,A){if(_ instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;y++,D=0){if(y>=_.length){A();return}for(var S=_[y].units;!(D>=S.length);D++){var g=S[D];if(!(g.data.length<=48||g.type!==1&&g.type!==5)){var E=this.decrypter.isSync();if(this.decryptAvcSample(_,y,D,A,g,E),!E)return}}}},I}();P.default=x},"./src/demux/transmuxer-interface.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"default",function(){return S});var R=s("./node_modules/webworkify-webpack/index.js"),p=s.n(R),x=s("./src/events.ts"),I=s("./src/demux/transmuxer.ts"),T=s("./src/utils/logger.ts"),L=s("./src/errors.ts"),_=s("./src/utils/mediasource-helper.ts"),y=s("./node_modules/eventemitter3/index.js"),D=s.n(y),A=Object(_.getMediaSource)()||{isTypeSupported:function(){return!1}},S=function(){function g(a,e,o,f){var n=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=a,this.id=e,this.onTransmuxComplete=o,this.onFlush=f;var i=a.config,t=function(d,l){l=l||{},l.frag=n.frag,l.id=n.id,a.trigger(d,l)};this.observer=new y.EventEmitter,this.observer.on(x.Events.FRAG_DECRYPTED,t),this.observer.on(x.Events.ERROR,t);var u={mp4:A.isTypeSupported("video/mp4"),mpeg:A.isTypeSupported("audio/mpeg"),mp3:A.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){a.trigger(x.Events.ERROR,{type:L.ErrorTypes.OTHER_ERROR,details:L.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 E=g.prototype;return E.destroy=function(){var e=this.worker;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.worker=null,this.onwmsg=void 0;else{var 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},E.push=function(e,o,f,n,i,t,u,c,r,h){var d,l,v=this;r.transmuxing.start=self.performance.now();var m=this.transmuxer,O=this.worker,b=t?t.start:i.start,M=i.decryptdata,F=this.frag,w=!(F&&i.cc===F.cc),C=!(F&&r.level===F.level),B=F?r.sn-F.sn:-1,U=this.part?r.part-this.part.index:-1,j=B===0&&r.id>1&&r.id===(F==null?void 0:F.stats.chunkCount),N=!C&&(B===1||B===0&&(U===1||j&&U<=0)),K=self.performance.now();(C||B||i.stats.parsing.start===0)&&(i.stats.parsing.start=K),t&&(U||!N)&&(t.stats.parsing.start=K);var H=!(F&&((d=i.initSegment)===null||d===void 0?void 0:d.url)===((l=F.initSegment)===null||l===void 0?void 0:l.url)),V=new I.TransmuxState(w,N,c,C,b,H);if(!N||w||H){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
|
-
discontinuity: `+w+`
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
var Vi=Object.create;var Nr=Object.defineProperty;var Yi=Object.getOwnPropertyDescriptor;var zi=Object.getOwnPropertyNames;var Xi=Object.getPrototypeOf,Qi=Object.prototype.hasOwnProperty;var Kr=(j,R)=>()=>(R||j((R={exports:{}}).exports,R),R.exports);var $i=(j,R,l,P)=>{if(R&&typeof R=="object"||typeof R=="function")for(let L of zi(R))!Qi.call(j,L)&&L!==l&&Nr(j,L,{get:()=>R[L],enumerable:!(P=Yi(R,L))||P.enumerable});return j};var Zt=(j,R,l)=>(l=j!=null?Vi(Xi(j)):{},$i(R||!j||!j.__esModule?Nr(l,"default",{value:j,enumerable:!0}):l,j));var Er=(j,R,l)=>{if(!R.has(j))throw TypeError("Cannot "+l)};var qt=(j,R,l)=>(Er(j,R,"read from private field"),l?l.call(j):R.get(j)),Bt=(j,R,l)=>{if(R.has(j))throw TypeError("Cannot add the same private member more than once");R instanceof WeakSet?R.add(j):R.set(j,l)},er=(j,R,l,P)=>(Er(j,R,"write to private field"),P?P.call(j,l):R.set(j,l),l);var tr=(j,R,l)=>(Er(j,R,"access private method"),l);var Gr=Kr((rr,Sr)=>{(function(){var j,R;j=this,R=function(){return function(){var l={80:function(A,M,O){A.exports=O(728).default},728:function(A,M,O){"use strict";O.d(M,{default:function(){return Hi}});var b=O(48),_=O.n(b),y=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(w){var C=16*Math.random()|0;return(w==="x"?C:3&C|8).toString(16)})},x=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},D=function(w){return w&&w.nodeName!==void 0?(w.muxId||(w.muxId=w.id||x()),w.muxId):w},E=function(w){var C;w&&w.nodeName!==void 0?w=D(C=w):C=document.querySelector(w);var F=C&&C.nodeName?C.nodeName.toLowerCase():"";return[C,w,F]},m=O(640),p=O.n(m),f=p().methodFactory;p().methodFactory=function(w,C,F){var N=f(w,C,F);return function(){for(var K=["[mux]"],V=0;V<arguments.length;V++)K.push(arguments[V]);N.apply(void 0,K)}},p().setLevel(p().getLevel());var e=p();function s(){return(_().doNotTrack||_().navigator&&_().navigator.doNotTrack)==="1"}var h={now:function(){var w=_().performance,C=w&&w.timing,F=w&&w.timeOrigin||C&&C.navigationStart;return typeof F=="number"&&typeof w.now=="function"?F+w.now():Date.now()}},g=O(678),i=O.n(g),r=function(w){return o(w)[0]},o=function(w){if(typeof w!="string"||w==="")return["localhost"];var C,F=(w.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return F&&(C=(F.match(/[^\.]+\.[^\.]+$/)||[])[0]),[F,C]},c={exists:function(){var w=_().performance;return(w&&w.timing)!==void 0},domContentLoadedEventEnd:function(){var w=_().performance,C=w&&w.timing;return C&&C.domContentLoadedEventEnd},navigationStart:function(){var w=_().performance,C=w&&w.timing;return C&&C.navigationStart}};function t(w,C,F){F=F===void 0?1:F,w[C]=w[C]||0,w[C]+=F}var n=["x-cdn","content-type","x-request-id"];function u(w){var C={};return(w=w||"").trim().split(/[\r\n]+/).forEach(function(F){if(F){var N=F.split(": "),K=N.shift();K&&(n.indexOf(K.toLowerCase())>=0||K.toLowerCase().indexOf("x-litix-")===0)&&(C[K]=N.join(": "))}}),C}var a=function(w){var C={};for(var F in w){var N=w[F];N["DATA-ID"].search("io.litix.data.")!==-1&&(C[N["DATA-ID"].replace("io.litix.data.","")]=N.VALUE)}return C};function d(w,C){var F=Object.keys(w);if(Object.getOwnPropertySymbols){var N=Object.getOwnPropertySymbols(w);C&&(N=N.filter(function(K){return Object.getOwnPropertyDescriptor(w,K).enumerable})),F.push.apply(F,N)}return F}function v(w){for(var C=1;C<arguments.length;C++){var F=arguments[C]!=null?arguments[C]:{};C%2?d(Object(F),!0).forEach(function(N){S(w,N,F[N])}):Object.getOwnPropertyDescriptors?Object.defineProperties(w,Object.getOwnPropertyDescriptors(F)):d(Object(F)).forEach(function(N){Object.defineProperty(w,N,Object.getOwnPropertyDescriptor(F,N))})}return w}function S(w,C,F){return C in w?Object.defineProperty(w,C,{value:F,enumerable:!0,configurable:!0,writable:!0}):w[C]=F,w}var T=function(w){if(!w)return{};var C=c.navigationStart(),F=w.loading,N=F?F.start:w.trequest,K=F?F.first:w.tfirst,V=F?F.end:w.tload;return{bytesLoaded:w.total,requestStart:Math.round(C+N),responseStart:Math.round(C+K),responseEnd:Math.round(C+V)}},I=function(w){if(w&&typeof w.getAllResponseHeaders=="function")return u(w.getAllResponseHeaders())},k=function(w,C){if(!w||typeof w.getRequests!="function")return{};var F=w.getRequests({state:"executed"});if(F.length===0)return{};var N,K=F[F.length-1],V=r(K.url),H=K.bytesLoaded,Q=new Date(K.requestStartDate).getTime(),J=new Date(K.firstByteDate).getTime(),X=new Date(K.requestEndDate).getTime(),ee=isNaN(K.duration)?0:K.duration,ce=typeof C.getMetricsFor=="function"?C.getMetricsFor(K.mediaType).HttpList:C.getDashMetrics().getHttpRequests(K.mediaType);return ce.length>0&&(N=u(ce[ce.length-1]._responseHeaders||"")),{requestStart:Q,requestResponseStart:J,requestResponseEnd:X,requestBytesLoaded:H,requestResponseHeaders:N,requestMediaDuration:ee,requestHostname:V}},B=function(w,C){var F=C.getQualityFor(w),N=C.getCurrentTrackFor(w).bitrateList;return N?{currentLevel:F,renditionWidth:N[F].width||null,renditionHeight:N[F].height||null,renditionBitrate:N[F].bandwidth}:{}};function U(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}var W=0,G=function(){function w(){(function(K,V){if(!(K instanceof V))throw new TypeError("Cannot call a class as a function")})(this,w)}var C,F,N;return C=w,F=[{key:"on",value:function(K,V,H){return V._eventEmitterGuid=V._eventEmitterGuid||++W,this._listeners=this._listeners||{},this._listeners[K]=this._listeners[K]||[],H&&(V=V.bind(H)),this._listeners[K].push(V),V}},{key:"off",value:function(K,V){var H=this._listeners&&this._listeners[K];H&&H.forEach(function(Q,J){Q._eventEmitterGuid===V._eventEmitterGuid&&H.splice(J,1)})}},{key:"one",value:function(K,V,H){var Q=this;V._eventEmitterGuid=V._eventEmitterGuid||++W;var J=function X(){Q.off(K,X),V.apply(H||this,arguments)};J._eventEmitterGuid=V._eventEmitterGuid,this.on(K,J)}},{key:"emit",value:function(K,V){var H=this;if(this._listeners){V=V||{};var Q=this._listeners["before*"]||[],J=this._listeners[K]||[],X=this._listeners["after"+K]||[],ee=function(ce,ye){(ce=ce.slice()).forEach(function(ve){ve.call(H,{type:K},ye)})};ee(Q,V),ee(J,V),ee(X,V)}}}],F&&U(C.prototype,F),N&&U(C,N),Object.defineProperty(C,"prototype",{writable:!1}),w}(),z=G;function Y(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}var $=function(){function w(K){var V=this;(function(H,Q){if(!(H instanceof Q))throw new TypeError("Cannot call a class as a function")})(this,w),this.pm=K,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,K.on("playing",function(){V._playheadShouldBeProgressing=!0}),K.on("play",this._startPlaybackHeartbeatInterval.bind(this)),K.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),K.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),K.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),K.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),K.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),K.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),K.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),K.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),K.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("seeked",function(){K.data.player_is_paused?V._stopPlaybackHeartbeatInterval():V._startPlaybackHeartbeatInterval()}),K.on("timeupdate",function(){V._playbackHeartbeatInterval!==null&&K.emit("playbackheartbeat")}),K.on("devicesleep",function(H,Q){V._playbackHeartbeatInterval!==null&&(_().clearInterval(V._playbackHeartbeatInterval),K.emit("playbackheartbeatend",{viewer_time:Q.viewer_time}),V._playbackHeartbeatInterval=null)})}var C,F,N;return C=w,(F=[{key:"_startPlaybackHeartbeatInterval",value:function(){var K=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=_().setInterval(function(){K.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(_().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&Y(C.prototype,F),N&&Y(C,N),Object.defineProperty(C,"prototype",{writable:!1}),w}();function Z(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function q(w,C,F){return C&&Z(w.prototype,C),F&&Z(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var ie=q(function w(C){var F=this;(function(N,K){if(!(N instanceof K))throw new TypeError("Cannot call a class as a function")})(this,w),C.on("viewinit",function(){F.viewErrored=!1}),C.on("error",function(){try{var N=C.errorTranslator({player_error_code:C.data.player_error_code,player_error_message:C.data.player_error_message});N?(C.data.player_error_code=N.player_error_code,C.data.player_error_message=N.player_error_message,F.viewErrored=!0):(delete C.data.player_error_code,delete C.data.player_error_message)}catch(K){C.mux.log.warn("Exception in error translator callback.",K),F.viewErrored=!0}})});function ne(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}var ae=function(){function w(K){(function(V,H){if(!(V instanceof H))throw new TypeError("Cannot call a class as a function")})(this,w),this.pm=K,this._watchTimeTrackerLastCheckedTime=null,K.on("playbackheartbeat",this._updateWatchTime.bind(this)),K.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var C,F,N;return C=w,(F=[{key:"_updateWatchTime",value:function(K,V){var H=V.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=H),t(this.pm.data,"view_watch_time",H-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=H}},{key:"_clearWatchTimeState",value:function(K,V){this._updateWatchTime(K,V),this._watchTimeTrackerLastCheckedTime=null}}])&&ne(C.prototype,F),N&&ne(C,N),Object.defineProperty(C,"prototype",{writable:!1}),w}();function te(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}var fe=function(){function w(K){(function(V,H){if(!(V instanceof H))throw new TypeError("Cannot call a class as a function")})(this,w),this.pm=K,this._playbackTimeTrackerLastPlayheadPosition=-1,K.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),K.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),K.on("seeking",this._clearPlaybackTimeState.bind(this))}var C,F,N;return C=w,(F=[{key:"_updatePlaybackTime",value:function(){var K=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&K>this._playbackTimeTrackerLastPlayheadPosition){var V=K-this._playbackTimeTrackerLastPlayheadPosition;V<=1e3&&t(this.pm.data,"view_content_playback_time",V)}this._playbackTimeTrackerLastPlayheadPosition=K}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&te(C.prototype,F),N&&te(C,N),Object.defineProperty(C,"prototype",{writable:!1}),w}();function de(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}var re=function(){function w(K){(function(H,Q){if(!(H instanceof Q))throw new TypeError("Cannot call a class as a function")})(this,w),this.pm=K;var V=this._updatePlayheadTime.bind(this);K.on("playbackheartbeat",V),K.on("playbackheartbeatend",V),K.on("timeupdate",V),K.on("destroy",function(){K.off("timeupdate",V)})}var C,F,N;return C=w,(F=[{key:"_updateMaxPlayheadPosition",value:function(){this.pm.data.view_max_playhead_position=this.pm.data.view_max_playhead_position===void 0?this.pm.data.player_playhead_time:Math.max(this.pm.data.view_max_playhead_position,this.pm.data.player_playhead_time)}},{key:"_updatePlayheadTime",value:function(K,V){var H=this,Q=function(){H.pm.currentFragmentPDT&&H.pm.currentFragmentStart&&(H.pm.data.player_program_time=H.pm.currentFragmentPDT+H.pm.data.player_playhead_time-H.pm.currentFragmentStart)};if(V&&V.player_playhead_time)this.pm.data.player_playhead_time=V.player_playhead_time,Q(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var J=this.pm.getPlayheadTime();J!==void 0&&(this.pm.data.player_playhead_time=J,Q(),this._updateMaxPlayheadPosition())}}}])&&de(C.prototype,F),N&&de(C,N),Object.defineProperty(C,"prototype",{writable:!1}),w}();function Ee(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function me(w,C,F){return C&&Ee(w.prototype,C),F&&Ee(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var Te=me(function w(C){if(function(K,V){if(!(K instanceof V))throw new TypeError("Cannot call a class as a function")}(this,w),!C.disableRebufferTracking){var F,N=function(){if(F){var K=C.data.viewer_time-F;t(C.data,"view_rebuffer_duration",K),F=C.data.viewer_time}C.data.view_watch_time>=0&&C.data.view_rebuffer_count>0&&(C.data.view_rebuffer_frequency=C.data.view_rebuffer_count/C.data.view_watch_time,C.data.view_rebuffer_percentage=C.data.view_rebuffer_duration/C.data.view_watch_time)};C.on("playbackheartbeat",function(){return N()}),C.on("rebufferstart",function(){F||(t(C.data,"view_rebuffer_count",1),F=C.data.viewer_time,C.one("rebufferend",function(){N(),F=void 0}))})}});function Me(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}var _e=function(){function w(K){var V=this;(function(H,Q){if(!(H instanceof Q))throw new TypeError("Cannot call a class as a function")})(this,w),this.pm=K,K.disableRebufferTracking||K.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,K.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),K.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),K.on("seeking",function(){V._cleanupRebufferTracker(null,{viewer_time:h.now()})}))}var C,F,N;return C=w,F=[{key:"_checkIfRebuffering",value:function(K,V){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(K,V);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var H=V.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&H>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=V.viewer_time}else this._cleanupRebufferTracker(K,V,!0);else this._prepareRebufferTrackerState(V.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(K){this._lastCheckedTime=K,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=K}},{key:"_cleanupRebufferTracker",value:function(K,V){var H=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:V.viewer_time});else{if(this._lastCheckedTime===null)return;var Q=this.pm.data.player_playhead_time-this._lastPlayheadTime,J=V.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&Q>0&&J-Q>this.pm.minimumRebufferDuration&&(this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+J-Q}))}H?this._prepareRebufferTrackerState(V.viewer_time):this._clearRebufferTrackerState()}}],F&&Me(C.prototype,F),N&&Me(C,N),Object.defineProperty(C,"prototype",{writable:!1}),w}(),ke=_e;function Ie(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}var Be=function(){function w(K){var V=this;(function(H,Q){if(!(H instanceof Q))throw new TypeError("Cannot call a class as a function")})(this,w),this.pm=K,K.on("viewinit",function(){var H=K.data,Q=H.view_id;if(!H.view_program_changed){var J=function(X,ee){var ce=ee.viewer_time;X.type==="playing"&&K.data.view_time_to_first_frame===void 0?V.calculateTimeToFirstFrame(ce||h.now(),Q):X.type!=="adplaying"||K.data.view_time_to_first_frame!==void 0&&!V._inPrerollPosition()||V.calculateTimeToFirstFrame(ce||h.now(),Q)};K.one("playing",J),K.one("adplaying",J),K.one("viewend",function(){K.off("playing",J),K.off("adplaying",J)})}})}var C,F,N;return C=w,(F=[{key:"_inPrerollPosition",value:function(){return this.pm.data.view_content_playback_time===void 0||this.pm.data.view_content_playback_time<=1e3}},{key:"calculateTimeToFirstFrame",value:function(K,V){V===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:K}),this.pm.data.view_time_to_first_frame=this.pm.data.view_watch_time,(this.pm.data.player_autoplay_on||this.pm.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.pm.data.view_aggregate_startup_time=this.pm.data.view_start+this.pm.data.view_watch_time-this.NAVIGATION_START))}}])&&Ie(C.prototype,F),N&&Ie(C,N),Object.defineProperty(C,"prototype",{writable:!1}),w}();function be(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function Ue(w,C,F){return C&&be(w.prototype,C),F&&be(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var Ke=Ue(function w(C){var F=this;(function(N,K){if(!(N instanceof K))throw new TypeError("Cannot call a class as a function")})(this,w),C.on("viewinit",function(){F._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(N){C.on(N,function(){if(F._lastPlayheadPosition>=0&&C.data.player_playhead_time>=0&&F._lastPlayerWidth>=0&&F._lastSourceWidth>0&&F._lastPlayerHeight>=0&&F._lastSourceHeight>0){var K=C.data.player_playhead_time-F._lastPlayheadPosition;if(K<0)return void(F._lastPlayheadPosition=-1);var V=Math.min(F._lastPlayerWidth/F._lastSourceWidth,F._lastPlayerHeight/F._lastSourceHeight),H=Math.max(0,V-1),Q=Math.max(0,1-V);C.data.view_max_upscale_percentage=Math.max(C.data.view_max_upscale_percentage||0,H),C.data.view_max_downscale_percentage=Math.max(C.data.view_max_downscale_percentage||0,Q),t(C.data,"view_total_content_playback_time",K),t(C.data,"view_total_upscaling",H*K),t(C.data,"view_total_downscaling",Q*K)}F._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(N){C.on(N,function(){F._lastPlayheadPosition=C.data.player_playhead_time,F._lastPlayerWidth=C.data.player_width,F._lastPlayerHeight=C.data.player_height,F._lastSourceWidth=C.data.video_source_width,F._lastSourceHeight=C.data.video_source_height})})});function je(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function Ne(w,C,F){return C&&je(w.prototype,C),F&&je(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var qe=Ne(function w(C){var F=this;(function(N,K){if(!(N instanceof K))throw new TypeError("Cannot call a class as a function")})(this,w),this.isSeeking=!1,C.on("seeking",function(N,K){i()(C.data,K),F._lastSeekingTime=h.now(),F.isSeeking===!1&&(F.isSeeking=!0,C.send("seeking"))}),C.on("seeked",function(){F.isSeeking=!1;var N=F._lastSeekingTime||h.now(),K=h.now()-N;t(C.data,"view_seek_count",1),t(C.data,"view_seek_duration",K);var V=C.data.view_max_seek_time||0;C.data.view_max_seek_time=Math.max(V,K)}),C.on("viewend",function(){F.isSeeking=!1})});function Fe(w,C){return function(F){if(Array.isArray(F))return F}(w)||function(F,N){var K=F==null?null:typeof Symbol!="undefined"&&F[Symbol.iterator]||F["@@iterator"];if(K!=null){var V,H,Q=[],J=!0,X=!1;try{for(K=K.call(F);!(J=(V=K.next()).done)&&(Q.push(V.value),!N||Q.length!==N);J=!0);}catch(ee){X=!0,H=ee}finally{try{J||K.return==null||K.return()}finally{if(X)throw H}}return Q}}(w,C)||function(F,N){if(F){if(typeof F=="string")return et(F,N);var K=Object.prototype.toString.call(F).slice(8,-1);return K==="Object"&&F.constructor&&(K=F.constructor.name),K==="Map"||K==="Set"?Array.from(F):K==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(K)?et(F,N):void 0}}(w,C)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function et(w,C){(C==null||C>w.length)&&(C=w.length);for(var F=0,N=new Array(C);F<C;F++)N[F]=w[F];return N}function Oe(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}var Pe=function(w,C){w.push(C),w.sort(function(F,N){return F.viewer_time-N.viewer_time})},Ve=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],Ce=function(){function w(K){var V=this;(function(Q,J){if(!(Q instanceof J))throw new TypeError("Cannot call a class as a function")})(this,w),this.pm=K,K.on("viewinit",function(){V.isAdBreak=!1,V._currentAdRequestNumber=0,V._currentAdResponseNumber=0,V._adRequests=[],V._adResponses=[],V._adHasPlayed=!1,V._wouldBeNewAdPlay=!0,V._prerollPlayTime=void 0}),Ve.forEach(function(Q){return K.on(Q,V._updateAdData.bind(V))});var H=function(){V.isAdBreak=!1};K.on("adbreakstart",function(){V.isAdBreak=!0}),K.on("play",H),K.on("playing",H),K.on("viewend",H),K.on("adrequest",function(Q,J){J=i()({ad_request_id:"generatedAdRequestId"+V._currentAdRequestNumber++},J),Pe(V._adRequests,J),t(K.data,"view_ad_request_count"),V.inPrerollPosition()&&(K.data.view_preroll_requested=!0,V._adHasPlayed||t(K.data,"view_preroll_request_count"))}),K.on("adresponse",function(Q,J){J=i()({ad_request_id:"generatedAdRequestId"+V._currentAdResponseNumber++},J),Pe(V._adResponses,J);var X=V.findAdRequest(J.ad_request_id);X&&t(K.data,"view_ad_request_time",Math.max(0,J.viewer_time-X.viewer_time))}),K.on("adplay",function(Q,J){V._adHasPlayed=!0,V._wouldBeNewAdPlay&&(V._wouldBeNewAdPlay=!1,t(K.data,"view_ad_played_count")),V.inPrerollPosition()&&!K.data.view_preroll_played&&(K.data.view_preroll_played=!0,V._adRequests.length>0&&(K.data.view_preroll_request_time=Math.max(0,J.viewer_time-V._adRequests[0].viewer_time)),K.data.view_start&&(K.data.view_startup_preroll_request_time=Math.max(0,J.viewer_time-K.data.view_start)),V._prerollPlayTime=J.viewer_time)}),K.on("adplaying",function(Q,J){V.inPrerollPosition()&&K.data.view_preroll_load_time===void 0&&V._prerollPlayTime!==void 0&&(K.data.view_preroll_load_time=J.viewer_time-V._prerollPlayTime,K.data.view_startup_preroll_load_time=J.viewer_time-V._prerollPlayTime)}),K.on("adended",function(){V._wouldBeNewAdPlay=!0}),K.on("aderror",function(){V._wouldBeNewAdPlay=!0})}var C,F,N;return C=w,(F=[{key:"inPrerollPosition",value:function(){return this.pm.data.view_content_playback_time===void 0||this.pm.data.view_content_playback_time<=1e3}},{key:"findAdRequest",value:function(K){for(var V=0;V<this._adRequests.length;V++)if(this._adRequests[V].ad_request_id===K)return this._adRequests[V]}},{key:"_updateAdData",value:function(K,V){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&V.ad_tag_url){var H=Fe(o(V.ad_tag_url),2),Q=H[0],J=H[1];this.pm.data.view_preroll_ad_tag_domain=J,this.pm.data.view_preroll_ad_tag_hostname=Q}if(!this.pm.data.view_preroll_ad_asset_hostname&&V.ad_asset_url){var X=Fe(o(V.ad_asset_url),2),ee=X[0],ce=X[1];this.pm.data.view_preroll_ad_asset_domain=ce,this.pm.data.view_preroll_ad_asset_hostname=ee}}}}])&&Oe(C.prototype,F),N&&Oe(C,N),Object.defineProperty(C,"prototype",{writable:!1}),w}();function Le(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function it(w,C,F){return C&&Le(w.prototype,C),F&&Le(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var We=it(function w(C){var F,N;(function(Q,J){if(!(Q instanceof J))throw new TypeError("Cannot call a class as a function")})(this,w);var K=function(){C.disableRebufferTracking||F&&(t(C.data,"view_waiting_rebuffer_duration",h.now()-F),F=!1,_().clearInterval(N))},V=!1,H=function(){V=!1,K()};C.on("waiting",function(){V&&(C.disableRebufferTracking||(t(C.data,"view_waiting_rebuffer_count",1),F=h.now(),N=_().setInterval(function(){if(F){var Q=h.now();t(C.data,"view_waiting_rebuffer_duration",Q-F),F=Q}},250)))}),C.on("playing",function(){K(),V=!0}),C.on("pause",H),C.on("seeking",H)});function ot(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function gt(w,C,F){return C&&ot(w.prototype,C),F&&ot(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var Xe=gt(function w(C){var F=this;(function(V,H){if(!(V instanceof H))throw new TypeError("Cannot call a class as a function")})(this,w);var N=function(){F.lastWallClockTime=h.now(),C.on("before*",K)},K=function(V){var H=h.now(),Q=F.lastWallClockTime;F.lastWallClockTime=H,H-Q>3e4&&(C.emit("devicesleep",{viewer_time:Q}),i()(C.data,{viewer_time:Q}),C.send("devicesleep"),C.emit("devicewake",{viewer_time:H}),i()(C.data,{viewer_time:H}),C.send("devicewake"))};C.one("playbackheartbeat",N),C.on("playbackheartbeatend",function(){C.off("before*",K),C.one("playbackheartbeat",N)})}),Dt=O(375),mt=O(655),nt=O.n(mt),lt="muxData",at=function(){var w;try{w=Dt.parse(nt().get(lt)||"")}catch{w={}}return w},pt=function(w){try{nt().set(lt,Dt.stringify(w),{expires:7300})}catch{}},vt=function(){var w=at();return w.mux_viewer_id=w.mux_viewer_id||y(),w.msn=w.msn||Math.random(),pt(w),{mux_viewer_id:w.mux_viewer_id,mux_sample_number:w.msn}};function or(w,C){var F=C.beaconCollectionDomain,N=C.beaconDomain;if(F)return"https://"+F;var K=N||"litix.io";return(w=w||"inferred").match(/^[a-z0-9]+$/)?"https://"+w+"."+K:"https://img.litix.io/a.gif"}var Pt=function(){var w;switch(At()){case"cellular":w="cellular";break;case"ethernet":w="wired";break;case"wifi":w="wifi";break;case void 0:break;default:w="other"}return w},At=function(){var w=_().navigator,C=w&&(w.connection||w.mozConnection||w.webkitConnection);return C&&C.type};Pt.getConnectionFromAPI=At;var Qe=Pt,Yt=zt({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"}),Ct=zt({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",fp:"fps",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"});function zt(w){var C={};for(var F in w)w.hasOwnProperty(F)&&(C[w[F]]=F);return C}function Mt(w){var C={},F={};return Object.keys(w).forEach(function(N){var K=!1;if(w.hasOwnProperty(N)&&w[N]!==void 0){var V=N.split("_"),H=V[0],Q=Yt[H];Q||(e.info("Data key word `"+V[0]+"` not expected in "+N),Q=H+"_"),V.splice(1).forEach(function(J){J==="url"&&(K=!0),Ct[J]?Q+=Ct[J]:Number(J)&&Math.floor(Number(J))===Number(J)?Q+=J:(e.info("Data key word `"+J+"` not expected in "+N),Q+="_"+J+"_")}),K?F[Q]=w[N]:C[Q]=w[N]}}),i()(C,F)}var lr={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},ur=["hb","requestcompleted","requestfailed","requestcanceled"],st=function(w,C){this._beaconUrl=w||"https://img.litix.io",this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=i()({},lr,C)};st.prototype.queueEvent=function(w,C){var F=i()({},C);return(this._eventQueue.length<=this._options.maxQueueLength||w==="eventrateexceeded")&&(this._eventQueue.push(F),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},st.prototype.flushEvents=function(){this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending()},st.prototype.destroy=function(){var w=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,w?this._clearBeaconQueue():this.flushEvents(),_().clearTimeout(this._sendTimeout)},st.prototype._clearBeaconQueue=function(){var w=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,C=this._eventQueue.slice(w);w>0&&i()(C[C.length-1],Mt({mux_view_message:"event queue truncated"}));var F=this._createPayload(C);Lt(this._beaconUrl,F,!0,function(){})},st.prototype._sendBeaconQueue=function(){var w=this;if(!this._postInFlight){var C=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var F=this._createPayload(C),N=h.now();Lt(this._beaconUrl,F,!1,function(K,V){V?(w._eventQueue=C.concat(w._eventQueue),w._failureCount+=1,e.info("Error sending beacon: "+V)):w._failureCount=0,w._roundTripTime=h.now()-N,w._postInFlight=!1})}},st.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var w=Math.pow(2,this._failureCount-1);return(1+(w*=Math.random()))*this._options.baseTimeBetweenBeacons},st.prototype._startBeaconSending=function(){var w=this;_().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=_().setTimeout(function(){w._eventQueue.length&&w._sendBeaconQueue(),w._startBeaconSending()},this._getNextBeaconTime()))},st.prototype._createPayload=function(w){var C,F,N,K=this,V={transmission_timestamp:Math.round(h.now())};this._roundTripTime&&(V.rtt_ms=Math.round(this._roundTripTime));var H=function(){C=JSON.stringify({metadata:V,events:F||w}),N=C.length/1024},Q=function(){return N<=K._options.maxPayloadKBSize};return H(),Q()||(e.info("Payload size is too big ("+N+" kb). Removing unnecessary events."),F=w.filter(function(J){return ur.indexOf(J.e)===-1}),H()),Q()||(e.info("Payload size still too big ("+N+" kb). Cropping fields.."),F.forEach(function(J){for(var X in J){var ee=J[X];typeof ee=="string"&&ee.length>51200&&(J[X]=ee.substring(0,51200))}}),H()),C};var Lt=function(w,C,F,N){if(F&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(w,C))N();else if(_().fetch)_().fetch(w,{method:"POST",body:C,headers:{"Content-Type":"text/plain"},keepalive:!0}).then(function(V){return N(null,V.ok?null:"Error")}).catch(function(V){return N(null,V)});else{if(_().XMLHttpRequest){var K=new(_()).XMLHttpRequest;return K.onreadystatechange=function(){if(K.readyState===4)return N(null,K.status!==200?"error":void 0)},K.open("POST",w),K.setRequestHeader("Content-Type","text/plain"),void K.send(C)}N()}},Xt=st;function Et(w){return Et=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(C){return typeof C}:function(C){return C&&typeof Symbol=="function"&&C.constructor===Symbol&&C!==Symbol.prototype?"symbol":typeof C},Et(w)}var fr=["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"],ci=["viewstart","error","ended","viewend"],Qt=function(w,C){var F=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.mux=w,this.envKey=C,this.eventQueue=new Xt(or(C,F)),this.previousBeaconData=null,this.lastEventTime=null,this.sampleRate=F.sampleRate,this.disableCookies=F.disableCookies,this.respectDoNotTrack=F.respectDoNotTrack;var N=F.platform||{};this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:N.name,viewer_application_version:N.version,viewer_application_engine:N.layout,viewer_device_name:N.product,viewer_device_category:"",viewer_device_manufacturer:N.manufacturer,viewer_os_family:N.os&&N.os.family,viewer_os_architecture:N.os&&N.os.architecture,viewer_os_version:N.os&&N.os.version};var K=Qe();K&&(this.pageLevelData=i()(this.pageLevelData,{viewer_connection_type:K})),_()!==void 0&&_().location&&_().location.href&&(this.pageLevelData.page_url=_().location.href),this.viewerData=this.disableCookies?{}:vt()};Qt.prototype.send=function(w,C){if(w){if(this.respectDoNotTrack&&s())return e.info("Not sending `"+w+"` because Do Not Track is enabled");if(!C||Et(C)!=="object")return e.error("A data object was expected in send() but was not provided");var F,N,K=this.disableCookies?{}:(F=at(),N=h.now(),F.session_start&&(F.sst=F.session_start,delete F.session_start),F.session_id&&(F.sid=F.session_id,delete F.session_id),F.session_expires&&(F.sex=F.session_expires,delete F.session_expires),(!F.sex||F.sex<N)&&(F.sid=y(),F.sst=N),F.sex=N+15e5,pt(F),{session_id:F.sid,session_start:F.sst,session_expires:F.sex}),V={};i()(V,this.pageLevelData),i()(V,C),i()(V,K),i()(V,this.viewerData),V.event=w,V.env_key=this.envKey,V.user_id&&(V.viewer_user_id=V.user_id,delete V.user_id);var H=V.mux_sample_number>=this.sampleRate,Q=Mt(this._deduplicateBeaconData(w,V));if(this.lastEventTime=this.mux.utils.now(),H)return e.info("Not sending event due to sample rate restriction",w,V,Q);if(this.envKey||e.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",w,V,Q),!this.rateLimited){if(e.info("Sending event",w,V,Q),this.rateLimited=!this.eventQueue.queueEvent(w,Q),this.mux.WINDOW_UNLOADING&&w==="viewend")this.eventQueue.destroy(!0);else if((ci.indexOf(w)>=0||this.mux.WINDOW_HIDDEN&&w==="hb")&&this.eventQueue.flushEvents(),this.rateLimited)return V.event="eventrateexceeded",Q=Mt(V),this.eventQueue.queueEvent(V.event,Q),e.error("Beaconing disabled due to rate limit.")}}},Qt.prototype.destroy=function(){this.eventQueue.destroy(!1)},Qt.prototype._deduplicateBeaconData=function(w,C){var F=this,N={},K=C.view_id;if(!K||w==="viewstart"||w==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)N=i()({},C),K&&(this.previousBeaconData=N),K&&w==="viewend"&&(this.previousBeaconData=null);else{var V=w.indexOf("request")===0;Object.keys(C).forEach(function(H){var Q=C[H];(Q!==F.previousBeaconData[H]||fr.indexOf(H)>-1||function(J,X,ee,ce){return!(!J||X.indexOf("request_")!==0||X!=="request_response_headers"&&Et(ee)==="object"&&Et(ce)==="object"&&Object.keys(ee||{}).length===Object.keys(ce||{}).length)}(V,H,Q,F.previousBeaconData[H])||function(J,X){return J==="renditionchange"&&X.indexOf("video_source_")===0}(w,H))&&(N[H]=Q,F.previousBeaconData[H]=Q)})}return N};var hi=Qt;function Pr(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function vi(w,C,F){return C&&Pr(w.prototype,C),F&&Pr(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var gi=vi(function w(C){(function(X,ee){if(!(X instanceof ee))throw new TypeError("Cannot call a class as a function")})(this,w);var F=0,N=0,K=0,V=0,H=0,Q=0,J=0;C.on("requestcompleted",function(X,ee){var ce,ye,ve=ee.request_start,se=ee.request_response_start,le=ee.request_response_end,xe=ee.request_bytes_loaded;if(V++,se?(ce=se-ve,ye=le-se):ye=le-ve,ye>0&&xe>0){var Ye=xe/ye*8e3;H++,N+=xe,K+=ye,C.data.view_min_request_throughput=Math.min(C.data.view_min_request_throughput||1/0,Ye),C.data.view_average_request_throughput=N/K*8e3,C.data.view_request_count=V,ce>0&&(F+=ce,C.data.view_max_request_latency=Math.max(C.data.view_max_request_latency||0,ce),C.data.view_average_request_latency=F/H)}}),C.on("requestfailed",function(X,ee){V++,Q++,C.data.view_request_count=V,C.data.view_request_failed_count=Q}),C.on("requestcanceled",function(X,ee){V++,J++,C.data.view_request_count=V,C.data.view_request_canceled_count=J})});function Cr(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function mi(w,C,F){return C&&Cr(w.prototype,C),F&&Cr(w,F),Object.defineProperty(w,"prototype",{writable:!1}),w}var pi=mi(function w(C){var F=this;(function(N,K){if(!(N instanceof K))throw new TypeError("Cannot call a class as a function")})(this,w),C.on("before*",function(N,K){var V=K.viewer_time,H=h.now(),Q=F._lastEventTime;if(F._lastEventTime=H,Q&&H-Q>36e5){var J=Object.keys(C.data).reduce(function(X,ee){return ee.indexOf("video_")===0?i()(X,function(ce,ye,ve){return ye in ce?Object.defineProperty(ce,ye,{value:ve,enumerable:!0,configurable:!0,writable:!0}):ce[ye]=ve,ce}({},ee,C.data[ee])):X},{});C.mux.log.info("Received event after at least an hour inactivity, creating a new view"),C.emit("viewinit",i()({viewer_time:V},J)),C.playbackHeartbeat._playheadShouldBeProgressing&&N.type!=="play"&&N.type!=="adbreakstart"&&(C.emit("play",{viewer_time:V}),N.type!=="playing"&&C.emit("playing",{viewer_time:V}))}})});function dr(w){return dr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(C){return typeof C}:function(C){return C&&typeof Symbol=="function"&&C.constructor===Symbol&&C!==Symbol.prototype?"symbol":typeof C},dr(w)}function Ei(w,C){return function(F){if(Array.isArray(F))return F}(w)||function(F,N){var K=F==null?null:typeof Symbol!="undefined"&&F[Symbol.iterator]||F["@@iterator"];if(K!=null){var V,H,Q=[],J=!0,X=!1;try{for(K=K.call(F);!(J=(V=K.next()).done)&&(Q.push(V.value),!N||Q.length!==N);J=!0);}catch(ee){X=!0,H=ee}finally{try{J||K.return==null||K.return()}finally{if(X)throw H}}return Q}}(w,C)||function(F,N){if(F){if(typeof F=="string")return Mr(F,N);var K=Object.prototype.toString.call(F).slice(8,-1);return K==="Object"&&F.constructor&&(K=F.constructor.name),K==="Map"||K==="Set"?Array.from(F):K==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(K)?Mr(F,N):void 0}}(w,C)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Mr(w,C){(C==null||C>w.length)&&(C=w.length);for(var F=0,N=new Array(C);F<C;F++)N[F]=w[F];return N}function Fr(w,C){for(var F=0;F<C.length;F++){var N=C[F];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(w,N.key,N)}}function cr(w,C){return cr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(F,N){return F.__proto__=N,F},cr(w,C)}function yi(w){var C=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}}();return function(){var F,N=$t(w);if(C){var K=$t(this).constructor;F=Reflect.construct(N,arguments,K)}else F=N.apply(this,arguments);return Ti(this,F)}}function Ti(w,C){if(C&&(dr(C)==="object"||typeof C=="function"))return C;if(C!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return we(w)}function we(w){if(w===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return w}function $t(w){return $t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(C){return C.__proto__||Object.getPrototypeOf(C)},$t(w)}var xi=["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"],Si=function(w){(function(H,Q){if(typeof Q!="function"&&Q!==null)throw new TypeError("Super expression must either be null or a function");H.prototype=Object.create(Q&&Q.prototype,{constructor:{value:H,writable:!0,configurable:!0}}),Object.defineProperty(H,"prototype",{writable:!1}),Q&&cr(H,Q)})(V,w);var C,F,N,K=yi(V);function V(H,Q,J){var X;(function(se,le){if(!(se instanceof le))throw new TypeError("Cannot call a class as a function")})(this,V),(X=K.call(this)).DOM_CONTENT_LOADED_EVENT_END=c.domContentLoadedEventEnd(),X.NAVIGATION_START=c.navigationStart(),X.mux=H,X.id=Q,(J=i()({debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(se){return se}},J)).data=J.data||{},J.data.property_key&&(J.data.env_key=J.data.property_key,delete J.data.property_key),e.setLevel(J.debug?"debug":"warn"),X.getPlayheadTime=J.getPlayheadTime,X.getStateData=J.getStateData||function(){return{}},X.getAdData=J.getAdData||function(){},X.minimumRebufferDuration=J.minimumRebufferDuration,X.sustainedRebufferThreshold=J.sustainedRebufferThreshold,X.playbackHeartbeatTime=J.playbackHeartbeatTime,X.disableRebufferTracking=J.disableRebufferTracking,X.disableRebufferTracking&&X.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."),X.disablePlayheadRebufferTracking=J.disablePlayheadRebufferTracking,X.errorTranslator=J.errorTranslator,X.playbackEventDispatcher=new hi(H,J.data.env_key,J),X.data={player_instance_id:y(),mux_sample_rate:J.sampleRate,beacon_domain:J.beaconCollectionDomain?J.beaconCollectionDomain:J.beaconDomain},X.data.view_sequence_number=1,X.data.player_sequence_number=1,X.oldEmit=X.emit,X.emit=function(se,le){le=i()({viewer_time:this.mux.utils.now()},le),this.oldEmit(se,le)};var ee=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(we(X));X.on("viewinit",function(se,le){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),i()(this.data,le),this._initializeViewData(),this.one("play",ee),this.one("adbreakstart",ee)});var ce=function(se){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",se)}.bind(we(X));if(X.on("videochange",function(se,le){ce(le)}),X.on("programchange",function(se,le){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),ce(i()(le,{view_program_changed:!0})),ee(),this.emit("play"),this.emit("playing")}),X.on("fragmentchange",function(se,le){this.currentFragmentPDT=le.currentFragmentPDT,this.currentFragmentStart=le.currentFragmentStart}),X.on("destroy",X.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var ye=function(){var se=X.data.view_start!==void 0;X.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",se&&X.mux.WINDOW_HIDDEN&&(X.data.player_is_paused||X.emit("hb"))};window.addEventListener("visibilitychange",ye,!1);var ve=function(se){se.persisted||X.destroy()};window.addEventListener("pagehide",ve,!1),X.on("destroy",function(){window.removeEventListener("visibilitychange",ye),window.removeEventListener("pagehide",ve)})}return X.on("playerready",function(se,le){i()(this.data,le)}),xi.forEach(function(se){X.on(se,function(le,xe){se.indexOf("ad")!==0&&this._updateStateData(),i()(this.data,xe),this._sanitizeData()}),X.on("after"+se,function(){(se!=="error"||this.errorTracker.viewErrored)&&this.send(se)})}),X.on("viewend",function(se,le){i()(X.data,le)}),X.one("playerready",function(se){var le=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=le-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time}),X.longResumeTracker=new pi(we(X)),X.errorTracker=new ie(we(X)),new Xe(we(X)),X.seekingTracker=new qe(we(X)),X.playheadTime=new re(we(X)),X.playbackHeartbeat=new $(we(X)),new Ke(we(X)),X.watchTimeTracker=new ae(we(X)),new fe(we(X)),X.adTracker=new Ce(we(X)),new ke(we(X)),new Te(we(X)),new Be(we(X)),new We(we(X)),new gi(we(X)),J.hlsjs&&X.addHLSJS(J),J.dashjs&&X.addDashJS(J),X.emit("viewinit",J.data),X}return C=V,F=[{key:"destroy",value: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(),window.clearTimeout(this._heartBeatTimeout))}},{key:"send",value:function(H){var Q=i()({},this.data);if(Q.video_source_is_live===void 0&&(Q.player_source_duration===1/0||Q.video_source_duration===1/0?Q.video_source_is_live=!0:(Q.player_source_duration>0||Q.video_source_duration>0)&&(Q.video_source_is_live=!1)),Q.video_source_is_live||["player_program_time","player_manifest_newest_program_time","player_live_edge_program_time","player_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"].forEach(function(ce){Q[ce]=void 0}),Q.video_source_url=Q.video_source_url||Q.player_source_url,Q.video_source_url){var J=Ei(o(Q.video_source_url),2),X=J[0],ee=J[1];Q.video_source_domain=ee,Q.video_source_hostname=X}delete Q.ad_request_id,this.playbackEventDispatcher.send(H,Q),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()}},{key:"_updateStateData",value:function(){i()(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var H=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(Q){var J=parseInt(H.data[Q],10);H.data[Q]=isNaN(J)?void 0:J}),["player_source_url","video_source_url"].forEach(function(Q){if(H.data[Q]){var J=H.data[Q].toLowerCase();J.indexOf("data:")!==0&&J.indexOf("blob:")!==0||(H.data[Q]="MSE style URL")}})}},{key:"_resetVideoData",value:function(H,Q){var J=this;Object.keys(this.data).forEach(function(X){X.indexOf("video_")===0&&delete J.data[X]})}},{key:"_resetViewData",value:function(){var H=this;Object.keys(this.data).forEach(function(Q){Q.indexOf("view_")===0&&delete H.data[Q]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(H,Q){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var H=this,Q=this.data.view_id=y(),J=function(){Q===H.data.view_id&&t(H.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",J):J()}},{key:"_restartHeartBeat",value:function(){var H=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){H.data.player_is_paused||H.emit("hb")},1e4))}},{key:"addHLSJS",value:function(H){H.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=H.hlsjs,function(Q,J,X){var ee=arguments.length>4?arguments[4]:void 0,ce=Q.log,ye=Q.utils.secondsToMs,ve=function(pe){var oe,he=parseInt(ee.version);return he===1&&pe.programDateTime!==null&&(oe=pe.programDateTime),he===0&&pe.pdt!==null&&(oe=pe.pdt),oe};if(c.exists()){var se=function(pe,oe){return Q.emit(J,pe,oe)},le=function(pe,oe){var he=oe.levels,ue=oe.audioTracks,ge=oe.url,Re=oe.stats,Ae=oe.networkDetails,rt=oe.sessionData,Ze={},ut={};he.forEach(function(ct,kt){Ze[kt]={width:ct.width,height:ct.height,bitrate:ct.bitrate,attrs:ct.attrs}}),ue.forEach(function(ct,kt){ut[kt]={name:ct.name,language:ct.lang,bitrate:ct.bitrate}});var ft=T(Re),dt=ft.bytesLoaded,He=ft.requestStart,mr=ft.responseStart,pr=ft.responseEnd;se("requestcompleted",v(v({},a(rt)),{},{request_event_type:pe,request_bytes_loaded:dt,request_start:He,request_response_start:mr,request_response_end:pr,request_type:"manifest",request_hostname:r(ge),request_response_headers:I(Ae),request_rendition_lists:{media:Ze,audio:ut,video:{}}}))};X.on(ee.Events.MANIFEST_LOADED,le);var xe=function(pe,oe){var he=oe.details,ue=oe.level,ge=oe.networkDetails,Re=oe.stats,Ae=T(Re),rt=Ae.bytesLoaded,Ze=Ae.requestStart,ut=Ae.responseStart,ft=Ae.responseEnd,dt=he.fragments[he.fragments.length-1],He=ve(dt)+ye(dt.duration);se("requestcompleted",{request_event_type:pe,request_bytes_loaded:rt,request_start:Ze,request_response_start:ut,request_response_end:ft,request_current_level:ue,request_type:"manifest",request_hostname:r(he.url),request_response_headers:I(ge),video_holdback:he.holdBack&&ye(he.holdBack),video_part_holdback:he.partHoldBack&&ye(he.partHoldBack),video_part_target_duration:he.partTarget&&ye(he.partTarget),video_target_duration:he.targetduration&&ye(he.targetduration),video_source_is_live:he.live,player_manifest_newest_program_time:isNaN(He)?void 0:He})};X.on(ee.Events.LEVEL_LOADED,xe);var Ye=function(pe,oe){var he=oe.details,ue=oe.networkDetails,ge=oe.stats,Re=T(ge),Ae=Re.bytesLoaded,rt=Re.requestStart,Ze=Re.responseStart,ut=Re.responseEnd;se("requestcompleted",{request_event_type:pe,request_bytes_loaded:Ae,request_start:rt,request_response_start:Ze,request_response_end:ut,request_type:"manifest",request_hostname:r(he.url),request_response_headers:I(ue)})};X.on(ee.Events.AUDIO_TRACK_LOADED,Ye);var $e=function(pe,oe){var he=oe.stats,ue=oe.networkDetails,ge=oe.frag;he=he||ge.stats;var Re=T(he),Ae={request_event_type:pe,request_bytes_loaded:Re.bytesLoaded,request_start:Re.requestStart,request_response_start:Re.responseStart,request_response_end:Re.responseEnd,request_hostname:ue?r(ue.responseURL):void 0,request_response_headers:I(ue),request_media_duration:ge.duration};ge.type==="main"?(Ae.request_type="media",Ae.request_current_level=ge.level,Ae.request_video_width=(X.levels[ge.level]||{}).width,Ae.request_video_height=(X.levels[ge.level]||{}).height):Ae.request_type=ge.type,se("requestcompleted",Ae)};X.on(ee.Events.FRAG_LOADED,$e);var yt=function(pe,oe){var he=oe.frag,ue=he.start,ge={currentFragmentPDT:ve(he),currentFragmentStart:ye(ue)};se("fragmentchange",ge)};X.on(ee.Events.FRAG_CHANGED,yt);var Se=function(pe,oe){var he=oe.type,ue=oe.details,ge=oe.response,Re=oe.fatal,Ae=oe.context,rt=oe.frag;if(ue===ee.ErrorDetails.MANIFEST_LOAD_ERROR||ue===ee.ErrorDetails.MANIFEST_LOAD_TIMEOUT||ue===ee.ErrorDetails.FRAG_LOAD_ERROR||ue===ee.ErrorDetails.FRAG_LOAD_TIMEOUT||ue===ee.ErrorDetails.LEVEL_LOAD_ERROR||ue===ee.ErrorDetails.LEVEL_LOAD_TIMEOUT){var Ze=rt&&rt.url||Ae&&Ae.url||"";se("requestfailed",{request_error:ue,request_url:Ze,request_hostname:r(Ze),request_type:ue===ee.ErrorDetails.FRAG_LOAD_ERROR||ue===ee.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:ge&&ge.code,request_error_text:ge&&ge.text})}Re&&se("error",{player_error_code:he,player_error_message:ue})};X.on(ee.Events.ERROR,Se);var Je=function(pe,oe){var he=oe.frag,ue=he&&he._url||"";se("requestcanceled",{request_event_type:pe,request_url:ue,request_type:"media",request_hostname:r(ue)})};X.on(ee.Events.FRAG_LOAD_EMERGENCY_ABORTED,Je);var Ge=function(pe,oe){var he=oe.level,ue=X.levels[he];if(ue&&ue.attrs&&ue.attrs.BANDWIDTH){var ge,Re=ue.attrs.BANDWIDTH,Ae=parseFloat(ue.attrs["FRAME-RATE"]);isNaN(Ae)||(ge=Ae),Re?se("renditionchange",{video_source_fps:ge,video_source_bitrate:Re,video_source_width:ue.width,video_source_height:ue.height}):ce.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};X.on(ee.Events.LEVEL_SWITCHED,Ge),X._stopMuxMonitor=function(){X.off(ee.Events.MANIFEST_LOADED,le),X.off(ee.Events.LEVEL_LOADED,xe),X.off(ee.Events.AUDIO_TRACK_LOADED,Ye),X.off(ee.Events.FRAG_LOADED,$e),X.off(ee.Events.FRAG_CHANGED,yt),X.off(ee.Events.ERROR,Se),X.off(ee.Events.FRAG_LOAD_EMERGENCY_ABORTED,Je),X.off(ee.Events.LEVEL_SWITCHED,Ge),X.off(ee.Events.DESTROYING,X._stopMuxMonitor),delete X._stopMuxMonitor},X.on(ee.Events.DESTROYING,X._stopMuxMonitor)}else ce.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,H.hlsjs,{},H.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var H;this.hlsjs&&((H=this.hlsjs)&&typeof H._stopMuxMonitor=="function"&&H._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(H){H.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=H.dashjs,function(Q,J,X){var ee=Q.log;if(X&&X.on){var ce=function(Se,Je){return Q.emit(J,Se,Je)},ye=function(Se){var Je=Se.type,Ge=(Se.data||{}).url;ce("requestcompleted",{request_event_type:Je,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:r(Ge)})};X.on("manifestLoaded",ye);var ve={},se=function(Se){var Je=Se.type,Ge=Se.fragmentModel,pe=(Se.chunk||{}).mediaInfo||{},oe=pe.type,he=pe.bitrateList,ue={};(he=he||[]).forEach(function(dt,He){ue[He]={},ue[He].width=dt.width,ue[He].height=dt.height,ue[He].bitrate=dt.bandwidth,ue[He].attrs={}}),oe==="video"?ve.video=ue:oe==="audio"?ve.audio=ue:ve.media=ue;var ge=k(Ge,X),Re=ge.requestStart,Ae=ge.requestResponseStart,rt=ge.requestResponseEnd,Ze=ge.requestResponseHeaders,ut=ge.requestMediaDuration,ft=ge.requestHostname;ce("requestcompleted",{request_event_type:Je,request_start:Re,request_response_start:Ae,request_response_end:rt,request_bytes_loaded:-1,request_type:oe+"_init",request_response_headers:Ze,request_hostname:ft,request_media_duration:ut,request_rendition_lists:ve})};X.on("initFragmentLoaded",se);var le=function(Se){var Je=Se.type,Ge=Se.fragmentModel,pe=Se.chunk||{},oe=pe.mediaInfo,he=pe.start,ue=(oe||{}).type,ge=k(Ge,X),Re=ge.requestStart,Ae=ge.requestResponseStart,rt=ge.requestResponseEnd,Ze=ge.requestBytesLoaded,ut=ge.requestResponseHeaders,ft=ge.requestMediaDuration,dt=ge.requestHostname,He=B(ue,X),mr=He.currentLevel,pr=He.renditionWidth,ct=He.renditionHeight,kt=He.renditionBitrate;ce("requestcompleted",{request_event_type:Je,request_start:Re,request_response_start:Ae,request_response_end:rt,request_bytes_loaded:Ze,request_type:ue,request_response_headers:ut,request_hostname:dt,request_media_start_time:he,request_media_duration:ft,request_current_level:mr,request_labeled_bitrate:kt,request_video_width:pr,request_video_height:ct})};X.on("mediaFragmentLoaded",le);var xe={video:void 0,audio:void 0,totalBitrate:void 0},Ye=function(){if(xe.video&&typeof xe.video.bitrate=="number"){if(xe.video.width&&xe.video.height){var Se=xe.video.bitrate;return xe.audio&&typeof xe.audio.bitrate=="number"&&(Se+=xe.audio.bitrate),Se!==xe.totalBitrate?(xe.totalBitrate=Se,{video_source_bitrate:Se,video_source_height:xe.video.height,video_source_width:xe.video.width}):void 0}ee.warn("have bitrate info for video but missing width/height")}},$e=function(Se,Je,Ge){if(typeof Se.newQuality=="number"){var pe=Se.mediaType;if(pe==="audio"||pe==="video"){var oe=X.getBitrateInfoListFor(pe).find(function(ue){return ue.qualityIndex===Se.newQuality});if(oe&&typeof oe.bitrate=="number"){xe[pe]=oe;var he=Ye();he&&ce("renditionchange",he)}else ee.warn("missing bitrate info for ".concat(pe))}}else ee.warn("missing evt.newQuality in qualityChangeRendered event",Se)};X.on("qualityChangeRendered",$e);var yt=function(Se){var Je=Se.error,Ge=Se.event,pe=(Ge=Ge||{}).request||{},oe=_().event&&_().event.currentTarget||{};ce("requestfailed",{request_error:Je+"_"+Ge.id+"_"+pe.type,request_url:Ge.url,request_hostname:r(Ge.url),request_type:pe.mediaType,request_error_code:oe.status,request_error_type:oe.statusText})};X.on("error",yt),X._stopMuxMonitor=function(){X.off("manifestLoaded",ye),X.off("initFragmentLoaded",se),X.off("mediaFragmentLoaded",le),X.off("qualityChangeRendered",$e),X.off("error",yt),delete X._stopMuxMonitor}}else ee.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,H.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var H;this.dashjs&&((H=this.dashjs)&&typeof H._stopMuxMonitor=="function"&&H._stopMuxMonitor(),this.dashjs=void 0)}}],F&&Fr(C.prototype,F),N&&Fr(C,N),Object.defineProperty(C,"prototype",{writable:!1}),V}(z),Di=Si,Ai=O(153),Ft=O.n(Ai);function hr(w){return hr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(C){return typeof C}:function(C){return C&&typeof Symbol=="function"&&C.constructor===Symbol&&C!==Symbol.prototype?"symbol":typeof C},hr(w)}function wr(w,C){return function(F){if(Array.isArray(F))return F}(w)||function(F,N){var K=F==null?null:typeof Symbol!="undefined"&&F[Symbol.iterator]||F["@@iterator"];if(K!=null){var V,H,Q=[],J=!0,X=!1;try{for(K=K.call(F);!(J=(V=K.next()).done)&&(Q.push(V.value),!N||Q.length!==N);J=!0);}catch(ee){X=!0,H=ee}finally{try{J||K.return==null||K.return()}finally{if(X)throw H}}return Q}}(w,C)||function(F,N){if(F){if(typeof F=="string")return kr(F,N);var K=Object.prototype.toString.call(F).slice(8,-1);return K==="Object"&&F.constructor&&(K=F.constructor.name),K==="Map"||K==="Set"?Array.from(F):K==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(K)?kr(F,N):void 0}}(w,C)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
4
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function kr(w,C){(C==null||C>w.length)&&(C=w.length);for(var F=0,N=new Array(C);F<C;F++)N[F]=w[F];return N}var _t,Li=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],_i={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};_()&&_().WeakMap&&(_t=new WeakMap);var bi="#EXT-X-TARGETDURATION",Oi="#EXT-X-PART-INF",Ri="#EXT-X-SERVER-CONTROL",Ii="#EXTINF",Pi="#EXT-X-PROGRAM-DATE-TIME",Ci="#EXT-X-VERSION",Mi="#EXT-X-SESSION-DATA",Jt=function(w){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(w),this.manifest};Jt.prototype.process=function(w){var C;for(this.buffer+=w,C=this.buffer.indexOf(`
|
|
5
|
+
`);C>-1;C=this.buffer.indexOf(`
|
|
6
|
+
`))this.processLine(this.buffer.substring(0,C)),this.buffer=this.buffer.substring(C+1)},Jt.prototype.processLine=function(w){var C=w.indexOf(":"),F=Bi(w,C),N=F[0],K=F.length===2?gr(F[1]):void 0;if(N[0]!=="#")this.currentUri.uri=N,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(N){case bi:if(!isFinite(K)||K<0)return;this.manifest.targetDuration=K,this.setHoldBack();break;case Oi:vr(this.manifest,F),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case Ri:vr(this.manifest,F),this.setHoldBack();break;case Ii:K===0?this.currentUri.duration=.01:K>0&&(this.currentUri.duration=K);break;case Pi:var V=K,H=new Date(V);this.manifest.dateTimeString||(this.manifest.dateTimeString=V,this.manifest.dateTimeObject=H),this.currentUri.dateTimeString=V,this.currentUri.dateTimeObject=H;break;case Ci:vr(this.manifest,F);break;case Mi:var Q=Ui(F[1]),J=a(Q);i()(this.manifest.sessionData,J)}},Jt.prototype.setHoldBack=function(){var w=this.manifest,C=w.serverControl,F=w.targetDuration,N=w.partTargetDuration;if(C){var K="holdBack",V="partHoldBack",H=F&&3*F,Q=N&&2*N;F&&!C.hasOwnProperty(K)&&(C[K]=H),H&&C[K]<H&&(C[K]=H),N&&!C.hasOwnProperty(V)&&(C[V]=3*N),N&&C[V]<Q&&(C[V]=Q)}};var vr=function(w,C){var F,N=Br(C[0].replace("#EXT-X-",""));ki(C[1])?(F={},F=i()(wi(C[1]),F)):F=gr(C[1]),w[N]=F},Br=function(w){return w.toLowerCase().replace(/-(\w)/g,function(C){return C[1].toUpperCase()})},gr=function(w){if(w.toLowerCase()==="yes"||w.toLowerCase()==="no")return w.toLowerCase()==="yes";var C=w.indexOf(":")!==-1?w:parseFloat(w);return isNaN(C)?w:C},Fi=function(w){var C={},F=w.split("=");return F.length>1&&(C[Br(F[0])]=gr(F[1])),C},wi=function(w){for(var C=w.split(","),F={},N=0;C.length>N;N++){var K=C[N],V=Fi(K);F=i()(V,F)}return F},ki=function(w){return w.indexOf("=")>-1},Bi=function(w,C){return C===-1?[w]:[w.substring(0,C),w.substring(C+1)]},Ui=function(w){var C={};if(w){var F=w.search(",");return[w.slice(0,F),w.slice(F+1)].forEach(function(N,K){for(var V=N.replace(/['"]+/g,"").split("="),H=0;H<V.length;H++)V[H]==="DATA-ID"&&(C["DATA-ID"]=V[1-H]),V[H]==="VALUE"&&(C.VALUE=V[1-H])}),{data:C}}},Ni=Jt,Ki={safeCall:function(w,C,F,N){var K=N;if(w&&typeof w[C]=="function")try{K=w[C].apply(w,F)}catch(V){e.info("safeCall error",V)}return K},safeIncrement:t,getComputedStyle:function(w,C){var F;if(w&&C&&_()&&typeof _().getComputedStyle=="function")return _t&&_t.has(w)&&(F=_t.get(w)),F||(F=_().getComputedStyle(w,null),_t&&_t.set(w,F)),F.getPropertyValue(C)},secondsToMs:function(w){return Math.floor(1e3*w)},assign:i(),headersStringToObject:u,extractHostnameAndDomain:o,extractHostname:r,manifestParser:Ni,generateShortID:x,generateUUID:y,now:h.now},ji={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"};function Wi(w,C){return function(F){if(Array.isArray(F))return F}(w)||function(F,N){var K=F==null?null:typeof Symbol!="undefined"&&F[Symbol.iterator]||F["@@iterator"];if(K!=null){var V,H,Q=[],J=!0,X=!1;try{for(K=K.call(F);!(J=(V=K.next()).done)&&(Q.push(V.value),!N||Q.length!==N);J=!0);}catch(ee){X=!0,H=ee}finally{try{J||K.return==null||K.return()}finally{if(X)throw H}}return Q}}(w,C)||function(F,N){if(F){if(typeof F=="string")return Ur(F,N);var K=Object.prototype.toString.call(F).slice(8,-1);return K==="Object"&&F.constructor&&(K=F.constructor.name),K==="Map"||K==="Set"?Array.from(F):K==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(K)?Ur(F,N):void 0}}(w,C)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
7
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Ur(w,C){(C==null||C>w.length)&&(C=w.length);for(var F=0,N=new Array(C);F<C;F++)N[F]=w[F];return N}var tt={},wt=function w(C){var F=arguments;typeof C=="string"?w.hasOwnProperty(C)?_().setTimeout(function(){F=Array.prototype.splice.call(F,1),w[C].apply(null,F)},0):e.warn("`"+C+"` is an unknown task"):typeof C=="function"?_().setTimeout(function(){C(w)},0):e.warn("`"+C+"` is invalid.")},Gi={loaded:h.now(),NAME:"mux-embed",VERSION:"4.14.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(w,C){return function(F,N,K){var V=wr(E(N),3),H=V[0],Q=V[1],J=V[2],X=F.log,ee=F.utils.getComputedStyle,ce=F.utils.secondsToMs;if(!H)return X.error("No element was found with the `"+Q+"` query selector.");if(J!=="video"&&J!=="audio")return X.error("The element of `"+Q+"` was not a media element.");H.mux&&(H.mux.destroy(),delete H.mux,X.warn("Already monitoring this video element, replacing existing event listeners")),(K=i()({automaticErrorTracking:!0},K)).data=i()({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:F.VERSION},K.data),K.getPlayheadTime=function(){return ce(H.currentTime)},K.getStateData=function(){var ve=this.hlsjs&&this.hlsjs.url,se=this.dashjs&&hr(this.dashjs.getSource==="function")&&this.dashjs.getSource(),le={player_is_paused:H.paused,player_playhead_time:ce(H.currentTime),player_width:parseInt(ee(H,"width")),player_height:parseInt(ee(H,"height")),player_autoplay_on:H.autoplay,player_preload_on:H.preload,player_language_code:H.lang,player_is_fullscreen:Ft()&&!!(Ft().fullscreenElement||Ft().webkitFullscreenElement||Ft().mozFullScreenElement||Ft().msFullscreenElement),video_poster_url:H.poster,video_source_url:ve||se||H.currentSrc,video_source_duration:ce(H.duration),video_source_height:H.videoHeight,video_source_width:H.videoWidth},xe=K.getPlayheadTime();if(H.getStartDate&&xe>0){var Ye=H.getStartDate();if(Ye&&typeof Ye.getTime=="function"&&Ye.getTime()){var $e=Ye.getTime();if(le.player_program_time=$e+xe,H.seekable.length>0){var yt=$e+H.seekable.end(H.seekable.length-1);le.player_live_edge_program_time=yt}}}return le},H.mux=H.mux||{},H.mux.deleted=!1,H.mux.emit=function(ve,se){F.emit(Q,ve,se)};var ye=function(){X.error("The monitor for this video element has already been destroyed.")};H.mux.destroy=function(){Object.keys(H.mux.listeners).forEach(function(ve){H.removeEventListener(ve,H.mux.listeners[ve],!1)}),delete H.mux.listeners,H.mux.destroy=ye,H.mux.swapElement=ye,H.mux.emit=ye,H.mux.addHLSJS=ye,H.mux.addDashJS=ye,H.mux.removeHLSJS=ye,H.mux.removeDashJS=ye,H.mux.deleted=!0,F.emit(Q,"destroy")},H.mux.swapElement=function(ve){var se=wr(E(ve),3),le=se[0],xe=se[1],Ye=se[2];return le?Ye!=="video"&&Ye!=="audio"?F.log.error("The element of `"+xe+"` was not a media element."):(le.muxId=H.muxId,delete H.muxId,le.mux=le.mux||{},le.mux.listeners=i()({},H.mux.listeners),delete H.mux.listeners,Object.keys(le.mux.listeners).forEach(function($e){H.removeEventListener($e,le.mux.listeners[$e],!1),le.addEventListener($e,le.mux.listeners[$e],!1)}),le.mux.swapElement=H.mux.swapElement,le.mux.destroy=H.mux.destroy,delete H.mux,void(H=le)):F.log.error("No element was found with the `"+xe+"` query selector.")},H.mux.addHLSJS=function(ve){F.addHLSJS(Q,ve)},H.mux.addDashJS=function(ve){F.addDashJS(Q,ve)},H.mux.removeHLSJS=function(){F.removeHLSJS(Q)},H.mux.removeDashJS=function(){F.removeDashJS(Q)},F.init(Q,K),F.emit(Q,"playerready"),H.paused||(F.emit(Q,"play"),H.readyState>2&&F.emit(Q,"playing")),H.mux.listeners={},Li.forEach(function(ve){(ve!=="error"||K.automaticErrorTracking)&&(H.mux.listeners[ve]=function(){var se={};if(ve==="error"){if(!H.error||H.error.code===1)return;se.player_error_code=H.error.code,se.player_error_message=_i[H.error.code]||H.error.message}F.emit(Q,ve,se)},H.addEventListener(ve,H.mux.listeners[ve],!1))})}(wt,w,C)},destroyMonitor:function(w){var C=Wi(E(w),1)[0];C&&C.mux&&typeof C.mux.destroy=="function"?C.mux.destroy():e.error("A video element monitor for `"+w+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(w,C){var F=D(w);tt[F]?tt[F].addHLSJS(C):e.error("A monitor for `"+F+"` has not been initialized.")},addDashJS:function(w,C){var F=D(w);tt[F]?tt[F].addDashJS(C):e.error("A monitor for `"+F+"` has not been initialized.")},removeHLSJS:function(w){var C=D(w);tt[C]?tt[C].removeHLSJS():e.error("A monitor for `"+C+"` has not been initialized.")},removeDashJS:function(w){var C=D(w);tt[C]?tt[C].removeDashJS():e.error("A monitor for `"+C+"` has not been initialized.")},init:function(w,C){s()&&C&&C.respectDoNotTrack&&e.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var F=D(w);tt[F]=new Di(wt,F,C)},emit:function(w,C,F){var N=D(w);tt[N]?(tt[N].emit(C,F),C==="destroy"&&delete tt[N]):e.error("A monitor for `"+N+"` has not been initialized.")},checkDoNotTrack:s,log:e,utils:Ki,events:ji,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(wt,Gi),_()!==void 0&&typeof _().addEventListener=="function"&&_().addEventListener("pagehide",function(w){w.persisted||(wt.WINDOW_UNLOADING=!0)},!1);var Hi=wt},655:function(A,M,O){var b,_;function y(x){return y=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},y(x);}(function(x){var D=!1;if((_=typeof(b=x)=="function"?b.call(M,O,M,A):b)===void 0||(A.exports=_),D=!0,y(M)==="object"&&(A.exports=x(),D=!0),!D){var E=window.Cookies,m=window.Cookies=x();m.noConflict=function(){return window.Cookies=E,m}}})(function(){var x=function(){for(var D=0,E={};D<arguments.length;D++){var m=arguments[D];for(var p in m)E[p]=m[p]}return E};return function D(E){function m(p,f,e){var s;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(e=x({path:"/"},m.defaults,e)).expires=="number"){var h=new Date;h.setMilliseconds(h.getMilliseconds()+864e5*e.expires),e.expires=h}try{s=JSON.stringify(f),/^[\{\[]/.test(s)&&(f=s)}catch{}return f=E.write?E.write(f,p):encodeURIComponent(String(f)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),p=(p=(p=encodeURIComponent(String(p))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[p,"=",f,e.expires?"; expires="+e.expires.toUTCString():"",e.path?"; path="+e.path:"",e.domain?"; domain="+e.domain:"",e.secure?"; secure":""].join("")}p||(s={});for(var g=document.cookie?document.cookie.split("; "):[],i=/(%[0-9A-Z]{2})+/g,r=0;r<g.length;r++){var o=g[r].split("="),c=o.slice(1).join("=");c.charAt(0)==='"'&&(c=c.slice(1,-1));try{var t=o[0].replace(i,decodeURIComponent);if(c=E.read?E.read(c,t):E(c,t)||c.replace(i,decodeURIComponent),this.json)try{c=JSON.parse(c)}catch{}if(p===t){s=c;break}p||(s[t]=c)}catch{}}return s}}return m.set=m,m.get=function(p){return m.call(m,p)},m.getJSON=function(){return m.apply({json:!0},[].slice.call(arguments))},m.defaults={},m.remove=function(p,f){m(p,"",x(f,{expires:-1}))},m.withConverter=D,m}(function(){})})},153:function(A,M,O){var b,_=O.g!==void 0?O.g:typeof window!="undefined"?window:{},y=O(558);typeof document!="undefined"?b=document:(b=_["__GLOBAL_DOCUMENT_CACHE@4"])||(b=_["__GLOBAL_DOCUMENT_CACHE@4"]=y),A.exports=b},48:function(A,M,O){var b;b=typeof window!="undefined"?window:O.g!==void 0?O.g:typeof self!="undefined"?self:{},A.exports=b},678:function(A){var M=9007199254740991,O="[object Arguments]",b="[object Function]",_="[object GeneratorFunction]",y=/^(?:0|[1-9]\d*)$/;function x(S,T,I){switch(I.length){case 0:return S.call(T);case 1:return S.call(T,I[0]);case 2:return S.call(T,I[0],I[1]);case 3:return S.call(T,I[0],I[1],I[2])}return S.apply(T,I)}var D,E,m=Object.prototype,p=m.hasOwnProperty,f=m.toString,e=m.propertyIsEnumerable,s=(D=Object.keys,E=Object,function(S){return D(E(S))}),h=Math.max,g=!e.call({valueOf:1},"valueOf");function i(S,T){var I=n(S)||function(W){return function(G){return function(z){return!!z&&typeof z=="object"}(G)&&u(G)}(W)&&p.call(W,"callee")&&(!e.call(W,"callee")||f.call(W)==O)}(S)?function(W,G){for(var z=-1,Y=Array(W);++z<W;)Y[z]=G(z);return Y}(S.length,String):[],k=I.length,B=!!k;for(var U in S)!T&&!p.call(S,U)||B&&(U=="length"||o(U,k))||I.push(U);return I}function r(S,T,I){var k=S[T];p.call(S,T)&&t(k,I)&&(I!==void 0||T in S)||(S[T]=I)}function o(S,T){return!!(T=T==null?M:T)&&(typeof S=="number"||y.test(S))&&S>-1&&S%1==0&&S<T}function c(S){var T=S&&S.constructor;return S===(typeof T=="function"&&T.prototype||m)}function t(S,T){return S===T||S!=S&&T!=T}var n=Array.isArray;function u(S){return S!=null&&function(T){return typeof T=="number"&&T>-1&&T%1==0&&T<=M}(S.length)&&!function(T){var I=a(T)?f.call(T):"";return I==b||I==_}(S)}function a(S){var T=typeof S;return!!S&&(T=="object"||T=="function")}var d,v=(d=function(S,T){if(g||c(T)||u(T))(function(k,B,U,W){U||(U={});for(var G=-1,z=B.length;++G<z;){var Y=B[G],$=W?W(U[Y],k[Y],Y,U,k):void 0;r(U,Y,$===void 0?k[Y]:$)}})(T,function(k){return u(k)?i(k):function(B){if(!c(B))return s(B);var U=[];for(var W in Object(B))p.call(B,W)&&W!="constructor"&&U.push(W);return U}(k)}(T),S);else for(var I in T)p.call(T,I)&&r(S,I,T[I])},function(S,T){return T=h(T===void 0?S.length-1:T,0),function(){for(var I=arguments,k=-1,B=h(I.length-T,0),U=Array(B);++k<B;)U[k]=I[T+k];k=-1;for(var W=Array(T+1);++k<T;)W[k]=I[k];return W[T]=U,x(S,this,W)}}(function(S,T){var I=-1,k=T.length,B=k>1?T[k-1]:void 0,U=k>2?T[2]:void 0;for(B=d.length>3&&typeof B=="function"?(k--,B):void 0,U&&function(G,z,Y){if(!a(Y))return!1;var $=typeof z;return!!($=="number"?u(Y)&&o(z,Y.length):$=="string"&&z in Y)&&t(Y[z],G)}(T[0],T[1],U)&&(B=k<3?void 0:B,k=1),S=Object(S);++I<k;){var W=T[I];W&&d(S,W,I,B)}return S}));A.exports=v},640:function(A,M,O){var b,_;(function(y,x){"use strict";b=function(){var D=function(){},E="undefined",m=typeof window!==E&&typeof window.navigator!==E&&/Trident\/|MSIE /.test(window.navigator.userAgent),p=["trace","debug","info","warn","error"];function f(n,u){var a=n[u];if(typeof a.bind=="function")return a.bind(n);try{return Function.prototype.bind.call(a,n)}catch{return function(){return Function.prototype.apply.apply(a,[n,arguments])}}}function e(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function s(n){return n==="debug"&&(n="log"),typeof console!==E&&(n==="trace"&&m?e:console[n]!==void 0?f(console,n):console.log!==void 0?f(console,"log"):D)}function h(n,u){for(var a=0;a<p.length;a++){var d=p[a];this[d]=a<n?D:this.methodFactory(d,n,u)}this.log=this.debug}function g(n,u,a){return function(){typeof console!==E&&(h.call(this,u,a),this[n].apply(this,arguments))}}function i(n,u,a){return s(n)||g.apply(this,arguments)}function r(n,u,a){var d,v=this;u=u==null?"WARN":u;var S="loglevel";function T(U){var W=(p[U]||"silent").toUpperCase();if(typeof window!==E&&S){try{return void(window.localStorage[S]=W)}catch{}try{window.document.cookie=encodeURIComponent(S)+"="+W+";"}catch{}}}function I(){var U;if(typeof window!==E&&S){try{U=window.localStorage[S]}catch{}if(typeof U===E)try{var W=window.document.cookie,G=W.indexOf(encodeURIComponent(S)+"=");G!==-1&&(U=/^([^;]+)/.exec(W.slice(G))[1])}catch{}return v.levels[U]===void 0&&(U=void 0),U}}function k(){if(typeof window!==E&&S){try{return void window.localStorage.removeItem(S)}catch{}try{window.document.cookie=encodeURIComponent(S)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof n=="string"?S+=":"+n:typeof n=="symbol"&&(S=void 0),v.name=n,v.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},v.methodFactory=a||i,v.getLevel=function(){return d},v.setLevel=function(U,W){if(typeof U=="string"&&v.levels[U.toUpperCase()]!==void 0&&(U=v.levels[U.toUpperCase()]),!(typeof U=="number"&&U>=0&&U<=v.levels.SILENT))throw"log.setLevel() called with invalid level: "+U;if(d=U,W!==!1&&T(U),h.call(v,U,n),typeof console===E&&U<v.levels.SILENT)return"No console available for logging"},v.setDefaultLevel=function(U){u=U,I()||v.setLevel(U,!1)},v.resetLevel=function(){v.setLevel(u,!1),k()},v.enableAll=function(U){v.setLevel(v.levels.TRACE,U)},v.disableAll=function(U){v.setLevel(v.levels.SILENT,U)};var B=I();B==null&&(B=u),v.setLevel(B,!1)}var o=new r,c={};o.getLogger=function(n){if(typeof n!="symbol"&&typeof n!="string"||n==="")throw new TypeError("You must supply a name when creating a logger.");var u=c[n];return u||(u=c[n]=new r(n,o.getLevel(),o.methodFactory)),u};var t=typeof window!==E?window.log:void 0;return o.noConflict=function(){return typeof window!==E&&window.log===o&&(window.log=t),o},o.getLoggers=function(){return c},o.default=o,o},(_=typeof b=="function"?b.call(M,O,M,A):b)===void 0||(A.exports=_)})()},375:function(A,M){"use strict";var O=Object.prototype.hasOwnProperty;function b(y){try{return decodeURIComponent(y.replace(/\+/g," "))}catch{return null}}function _(y){try{return encodeURIComponent(y)}catch{return null}}M.stringify=function(y,x){x=x||"";var D,E,m=[];for(E in typeof x!="string"&&(x="?"),y)if(O.call(y,E)){if((D=y[E])||D!=null&&!isNaN(D)||(D=""),E=_(E),D=_(D),E===null||D===null)continue;m.push(E+"="+D)}return m.length?x+m.join("&"):""},M.parse=function(y){for(var x,D=/([^=?#&]+)=?([^&]*)/g,E={};x=D.exec(y);){var m=b(x[1]),p=b(x[2]);m===null||p===null||m in E||(E[m]=p)}return E}},558:function(){}},P={};function L(A){var M=P[A];if(M!==void 0)return M.exports;var O=P[A]={exports:{}};return l[A].call(O.exports,O,O.exports,L),O.exports}return L.n=function(A){var M=A&&A.__esModule?function(){return A.default}:function(){return A};return L.d(M,{a:M}),M},L.d=function(A,M){for(var O in M)L.o(M,O)&&!L.o(A,O)&&Object.defineProperty(A,O,{enumerable:!0,get:M[O]})},L.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),L.o=function(A,M){return Object.prototype.hasOwnProperty.call(A,M)},L(80)}()},typeof rr=="object"&&typeof Sr=="object"?Sr.exports=R():typeof rr=="object"?rr.mux=R():j.mux=R()})()});var ir=Kr((Kt,Dr)=>{typeof window!="undefined"&&function(R,l){typeof Kt=="object"&&typeof Dr=="object"?Dr.exports=l():typeof define=="function"&&define.amd?define([],l):typeof Kt=="object"?Kt.Hls=l():R.Hls=l()}(Kt,function(){return function(j){var R={};function l(P){if(R[P])return R[P].exports;var L=R[P]={i:P,l:!1,exports:{}};return j[P].call(L.exports,L,L.exports,l),L.l=!0,L.exports}return l.m=j,l.c=R,l.d=function(P,L,A){l.o(P,L)||Object.defineProperty(P,L,{enumerable:!0,get:A})},l.r=function(P){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(P,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(P,"__esModule",{value:!0})},l.t=function(P,L){if(L&1&&(P=l(P)),L&8||L&4&&typeof P=="object"&&P&&P.__esModule)return P;var A=Object.create(null);if(l.r(A),Object.defineProperty(A,"default",{enumerable:!0,value:P}),L&2&&typeof P!="string")for(var M in P)l.d(A,M,function(O){return P[O]}.bind(null,M));return A},l.n=function(P){var L=P&&P.__esModule?function(){return P.default}:function(){return P};return l.d(L,"a",L),L},l.o=function(P,L){return Object.prototype.hasOwnProperty.call(P,L)},l.p="/dist/",l(l.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(j,R,l){"use strict";var P=Object.prototype.hasOwnProperty,L="~";function A(){}Object.create&&(A.prototype=Object.create(null),new A().__proto__||(L=!1));function M(y,x,D){this.fn=y,this.context=x,this.once=D||!1}function O(y,x,D,E,m){if(typeof D!="function")throw new TypeError("The listener must be a function");var p=new M(D,E||y,m),f=L?L+x:x;return y._events[f]?y._events[f].fn?y._events[f]=[y._events[f],p]:y._events[f].push(p):(y._events[f]=p,y._eventsCount++),y}function b(y,x){--y._eventsCount===0?y._events=new A:delete y._events[x]}function _(){this._events=new A,this._eventsCount=0}_.prototype.eventNames=function(){var x=[],D,E;if(this._eventsCount===0)return x;for(E in D=this._events)P.call(D,E)&&x.push(L?E.slice(1):E);return Object.getOwnPropertySymbols?x.concat(Object.getOwnPropertySymbols(D)):x},_.prototype.listeners=function(x){var D=L?L+x:x,E=this._events[D];if(!E)return[];if(E.fn)return[E.fn];for(var m=0,p=E.length,f=new Array(p);m<p;m++)f[m]=E[m].fn;return f},_.prototype.listenerCount=function(x){var D=L?L+x:x,E=this._events[D];return E?E.fn?1:E.length:0},_.prototype.emit=function(x,D,E,m,p,f){var e=L?L+x:x;if(!this._events[e])return!1;var s=this._events[e],h=arguments.length,g,i;if(s.fn){switch(s.once&&this.removeListener(x,s.fn,void 0,!0),h){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,D),!0;case 3:return s.fn.call(s.context,D,E),!0;case 4:return s.fn.call(s.context,D,E,m),!0;case 5:return s.fn.call(s.context,D,E,m,p),!0;case 6:return s.fn.call(s.context,D,E,m,p,f),!0}for(i=1,g=new Array(h-1);i<h;i++)g[i-1]=arguments[i];s.fn.apply(s.context,g)}else{var r=s.length,o;for(i=0;i<r;i++)switch(s[i].once&&this.removeListener(x,s[i].fn,void 0,!0),h){case 1:s[i].fn.call(s[i].context);break;case 2:s[i].fn.call(s[i].context,D);break;case 3:s[i].fn.call(s[i].context,D,E);break;case 4:s[i].fn.call(s[i].context,D,E,m);break;default:if(!g)for(o=1,g=new Array(h-1);o<h;o++)g[o-1]=arguments[o];s[i].fn.apply(s[i].context,g)}}return!0},_.prototype.on=function(x,D,E){return O(this,x,D,E,!1)},_.prototype.once=function(x,D,E){return O(this,x,D,E,!0)},_.prototype.removeListener=function(x,D,E,m){var p=L?L+x:x;if(!this._events[p])return this;if(!D)return b(this,p),this;var f=this._events[p];if(f.fn)f.fn===D&&(!m||f.once)&&(!E||f.context===E)&&b(this,p);else{for(var e=0,s=[],h=f.length;e<h;e++)(f[e].fn!==D||m&&!f[e].once||E&&f[e].context!==E)&&s.push(f[e]);s.length?this._events[p]=s.length===1?s[0]:s:b(this,p)}return this},_.prototype.removeAllListeners=function(x){var D;return x?(D=L?L+x:x,this._events[D]&&b(this,D)):(this._events=new A,this._eventsCount=0),this},_.prototype.off=_.prototype.removeListener,_.prototype.addListener=_.prototype.on,_.prefixed=L,_.EventEmitter=_,j.exports=_},"./node_modules/url-toolkit/src/url-toolkit.js":function(j,R,l){(function(P){var L=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,A=/^(?=([^\/?#]*))\1([^]*)$/,M=/(?:\/|^)\.(?=\/)/g,O=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,b={buildAbsoluteURL:function(_,y,x){if(x=x||{},_=_.trim(),y=y.trim(),!y){if(!x.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 E=b.parseURL(y);if(!E)throw new Error("Error trying to parse relative URL.");if(E.scheme)return x.alwaysNormalize?(E.path=b.normalizePath(E.path),b.buildURLFromParts(E)):y;var m=b.parseURL(_);if(!m)throw new Error("Error trying to parse base URL.");if(!m.netLoc&&m.path&&m.path[0]!=="/"){var p=A.exec(m.path);m.netLoc=p[1],m.path=p[2]}m.netLoc&&!m.path&&(m.path="/");var f={scheme:m.scheme,netLoc:E.netLoc,path:null,params:E.params,query:E.query,fragment:E.fragment};if(!E.netLoc&&(f.netLoc=m.netLoc,E.path[0]!=="/"))if(!E.path)f.path=m.path,E.params||(f.params=m.params,E.query||(f.query=m.query));else{var e=m.path,s=e.substring(0,e.lastIndexOf("/")+1)+E.path;f.path=b.normalizePath(s)}return f.path===null&&(f.path=x.alwaysNormalize?b.normalizePath(E.path):E.path),b.buildURLFromParts(f)},parseURL:function(_){var y=L.exec(_);return y?{scheme:y[1]||"",netLoc:y[2]||"",path:y[3]||"",params:y[4]||"",query:y[5]||"",fragment:y[6]||""}:null},normalizePath:function(_){for(_=_.split("").reverse().join("").replace(M,"");_.length!==(_=_.replace(O,"")).length;);return _.split("").reverse().join("")},buildURLFromParts:function(_){return _.scheme+_.netLoc+_.path+_.params+_.query+_.fragment}};j.exports=b})(this)},"./node_modules/webworkify-webpack/index.js":function(j,R,l){function P(x){var D={};function E(p){if(D[p])return D[p].exports;var f=D[p]={i:p,l:!1,exports:{}};return x[p].call(f.exports,f,f.exports,E),f.l=!0,f.exports}E.m=x,E.c=D,E.i=function(p){return p},E.d=function(p,f,e){E.o(p,f)||Object.defineProperty(p,f,{configurable:!1,enumerable:!0,get:e})},E.r=function(p){Object.defineProperty(p,"__esModule",{value:!0})},E.n=function(p){var f=p&&p.__esModule?function(){return p.default}:function(){return p};return E.d(f,"a",f),f},E.o=function(p,f){return Object.prototype.hasOwnProperty.call(p,f)},E.p="/",E.oe=function(p){throw console.error(p),p};var m=E(E.s=ENTRY_MODULE);return m.default||m}var L="[\\.|\\-|\\+|\\w|/|@]+",A="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+L+").*?\\)";function M(x){return(x+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function O(x){return!isNaN(1*x)}function b(x,D,E){var m={};m[E]=[];var p=D.toString(),f=p.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!f)return m;for(var e=f[1],s=new RegExp("(\\\\n|\\W)"+M(e)+A,"g"),h;h=s.exec(p);)h[3]!=="dll-reference"&&m[E].push(h[3]);for(s=new RegExp("\\("+M(e)+'\\("(dll-reference\\s('+L+'))"\\)\\)'+A,"g");h=s.exec(p);)x[h[2]]||(m[E].push(h[1]),x[h[2]]=l(h[1]).m),m[h[2]]=m[h[2]]||[],m[h[2]].push(h[4]);for(var g=Object.keys(m),i=0;i<g.length;i++)for(var r=0;r<m[g[i]].length;r++)O(m[g[i]][r])&&(m[g[i]][r]=1*m[g[i]][r]);return m}function _(x){var D=Object.keys(x);return D.reduce(function(E,m){return E||x[m].length>0},!1)}function y(x,D){for(var E={main:[D]},m={main:[]},p={main:{}};_(E);)for(var f=Object.keys(E),e=0;e<f.length;e++){var s=f[e],h=E[s],g=h.pop();if(p[s]=p[s]||{},!(p[s][g]||!x[s][g])){p[s][g]=!0,m[s]=m[s]||[],m[s].push(g);for(var i=b(x,x[s][g],s),r=Object.keys(i),o=0;o<r.length;o++)E[r[o]]=E[r[o]]||[],E[r[o]]=E[r[o]].concat(i[r[o]])}}return m}j.exports=function(x,D){D=D||{};var E={main:l.m},m=D.all?{main:Object.keys(E.main)}:y(E,x),p="";Object.keys(m).filter(function(g){return g!=="main"}).forEach(function(g){for(var i=0;m[g][i];)i++;m[g].push(i),E[g][i]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",p=p+"var "+g+" = ("+P.toString().replace("ENTRY_MODULE",JSON.stringify(i))+")({"+m[g].map(function(r){return""+JSON.stringify(r)+": "+E[g][r].toString()}).join(",")+`});
|
|
8
|
+
`}),p=p+"new (("+P.toString().replace("ENTRY_MODULE",JSON.stringify(x))+")({"+m.main.map(function(g){return""+JSON.stringify(g)+": "+E.main[g].toString()}).join(",")+"}))(self);";var f=new window.Blob([p],{type:"text/javascript"});if(D.bare)return f;var e=window.URL||window.webkitURL||window.mozURL||window.msURL,s=e.createObjectURL(f),h=new window.Worker(s);return h.objectURL=s,h}},"./src/config.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"hlsDefaultConfig",function(){return o}),l.d(R,"mergeConfig",function(){return t}),l.d(R,"enableStreamingMode",function(){return n});var P=l("./src/controller/abr-controller.ts"),L=l("./src/controller/audio-stream-controller.ts"),A=l("./src/controller/audio-track-controller.ts"),M=l("./src/controller/subtitle-stream-controller.ts"),O=l("./src/controller/subtitle-track-controller.ts"),b=l("./src/controller/buffer-controller.ts"),_=l("./src/controller/timeline-controller.ts"),y=l("./src/controller/cap-level-controller.ts"),x=l("./src/controller/fps-controller.ts"),D=l("./src/controller/eme-controller.ts"),E=l("./src/controller/cmcd-controller.ts"),m=l("./src/utils/xhr-loader.ts"),p=l("./src/utils/fetch-loader.ts"),f=l("./src/utils/cues.ts"),e=l("./src/utils/mediakeys-helper.ts"),s=l("./src/utils/logger.ts");function h(){return h=Object.assign?Object.assign.bind():function(u){for(var a=1;a<arguments.length;a++){var d=arguments[a];for(var v in d)Object.prototype.hasOwnProperty.call(d,v)&&(u[v]=d[v])}return u},h.apply(this,arguments)}function g(u,a){var d=Object.keys(u);if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(u);a&&(v=v.filter(function(S){return Object.getOwnPropertyDescriptor(u,S).enumerable})),d.push.apply(d,v)}return d}function i(u){for(var a=1;a<arguments.length;a++){var d=arguments[a]!=null?arguments[a]:{};a%2?g(Object(d),!0).forEach(function(v){r(u,v,d[v])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(d)):g(Object(d)).forEach(function(v){Object.defineProperty(u,v,Object.getOwnPropertyDescriptor(d,v))})}return u}function r(u,a,d){return a in u?Object.defineProperty(u,a,{value:d,enumerable:!0,configurable:!0,writable:!0}):u[a]=d,u}var o=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:m.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:P.default,bufferController:b.default,capLevelController:y.default,fpsController:x.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:M.SubtitleStreamController,subtitleTrackController:O.default,timelineController:_.TimelineController,audioStreamController:L.default,audioTrackController:A.default,emeController:D.default,cmcdController:E.default});function c(){return{cueHandler:f.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 t(u,a){if((a.liveSyncDurationCount||a.liveMaxLatencyDurationCount)&&(a.liveSyncDuration||a.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(a.liveMaxLatencyDurationCount!==void 0&&(a.liveSyncDurationCount===void 0||a.liveMaxLatencyDurationCount<=a.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(a.liveMaxLatencyDuration!==void 0&&(a.liveSyncDuration===void 0||a.liveMaxLatencyDuration<=a.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return h({},u,a)}function n(u){var a=u.loader;if(a!==p.default&&a!==m.default)s.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),u.progressive=!1;else{var d=Object(p.fetchSupported)();d&&(u.loader=p.default,u.progressive=!0,u.enableSoftwareAES=!0,s.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/polyfills/number.ts"),L=l("./src/utils/ewma-bandwidth-estimator.ts"),A=l("./src/events.ts"),M=l("./src/utils/buffer-helper.ts"),O=l("./src/errors.ts"),b=l("./src/types/loader.ts"),_=l("./src/utils/logger.ts");function y(E,m){for(var p=0;p<m.length;p++){var f=m[p];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(E,f.key,f)}}function x(E,m,p){return m&&y(E.prototype,m),p&&y(E,p),Object.defineProperty(E,"prototype",{writable:!1}),E}var D=function(){function E(p){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=p;var f=p.config;this.bwEstimator=new L.default(f.abrEwmaSlowVoD,f.abrEwmaFastVoD,f.abrEwmaDefaultEstimate),this.registerListeners()}var m=E.prototype;return m.registerListeners=function(){var f=this.hls;f.on(A.Events.FRAG_LOADING,this.onFragLoading,this),f.on(A.Events.FRAG_LOADED,this.onFragLoaded,this),f.on(A.Events.FRAG_BUFFERED,this.onFragBuffered,this),f.on(A.Events.LEVEL_LOADED,this.onLevelLoaded,this),f.on(A.Events.ERROR,this.onError,this)},m.unregisterListeners=function(){var f=this.hls;f.off(A.Events.FRAG_LOADING,this.onFragLoading,this),f.off(A.Events.FRAG_LOADED,this.onFragLoaded,this),f.off(A.Events.FRAG_BUFFERED,this.onFragBuffered,this),f.off(A.Events.LEVEL_LOADED,this.onLevelLoaded,this),f.off(A.Events.ERROR,this.onError,this)},m.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},m.onFragLoading=function(f,e){var s=e.frag;if(s.type===b.PlaylistLevelType.MAIN&&!this.timer){var h;this.fragCurrent=s,this.partCurrent=(h=e.part)!=null?h:null,this.timer=self.setInterval(this.onCheck,100)}},m.onLevelLoaded=function(f,e){var s=this.hls.config;e.details.live?this.bwEstimator.update(s.abrEwmaSlowLive,s.abrEwmaFastLive):this.bwEstimator.update(s.abrEwmaSlowVoD,s.abrEwmaFastVoD)},m._abandonRulesCheck=function(){var f=this.fragCurrent,e=this.partCurrent,s=this.hls,h=s.autoLevelEnabled,g=s.config,i=s.media;if(!(!f||!i)){var r=e?e.stats:f.stats,o=e?e.duration:f.duration;if(r.aborted){_.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!(!h||i.paused||!i.playbackRate||!i.readyState)){var c=performance.now()-r.loading.start,t=Math.abs(i.playbackRate);if(!(c<=500*o/t)){var n=s.levels,u=s.minAutoLevel,a=n[f.level],d=r.total||Math.max(r.loaded,Math.round(o*a.maxBitrate/8)),v=Math.max(1,r.bwEstimate?r.bwEstimate/8:r.loaded*1e3/c),S=(d-r.loaded)/v,T=i.currentTime,I=(M.BufferHelper.bufferInfo(i,T,g.maxBufferHole).end-T)/t;if(!(I>=2*o/t||S<=I)){var k=Number.POSITIVE_INFINITY,B;for(B=f.level-1;B>u;B--){var U=n[B].maxBitrate;if(k=o*U/(8*.8*v),k<I)break}if(!(k>=S)){var W=this.bwEstimator.getEstimate();_.logger.warn("Fragment "+f.sn+(e?" part "+e.index:"")+" of level "+f.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+B+`
|
|
9
|
+
Current BW estimate: `+(Object(P.isFiniteNumber)(W)?(W/1024).toFixed(3):"Unknown")+` Kb/s
|
|
10
|
+
Estimated load time for current fragment: `+S.toFixed(3)+` s
|
|
11
|
+
Estimated load time for the next fragment: `+k.toFixed(3)+` s
|
|
12
|
+
Time to underbuffer: `+I.toFixed(3)+" s"),s.nextLoadLevel=B,this.bwEstimator.sample(c,r.loaded),this.clearTimer(),f.loader&&(this.fragCurrent=this.partCurrent=null,f.loader.abort()),s.trigger(A.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:f,part:e,stats:r})}}}}}},m.onFragLoaded=function(f,e){var s=e.frag,h=e.part;if(s.type===b.PlaylistLevelType.MAIN&&Object(P.isFiniteNumber)(s.sn)){var g=h?h.stats:s.stats,i=h?h.duration:s.duration;if(this.clearTimer(),this.lastLoadedFragLevel=s.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var r=this.hls.levels[s.level],o=(r.loaded?r.loaded.bytes:0)+g.loaded,c=(r.loaded?r.loaded.duration:0)+i;r.loaded={bytes:o,duration:c},r.realBitrate=Math.round(8*o/c)}if(s.bitrateTest){var t={stats:g,frag:s,part:h,id:s.type};this.onFragBuffered(A.Events.FRAG_BUFFERED,t)}}},m.onFragBuffered=function(f,e){var s=e.frag,h=e.part,g=h?h.stats:s.stats;if(!g.aborted&&!(s.type!==b.PlaylistLevelType.MAIN||s.sn==="initSegment")){var i=g.parsing.end-g.loading.start;this.bwEstimator.sample(i,g.loaded),g.bwEstimate=this.bwEstimator.getEstimate(),s.bitrateTest?this.bitrateTestDelay=i/1e3:this.bitrateTestDelay=0}},m.onError=function(f,e){switch(e.details){case O.ErrorDetails.FRAG_LOAD_ERROR:case O.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},m.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},m.getNextABRAutoLevel=function(){var f=this.fragCurrent,e=this.partCurrent,s=this.hls,h=s.maxAutoLevel,g=s.config,i=s.minAutoLevel,r=s.media,o=e?e.duration:f?f.duration:0,c=r?r.currentTime:0,t=r&&r.playbackRate!==0?Math.abs(r.playbackRate):1,n=this.bwEstimator?this.bwEstimator.getEstimate():g.abrEwmaDefaultEstimate,u=(M.BufferHelper.bufferInfo(r,c,g.maxBufferHole).end-c)/t,a=this.findBestLevel(n,i,h,u,g.abrBandWidthFactor,g.abrBandWidthUpFactor);if(a>=0)return a;_.logger.trace((u?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var d=o?Math.min(o,g.maxStarvationDelay):g.maxStarvationDelay,v=g.abrBandWidthFactor,S=g.abrBandWidthUpFactor;if(!u){var T=this.bitrateTestDelay;if(T){var I=o?Math.min(o,g.maxLoadingDelay):g.maxLoadingDelay;d=I-T,_.logger.trace("bitrate test took "+Math.round(1e3*T)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*d)+" ms"),v=S=1}}return a=this.findBestLevel(n,i,h,u+d,v,S),Math.max(a,0)},m.findBestLevel=function(f,e,s,h,g,i){for(var r,o=this.fragCurrent,c=this.partCurrent,t=this.lastLoadedFragLevel,n=this.hls.levels,u=n[t],a=!!(u!=null&&(r=u.details)!==null&&r!==void 0&&r.live),d=u==null?void 0:u.codecSet,v=c?c.duration:o?o.duration:0,S=s;S>=e;S--){var T=n[S];if(!(!T||d&&T.codecSet!==d)){var I=T.details,k=(c?I==null?void 0:I.partTarget:I==null?void 0:I.averagetargetduration)||v,B=void 0;S<=t?B=g*f:B=i*f;var U=n[S].maxBitrate,W=U*k/B;if(_.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+S+"/"+Math.round(B)+"/"+U+"/"+k+"/"+h+"/"+W),B>U&&(!W||a&&!this.bitrateTestDelay||W<h))return S}}return-1},x(E,[{key:"nextAutoLevel",get:function(){var f=this._nextAutoLevel,e=this.bwEstimator;if(f!==-1&&!e.canEstimate())return f;var s=this.getNextABRAutoLevel();return f!==-1&&this.hls.levels[s].loadError?f:(f!==-1&&(s=Math.min(f,s)),s)},set:function(f){this._nextAutoLevel=f}}]),E}();R.default=D},"./src/controller/audio-stream-controller.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/polyfills/number.ts"),L=l("./src/controller/base-stream-controller.ts"),A=l("./src/events.ts"),M=l("./src/utils/buffer-helper.ts"),O=l("./src/controller/fragment-tracker.ts"),b=l("./src/types/level.ts"),_=l("./src/types/loader.ts"),y=l("./src/loader/fragment.ts"),x=l("./src/demux/chunk-cache.ts"),D=l("./src/demux/transmuxer-interface.ts"),E=l("./src/types/transmuxer.ts"),m=l("./src/controller/fragment-finders.ts"),p=l("./src/utils/discontinuities.ts"),f=l("./src/errors.ts");function e(){return e=Object.assign?Object.assign.bind():function(r){for(var o=1;o<arguments.length;o++){var c=arguments[o];for(var t in c)Object.prototype.hasOwnProperty.call(c,t)&&(r[t]=c[t])}return r},e.apply(this,arguments)}function s(r,o){r.prototype=Object.create(o.prototype),r.prototype.constructor=r,h(r,o)}function h(r,o){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},h(r,o)}var g=100,i=function(r){s(o,r);function o(t,n){var u;return u=r.call(this,t,n,"[audio-stream-controller]")||this,u.videoBuffer=null,u.videoTrackCC=-1,u.waitingVideoCC=-1,u.audioSwitch=!1,u.trackId=-1,u.waitingData=null,u.mainDetails=null,u.bufferFlushed=!1,u.cachedTrackLoadedData=null,u._registerListeners(),u}var c=o.prototype;return c.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},c._registerListeners=function(){var n=this.hls;n.on(A.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.on(A.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.on(A.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.on(A.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.on(A.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),n.on(A.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.on(A.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.on(A.Events.ERROR,this.onError,this),n.on(A.Events.BUFFER_RESET,this.onBufferReset,this),n.on(A.Events.BUFFER_CREATED,this.onBufferCreated,this),n.on(A.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.on(A.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.on(A.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c._unregisterListeners=function(){var n=this.hls;n.off(A.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.off(A.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.off(A.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(A.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.off(A.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),n.off(A.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.off(A.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.off(A.Events.ERROR,this.onError,this),n.off(A.Events.BUFFER_RESET,this.onBufferReset,this),n.off(A.Events.BUFFER_CREATED,this.onBufferCreated,this),n.off(A.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.off(A.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.off(A.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c.onInitPtsFound=function(n,u){var a=u.frag,d=u.id,v=u.initPTS;if(d==="main"){var S=a.cc;this.initPTS[a.cc]=v,this.log("InitPTS for cc: "+S+" found from main: "+v),this.videoTrackCC=S,this.state===L.State.WAITING_INIT_PTS&&this.tick()}},c.startLoad=function(n){if(!this.levels){this.startPosition=n,this.state=L.State.STOPPED;return}var u=this.lastCurrentTime;this.stopLoad(),this.setInterval(g),this.fragLoadError=0,u>0&&n===-1?(this.log("Override startPosition with lastCurrentTime @"+u.toFixed(3)),n=u,this.state=L.State.IDLE):(this.loadedmetadata=!1,this.state=L.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=n,this.tick()},c.doTick=function(){switch(this.state){case L.State.IDLE:this.doTickIdle();break;case L.State.WAITING_TRACK:{var n,u=this.levels,a=this.trackId,d=u==null||(n=u[a])===null||n===void 0?void 0:n.details;if(d){if(this.waitForCdnTuneIn(d))break;this.state=L.State.WAITING_INIT_PTS}break}case L.State.FRAG_LOADING_WAITING_RETRY:{var v,S=performance.now(),T=this.retryDate;(!T||S>=T||(v=this.media)!==null&&v!==void 0&&v.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=L.State.IDLE);break}case L.State.WAITING_INIT_PTS:{var I=this.waitingData;if(I){var k=I.frag,B=I.part,U=I.cache,W=I.complete;if(this.initPTS[k.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=L.State.FRAG_LOADING;var G=U.flush(),z={frag:k,part:B,payload:G,networkDetails:null};this._handleFragmentLoadProgress(z),W&&r.prototype._handleFragmentLoadComplete.call(this,z)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+k.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var Y=this.getLoadPosition(),$=M.BufferHelper.bufferInfo(this.mediaBuffer,Y,this.config.maxBufferHole),Z=Object(m.fragmentWithinToleranceTest)($.end,this.config.maxFragLookUpTolerance,k);Z<0&&(this.log("Waiting fragment cc ("+k.cc+") @ "+k.start+" cancelled because another fragment at "+$.end+" is needed"),this.clearWaitingFragment())}}else this.state=L.State.IDLE}}this.onTickEnd()},c.clearWaitingFragment=function(){var n=this.waitingData;n&&(this.fragmentTracker.removeFragment(n.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=L.State.IDLE)},c.resetLoadingState=function(){this.clearWaitingFragment(),r.prototype.resetLoadingState.call(this)},c.onTickEnd=function(){var n=this.media;if(!(!n||!n.readyState)){var u=this.mediaBuffer?this.mediaBuffer:n,a=u.buffered;!this.loadedmetadata&&a.length&&(this.loadedmetadata=!0),this.lastCurrentTime=n.currentTime}},c.doTickIdle=function(){var n,u,a=this.hls,d=this.levels,v=this.media,S=this.trackId,T=a.config;if(!(!d||!d[S])&&!(!v&&(this.startFragRequested||!T.startFragPrefetch))){var I=d[S],k=I.details;if(!k||k.live&&this.levelLastLoaded!==S||this.waitForCdnTuneIn(k)){this.state=L.State.WAITING_TRACK;return}var B=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&B&&(this.bufferFlushed=!1,this.afterBufferFlushed(B,y.ElementaryStreamTypes.AUDIO,_.PlaylistLevelType.AUDIO));var U=this.getFwdBufferInfo(B,_.PlaylistLevelType.AUDIO);if(U!==null){var W=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,_.PlaylistLevelType.MAIN),G=U.len,z=this.getMaxBufferLength(W==null?void 0:W.len),Y=this.audioSwitch;if(!(G>=z&&!Y)){if(!Y&&this._streamEnded(U,k)){a.trigger(A.Events.BUFFER_EOS,{type:"audio"}),this.state=L.State.ENDED;return}var $=k.fragments,Z=$[0].start,q=U.end;if(Y&&v){var ie=this.getLoadPosition();q=ie,k.PTSKnown&&ie<Z&&(U.end>Z||U.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),v.currentTime=Z+.05)}if(!(W&&q>W.end+k.targetduration)&&!((!W||!W.len)&&U.len)){var ne=this.getNextFragment(q,k);if(!ne){this.bufferFlushed=!0;return}((n=ne.decryptdata)===null||n===void 0?void 0:n.keyFormat)==="identity"&&!((u=ne.decryptdata)!==null&&u!==void 0&&u.key)?this.loadKey(ne,k):this.loadFragment(ne,k,q)}}}}},c.getMaxBufferLength=function(n){var u=r.prototype.getMaxBufferLength.call(this);return n?Math.max(u,n):u},c.onMediaDetaching=function(){this.videoBuffer=null,r.prototype.onMediaDetaching.call(this)},c.onAudioTracksUpdated=function(n,u){var a=u.audioTracks;this.resetTransmuxer(),this.levels=a.map(function(d){return new b.Level(d)})},c.onAudioTrackSwitching=function(n,u){var a=!!u.url;this.trackId=u.id;var d=this.fragCurrent;d!=null&&d.loader&&d.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),a?this.setInterval(g):this.resetTransmuxer(),a?(this.audioSwitch=!0,this.state=L.State.IDLE):this.state=L.State.STOPPED,this.tick()},c.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},c.onLevelLoaded=function(n,u){this.mainDetails=u.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(A.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},c.onAudioTrackLoaded=function(n,u){var a;if(this.mainDetails==null){this.cachedTrackLoadedData=u;return}var d=this.levels,v=u.details,S=u.id;if(!d){this.warn("Audio tracks were reset while loading level "+S);return}this.log("Track "+S+" loaded ["+v.startSN+","+v.endSN+"],duration:"+v.totalduration);var T=d[S],I=0;if(v.live||(a=T.details)!==null&&a!==void 0&&a.live){var k=this.mainDetails;if(v.fragments[0]||(v.deltaUpdateFailed=!0),v.deltaUpdateFailed||!k)return;!T.details&&v.hasProgramDateTime&&k.hasProgramDateTime?(Object(p.alignMediaPlaylistByPDT)(v,k),I=v.fragments[0].start):I=this.alignPlaylists(v,T.details)}T.details=v,this.levelLastLoaded=S,!this.startFragRequested&&(this.mainDetails||!v.live)&&this.setStartPosition(T.details,I),this.state===L.State.WAITING_TRACK&&!this.waitForCdnTuneIn(v)&&(this.state=L.State.IDLE),this.tick()},c._handleFragmentLoadProgress=function(n){var u,a=n.frag,d=n.part,v=n.payload,S=this.config,T=this.trackId,I=this.levels;if(!I){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+a.sn+" of level "+a.level+" will not be buffered");return}var k=I[T];console.assert(k,"Audio track is defined on fragment load progress");var B=k.details;console.assert(B,"Audio track details are defined on fragment load progress");var U=S.defaultAudioCodec||k.audioCodec||"mp4a.40.2",W=this.transmuxer;W||(W=this.transmuxer=new D.default(this.hls,_.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var G=this.initPTS[a.cc],z=(u=a.initSegment)===null||u===void 0?void 0:u.data;if(G!==void 0){var Y=!1,$=d?d.index:-1,Z=$!==-1,q=new E.ChunkMetadata(a.level,a.sn,a.stats.chunkCount,v.byteLength,$,Z);W.push(v,z,U,"",a,d,B.totalduration,Y,q,G)}else{this.log("Unknown video PTS for cc "+a.cc+", waiting for video PTS before demuxing audio frag "+a.sn+" of ["+B.startSN+" ,"+B.endSN+"],track "+T);var ie=this.waitingData=this.waitingData||{frag:a,part:d,cache:new x.default,complete:!1},ne=ie.cache;ne.push(new Uint8Array(v)),this.waitingVideoCC=this.videoTrackCC,this.state=L.State.WAITING_INIT_PTS}},c._handleFragmentLoadComplete=function(n){if(this.waitingData){this.waitingData.complete=!0;return}r.prototype._handleFragmentLoadComplete.call(this,n)},c.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},c.onBufferCreated=function(n,u){var a=u.tracks.audio;a&&(this.mediaBuffer=a.buffer||null),u.tracks.video&&(this.videoBuffer=u.tracks.video.buffer||null)},c.onFragBuffered=function(n,u){var a=u.frag,d=u.part;if(a.type===_.PlaylistLevelType.AUDIO){if(this.fragContextChanged(a)){this.warn("Fragment "+a.sn+(d?" p: "+d.index:"")+" of level "+a.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}a.sn!=="initSegment"&&(this.fragPrevious=a,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(A.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(a,d)}},c.onError=function(n,u){switch(u.details){case f.ErrorDetails.FRAG_LOAD_ERROR:case f.ErrorDetails.FRAG_LOAD_TIMEOUT:case f.ErrorDetails.KEY_LOAD_ERROR:case f.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_.PlaylistLevelType.AUDIO,u);break;case f.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case f.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==L.State.ERROR&&this.state!==L.State.STOPPED&&(this.state=u.fatal?L.State.ERROR:L.State.IDLE,this.warn(u.details+" while loading frag, switching to "+this.state+" state"));break;case f.ErrorDetails.BUFFER_FULL_ERROR:if(u.parent==="audio"&&(this.state===L.State.PARSING||this.state===L.State.PARSED)){var a=!0,d=this.getFwdBufferInfo(this.mediaBuffer,_.PlaylistLevelType.AUDIO);d&&d.len>.5&&(a=!this.reduceMaxBufferLength(d.len)),a&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,r.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},c.onBufferFlushed=function(n,u){var a=u.type;a===y.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},c._handleTransmuxComplete=function(n){var u,a="audio",d=this.hls,v=n.remuxResult,S=n.chunkMeta,T=this.getCurrentContext(S);if(!T){this.warn("The loading context changed while buffering fragment "+S.sn+" of level "+S.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(S.level);return}var I=T.frag,k=T.part,B=T.level.details,U=v.audio,W=v.text,G=v.id3,z=v.initSegment;if(!(this.fragContextChanged(I)||!B)){if(this.state=L.State.PARSING,this.audioSwitch&&U&&this.completeAudioSwitch(),z!=null&&z.tracks&&(this._bufferInitSegment(z.tracks,I,S),d.trigger(A.Events.FRAG_PARSING_INIT_SEGMENT,{frag:I,id:a,tracks:z.tracks})),U){var Y=U.startPTS,$=U.endPTS,Z=U.startDTS,q=U.endDTS;k&&(k.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:Y,endPTS:$,startDTS:Z,endDTS:q}),I.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,Y,$,Z,q),this.bufferFragmentData(U,I,k,S)}if(G!=null&&(u=G.samples)!==null&&u!==void 0&&u.length){var ie=e({id:a,frag:I,details:B},G);d.trigger(A.Events.FRAG_PARSING_METADATA,ie)}if(W){var ne=e({id:a,frag:I,details:B},W);d.trigger(A.Events.FRAG_PARSING_USERDATA,ne)}}},c._bufferInitSegment=function(n,u,a){if(this.state===L.State.PARSING){n.video&&delete n.video;var d=n.audio;if(!!d){d.levelCodec=d.codec,d.id="audio",this.log("Init audio buffer, container:"+d.container+", codecs[parsed]=["+d.codec+"]"),this.hls.trigger(A.Events.BUFFER_CODECS,n);var v=d.initSegment;if(v!=null&&v.byteLength){var S={type:"audio",frag:u,part:null,chunkMeta:a,parent:u.type,data:v};this.hls.trigger(A.Events.BUFFER_APPENDING,S)}this.tick()}}},c.loadFragment=function(n,u,a){var d=this.fragmentTracker.getState(n);this.fragCurrent=n,(this.audioSwitch||d===O.FragmentState.NOT_LOADED||d===O.FragmentState.PARTIAL)&&(n.sn==="initSegment"?this._loadInitSegment(n):u.live&&!Object(P.isFiniteNumber)(this.initPTS[n.cc])?(this.log("Waiting for video PTS in continuity counter "+n.cc+" of live stream before loading audio fragment "+n.sn+" of level "+this.trackId),this.state=L.State.WAITING_INIT_PTS):(this.startFragRequested=!0,r.prototype.loadFragment.call(this,n,u,a)))},c.completeAudioSwitch=function(){var n=this.hls,u=this.media,a=this.trackId;u&&(this.log("Switching audio track : flushing all audio"),r.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,n.trigger(A.Events.AUDIO_TRACK_SWITCHED,{id:a})},o}(L.default);R.default=i},"./src/controller/audio-track-controller.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/events.ts"),L=l("./src/errors.ts"),A=l("./src/controller/base-playlist-controller.ts"),M=l("./src/types/loader.ts");function O(D,E){for(var m=0;m<E.length;m++){var p=E[m];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(D,p.key,p)}}function b(D,E,m){return E&&O(D.prototype,E),m&&O(D,m),Object.defineProperty(D,"prototype",{writable:!1}),D}function _(D,E){D.prototype=Object.create(E.prototype),D.prototype.constructor=D,y(D,E)}function y(D,E){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(p,f){return p.__proto__=f,p},y(D,E)}var x=function(D){_(E,D);function E(p){var f;return f=D.call(this,p,"[audio-track-controller]")||this,f.tracks=[],f.groupId=null,f.tracksInGroup=[],f.trackId=-1,f.trackName="",f.selectDefaultTrack=!0,f.registerListeners(),f}var m=E.prototype;return m.registerListeners=function(){var f=this.hls;f.on(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),f.on(P.Events.MANIFEST_PARSED,this.onManifestParsed,this),f.on(P.Events.LEVEL_LOADING,this.onLevelLoading,this),f.on(P.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),f.on(P.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),f.on(P.Events.ERROR,this.onError,this)},m.unregisterListeners=function(){var f=this.hls;f.off(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),f.off(P.Events.MANIFEST_PARSED,this.onManifestParsed,this),f.off(P.Events.LEVEL_LOADING,this.onLevelLoading,this),f.off(P.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),f.off(P.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),f.off(P.Events.ERROR,this.onError,this)},m.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,D.prototype.destroy.call(this)},m.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},m.onManifestParsed=function(f,e){this.tracks=e.audioTracks||[]},m.onAudioTrackLoaded=function(f,e){var s=e.id,h=e.details,g=this.tracksInGroup[s];if(!g){this.warn("Invalid audio track id "+s);return}var i=g.details;g.details=e.details,this.log("audioTrack "+s+" loaded ["+h.startSN+"-"+h.endSN+"]"),s===this.trackId&&(this.retryCount=0,this.playlistLoaded(s,e,i))},m.onLevelLoading=function(f,e){this.switchLevel(e.level)},m.onLevelSwitching=function(f,e){this.switchLevel(e.level)},m.switchLevel=function(f){var e=this.hls.levels[f];if(!!(e!=null&&e.audioGroupIds)){var s=e.audioGroupIds[e.urlId];if(this.groupId!==s){this.groupId=s;var h=this.tracks.filter(function(i){return!s||i.groupId===s});this.selectDefaultTrack&&!h.some(function(i){return i.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=h;var g={audioTracks:h};this.log("Updating audio tracks, "+h.length+' track(s) found in "'+s+'" group-id'),this.hls.trigger(P.Events.AUDIO_TRACKS_UPDATED,g),this.selectInitialTrack()}}},m.onError=function(f,e){D.prototype.onError.call(this,f,e),!(e.fatal||!e.context)&&e.context.type===M.PlaylistContextType.AUDIO_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.retryLoadingOrFail(e)},m.setAudioTrack=function(f){var e=this.tracksInGroup;if(f<0||f>=e.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var s=e[this.trackId];this.log("Now switching to audio-track index "+f);var h=e[f],g=h.id,i=h.groupId,r=i===void 0?"":i,o=h.name,c=h.type,t=h.url;if(this.trackId=f,this.trackName=o,this.selectDefaultTrack=!1,this.hls.trigger(P.Events.AUDIO_TRACK_SWITCHING,{id:g,groupId:r,name:o,type:c,url:t}),!(h.details&&!h.details.live)){var n=this.switchParams(h.url,s==null?void 0:s.details);this.loadPlaylist(n)}},m.selectInitialTrack=function(){var f=this.tracksInGroup;console.assert(f.length,"Initial audio track should be selected when tracks are known");var e=this.trackName,s=this.findTrackId(e)||this.findTrackId();s!==-1?this.setAudioTrack(s):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},m.findTrackId=function(f){for(var e=this.tracksInGroup,s=0;s<e.length;s++){var h=e[s];if((!this.selectDefaultTrack||h.default)&&(!f||f===h.name))return h.id}return-1},m.loadPlaylist=function(f){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var s=e.id,h=e.groupId,g=e.url;if(f)try{g=f.addDirectives(g)}catch(i){this.warn("Could not construct new URL with HLS Delivery Directives: "+i)}this.log("loading audio-track playlist for id: "+s),this.clearTimer(),this.hls.trigger(P.Events.AUDIO_TRACK_LOADING,{url:g,id:s,groupId:h,deliveryDirectives:f||null})}},b(E,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(f){this.selectDefaultTrack=!1,this.setAudioTrack(f)}}]),E}(A.default);R.default=x},"./src/controller/base-playlist-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return b});var P=l("./src/polyfills/number.ts"),L=l("./src/types/level.ts"),A=l("./src/controller/level-helper.ts"),M=l("./src/utils/logger.ts"),O=l("./src/errors.ts"),b=function(){function _(x,D){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=M.logger.log.bind(M.logger,D+":"),this.warn=M.logger.warn.bind(M.logger,D+":"),this.hls=x}var y=_.prototype;return y.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},y.onError=function(D,E){E.fatal&&E.type===O.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},y.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},y.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},y.stopLoad=function(){this.canLoad=!1,this.clearTimer()},y.switchParams=function(D,E){var m=E==null?void 0:E.renditionReports;if(m)for(var p=0;p<m.length;p++){var f=m[p],e=""+f.URI;if(e===D.slice(-e.length)){var s=parseInt(f["LAST-MSN"]),h=parseInt(f["LAST-PART"]);if(E&&this.hls.config.lowLatencyMode){var g=Math.min(E.age-E.partTarget,E.targetduration);h!==void 0&&g>E.partTarget&&(h+=1)}if(Object(P.isFiniteNumber)(s))return new L.HlsUrlParameters(s,Object(P.isFiniteNumber)(h)?h:void 0,L.HlsSkip.No)}}},y.loadPlaylist=function(D){},y.shouldLoadTrack=function(D){return this.canLoad&&D&&!!D.url&&(!D.details||D.details.live)},y.playlistLoaded=function(D,E,m){var p=this,f=E.details,e=E.stats,s=e.loading.end?Math.max(0,self.performance.now()-e.loading.end):0;if(f.advancedDateTime=Date.now()-s,f.live||m!=null&&m.live){if(f.reloaded(m),m&&this.log("live playlist "+D+" "+(f.advanced?"REFRESHED "+f.lastPartSn+"-"+f.lastPartIndex:"MISSED")),m&&f.fragments.length>0&&Object(A.mergeDetails)(m,f),!this.canLoad||!f.live)return;var h,g=void 0,i=void 0;if(f.canBlockReload&&f.endSN&&f.advanced){var r=this.hls.config.lowLatencyMode,o=f.lastPartSn,c=f.endSN,t=f.lastPartIndex,n=t!==-1,u=o===c,a=r?0:t;n?(g=u?c+1:o,i=u?a:t+1):g=c+1;var d=f.age,v=d+f.ageHeader,S=Math.min(v-f.partTarget,f.targetduration*1.5);if(S>0){if(m&&S>m.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+m.tuneInGoal+" to: "+S+" with playlist age: "+f.age),S=0;else{var T=Math.floor(S/f.targetduration);if(g+=T,i!==void 0){var I=Math.round(S%f.targetduration/f.partTarget);i+=I}this.log("CDN Tune-in age: "+f.ageHeader+"s last advanced "+d.toFixed(2)+"s goal: "+S+" skip sn "+T+" to part "+i)}f.tuneInGoal=S}if(h=this.getDeliveryDirectives(f,E.deliveryDirectives,g,i),r||!u){this.loadPlaylist(h);return}}else h=this.getDeliveryDirectives(f,E.deliveryDirectives,g,i);var k=Object(A.computeReloadInterval)(f,e);g!==void 0&&f.canBlockReload&&(k-=f.partTarget||1),this.log("reload live playlist "+D+" in "+Math.round(k)+" ms"),this.timer=self.setTimeout(function(){return p.loadPlaylist(h)},k)}else this.clearTimer()},y.getDeliveryDirectives=function(D,E,m,p){var f=Object(L.getSkipValue)(D,m);return E!=null&&E.skip&&D.deltaUpdateFailed&&(m=E.msn,p=E.part,f=L.HlsSkip.No),new L.HlsUrlParameters(m,p,f)},y.retryLoadingOrFail=function(D){var E=this,m=this.hls.config,p=this.retryCount<m.levelLoadingMaxRetry;if(p){var f;if(this.retryCount++,D.details.indexOf("LoadTimeOut")>-1&&(f=D.context)!==null&&f!==void 0&&f.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+D.details+'"'),this.loadPlaylist();else{var e=Math.min(Math.pow(2,this.retryCount)*m.levelLoadingRetryDelay,m.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return E.loadPlaylist()},e),this.warn("retry playlist loading #"+this.retryCount+" in "+e+' ms after "'+D.details+'"')}}else this.warn('cannot recover from error "'+D.details+'"'),this.clearTimer(),D.fatal=!0;return p},_}()},"./src/controller/base-stream-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"State",function(){return c}),l.d(R,"default",function(){return t});var P=l("./src/polyfills/number.ts"),L=l("./src/task-loop.ts"),A=l("./src/controller/fragment-tracker.ts"),M=l("./src/utils/buffer-helper.ts"),O=l("./src/utils/logger.ts"),b=l("./src/events.ts"),_=l("./src/errors.ts"),y=l("./src/types/transmuxer.ts"),x=l("./src/utils/mp4-tools.ts"),D=l("./src/utils/discontinuities.ts"),E=l("./src/controller/fragment-finders.ts"),m=l("./src/controller/level-helper.ts"),p=l("./src/loader/fragment-loader.ts"),f=l("./src/crypt/decrypter.ts"),e=l("./src/utils/time-ranges.ts"),s=l("./src/types/loader.ts");function h(n,u){for(var a=0;a<u.length;a++){var d=u[a];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(n,d.key,d)}}function g(n,u,a){return u&&h(n.prototype,u),a&&h(n,a),Object.defineProperty(n,"prototype",{writable:!1}),n}function i(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function r(n,u){n.prototype=Object.create(u.prototype),n.prototype.constructor=n,o(n,u)}function o(n,u){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(d,v){return d.__proto__=v,d},o(n,u)}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"},t=function(n){r(u,n);function u(d,v,S){var T;return T=n.call(this)||this,T.hls=void 0,T.fragPrevious=null,T.fragCurrent=null,T.fragmentTracker=void 0,T.transmuxer=null,T._state=c.STOPPED,T.media=null,T.mediaBuffer=null,T.config=void 0,T.bitrateTest=!1,T.lastCurrentTime=0,T.nextLoadPosition=0,T.startPosition=0,T.loadedmetadata=!1,T.fragLoadError=0,T.retryDate=0,T.levels=null,T.fragmentLoader=void 0,T.levelLastLoaded=null,T.startFragRequested=!1,T.decrypter=void 0,T.initPTS=[],T.onvseeking=null,T.onvended=null,T.logPrefix="",T.log=void 0,T.warn=void 0,T.logPrefix=S,T.log=O.logger.log.bind(O.logger,S+":"),T.warn=O.logger.warn.bind(O.logger,S+":"),T.hls=d,T.fragmentLoader=new p.default(d.config),T.fragmentTracker=v,T.config=d.config,T.decrypter=new f.default(d,d.config),d.on(b.Events.KEY_LOADED,T.onKeyLoaded,i(T)),d.on(b.Events.LEVEL_SWITCHING,T.onLevelSwitching,i(T)),T}var a=u.prototype;return a.doTick=function(){this.onTickEnd()},a.onTickEnd=function(){},a.startLoad=function(v){},a.stopLoad=function(){this.fragmentLoader.abort();var v=this.fragCurrent;v&&this.fragmentTracker.removeFragment(v),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=c.STOPPED},a._streamEnded=function(v,S){var T=this.fragCurrent,I=this.fragmentTracker;if(!S.live&&T&&this.media&&T.sn>=S.endSN&&!v.nextStart){var k=S.partList;if(k!=null&&k.length){var B=k[k.length-1],U=M.BufferHelper.isBuffered(this.media,B.start+B.duration/2);return U}var W=I.getState(T);return W===A.FragmentState.PARTIAL||W===A.FragmentState.OK}return!1},a.onMediaAttached=function(v,S){var T=this.media=this.mediaBuffer=S.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),T.addEventListener("seeking",this.onvseeking),T.addEventListener("ended",this.onvended);var I=this.config;this.levels&&I.autoStartLoad&&this.state===c.STOPPED&&this.startLoad(I.startPosition)},a.onMediaDetaching=function(){var v=this.media;v!=null&&v.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),v&&this.onvseeking&&this.onvended&&(v.removeEventListener("seeking",this.onvseeking),v.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},a.onMediaSeeking=function(){var v=this.config,S=this.fragCurrent,T=this.media,I=this.mediaBuffer,k=this.state,B=T?T.currentTime:0,U=M.BufferHelper.bufferInfo(I||T,B,v.maxBufferHole);if(this.log("media seeking to "+(Object(P.isFiniteNumber)(B)?B.toFixed(3):B)+", state: "+k),k===c.ENDED)this.resetLoadingState();else if(S&&!U.len){var W=v.maxFragLookUpTolerance,G=S.start-W,z=S.start+S.duration+W,Y=B>z;(B<G||Y)&&(Y&&S.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),S.loader.abort()),this.resetLoadingState())}T&&(this.lastCurrentTime=B),!this.loadedmetadata&&!U.len&&(this.nextLoadPosition=this.startPosition=B),this.tickImmediate()},a.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},a.onKeyLoaded=function(v,S){if(!(this.state!==c.KEY_LOADING||S.frag!==this.fragCurrent||!this.levels)){this.state=c.IDLE;var T=this.levels[S.frag.level].details;T&&this.loadFragment(S.frag,T,S.frag.start)}},a.onLevelSwitching=function(v,S){this.fragLoadError=0},a.onHandlerDestroying=function(){this.stopLoad(),n.prototype.onHandlerDestroying.call(this)},a.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,n.prototype.onHandlerDestroyed.call(this)},a.loadKey=function(v,S){this.log("Loading key for "+v.sn+" of ["+S.startSN+"-"+S.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+v.level),this.state=c.KEY_LOADING,this.fragCurrent=v,this.hls.trigger(b.Events.KEY_LOADING,{frag:v})},a.loadFragment=function(v,S,T){this._loadFragForPlayback(v,S,T)},a._loadFragForPlayback=function(v,S,T){var I=this,k=function(U){if(I.fragContextChanged(v)){I.warn("Fragment "+v.sn+(U.part?" p: "+U.part.index:"")+" of level "+v.level+" was dropped during download."),I.fragmentTracker.removeFragment(v);return}v.stats.chunkCount++,I._handleFragmentLoadProgress(U)};this._doFragLoad(v,S,T,k).then(function(B){if(!!B){I.fragLoadError=0;var U=I.state;if(I.fragContextChanged(v)){(U===c.FRAG_LOADING||!I.fragCurrent&&U===c.PARSING)&&(I.fragmentTracker.removeFragment(v),I.state=c.IDLE);return}"payload"in B&&(I.log("Loaded fragment "+v.sn+" of level "+v.level),I.hls.trigger(b.Events.FRAG_LOADED,B)),I._handleFragmentLoadComplete(B)}}).catch(function(B){I.state===c.STOPPED||I.state===c.ERROR||(I.warn(B),I.resetFragmentLoading(v))})},a.flushMainBuffer=function(v,S,T){if(T===void 0&&(T=null),!!(v-S)){var I={startOffset:v,endOffset:S,type:T};this.fragLoadError=0,this.hls.trigger(b.Events.BUFFER_FLUSHING,I)}},a._loadInitSegment=function(v){var S=this;this._doFragLoad(v).then(function(T){if(!T||S.fragContextChanged(v)||!S.levels)throw new Error("init load aborted");return T}).then(function(T){var I=S.hls,k=T.payload,B=v.decryptdata;if(k&&k.byteLength>0&&B&&B.key&&B.iv&&B.method==="AES-128"){var U=self.performance.now();return S.decrypter.webCryptoDecrypt(new Uint8Array(k),B.key.buffer,B.iv.buffer).then(function(W){var G=self.performance.now();return I.trigger(b.Events.FRAG_DECRYPTED,{frag:v,payload:W,stats:{tstart:U,tdecrypt:G}}),T.payload=W,T})}return T}).then(function(T){var I=S.fragCurrent,k=S.hls,B=S.levels;if(!B)throw new Error("init load aborted, missing levels");var U=B[v.level].details;console.assert(U,"Level details are defined when init segment is loaded");var W=v.stats;S.state=c.IDLE,S.fragLoadError=0,v.data=new Uint8Array(T.payload),W.parsing.start=W.buffering.start=self.performance.now(),W.parsing.end=W.buffering.end=self.performance.now(),T.frag===I&&k.trigger(b.Events.FRAG_BUFFERED,{stats:W,frag:I,part:null,id:v.type}),S.tick()}).catch(function(T){S.state===c.STOPPED||S.state===c.ERROR||(S.warn(T),S.resetFragmentLoading(v))})},a.fragContextChanged=function(v){var S=this.fragCurrent;return!v||!S||v.level!==S.level||v.sn!==S.sn||v.urlId!==S.urlId},a.fragBufferedComplete=function(v,S){var T=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+v.type+" sn: "+v.sn+(S?" part: "+S.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+v.level+" "+(T?e.default.toString(M.BufferHelper.getBuffered(T)):"(detached)")),this.state=c.IDLE,T&&(!this.loadedmetadata&&T.buffered.length&&this.fragCurrent===this.fragPrevious&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},a.seekToStartPos=function(){},a._handleFragmentLoadComplete=function(v){var S=this.transmuxer;if(!!S){var T=v.frag,I=v.part,k=v.partsLoaded,B=!k||k.length===0||k.some(function(W){return!W}),U=new y.ChunkMetadata(T.level,T.sn,T.stats.chunkCount+1,0,I?I.index:-1,!B);S.flush(U)}},a._handleFragmentLoadProgress=function(v){},a._doFragLoad=function(v,S,T,I){var k=this;if(T===void 0&&(T=null),!this.levels)throw new Error("frag load aborted, missing levels");if(T=Math.max(v.start,T||0),this.config.lowLatencyMode&&S){var B=S.partList;if(B&&I){T>v.end&&S.fragmentHint&&(v=S.fragmentHint);var U=this.getNextPart(B,v,T);if(U>-1){var W=B[U];return this.log("Loading part sn: "+v.sn+" p: "+W.index+" cc: "+v.cc+" of playlist ["+S.startSN+"-"+S.endSN+"] parts [0-"+U+"-"+(B.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+v.level+", target: "+parseFloat(T.toFixed(3))),this.nextLoadPosition=W.start+W.duration,this.state=c.FRAG_LOADING,this.hls.trigger(b.Events.FRAG_LOADING,{frag:v,part:B[U],targetBufferTime:T}),this.doFragPartsLoad(v,B,U,I).catch(function(G){return k.handleFragLoadError(G)})}else if(!v.url||this.loadedEndOfParts(B,T))return Promise.resolve(null)}}return this.log("Loading fragment "+v.sn+" cc: "+v.cc+" "+(S?"of ["+S.startSN+"-"+S.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+v.level+", target: "+parseFloat(T.toFixed(3))),Object(P.isFiniteNumber)(v.sn)&&!this.bitrateTest&&(this.nextLoadPosition=v.start+v.duration),this.state=c.FRAG_LOADING,this.hls.trigger(b.Events.FRAG_LOADING,{frag:v,targetBufferTime:T}),this.fragmentLoader.load(v,I).catch(function(G){return k.handleFragLoadError(G)})},a.doFragPartsLoad=function(v,S,T,I){var k=this;return new Promise(function(B,U){var W=[],G=function z(Y){var $=S[Y];k.fragmentLoader.loadPart(v,$,I).then(function(Z){W[$.index]=Z;var q=Z.part;k.hls.trigger(b.Events.FRAG_LOADED,Z);var ie=S[Y+1];if(ie&&ie.fragment===v)z(Y+1);else return B({frag:v,part:q,partsLoaded:W})}).catch(U)};G(T)})},a.handleFragLoadError=function(v){var S=v.data;return S&&S.details===_.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(S.frag,S.part):this.hls.trigger(b.Events.ERROR,S),null},a._handleTransmuxerFlush=function(v){var S=this.getCurrentContext(v);if(!S||this.state!==c.PARSING){this.fragCurrent||(this.state=c.IDLE);return}var T=S.frag,I=S.part,k=S.level,B=self.performance.now();T.stats.parsing.end=B,I&&(I.stats.parsing.end=B),this.updateLevelTiming(T,I,k,v.partial)},a.getCurrentContext=function(v){var S=this.levels,T=v.level,I=v.sn,k=v.part;if(!S||!S[T])return this.warn("Levels object was unset while buffering fragment "+I+" of level "+T+". The current chunk will not be buffered."),null;var B=S[T],U=k>-1?Object(m.getPartWith)(B,I,k):null,W=U?U.fragment:Object(m.getFragmentWithSN)(B,I,this.fragCurrent);return W?{frag:W,part:U,level:B}:null},a.bufferFragmentData=function(v,S,T,I){if(!(!v||this.state!==c.PARSING)){var k=v.data1,B=v.data2,U=k;if(k&&B&&(U=Object(x.appendUint8Array)(k,B)),!(!U||!U.length)){var W={type:v.type,frag:S,part:T,chunkMeta:I,parent:S.type,data:U};this.hls.trigger(b.Events.BUFFER_APPENDING,W),v.dropped&&v.independent&&!T&&this.flushBufferGap(S)}}},a.flushBufferGap=function(v){var S=this.media;if(!!S){if(!M.BufferHelper.isBuffered(S,S.currentTime)){this.flushMainBuffer(0,v.start);return}var T=S.currentTime,I=M.BufferHelper.bufferInfo(S,T,0),k=v.duration,B=Math.min(this.config.maxFragLookUpTolerance*2,k*.25),U=Math.max(Math.min(v.start-B,I.end-B),T+B);v.start-U>B&&this.flushMainBuffer(U,v.start)}},a.getFwdBufferInfo=function(v,S){var T=this.config,I=this.getLoadPosition();if(!Object(P.isFiniteNumber)(I))return null;var k=M.BufferHelper.bufferInfo(v,I,T.maxBufferHole);if(k.len===0&&k.nextStart!==void 0){var B=this.fragmentTracker.getBufferedFrag(I,S);if(B&&k.nextStart<B.end)return M.BufferHelper.bufferInfo(v,I,Math.max(k.nextStart,T.maxBufferHole))}return k},a.getMaxBufferLength=function(v){var S=this.config,T;return v?T=Math.max(8*S.maxBufferSize/v,S.maxBufferLength):T=S.maxBufferLength,Math.min(T,S.maxMaxBufferLength)},a.reduceMaxBufferLength=function(v){var S=this.config,T=v||S.maxBufferLength;return S.maxMaxBufferLength>=T?(S.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+S.maxMaxBufferLength+"s"),!0):!1},a.getNextFragment=function(v,S){var T=S.fragments,I=T.length;if(!I)return null;var k=this.config,B=T[0].start,U;if(S.live){var W=k.initialLiveManifestSize;if(I<W)return this.warn("Not enough fragments to start playback (have: "+I+", need: "+W+")"),null;!S.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(U=this.getInitialLiveFragment(S,T),this.startPosition=U?this.hls.liveSyncPosition||U.start:v)}else v<=B&&(U=T[0]);if(!U){var G=k.lowLatencyMode?S.partEnd:S.fragmentEnd;U=this.getFragmentAtPosition(v,G,S)}return this.mapToInitFragWhenRequired(U)},a.mapToInitFragWhenRequired=function(v){return v!=null&&v.initSegment&&!(v!=null&&v.initSegment.data)&&!this.bitrateTest?v.initSegment:v},a.getNextPart=function(v,S,T){for(var I=-1,k=!1,B=!0,U=0,W=v.length;U<W;U++){var G=v[U];if(B=B&&!G.independent,I>-1&&T<G.start)break;var z=G.loaded;!z&&(k||G.independent||B)&&G.fragment===S&&(I=U),k=z}return I},a.loadedEndOfParts=function(v,S){var T=v[v.length-1];return T&&S>T.start&&T.loaded},a.getInitialLiveFragment=function(v,S){var T=this.fragPrevious,I=null;if(T){if(v.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+T.programDateTime),I=Object(E.findFragmentByPDT)(S,T.endProgramDateTime,this.config.maxFragLookUpTolerance)),!I){var k=T.sn+1;if(k>=v.startSN&&k<=v.endSN){var B=S[k-v.startSN];T.cc===B.cc&&(I=B,this.log("Live playlist, switching playlist, load frag with next SN: "+I.sn))}I||(I=Object(E.findFragWithCC)(S,T.cc),I&&this.log("Live playlist, switching playlist, load frag with same CC: "+I.sn))}}else{var U=this.hls.liveSyncPosition;U!==null&&(I=this.getFragmentAtPosition(U,this.bitrateTest?v.fragmentEnd:v.edge,v))}return I},a.getFragmentAtPosition=function(v,S,T){var I=this.config,k=this.fragPrevious,B=T.fragments,U=T.endSN,W=T.fragmentHint,G=I.maxFragLookUpTolerance,z=!!(I.lowLatencyMode&&T.partList&&W);z&&W&&!this.bitrateTest&&(B=B.concat(W),U=W.sn);var Y;if(v<S){var $=v>S-G?0:G;Y=Object(E.findFragmentByPTS)(k,B,v,$)}else Y=B[B.length-1];if(Y){var Z=Y.sn-T.startSN;if(k&&Y.sn===k.sn&&!z){var q=k&&Y.level===k.level;if(q){var ie=B[Z+1];Y.sn<U&&this.fragmentTracker.getState(ie)!==A.FragmentState.OK?(this.log("SN "+Y.sn+" just loaded, load next one: "+ie.sn),Y=ie):Y=null}}}return Y},a.synchronizeToLiveEdge=function(v){var S=this.config,T=this.media;if(!!T){var I=this.hls.liveSyncPosition,k=T.currentTime,B=v.fragments[0].start,U=v.edge,W=k>=B-S.maxFragLookUpTolerance&&k<=U;if(I!==null&&T.duration>I&&(k<I||!W)){var G=S.liveMaxLatencyDuration!==void 0?S.liveMaxLatencyDuration:S.liveMaxLatencyDurationCount*v.targetduration;(!W&&T.readyState<4||k<U-G)&&(this.loadedmetadata||(this.nextLoadPosition=I),T.readyState&&(this.warn("Playback: "+k.toFixed(3)+" is located too far from the end of live sliding playlist: "+U+", reset currentTime to : "+I.toFixed(3)),T.currentTime=I))}}},a.alignPlaylists=function(v,S){var T=this.levels,I=this.levelLastLoaded,k=this.fragPrevious,B=I!==null?T[I]:null,U=v.fragments.length;if(!U)return this.warn("No fragments in live playlist"),0;var W=v.fragments[0].start,G=!S,z=v.alignedSliding&&Object(P.isFiniteNumber)(W);if(G||!z&&!W){Object(D.alignStream)(k,B,v);var Y=v.fragments[0].start;return this.log("Live playlist sliding: "+Y.toFixed(2)+" start-sn: "+(S?S.startSN:"na")+"->"+v.startSN+" prev-sn: "+(k?k.sn:"na")+" fragments: "+U),Y}return W},a.waitForCdnTuneIn=function(v){var S=3;return v.live&&v.canBlockReload&&v.partTarget&&v.tuneInGoal>Math.max(v.partHoldBack,v.partTarget*S)},a.setStartPosition=function(v,S){var T=this.startPosition;if(T<S&&(T=-1),T===-1||this.lastCurrentTime===-1){var I=v.startTimeOffset;Object(P.isFiniteNumber)(I)?(T=S+I,I<0&&(T+=v.totalduration),T=Math.min(Math.max(S,T),S+v.totalduration),this.log("Start time offset "+I+" found in playlist, adjust startPosition to "+T),this.startPosition=T):v.live?T=this.hls.liveSyncPosition||S:this.startPosition=T=0,this.lastCurrentTime=T}this.nextLoadPosition=T},a.getLoadPosition=function(){var v=this.media,S=0;return this.loadedmetadata&&v?S=v.currentTime:this.nextLoadPosition&&(S=this.nextLoadPosition),S},a.handleFragLoadAborted=function(v,S){this.transmuxer&&v.sn!=="initSegment"&&v.stats.aborted&&(this.warn("Fragment "+v.sn+(S?" part"+S.index:"")+" of level "+v.level+" was aborted"),this.resetFragmentLoading(v))},a.resetFragmentLoading=function(v){(!this.fragCurrent||!this.fragContextChanged(v)&&this.state!==c.FRAG_LOADING_WAITING_RETRY)&&(this.state=c.IDLE)},a.onFragmentOrKeyLoadError=function(v,S){if(!S.fatal){var T=S.frag;if(!(!T||T.type!==v)){var I=this.fragCurrent;console.assert(I&&T.sn===I.sn&&T.level===I.level&&T.urlId===I.urlId,"Frag load error must match current frag to retry");var k=this.config;if(this.fragLoadError+1<=k.fragLoadingMaxRetry){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var B=Math.min(Math.pow(2,this.fragLoadError)*k.fragLoadingRetryDelay,k.fragLoadingMaxRetryTimeout);this.warn("Fragment "+T.sn+" of "+v+" "+T.level+" failed to load, retrying in "+B+"ms"),this.retryDate=self.performance.now()+B,this.fragLoadError++,this.state=c.FRAG_LOADING_WAITING_RETRY}else S.levelRetry?(v===s.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=c.IDLE):(O.logger.error(S.details+" reaches max retry, redispatch as fatal ..."),S.fatal=!0,this.hls.stopLoad(),this.state=c.ERROR)}}},a.afterBufferFlushed=function(v,S,T){if(!!v){var I=M.BufferHelper.getBuffered(v);this.fragmentTracker.detectEvictedFragments(S,I,T),this.state===c.ENDED&&this.resetLoadingState()}},a.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=c.IDLE},a.resetStartWhenNotLoaded=function(v){if(!this.loadedmetadata){this.startFragRequested=!1;var S=this.levels?this.levels[v].details:null;S!=null&&S.live?(this.startPosition=-1,this.setStartPosition(S,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},a.updateLevelTiming=function(v,S,T,I){var k=this,B=T.details;console.assert(!!B,"level.details must be defined");var U=Object.keys(v.elementaryStreams).reduce(function(W,G){var z=v.elementaryStreams[G];if(z){var Y=z.endPTS-z.startPTS;if(Y<=0)return k.warn("Could not parse fragment "+v.sn+" "+G+" duration reliably ("+Y+")"),W||!1;var $=I?0:Object(m.updateFragPTSDTS)(B,v,z.startPTS,z.endPTS,z.startDTS,z.endDTS);return k.hls.trigger(b.Events.LEVEL_PTS_UPDATED,{details:B,level:T,drift:$,type:G,frag:v,start:z.startPTS,end:z.endPTS}),!0}return W},!1);U||(this.warn("Found no media in fragment "+v.sn+" of level "+T.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=c.PARSED,this.hls.trigger(b.Events.FRAG_PARSED,{frag:v,part:S})},a.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},g(u,[{key:"state",get:function(){return this._state},set:function(v){var S=this._state;S!==v&&(this._state=v,this.log(S+"->"+v))}}]),u}(L.default)},"./src/controller/buffer-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return E});var P=l("./src/polyfills/number.ts"),L=l("./src/events.ts"),A=l("./src/utils/logger.ts"),M=l("./src/errors.ts"),O=l("./src/utils/buffer-helper.ts"),b=l("./src/utils/mediasource-helper.ts"),_=l("./src/loader/fragment.ts"),y=l("./src/controller/buffer-operation-queue.ts"),x=Object(b.getMediaSource)(),D=/([ha]vc.)(?:\.[^.,]+)+/,E=function(){function m(f){var e=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var s=e.hls,h=e.media,g=e.mediaSource;A.logger.log("[buffer-controller]: Media source opened"),h&&(e.updateMediaElementDuration(),s.trigger(L.Events.MEDIA_ATTACHED,{media:h})),g&&g.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){A.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){A.logger.log("[buffer-controller]: Media source ended")},this.hls=f,this._initSourceBuffer(),this.registerListeners()}var p=m.prototype;return p.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},p.destroy=function(){this.unregisterListeners(),this.details=null},p.registerListeners=function(){var e=this.hls;e.on(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(L.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(L.Events.BUFFER_RESET,this.onBufferReset,this),e.on(L.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(L.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(L.Events.BUFFER_EOS,this.onBufferEos,this),e.on(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(L.Events.FRAG_PARSED,this.onFragParsed,this),e.on(L.Events.FRAG_CHANGED,this.onFragChanged,this)},p.unregisterListeners=function(){var e=this.hls;e.off(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(L.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(L.Events.BUFFER_RESET,this.onBufferReset,this),e.off(L.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(L.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(L.Events.BUFFER_EOS,this.onBufferEos,this),e.off(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(L.Events.FRAG_PARSED,this.onFragParsed,this),e.off(L.Events.FRAG_CHANGED,this.onFragChanged,this)},p._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new y.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},p.onManifestParsed=function(e,s){var h=2;(s.audio&&!s.video||!s.altAudio)&&(h=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=h,this.details=null,A.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},p.onMediaAttaching=function(e,s){var h=this.media=s.media;if(h&&x){var g=this.mediaSource=new x;g.addEventListener("sourceopen",this._onMediaSourceOpen),g.addEventListener("sourceended",this._onMediaSourceEnded),g.addEventListener("sourceclose",this._onMediaSourceClose),h.src=self.URL.createObjectURL(g),this._objectUrl=h.src}},p.onMediaDetaching=function(){var e=this.media,s=this.mediaSource,h=this._objectUrl;if(s){if(A.logger.log("[buffer-controller]: media source detaching"),s.readyState==="open")try{s.endOfStream()}catch(g){A.logger.warn("[buffer-controller]: onMediaDetaching: "+g.message+" while calling endOfStream")}this.onBufferReset(),s.removeEventListener("sourceopen",this._onMediaSourceOpen),s.removeEventListener("sourceended",this._onMediaSourceEnded),s.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(h&&self.URL.revokeObjectURL(h),e.src===h?(e.removeAttribute("src"),e.load()):A.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(L.Events.MEDIA_DETACHED,void 0)},p.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(s){var h=e.sourceBuffer[s];try{h&&(e.removeBufferListeners(s),e.mediaSource&&e.mediaSource.removeSourceBuffer(h),e.sourceBuffer[s]=void 0)}catch(g){A.logger.warn("[buffer-controller]: Failed to reset the "+s+" buffer",g)}}),this._initSourceBuffer()},p.onBufferCodecs=function(e,s){var h=this,g=this.getSourceBufferTypes().length;Object.keys(s).forEach(function(i){if(g){var r=h.tracks[i];if(r&&typeof r.buffer.changeType=="function"){var o=s[i],c=o.id,t=o.codec,n=o.levelCodec,u=o.container,a=o.metadata,d=(r.levelCodec||r.codec).replace(D,"$1"),v=(n||t).replace(D,"$1");if(d!==v){var S=u+";codecs="+(n||t);h.appendChangeType(i,S),A.logger.log("[buffer-controller]: switching codec "+d+" to "+v),h.tracks[i]={buffer:r.buffer,codec:t,container:u,levelCodec:n,metadata:a,id:c}}}}else h.pendingTracks[i]=s[i]}),!g&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},p.appendChangeType=function(e,s){var h=this,g=this.operationQueue,i={execute:function(){var o=h.sourceBuffer[e];o&&(A.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+s),o.changeType(s)),g.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(o){A.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",o)}};g.append(i,e)},p.onBufferAppending=function(e,s){var h=this,g=this.hls,i=this.operationQueue,r=this.tracks,o=s.data,c=s.type,t=s.frag,n=s.part,u=s.chunkMeta,a=u.buffering[c],d=self.performance.now();a.start=d;var v=t.stats.buffering,S=n?n.stats.buffering:null;v.start===0&&(v.start=d),S&&S.start===0&&(S.start=d);var T=r.audio,I=c==="audio"&&u.id===1&&(T==null?void 0:T.container)==="audio/mpeg",k={execute:function(){if(a.executeStart=self.performance.now(),I){var U=h.sourceBuffer[c];if(U){var W=t.start-U.timestampOffset;Math.abs(W)>=.1&&(A.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+t.start+" (delta: "+W+") sn: "+t.sn+")"),U.timestampOffset=t.start)}}h.appendExecutor(o,c)},onStart:function(){},onComplete:function(){var U=self.performance.now();a.executeEnd=a.end=U,v.first===0&&(v.first=U),S&&S.first===0&&(S.first=U);var W=h.sourceBuffer,G={};for(var z in W)G[z]=O.BufferHelper.getBuffered(W[z]);h.appendError=0,h.hls.trigger(L.Events.BUFFER_APPENDED,{type:c,frag:t,part:n,chunkMeta:u,parent:t.type,timeRanges:G})},onError:function(U){A.logger.error("[buffer-controller]: Error encountered while trying to append to the "+c+" SourceBuffer",U);var W={type:M.ErrorTypes.MEDIA_ERROR,parent:t.type,details:M.ErrorDetails.BUFFER_APPEND_ERROR,err:U,fatal:!1};U.code===DOMException.QUOTA_EXCEEDED_ERR?W.details=M.ErrorDetails.BUFFER_FULL_ERROR:(h.appendError++,W.details=M.ErrorDetails.BUFFER_APPEND_ERROR,h.appendError>g.config.appendErrorMaxRetry&&(A.logger.error("[buffer-controller]: Failed "+g.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),W.fatal=!0,g.stopLoad())),g.trigger(L.Events.ERROR,W)}};i.append(k,c)},p.onBufferFlushing=function(e,s){var h=this,g=this.operationQueue,i=function(o){return{execute:h.removeExecutor.bind(h,o,s.startOffset,s.endOffset),onStart:function(){},onComplete:function(){h.hls.trigger(L.Events.BUFFER_FLUSHED,{type:o})},onError:function(t){A.logger.warn("[buffer-controller]: Failed to remove from "+o+" SourceBuffer",t)}}};s.type?g.append(i(s.type),s.type):this.getSourceBufferTypes().forEach(function(r){g.append(i(r),r)})},p.onFragParsed=function(e,s){var h=this,g=s.frag,i=s.part,r=[],o=i?i.elementaryStreams:g.elementaryStreams;o[_.ElementaryStreamTypes.AUDIOVIDEO]?r.push("audiovideo"):(o[_.ElementaryStreamTypes.AUDIO]&&r.push("audio"),o[_.ElementaryStreamTypes.VIDEO]&&r.push("video"));var c=function(){var n=self.performance.now();g.stats.buffering.end=n,i&&(i.stats.buffering.end=n);var u=i?i.stats:g.stats;h.hls.trigger(L.Events.FRAG_BUFFERED,{frag:g,part:i,stats:u,id:g.type})};r.length===0&&A.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+g.type+" level: "+g.level+" sn: "+g.sn),this.blockBuffers(c,r)},p.onFragChanged=function(e,s){this.flushBackBuffer()},p.onBufferEos=function(e,s){var h=this,g=this.getSourceBufferTypes().reduce(function(i,r){var o=h.sourceBuffer[r];return(!s.type||s.type===r)&&o&&!o.ended&&(o.ended=!0,A.logger.log("[buffer-controller]: "+r+" sourceBuffer now EOS")),i&&!!(!o||o.ended)},!0);g&&this.blockBuffers(function(){var i=h.mediaSource;!i||i.readyState!=="open"||i.endOfStream()})},p.onLevelUpdated=function(e,s){var h=s.details;!h.fragments.length||(this.details=h,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},p.flushBackBuffer=function(){var e=this.hls,s=this.details,h=this.media,g=this.sourceBuffer;if(!(!h||s===null)){var i=this.getSourceBufferTypes();if(!!i.length){var r=s.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(!(!Object(P.isFiniteNumber)(r)||r<0)){var o=h.currentTime,c=s.levelTargetDuration,t=Math.max(r,c),n=Math.floor(o/c)*c-t;i.forEach(function(u){var a=g[u];if(a){var d=O.BufferHelper.getBuffered(a);d.length>0&&n>d.start(0)&&(e.trigger(L.Events.BACK_BUFFER_REACHED,{bufferEnd:n}),s.live&&e.trigger(L.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:n}),e.trigger(L.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:n,type:u}))}})}}}},p.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var e=this.details,s=this.hls,h=this.media,g=this.mediaSource,i=e.fragments[0].start+e.totalduration,r=h.duration,o=Object(P.isFiniteNumber)(g.duration)?g.duration:0;e.live&&s.config.liveDurationInfinity?(A.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),g.duration=1/0,this.updateSeekableRange(e)):(i>o&&i>r||!Object(P.isFiniteNumber)(r))&&(A.logger.log("[buffer-controller]: Updating Media Source duration to "+i.toFixed(3)),g.duration=i)}},p.updateSeekableRange=function(e){var s=this.mediaSource,h=e.fragments,g=h.length;if(g&&e.live&&s!==null&&s!==void 0&&s.setLiveSeekableRange){var i=Math.max(0,h[0].start),r=Math.max(i,i+e.totalduration);s.setLiveSeekableRange(i,r)}},p.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,s=this.operationQueue,h=this.pendingTracks,g=Object.keys(h).length;if(g&&!e||g===2){this.createSourceBuffers(h),this.pendingTracks={};var i=this.getSourceBufferTypes();if(i.length===0){this.hls.trigger(L.Events.ERROR,{type:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}i.forEach(function(r){s.executeNext(r)})}},p.createSourceBuffers=function(e){var s=this.sourceBuffer,h=this.mediaSource;if(!h)throw Error("createSourceBuffers called when mediaSource was null");var g=0;for(var i in e)if(!s[i]){var r=e[i];if(!r)throw Error("source buffer exists for track "+i+", however track does not");var o=r.levelCodec||r.codec,c=r.container+";codecs="+o;A.logger.log("[buffer-controller]: creating sourceBuffer("+c+")");try{var t=s[i]=h.addSourceBuffer(c),n=i;this.addBufferListener(n,"updatestart",this._onSBUpdateStart),this.addBufferListener(n,"updateend",this._onSBUpdateEnd),this.addBufferListener(n,"error",this._onSBUpdateError),this.tracks[i]={buffer:t,codec:o,container:r.container,levelCodec:r.levelCodec,metadata:r.metadata,id:r.id},g++}catch(u){A.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+u.message),this.hls.trigger(L.Events.ERROR,{type:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:u,mimeType:c})}}g&&this.hls.trigger(L.Events.BUFFER_CREATED,{tracks:this.tracks})},p._onSBUpdateStart=function(e){var s=this.operationQueue,h=s.current(e);h.onStart()},p._onSBUpdateEnd=function(e){var s=this.operationQueue,h=s.current(e);h.onComplete(),s.shiftAndExecuteNext(e)},p._onSBUpdateError=function(e,s){A.logger.error("[buffer-controller]: "+e+" SourceBuffer error",s),this.hls.trigger(L.Events.ERROR,{type:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var h=this.operationQueue.current(e);h&&h.onError(s)},p.removeExecutor=function(e,s,h){var g=this.media,i=this.mediaSource,r=this.operationQueue,o=this.sourceBuffer,c=o[e];if(!g||!i||!c){A.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),r.shiftAndExecuteNext(e);return}var t=Object(P.isFiniteNumber)(g.duration)?g.duration:1/0,n=Object(P.isFiniteNumber)(i.duration)?i.duration:1/0,u=Math.max(0,s),a=Math.min(h,t,n);a>u?(A.logger.log("[buffer-controller]: Removing ["+u+","+a+"] from the "+e+" SourceBuffer"),console.assert(!c.updating,e+" sourceBuffer must not be updating"),c.remove(u,a)):r.shiftAndExecuteNext(e)},p.appendExecutor=function(e,s){var h=this.operationQueue,g=this.sourceBuffer,i=g[s];if(!i){A.logger.warn("[buffer-controller]: Attempting to append to the "+s+" SourceBuffer, but it does not exist"),h.shiftAndExecuteNext(s);return}i.ended=!1,console.assert(!i.updating,s+" sourceBuffer must not be updating"),i.appendBuffer(e)},p.blockBuffers=function(e,s){var h=this;if(s===void 0&&(s=this.getSourceBufferTypes()),!s.length){A.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}var g=this.operationQueue,i=s.map(function(r){return g.appendBlocker(r)});Promise.all(i).then(function(){e(),s.forEach(function(r){var o=h.sourceBuffer[r];(!o||!o.updating)&&g.shiftAndExecuteNext(r)})})},p.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},p.addBufferListener=function(e,s,h){var g=this.sourceBuffer[e];if(!!g){var i=h.bind(this,e);this.listeners[e].push({event:s,listener:i}),g.addEventListener(s,i)}},p.removeBufferListeners=function(e){var s=this.sourceBuffer[e];!s||this.listeners[e].forEach(function(h){s.removeEventListener(h.event,h.listener)})},m}()},"./src/controller/buffer-operation-queue.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return L});var P=l("./src/utils/logger.ts"),L=function(){function A(O){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=O}var M=A.prototype;return M.append=function(b,_){var y=this.queues[_];y.push(b),y.length===1&&this.buffers[_]&&this.executeNext(_)},M.insertAbort=function(b,_){var y=this.queues[_];y.unshift(b),this.executeNext(_)},M.appendBlocker=function(b){var _,y=new Promise(function(D){_=D}),x={execute:_,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(x,b),y},M.executeNext=function(b){var _=this.buffers,y=this.queues,x=_[b],D=y[b];if(D.length){var E=D[0];try{E.execute()}catch(m){P.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),E.onError(m),(!x||!x.updating)&&(D.shift(),this.executeNext(b))}}},M.shiftAndExecuteNext=function(b){this.queues[b].shift(),this.executeNext(b)},M.current=function(b){return this.queues[b][0]},A}()},"./src/controller/cap-level-controller.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/events.ts");function L(O,b){for(var _=0;_<b.length;_++){var y=b[_];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(O,y.key,y)}}function A(O,b,_){return b&&L(O.prototype,b),_&&L(O,_),Object.defineProperty(O,"prototype",{writable:!1}),O}var M=function(){function O(_){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=O.prototype;return b.setStreamController=function(y){this.streamController=y},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 y=this.hls;y.on(P.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.on(P.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.on(P.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.on(P.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.on(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},b.unregisterListener=function(){var y=this.hls;y.off(P.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.off(P.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.off(P.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.off(P.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.off(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},b.onFpsDropLevelCapping=function(y,x){O.isLevelAllowed(x.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(x.droppedLevel)},b.onMediaAttaching=function(y,x){this.media=x.media instanceof HTMLVideoElement?x.media:null},b.onManifestParsed=function(y,x){var D=this.hls;this.restrictedLevels=[],this.firstLevel=x.firstLevel,D.config.capLevelToPlayerSize&&x.video&&this.startCapping()},b.onBufferCodecs=function(y,x){var D=this.hls;D.config.capLevelToPlayerSize&&x.video&&this.startCapping()},b.onMediaDetaching=function(){this.stopCapping()},b.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var y=this.hls.levels;if(y.length){var x=this.hls;x.autoLevelCapping=this.getMaxLevel(y.length-1),x.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=x.autoLevelCapping}}},b.getMaxLevel=function(y){var x=this,D=this.hls.levels;if(!D.length)return-1;var E=D.filter(function(m,p){return O.isLevelAllowed(p,x.restrictedLevels)&&p<=y});return this.clientRect=null,O.getMaxLevelByMediaSize(E,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 y=this.media,x={width:0,height:0};if(y){var D=y.getBoundingClientRect();x.width=D.width,x.height=D.height,!x.width&&!x.height&&(x.width=D.right-D.left||y.width||0,x.height=D.bottom-D.top||y.height||0)}return this.clientRect=x,x},O.isLevelAllowed=function(y,x){return x===void 0&&(x=[]),x.indexOf(y)===-1},O.getMaxLevelByMediaSize=function(y,x,D){if(!y||!y.length)return-1;for(var E=function(s,h){return h?s.width!==h.width||s.height!==h.height:!0},m=y.length-1,p=0;p<y.length;p+=1){var f=y[p];if((f.width>=x||f.height>=D)&&E(f,y[p+1])){m=p;break}}return m},A(O,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var y=1;if(!this.hls.config.ignoreDevicePixelRatio)try{y=self.devicePixelRatio}catch{}return y}}]),O}();R.default=M},"./src/controller/cmcd-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return E});var P=l("./src/events.ts"),L=l("./src/types/cmcd.ts"),A=l("./src/utils/buffer-helper.ts"),M=l("./src/utils/logger.ts");function O(m,p){for(var f=0;f<p.length;f++){var e=p[f];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(m,e.key,e)}}function b(m,p,f){return p&&O(m.prototype,p),f&&O(m,f),Object.defineProperty(m,"prototype",{writable:!1}),m}function _(m,p){var f=typeof Symbol!="undefined"&&m[Symbol.iterator]||m["@@iterator"];if(f)return(f=f.call(m)).next.bind(f);if(Array.isArray(m)||(f=y(m))||p&&m&&typeof m.length=="number"){f&&(m=f);var e=0;return function(){return e>=m.length?{done:!0}:{done:!1,value:m[e++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
13
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function y(m,p){if(!!m){if(typeof m=="string")return x(m,p);var f=Object.prototype.toString.call(m).slice(8,-1);if(f==="Object"&&m.constructor&&(f=m.constructor.name),f==="Map"||f==="Set")return Array.from(m);if(f==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(f))return x(m,p)}}function x(m,p){(p==null||p>m.length)&&(p=m.length);for(var f=0,e=new Array(p);f<p;f++)e[f]=m[f];return e}function D(){return D=Object.assign?Object.assign.bind():function(m){for(var p=1;p<arguments.length;p++){var f=arguments[p];for(var e in f)Object.prototype.hasOwnProperty.call(f,e)&&(m[e]=f[e])}return m},D.apply(this,arguments)}var E=function(){function m(f){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(g){try{e.apply(g,{ot:L.CMCDObjectType.MANIFEST,su:!e.initialized})}catch(i){M.logger.warn("Could not generate manifest CMCD data.",i)}},this.applyFragmentData=function(g){try{var i=g.frag,r=e.hls.levels[i.level],o=e.getObjectType(i),c={d:i.duration*1e3,ot:o};(o===L.CMCDObjectType.VIDEO||o===L.CMCDObjectType.AUDIO||o==L.CMCDObjectType.MUXED)&&(c.br=r.bitrate/1e3,c.tb=e.getTopBandwidth(o)/1e3,c.bl=e.getBufferLength(o)),e.apply(g,c)}catch(t){M.logger.warn("Could not generate segment CMCD data.",t)}},this.hls=f;var s=this.config=f.config,h=s.cmcd;h!=null&&(s.pLoader=this.createPlaylistLoader(),s.fLoader=this.createFragmentLoader(),this.sid=h.sessionId||m.uuid(),this.cid=h.contentId,this.useHeaders=h.useHeaders===!0,this.registerListeners())}var p=m.prototype;return p.registerListeners=function(){var e=this.hls;e.on(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(P.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(P.Events.BUFFER_CREATED,this.onBufferCreated,this)},p.unregisterListeners=function(){var e=this.hls;e.off(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(P.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(P.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},p.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},p.onMediaAttached=function(e,s){this.media=s.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},p.onMediaDetached=function(){!this.media||(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},p.onBufferCreated=function(e,s){var h,g;this.audioBuffer=(h=s.tracks.audio)===null||h===void 0?void 0:h.buffer,this.videoBuffer=(g=s.tracks.video)===null||g===void 0?void 0:g.buffer},p.createData=function(){var e;return{v:L.CMCDVersion,sf:L.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)===null||e===void 0?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},p.apply=function(e,s){s===void 0&&(s={}),D(s,this.createData());var h=s.ot===L.CMCDObjectType.INIT||s.ot===L.CMCDObjectType.VIDEO||s.ot===L.CMCDObjectType.MUXED;if(this.starved&&h&&(s.bs=!0,s.su=!0,this.starved=!1),s.su==null&&(s.su=this.buffering),this.useHeaders){var g=m.toHeaders(s);if(!Object.keys(g).length)return;e.headers||(e.headers={}),D(e.headers,g)}else{var i=m.toQuery(s);if(!i)return;e.url=m.appendQueryToUri(e.url,i)}},p.getObjectType=function(e){var s=e.type;if(s==="subtitle")return L.CMCDObjectType.TIMED_TEXT;if(e.sn==="initSegment")return L.CMCDObjectType.INIT;if(s==="audio")return L.CMCDObjectType.AUDIO;if(s==="main")return this.hls.audioTracks.length?L.CMCDObjectType.VIDEO:L.CMCDObjectType.MUXED},p.getTopBandwidth=function(e){var s=0,h,g=this.hls;if(e===L.CMCDObjectType.AUDIO)h=g.audioTracks;else{var i=g.maxAutoLevel,r=i>-1?i+1:g.levels.length;h=g.levels.slice(0,r)}for(var o=_(h),c;!(c=o()).done;){var t=c.value;t.bitrate>s&&(s=t.bitrate)}return s>0?s:NaN},p.getBufferLength=function(e){var s=this.hls.media,h=e===L.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!h||!s)return NaN;var g=A.BufferHelper.bufferInfo(h,s.currentTime,this.config.maxBufferHole);return g.len*1e3},p.createPlaylistLoader=function(){var e=this.config.pLoader,s=this.applyPlaylistData,h=e||this.config.loader;return function(){function g(r){this.loader=void 0,this.loader=new h(r)}var i=g.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(o,c,t){s(o),this.loader.load(o,c,t)},b(g,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),g}()},p.createFragmentLoader=function(){var e=this.config.fLoader,s=this.applyFragmentData,h=e||this.config.loader;return function(){function g(r){this.loader=void 0,this.loader=new h(r)}var i=g.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(o,c,t){s(o),this.loader.load(o,c,t)},b(g,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),g}()},m.uuid=function(){var e=URL.createObjectURL(new Blob),s=e.toString();return URL.revokeObjectURL(e),s.slice(s.lastIndexOf("/")+1)},m.serialize=function(e){for(var s=[],h=function(I){return!Number.isNaN(I)&&I!=null&&I!==""&&I!==!1},g=function(I){return Math.round(I)},i=function(I){return g(I/100)*100},r=function(I){return encodeURIComponent(I)},o={br:g,d:g,bl:i,dl:i,mtp:i,nor:r,rtp:i,tb:g},c=Object.keys(e||{}).sort(),t=_(c),n;!(n=t()).done;){var u=n.value,a=e[u];if(!!h(a)&&!(u==="v"&&a===1)&&!(u=="pr"&&a===1)){var d=o[u];d&&(a=d(a));var v=typeof a,S=void 0;u==="ot"||u==="sf"||u==="st"?S=u+"="+a:v==="boolean"?S=u:v==="number"?S=u+"="+a:S=u+"="+JSON.stringify(a),s.push(S)}}return s.join(",")},m.toHeaders=function(e){for(var s=Object.keys(e),h={},g=["Object","Request","Session","Status"],i=[{},{},{},{}],r={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},o=0,c=s;o<c.length;o++){var t=c[o],n=r[t]!=null?r[t]:1;i[n][t]=e[t]}for(var u=0;u<i.length;u++){var a=m.serialize(i[u]);a&&(h["CMCD-"+g[u]]=a)}return h},m.toQuery=function(e){return"CMCD="+encodeURIComponent(m.serialize(e))},m.appendQueryToUri=function(e,s){if(!s)return e;var h=e.includes("?")?"&":"?";return""+e+h+s},m}()},"./src/controller/eme-controller.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/events.ts"),L=l("./src/errors.ts"),A=l("./src/utils/logger.ts"),M=l("./src/utils/mediakeys-helper.ts");function O(E,m){for(var p=0;p<m.length;p++){var f=m[p];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(E,f.key,f)}}function b(E,m,p){return m&&O(E.prototype,m),p&&O(E,p),Object.defineProperty(E,"prototype",{writable:!1}),E}var _=3,y=function(m,p,f){var e={audioCapabilities:[],videoCapabilities:[]};return m.forEach(function(s){e.audioCapabilities.push({contentType:'audio/mp4; codecs="'+s+'"',robustness:f.audioRobustness||""})}),p.forEach(function(s){e.videoCapabilities.push({contentType:'video/mp4; codecs="'+s+'"',robustness:f.videoRobustness||""})}),[e]},x=function(m,p,f,e){switch(m){case M.KeySystems.WIDEVINE:return y(p,f,e);default:throw new Error("Unknown key-system: "+m)}},D=function(){function E(p){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=p,this._config=p.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var m=E.prototype;return m.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},m._registerListeners=function(){this.hls.on(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(P.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(P.Events.MANIFEST_PARSED,this.onManifestParsed,this)},m._unregisterListeners=function(){this.hls.off(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(P.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(P.Events.MANIFEST_PARSED,this.onManifestParsed,this)},m.getLicenseServerUrl=function(f){switch(f){case M.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+f+'"')},m._attemptKeySystemAccess=function(f,e,s){var h=this,g=x(f,e,s,this._drmSystemOptions);A.logger.log("Requesting encrypted media key-system access");var i=this.requestMediaKeySystemAccess(f,g);this.mediaKeysPromise=i.then(function(r){return h._onMediaKeySystemAccessObtained(f,r)}),i.catch(function(r){A.logger.error('Failed to obtain key-system "'+f+'" access:',r)})},m._onMediaKeySystemAccessObtained=function(f,e){var s=this;A.logger.log('Access for key-system "'+f+'" obtained');var h={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:e,mediaKeySystemDomain:f};this._mediaKeysList.push(h);var g=Promise.resolve().then(function(){return e.createMediaKeys()}).then(function(i){return h.mediaKeys=i,A.logger.log('Media-keys created for key-system "'+f+'"'),s._onMediaKeysCreated(),i});return g.catch(function(i){A.logger.error("Failed to create media-keys:",i)}),g},m._onMediaKeysCreated=function(){var f=this;this._mediaKeysList.forEach(function(e){e.mediaKeysSession||(e.mediaKeysSession=e.mediaKeys.createSession(),f._onNewMediaKeySession(e.mediaKeysSession))})},m._onNewMediaKeySession=function(f){var e=this;A.logger.log("New key-system session "+f.sessionId),f.addEventListener("message",function(s){e._onKeySessionMessage(f,s.message)},!1)},m._onKeySessionMessage=function(f,e){A.logger.log("Got EME message event, creating license request"),this._requestLicense(e,function(s){A.logger.log("Received license data (length: "+(s&&s.byteLength)+"), updating key-session"),f.update(s).catch(function(h){A.logger.warn("Updating key-session failed: "+h)})})},m.onMediaEncrypted=function(f){var e=this;if(A.logger.log('Media is encrypted using "'+f.initDataType+'" init data type'),!this.mediaKeysPromise){A.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var s=function(g){!e._media||(e._attemptSetMediaKeys(g),e._generateRequestWithPreferredKeySession(f.initDataType,f.initData))};this.mediaKeysPromise.then(s).catch(s)},m._attemptSetMediaKeys=function(f){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){A.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}A.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}},m._generateRequestWithPreferredKeySession=function(f,e){var s=this,h=this._mediaKeysList[0];if(!h){A.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(h.mediaKeysSessionInitialized){A.logger.warn("Key-Session already initialized but requested again");return}var g=h.mediaKeysSession;if(!g){A.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!e){A.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}A.logger.log('Generating key-session request for "'+f+'" init data type'),h.mediaKeysSessionInitialized=!0,g.generateRequest(f,e).then(function(){A.logger.debug("Key-session generation succeeded")}).catch(function(i){A.logger.error("Error generating key-session request:",i),s.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},m._createLicenseXhr=function(f,e,s){var h=new XMLHttpRequest;h.responseType="arraybuffer",h.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,h,f,e,s);var g=this._licenseXhrSetup;if(g)try{g.call(this.hls,h,f),g=void 0}catch(i){A.logger.error(i)}try{h.readyState||h.open("POST",f,!0),g&&g.call(this.hls,h,f)}catch(i){throw new Error("issue setting up KeySystem license XHR "+i)}return h},m._onLicenseRequestReadyStageChange=function(f,e,s,h){switch(f.readyState){case 4:if(f.status===200){this._requestLicenseFailureCount=0,A.logger.log("License request succeeded");var g=f.response,i=this._licenseResponseCallback;if(i)try{g=i.call(this.hls,f,e)}catch(o){A.logger.error(o)}h(g)}else{if(A.logger.error("License Request XHR failed ("+e+"). Status: "+f.status+" ("+f.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>_){this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var r=_-this._requestLicenseFailureCount+1;A.logger.warn("Retrying license request, "+r+" attempts left"),this._requestLicense(s,h)}break}},m._generateLicenseRequestChallenge=function(f,e){switch(f.mediaKeySystemDomain){case M.KeySystems.WIDEVINE:return e}throw new Error("unsupported key-system: "+f.mediaKeySystemDomain)},m._requestLicense=function(f,e){A.logger.log("Requesting content license for key-system");var s=this._mediaKeysList[0];if(!s){A.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var h=this.getLicenseServerUrl(s.mediaKeySystemDomain),g=this._createLicenseXhr(h,f,e);A.logger.log("Sending license request to URL: "+h);var i=this._generateLicenseRequestChallenge(s,f);g.send(i)}catch(r){A.logger.error("Failure requesting DRM license: "+r),this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},m.onMediaAttached=function(f,e){if(!!this._emeEnabled){var s=e.media;this._media=s,s.addEventListener("encrypted",this._onMediaEncrypted)}},m.onMediaDetached=function(){var f=this._media,e=this._mediaKeysList;!f||(f.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(e.map(function(s){if(s.mediaKeysSession)return s.mediaKeysSession.close().catch(function(){})})).then(function(){return f.setMediaKeys(null)}).catch(function(){}))},m.onManifestParsed=function(f,e){if(!!this._emeEnabled){var s=e.levels.map(function(g){return g.audioCodec}).filter(function(g){return!!g}),h=e.levels.map(function(g){return g.videoCodec}).filter(function(g){return!!g});this._attemptKeySystemAccess(M.KeySystems.WIDEVINE,s,h)}},b(E,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),E}();R.default=D},"./src/controller/fps-controller.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/events.ts"),L=l("./src/utils/logger.ts"),A=function(){function M(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 O=M.prototype;return O.setStreamController=function(_){this.streamController=_},O.registerListeners=function(){this.hls.on(P.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},O.unregisterListeners=function(){this.hls.off(P.Events.MEDIA_ATTACHING,this.onMediaAttaching)},O.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},O.onMediaAttaching=function(_,y){var x=this.hls.config;if(x.capLevelOnFPSDrop){var D=y.media instanceof self.HTMLVideoElement?y.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),x.fpsDroppedMonitoringPeriod)}},O.checkFPS=function(_,y,x){var D=performance.now();if(y){if(this.lastTime){var E=D-this.lastTime,m=x-this.lastDroppedFrames,p=y-this.lastDecodedFrames,f=1e3*m/E,e=this.hls;if(e.trigger(P.Events.FPS_DROP,{currentDropped:m,currentDecoded:p,totalDroppedFrames:x}),f>0&&m>e.config.fpsDroppedMonitoringThreshold*p){var s=e.currentLevel;L.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+s),s>0&&(e.autoLevelCapping===-1||e.autoLevelCapping>=s)&&(s=s-1,e.trigger(P.Events.FPS_DROP_LEVEL_CAPPING,{level:s,droppedLevel:e.currentLevel}),e.autoLevelCapping=s,this.streamController.nextLevelSwitch())}}this.lastTime=D,this.lastDroppedFrames=x,this.lastDecodedFrames=y}},O.checkFPSInterval=function(){var _=this.media;if(_)if(this.isVideoPlaybackQualityAvailable){var y=_.getVideoPlaybackQuality();this.checkFPS(_,y.totalVideoFrames,y.droppedVideoFrames)}else this.checkFPS(_,_.webkitDecodedFrameCount,_.webkitDroppedFrameCount)},M}();R.default=A},"./src/controller/fragment-finders.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"findFragmentByPDT",function(){return A}),l.d(R,"findFragmentByPTS",function(){return M}),l.d(R,"fragmentWithinToleranceTest",function(){return O}),l.d(R,"pdtWithinToleranceTest",function(){return b}),l.d(R,"findFragWithCC",function(){return _});var P=l("./src/polyfills/number.ts"),L=l("./src/utils/binary-search.ts");function A(y,x,D){if(x===null||!Array.isArray(y)||!y.length||!Object(P.isFiniteNumber)(x))return null;var E=y[0].programDateTime;if(x<(E||0))return null;var m=y[y.length-1].endProgramDateTime;if(x>=(m||0))return null;D=D||0;for(var p=0;p<y.length;++p){var f=y[p];if(b(x,D,f))return f}return null}function M(y,x,D,E){D===void 0&&(D=0),E===void 0&&(E=0);var m=null;if(y?m=x[y.sn-x[0].sn+1]||null:D===0&&x[0].start===0&&(m=x[0]),m&&O(D,E,m)===0)return m;var p=L.default.search(x,O.bind(null,D,E));return p||m}function O(y,x,D){y===void 0&&(y=0),x===void 0&&(x=0);var E=Math.min(x,D.duration+(D.deltaPTS?D.deltaPTS:0));return D.start+D.duration-E<=y?1:D.start-E>y&&D.start?-1:0}function b(y,x,D){var E=Math.min(x,D.duration+(D.deltaPTS?D.deltaPTS:0))*1e3,m=D.endProgramDateTime||0;return m-E>y}function _(y,x){return L.default.search(y,function(D){return D.cc<x?1:D.cc>x?-1:0})}},"./src/controller/fragment-tracker.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"FragmentState",function(){return A}),l.d(R,"FragmentTracker",function(){return M});var P=l("./src/events.ts"),L=l("./src/types/loader.ts"),A;(function(_){_.NOT_LOADED="NOT_LOADED",_.APPENDING="APPENDING",_.PARTIAL="PARTIAL",_.OK="OK"})(A||(A={}));var M=function(){function _(x){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=x,this._registerListeners()}var y=_.prototype;return y._registerListeners=function(){var D=this.hls;D.on(P.Events.BUFFER_APPENDED,this.onBufferAppended,this),D.on(P.Events.FRAG_BUFFERED,this.onFragBuffered,this),D.on(P.Events.FRAG_LOADED,this.onFragLoaded,this)},y._unregisterListeners=function(){var D=this.hls;D.off(P.Events.BUFFER_APPENDED,this.onBufferAppended,this),D.off(P.Events.FRAG_BUFFERED,this.onFragBuffered,this),D.off(P.Events.FRAG_LOADED,this.onFragLoaded,this)},y.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},y.getAppendedFrag=function(D,E){if(E===L.PlaylistLevelType.MAIN){var m=this.activeFragment,p=this.activeParts;if(!m)return null;if(p)for(var f=p.length;f--;){var e=p[f],s=e?e.end:m.appendedPTS;if(e.start<=D&&s!==void 0&&D<=s)return f>9&&(this.activeParts=p.slice(f-9)),e}else if(m.start<=D&&m.appendedPTS!==void 0&&D<=m.appendedPTS)return m}return this.getBufferedFrag(D,E)},y.getBufferedFrag=function(D,E){for(var m=this.fragments,p=Object.keys(m),f=p.length;f--;){var e=m[p[f]];if((e==null?void 0:e.body.type)===E&&e.buffered){var s=e.body;if(s.start<=D&&D<=s.end)return s}}return null},y.detectEvictedFragments=function(D,E,m){var p=this;Object.keys(this.fragments).forEach(function(f){var e=p.fragments[f];if(!!e){if(!e.buffered){e.body.type===m&&p.removeFragment(e.body);return}var s=e.range[D];!s||s.time.some(function(h){var g=!p.isTimeBuffered(h.startPTS,h.endPTS,E);return g&&p.removeFragment(e.body),g})}})},y.detectPartialFragments=function(D){var E=this,m=this.timeRanges,p=D.frag,f=D.part;if(!(!m||p.sn==="initSegment")){var e=b(p),s=this.fragments[e];!s||(Object.keys(m).forEach(function(h){var g=p.elementaryStreams[h];if(!!g){var i=m[h],r=f!==null||g.partial===!0;s.range[h]=E.getBufferedTimes(p,f,r,i)}}),s.loaded=null,Object.keys(s.range).length?s.buffered=!0:this.removeFragment(s.body))}},y.fragBuffered=function(D){var E=b(D),m=this.fragments[E];m&&(m.loaded=null,m.buffered=!0)},y.getBufferedTimes=function(D,E,m,p){for(var f={time:[],partial:m},e=E?E.start:D.start,s=E?E.end:D.end,h=D.minEndPTS||s,g=D.maxStartPTS||e,i=0;i<p.length;i++){var r=p.start(i)-this.bufferPadding,o=p.end(i)+this.bufferPadding;if(g>=r&&h<=o){f.time.push({startPTS:Math.max(e,p.start(i)),endPTS:Math.min(s,p.end(i))});break}else if(e<o&&s>r)f.partial=!0,f.time.push({startPTS:Math.max(e,p.start(i)),endPTS:Math.min(s,p.end(i))});else if(s<=r)break}return f},y.getPartialFragment=function(D){var E=null,m,p,f,e=0,s=this.bufferPadding,h=this.fragments;return Object.keys(h).forEach(function(g){var i=h[g];!i||O(i)&&(p=i.body.start-s,f=i.body.end+s,D>=p&&D<=f&&(m=Math.min(D-p,f-D),e<=m&&(E=i.body,e=m)))}),E},y.getState=function(D){var E=b(D),m=this.fragments[E];return m?m.buffered?O(m)?A.PARTIAL:A.OK:A.APPENDING:A.NOT_LOADED},y.isTimeBuffered=function(D,E,m){for(var p,f,e=0;e<m.length;e++){if(p=m.start(e)-this.bufferPadding,f=m.end(e)+this.bufferPadding,D>=p&&E<=f)return!0;if(E<=p)return!1}return!1},y.onFragLoaded=function(D,E){var m=E.frag,p=E.part;if(!(m.sn==="initSegment"||m.bitrateTest||p)){var f=b(m);this.fragments[f]={body:m,loaded:E,buffered:!1,range:Object.create(null)}}},y.onBufferAppended=function(D,E){var m=this,p=E.frag,f=E.part,e=E.timeRanges;if(p.type===L.PlaylistLevelType.MAIN)if(this.activeFragment=p,f){var s=this.activeParts;s||(this.activeParts=s=[]),s.push(f)}else this.activeParts=null;this.timeRanges=e,Object.keys(e).forEach(function(h){var g=e[h];if(m.detectEvictedFragments(h,g),!f)for(var i=0;i<g.length;i++)p.appendedPTS=Math.max(g.end(i),p.appendedPTS||0)})},y.onFragBuffered=function(D,E){this.detectPartialFragments(E)},y.hasFragment=function(D){var E=b(D);return!!this.fragments[E]},y.removeFragmentsInRange=function(D,E,m){var p=this;Object.keys(this.fragments).forEach(function(f){var e=p.fragments[f];if(!!e&&e.buffered){var s=e.body;s.type===m&&s.start<E&&s.end>D&&p.removeFragment(s)}})},y.removeFragment=function(D){var E=b(D);D.stats.loaded=0,D.clearElementaryStreamInfo(),delete this.fragments[E]},y.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},_}();function O(_){var y,x;return _.buffered&&(((y=_.range.video)===null||y===void 0?void 0:y.partial)||((x=_.range.audio)===null||x===void 0?void 0:x.partial))}function b(_){return _.type+"_"+_.level+"_"+_.urlId+"_"+_.sn}},"./src/controller/gap-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"STALL_MINIMUM_DURATION_MS",function(){return O}),l.d(R,"MAX_START_GAP_JUMP",function(){return b}),l.d(R,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return _}),l.d(R,"SKIP_BUFFER_RANGE_START",function(){return y}),l.d(R,"default",function(){return x});var P=l("./src/utils/buffer-helper.ts"),L=l("./src/errors.ts"),A=l("./src/events.ts"),M=l("./src/utils/logger.ts"),O=250,b=2,_=.1,y=.05,x=function(){function D(m,p,f,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=m,this.media=p,this.fragmentTracker=f,this.hls=e}var E=D.prototype;return E.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},E.poll=function(p,f){var e=this.config,s=this.media,h=this.stalled;if(s!==null){var g=s.currentTime,i=s.seeking,r=this.seeking&&!i,o=!this.seeking&&i;if(this.seeking=i,g!==p){if(this.moved=!0,h!==null){if(this.stallReported){var c=self.performance.now()-h;M.logger.warn("playback not stuck anymore @"+g+", after "+Math.round(c)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((o||r)&&(this.stalled=null),!(s.paused&&!i||s.ended||s.playbackRate===0||!P.BufferHelper.getBuffered(s).length)){var t=P.BufferHelper.bufferInfo(s,g,0),n=t.len>0,u=t.nextStart||0;if(!(!n&&!u)){if(i){var a=t.len>b,d=!u||f&&f.start<=g||u-g>b&&!this.fragmentTracker.getPartialFragment(g);if(a||d)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var v,S=Math.max(u,t.start||0)-g,T=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,I=T==null||(v=T.details)===null||v===void 0?void 0:v.live,k=I?T.details.targetduration*2:b;if(S>0&&S<=k){this._trySkipBufferHole(null);return}}var B=self.performance.now();if(h===null){this.stalled=B;return}var U=B-h;if(!(!i&&U>=O&&(this._reportStall(t),!this.media))){var W=P.BufferHelper.bufferInfo(s,g,e.maxBufferHole);this._tryFixBufferStall(W,U)}}}}},E._tryFixBufferStall=function(p,f){var e=this.config,s=this.fragmentTracker,h=this.media;if(h!==null){var g=h.currentTime,i=s.getPartialFragment(g);if(i){var r=this._trySkipBufferHole(i);if(r||!this.media)return}p.len>e.maxBufferHole&&f>e.highBufferWatchdogPeriod*1e3&&(M.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},E._reportStall=function(p){var f=this.hls,e=this.media,s=this.stallReported;!s&&e&&(this.stallReported=!0,M.logger.warn("Playback stalling at @"+e.currentTime+" due to low buffer ("+JSON.stringify(p)+")"),f.trigger(A.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:p.len}))},E._trySkipBufferHole=function(p){var f=this.config,e=this.hls,s=this.media;if(s===null)return 0;for(var h=s.currentTime,g=0,i=P.BufferHelper.getBuffered(s),r=0;r<i.length;r++){var o=i.start(r);if(h+f.maxBufferHole>=g&&h<o){var c=Math.max(o+y,s.currentTime+_);return M.logger.warn("skipping hole, adjusting currentTime from "+h+" to "+c),this.moved=!0,this.stalled=null,s.currentTime=c,p&&e.trigger(A.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+h+" to "+c,frag:p}),c}g=i.end(r)}return 0},E._tryNudgeBuffer=function(){var p=this.config,f=this.hls,e=this.media,s=this.nudgeRetry;if(e!==null){var h=e.currentTime;if(this.nudgeRetry++,s<p.nudgeMaxRetry){var g=h+(s+1)*p.nudgeOffset;M.logger.warn("Nudging 'currentTime' from "+h+" to "+g),e.currentTime=g,f.trigger(A.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else M.logger.error("Playhead still not moving while enough data buffered @"+h+" after "+p.nudgeMaxRetry+" nudges"),f.trigger(A.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},D}()},"./src/controller/id3-track-controller.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/polyfills/number.ts"),L=l("./src/events.ts"),A=l("./src/utils/texttrack-utils.ts"),M=l("./src/demux/id3.ts"),O=l("./src/loader/date-range.ts"),b=l("./src/types/demuxer.ts"),_=.25;function y(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}function x(m,p){return m.getTime()/1e3-p}function D(m){return Uint8Array.from(m.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var E=function(){function m(f){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=f,this._registerListeners()}var p=m.prototype;return p.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},p._registerListeners=function(){var e=this.hls;e.on(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(L.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},p._unregisterListeners=function(){var e=this.hls;e.off(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(L.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},p.onMediaAttached=function(e,s){this.media=s.media},p.onMediaDetaching=function(){!this.id3Track||(Object(A.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},p.onManifestLoading=function(){this.dateRangeCuesAppended={}},p.createTrack=function(e){var s=this.getID3Track(e.textTracks);return s.mode="hidden",s},p.getID3Track=function(e){if(!!this.media){for(var s=0;s<e.length;s++){var h=e[s];if(h.kind==="metadata"&&h.label==="id3")return Object(A.sendAddTrackEvent)(h,this.media),h}return this.media.addTextTrack("metadata","id3")}},p.onFragParsingMetadata=function(e,s){if(!!this.media){var h=this.hls.config,g=h.enableEmsgMetadataCues,i=h.enableID3MetadataCues;if(!(!g&&!i)){var r=s.frag,o=s.samples,c=s.details;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var t=c.edge||r.end,n=y(),u=!1,a={},d=0;d<o.length;d++){var v=o[d].type;if(!(v===b.MetadataSchema.emsg&&!g||!i)){var S=M.getID3Frames(o[d].data);if(S){var T=o[d].pts,I=t,k=I-T;k<=0&&(I=T+_);for(var B=0;B<S.length;B++){var U=S[B];if(!M.isTimeStampFrame(U)){var W=new n(T,I,"");W.value=U,v&&(W.type=v),this.id3Track.addCue(W),a[U.key]=null,u=!0}}}}}u&&this.updateId3CueEnds(a)}}},p.updateId3CueEnds=function(e){var s,h=(s=this.id3Track)===null||s===void 0?void 0:s.cues;if(h)for(var g=h.length;g--;){var i,r=h[g],o=(i=r.value)===null||i===void 0?void 0:i.key;if(o&&o in e){var c=e[o];c&&r.endTime!==c&&(r.endTime=c),e[o]=r.startTime}}},p.onBufferFlushing=function(e,s){var h=s.startOffset,g=s.endOffset,i=s.type,r=this.id3Track,o=this.hls;if(!!o){var c=o.config,t=c.enableEmsgMetadataCues,n=c.enableID3MetadataCues;if(r&&(t||n)){var u;i==="audio"?u=function(d){return d.type===b.MetadataSchema.audioId3&&n}:i==="video"?u=function(d){return d.type===b.MetadataSchema.emsg&&t}:u=function(d){return d.type===b.MetadataSchema.audioId3&&n||d.type===b.MetadataSchema.emsg&&t},Object(A.removeCuesInRange)(r,h,g,u)}}},p.onLevelUpdated=function(e,s){var h=this,g=s.details;if(!(!this.media||!g.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var i=this.dateRangeCuesAppended,r=this.id3Track,o=g.dateRanges,c=Object.keys(o);if(r)for(var t=Object.keys(i).filter(function(k){return!c.includes(k)}),n=function(B){var U=t[B];Object.keys(i[U].cues).forEach(function(W){r.removeCue(i[U].cues[W])}),delete i[U]},u=t.length;u--;)n(u);var a=g.fragments[g.fragments.length-1];if(!(c.length===0||!Object(P.isFiniteNumber)(a==null?void 0:a.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var d=a.programDateTime/1e3-a.start,v=g.edge||a.end,S=y(),T=function(B){var U=c[B],W=o[U],G=i[U],z=(G==null?void 0:G.cues)||{},Y=(G==null?void 0:G.durationKnown)||!1,$=x(W.startDate,d),Z=v,q=W.endDate;if(q)Z=x(q,d),Y=!0;else if(W.endOnNext&&!Y){var ie=c.reduce(function(re,Ee){var me=o[Ee];return me.class===W.class&&me.id!==Ee&&me.startDate>W.startDate&&re.push(me),re},[]).sort(function(re,Ee){return re.startDate.getTime()-Ee.startDate.getTime()})[0];ie&&(Z=x(ie.startDate,d),Y=!0)}for(var ne=Object.keys(W.attr),ae=0;ae<ne.length;ae++){var te=ne[ae];if(!(te===O.DateRangeAttribute.ID||te===O.DateRangeAttribute.CLASS||te===O.DateRangeAttribute.START_DATE||te===O.DateRangeAttribute.DURATION||te===O.DateRangeAttribute.END_DATE||te===O.DateRangeAttribute.END_ON_NEXT)){var fe=z[te];if(fe)Y&&!G.durationKnown&&(fe.endTime=Z);else{var de=W.attr[te];fe=new S($,Z,""),(te===O.DateRangeAttribute.SCTE35_OUT||te===O.DateRangeAttribute.SCTE35_IN)&&(de=D(de)),fe.value={key:te,data:de},fe.type=b.MetadataSchema.dateRange,h.id3Track.addCue(fe),z[te]=fe}}}i[U]={cues:z,dateRange:W,durationKnown:Y}},I=0;I<c.length;I++)T(I)}}},m}();R.default=E},"./src/controller/latency-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return b});var P=l("./src/errors.ts"),L=l("./src/events.ts"),A=l("./src/utils/logger.ts");function M(_,y){for(var x=0;x<y.length;x++){var D=y[x];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(_,D.key,D)}}function O(_,y,x){return y&&M(_.prototype,y),x&&M(_,x),Object.defineProperty(_,"prototype",{writable:!1}),_}var b=function(){function _(x){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=x,this.config=x.config,this.registerListeners()}var y=_.prototype;return y.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},y.registerListeners=function(){this.hls.on(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(L.Events.ERROR,this.onError,this)},y.unregisterListeners=function(){this.hls.off(L.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(L.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(L.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(L.Events.ERROR,this.onError)},y.onMediaAttached=function(D,E){this.media=E.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},y.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},y.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},y.onLevelUpdated=function(D,E){var m=E.details;this.levelDetails=m,m.advanced&&this.timeupdate(),!m.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},y.onError=function(D,E){E.details===P.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,A.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},y.timeupdate=function(){var D=this.media,E=this.levelDetails;if(!(!D||!E)){this.currentTime=D.currentTime;var m=this.computeLatency();if(m!==null){this._latency=m;var p=this.config,f=p.lowLatencyMode,e=p.maxLiveSyncPlaybackRate;if(!(!f||e===1)){var s=this.targetLatency;if(s!==null){var h=m-s,g=Math.min(this.maxLatency,s+E.targetduration),i=h<g;if(E.live&&i&&h>.05&&this.forwardBufferLength>1){var r=Math.min(2,Math.max(1,e)),o=Math.round(2/(1+Math.exp(-.75*h-this.edgeStalled))*20)/20;D.playbackRate=Math.min(r,Math.max(1,o))}else D.playbackRate!==1&&D.playbackRate!==0&&(D.playbackRate=1)}}}}},y.estimateLiveEdge=function(){var D=this.levelDetails;return D===null?null:D.edge+D.age},y.computeLatency=function(){var D=this.estimateLiveEdge();return D===null?null:D-this.currentTime},O(_,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var D=this.config,E=this.levelDetails;return D.liveMaxLatencyDuration!==void 0?D.liveMaxLatencyDuration:E?D.liveMaxLatencyDurationCount*E.targetduration:0}},{key:"targetLatency",get:function(){var D=this.levelDetails;if(D===null)return null;var E=D.holdBack,m=D.partHoldBack,p=D.targetduration,f=this.config,e=f.liveSyncDuration,s=f.liveSyncDurationCount,h=f.lowLatencyMode,g=this.hls.userConfig,i=h&&m||E;(g.liveSyncDuration||g.liveSyncDurationCount||i===0)&&(i=e!==void 0?e:s*p);var r=p,o=1;return i+Math.min(this.stallCount*o,r)}},{key:"liveSyncPosition",get:function(){var D=this.estimateLiveEdge(),E=this.targetLatency,m=this.levelDetails;if(D===null||E===null||m===null)return null;var p=m.edge,f=D-E-this.edgeStalled,e=p-m.totalduration,s=p-(this.config.lowLatencyMode&&m.partTarget||m.targetduration);return Math.min(Math.max(e,f),s)}},{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 E=(this.config.lowLatencyMode&&D.partTarget||D.targetduration)*3;return Math.max(D.age-E,0)}},{key:"forwardBufferLength",get:function(){var D=this.media,E=this.levelDetails;if(!D||!E)return 0;var m=D.buffered.length;return(m?D.buffered.end(m-1):E.edge)-this.currentTime}}]),_}()},"./src/controller/level-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return f});var P=l("./src/types/level.ts"),L=l("./src/events.ts"),A=l("./src/errors.ts"),M=l("./src/utils/codecs.ts"),O=l("./src/controller/level-helper.ts"),b=l("./src/controller/base-playlist-controller.ts"),_=l("./src/types/loader.ts");function y(){return y=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var h=arguments[s];for(var g in h)Object.prototype.hasOwnProperty.call(h,g)&&(e[g]=h[g])}return e},y.apply(this,arguments)}function x(e,s){for(var h=0;h<s.length;h++){var g=s[h];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(e,g.key,g)}}function D(e,s,h){return s&&x(e.prototype,s),h&&x(e,h),Object.defineProperty(e,"prototype",{writable:!1}),e}function E(e,s){e.prototype=Object.create(s.prototype),e.prototype.constructor=e,m(e,s)}function m(e,s){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,i){return g.__proto__=i,g},m(e,s)}var p=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),f=function(e){E(s,e);function s(g){var i;return i=e.call(this,g,"[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 h=s.prototype;return h._registerListeners=function(){var i=this.hls;i.on(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.on(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.on(L.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.on(L.Events.FRAG_LOADED,this.onFragLoaded,this),i.on(L.Events.ERROR,this.onError,this)},h._unregisterListeners=function(){var i=this.hls;i.off(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.off(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.off(L.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.off(L.Events.FRAG_LOADED,this.onFragLoaded,this),i.off(L.Events.ERROR,this.onError,this)},h.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,e.prototype.destroy.call(this)},h.startLoad=function(){var i=this._levels;i.forEach(function(r){r.loadError=0}),e.prototype.startLoad.call(this)},h.onManifestLoaded=function(i,r){var o=[],c=[],t=[],n,u={},a,d=!1,v=!1,S=!1;if(r.levels.forEach(function(B){var U=B.attrs;d=d||!!(B.width&&B.height),v=v||!!B.videoCodec,S=S||!!B.audioCodec,p&&B.audioCodec&&B.audioCodec.indexOf("mp4a.40.34")!==-1&&(B.audioCodec=void 0);var W=B.bitrate+"-"+B.attrs.RESOLUTION+"-"+B.attrs.CODECS;a=u[W],a?a.url.push(B.url):(a=new P.Level(B),u[W]=a,o.push(a)),U&&(U.AUDIO&&Object(O.addGroupId)(a,"audio",U.AUDIO),U.SUBTITLES&&Object(O.addGroupId)(a,"text",U.SUBTITLES))}),(d||v)&&S&&(o=o.filter(function(B){var U=B.videoCodec,W=B.width,G=B.height;return!!U||!!(W&&G)})),o=o.filter(function(B){var U=B.audioCodec,W=B.videoCodec;return(!U||Object(M.isCodecSupportedInMp4)(U,"audio"))&&(!W||Object(M.isCodecSupportedInMp4)(W,"video"))}),r.audioTracks&&(c=r.audioTracks.filter(function(B){return!B.audioCodec||Object(M.isCodecSupportedInMp4)(B.audioCodec,"audio")}),Object(O.assignTrackIdsByGroup)(c)),r.subtitles&&(t=r.subtitles,Object(O.assignTrackIdsByGroup)(t)),o.length>0){n=o[0].bitrate,o.sort(function(B,U){return B.bitrate-U.bitrate}),this._levels=o;for(var T=0;T<o.length;T++)if(o[T].bitrate===n){this._firstLevel=T,this.log("manifest loaded, "+o.length+" level(s) found, first bitrate: "+n);break}var I=S&&!v,k={levels:o,audioTracks:c,subtitleTracks:t,firstLevel:this._firstLevel,stats:r.stats,audio:S,video:v,altAudio:!I&&c.some(function(B){return!!B.url})};this.hls.trigger(L.Events.MANIFEST_PARSED,k),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(L.Events.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,reason:"no level with compatible codecs found in manifest"})},h.onError=function(i,r){var o;if(e.prototype.onError.call(this,i,r),!r.fatal){var c=r.context,t=this._levels[this.currentLevelIndex];if(c&&(c.type===_.PlaylistContextType.AUDIO_TRACK&&t.audioGroupIds&&c.groupId===t.audioGroupIds[t.urlId]||c.type===_.PlaylistContextType.SUBTITLE_TRACK&&t.textGroupIds&&c.groupId===t.textGroupIds[t.urlId])){this.redundantFailover(this.currentLevelIndex);return}var n=!1,u=!0,a;switch(r.details){case A.ErrorDetails.FRAG_LOAD_ERROR:case A.ErrorDetails.FRAG_LOAD_TIMEOUT:case A.ErrorDetails.KEY_LOAD_ERROR:case A.ErrorDetails.KEY_LOAD_TIMEOUT:if(r.frag){var d=r.frag.type===_.PlaylistLevelType.MAIN?r.frag.level:this.currentLevelIndex,v=this._levels[d];v?(v.fragmentError++,v.fragmentError>this.hls.config.fragLoadingMaxRetry&&(a=d)):a=d}break;case A.ErrorDetails.LEVEL_LOAD_ERROR:case A.ErrorDetails.LEVEL_LOAD_TIMEOUT:c&&(c.deliveryDirectives&&(u=!1),a=c.level),n=!0;break;case A.ErrorDetails.REMUX_ALLOC_ERROR:a=(o=r.level)!=null?o:this.currentLevelIndex,n=!0;break}a!==void 0&&this.recoverLevel(r,a,n,u)}},h.recoverLevel=function(i,r,o,c){var t=i.details,n=this._levels[r];if(n.loadError++,o){var u=this.retryLoadingOrFail(i);if(u)i.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(c){var a=n.url.length;if(a>1&&n.loadError<a)i.levelRetry=!0,this.redundantFailover(r);else if(this.manualLevelIndex===-1){for(var d=-1,v=this._levels,S=v.length;S--;){var T=(S+this.currentLevelIndex)%v.length;if(T!==this.currentLevelIndex&&v[T].loadError===0){d=T;break}}d>-1&&this.currentLevelIndex!==d&&(this.warn(t+": switch to "+d),i.levelRetry=!0,this.hls.nextAutoLevel=d)}}},h.redundantFailover=function(i){var r=this._levels[i],o=r.url.length;if(o>1){var c=(r.urlId+1)%o;this.warn("Switching to redundant URL-id "+c),this._levels.forEach(function(t){t.urlId=c}),this.level=i}},h.onFragLoaded=function(i,r){var o=r.frag;if(o!==void 0&&o.type===_.PlaylistLevelType.MAIN){var c=this._levels[o.level];c!==void 0&&(c.fragmentError=0,c.loadError=0)}},h.onLevelLoaded=function(i,r){var o,c=r.level,t=r.details,n=this._levels[c];if(!n){var u;this.warn("Invalid level index "+c),(u=r.deliveryDirectives)!==null&&u!==void 0&&u.skip&&(t.deltaUpdateFailed=!0);return}c===this.currentLevelIndex?(n.fragmentError===0&&(n.loadError=0,this.retryCount=0),this.playlistLoaded(c,r,n.details)):(o=r.deliveryDirectives)!==null&&o!==void 0&&o.skip&&(t.deltaUpdateFailed=!0)},h.onAudioTrackSwitched=function(i,r){var o=this.hls.levels[this.currentLevelIndex];if(!!o&&o.audioGroupIds){for(var c=-1,t=this.hls.audioTracks[r.id].groupId,n=0;n<o.audioGroupIds.length;n++)if(o.audioGroupIds[n]===t){c=n;break}c!==o.urlId&&(o.urlId=c,this.startLoad())}},h.loadPlaylist=function(i){var r=this.currentLevelIndex,o=this._levels[r];if(this.canLoad&&o&&o.url.length>0){var c=o.urlId,t=o.url[c];if(i)try{t=i.addDirectives(t)}catch(n){this.warn("Could not construct new URL with HLS Delivery Directives: "+n)}this.log("Attempt loading level index "+r+(i?" at sn "+i.msn+" part "+i.part:"")+" with URL-id "+c+" "+t),this.clearTimer(),this.hls.trigger(L.Events.LEVEL_LOADING,{url:t,level:r,id:c,deliveryDirectives:i||null})}},h.removeLevel=function(i,r){var o=function(n,u){return u!==r},c=this._levels.filter(function(t,n){return n!==i?!0:t.url.length>1&&r!==void 0?(t.url=t.url.filter(o),t.audioGroupIds&&(t.audioGroupIds=t.audioGroupIds.filter(o)),t.textGroupIds&&(t.textGroupIds=t.textGroupIds.filter(o)),t.urlId=0,!0):!1}).map(function(t,n){var u=t.details;return u!=null&&u.fragments&&u.fragments.forEach(function(a){a.level=n}),t});this._levels=c,this.hls.trigger(L.Events.LEVELS_UPDATED,{levels:c})},D(s,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(i){var r,o=this._levels;if(o.length!==0&&!(this.currentLevelIndex===i&&(r=o[i])!==null&&r!==void 0&&r.details)){if(i<0||i>=o.length){var c=i<0;if(this.hls.trigger(L.Events.ERROR,{type:A.ErrorTypes.OTHER_ERROR,details:A.ErrorDetails.LEVEL_SWITCH_ERROR,level:i,fatal:c,reason:"invalid level idx"}),c)return;i=Math.min(i,o.length-1)}this.clearTimer();var t=this.currentLevelIndex,n=o[t],u=o[i];this.log("switching to level "+i+" from "+t),this.currentLevelIndex=i;var a=y({},u,{level:i,maxBitrate:u.maxBitrate,uri:u.uri,urlId:u.urlId});delete a._urlId,this.hls.trigger(L.Events.LEVEL_SWITCHING,a);var d=u.details;if(!d||d.live){var v=this.switchParams(u.uri,n==null?void 0:n.details);this.loadPlaylist(v)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(i){this.manualLevelIndex=i,this._startLevel===void 0&&(this._startLevel=i),i!==-1&&(this.level=i)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(i){this._firstLevel=i}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var i=this.hls.config.startLevel;return i!==void 0?i:this._firstLevel}else return this._startLevel},set:function(i){this._startLevel=i}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(i){this.level=i,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=i)}}]),s}(b.default)},"./src/controller/level-helper.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"addGroupId",function(){return O}),l.d(R,"assignTrackIdsByGroup",function(){return b}),l.d(R,"updatePTS",function(){return _}),l.d(R,"updateFragPTSDTS",function(){return x}),l.d(R,"mergeDetails",function(){return D}),l.d(R,"mapPartIntersection",function(){return m}),l.d(R,"mapFragmentIntersection",function(){return p}),l.d(R,"adjustSliding",function(){return f}),l.d(R,"addSliding",function(){return e}),l.d(R,"computeReloadInterval",function(){return s}),l.d(R,"getFragmentWithSN",function(){return h}),l.d(R,"getPartWith",function(){return g});var P=l("./src/polyfills/number.ts"),L=l("./src/utils/logger.ts"),A=l("./src/loader/date-range.ts");function M(){return M=Object.assign?Object.assign.bind():function(i){for(var r=1;r<arguments.length;r++){var o=arguments[r];for(var c in o)Object.prototype.hasOwnProperty.call(o,c)&&(i[c]=o[c])}return i},M.apply(this,arguments)}function O(i,r,o){switch(r){case"audio":i.audioGroupIds||(i.audioGroupIds=[]),i.audioGroupIds.push(o);break;case"text":i.textGroupIds||(i.textGroupIds=[]),i.textGroupIds.push(o);break}}function b(i){var r={};i.forEach(function(o){var c=o.groupId||"";o.id=r[c]=r[c]||0,r[c]++})}function _(i,r,o){var c=i[r],t=i[o];y(c,t)}function y(i,r){var o=r.startPTS;if(Object(P.isFiniteNumber)(o)){var c=0,t;r.sn>i.sn?(c=o-i.start,t=i):(c=i.start-o,t=r),t.duration!==c&&(t.duration=c)}else if(r.sn>i.sn){var n=i.cc===r.cc;n&&i.minEndPTS?r.start=i.start+(i.minEndPTS-i.start):r.start=i.start+i.duration}else r.start=Math.max(i.start-r.duration,0)}function x(i,r,o,c,t,n){var u=c-o;u<=0&&(L.logger.warn("Fragment should have a positive duration",r),c=o+r.duration,n=t+r.duration);var a=o,d=c,v=r.startPTS,S=r.endPTS;if(Object(P.isFiniteNumber)(v)){var T=Math.abs(v-o);Object(P.isFiniteNumber)(r.deltaPTS)?r.deltaPTS=Math.max(T,r.deltaPTS):r.deltaPTS=T,a=Math.max(o,v),o=Math.min(o,v),t=Math.min(t,r.startDTS),d=Math.min(c,S),c=Math.max(c,S),n=Math.max(n,r.endDTS)}r.duration=c-o;var I=o-r.start;r.appendedPTS=c,r.start=r.startPTS=o,r.maxStartPTS=a,r.startDTS=t,r.endPTS=c,r.minEndPTS=d,r.endDTS=n;var k=r.sn;if(!i||k<i.startSN||k>i.endSN)return 0;var B,U=k-i.startSN,W=i.fragments;for(W[U]=r,B=U;B>0;B--)y(W[B],W[B-1]);for(B=U;B<W.length-1;B++)y(W[B],W[B+1]);return i.fragmentHint&&y(W[W.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,I}function D(i,r){for(var o=null,c=i.fragments,t=c.length-1;t>=0;t--){var n=c[t].initSegment;if(n){o=n;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;var u=0,a;if(p(i,r,function(B,U){B.relurl&&(u=B.cc-U.cc),Object(P.isFiniteNumber)(B.startPTS)&&Object(P.isFiniteNumber)(B.endPTS)&&(U.start=U.startPTS=B.startPTS,U.startDTS=B.startDTS,U.appendedPTS=B.appendedPTS,U.maxStartPTS=B.maxStartPTS,U.endPTS=B.endPTS,U.endDTS=B.endDTS,U.minEndPTS=B.minEndPTS,U.duration=B.endPTS-B.startPTS,U.duration&&(a=U),r.PTSKnown=r.alignedSliding=!0),U.elementaryStreams=B.elementaryStreams,U.loader=B.loader,U.stats=B.stats,U.urlId=B.urlId,B.initSegment&&(U.initSegment=B.initSegment,o=B.initSegment)}),o){var d=r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments;d.forEach(function(B){var U;(!B.initSegment||B.initSegment.relurl===((U=o)===null||U===void 0?void 0:U.relurl))&&(B.initSegment=o)})}if(r.skippedSegments)if(r.deltaUpdateFailed=r.fragments.some(function(B){return!B}),r.deltaUpdateFailed){L.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var v=r.skippedSegments;v--;)r.fragments.shift();r.startSN=r.fragments[0].sn,r.startCC=r.fragments[0].cc}else r.canSkipDateRanges&&(r.dateRanges=E(i.dateRanges,r.dateRanges,r.recentlyRemovedDateranges));var S=r.fragments;if(u){L.logger.warn("discontinuity sliding from playlist, take drift into account");for(var T=0;T<S.length;T++)S[T].cc+=u}r.skippedSegments&&(r.startCC=r.fragments[0].cc),m(i.partList,r.partList,function(B,U){U.elementaryStreams=B.elementaryStreams,U.stats=B.stats}),a?x(r,a,a.startPTS,a.endPTS,a.startDTS,a.endDTS):f(i,r),S.length&&(r.totalduration=r.edge-S[0].start),r.driftStartTime=i.driftStartTime,r.driftStart=i.driftStart;var I=r.advancedDateTime;if(r.advanced&&I){var k=r.edge;r.driftStart||(r.driftStartTime=I,r.driftStart=k),r.driftEndTime=I,r.driftEnd=k}else r.driftEndTime=i.driftEndTime,r.driftEnd=i.driftEnd,r.advancedDateTime=i.advancedDateTime}function E(i,r,o){var c=M({},i);return o&&o.forEach(function(t){delete c[t]}),Object.keys(r).forEach(function(t){var n=new A.DateRange(r[t].attr,c[t]);n.isValid?c[t]=n:L.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(r[t].attr)+'"')}),c}function m(i,r,o){if(i&&r)for(var c=0,t=0,n=i.length;t<=n;t++){var u=i[t],a=r[t+c];u&&a&&u.index===a.index&&u.fragment.sn===a.fragment.sn?o(u,a):c--}}function p(i,r,o){for(var c=r.skippedSegments,t=Math.max(i.startSN,r.startSN)-r.startSN,n=(i.fragmentHint?1:0)+(c?r.endSN:Math.min(i.endSN,r.endSN))-r.startSN,u=r.startSN-i.startSN,a=r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments,d=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,v=t;v<=n;v++){var S=d[u+v],T=a[v];c&&!T&&v<c&&(T=r.fragments[v]=S),S&&T&&o(S,T)}}function f(i,r){var o=r.startSN+r.skippedSegments-i.startSN,c=i.fragments;o<0||o>=c.length||e(r,c[o].start)}function e(i,r){if(r){for(var o=i.fragments,c=i.skippedSegments;c<o.length;c++)o[c].start+=r;i.fragmentHint&&(i.fragmentHint.start+=r)}}function s(i,r){var o=1e3*i.levelTargetDuration,c=o/2,t=i.age,n=t>0&&t<o*3,u=r.loading.end-r.loading.start,a,d=i.availabilityDelay;if(i.updated===!1)if(n){var v=333*i.misses;a=Math.max(Math.min(c,u*2),v),i.availabilityDelay=(i.availabilityDelay||0)+a}else a=c;else n?(d=Math.min(d||o/2,t),i.availabilityDelay=d,a=d+o-t):a=o-u;return Math.round(a)}function h(i,r,o){if(!i||!i.details)return null;var c=i.details,t=c.fragments[r-c.startSN];return t||(t=c.fragmentHint,t&&t.sn===r)?t:r<c.startSN&&o&&o.sn===r?o:null}function g(i,r,o){if(!i||!i.details)return null;var c=i.details.partList;if(c)for(var t=c.length;t--;){var n=c[t];if(n.index===o&&n.fragment.sn===r)return n}return null}},"./src/controller/stream-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return g});var P=l("./src/polyfills/number.ts"),L=l("./src/controller/base-stream-controller.ts"),A=l("./src/is-supported.ts"),M=l("./src/events.ts"),O=l("./src/utils/buffer-helper.ts"),b=l("./src/controller/fragment-tracker.ts"),_=l("./src/types/loader.ts"),y=l("./src/loader/fragment.ts"),x=l("./src/demux/transmuxer-interface.ts"),D=l("./src/types/transmuxer.ts"),E=l("./src/controller/gap-controller.ts"),m=l("./src/errors.ts");function p(i,r){for(var o=0;o<r.length;o++){var c=r[o];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(i,c.key,c)}}function f(i,r,o){return r&&p(i.prototype,r),o&&p(i,o),Object.defineProperty(i,"prototype",{writable:!1}),i}function e(i,r){i.prototype=Object.create(r.prototype),i.prototype.constructor=i,s(i,r)}function s(i,r){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(c,t){return c.__proto__=t,c},s(i,r)}var h=100,g=function(i){e(r,i);function r(c,t){var n;return n=i.call(this,c,t,"[stream-controller]")||this,n.audioCodecSwap=!1,n.gapController=null,n.level=-1,n._forceStartLoad=!1,n.altAudio=!1,n.audioOnly=!1,n.fragPlaying=null,n.onvplaying=null,n.onvseeked=null,n.fragLastKbps=0,n.couldBacktrack=!1,n.backtrackFragment=null,n.audioCodecSwitch=!1,n.videoBuffer=null,n._registerListeners(),n}var o=r.prototype;return o._registerListeners=function(){var t=this.hls;t.on(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(M.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(M.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(M.Events.ERROR,this.onError,this),t.on(M.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(M.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(M.Events.BUFFER_CREATED,this.onBufferCreated,this),t.on(M.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(M.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(M.Events.FRAG_BUFFERED,this.onFragBuffered,this)},o._unregisterListeners=function(){var t=this.hls;t.off(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(M.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(M.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(M.Events.ERROR,this.onError,this),t.off(M.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(M.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(M.Events.BUFFER_CREATED,this.onBufferCreated,this),t.off(M.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(M.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(M.Events.FRAG_BUFFERED,this.onFragBuffered,this)},o.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},o.startLoad=function(t){if(this.levels){var n=this.lastCurrentTime,u=this.hls;if(this.stopLoad(),this.setInterval(h),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var a=u.startLevel;a===-1&&(u.config.testBandwidth&&this.levels.length>1?(a=0,this.bitrateTest=!0):a=u.nextAutoLevel),this.level=u.nextLoadLevel=a,this.loadedmetadata=!1}n>0&&t===-1&&(this.log("Override startPosition with lastCurrentTime @"+n.toFixed(3)),t=n),this.state=L.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=L.State.STOPPED},o.stopLoad=function(){this._forceStartLoad=!1,i.prototype.stopLoad.call(this)},o.doTick=function(){switch(this.state){case L.State.IDLE:this.doTickIdle();break;case L.State.WAITING_LEVEL:{var t,n=this.levels,u=this.level,a=n==null||(t=n[u])===null||t===void 0?void 0:t.details;if(a&&(!a.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(a))break;this.state=L.State.IDLE;break}break}case L.State.FRAG_LOADING_WAITING_RETRY:{var d,v=self.performance.now(),S=this.retryDate;(!S||v>=S||(d=this.media)!==null&&d!==void 0&&d.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=L.State.IDLE)}break;default:break}this.onTickEnd()},o.onTickEnd=function(){i.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},o.doTickIdle=function(){var t,n,u=this.hls,a=this.levelLastLoaded,d=this.levels,v=this.media,S=u.config,T=u.nextLoadLevel;if(!(a===null||!v&&(this.startFragRequested||!S.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!d||!d[T])){var I=d[T];this.level=u.nextLoadLevel=T;var k=I.details;if(!k||this.state===L.State.WAITING_LEVEL||k.live&&this.levelLastLoaded!==T){this.state=L.State.WAITING_LEVEL;return}var B=this.getMainFwdBufferInfo();if(B!==null){var U=B.len,W=this.getMaxBufferLength(I.maxBitrate);if(!(U>=W)){if(this._streamEnded(B,k)){var G={};this.altAudio&&(G.type="video"),this.hls.trigger(M.Events.BUFFER_EOS,G),this.state=L.State.ENDED;return}this.backtrackFragment&&this.backtrackFragment.start>B.end&&(this.backtrackFragment=null);var z=this.backtrackFragment?this.backtrackFragment.start:B.end,Y=this.getNextFragment(z,k);if(this.couldBacktrack&&!this.fragPrevious&&Y&&Y.sn!=="initSegment"&&this.fragmentTracker.getState(Y)!==b.FragmentState.OK){var $,Z=(($=this.backtrackFragment)!=null?$:Y).sn,q=Z-k.startSN,ie=k.fragments[q-1];ie&&Y.cc===ie.cc&&(Y=ie,this.fragmentTracker.removeFragment(ie))}else this.backtrackFragment&&B.len&&(this.backtrackFragment=null);if(Y&&this.fragmentTracker.getState(Y)===b.FragmentState.OK&&this.nextLoadPosition>z){var ne=this.audioOnly&&!this.altAudio?y.ElementaryStreamTypes.AUDIO:y.ElementaryStreamTypes.VIDEO;v&&this.afterBufferFlushed(v,ne,_.PlaylistLevelType.MAIN),Y=this.getNextFragment(this.nextLoadPosition,k)}!Y||(Y.initSegment&&!Y.initSegment.data&&!this.bitrateTest&&(Y=Y.initSegment),((t=Y.decryptdata)===null||t===void 0?void 0:t.keyFormat)==="identity"&&!((n=Y.decryptdata)!==null&&n!==void 0&&n.key)?this.loadKey(Y,k):this.loadFragment(Y,k,z))}}}},o.loadFragment=function(t,n,u){var a,d=this.fragmentTracker.getState(t);this.fragCurrent=t,d===b.FragmentState.NOT_LOADED?t.sn==="initSegment"?this._loadInitSegment(t):this.bitrateTest?(this.log("Fragment "+t.sn+" of level "+t.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(t)):(this.startFragRequested=!0,i.prototype.loadFragment.call(this,t,n,u)):d===b.FragmentState.APPENDING?this.reduceMaxBufferLength(t.duration)&&this.fragmentTracker.removeFragment(t):((a=this.media)===null||a===void 0?void 0:a.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},o.getAppendedFrag=function(t){var n=this.fragmentTracker.getAppendedFrag(t,_.PlaylistLevelType.MAIN);return n&&"fragment"in n?n.fragment:n},o.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,_.PlaylistLevelType.MAIN)},o.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},o.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},o.nextLevelSwitch=function(){var t=this.levels,n=this.media;if(n!=null&&n.readyState){var u,a=this.getAppendedFrag(n.currentTime);if(a&&a.start>1&&this.flushMainBuffer(0,a.start-1),!n.paused&&t){var d=this.hls.nextLoadLevel,v=t[d],S=this.fragLastKbps;S&&this.fragCurrent?u=this.fragCurrent.duration*v.maxBitrate/(1e3*S)+1:u=0}else u=0;var T=this.getBufferedFrag(n.currentTime+u);if(T){var I=this.followingBufferedFrag(T);if(I){this.abortCurrentFrag();var k=I.maxStartPTS?I.maxStartPTS:I.start,B=I.duration,U=Math.max(T.end,k+Math.min(Math.max(B-this.config.maxFragLookUpTolerance,B*.5),B*.75));this.flushMainBuffer(U,Number.POSITIVE_INFINITY)}}}},o.abortCurrentFrag=function(){var t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t!=null&&t.loader&&t.loader.abort(),this.state){case L.State.KEY_LOADING:case L.State.FRAG_LOADING:case L.State.FRAG_LOADING_WAITING_RETRY:case L.State.PARSING:case L.State.PARSED:this.state=L.State.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},o.flushMainBuffer=function(t,n){i.prototype.flushMainBuffer.call(this,t,n,this.altAudio?"video":null)},o.onMediaAttached=function(t,n){i.prototype.onMediaAttached.call(this,t,n);var u=n.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),u.addEventListener("playing",this.onvplaying),u.addEventListener("seeked",this.onvseeked),this.gapController=new E.default(this.config,u,this.fragmentTracker,this.hls)},o.onMediaDetaching=function(){var t=this.media;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.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)},o.onMediaPlaying=function(){this.tick()},o.onMediaSeeked=function(){var t=this.media,n=t?t.currentTime:null;Object(P.isFiniteNumber)(n)&&this.log("Media seeked to "+n.toFixed(3)),this.tick()},o.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(M.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},o.onManifestParsed=function(t,n){var u=!1,a=!1,d;n.levels.forEach(function(v){d=v.audioCodec,d&&(d.indexOf("mp4a.40.2")!==-1&&(u=!0),d.indexOf("mp4a.40.5")!==-1&&(a=!0))}),this.audioCodecSwitch=u&&a&&!Object(A.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=n.levels,this.startFragRequested=!1},o.onLevelLoading=function(t,n){var u=this.levels;if(!(!u||this.state!==L.State.IDLE)){var a=u[n.level];(!a.details||a.details.live&&this.levelLastLoaded!==n.level||this.waitForCdnTuneIn(a.details))&&(this.state=L.State.WAITING_LEVEL)}},o.onLevelLoaded=function(t,n){var u,a=this.levels,d=n.level,v=n.details,S=v.totalduration;if(!a){this.warn("Levels were reset while loading level "+d);return}this.log("Level "+d+" loaded ["+v.startSN+","+v.endSN+"], cc ["+v.startCC+", "+v.endCC+"] duration:"+S);var T=this.fragCurrent;T&&(this.state===L.State.FRAG_LOADING||this.state===L.State.FRAG_LOADING_WAITING_RETRY)&&T.level!==n.level&&T.loader&&(this.state=L.State.IDLE,this.backtrackFragment=null,T.loader.abort());var I=a[d],k=0;if(v.live||(u=I.details)!==null&&u!==void 0&&u.live){if(v.fragments[0]||(v.deltaUpdateFailed=!0),v.deltaUpdateFailed)return;k=this.alignPlaylists(v,I.details)}if(I.details=v,this.levelLastLoaded=d,this.hls.trigger(M.Events.LEVEL_UPDATED,{details:v,level:d}),this.state===L.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(v))return;this.state=L.State.IDLE}this.startFragRequested?v.live&&this.synchronizeToLiveEdge(v):this.setStartPosition(v,k),this.tick()},o._handleFragmentLoadProgress=function(t){var n,u=t.frag,a=t.part,d=t.payload,v=this.levels;if(!v){this.warn("Levels were reset while fragment load was in progress. Fragment "+u.sn+" of level "+u.level+" will not be buffered");return}var S=v[u.level],T=S.details;if(!T){this.warn("Dropping fragment "+u.sn+" of level "+u.level+" after level details were reset");return}var I=S.videoCodec,k=T.PTSKnown||!T.live,B=(n=u.initSegment)===null||n===void 0?void 0:n.data,U=this._getAudioCodec(S),W=this.transmuxer=this.transmuxer||new x.default(this.hls,_.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),G=a?a.index:-1,z=G!==-1,Y=new D.ChunkMetadata(u.level,u.sn,u.stats.chunkCount,d.byteLength,G,z),$=this.initPTS[u.cc];W.push(d,B,U,I,u,a,T.totalduration,k,Y,$)},o.onAudioTrackSwitching=function(t,n){var u=this.altAudio,a=!!n.url,d=n.id;if(!a){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var v=this.fragCurrent;v!=null&&v.loader&&(this.log("Switching to main audio track, cancel main fragment load"),v.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var S=this.hls;u&&S.trigger(M.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),S.trigger(M.Events.AUDIO_TRACK_SWITCHED,{id:d})}},o.onAudioTrackSwitched=function(t,n){var u=n.id,a=!!this.hls.audioTracks[u].url;if(a){var d=this.videoBuffer;d&&this.mediaBuffer!==d&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=d)}this.altAudio=a,this.tick()},o.onBufferCreated=function(t,n){var u=n.tracks,a,d,v=!1;for(var S in u){var T=u[S];if(T.id==="main"){if(d=S,a=T,S==="video"){var I=u[S];I&&(this.videoBuffer=I.buffer)}}else v=!0}v&&a?(this.log("Alternate track found, use "+d+".buffered to schedule main fragment loading"),this.mediaBuffer=a.buffer):this.mediaBuffer=this.media},o.onFragBuffered=function(t,n){var u=n.frag,a=n.part;if(!(u&&u.type!==_.PlaylistLevelType.MAIN)){if(this.fragContextChanged(u)){this.warn("Fragment "+u.sn+(a?" p: "+a.index:"")+" of level "+u.level+" finished buffering, but was aborted. state: "+this.state),this.state===L.State.PARSED&&(this.state=L.State.IDLE);return}var d=a?a.stats:u.stats;this.fragLastKbps=Math.round(8*d.total/(d.buffering.end-d.loading.first)),u.sn!=="initSegment"&&(this.fragPrevious=u),this.fragBufferedComplete(u,a)}},o.onError=function(t,n){switch(n.details){case m.ErrorDetails.FRAG_LOAD_ERROR:case m.ErrorDetails.FRAG_LOAD_TIMEOUT:case m.ErrorDetails.KEY_LOAD_ERROR:case m.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_.PlaylistLevelType.MAIN,n);break;case m.ErrorDetails.LEVEL_LOAD_ERROR:case m.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==L.State.ERROR&&(n.fatal?(this.warn(""+n.details),this.state=L.State.ERROR):!n.levelRetry&&this.state===L.State.WAITING_LEVEL&&(this.state=L.State.IDLE));break;case m.ErrorDetails.BUFFER_FULL_ERROR:if(n.parent==="main"&&(this.state===L.State.PARSING||this.state===L.State.PARSED)){var u=!0,a=this.getFwdBufferInfo(this.media,_.PlaylistLevelType.MAIN);a&&a.len>.5&&(u=!this.reduceMaxBufferLength(a.len)),u&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},o.checkBuffer=function(){var t=this.media,n=this.gapController;if(!(!t||!n||!t.readyState)){if(this.loadedmetadata||!O.BufferHelper.getBuffered(t).length){var u=this.state!==L.State.IDLE?this.fragCurrent:null;n.poll(this.lastCurrentTime,u)}this.lastCurrentTime=t.currentTime}},o.onFragLoadEmergencyAborted=function(){this.state=L.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},o.onBufferFlushed=function(t,n){var u=n.type;if(u!==y.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var a=(u===y.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(a,u,_.PlaylistLevelType.MAIN)}},o.onLevelsUpdated=function(t,n){this.levels=n.levels},o.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},o.seekToStartPos=function(){var t=this.media;if(!!t){var n=t.currentTime,u=this.startPosition;if(u>=0&&n<u){if(t.seeking){this.log("could not seek to "+u+", already seeking at "+n);return}var a=O.BufferHelper.getBuffered(t),d=a.length?a.start(0):0,v=d-u;v>0&&(v<this.config.maxBufferHole||v<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+v+" to match buffer start"),u+=v,this.startPosition=u),this.log("seek to target start position "+u+" from current time "+n),t.currentTime=u}}},o._getAudioCodec=function(t){var n=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&n&&(this.log("Swapping audio codec"),n.indexOf("mp4a.40.5")!==-1?n="mp4a.40.2":n="mp4a.40.5"),n},o._loadBitrateTestFrag=function(t){var n=this;t.bitrateTest=!0,this._doFragLoad(t).then(function(u){var a=n.hls;if(!(!u||a.nextLoadLevel||n.fragContextChanged(t))){n.fragLoadError=0,n.state=L.State.IDLE,n.startFragRequested=!1,n.bitrateTest=!1;var d=t.stats;d.parsing.start=d.parsing.end=d.buffering.start=d.buffering.end=self.performance.now(),a.trigger(M.Events.FRAG_LOADED,u),t.bitrateTest=!1}})},o._handleTransmuxComplete=function(t){var n,u="main",a=this.hls,d=t.remuxResult,v=t.chunkMeta,S=this.getCurrentContext(v);if(!S){this.warn("The loading context changed while buffering fragment "+v.sn+" of level "+v.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(v.level);return}var T=S.frag,I=S.part,k=S.level,B=d.video,U=d.text,W=d.id3,G=d.initSegment,z=k.details,Y=this.altAudio?void 0:d.audio;if(!this.fragContextChanged(T)){if(this.state=L.State.PARSING,G){G.tracks&&(this._bufferInitSegment(k,G.tracks,T,v),a.trigger(M.Events.FRAG_PARSING_INIT_SEGMENT,{frag:T,id:u,tracks:G.tracks}));var $=G.initPTS,Z=G.timescale;Object(P.isFiniteNumber)($)&&(this.initPTS[T.cc]=$,a.trigger(M.Events.INIT_PTS_FOUND,{frag:T,id:u,initPTS:$,timescale:Z}))}if(B&&d.independent!==!1){if(z){var q=B.startPTS,ie=B.endPTS,ne=B.startDTS,ae=B.endDTS;if(I)I.elementaryStreams[B.type]={startPTS:q,endPTS:ie,startDTS:ne,endDTS:ae};else if(B.firstKeyFrame&&B.independent&&(this.couldBacktrack=!0),B.dropped&&B.independent){var te=this.getMainFwdBufferInfo(),fe=(te?te.end:this.getLoadPosition())+this.config.maxBufferHole,de=B.firstKeyFramePTS?B.firstKeyFramePTS:q;if(fe<de-this.config.maxBufferHole){this.backtrack(T);return}T.setElementaryStreamInfo(B.type,T.start,ie,T.start,ae,!0)}T.setElementaryStreamInfo(B.type,q,ie,ne,ae),this.backtrackFragment&&(this.backtrackFragment=T),this.bufferFragmentData(B,T,I,v)}}else if(d.independent===!1){this.backtrack(T);return}if(Y){var re=Y.startPTS,Ee=Y.endPTS,me=Y.startDTS,Te=Y.endDTS;I&&(I.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:re,endPTS:Ee,startDTS:me,endDTS:Te}),T.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,re,Ee,me,Te),this.bufferFragmentData(Y,T,I,v)}if(z&&W!==null&&W!==void 0&&(n=W.samples)!==null&&n!==void 0&&n.length){var Me={id:u,frag:T,details:z,samples:W.samples};a.trigger(M.Events.FRAG_PARSING_METADATA,Me)}if(z&&U){var _e={id:u,frag:T,details:z,samples:U.samples};a.trigger(M.Events.FRAG_PARSING_USERDATA,_e)}}},o._bufferInitSegment=function(t,n,u,a){var d=this;if(this.state===L.State.PARSING){this.audioOnly=!!n.audio&&!n.video,this.altAudio&&!this.audioOnly&&delete n.audio;var v=n.audio,S=n.video,T=n.audiovideo;if(v){var I=t.audioCodec,k=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(I&&(I.indexOf("mp4a.40.5")!==-1?I="mp4a.40.2":I="mp4a.40.5"),v.metadata.channelCount!==1&&k.indexOf("firefox")===-1&&(I="mp4a.40.5")),k.indexOf("android")!==-1&&v.container!=="audio/mpeg"&&(I="mp4a.40.2",this.log("Android: force audio codec to "+I)),t.audioCodec&&t.audioCodec!==I&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+I+'"'),v.levelCodec=I,v.id="main",this.log("Init audio buffer, container:"+v.container+", codecs[selected/level/parsed]=["+(I||"")+"/"+(t.audioCodec||"")+"/"+v.codec+"]")}S&&(S.levelCodec=t.videoCodec,S.id="main",this.log("Init video buffer, container:"+S.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+S.codec+"]")),T&&this.log("Init audiovideo buffer, container:"+T.container+", codecs[level/parsed]=["+(t.attrs.CODECS||"")+"/"+T.codec+"]"),this.hls.trigger(M.Events.BUFFER_CODECS,n),Object.keys(n).forEach(function(B){var U=n[B],W=U.initSegment;W!=null&&W.byteLength&&d.hls.trigger(M.Events.BUFFER_APPENDING,{type:B,data:W,frag:u,part:null,chunkMeta:a,parent:u.type})}),this.tick()}},o.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,_.PlaylistLevelType.MAIN)},o.backtrack=function(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=L.State.IDLE},o.checkFragmentChanged=function(){var t=this.media,n=null;if(t&&t.readyState>1&&t.seeking===!1){var u=t.currentTime;if(O.BufferHelper.isBuffered(t,u)?n=this.getAppendedFrag(u):O.BufferHelper.isBuffered(t,u+.1)&&(n=this.getAppendedFrag(u+.1)),n){this.backtrackFragment=null;var a=this.fragPlaying,d=n.level;(!a||n.sn!==a.sn||a.level!==d||n.urlId!==a.urlId)&&(this.hls.trigger(M.Events.FRAG_CHANGED,{frag:n}),(!a||a.level!==d)&&this.hls.trigger(M.Events.LEVEL_SWITCHED,{level:d}),this.fragPlaying=n)}}},f(r,[{key:"nextLevel",get:function(){var t=this.nextBufferedFrag;return t?t.level:-1}},{key:"currentFrag",get:function(){var t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null}},{key:"currentProgramDateTime",get:function(){var t=this.media;if(t){var n=t.currentTime,u=this.currentFrag;if(u&&Object(P.isFiniteNumber)(n)&&Object(P.isFiniteNumber)(u.programDateTime)){var a=u.programDateTime+(n-u.start)*1e3;return new Date(a)}}return null}},{key:"currentLevel",get:function(){var t=this.currentFrag;return t?t.level:-1}},{key:"nextBufferedFrag",get:function(){var t=this.currentFrag;return t?this.followingBufferedFrag(t):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),r}(L.default)},"./src/controller/subtitle-stream-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"SubtitleStreamController",function(){return e});var P=l("./src/events.ts"),L=l("./src/utils/buffer-helper.ts"),A=l("./src/controller/fragment-finders.ts"),M=l("./src/utils/discontinuities.ts"),O=l("./src/controller/level-helper.ts"),b=l("./src/controller/fragment-tracker.ts"),_=l("./src/controller/base-stream-controller.ts"),y=l("./src/types/loader.ts"),x=l("./src/types/level.ts");function D(h,g){for(var i=0;i<g.length;i++){var r=g[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(h,r.key,r)}}function E(h,g,i){return g&&D(h.prototype,g),i&&D(h,i),Object.defineProperty(h,"prototype",{writable:!1}),h}function m(h,g){h.prototype=Object.create(g.prototype),h.prototype.constructor=h,p(h,g)}function p(h,g){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},p(h,g)}var f=500,e=function(h){m(g,h);function g(r,o){var c;return c=h.call(this,r,o,"[subtitle-stream-controller]")||this,c.levels=[],c.currentTrackId=-1,c.tracksBuffered=[],c.mainDetails=null,c._registerListeners(),c}var i=g.prototype;return i.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},i._registerListeners=function(){var o=this.hls;o.on(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),o.on(P.Events.ERROR,this.onError,this),o.on(P.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),o.on(P.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),o.on(P.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.on(P.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),o.on(P.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i._unregisterListeners=function(){var o=this.hls;o.off(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),o.off(P.Events.ERROR,this.onError,this),o.off(P.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),o.off(P.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),o.off(P.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.off(P.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),o.off(P.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i.startLoad=function(){this.stopLoad(),this.state=_.State.IDLE,this.setInterval(f),this.tick()},i.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},i.onLevelLoaded=function(o,c){this.mainDetails=c.details},i.onSubtitleFragProcessed=function(o,c){var t=c.frag,n=c.success;if(this.fragPrevious=t,this.state=_.State.IDLE,!!n){var u=this.tracksBuffered[this.currentTrackId];if(!!u){for(var a,d=t.start,v=0;v<u.length;v++)if(d>=u[v].start&&d<=u[v].end){a=u[v];break}var S=t.start+t.duration;a?a.end=S:(a={start:d,end:S},u.push(a)),this.fragmentTracker.fragBuffered(t)}}},i.onBufferFlushing=function(o,c){var t=c.startOffset,n=c.endOffset;if(t===0&&n!==Number.POSITIVE_INFINITY){var u=this.currentTrackId,a=this.levels;if(!a.length||!a[u]||!a[u].details)return;var d=a[u].details,v=d.targetduration,S=n-v;if(S<=0)return;c.endOffsetSubtitles=Math.max(0,S),this.tracksBuffered.forEach(function(T){for(var I=0;I<T.length;){if(T[I].end<=S){T.shift();continue}else if(T[I].start<S)T[I].start=S;else break;I++}}),this.fragmentTracker.removeFragmentsInRange(t,S,y.PlaylistLevelType.SUBTITLE)}},i.onError=function(o,c){var t,n=c.frag;!n||n.type!==y.PlaylistLevelType.SUBTITLE||((t=this.fragCurrent)!==null&&t!==void 0&&t.loader&&this.fragCurrent.loader.abort(),this.state=_.State.IDLE)},i.onSubtitleTracksUpdated=function(o,c){var t=this,n=c.subtitleTracks;this.tracksBuffered=[],this.levels=n.map(function(u){return new x.Level(u)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(u){t.tracksBuffered[u.id]=[]}),this.mediaBuffer=null},i.onSubtitleTrackSwitch=function(o,c){if(this.currentTrackId=c.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var t=this.levels[this.currentTrackId];t!=null&&t.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,t&&this.setInterval(f)},i.onSubtitleTrackLoaded=function(o,c){var t,n=c.details,u=c.id,a=this.currentTrackId,d=this.levels;if(!!d.length){var v=d[a];if(!(u>=d.length||u!==a||!v)){if(this.mediaBuffer=this.mediaBufferTimeRanges,n.live||(t=v.details)!==null&&t!==void 0&&t.live){var S=this.mainDetails;if(n.deltaUpdateFailed||!S)return;var T=S.fragments[0];if(!v.details)n.hasProgramDateTime&&S.hasProgramDateTime?Object(M.alignMediaPlaylistByPDT)(n,S):T&&Object(O.addSliding)(n,T.start);else{var I=this.alignPlaylists(n,v.details);I===0&&T&&Object(O.addSliding)(n,T.start)}}if(v.details=n,this.levelLastLoaded=u,this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===_.State.IDLE){var k=Object(A.findFragmentByPTS)(null,n.fragments,this.media.currentTime,0);k||(this.warn("Subtitle playlist not aligned with playback"),v.details=void 0)}}}},i._handleFragmentLoadComplete=function(o){var c=o.frag,t=o.payload,n=c.decryptdata,u=this.hls;if(!this.fragContextChanged(c)&&t&&t.byteLength>0&&n&&n.key&&n.iv&&n.method==="AES-128"){var a=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(t),n.key.buffer,n.iv.buffer).then(function(d){var v=performance.now();u.trigger(P.Events.FRAG_DECRYPTED,{frag:c,payload:d,stats:{tstart:a,tdecrypt:v}})})}},i.doTick=function(){if(!this.media){this.state=_.State.IDLE;return}if(this.state===_.State.IDLE){var o=this.currentTrackId,c=this.levels;if(!c.length||!c[o]||!c[o].details)return;var t=c[o].details,n=t.targetduration,u=this.config,a=this.media,d=L.BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],a.currentTime-n,u.maxBufferHole),v=d.end,S=d.len,T=this.getMaxBufferLength()+n;if(S>T)return;console.assert(t,"Subtitle track details are defined on idle subtitle stream controller tick");var I=t.fragments,k=I.length,B=t.edge,U,W=this.fragPrevious;if(v<B){var G=u.maxFragLookUpTolerance;U=Object(A.findFragmentByPTS)(W,I,Math.max(I[0].start,v),G),!U&&W&&W.start<I[0].start&&(U=I[0])}else U=I[k-1];if(U=this.mapToInitFragWhenRequired(U),!U||this.fragmentTracker.getState(U)!==b.FragmentState.NOT_LOADED)return;U.encrypted?this.loadKey(U,t):this.loadFragment(U,t,v)}},i.loadFragment=function(o,c,t){this.fragCurrent=o,o.sn==="initSegment"?this._loadInitSegment(o):h.prototype.loadFragment.call(this,o,c,t)},E(g,[{key:"mediaBufferTimeRanges",get:function(){return new s(this.tracksBuffered[this.currentTrackId]||[])}}]),g}(_.default),s=function(g){this.buffered=void 0;var i=function(o,c,t){if(c=c>>>0,c>t-1)throw new DOMException("Failed to execute '"+o+"' on 'TimeRanges': The index provided ("+c+") is greater than the maximum bound ("+t+")");return g[c][o]};this.buffered={get length(){return g.length},end:function(o){return i("end",o,g.length)},start:function(o){return i("start",o,g.length)}}}},"./src/controller/subtitle-track-controller.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/events.ts"),L=l("./src/utils/texttrack-utils.ts"),A=l("./src/controller/base-playlist-controller.ts"),M=l("./src/types/loader.ts");function O(E,m){for(var p=0;p<m.length;p++){var f=m[p];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(E,f.key,f)}}function b(E,m,p){return m&&O(E.prototype,m),p&&O(E,p),Object.defineProperty(E,"prototype",{writable:!1}),E}function _(E,m){E.prototype=Object.create(m.prototype),E.prototype.constructor=E,y(E,m)}function y(E,m){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(f,e){return f.__proto__=e,f},y(E,m)}var x=function(E){_(m,E);function m(f){var e;return e=E.call(this,f,"[subtitle-track-controller]")||this,e.media=null,e.tracks=[],e.groupId=null,e.tracksInGroup=[],e.trackId=-1,e.selectDefaultTrack=!0,e.queuedDefaultTrack=-1,e.trackChangeListener=function(){return e.onTextTracksChanged()},e.asyncPollTrackChange=function(){return e.pollTrackChange(0)},e.useTextTrackPolling=!1,e.subtitlePollingInterval=-1,e._subtitleDisplay=!0,e.registerListeners(),e}var p=m.prototype;return p.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,E.prototype.destroy.call(this)},p.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.MANIFEST_PARSED,this.onManifestParsed,this),e.on(P.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(P.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(P.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(P.Events.ERROR,this.onError,this)},p.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.MANIFEST_PARSED,this.onManifestParsed,this),e.off(P.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(P.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(P.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(P.Events.ERROR,this.onError,this)},p.onMediaAttached=function(e,s){this.media=s.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},p.pollTrackChange=function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)},p.onMediaDetaching=function(){if(!!this.media){self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var e=D(this.media.textTracks);e.forEach(function(s){Object(L.clearCurrentCues)(s)}),this.subtitleTrack=-1,this.media=null}},p.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},p.onManifestParsed=function(e,s){this.tracks=s.subtitleTracks},p.onSubtitleTrackLoaded=function(e,s){var h=s.id,g=s.details,i=this.trackId,r=this.tracksInGroup[i];if(!r){this.warn("Invalid subtitle track id "+h);return}var o=r.details;r.details=s.details,this.log("subtitle track "+h+" loaded ["+g.startSN+"-"+g.endSN+"]"),h===this.trackId&&(this.retryCount=0,this.playlistLoaded(h,s,o))},p.onLevelLoading=function(e,s){this.switchLevel(s.level)},p.onLevelSwitching=function(e,s){this.switchLevel(s.level)},p.switchLevel=function(e){var s=this.hls.levels[e];if(!!(s!=null&&s.textGroupIds)){var h=s.textGroupIds[s.urlId];if(this.groupId!==h){var g=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,i=this.tracks.filter(function(c){return!h||c.groupId===h});this.tracksInGroup=i;var r=this.findTrackId(g==null?void 0:g.name)||this.findTrackId();this.groupId=h;var o={subtitleTracks:i};this.log("Updating subtitle tracks, "+i.length+' track(s) found in "'+h+'" group-id'),this.hls.trigger(P.Events.SUBTITLE_TRACKS_UPDATED,o),r!==-1&&this.setSubtitleTrack(r,g)}}},p.findTrackId=function(e){for(var s=this.tracksInGroup,h=0;h<s.length;h++){var g=s[h];if((!this.selectDefaultTrack||g.default)&&(!e||e===g.name))return g.id}return-1},p.onError=function(e,s){E.prototype.onError.call(this,e,s),!(s.fatal||!s.context)&&s.context.type===M.PlaylistContextType.SUBTITLE_TRACK&&s.context.id===this.trackId&&s.context.groupId===this.groupId&&this.retryLoadingOrFail(s)},p.loadPlaylist=function(e){var s=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(s)){var h=s.id,g=s.groupId,i=s.url;if(e)try{i=e.addDirectives(i)}catch(r){this.warn("Could not construct new URL with HLS Delivery Directives: "+r)}this.log("Loading subtitle playlist for id "+h),this.hls.trigger(P.Events.SUBTITLE_TRACK_LOADING,{url:i,id:h,groupId:g,deliveryDirectives:e||null})}},p.toggleTrackModes=function(e){var s=this,h=this.media,g=this.trackId;if(!!h){var i=D(h.textTracks),r=i.filter(function(t){return t.groupId===s.groupId});if(e===-1)[].slice.call(i).forEach(function(t){t.mode="disabled"});else{var o=r[g];o&&(o.mode="disabled")}var c=r[e];c&&(c.mode=this.subtitleDisplay?"showing":"hidden")}},p.setSubtitleTrack=function(e,s){var h,g=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),!(this.trackId===e&&(e===-1||(h=g[e])!==null&&h!==void 0&&h.details)||e<-1||e>=g.length)){this.clearTimer();var i=g[e];if(this.log("Switching to subtitle track "+e),this.trackId=e,i){var r=i.id,o=i.groupId,c=o===void 0?"":o,t=i.name,n=i.type,u=i.url;this.hls.trigger(P.Events.SUBTITLE_TRACK_SWITCH,{id:r,groupId:c,name:t,type:n,url:u});var a=this.switchParams(i.url,s==null?void 0:s.details);this.loadPlaylist(a)}else this.hls.trigger(P.Events.SUBTITLE_TRACK_SWITCH,{id:e})}},p.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!(!this.media||!this.hls.config.renderTextTracksNatively)){for(var e=-1,s=D(this.media.textTracks),h=0;h<s.length;h++)if(s[h].mode==="hidden")e=h;else if(s[h].mode==="showing"){e=h;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}},b(m,[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1;var s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,s)}}]),m}(A.default);function D(E){for(var m=[],p=0;p<E.length;p++){var f=E[p];f.kind==="subtitles"&&f.label&&m.push(E[p])}return m}R.default=x},"./src/controller/timeline-controller.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"TimelineController",function(){return E});var P=l("./src/polyfills/number.ts"),L=l("./src/events.ts"),A=l("./src/utils/cea-608-parser.ts"),M=l("./src/utils/output-filter.ts"),O=l("./src/utils/webvtt-parser.ts"),b=l("./src/utils/texttrack-utils.ts"),_=l("./src/utils/imsc1-ttml-parser.ts"),y=l("./src/utils/mp4-tools.ts"),x=l("./src/types/loader.ts"),D=l("./src/utils/logger.ts"),E=function(){function e(h){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=f(),this.captionsProperties=void 0,this.hls=h,this.config=h.config,this.Cues=h.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 g=new M.default(this,"textTrack1"),i=new M.default(this,"textTrack2"),r=new M.default(this,"textTrack3"),o=new M.default(this,"textTrack4");this.cea608Parser1=new A.default(1,g,i),this.cea608Parser2=new A.default(3,r,o)}h.on(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),h.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.on(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),h.on(L.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),h.on(L.Events.FRAG_LOADING,this.onFragLoading,this),h.on(L.Events.FRAG_LOADED,this.onFragLoaded,this),h.on(L.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),h.on(L.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),h.on(L.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.on(L.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),h.on(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var s=e.prototype;return s.destroy=function(){var g=this.hls;g.off(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),g.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),g.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),g.off(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),g.off(L.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),g.off(L.Events.FRAG_LOADING,this.onFragLoading,this),g.off(L.Events.FRAG_LOADED,this.onFragLoaded,this),g.off(L.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),g.off(L.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),g.off(L.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),g.off(L.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),g.off(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},s.addCues=function(g,i,r,o,c){for(var t=!1,n=c.length;n--;){var u=c[n],a=p(u[0],u[1],i,r);if(a>=0&&(u[0]=Math.min(u[0],i),u[1]=Math.max(u[1],r),t=!0,a/(r-i)>.5))return}if(t||c.push([i,r]),this.config.renderTextTracksNatively){var d=this.captionsTracks[g];this.Cues.newCue(d,i,r,o)}else{var v=this.Cues.newCue(null,i,r,o);this.hls.trigger(L.Events.CUES_PARSED,{type:"captions",cues:v,track:g})}},s.onInitPtsFound=function(g,i){var r=this,o=i.frag,c=i.id,t=i.initPTS,n=i.timescale,u=this.unparsedVttFrags;c==="main"&&(this.initPTS[o.cc]=t,this.timescale[o.cc]=n),u.length&&(this.unparsedVttFrags=[],u.forEach(function(a){r.onFragLoaded(L.Events.FRAG_LOADED,a)}))},s.getExistingTrack=function(g){var i=this.media;if(i)for(var r=0;r<i.textTracks.length;r++){var o=i.textTracks[r];if(o[g])return o}return null},s.createCaptionsTrack=function(g){this.config.renderTextTracksNatively?this.createNativeTrack(g):this.createNonNativeTrack(g)},s.createNativeTrack=function(g){if(!this.captionsTracks[g]){var i=this.captionsProperties,r=this.captionsTracks,o=this.media,c=i[g],t=c.label,n=c.languageCode,u=this.getExistingTrack(g);if(u)r[g]=u,Object(b.clearCurrentCues)(r[g]),Object(b.sendAddTrackEvent)(r[g],o);else{var a=this.createTextTrack("captions",t,n);a&&(a[g]=!0,r[g]=a)}}},s.createNonNativeTrack=function(g){if(!this.nonNativeCaptionsTracks[g]){var i=this.captionsProperties[g];if(!!i){var r=i.label,o={_id:g,label:r,kind:"captions",default:i.media?!!i.media.default:!1,closedCaptions:i.media};this.nonNativeCaptionsTracks[g]=o,this.hls.trigger(L.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[o]})}}},s.createTextTrack=function(g,i,r){var o=this.media;if(!!o)return o.addTextTrack(g,i,r)},s.onMediaAttaching=function(g,i){this.media=i.media,this._cleanTracks()},s.onMediaDetaching=function(){var g=this.captionsTracks;Object.keys(g).forEach(function(i){Object(b.clearCurrentCues)(g[i]),delete g[i]}),this.nonNativeCaptionsTracks={}},s.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=f(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},s._cleanTracks=function(){var g=this.media;if(!!g){var i=g.textTracks;if(i)for(var r=0;r<i.length;r++)Object(b.clearCurrentCues)(i[r])}},s.onSubtitleTracksUpdated=function(g,i){var r=this;this.textTracks=[];var o=i.subtitleTracks||[],c=o.some(function(a){return a.textCodec===_.IMSC1_CODEC});if(this.config.enableWebVTT||c&&this.config.enableIMSC1){var t=this.tracks&&o&&this.tracks.length===o.length;if(this.tracks=o||[],this.config.renderTextTracksNatively){var n=this.media?this.media.textTracks:[];this.tracks.forEach(function(a,d){var v;if(d<n.length){for(var S=null,T=0;T<n.length;T++)if(m(n[T],a)){S=n[T];break}S&&(v=S)}if(v)Object(b.clearCurrentCues)(v);else{var I=r._captionsOrSubtitlesFromCharacteristics(a);v=r.createTextTrack(I,a.name,a.lang),v&&(v.mode="disabled")}v&&(v.groupId=a.groupId,r.textTracks.push(v))})}else if(!t&&this.tracks&&this.tracks.length){var u=this.tracks.map(function(a){return{label:a.name,kind:a.type.toLowerCase(),default:a.default,subtitleTrack:a}});this.hls.trigger(L.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:u})}}},s._captionsOrSubtitlesFromCharacteristics=function(g){var i;if((i=g.attrs)!==null&&i!==void 0&&i.CHARACTERISTICS){var r=/transcribes-spoken-dialog/gi.test(g.attrs.CHARACTERISTICS),o=/describes-music-and-sound/gi.test(g.attrs.CHARACTERISTICS);if(r&&o)return"captions"}return"subtitles"},s.onManifestLoaded=function(g,i){var r=this;this.config.enableCEA708Captions&&i.captions&&i.captions.forEach(function(o){var c=/(?:CC|SERVICE)([1-4])/.exec(o.instreamId);if(!!c){var t="textTrack"+c[1],n=r.captionsProperties[t];!n||(n.label=o.name,o.lang&&(n.languageCode=o.lang),n.media=o)}})},s.onFragLoading=function(g,i){var r=this.cea608Parser1,o=this.cea608Parser2,c=this.lastSn,t=this.lastPartIndex;if(!(!this.enabled||!(r&&o))&&i.frag.type===x.PlaylistLevelType.MAIN){var n,u,a=i.frag.sn,d=(n=i==null||(u=i.part)===null||u===void 0?void 0:u.index)!=null?n:-1;a===c+1||a===c&&d===t+1||(r.reset(),o.reset()),this.lastSn=a,this.lastPartIndex=d}},s.onFragLoaded=function(g,i){var r=i.frag,o=i.payload,c=this.initPTS,t=this.unparsedVttFrags;if(r.type===x.PlaylistLevelType.SUBTITLE)if(o.byteLength){if(!Object(P.isFiniteNumber)(c[r.cc])){t.push(i),c.length&&this.hls.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Missing initial subtitle PTS")});return}var n=r.decryptdata,u="stats"in i;if(n==null||n.key==null||n.method!=="AES-128"||u){var a=this.tracks[r.level],d=this.vttCCs;d[r.cc]||(d[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),a&&a.textCodec===_.IMSC1_CODEC?this._parseIMSC1(r,o):this._parseVTTs(r,o,d)}}else this.hls.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})},s._parseIMSC1=function(g,i){var r=this,o=this.hls;Object(_.parseIMSC1)(i,this.initPTS[g.cc],this.timescale[g.cc],function(c){r._appendCues(c,g.level),o.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:g})},function(c){D.logger.log("Failed to parse IMSC1: "+c),o.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:g,error:c})})},s._parseVTTs=function(g,i,r){var o,c=this,t=this.hls,n=(o=g.initSegment)!==null&&o!==void 0&&o.data?Object(y.appendUint8Array)(g.initSegment.data,new Uint8Array(i)):i;Object(O.parseWebVTT)(n,this.initPTS[g.cc],this.timescale[g.cc],r,g.cc,g.start,function(u){c._appendCues(u,g.level),t.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:g})},function(u){c._fallbackToIMSC1(g,i),D.logger.log("Failed to parse VTT cue: "+u),t.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:g,error:u})})},s._fallbackToIMSC1=function(g,i){var r=this,o=this.tracks[g.level];o.textCodec||Object(_.parseIMSC1)(i,this.initPTS[g.cc],this.timescale[g.cc],function(){o.textCodec=_.IMSC1_CODEC,r._parseIMSC1(g,i)},function(){o.textCodec="wvtt"})},s._appendCues=function(g,i){var r=this.hls;if(this.config.renderTextTracksNatively){var o=this.textTracks[i];if(!o||o.mode==="disabled")return;g.forEach(function(n){return Object(b.addCueToTrack)(o,n)})}else{var c=this.tracks[i];if(!c)return;var t=c.default?"default":"subtitles"+i;r.trigger(L.Events.CUES_PARSED,{type:"subtitles",cues:g,track:t})}},s.onFragDecrypted=function(g,i){var r=i.frag;if(r.type===x.PlaylistLevelType.SUBTITLE){if(!Object(P.isFiniteNumber)(this.initPTS[r.cc])){this.unparsedVttFrags.push(i);return}this.onFragLoaded(L.Events.FRAG_LOADED,i)}},s.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},s.onFragParsingUserdata=function(g,i){var r=this.cea608Parser1,o=this.cea608Parser2;if(!(!this.enabled||!(r&&o)))for(var c=0;c<i.samples.length;c++){var t=i.samples[c].bytes;if(t){var n=this.extractCea608Data(t);r.addData(i.samples[c].pts,n[0]),o.addData(i.samples[c].pts,n[1])}}},s.onBufferFlushing=function(g,i){var r=i.startOffset,o=i.endOffset,c=i.endOffsetSubtitles,t=i.type,n=this.media;if(!(!n||n.currentTime<o)){if(!t||t==="video"){var u=this.captionsTracks;Object.keys(u).forEach(function(d){return Object(b.removeCuesInRange)(u[d],r,o)})}if(this.config.renderTextTracksNatively&&r===0&&c!==void 0){var a=this.textTracks;Object.keys(a).forEach(function(d){return Object(b.removeCuesInRange)(a[d],r,c)})}}},s.extractCea608Data=function(g){for(var i=[[],[]],r=g[0]&31,o=2,c=0;c<r;c++){var t=g[o++],n=127&g[o++],u=127&g[o++];if(!(n===0&&u===0)){var a=(4&t)!==0;if(a){var d=3&t;(d===0||d===1)&&(i[d].push(n),i[d].push(u))}}}return i},e}();function m(e,s){return e&&e.label===s.name&&!(e.textTrack1||e.textTrack2)}function p(e,s,h,g){return Math.min(s,g)-Math.max(e,h)}function f(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}},"./src/crypt/aes-crypto.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return P});var P=function(){function L(M,O){this.subtle=void 0,this.aesIV=void 0,this.subtle=M,this.aesIV=O}var A=L.prototype;return A.decrypt=function(O,b){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},b,O)},L}()},"./src/crypt/aes-decryptor.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"removePadding",function(){return L}),l.d(R,"default",function(){return A});var P=l("./src/utils/typed-array.ts");function L(M){var O=M.byteLength,b=O&&new DataView(M.buffer).getUint8(O-1);return b?Object(P.sliceUint8)(M,0,O-b):M}var A=function(){function M(){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 O=M.prototype;return O.uint8ArrayToUint32Array_=function(_){for(var y=new DataView(_),x=new Uint32Array(4),D=0;D<4;D++)x[D]=y.getUint32(D*4);return x},O.initTable=function(){var _=this.sBox,y=this.invSBox,x=this.subMix,D=x[0],E=x[1],m=x[2],p=x[3],f=this.invSubMix,e=f[0],s=f[1],h=f[2],g=f[3],i=new Uint32Array(256),r=0,o=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 t=o^o<<1^o<<2^o<<3^o<<4;t=t>>>8^t&255^99,_[r]=t,y[t]=r;var n=i[r],u=i[n],a=i[u],d=i[t]*257^t*16843008;D[r]=d<<24|d>>>8,E[r]=d<<16|d>>>16,m[r]=d<<8|d>>>24,p[r]=d,d=a*16843009^u*65537^n*257^r*16843008,e[t]=d<<24|d>>>8,s[t]=d<<16|d>>>16,h[t]=d<<8|d>>>24,g[t]=d,r?(r=n^i[i[i[a^n]]],o^=i[i[o]]):r=o=1}},O.expandKey=function(_){for(var y=this.uint8ArrayToUint32Array_(_),x=!0,D=0;D<y.length&&x;)x=y[D]===this.key[D],D++;if(!x){this.key=y;var E=this.keySize=y.length;if(E!==4&&E!==6&&E!==8)throw new Error("Invalid aes key size="+E);var m=this.ksRows=(E+6+1)*4,p,f,e=this.keySchedule=new Uint32Array(m),s=this.invKeySchedule=new Uint32Array(m),h=this.sBox,g=this.rcon,i=this.invSubMix,r=i[0],o=i[1],c=i[2],t=i[3],n,u;for(p=0;p<m;p++){if(p<E){n=e[p]=y[p];continue}u=n,p%E===0?(u=u<<8|u>>>24,u=h[u>>>24]<<24|h[u>>>16&255]<<16|h[u>>>8&255]<<8|h[u&255],u^=g[p/E|0]<<24):E>6&&p%E===4&&(u=h[u>>>24]<<24|h[u>>>16&255]<<16|h[u>>>8&255]<<8|h[u&255]),e[p]=n=(e[p-E]^u)>>>0}for(f=0;f<m;f++)p=m-f,f&3?u=e[p]:u=e[p-4],f<4||p<=4?s[f]=u:s[f]=r[h[u>>>24]]^o[h[u>>>16&255]]^c[h[u>>>8&255]]^t[h[u&255]],s[f]=s[f]>>>0}},O.networkToHostOrderSwap=function(_){return _<<24|(_&65280)<<8|(_&16711680)>>8|_>>>24},O.decrypt=function(_,y,x){for(var D=this.keySize+6,E=this.invKeySchedule,m=this.invSBox,p=this.invSubMix,f=p[0],e=p[1],s=p[2],h=p[3],g=this.uint8ArrayToUint32Array_(x),i=g[0],r=g[1],o=g[2],c=g[3],t=new Int32Array(_),n=new Int32Array(t.length),u,a,d,v,S,T,I,k,B,U,W,G,z,Y,$=this.networkToHostOrderSwap;y<t.length;){for(B=$(t[y]),U=$(t[y+1]),W=$(t[y+2]),G=$(t[y+3]),S=B^E[0],T=G^E[1],I=W^E[2],k=U^E[3],z=4,Y=1;Y<D;Y++)u=f[S>>>24]^e[T>>16&255]^s[I>>8&255]^h[k&255]^E[z],a=f[T>>>24]^e[I>>16&255]^s[k>>8&255]^h[S&255]^E[z+1],d=f[I>>>24]^e[k>>16&255]^s[S>>8&255]^h[T&255]^E[z+2],v=f[k>>>24]^e[S>>16&255]^s[T>>8&255]^h[I&255]^E[z+3],S=u,T=a,I=d,k=v,z=z+4;u=m[S>>>24]<<24^m[T>>16&255]<<16^m[I>>8&255]<<8^m[k&255]^E[z],a=m[T>>>24]<<24^m[I>>16&255]<<16^m[k>>8&255]<<8^m[S&255]^E[z+1],d=m[I>>>24]<<24^m[k>>16&255]<<16^m[S>>8&255]<<8^m[T&255]^E[z+2],v=m[k>>>24]<<24^m[S>>16&255]<<16^m[T>>8&255]<<8^m[I&255]^E[z+3],n[y]=$(u^i),n[y+1]=$(v^r),n[y+2]=$(d^o),n[y+3]=$(a^c),i=B,r=U,o=W,c=G,y=y+4}return n.buffer},M}()},"./src/crypt/decrypter.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return y});var P=l("./src/crypt/aes-crypto.ts"),L=l("./src/crypt/fast-aes-key.ts"),A=l("./src/crypt/aes-decryptor.ts"),M=l("./src/utils/logger.ts"),O=l("./src/utils/mp4-tools.ts"),b=l("./src/utils/typed-array.ts"),_=16,y=function(){function x(E,m,p){var f=p===void 0?{}:p,e=f.removePKCS7Padding,s=e===void 0?!0:e;if(this.logEnabled=!0,this.observer=void 0,this.config=void 0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.observer=E,this.config=m,this.removePKCS7Padding=s,s)try{var h=self.crypto;h&&(this.subtle=h.subtle||h.webkitSubtle)}catch{}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var D=x.prototype;return D.destroy=function(){this.observer=null},D.isSync=function(){return this.config.enableSoftwareAES},D.flush=function(){var m=this.currentResult;if(!m){this.reset();return}var p=new Uint8Array(m);return this.reset(),this.removePKCS7Padding?Object(A.removePadding)(p):p},D.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},D.decrypt=function(m,p,f,e){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(m),p,f);var s=this.flush();s&&e(s.buffer)}else this.webCryptoDecrypt(new Uint8Array(m),p,f).then(e)},D.softwareDecrypt=function(m,p,f){var e=this.currentIV,s=this.currentResult,h=this.remainderData;this.logOnce("JS AES decrypt"),h&&(m=Object(O.appendUint8Array)(h,m),this.remainderData=null);var g=this.getValidChunk(m);if(!g.length)return null;e&&(f=e);var i=this.softwareDecrypter;i||(i=this.softwareDecrypter=new A.default),i.expandKey(p);var r=s;return this.currentResult=i.decrypt(g.buffer,0,f),this.currentIV=Object(b.sliceUint8)(g,-16).buffer,r||null},D.webCryptoDecrypt=function(m,p,f){var e=this,s=this.subtle;return(this.key!==p||!this.fastAesKey)&&(this.key=p,this.fastAesKey=new L.default(s,p)),this.fastAesKey.expandKey().then(function(h){if(!s)return Promise.reject(new Error("web crypto not initialized"));var g=new P.default(s,f);return g.decrypt(m.buffer,h)}).catch(function(h){return e.onWebCryptoError(h,m,p,f)})},D.onWebCryptoError=function(m,p,f,e){return M.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",m),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(p,f,e)},D.getValidChunk=function(m){var p=m,f=m.length-m.length%_;return f!==m.length&&(p=Object(b.sliceUint8)(m,0,f),this.remainderData=Object(b.sliceUint8)(m,f)),p},D.logOnce=function(m){!this.logEnabled||(M.logger.log("[decrypter.ts]: "+m),this.logEnabled=!1)},x}()},"./src/crypt/fast-aes-key.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return P});var P=function(){function L(M,O){this.subtle=void 0,this.key=void 0,this.subtle=M,this.key=O}var A=L.prototype;return A.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},L}()},"./src/demux/aacdemuxer.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/demux/base-audio-demuxer.ts"),L=l("./src/demux/adts.ts"),A=l("./src/utils/logger.ts"),M=l("./src/demux/id3.ts");function O(y,x){y.prototype=Object.create(x.prototype),y.prototype.constructor=y,b(y,x)}function b(y,x){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(E,m){return E.__proto__=m,E},b(y,x)}var _=function(y){O(x,y);function x(E,m){var p;return p=y.call(this)||this,p.observer=void 0,p.config=void 0,p.observer=E,p.config=m,p}var D=x.prototype;return D.resetInitSegment=function(m,p,f,e){y.prototype.resetInitSegment.call(this,m,p,f,e),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:p,duration:e,inputTimeScale:9e4,dropped:0}},x.probe=function(m){if(!m)return!1;for(var p=M.getID3Data(m,0)||[],f=p.length,e=m.length;f<e;f++)if(L.probe(m,f))return A.logger.log("ADTS sync word found !"),!0;return!1},D.canParse=function(m,p){return L.canParse(m,p)},D.appendFrame=function(m,p,f){L.initTrackConfig(m,this.observer,p,f,m.manifestCodec);var e=L.appendFrame(m,p,f,this.basePTS,this.frameIndex);if(e&&e.missing===0)return e},x}(P.default);R.default=_},"./src/demux/adts.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"getAudioConfig",function(){return M}),l.d(R,"isHeaderPattern",function(){return O}),l.d(R,"getHeaderLength",function(){return b}),l.d(R,"getFullFrameLength",function(){return _}),l.d(R,"canGetFrameLength",function(){return y}),l.d(R,"isHeader",function(){return x}),l.d(R,"canParse",function(){return D}),l.d(R,"probe",function(){return E}),l.d(R,"initTrackConfig",function(){return m}),l.d(R,"getFrameDuration",function(){return p}),l.d(R,"parseFrameHeader",function(){return f}),l.d(R,"appendFrame",function(){return e});var P=l("./src/utils/logger.ts"),L=l("./src/errors.ts"),A=l("./src/events.ts");function M(s,h,g,i){var r,o,c,t,n=navigator.userAgent.toLowerCase(),u=i,a=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];r=((h[g+2]&192)>>>6)+1;var d=(h[g+2]&60)>>>2;if(d>a.length-1){s.trigger(A.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+d});return}return c=(h[g+2]&1)<<2,c|=(h[g+3]&192)>>>6,P.logger.log("manifest codec:"+i+", ADTS type:"+r+", samplingIndex:"+d),/firefox/i.test(n)?d>=6?(r=5,t=new Array(4),o=d-3):(r=2,t=new Array(2),o=d):n.indexOf("android")!==-1?(r=2,t=new Array(2),o=d):(r=5,t=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&d>=6?o=d-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(d>=6&&c===1||/vivaldi/i.test(n))||!i&&c===1)&&(r=2,t=new Array(2)),o=d)),t[0]=r<<3,t[0]|=(d&14)>>1,t[1]|=(d&1)<<7,t[1]|=c<<3,r===5&&(t[1]|=(o&14)>>1,t[2]=(o&1)<<7,t[2]|=2<<2,t[3]=0),{config:t,samplerate:a[d],channelCount:c,codec:"mp4a.40."+r,manifestCodec:u}}function O(s,h){return s[h]===255&&(s[h+1]&246)===240}function b(s,h){return s[h+1]&1?7:9}function _(s,h){return(s[h+3]&3)<<11|s[h+4]<<3|(s[h+5]&224)>>>5}function y(s,h){return h+5<s.length}function x(s,h){return h+1<s.length&&O(s,h)}function D(s,h){return y(s,h)&&O(s,h)&&_(s,h)<=s.length-h}function E(s,h){if(x(s,h)){var g=b(s,h);if(h+g>=s.length)return!1;var i=_(s,h);if(i<=g)return!1;var r=h+i;return r===s.length||x(s,r)}return!1}function m(s,h,g,i,r){if(!s.samplerate){var o=M(h,g,i,r);if(!o)return;s.config=o.config,s.samplerate=o.samplerate,s.channelCount=o.channelCount,s.codec=o.codec,s.manifestCodec=o.manifestCodec,P.logger.log("parsed codec:"+s.codec+", rate:"+o.samplerate+", channels:"+o.channelCount)}}function p(s){return 1024*9e4/s}function f(s,h){var g=b(s,h);if(h+g<=s.length){var i=_(s,h)-g;if(i>0)return{headerLength:g,frameLength:i}}}function e(s,h,g,i,r){var o=p(s.samplerate),c=i+r*o,t=f(h,g),n;if(t){var u=t.frameLength,a=t.headerLength,d=a+u,v=Math.max(0,g+d-h.length);v?(n=new Uint8Array(d-a),n.set(h.subarray(g+a,h.length),0)):n=h.subarray(g+a,g+d);var S={unit:n,pts:c};return v||s.samples.push(S),{sample:S,length:d,missing:v}}var T=h.length-g;n=new Uint8Array(T),n.set(h.subarray(g,h.length),0);var I={unit:n,pts:c};return{sample:I,length:T,missing:-1}}},"./src/demux/base-audio-demuxer.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"initPTSFn",function(){return y});var P=l("./src/polyfills/number.ts"),L=l("./src/demux/id3.ts"),A=l("./src/types/demuxer.ts"),M=l("./src/demux/dummy-demuxed-track.ts"),O=l("./src/utils/mp4-tools.ts"),b=l("./src/utils/typed-array.ts"),_=function(){function x(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null}var D=x.prototype;return D.resetInitSegment=function(m,p,f,e){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},D.resetTimeStamp=function(m){this.initPTS=m,this.resetContiguity()},D.resetContiguity=function(){this.basePTS=null,this.frameIndex=0},D.canParse=function(m,p){return!1},D.appendFrame=function(m,p,f){},D.demux=function(m,p){this.cachedData&&(m=Object(O.appendUint8Array)(this.cachedData,m),this.cachedData=null);var f=L.getID3Data(m,0),e=f?f.length:0,s,h,g=this._audioTrack,i=this._id3Track,r=f?L.getTimeStamp(f):void 0,o=m.length;for((this.basePTS===null||this.frameIndex===0&&Object(P.isFiniteNumber)(r))&&(this.basePTS=y(r,p,this.initPTS)),f&&f.length>0&&i.samples.push({pts:this.basePTS,dts:this.basePTS,data:f,type:A.MetadataSchema.audioId3}),h=this.basePTS;e<o;){if(this.canParse(m,e)){var c=this.appendFrame(g,m,e);c?(this.frameIndex++,h=c.sample.pts,e+=c.length,s=e):e=o}else L.canParse(m,e)?(f=L.getID3Data(m,e),i.samples.push({pts:h,dts:h,data:f,type:A.MetadataSchema.audioId3}),e+=f.length,s=e):e++;if(e===o&&s!==o){var t=Object(b.sliceUint8)(m,s);this.cachedData?this.cachedData=Object(O.appendUint8Array)(this.cachedData,t):this.cachedData=t}}return{audioTrack:g,videoTrack:Object(M.dummyTrack)(),id3Track:i,textTrack:Object(M.dummyTrack)()}},D.demuxSampleAes=function(m,p,f){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},D.flush=function(m){var p=this.cachedData;return p&&(this.cachedData=null,this.demux(p,0)),{audioTrack:this._audioTrack,videoTrack:Object(M.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(M.dummyTrack)()}},D.destroy=function(){},x}(),y=function(D,E,m){return Object(P.isFiniteNumber)(D)?D*90:E*9e4+(m||0)};R.default=_},"./src/demux/chunk-cache.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return P});var P=function(){function A(){this.chunks=[],this.dataLength=0}var M=A.prototype;return M.push=function(b){this.chunks.push(b),this.dataLength+=b.length},M.flush=function(){var b=this.chunks,_=this.dataLength,y;if(b.length)b.length===1?y=b[0]:y=L(b,_);else return new Uint8Array(0);return this.reset(),y},M.reset=function(){this.chunks.length=0,this.dataLength=0},A}();function L(A,M){for(var O=new Uint8Array(M),b=0,_=0;_<A.length;_++){var y=A[_];O.set(y,b),b+=y.length}return O}},"./src/demux/dummy-demuxed-track.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"dummyTrack",function(){return P});function P(L,A){return L===void 0&&(L=""),A===void 0&&(A=9e4),{type:L,id:-1,pid:-1,inputTimeScale:A,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/utils/logger.ts"),L=function(){function A(O){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=O,this.bytesAvailable=O.byteLength,this.word=0,this.bitsAvailable=0}var M=A.prototype;return M.loadWord=function(){var b=this.data,_=this.bytesAvailable,y=b.byteLength-_,x=new Uint8Array(4),D=Math.min(4,_);if(D===0)throw new Error("no bytes available");x.set(b.subarray(y,y+D)),this.word=new DataView(x.buffer).getUint32(0),this.bitsAvailable=D*8,this.bytesAvailable-=D},M.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)},M.readBits=function(b){var _=Math.min(this.bitsAvailable,b),y=this.word>>>32-_;return b>32&&P.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?y<<_|this.readBits(_):y},M.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()},M.skipUEG=function(){this.skipBits(1+this.skipLZ())},M.skipEG=function(){this.skipBits(1+this.skipLZ())},M.readUEG=function(){var b=this.skipLZ();return this.readBits(b+1)-1},M.readEG=function(){var b=this.readUEG();return 1&b?1+b>>>1:-1*(b>>>1)},M.readBoolean=function(){return this.readBits(1)===1},M.readUByte=function(){return this.readBits(8)},M.readUShort=function(){return this.readBits(16)},M.readUInt=function(){return this.readBits(32)},M.skipScalingList=function(b){for(var _=8,y=8,x,D=0;D<b;D++)y!==0&&(x=this.readEG(),y=(_+x+256)%256),_=y===0?_:y},M.readSPS=function(){var b=0,_=0,y=0,x=0,D,E,m,p=this.readUByte.bind(this),f=this.readBits.bind(this),e=this.readUEG.bind(this),s=this.readBoolean.bind(this),h=this.skipBits.bind(this),g=this.skipEG.bind(this),i=this.skipUEG.bind(this),r=this.skipScalingList.bind(this);p();var o=p();if(f(5),h(3),p(),i(),o===100||o===110||o===122||o===244||o===44||o===83||o===86||o===118||o===128){var c=e();if(c===3&&h(1),i(),i(),h(1),s())for(E=c!==3?8:12,m=0;m<E;m++)s()&&(m<6?r(16):r(64))}i();var t=e();if(t===0)e();else if(t===1)for(h(1),g(),g(),D=e(),m=0;m<D;m++)g();i(),h(1);var n=e(),u=e(),a=f(1);a===0&&h(1),h(1),s()&&(b=e(),_=e(),y=e(),x=e());var d=[1,1];if(s()&&s()){var v=p();switch(v){case 1:d=[1,1];break;case 2:d=[12,11];break;case 3:d=[10,11];break;case 4:d=[16,11];break;case 5:d=[40,33];break;case 6:d=[24,11];break;case 7:d=[20,11];break;case 8:d=[32,11];break;case 9:d=[80,33];break;case 10:d=[18,11];break;case 11:d=[15,11];break;case 12:d=[64,33];break;case 13:d=[160,99];break;case 14:d=[4,3];break;case 15:d=[3,2];break;case 16:d=[2,1];break;case 255:{d=[p()<<8|p(),p()<<8|p()];break}}}return{width:Math.ceil((n+1)*16-b*2-_*2),height:(2-a)*(u+1)*16-(a?2:4)*(y+x),pixelRatio:d}},M.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},A}();R.default=L},"./src/demux/id3.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"isHeader",function(){return P}),l.d(R,"isFooter",function(){return L}),l.d(R,"getID3Data",function(){return A}),l.d(R,"canParse",function(){return O}),l.d(R,"getTimeStamp",function(){return b}),l.d(R,"isTimeStampFrame",function(){return _}),l.d(R,"getID3Frames",function(){return x}),l.d(R,"decodeFrame",function(){return D}),l.d(R,"utf8ArrayToStr",function(){return e}),l.d(R,"testables",function(){return s});var P=function(r,o){return o+10<=r.length&&r[o]===73&&r[o+1]===68&&r[o+2]===51&&r[o+3]<255&&r[o+4]<255&&r[o+6]<128&&r[o+7]<128&&r[o+8]<128&&r[o+9]<128},L=function(r,o){return o+10<=r.length&&r[o]===51&&r[o+1]===68&&r[o+2]===73&&r[o+3]<255&&r[o+4]<255&&r[o+6]<128&&r[o+7]<128&&r[o+8]<128&&r[o+9]<128},A=function(r,o){for(var c=o,t=0;P(r,o);){t+=10;var n=M(r,o+6);t+=n,L(r,o+10)&&(t+=10),o+=t}if(t>0)return r.subarray(c,c+t)},M=function(r,o){var c=0;return c=(r[o]&127)<<21,c|=(r[o+1]&127)<<14,c|=(r[o+2]&127)<<7,c|=r[o+3]&127,c},O=function(r,o){return P(r,o)&&M(r,o+6)+10<=r.length-o},b=function(r){for(var o=x(r),c=0;c<o.length;c++){var t=o[c];if(_(t))return f(t)}},_=function(r){return r&&r.key==="PRIV"&&r.info==="com.apple.streaming.transportStreamTimestamp"},y=function(r){var o=String.fromCharCode(r[0],r[1],r[2],r[3]),c=M(r,4),t=10;return{type:o,size:c,data:r.subarray(t,t+c)}},x=function(r){for(var o=0,c=[];P(r,o);){var t=M(r,o+6);o+=10;for(var n=o+t;o+8<n;){var u=y(r.subarray(o)),a=D(u);a&&c.push(a),o+=u.size+10}L(r,o)&&(o+=10)}return c},D=function(r){return r.type==="PRIV"?E(r):r.type[0]==="W"?p(r):m(r)},E=function(r){if(!(r.size<2)){var o=e(r.data,!0),c=new Uint8Array(r.data.subarray(o.length+1));return{key:r.type,info:o,data:c.buffer}}},m=function(r){if(!(r.size<2)){if(r.type==="TXXX"){var o=1,c=e(r.data.subarray(o),!0);o+=c.length+1;var t=e(r.data.subarray(o));return{key:r.type,info:c,data:t}}var n=e(r.data.subarray(1));return{key:r.type,data:n}}},p=function(r){if(r.type==="WXXX"){if(r.size<2)return;var o=1,c=e(r.data.subarray(o),!0);o+=c.length+1;var t=e(r.data.subarray(o));return{key:r.type,info:c,data:t}}var n=e(r.data);return{key:r.type,data:n}},f=function(r){if(r.data.byteLength===8){var o=new Uint8Array(r.data),c=o[3]&1,t=(o[4]<<23)+(o[5]<<15)+(o[6]<<7)+o[7];return t/=45,c&&(t+=4772185884e-2),Math.round(t)}},e=function(r,o){o===void 0&&(o=!1);var c=g();if(c){var t=c.decode(r);if(o){var n=t.indexOf("\0");return n!==-1?t.substring(0,n):t}return t.replace(/\0/g,"")}for(var u=r.length,a,d,v,S="",T=0;T<u;){if(a=r[T++],a===0&&o)return S;if(a===0||a===3)continue;switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:S+=String.fromCharCode(a);break;case 12:case 13:d=r[T++],S+=String.fromCharCode((a&31)<<6|d&63);break;case 14:d=r[T++],v=r[T++],S+=String.fromCharCode((a&15)<<12|(d&63)<<6|(v&63)<<0);break;default:}}return S},s={decodeTextFrame:m},h;function g(){return!h&&typeof self.TextDecoder!="undefined"&&(h=new self.TextDecoder("utf-8")),h}},"./src/demux/mp3demuxer.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/demux/base-audio-demuxer.ts"),L=l("./src/demux/id3.ts"),A=l("./src/utils/logger.ts"),M=l("./src/demux/mpegaudio.ts");function O(y,x){y.prototype=Object.create(x.prototype),y.prototype.constructor=y,b(y,x)}function b(y,x){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(E,m){return E.__proto__=m,E},b(y,x)}var _=function(y){O(x,y);function x(){return y.apply(this,arguments)||this}var D=x.prototype;return D.resetInitSegment=function(m,p,f,e){y.prototype.resetInitSegment.call(this,m,p,f,e),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:p,duration:e,inputTimeScale:9e4,dropped:0}},x.probe=function(m){if(!m)return!1;for(var p=L.getID3Data(m,0)||[],f=p.length,e=m.length;f<e;f++)if(M.probe(m,f))return A.logger.log("MPEG Audio sync word found !"),!0;return!1},D.canParse=function(m,p){return M.canParse(m,p)},D.appendFrame=function(m,p,f){if(this.basePTS!==null)return M.appendFrame(m,p,f,this.basePTS,this.frameIndex)},x}(P.default);R.default=_},"./src/demux/mp4demuxer.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/polyfills/number.ts"),L=l("./src/types/demuxer.ts"),A=l("./src/utils/mp4-tools.ts"),M=l("./src/demux/dummy-demuxed-track.ts"),O=/\/emsg[-/]ID3/i,b=function(){function _(x,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 y=_.prototype;return y.resetTimeStamp=function(){},y.resetInitSegment=function(D,E,m,p){var f=Object(A.parseInitSegment)(D),e=this.videoTrack=Object(M.dummyTrack)("video",1),s=this.audioTrack=Object(M.dummyTrack)("audio",1),h=this.txtTrack=Object(M.dummyTrack)("text",1);if(this.id3Track=Object(M.dummyTrack)("id3",1),this.timeOffset=0,f.video){var g=f.video,i=g.id,r=g.timescale,o=g.codec;e.id=i,e.timescale=h.timescale=r,e.codec=o}if(f.audio){var c=f.audio,t=c.id,n=c.timescale,u=c.codec;s.id=t,s.timescale=n,s.codec=u}h.id=A.RemuxerTrackIdConfig.text,e.sampleDuration=0,e.duration=s.duration=p},y.resetContiguity=function(){},_.probe=function(D){return D=D.length>16384?D.subarray(0,16384):D,Object(A.findBox)(D,["moof"]).length>0},y.demux=function(D,E){this.timeOffset=E;var m=D,p=this.videoTrack,f=this.txtTrack;if(this.config.progressive){this.remainderData&&(m=Object(A.appendUint8Array)(this.remainderData,D));var e=Object(A.segmentValidRange)(m);this.remainderData=e.remainder,p.samples=e.valid||new Uint8Array}else p.samples=m;var s=this.extractID3Track(p,E);return f.samples=Object(A.parseSamples)(E,p),{videoTrack:p,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}},y.flush=function(){var D=this.timeOffset,E=this.videoTrack,m=this.txtTrack;E.samples=this.remainderData||new Uint8Array,this.remainderData=null;var p=this.extractID3Track(E,this.timeOffset);return m.samples=Object(A.parseSamples)(D,E),{videoTrack:E,audioTrack:Object(M.dummyTrack)(),id3Track:p,textTrack:Object(M.dummyTrack)()}},y.extractID3Track=function(D,E){var m=this.id3Track;if(D.samples.length){var p=Object(A.findBox)(D.samples,["emsg"]);p&&p.forEach(function(f){var e=Object(A.parseEmsg)(f);if(O.test(e.schemeIdUri)){var s=Object(P.isFiniteNumber)(e.presentationTime)?e.presentationTime/e.timeScale:E+e.presentationTimeDelta/e.timeScale,h=e.payload;m.samples.push({data:h,len:h.byteLength,dts:s,pts:s,type:L.MetadataSchema.emsg})}})}return m},y.demuxSampleAes=function(D,E,m){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},y.destroy=function(){},_}();R.default=b},"./src/demux/mpegaudio.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"appendFrame",function(){return b}),l.d(R,"parseHeader",function(){return _}),l.d(R,"isHeaderPattern",function(){return y}),l.d(R,"isHeader",function(){return x}),l.d(R,"canParse",function(){return D}),l.d(R,"probe",function(){return E});var P=null,L=[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],A=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],M=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],O=[0,1,1,4];function b(m,p,f,e,s){if(!(f+24>p.length)){var h=_(p,f);if(h&&f+h.frameLength<=p.length){var g=h.samplesPerFrame*9e4/h.sampleRate,i=e+s*g,r={unit:p.subarray(f,f+h.frameLength),pts:i,dts:i};return m.config=[],m.channelCount=h.channelCount,m.samplerate=h.sampleRate,m.samples.push(r),{sample:r,length:h.frameLength,missing:0}}}}function _(m,p){var f=m[p+1]>>3&3,e=m[p+1]>>1&3,s=m[p+2]>>4&15,h=m[p+2]>>2&3;if(f!==1&&s!==0&&s!==15&&h!==3){var g=m[p+2]>>1&1,i=m[p+3]>>6,r=f===3?3-e:e===3?3:4,o=L[r*14+s-1]*1e3,c=f===3?0:f===2?1:2,t=A[c*3+h],n=i===3?1:2,u=M[f][e],a=O[e],d=u*8*a,v=Math.floor(u*o/t+g)*a;if(P===null){var S=navigator.userAgent||"",T=S.match(/Chrome\/(\d+)/i);P=T?parseInt(T[1]):0}var I=!!P&&P<=87;return I&&e===2&&o>=224e3&&i===0&&(m[p+3]=m[p+3]|128),{sampleRate:t,channelCount:n,frameLength:v,samplesPerFrame:d}}}function y(m,p){return m[p]===255&&(m[p+1]&224)===224&&(m[p+1]&6)!==0}function x(m,p){return p+1<m.length&&y(m,p)}function D(m,p){var f=4;return y(m,p)&&f<=m.length-p}function E(m,p){if(p+1<m.length&&y(m,p)){var f=4,e=_(m,p),s=f;e!=null&&e.frameLength&&(s=e.frameLength);var h=p+s;return h===m.length||x(m,h)}return!1}},"./src/demux/sample-aes.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/crypt/decrypter.ts"),L=l("./src/demux/tsdemuxer.ts"),A=function(){function M(b,_,y){this.keyData=void 0,this.decrypter=void 0,this.keyData=y,this.decrypter=new P.default(b,_,{removePKCS7Padding:!1})}var O=M.prototype;return O.decryptBuffer=function(_,y){this.decrypter.decrypt(_,this.keyData.key.buffer,this.keyData.iv.buffer,y)},O.decryptAacSample=function(_,y,x,D){var E=_[y].unit;if(!(E.length<=16)){var m=E.subarray(16,E.length-E.length%16),p=m.buffer.slice(m.byteOffset,m.byteOffset+m.length),f=this;this.decryptBuffer(p,function(e){var s=new Uint8Array(e);E.set(s,16),D||f.decryptAacSamples(_,y+1,x)})}},O.decryptAacSamples=function(_,y,x){for(;;y++){if(y>=_.length){x();return}if(!(_[y].unit.length<32)){var D=this.decrypter.isSync();if(this.decryptAacSample(_,y,x,D),!D)return}}},O.getAvcEncryptedData=function(_){for(var y=Math.floor((_.length-48)/160)*16+16,x=new Int8Array(y),D=0,E=32;E<_.length-16;E+=160,D+=16)x.set(_.subarray(E,E+16),D);return x},O.getAvcDecryptedUnit=function(_,y){for(var x=new Uint8Array(y),D=0,E=32;E<_.length-16;E+=160,D+=16)_.set(x.subarray(D,D+16),E);return _},O.decryptAvcSample=function(_,y,x,D,E,m){var p=Object(L.discardEPB)(E.data),f=this.getAvcEncryptedData(p),e=this;this.decryptBuffer(f.buffer,function(s){E.data=e.getAvcDecryptedUnit(p,s),m||e.decryptAvcSamples(_,y,x+1,D)})},O.decryptAvcSamples=function(_,y,x,D){if(_ instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;y++,x=0){if(y>=_.length){D();return}for(var E=_[y].units;!(x>=E.length);x++){var m=E[x];if(!(m.data.length<=48||m.type!==1&&m.type!==5)){var p=this.decrypter.isSync();if(this.decryptAvcSample(_,y,x,D,m,p),!p)return}}}},M}();R.default=A},"./src/demux/transmuxer-interface.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return E});var P=l("./node_modules/webworkify-webpack/index.js"),L=l.n(P),A=l("./src/events.ts"),M=l("./src/demux/transmuxer.ts"),O=l("./src/utils/logger.ts"),b=l("./src/errors.ts"),_=l("./src/utils/mediasource-helper.ts"),y=l("./node_modules/eventemitter3/index.js"),x=l.n(y),D=Object(_.getMediaSource)()||{isTypeSupported:function(){return!1}},E=function(){function m(f,e,s,h){var g=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=f,this.id=e,this.onTransmuxComplete=s,this.onFlush=h;var i=f.config,r=function(u,a){a=a||{},a.frag=g.frag,a.id=g.id,f.trigger(u,a)};this.observer=new y.EventEmitter,this.observer.on(A.Events.FRAG_DECRYPTED,r),this.observer.on(A.Events.ERROR,r);var o={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"){O.logger.log("demuxing in webworker");var t;try{t=this.worker=P("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),t.addEventListener("message",this.onwmsg),t.onerror=function(n){f.trigger(A.Events.ERROR,{type:b.ErrorTypes.OTHER_ERROR,details:b.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(n.message+" ("+n.filename+":"+n.lineno+")")})},t.postMessage({cmd:"init",typeSupported:o,vendor:c,id:e,config:JSON.stringify(i)})}catch(n){O.logger.warn("Error in worker:",n),O.logger.error("Error while initializing DemuxerWorker, fallback to inline"),t&&self.URL.revokeObjectURL(t.objectURL),this.transmuxer=new M.default(this.observer,o,i,c,e),this.worker=null}}else this.transmuxer=new M.default(this.observer,o,i,c,e)}var p=m.prototype;return p.destroy=function(){var e=this.worker;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.worker=null,this.onwmsg=void 0;else{var s=this.transmuxer;s&&(s.destroy(),this.transmuxer=null)}var h=this.observer;h&&h.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},p.push=function(e,s,h,g,i,r,o,c,t,n){var u,a,d=this;t.transmuxing.start=self.performance.now();var v=this.transmuxer,S=this.worker,T=r?r.start:i.start,I=i.decryptdata,k=this.frag,B=!(k&&i.cc===k.cc),U=!(k&&t.level===k.level),W=k?t.sn-k.sn:-1,G=this.part?t.part-this.part.index:-1,z=W===0&&t.id>1&&t.id===(k==null?void 0:k.stats.chunkCount),Y=!U&&(W===1||W===0&&(G===1||z&&G<=0)),$=self.performance.now();(U||W||i.stats.parsing.start===0)&&(i.stats.parsing.start=$),r&&(G||!Y)&&(r.stats.parsing.start=$);var Z=!(k&&((u=i.initSegment)===null||u===void 0?void 0:u.url)===((a=k.initSegment)===null||a===void 0?void 0:a.url)),q=new M.TransmuxState(B,Y,c,U,T,Z);if(!Y||B||Z){O.logger.log("[transmuxer-interface, "+i.type+"]: Starting new transmux session for sn: "+t.sn+" p: "+t.part+" level: "+t.level+" id: "+t.id+`
|
|
14
|
+
discontinuity: `+B+`
|
|
15
|
+
trackSwitch: `+U+`
|
|
16
|
+
contiguous: `+Y+`
|
|
16
17
|
accurateTimeOffset: `+c+`
|
|
17
|
-
timeOffset: `+
|
|
18
|
-
initSegmentChange: `+H);var Y=new I.TransmuxConfig(f,n,o,u,h);this.configureTransmuxer(Y)}if(this.frag=i,this.part=t,O)O.postMessage({cmd:"demux",data:e,decryptdata:M,chunkMeta:r,state:V},e instanceof ArrayBuffer?[e]:[]);else if(m){var Q=m.push(e,M,r,V);Object(I.isPromise)(Q)?Q.then(function(J){v.handleTransmuxComplete(J)}):this.handleTransmuxComplete(Q)}},E.flush=function(e){var o=this;e.transmuxing.start=self.performance.now();var f=this.transmuxer,n=this.worker;if(n)n.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)}},E.handleFlushResult=function(e,o){var f=this;e.forEach(function(n){f.handleTransmuxComplete(n)}),this.onFlush(o)},E.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}}},E.configureTransmuxer=function(e){var o=this.worker,f=this.transmuxer;o?o.postMessage({cmd:"configure",config:e}):f&&f.configure(e)},E.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},g}()},"./src/demux/transmuxer-worker.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"default",function(){return L});var R=s("./src/demux/transmuxer.ts"),p=s("./src/events.ts"),x=s("./src/utils/logger.ts"),I=s("./node_modules/eventemitter3/index.js"),T=s.n(I);function L(S){var g=new I.EventEmitter,E=function(o,f){S.postMessage({event:o,data:f})};g.on(p.Events.FRAG_DECRYPTED,E),g.on(p.Events.ERROR,E);var a=function(){var o=function(i){var t=function(c){E("workerLog",{logType:i,message:c})};x.logger[i]=t};for(var f in x.logger)o(f)};S.addEventListener("message",function(e){var o=e.data;switch(o.cmd){case"init":{var f=JSON.parse(o.config);S.transmuxer=new R.default(g,o.typeSupported,f,o.vendor,o.id),Object(x.enableLogs)(f.debug),a(),E("init",null);break}case"configure":{S.transmuxer.configure(o.config);break}case"demux":{var n=S.transmuxer.push(o.data,o.decryptdata,o.chunkMeta,o.state);Object(R.isPromise)(n)?n.then(function(u){_(S,u)}):_(S,n);break}case"flush":{var i=o.chunkMeta,t=S.transmuxer.flush(i);Object(R.isPromise)(t)?t.then(function(u){D(S,u,i)}):D(S,t,i);break}default:break}})}function _(S,g){if(A(g.remuxResult))return!1;var E=[],a=g.remuxResult,e=a.audio,o=a.video;return e&&y(E,e),o&&y(E,o),S.postMessage({event:"transmuxComplete",data:g},E),!0}function y(S,g){g.data1&&S.push(g.data1.buffer),g.data2&&S.push(g.data2.buffer)}function D(S,g,E){var a=g.reduce(function(e,o){return _(S,o)||e},!1);a||S.postMessage({event:"transmuxComplete",data:g[0]}),S.postMessage({event:"flush",data:E})}function A(S){return!S.audio&&!S.video&&!S.text&&!S.id3&&!S.initSegment}},"./src/demux/transmuxer.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"default",function(){return E}),s.d(P,"isPromise",function(){return o}),s.d(P,"TransmuxConfig",function(){return f}),s.d(P,"TransmuxState",function(){return n});var R=s("./src/events.ts"),p=s("./src/errors.ts"),x=s("./src/crypt/decrypter.ts"),I=s("./src/demux/aacdemuxer.ts"),T=s("./src/demux/mp4demuxer.ts"),L=s("./src/demux/tsdemuxer.ts"),_=s("./src/demux/mp3demuxer.ts"),y=s("./src/remux/mp4-remuxer.ts"),D=s("./src/remux/passthrough-remuxer.ts"),A=s("./src/utils/logger.ts"),S;try{S=self.performance.now.bind(self.performance)}catch{A.logger.debug("Unable to use Performance API on this environment"),S=self.Date.now}var g=[{demux:L.default,remux:y.default},{demux:T.default,remux:D.default},{demux:I.default,remux:y.default},{demux:_.default,remux:y.default}],E=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=S();var m=new Uint8Array(c),O=this.config,b=this.currentTransmuxState,M=this.transmuxConfig;d&&(this.currentTransmuxState=d);var F=d||b,w=F.contiguous,C=F.discontinuity,B=F.trackSwitch,U=F.accurateTimeOffset,j=F.timeOffset,N=F.initSegmentChange,K=M.audioCodec,H=M.videoCodec,V=M.defaultInitPts,Y=M.duration,Q=M.initSegmentData;(C||B||N)&&this.resetInitSegment(Q,K,H,Y),(C||N)&&this.resetInitialTimestamp(V),w||this.resetContiguity();var J=a(m,r);if(J&&J.method==="AES-128"){var z=this.getDecrypter();if(O.enableSoftwareAES){var q=z.softwareDecrypt(m,J.key.buffer,J.iv.buffer);if(!q)return v.executeEnd=S(),e(h);m=new Uint8Array(q)}else return this.decryptionPromise=z.webCryptoDecrypt(m,J.key.buffer,J.iv.buffer).then(function(le){var ne=l.push(le,null,h);return l.decryptionPromise=null,ne}),this.decryptionPromise}this.needsProbing(m,C,B)&&this.configureTransmuxer(m,M);var re=this.transmux(m,J,j,U,h),X=this.currentTransmuxState;return X.contiguous=!0,X.discontinuity=!1,X.trackSwitch=!1,v.executeEnd=S(),re},t.flush=function(c){var r=this,h=c.transmuxing;h.executeStart=S();var d=this.decrypter,l=this.currentTransmuxState,v=this.decryptionPromise;if(v)return v.then(function(){return r.flush(c)});var m=[],O=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=S(),[e(c)];var w=M.flush(O);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,O=this.currentTransmuxState,b=O.accurateTimeOffset,M=O.timeOffset;A.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=S()},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,O=l.id3Track,b=l.textTrack,M=this.remuxer.remux(v,m,O,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 O=v.remuxer.remux(m.audioTrack,m.videoTrack,m.id3Track,m.textTrack,h,d,!1,v.id);return{remuxResult:O,chunkMeta:l}})},t.configureTransmuxer=function(c,r){for(var h=this.config,d=this.observer,l=this.typeSupported,v=this.vendor,m=r.audioCodec,O=r.defaultInitPts,b=r.duration,M=r.initSegmentData,F=r.videoCodec,w,C=0,B=g.length;C<B;C++)if(g[C].demux.probe(c)){w=g[C];break}w||(A.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),w={demux:T.default,remux:D.default});var U=this.demuxer,j=this.remuxer,N=w.remux,K=w.demux;(!j||!(j instanceof N))&&(this.remuxer=new N(d,h,l,v)),(!U||!(U instanceof K))&&(this.demuxer=new K(d,h,l),this.probe=K.probe),this.resetInitSegment(M,m,F,b),this.resetInitialTimestamp(O)},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 x.default(this.observer,this.config)),c},i}();function a(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},n=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(k,P,s){"use strict";s.r(P),s.d(P,"discardEPB",function(){return f});var R=s("./src/demux/adts.ts"),p=s("./src/demux/mpegaudio.ts"),x=s("./src/demux/exp-golomb.ts"),I=s("./src/demux/sample-aes.ts"),T=s("./src/events.ts"),L=s("./src/utils/mp4-tools.ts"),_=s("./src/utils/logger.ts"),y=s("./src/errors.ts"),D=s("./src/types/demuxer.ts");function A(){return A=Object.assign?Object.assign.bind():function(n){for(var i=1;i<arguments.length;i++){var t=arguments[i];for(var u in t)Object.prototype.hasOwnProperty.call(t,u)&&(n[u]=t[u])}return n},A.apply(this,arguments)}var S=function(){function n(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}n.probe=function(u){return u[0]===71&&u[188]===71},n.createTrack=function(u,c){return{container:u==="video"||u==="audio"?"video/mp2t":void 0,type:u,id:L.RemuxerTrackIdConfig[u],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:u==="audio"?c:void 0}};var i=n.prototype;return i.resetInitSegment=function(u,c,r,h){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=n.createTrack("video"),this._audioTrack=n.createTrack("audio",h),this._id3Track=n.createTrack("id3"),this._txtTrack=n.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=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,O=this._txtTrack,b=l.pid,M=l.pesData,F=v.pid,w=m.pid,C=v.pesData,B=m.pesData,U=null,j=this.pmtParsed,N=this._pmtId,K=u.length;if(this.remainderData&&(u=Object(L.appendUint8Array)(this.remainderData,u),K=u.length,this.remainderData=null),K<188&&!h)return this.remainderData=u,{audioTrack:v,videoTrack:l,id3Track:m,textTrack:O};K-=K%188,K<u.byteLength&&!h&&(this.remainderData=new Uint8Array(u.buffer,K,u.buffer.byteLength-K));for(var H=0,V=0;V<K;V+=188)if(u[V]===71){var Y=!!(u[V+1]&64),Q=((u[V+1]&31)<<8)+u[V+2],J=(u[V+3]&48)>>4,z=void 0;if(J>1){if(z=V+5+u[V+4],z===V+188)continue}else z=V+4;switch(Q){case b:Y&&(M&&(d=e(M))&&this.parseAVCPES(l,O,d,!1),M={data:[],size:0}),M&&(M.data.push(u.subarray(z,V+188)),M.size+=V+188-z);break;case F:if(Y){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(z,V+188)),C.size+=V+188-z);break;case w:Y&&(B&&(d=e(B))&&this.parseID3PES(m,d),B={data:[],size:0}),B&&(B.data.push(u.subarray(z,V+188)),B.size+=V+188-z);break;case 0:Y&&(z+=u[z]+1),N=this._pmtId=E(u,z);break;case N:{Y&&(z+=u[z]+1);var q=a(u,z,this.typeSupported,r);b=q.avc,b>0&&(l.pid=b),F=q.audio,F>0&&(v.pid=F,v.segmentCodec=q.segmentCodec),w=q.id3,w>0&&(m.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=Q;break}}else H++;H>0&&this.observer.emit(T.Events.ERROR,T.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+H+" TS packet/s that do not start with 0x47"}),l.pesData=M,v.pesData=C,m.pesData=B;var re={audioTrack:v,videoTrack:l,id3Track:m,textTrack:O};return h&&this.extractRemainingSamples(re),re},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,O;if(l&&(O=e(l))?(this.parseAVCPES(r,d,O,!0),r.pesData=null):r.pesData=l,v&&(O=e(v))){switch(c.segmentCodec){case"aac":this.parseAACPES(c,O);break;case"mp3":this.parseMPEGPES(c,O);break}c.pesData=null}else v!=null&&v.size&&_.logger.log("last AAC PES packet truncated,might overlap between fragments"),c.pesData=v;m&&(O=e(m))?(this.parseID3PES(h,O),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,O,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:{O=!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 x.default(F).readSliceType();(w===2||w===4||w===7||w===9)&&(m.key=!0)}break}case 5:O=!0,m||(m=d.avcSample=g(!0,r.pts,r.dts,"")),v&&(m.debug+="IDR "),m.key=!0,m.frame=!0;break;case 6:{O=!0,v&&m&&(m.debug+="SEI "),Object(L.parseSEIMessageFromNALu)(f(M.data),r.pts,c.samples);break}case 7:if(O=!0,b=!0,v&&m&&(m.debug+="SPS "),!u.sps){var C=new x.default(M.data),B=C.readSPS();u.width=B.width,u.height=B.height,u.pixelRatio=B.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 K=U[N].toString(16);K.length<2&&(K="0"+K),j+=K}u.codec=j}break;case 8:O=!0,v&&m&&(m.debug+="PPS "),u.pps||(u.pps=[M.data]);break;case 9:O=!1,u.audFound=!0,m&&o(m,u),m=d.avcSample=g(!1,r.pts,r.dts,v?"AUD ":"");break;case 12:O=!0;break;default:O=!1,m&&(m.debug+="unknown NAL "+M.type+" ");break}if(m&&O){var H=m.units;H.push(M)}}),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,O,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)),O=v-h-1,O>0)){var B=new Uint8Array(C.data.byteLength+O);B.set(C.data,0),B.set(c.subarray(0,O),C.data.byteLength),C.data=B,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 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 m=new Uint8Array(v+d.byteLength);m.set(h.sample.unit,0),m.set(d,v),d=m}else{var O=v-l;h.sample.unit.set(d.subarray(0,l),O),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(T.Events.ERROR,T.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.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 B=R.getFrameDuration(u.samplerate);C=h.sample.pts+B}else{_.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var U=0,j;b<M;)if(j=R.appendFrame(u,d,b,C,U),b+=j.length,j.missing){this.aacOverFlow=j;break}else for(U++;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=A({},c,{type:this._avcTrack?D.MetadataSchema.emsg:D.MetadataSchema.audioId3});u.samples.push(r)},n}();function g(n,i,t,u){return{key:n,frame:!1,pts:i,dts:t,units:[],debug:u,length:0}}function E(n,i){return(n[i+10]&31)<<8|n[i+11]}function a(n,i,t,u){var c={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},r=(n[i+1]&15)<<8|n[i+2],h=i+3+r-4,d=(n[i+10]&15)<<8|n[i+11];for(i+=12+d;i<h;){var l=(n[i+1]&31)<<8|n[i+2];switch(n[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+=((n[i+3]&15)<<8|n[i+4])+5}return c}function e(n){var i=0,t,u,c,r,h,d=n.data;if(!n||n.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>n.size-6)return null;var m=t[7];m&192&&(r=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,m&64?(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 O=c+9;if(n.size<=O)return null;n.size-=O;for(var b=new Uint8Array(n.size),M=0,F=d.length;M<F;M++){t=d[M];var w=t.byteLength;if(O)if(O>w){O-=w;continue}else t=t.subarray(O),w-=O,O=0;b.set(t,i),i+=w}return u&&(u-=c+3),{data:b,pts:r,dts:h,len:u}}return null}function o(n,i){if(n.units.length&&n.frame){if(n.pts===void 0){var t=i.samples,u=t.length;if(u){var c=t[u-1];n.pts=c.pts,n.dts=c.dts}else{i.dropped++;return}}i.samples.push(n)}n.debug.length&&_.logger.log(n.pts+"/"+n.dts+":"+n.debug)}function f(n){for(var i=n.byteLength,t=[],u=1;u<i-2;)n[u]===0&&n[u+1]===0&&n[u+2]===3?(t.push(u+2),u+=2):u++;if(t.length===0)return n;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]=n[h];return r}P.default=S},"./src/errors.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"ErrorTypes",function(){return R}),s.d(P,"ErrorDetails",function(){return p});var R;(function(x){x.NETWORK_ERROR="networkError",x.MEDIA_ERROR="mediaError",x.KEY_SYSTEM_ERROR="keySystemError",x.MUX_ERROR="muxError",x.OTHER_ERROR="otherError"})(R||(R={}));var p;(function(x){x.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",x.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",x.KEY_SYSTEM_NO_SESSION="keySystemNoSession",x.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",x.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",x.MANIFEST_LOAD_ERROR="manifestLoadError",x.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",x.MANIFEST_PARSING_ERROR="manifestParsingError",x.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",x.LEVEL_EMPTY_ERROR="levelEmptyError",x.LEVEL_LOAD_ERROR="levelLoadError",x.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",x.LEVEL_SWITCH_ERROR="levelSwitchError",x.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",x.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",x.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",x.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",x.FRAG_LOAD_ERROR="fragLoadError",x.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",x.FRAG_DECRYPT_ERROR="fragDecryptError",x.FRAG_PARSING_ERROR="fragParsingError",x.REMUX_ALLOC_ERROR="remuxAllocError",x.KEY_LOAD_ERROR="keyLoadError",x.KEY_LOAD_TIMEOUT="keyLoadTimeOut",x.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",x.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",x.BUFFER_APPEND_ERROR="bufferAppendError",x.BUFFER_APPENDING_ERROR="bufferAppendingError",x.BUFFER_STALLED_ERROR="bufferStalledError",x.BUFFER_FULL_ERROR="bufferFullError",x.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",x.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",x.INTERNAL_EXCEPTION="internalException",x.INTERNAL_ABORTED="aborted",x.UNKNOWN="unknown"})(p||(p={}))},"./src/events.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"Events",function(){return R});var R;(function(p){p.MEDIA_ATTACHING="hlsMediaAttaching",p.MEDIA_ATTACHED="hlsMediaAttached",p.MEDIA_DETACHING="hlsMediaDetaching",p.MEDIA_DETACHED="hlsMediaDetached",p.BUFFER_RESET="hlsBufferReset",p.BUFFER_CODECS="hlsBufferCodecs",p.BUFFER_CREATED="hlsBufferCreated",p.BUFFER_APPENDING="hlsBufferAppending",p.BUFFER_APPENDED="hlsBufferAppended",p.BUFFER_EOS="hlsBufferEos",p.BUFFER_FLUSHING="hlsBufferFlushing",p.BUFFER_FLUSHED="hlsBufferFlushed",p.MANIFEST_LOADING="hlsManifestLoading",p.MANIFEST_LOADED="hlsManifestLoaded",p.MANIFEST_PARSED="hlsManifestParsed",p.LEVEL_SWITCHING="hlsLevelSwitching",p.LEVEL_SWITCHED="hlsLevelSwitched",p.LEVEL_LOADING="hlsLevelLoading",p.LEVEL_LOADED="hlsLevelLoaded",p.LEVEL_UPDATED="hlsLevelUpdated",p.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",p.LEVELS_UPDATED="hlsLevelsUpdated",p.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",p.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",p.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",p.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",p.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",p.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",p.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",p.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",p.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",p.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",p.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",p.CUES_PARSED="hlsCuesParsed",p.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",p.INIT_PTS_FOUND="hlsInitPtsFound",p.FRAG_LOADING="hlsFragLoading",p.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",p.FRAG_LOADED="hlsFragLoaded",p.FRAG_DECRYPTED="hlsFragDecrypted",p.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",p.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",p.FRAG_PARSING_METADATA="hlsFragParsingMetadata",p.FRAG_PARSED="hlsFragParsed",p.FRAG_BUFFERED="hlsFragBuffered",p.FRAG_CHANGED="hlsFragChanged",p.FPS_DROP="hlsFpsDrop",p.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",p.ERROR="hlsError",p.DESTROYING="hlsDestroying",p.KEY_LOADING="hlsKeyLoading",p.KEY_LOADED="hlsKeyLoaded",p.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",p.BACK_BUFFER_REACHED="hlsBackBufferReached"})(R||(R={}))},"./src/hls.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"default",function(){return i});var R=s("./node_modules/url-toolkit/src/url-toolkit.js"),p=s.n(R),x=s("./src/loader/playlist-loader.ts"),I=s("./src/loader/key-loader.ts"),T=s("./src/controller/id3-track-controller.ts"),L=s("./src/controller/latency-controller.ts"),_=s("./src/controller/level-controller.ts"),y=s("./src/controller/fragment-tracker.ts"),D=s("./src/controller/stream-controller.ts"),A=s("./src/is-supported.ts"),S=s("./src/utils/logger.ts"),g=s("./src/config.ts"),E=s("./node_modules/eventemitter3/index.js"),a=s.n(E),e=s("./src/events.ts"),o=s("./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 n(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(A.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 E.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var r=this.config=Object(g.mergeConfig)(t.DefaultConfig,c);this.userConfig=c,Object(S.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),O=this.bufferController=new d(this),b=this.capLevelController=new l(this),M=new v(this),F=new x.default(this),w=new I.default(this),C=new T.default(this),B=this.levelController=new _.default(this),U=new y.FragmentTracker(this),j=this.streamController=new D.default(this,U);b.setStreamController(j),M.setStreamController(j);var N=[F,w,B,j];this.networkControllers=N;var K=[m,O,b,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,K),this.emeController=this.createController(r.emeController,null,K),this.cmcdController=this.createController(r.cmcdController,null,K),this.latencyController=this.createController(L.default,null,K),this.coreComponents=K}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){S.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(){S.logger.log("destroy"),this.trigger(e.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(r){return r.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(r){return r.destroy()}),this.coreComponents.length=0},u.attachMedia=function(r){S.logger.log("attachMedia"),this._media=r,this.trigger(e.Events.MEDIA_ATTACHING,{media:r})},u.detachMedia=function(){S.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});S.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),S.logger.log("startLoad("+r+")"),this.networkControllers.forEach(function(h){h.startLoad(r)})},u.stopLoad=function(){S.logger.log("stopLoad"),this.networkControllers.forEach(function(r){r.stopLoad()})},u.swapAudioCodec=function(){S.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},u.recoverMediaError=function(){S.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)},n(t,[{key:"levels",get:function(){var r=this.levelController.levels;return r||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(r){S.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){S.logger.log("set nextLevel:"+r),this.levelController.manualLevel=r,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(r){S.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){S.logger.log("set firstLevel:"+r),this.levelController.firstLevel=r}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(r){S.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&&(S.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(k,P,s){"use strict";s.r(P),s.d(P,"isSupported",function(){return x}),s.d(P,"changeTypeSupported",function(){return I});var R=s("./src/utils/mediasource-helper.ts");function p(){return self.SourceBuffer||self.WebKitSourceBuffer}function x(){var T=Object(R.getMediaSource)();if(!T)return!1;var L=p(),_=T&&typeof T.isTypeSupported=="function"&&T.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),y=!L||L.prototype&&typeof L.prototype.appendBuffer=="function"&&typeof L.prototype.remove=="function";return!!_&&!!y}function I(){var T,L=p();return typeof(L==null||(T=L.prototype)===null||T===void 0?void 0:T.changeType)=="function"}},"./src/loader/date-range.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"DateRangeAttribute",function(){return _}),s.d(P,"DateRange",function(){return y});var R=s("./src/polyfills/number.ts"),p=s("./src/utils/attr-list.ts"),x=s("./src/utils/logger.ts");function I(){return I=Object.assign?Object.assign.bind():function(D){for(var A=1;A<arguments.length;A++){var S=arguments[A];for(var g in S)Object.prototype.hasOwnProperty.call(S,g)&&(D[g]=S[g])}return D},I.apply(this,arguments)}function T(D,A){for(var S=0;S<A.length;S++){var g=A[S];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(D,g.key,g)}}function L(D,A,S){return A&&T(D.prototype,A),S&&T(D,S),Object.defineProperty(D,"prototype",{writable:!1}),D}var _;(function(D){D.ID="ID",D.CLASS="CLASS",D.START_DATE="START-DATE",D.DURATION="DURATION",D.END_DATE="END-DATE",D.END_ON_NEXT="END-ON-NEXT",D.PLANNED_DURATION="PLANNED-DURATION",D.SCTE35_OUT="SCTE35-OUT",D.SCTE35_IN="SCTE35-IN"})(_||(_={}));var y=function(){function D(A,S){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,S){var g=S.attr;for(var E in g)if(Object.prototype.hasOwnProperty.call(A,E)&&A[E]!==g[E]){x.logger.warn('DATERANGE tag attribute: "'+E+'" does not match for tags with ID: "'+A.ID+'"'),this._badValueForSameId=E;break}A=I(new p.AttrList({}),g,A)}if(this.attr=A,this._startDate=new Date(A[_.START_DATE]),_.END_DATE in this.attr){var a=new Date(this.attr[_.END_DATE]);Object(R.isFiniteNumber)(a.getTime())&&(this._endDate=a)}}return L(D,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var S=this.duration;return S!==null?new Date(this._startDate.getTime()+S*1e3):null}},{key:"duration",get:function(){if(_.DURATION in this.attr){var S=this.attr.decimalFloatingPoint(_.DURATION);if(Object(R.isFiniteNumber)(S))return S}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)}}]),D}()},"./src/loader/fragment-loader.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"default",function(){return S}),s.d(P,"LoadError",function(){return E});var R=s("./src/polyfills/number.ts"),p=s("./src/errors.ts");function x(a,e){a.prototype=Object.create(e.prototype),a.prototype.constructor=a,y(a,e)}function I(a){var e=typeof Map=="function"?new Map:void 0;return I=function(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,n)}function n(){return T(f,arguments,D(this).constructor)}return n.prototype=Object.create(f.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),y(n,f)},I(a)}function T(a,e,o){return L()?T=Reflect.construct.bind():T=function(n,i,t){var u=[null];u.push.apply(u,i);var c=Function.bind.apply(n,u),r=new c;return t&&y(r,t.prototype),r},T.apply(null,arguments)}function L(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function _(a){return Function.toString.call(a).indexOf("[native code]")!==-1}function y(a,e){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(f,n){return f.__proto__=n,f},y(a,e)}function D(a){return D=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},D(a)}var A=Math.pow(2,17),S=function(){function a(o){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=o}var e=a.prototype;return e.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},e.abort=function(){this.loader&&this.loader.abort()},e.load=function(f,n){var i=this,t=f.url;if(!t)return Promise.reject(new E({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:A};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 E({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 E({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 E({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:f,networkDetails:F}))},onProgress:function(b,M,F,w){n&&n({frag:f,part:null,payload:F,networkDetails:w})}})})},e.loadPart=function(f,n,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,n),m={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:A};n.stats=l.stats,l.load(v,m,{onSuccess:function(b,M,F,w){t.resetLoader(f,l),t.updateStatsFromPart(f,n);var C={frag:f,part:n,payload:b.data,networkDetails:w};i(C),h(C)},onError:function(b,M,F){t.resetLoader(f,l),d(new E({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:f,part:n,response:b,networkDetails:F}))},onAbort:function(b,M,F){f.stats.aborted=n.stats.aborted,t.resetLoader(f,l),d(new E({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:f,part:n,networkDetails:F}))},onTimeout:function(b,M,F){t.resetLoader(f,l),d(new E({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:f,part:n,networkDetails:F}))}})})},e.updateStatsFromPart=function(f,n){var i=f.stats,t=n.stats,u=t.total;if(i.loaded+=t.loaded,u){var c=Math.round(f.duration/n.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,n){f.loader=null,this.loader===n&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),n.destroy()},a}();function g(a,e){e===void 0&&(e=null);var o=e||a,f={frag:a,part:e,responseType:"arraybuffer",url:o.url,headers:{},rangeStart:0,rangeEnd:0},n=o.byteRangeStartOffset,i=o.byteRangeEndOffset;return Object(R.isFiniteNumber)(n)&&Object(R.isFiniteNumber)(i)&&(f.rangeStart=n,f.rangeEnd=i),f}var E=function(a){x(e,a);function e(o){for(var f,n=arguments.length,i=new Array(n>1?n-1:0),t=1;t<n;t++)i[t-1]=arguments[t];return f=a.call.apply(a,[this].concat(i))||this,f.data=void 0,f.data=o,f}return e}(I(Error))},"./src/loader/fragment.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"ElementaryStreamTypes",function(){return S}),s.d(P,"BaseSegment",function(){return g}),s.d(P,"Fragment",function(){return E}),s.d(P,"Part",function(){return a});var R=s("./src/polyfills/number.ts"),p=s("./node_modules/url-toolkit/src/url-toolkit.js"),x=s.n(p),I=s("./src/utils/logger.ts"),T=s("./src/loader/level-key.ts"),L=s("./src/loader/load-stats.ts");function _(e,o){e.prototype=Object.create(o.prototype),e.prototype.constructor=e,y(e,o)}function y(e,o){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},y(e,o)}function D(e,o){for(var f=0;f<o.length;f++){var n=o[f];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function A(e,o,f){return o&&D(e.prototype,o),f&&D(e,f),Object.defineProperty(e,"prototype",{writable:!1}),e}var S;(function(e){e.AUDIO="audio",e.VIDEO="video",e.AUDIOVIDEO="audiovideo"})(S||(S={}));var g=function(){function e(f){var n;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(n={},n[S.AUDIO]=null,n[S.VIDEO]=null,n[S.AUDIOVIDEO]=null,n),this.baseurl=f}var o=e.prototype;return o.setByteRange=function(n,i){var t=n.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},A(e,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(p.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(n){this._url=n}}]),e}(),E=function(e){_(o,e);function o(n,i){var t;return t=e.call(this,i)||this,t._decryptdata=null,t.rawProgramDateTime=null,t.programDateTime=null,t.tagList=[],t.duration=0,t.sn=0,t.levelkey=void 0,t.type=void 0,t.loader=null,t.level=-1,t.cc=0,t.startPTS=void 0,t.endPTS=void 0,t.appendedPTS=void 0,t.startDTS=void 0,t.endDTS=void 0,t.start=0,t.deltaPTS=void 0,t.maxStartPTS=void 0,t.minEndPTS=void 0,t.stats=new L.LoadStats,t.urlId=0,t.data=void 0,t.bitrateTest=!1,t.title=null,t.initSegment=null,t.type=n,t}var 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[S.AUDIO]=null,i[S.VIDEO]=null,i[S.AUDIOVIDEO]=null},A(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),a=function(e){_(o,e);function o(f,n,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 L.LoadStats,c.duration=f.decimalFloatingPoint("DURATION"),c.gap=f.bool("GAP"),c.independent=f.bool("INDEPENDENT"),c.relurl=f.enumeratedString("URI"),c.fragment=n,c.index=t;var r=f.enumeratedString("BYTERANGE");return r&&c.setByteRange(r,u),u&&(c.fragOffset=u.fragOffset+u.duration),c}return A(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 n=this.elementaryStreams;return!!(n.audio||n.video||n.audiovideo)}}]),o}(g)},"./src/loader/key-loader.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"default",function(){return I});var R=s("./src/events.ts"),p=s("./src/errors.ts"),x=s("./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 L=T.prototype;return L.startLoad=function(y){},L.stopLoad=function(){this.destroyInternalLoaders()},L.registerListeners=function(){this.hls.on(R.Events.KEY_LOADING,this.onKeyLoading,this)},L.unregisterListeners=function(){this.hls.off(R.Events.KEY_LOADING,this.onKeyLoading)},L.destroyInternalLoaders=function(){for(var y in this.loaders){var D=this.loaders[y];D&&D.destroy()}this.loaders={}},L.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},L.onKeyLoading=function(y,D){var A=D.frag,S=A.type,g=this.loaders[S];if(!A.decryptdata){x.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var E=A.decryptdata.uri;if(E!==this.decrypturl||this.decryptkey===null){var a=this.hls.config;if(g&&(x.logger.warn("abort previous key loader for type:"+S),g.abort()),!E){x.logger.warn("key uri is falsy");return}var e=a.loader,o=A.loader=this.loaders[S]=new e(a);this.decrypturl=E,this.decryptkey=null;var f={url:E,frag:A,responseType:"arraybuffer"},n={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:a.fragLoadingRetryDelay,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:0},i={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};o.load(f,n,i)}else this.decryptkey&&(A.decryptdata.key=this.decryptkey,this.hls.trigger(R.Events.KEY_LOADED,{frag:A}))},L.loadsuccess=function(y,D,A){var S=A.frag;if(!S.decryptdata){x.logger.error("after key load, decryptdata unset");return}this.decryptkey=S.decryptdata.key=new Uint8Array(y.data),S.loader=null,delete this.loaders[S.type],this.hls.trigger(R.Events.KEY_LOADED,{frag:S})},L.loaderror=function(y,D){var A=D.frag,S=A.loader;S&&S.abort(),delete this.loaders[A.type],this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:A,response:y})},L.loadtimeout=function(y,D){var A=D.frag,S=A.loader;S&&S.abort(),delete this.loaders[A.type],this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:A})},T}()},"./src/loader/level-details.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"LevelDetails",function(){return T});var R=s("./src/polyfills/number.ts");function p(L,_){for(var y=0;y<_.length;y++){var D=_[y];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(L,D.key,D)}}function x(L,_,y){return _&&p(L.prototype,_),y&&p(L,y),Object.defineProperty(L,"prototype",{writable:!1}),L}var I=10,T=function(){function L(y){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.needSidxRanges=!1,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.fragments=[],this.dateRanges={},this.url=y}var _=L.prototype;return _.reloaded=function(D){if(!D){this.advanced=!0,this.updated=!0;return}var A=this.lastPartSn-D.lastPartSn,S=this.lastPartIndex-D.lastPartIndex;this.updated=this.endSN!==D.endSN||!!S||!!A,this.advanced=this.endSN>D.endSN||A>0||A===0&&S>0,this.updated||this.advanced?this.misses=Math.floor(D.misses*.6):this.misses=D.misses+1,this.availabilityDelay=D.availabilityDelay},x(L,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(R.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||I}},{key:"drift",get:function(){var D=this.driftEndTime-this.driftStartTime;if(D>0){var A=this.driftEnd-this.driftStart;return A*1e3/D}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var D;return(D=this.partList)!==null&&D!==void 0&&D.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var D;return(D=this.fragments)!==null&&D!==void 0&&D.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var D;return(D=this.partList)!==null&&D!==void 0&&D.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var D;return(D=this.partList)!==null&&D!==void 0&&D.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),L}()},"./src/loader/level-key.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"LevelKey",function(){return T});var R=s("./node_modules/url-toolkit/src/url-toolkit.js"),p=s.n(R);function x(L,_){for(var y=0;y<_.length;y++){var D=_[y];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(L,D.key,D)}}function I(L,_,y){return _&&x(L.prototype,_),y&&x(L,y),Object.defineProperty(L,"prototype",{writable:!1}),L}var T=function(){L.fromURL=function(y,D){return new L(y,D)},L.fromURI=function(y){return new L(y)};function L(_,y){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,y?this._uri=Object(R.buildAbsoluteURL)(_,y,{alwaysNormalize:!0}):this._uri=_}return I(L,[{key:"uri",get:function(){return this._uri}}]),L}()},"./src/loader/load-stats.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"LoadStats",function(){return R});var R=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"default",function(){return f});var R=s("./src/polyfills/number.ts"),p=s("./node_modules/url-toolkit/src/url-toolkit.js"),x=s.n(p),I=s("./src/loader/date-range.ts"),T=s("./src/loader/fragment.ts"),L=s("./src/loader/level-details.ts"),_=s("./src/loader/level-key.ts"),y=s("./src/utils/attr-list.ts"),D=s("./src/utils/logger.ts"),A=s("./src/utils/codecs.ts"),S=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,g=/#EXT-X-MEDIA:(.*)/g,E=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),a=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),e=/\.(mp4|m4s|m4v|m4a)$/i;function 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={},O=!1;S.lastIndex=0;for(var b;(b=S.exec(d))!=null;)if(b[1]){var M=new y.AttrList(b[1]),F={attrs:M,bitrate:M.decimalInteger("AVERAGE-BANDWIDTH")||M.decimalInteger("BANDWIDTH"),name:M.NAME,url:r.resolve(b[2],l)},w=M.decimalResolution("RESOLUTION");w&&(F.width=w.width,F.height=w.height),n((M.CODECS||"").split(/[ ,]+/).filter(function(B){return B}),F),F.videoCodec&&F.videoCodec.indexOf("avc1")!==-1&&(F.videoCodec=r.convertAVC1ToAVCOTI(F.videoCodec)),v.push(F)}else if(b[3]){var C=new y.AttrList(b[3]);C["DATA-ID"]&&(O=!0,m[C["DATA-ID"]]=C)}return{levels:v,sessionData:O?m:null}},r.parseMasterPlaylistMedia=function(d,l,v,m){m===void 0&&(m=[]);var O,b=[],M=0;for(g.lastIndex=0;(O=g.exec(d))!==null;){var F=new y.AttrList(O[1]);if(F.TYPE===v){var w={attrs:F,bitrate:0,id:M++,groupId:F["GROUP-ID"],instreamId:F["INSTREAM-ID"],name:F.NAME||F.LANGUAGE||"",type:v,default:F.bool("DEFAULT"),autoselect:F.bool("AUTOSELECT"),forced:F.bool("FORCED"),lang:F.LANGUAGE,url:F.URI?r.resolve(F.URI,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,O){var b=new L.LevelDetails(l),M=b.fragments,F=null,w=0,C=0,B=0,U=0,j=null,N=new T.Fragment(m,l),K,H,V,Y=-1,Q=!1;for(E.lastIndex=0,b.m3u8=d;(K=E.exec(d))!==null;){Q&&(Q=!1,N=new T.Fragment(m,l),N.start=B,N.sn=w,N.cc=U,N.level=v,F&&(N.initSegment=F,N.rawProgramDateTime=F.rawProgramDateTime,F.rawProgramDateTime=null));var J=K[1];if(J){N.duration=parseFloat(J);var z=(" "+K[2]).slice(1);N.title=z||null,N.tagList.push(z?["INF",J,z]:["INF",J])}else if(K[3])Object(R.isFiniteNumber)(N.duration)&&(N.start=B,V&&(N.levelkey=V),N.sn=w,N.level=v,N.cc=U,N.urlId=O,M.push(N),N.relurl=(" "+K[3]).slice(1),u(N,j),j=N,B+=N.duration,w++,C=0,Q=!0);else if(K[4]){var q=(" "+K[4]).slice(1);j?N.setByteRange(q,j):N.setByteRange(q)}else if(K[5])N.rawProgramDateTime=(" "+K[5]).slice(1),N.tagList.push(["PROGRAM-DATE-TIME",N.rawProgramDateTime]),Y===-1&&(Y=M.length);else{if(K=K[0].match(a),!K){D.logger.warn("No matches on slow regex match for level playlist!");continue}for(H=1;H<K.length&&typeof K[H]=="undefined";H++);var re=(" "+K[H]).slice(1),X=(" "+K[H+1]).slice(1),le=K[H+2]?(" "+K[H+2]).slice(1):"";switch(re){case"PLAYLIST-TYPE":b.type=X.toUpperCase();break;case"MEDIA-SEQUENCE":w=b.startSN=parseInt(X);break;case"SKIP":{var ne=new y.AttrList(X),te=ne.decimalInteger("SKIPPED-SEGMENTS");if(Object(R.isFiniteNumber)(te)){b.skippedSegments=te;for(var ee=te;ee--;)M.unshift(null);w+=te}var $=ne.enumeratedString("RECENTLY-REMOVED-DATERANGES");$&&(b.recentlyRemovedDateranges=$.split(" "));break}case"TARGETDURATION":b.targetduration=parseFloat(X);break;case"VERSION":b.version=parseInt(X);break;case"EXTM3U":break;case"ENDLIST":b.live=!1;break;case"#":(X||le)&&N.tagList.push(le?[X,le]:[X]);break;case"DISCONTINUITY":U++,N.tagList.push(["DIS"]);break;case"GAP":N.tagList.push([re]);break;case"BITRATE":N.tagList.push([re,X]);break;case"DATERANGE":{var Z=new y.AttrList(X),ue=new I.DateRange(Z,b.dateRanges[Z.ID]);ue.isValid||b.skippedSegments?b.dateRanges[ue.id]=ue:D.logger.warn('Ignoring invalid DATERANGE tag: "'+X+'"'),N.tagList.push(["EXT-X-DATERANGE",X]);break}case"DISCONTINUITY-SEQUENCE":U=parseInt(X);break;case"KEY":{var he,se=new y.AttrList(X),pe=se.enumeratedString("METHOD"),ye=se.URI,Te=se.hexadecimalInteger("IV"),ae=se.enumeratedString("KEYFORMATVERSIONS"),fe=se.enumeratedString("KEYID"),ge=(he=se.enumeratedString("KEYFORMAT"))!=null?he:"identity",ve=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(ve.indexOf(ge)>-1){D.logger.warn("Keyformat "+ge+" is not supported from the manifest");continue}else if(ge!=="identity")continue;pe&&(V=_.LevelKey.fromURL(l,ye),ye&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(pe)>=0&&(V.method=pe,V.keyFormat=ge,fe&&(V.keyID=fe),ae&&(V.keyFormatVersions=ae),V.iv=Te));break}case"START":{var xe=new y.AttrList(X),_e=xe.decimalFloatingPoint("TIME-OFFSET");Object(R.isFiniteNumber)(_e)&&(b.startTimeOffset=_e);break}case"MAP":{var be=new y.AttrList(X);if(N.duration){var Se=new T.Fragment(m,l);c(Se,be,v,V),F=Se,N.initSegment=F,F.rawProgramDateTime&&!N.rawProgramDateTime&&(N.rawProgramDateTime=F.rawProgramDateTime)}else c(N,be,v,V),F=N,Q=!0;break}case"SERVER-CONTROL":{var Ee=new y.AttrList(X);b.canBlockReload=Ee.bool("CAN-BLOCK-RELOAD"),b.canSkipUntil=Ee.optionalFloat("CAN-SKIP-UNTIL",0),b.canSkipDateRanges=b.canSkipUntil>0&&Ee.bool("CAN-SKIP-DATERANGES"),b.partHoldBack=Ee.optionalFloat("PART-HOLD-BACK",0),b.holdBack=Ee.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var W=new y.AttrList(X);b.partTarget=W.decimalFloatingPoint("PART-TARGET");break}case"PART":{var G=b.partList;G||(G=b.partList=[]);var oe=C>0?G[G.length-1]:void 0,de=C++,ce=new T.Part(new y.AttrList(X),N,l,de,oe);G.push(ce),N.duration+=ce.duration;break}case"PRELOAD-HINT":{var De=new y.AttrList(X);b.preloadHint=De;break}case"RENDITION-REPORT":{var ie=new y.AttrList(X);b.renditionReports=b.renditionReports||[],b.renditionReports.push(ie);break}default:D.logger.warn("line parsed but not handled: "+K);break}}}j&&!j.relurl?(M.pop(),B-=j.duration,b.partList&&(b.fragmentHint=j)):b.partList&&(u(N,j),N.cc=U,b.fragmentHint=N);var Le=M.length,Ae=M[0],Oe=M[Le-1];if(B+=b.skippedSegments*b.targetduration,B>0&&Le&&Oe){b.averagetargetduration=B/Le;var Fe=Oe.sn;b.endSN=Fe!=="initSegment"?Fe:0,Ae&&(b.startCC=Ae.cc,Ae.initSegment||b.fragments.every(function(Me){return Me.relurl&&o(Me.relurl)})&&(D.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),N=new T.Fragment(m,l),N.relurl=Oe.relurl,N.level=v,N.sn="initSegment",Ae.initSegment=N,b.needSidxRanges=!0))}else b.endSN=0,b.startCC=0;return b.fragmentHint&&(B+=b.fragmentHint.duration),b.totalduration=B,b.endCC=U,Y>0&&t(M,Y),b},r}();function n(r,h){["video","audio","text"].forEach(function(d){var l=r.filter(function(m){return Object(A.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(k,P,s){"use strict";s.r(P);var R=s("./src/polyfills/number.ts"),p=s("./src/events.ts"),x=s("./src/errors.ts"),I=s("./src/utils/logger.ts"),T=s("./src/utils/mp4-tools.ts"),L=s("./src/loader/m3u8-parser.ts"),_=s("./src/types/loader.ts"),y=s("./src/utils/attr-list.ts");function D(g){var E=g.type;switch(E){case _.PlaylistContextType.AUDIO_TRACK:return _.PlaylistLevelType.AUDIO;case _.PlaylistContextType.SUBTITLE_TRACK:return _.PlaylistLevelType.SUBTITLE;default:return _.PlaylistLevelType.MAIN}}function A(g,E){var a=g.url;return(a===void 0||a.indexOf("data:")===0)&&(a=E.url),a}var S=function(){function g(a){this.hls=void 0,this.loaders=Object.create(null),this.hls=a,this.registerListeners()}var E=g.prototype;return E.startLoad=function(e){},E.stopLoad=function(){this.destroyInternalLoaders()},E.registerListeners=function(){var e=this.hls;e.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(p.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},E.unregisterListeners=function(){var e=this.hls;e.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(p.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(p.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},E.createInternalLoader=function(e){var o=this.hls.config,f=o.pLoader,n=o.loader,i=f||n,t=new i(o);return e.loader=t,this.loaders[e.type]=t,t},E.getInternalLoader=function(e){return this.loaders[e.type]},E.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},E.destroyInternalLoaders=function(){for(var e in this.loaders){var o=this.loaders[e];o&&o.destroy(),this.resetInternalLoader(e)}},E.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},E.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})},E.onLevelLoading=function(e,o){var f=o.id,n=o.level,i=o.url,t=o.deliveryDirectives;this.load({id:f,groupId:null,level:n,responseType:"text",type:_.PlaylistContextType.LEVEL,url:i,deliveryDirectives:t})},E.onAudioTrackLoading=function(e,o){var f=o.id,n=o.groupId,i=o.url,t=o.deliveryDirectives;this.load({id:f,groupId:n,level:null,responseType:"text",type:_.PlaylistContextType.AUDIO_TRACK,url:i,deliveryDirectives:t})},E.onSubtitleTrackLoading=function(e,o){var f=o.id,n=o.groupId,i=o.url,t=o.deliveryDirectives;this.load({id:f,groupId:n,level:null,responseType:"text",type:_.PlaylistContextType.SUBTITLE_TRACK,url:i,deliveryDirectives:t})},E.load=function(e){var o,f=this.hls.config,n=this.getInternalLoader(e);if(n){var i=n.context;if(i&&i.url===e.url){I.logger.trace("[playlist-loader]: playlist request ongoing");return}I.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),n.abort()}var t,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(n=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)};n.load(e,v,m)},E.loadsuccess=function(e,o,f,n){if(n===void 0&&(n=null),f.isSidxRequest){this.handleSidxRequest(e,f),this.handlePlaylistLoaded(e,o,f,n);return}this.resetInternalLoader(f.type);var i=e.data;if(i.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(e,f,"no EXTM3U delimiter",n);return}o.parsing.start=performance.now(),i.indexOf("#EXTINF:")>0||i.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,o,f,n):this.handleMasterPlaylist(e,o,f,n)},E.loaderror=function(e,o,f){f===void 0&&(f=null),this.handleNetworkError(o,f,!1,e)},E.loadtimeout=function(e,o,f){f===void 0&&(f=null),this.handleNetworkError(o,f,!0)},E.handleMasterPlaylist=function(e,o,f,n){var i=this.hls,t=e.data,u=A(e,f),c=L.default.parseMasterPlaylist(t,u),r=c.levels,h=c.sessionData;if(!r.length){this.handleManifestParsingError(e,f,"no level found in manifest",n);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=L.default.parseMasterPlaylistMedia(t,u,"AUDIO",d),m=L.default.parseMasterPlaylistMedia(t,u,"SUBTITLES",l),O=L.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 y.AttrList({}),bitrate:0,url:""}))}i.trigger(p.Events.MANIFEST_LOADED,{levels:r,audioTracks:v,subtitles:m,captions:O,url:u,stats:o,networkDetails:n,sessionData:h})},E.handleTrackOrLevelPlaylist=function(e,o,f,n){var i=this.hls,t=f.id,u=f.level,c=f.type,r=A(e,f),h=Object(R.isFiniteNumber)(t)?t:0,d=Object(R.isFiniteNumber)(u)?u:h,l=D(f),v=L.default.parseLevelPlaylist(e.data,r,d,l,h);if(!v.fragments.length){i.trigger(p.Events.ERROR,{type:x.ErrorTypes.NETWORK_ERROR,details:x.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 y.AttrList({}),bitrate:0,details:v,name:"",url:r};i.trigger(p.Events.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:r,stats:o,networkDetails:n,sessionData:null})}if(o.parsing.end=performance.now(),v.needSidxRanges){var O,b=(O=v.fragments[0].initSegment)===null||O===void 0?void 0:O.url;this.load({url:b,isSidxRequest:!0,type: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,n)},E.handleSidxRequest=function(e,o){var f=new Uint8Array(e.data),n=Object(T.findBox)(f,["sidx"])[0];if(!!n){var i=Object(T.parseSegmentIndex)(n);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")}})}}},E.handleManifestParsingError=function(e,o,f,n){this.hls.trigger(p.Events.ERROR,{type:x.ErrorTypes.NETWORK_ERROR,details:x.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:o.type===_.PlaylistContextType.MANIFEST,url:e.url,reason:f,response:e,context:o,networkDetails:n})},E.handleNetworkError=function(e,o,f,n){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=x.ErrorDetails.UNKNOWN,t=!1,u=this.getInternalLoader(e);switch(e.type){case _.PlaylistContextType.MANIFEST:i=f?x.ErrorDetails.MANIFEST_LOAD_TIMEOUT:x.ErrorDetails.MANIFEST_LOAD_ERROR,t=!0;break;case _.PlaylistContextType.LEVEL:i=f?x.ErrorDetails.LEVEL_LOAD_TIMEOUT:x.ErrorDetails.LEVEL_LOAD_ERROR,t=!1;break;case _.PlaylistContextType.AUDIO_TRACK:i=f?x.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:x.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,t=!1;break;case _.PlaylistContextType.SUBTITLE_TRACK:i=f?x.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:x.ErrorDetails.SUBTITLE_LOAD_ERROR,t=!1;break}u&&this.resetInternalLoader(e.type);var c={type:x.ErrorTypes.NETWORK_ERROR,details:i,fatal:t,url:e.url,loader:u,context:e,networkDetails:o};n&&(c.response=n),this.hls.trigger(p.Events.ERROR,c)},E.handlePlaylistLoaded=function(e,o,f,n){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",n);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:n,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:n,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:n,deliveryDirectives:d});break}},g}();P.default=S},"./src/polyfills/number.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"isFiniteNumber",function(){return R}),s.d(P,"MAX_SAFE_INTEGER",function(){return p});var R=Number.isFinite||function(x){return typeof x=="number"&&isFinite(x)},p=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(k,P,s){"use strict";s.r(P);var R=function(){function p(){}return p.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}},p}();P.default=R},"./src/remux/mp4-generator.ts":function(k,P,s){"use strict";s.r(P);var R=Math.pow(2,32)-1,p=function(){function x(){}return x.init=function(){x.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var T;for(T in x.types)x.types.hasOwnProperty(T)&&(x.types[T]=[T.charCodeAt(0),T.charCodeAt(1),T.charCodeAt(2),T.charCodeAt(3)]);var L=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),_=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);x.HDLR_TYPES={video:L,audio:_};var y=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),D=new Uint8Array([0,0,0,0,0,0,0,0]);x.STTS=x.STSC=x.STCO=D,x.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),x.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),x.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),x.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var A=new Uint8Array([105,115,111,109]),S=new Uint8Array([97,118,99,49]),g=new Uint8Array([0,0,0,1]);x.FTYP=x.box(x.types.ftyp,A,g,A,S),x.DINF=x.box(x.types.dinf,x.box(x.types.dref,y))},x.box=function(T){for(var L=8,_=arguments.length,y=new Array(_>1?_-1:0),D=1;D<_;D++)y[D-1]=arguments[D];for(var A=y.length,S=A;A--;)L+=y[A].byteLength;var g=new Uint8Array(L);for(g[0]=L>>24&255,g[1]=L>>16&255,g[2]=L>>8&255,g[3]=L&255,g.set(T,4),A=0,L=8;A<S;A++)g.set(y[A],L),L+=y[A].byteLength;return g},x.hdlr=function(T){return x.box(x.types.hdlr,x.HDLR_TYPES[T])},x.mdat=function(T){return x.box(x.types.mdat,T)},x.mdhd=function(T,L){L*=T;var _=Math.floor(L/(R+1)),y=Math.floor(L%(R+1));return x.box(x.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,T>>24&255,T>>16&255,T>>8&255,T&255,_>>24,_>>16&255,_>>8&255,_&255,y>>24,y>>16&255,y>>8&255,y&255,85,196,0,0]))},x.mdia=function(T){return x.box(x.types.mdia,x.mdhd(T.timescale,T.duration),x.hdlr(T.type),x.minf(T))},x.mfhd=function(T){return x.box(x.types.mfhd,new Uint8Array([0,0,0,0,T>>24,T>>16&255,T>>8&255,T&255]))},x.minf=function(T){return T.type==="audio"?x.box(x.types.minf,x.box(x.types.smhd,x.SMHD),x.DINF,x.stbl(T)):x.box(x.types.minf,x.box(x.types.vmhd,x.VMHD),x.DINF,x.stbl(T))},x.moof=function(T,L,_){return x.box(x.types.moof,x.mfhd(T),x.traf(_,L))},x.moov=function(T){for(var L=T.length,_=[];L--;)_[L]=x.trak(T[L]);return x.box.apply(null,[x.types.moov,x.mvhd(T[0].timescale,T[0].duration)].concat(_).concat(x.mvex(T)))},x.mvex=function(T){for(var L=T.length,_=[];L--;)_[L]=x.trex(T[L]);return x.box.apply(null,[x.types.mvex].concat(_))},x.mvhd=function(T,L){L*=T;var _=Math.floor(L/(R+1)),y=Math.floor(L%(R+1)),D=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,T>>24&255,T>>16&255,T>>8&255,T&255,_>>24,_>>16&255,_>>8&255,_&255,y>>24,y>>16&255,y>>8&255,y&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return x.box(x.types.mvhd,D)},x.sdtp=function(T){var L=T.samples||[],_=new Uint8Array(4+L.length),y,D;for(y=0;y<L.length;y++)D=L[y].flags,_[y+4]=D.dependsOn<<4|D.isDependedOn<<2|D.hasRedundancy;return x.box(x.types.sdtp,_)},x.stbl=function(T){return x.box(x.types.stbl,x.stsd(T),x.box(x.types.stts,x.STTS),x.box(x.types.stsc,x.STSC),x.box(x.types.stsz,x.STSZ),x.box(x.types.stco,x.STCO))},x.avc1=function(T){var L=[],_=[],y,D,A;for(y=0;y<T.sps.length;y++)D=T.sps[y],A=D.byteLength,L.push(A>>>8&255),L.push(A&255),L=L.concat(Array.prototype.slice.call(D));for(y=0;y<T.pps.length;y++)D=T.pps[y],A=D.byteLength,_.push(A>>>8&255),_.push(A&255),_=_.concat(Array.prototype.slice.call(D));var S=x.box(x.types.avcC,new Uint8Array([1,L[3],L[4],L[5],255,224|T.sps.length].concat(L).concat([T.pps.length]).concat(_))),g=T.width,E=T.height,a=T.pixelRatio[0],e=T.pixelRatio[1];return x.box(x.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,g>>8&255,g&255,E>>8&255,E&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),S,x.box(x.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),x.box(x.types.pasp,new Uint8Array([a>>24,a>>16&255,a>>8&255,a&255,e>>24,e>>16&255,e>>8&255,e&255])))},x.esds=function(T){var L=T.config.length;return new Uint8Array([0,0,0,0,3,23+L,0,1,0,4,15+L,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([L]).concat(T.config).concat([6,1,2]))},x.mp4a=function(T){var L=T.samplerate;return x.box(x.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,T.channelCount,0,16,0,0,0,0,L>>8&255,L&255,0,0]),x.box(x.types.esds,x.esds(T)))},x.mp3=function(T){var L=T.samplerate;return x.box(x.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,T.channelCount,0,16,0,0,0,0,L>>8&255,L&255,0,0]))},x.stsd=function(T){return T.type==="audio"?T.segmentCodec==="mp3"&&T.codec==="mp3"?x.box(x.types.stsd,x.STSD,x.mp3(T)):x.box(x.types.stsd,x.STSD,x.mp4a(T)):x.box(x.types.stsd,x.STSD,x.avc1(T))},x.tkhd=function(T){var L=T.id,_=T.duration*T.timescale,y=T.width,D=T.height,A=Math.floor(_/(R+1)),S=Math.floor(_%(R+1));return x.box(x.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,L>>24&255,L>>16&255,L>>8&255,L&255,0,0,0,0,A>>24,A>>16&255,A>>8&255,A&255,S>>24,S>>16&255,S>>8&255,S&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,y>>8&255,y&255,0,0,D>>8&255,D&255,0,0]))},x.traf=function(T,L){var _=x.sdtp(T),y=T.id,D=Math.floor(L/(R+1)),A=Math.floor(L%(R+1));return x.box(x.types.traf,x.box(x.types.tfhd,new Uint8Array([0,0,0,0,y>>24,y>>16&255,y>>8&255,y&255])),x.box(x.types.tfdt,new Uint8Array([1,0,0,0,D>>24,D>>16&255,D>>8&255,D&255,A>>24,A>>16&255,A>>8&255,A&255])),x.trun(T,_.length+16+20+8+16+8+8),_)},x.trak=function(T){return T.duration=T.duration||4294967295,x.box(x.types.trak,x.tkhd(T),x.mdia(T))},x.trex=function(T){var L=T.id;return x.box(x.types.trex,new Uint8Array([0,0,0,0,L>>24,L>>16&255,L>>8&255,L&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},x.trun=function(T,L){var _=T.samples||[],y=_.length,D=12+16*y,A=new Uint8Array(D),S,g,E,a,e,o;for(L+=8+D,A.set([T.type==="video"?1:0,0,15,1,y>>>24&255,y>>>16&255,y>>>8&255,y&255,L>>>24&255,L>>>16&255,L>>>8&255,L&255],0),S=0;S<y;S++)g=_[S],E=g.duration,a=g.size,e=g.flags,o=g.cts,A.set([E>>>24&255,E>>>16&255,E>>>8&255,E&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255,e.isLeading<<2|e.dependsOn,e.isDependedOn<<6|e.hasRedundancy<<4|e.paddingValue<<1|e.isNonSync,e.degradPrio&240<<8,e.degradPrio&15,o>>>24&255,o>>>16&255,o>>>8&255,o&255],12+16*S);return x.box(x.types.trun,A)},x.initSegment=function(T){x.types||x.init();var L=x.moov(T),_=new Uint8Array(x.FTYP.byteLength+L.byteLength);return _.set(x.FTYP),_.set(L,x.FTYP.byteLength),_},x}();p.types=void 0,p.HDLR_TYPES=void 0,p.STTS=void 0,p.STSC=void 0,p.STCO=void 0,p.STSZ=void 0,p.VMHD=void 0,p.SMHD=void 0,p.STSD=void 0,p.FTYP=void 0,p.DINF=void 0,P.default=p},"./src/remux/mp4-remuxer.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"default",function(){return e}),s.d(P,"normalizePts",function(){return o}),s.d(P,"flushTextTrackMetadataCueSamples",function(){return n}),s.d(P,"flushTextTrackUserdataCueSamples",function(){return i});var R=s("./src/polyfills/number.ts"),p=s("./src/remux/aac-helper.ts"),x=s("./src/remux/mp4-generator.ts"),I=s("./src/events.ts"),T=s("./src/errors.ts"),L=s("./src/utils/logger.ts"),_=s("./src/types/loader.ts"),y=s("./src/utils/timescale-conversion.ts");function D(){return D=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},D.apply(this,arguments)}var A=10*1e3,S=1024,g=1152,E=null,a=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,E===null){var m=navigator.userAgent||"",O=m.match(/Chrome\/(\d+)/i);E=O?parseInt(O[1]):0}if(a===null){var b=navigator.userAgent.match(/Safari\/(\d+)/i);a=b?parseInt(b[1]):0}}var r=c.prototype;return r.destroy=function(){},r.resetTimeStamp=function(d){L.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=d},r.resetNextTimestamp=function(){L.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},r.resetInitSegment=function(){L.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},r.getVideoStartPts=function(d){var l=!1,v=d.reduce(function(m,O){var b=O.pts-m;return b<-4294967296?(l=!0,o(m,O.pts)):b>0?m:O.pts},d[0].pts);return l&&L.logger.debug("PTS rollover detected"),v},r.remux=function(d,l,v,m,O,b,M,F){var w,C,B,U,j,N,K=O,H=O,V=d.pid>-1,Y=l.pid>-1,Q=l.samples.length,J=d.samples.length>0,z=M&&Q>0||Q>1,q=(!V||J)&&(!Y||z)||this.ISGenerated||M;if(q){this.ISGenerated||(B=this.generateIS(d,l,O));var re=this.isVideoContiguous,X=-1,le;if(z&&(X=f(l.samples),!re&&this.config.forceKeyFrameOnDiscontinuity))if(N=!0,X>0){L.logger.warn("[mp4-remuxer]: Dropped "+X+" out of "+Q+" video samples due to a missing keyframe");var ne=this.getVideoStartPts(l.samples);l.samples=l.samples.slice(X),l.dropped+=X,H+=(l.samples[0].pts-ne)/l.inputTimeScale,le=H}else X===-1&&(L.logger.warn("[mp4-remuxer]: No keyframe found out of "+Q+" video samples"),N=!1);if(this.ISGenerated){if(J&&z){var te=this.getVideoStartPts(l.samples),ee=o(d.samples[0].pts,te)-te,$=ee/l.inputTimeScale;K+=Math.max(0,$),H+=Math.max(0,-$)}if(J){if(d.samplerate||(L.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),B=this.generateIS(d,l,O)),C=this.remuxAudio(d,K,this.isAudioContiguous,b,Y||z||F===_.PlaylistLevelType.AUDIO?H:void 0),z){var Z=C?C.endPTS-C.startPTS:0;l.inputTimeScale||(L.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),B=this.generateIS(d,l,O)),w=this.remuxVideo(l,H,re,Z)}}else z&&(w=this.remuxVideo(l,H,re,0));w&&(w.firstKeyFrame=X,w.independent=X!==-1,w.firstKeyFramePTS=le)}}return this.ISGenerated&&(v.samples.length&&(j=n(v,O,this._initPTS,this._initDTS)),m.samples.length&&(U=i(m,O,this._initPTS))),{audio:C,video:w,initSegment:B,independent:N,text:U,id3:j}},r.generateIS=function(d,l,v){var m=d.samples,O=l.samples,b=this.typeSupported,M={},F=!Object(R.isFiniteNumber)(this._initPTS),w="audio/mp4",C,B,U;if(F&&(C=B=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):x.default.initSegment([d]),metadata:{channelCount:d.channelCount}},F&&(U=d.inputTimeScale,C=B=m[0].pts-Math.round(U*v))}if(l.sps&&l.pps&&O.length&&(l.timescale=l.inputTimeScale,M.video={id:"main",container:"video/mp4",codec:l.codec,initSegment:x.default.initSegment([l]),metadata:{width:l.width,height:l.height}},F)){U=l.inputTimeScale;var j=this.getVideoStartPts(O),N=Math.round(U*v);B=Math.min(B,o(O[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=B),{tracks:M,initPTS:C,timescale:U}},r.remuxVideo=function(d,l,v,m){var O=d.inputTimeScale,b=d.samples,M=[],F=b.length,w=this._initPTS,C=this.nextAvcDts,B=8,U=this.videoSampleDuration,j,N,K=Number.POSITIVE_INFINITY,H=Number.NEGATIVE_INFINITY,V=!1;if(!v||C===null){var Y=l*O,Q=b[0].pts-o(b[0].dts,b[0].pts);C=Y-Q}for(var J=0;J<F;J++){var z=b[J];z.pts=o(z.pts-w,C),z.dts=o(z.dts-w,C),z.dts<b[J>0?J-1:J].dts&&(V=!0)}V&&b.sort(function(Be,$e){var Ze=Be.dts-$e.dts,ft=Be.pts-$e.pts;return Ze||ft}),j=b[0].dts,N=b[b.length-1].dts;var q=N-j,re=q?Math.round(q/(F-1)):U||d.inputTimeScale/30;if(v){var X=j-C,le=X>re,ne=X<-1;if(le||ne){le?L.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(X,!0)+" ms ("+X+"dts) hole between fragments detected, filling it"):L.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(-X,!0)+" ms ("+X+"dts) overlapping between fragments detected"),j=C;var te=b[0].pts-X;b[0].dts=j,b[0].pts=te,L.logger.log("Video: First PTS/DTS adjusted: "+Object(y.toMsFromMpegTsClock)(te,!0)+"/"+Object(y.toMsFromMpegTsClock)(j,!0)+", delta: "+Object(y.toMsFromMpegTsClock)(X,!0)+" ms")}}j=Math.max(0,j);for(var ee=0,$=0,Z=0;Z<F;Z++){for(var ue=b[Z],he=ue.units,se=he.length,pe=0,ye=0;ye<se;ye++)pe+=he[ye].data.length;$+=pe,ee+=se,ue.length=pe,ue.dts=Math.max(ue.dts,j),K=Math.min(ue.pts,K),H=Math.max(ue.pts,H)}N=b[F-1].dts;var Te=$+4*ee+8,ae;try{ae=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 fe=new DataView(ae.buffer);fe.setUint32(0,Te),ae.set(x.default.types.mdat,4);for(var ge=!1,ve=Number.POSITIVE_INFINITY,xe=Number.POSITIVE_INFINITY,_e=Number.NEGATIVE_INFINITY,be=Number.NEGATIVE_INFINITY,Se=0;Se<F;Se++){for(var Ee=b[Se],W=Ee.units,G=0,oe=0,de=W.length;oe<de;oe++){var ce=W[oe],De=ce.data,ie=ce.data.byteLength;fe.setUint32(B,ie),B+=4,ae.set(De,B),B+=ie,G+=4+ie}var Le=void 0;if(Se<F-1)U=b[Se+1].dts-Ee.dts,Le=b[Se+1].pts-Ee.pts;else{var Ae=this.config,Oe=Se>0?Ee.dts-b[Se-1].dts:re;if(Le=Se>0?Ee.pts-b[Se-1].pts:re,Ae.stretchShortVideoTrack&&this.nextAudioPts!==null){var Fe=Math.floor(Ae.maxBufferHole*O),Me=(m?K+m*O:this.nextAudioPts)-Ee.pts;Me>Fe?(U=Me-Oe,U<0?U=Oe:ge=!0,L.logger.log("[mp4-remuxer]: It is approximately "+Me/90+" ms to the next segment; using duration "+U/90+" ms for the last video frame.")):U=Oe}else U=Oe}var Ce=Math.round(Ee.pts-Ee.dts);ve=Math.min(ve,U),_e=Math.max(_e,U),xe=Math.min(xe,Le),be=Math.max(be,Le),M.push(new t(Ee.key,U,G,Ce))}if(M.length){if(E){if(E<70){var Xe=M[0].flags;Xe.dependsOn=2,Xe.isNonSync=0}}else if(a&&be-xe<_e-ve&&re/_e<.025&&M[0].cts===0){L.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var je=j,Re=0,we=M.length;Re<we;Re++){var Ke=je+M[Re].duration,We=je+M[Re].cts;if(Re<we-1){var Qe=Ke+M[Re+1].cts;M[Re].duration=Qe-We}else M[Re].duration=Re?M[Re-1].duration:re;M[Re].cts=0,je=Ke}}}console.assert(U!==null,"mp4SampleDuration must be computed"),U=ge||!U?re:U,this.nextAvcDts=C=N+U,this.videoSampleDuration=U,this.isVideoContiguous=!0;var Je=x.default.moof(d.sequenceNumber++,j,D({},d,{samples:M})),lt="video",ut={data1:Je,data2:ae,startPTS:K/O,endPTS:(H+U)/O,startDTS:j/O,endDTS:C/O,type:lt,hasAudio:!1,hasVideo:!0,nb:M.length,dropped:d.dropped};return d.samples=[],d.dropped=0,console.assert(ae.length,"MDAT length must not be zero"),ut},r.remuxAudio=function(d,l,v,m,O){var b=d.inputTimeScale,M=d.samplerate?d.samplerate:b,F=b/M,w=d.segmentCodec==="aac"?S:g,C=w*F,B=this._initPTS,U=d.segmentCodec==="mp3"&&this.typeSupported.mpeg,j=[],N=O!==void 0,K=d.samples,H=U?0:8,V=this.nextAudioPts||-1,Y=l*b;if(this.isAudioContiguous=v=v||K.length&&V>0&&(m&&Math.abs(Y-V)<9e3||Math.abs(o(K[0].pts-B,Y)-V)<20*C),K.forEach(function(ce){ce.pts=o(ce.pts-B,Y)}),!v||V<0){if(K=K.filter(function(ce){return ce.pts>=0}),!K.length)return;O===0?V=0:m&&!N?V=Math.max(0,Y):V=K[0].pts}if(d.segmentCodec==="aac")for(var Q=this.config.maxAudioFramesDrift,J=0,z=V;J<K.length;J++){var q=K[J],re=q.pts,X=re-z,le=Math.abs(1e3*X/b);if(X<=-Q*C&&N)J===0&&(L.logger.warn("Audio frame @ "+(re/b).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*X/b)+" ms."),this.nextAudioPts=V=z=re);else if(X>=Q*C&&le<A&&N){var ne=Math.round(X/C);z=re-ne*C,z<0&&(ne--,z+=C),J===0&&(this.nextAudioPts=V=z),L.logger.warn("[mp4-remuxer]: Injecting "+ne+" audio frame @ "+(z/b).toFixed(3)+"s due to "+Math.round(1e3*X/b)+" ms gap.");for(var te=0;te<ne;te++){var ee=Math.max(z,0),$=p.default.getSilentFrame(d.manifestCodec||d.codec,d.channelCount);$||(L.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),$=q.unit.subarray()),K.splice(J,0,{unit:$,pts:ee}),z+=C,J++}}q.pts=z,z+=C}for(var Z=null,ue=null,he,se=0,pe=K.length;pe--;)se+=K[pe].unit.byteLength;for(var ye=0,Te=K.length;ye<Te;ye++){var ae=K[ye],fe=ae.unit,ge=ae.pts;if(ue!==null){var ve=j[ye-1];ve.duration=Math.round((ge-ue)/F)}else if(v&&d.segmentCodec==="aac"&&(ge=V),Z=ge,se>0){se+=H;try{he=new Uint8Array(se)}catch{this.observer.emit(I.Events.ERROR,I.Events.ERROR,{type:T.ErrorTypes.MUX_ERROR,details:T.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:se,reason:"fail allocating audio mdat "+se});return}if(!U){var xe=new DataView(he.buffer);xe.setUint32(0,se),he.set(x.default.types.mdat,4)}}else return;he.set(fe,H);var _e=fe.byteLength;H+=_e,j.push(new t(!0,w,_e,0)),ue=ge}var be=j.length;if(!!be){var Se=j[j.length-1];this.nextAudioPts=V=ue+F*Se.duration;var Ee=U?new Uint8Array(0):x.default.moof(d.sequenceNumber++,Z/F,D({},d,{samples:j}));d.samples=[];var W=Z/b,G=V/b,oe="audio",de={data1:Ee,data2:he,startPTS:W,endPTS:G,startDTS:W,endDTS:G,type:oe,hasAudio:!0,hasVideo:!1,nb:be};return this.isAudioContiguous=!0,console.assert(he.length,"MDAT length must not be zero"),de}},r.remuxEmptyAudio=function(d,l,v,m){var O=d.inputTimeScale,b=d.samplerate?d.samplerate:O,M=O/b,F=this.nextAudioPts,w=(F!==null?F:m.startDTS*O)+this._initDTS,C=m.endDTS*O+this._initDTS,B=M*S,U=Math.ceil((C-w)/B),j=p.default.getSilentFrame(d.manifestCodec||d.codec,d.channelCount);if(L.logger.warn("[mp4-remuxer]: remux empty Audio"),!j){L.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var N=[],K=0;K<U;K++){var H=w+K*B;N.push({unit:j,pts:H,dts:H})}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 n(c,r,h,d){var l=c.samples.length;if(!!l){for(var v=c.inputTimeScale,m=0;m<l;m++){var O=c.samples[m];O.pts=o(O.pts-h,r*v)/v,O.dts=o(O.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 O=c.samples;return c.samples=[],{samples:O}}}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(k,P,s){"use strict";s.r(P);var R=s("./src/polyfills/number.ts"),p=s("./src/remux/mp4-remuxer.ts"),x=s("./src/utils/mp4-tools.ts"),I=s("./src/loader/fragment.ts"),T=s("./src/utils/logger.ts"),L=function(){function y(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndTime=null}var D=y.prototype;return D.destroy=function(){},D.resetTimeStamp=function(S){this.initPTS=S,this.lastEndTime=null},D.resetNextTimestamp=function(){this.lastEndTime=null},D.resetInitSegment=function(S,g,E){this.audioCodec=g,this.videoCodec=E,this.generateInitSegment(S),this.emitInitSegment=!0},D.generateInitSegment=function(S){var g=this.audioCodec,E=this.videoCodec;if(!S||!S.byteLength){this.initTracks=void 0,this.initData=void 0;return}var a=this.initData=Object(x.parseInitSegment)(S);g||(g=_(a.audio,I.ElementaryStreamTypes.AUDIO)),E||(E=_(a.video,I.ElementaryStreamTypes.VIDEO));var e={};a.audio&&a.video?e.audiovideo={container:"video/mp4",codec:g+","+E,initSegment:S,id:"main"}:a.audio?e.audio={container:"audio/mp4",codec:g,initSegment:S,id:"audio"}:a.video?e.video={container:"video/mp4",codec:E,initSegment:S,id:"main"}:T.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=e},D.remux=function(S,g,E,a,e){var o,f=this.initPTS,n=this.lastEndTime,i={audio:void 0,video:void 0,text:a,id3:E,initSegment:void 0};Object(R.isFiniteNumber)(n)||(n=this.lastEndTime=e||0);var t=g.samples;if(!t||!t.length)return i;var 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(x.getStartDTS)(c,t);Object(R.isFiniteNumber)(f)||(this.initPTS=u.initPTS=f=r-e);var h=Object(x.getDuration)(t,c),d=S?r-f:n,l=d+h;Object(x.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,m=!!c.video,O="";v&&(O+="audio"),m&&(O+="video");var b={data1:t,startPTS:d,startDTS:d,endPTS:l,endDTS:l,type:O,hasAudio:v,hasVideo:m,nb:1,dropped:0};i.audio=b.type==="audio"?b:void 0,i.video=b.type!=="audio"?b:void 0,i.initSegment=u;var M=(o=this.initPTS)!=null?o:0;return i.id3=Object(p.flushTextTrackMetadataCueSamples)(E,e,M,M),a.samples.length&&(i.text=Object(p.flushTextTrackUserdataCueSamples)(a,e,M)),i},y}();function _(y,D){var A=y==null?void 0:y.codec;return A&&A.length>4?A:A==="hvc1"||A==="hev1"?"hvc1.1.c.L120.90":A==="av01"?"av01.0.04M.08":A==="avc1"||D===I.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}P.default=L},"./src/task-loop.ts":function(k,P,s){"use strict";s.r(P),s.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 x=p.prototype;return x.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},x.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},x.onHandlerDestroyed=function(){},x.hasInterval=function(){return!!this._tickInterval},x.hasNextTick=function(){return!!this._tickTimer},x.setInterval=function(T){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,T),!0)},x.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},x.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},x.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},x.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},x.doTick=function(){},p}()},"./src/types/cmcd.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"CMCDVersion",function(){return R}),s.d(P,"CMCDObjectType",function(){return p}),s.d(P,"CMCDStreamingFormat",function(){return x}),s.d(P,"CMCDStreamType",function(){return I});var R=1,p;(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"})(p||(p={}));var x;(function(T){T.DASH="d",T.HLS="h",T.SMOOTH="s",T.OTHER="o"})(x||(x={}));var I;(function(T){T.VOD="v",T.LIVE="l"})(I||(I={}))},"./src/types/demuxer.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"MetadataSchema",function(){return R});var R;(function(p){p.audioId3="org.id3",p.dateRange="com.apple.quicktime.HLS",p.emsg="https://aomedia.org/emsg/ID3"})(R||(R={}))},"./src/types/level.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"HlsSkip",function(){return x}),s.d(P,"getSkipValue",function(){return I}),s.d(P,"HlsUrlParameters",function(){return T}),s.d(P,"Level",function(){return L});function R(_,y){for(var D=0;D<y.length;D++){var A=y[D];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(_,A.key,A)}}function p(_,y,D){return y&&R(_.prototype,y),D&&R(_,D),Object.defineProperty(_,"prototype",{writable:!1}),_}var x;(function(_){_.No="",_.Yes="YES",_.v2="v2"})(x||(x={}));function I(_,y){var D=_.canSkipUntil,A=_.canSkipDateRanges,S=_.endSN,g=y!==void 0?y-S:0;return D&&g<D?A?x.v2:x.Yes:x.No}var T=function(){function _(D,A,S){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=D,this.part=A,this.skip=S}var y=_.prototype;return y.addDirectives=function(A){var S=new self.URL(A);return this.msn!==void 0&&S.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&S.searchParams.set("_HLS_part",this.part.toString()),this.skip&&S.searchParams.set("_HLS_skip",this.skip),S.toString()},_}(),L=function(){function _(y){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[y.url],this.attrs=y.attrs,this.bitrate=y.bitrate,y.details&&(this.details=y.details),this.id=y.id||0,this.name=y.name,this.width=y.width||0,this.height=y.height||0,this.audioCodec=y.audioCodec,this.videoCodec=y.videoCodec,this.unknownCodecs=y.unknownCodecs,this.codecSet=[y.videoCodec,y.audioCodec].filter(function(D){return D}).join(",").replace(/\.[^.,]+/g,"")}return p(_,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(D){var A=D%this.url.length;this._urlId!==A&&(this.details=void 0,this._urlId=A)}}]),_}()},"./src/types/loader.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"PlaylistContextType",function(){return R}),s.d(P,"PlaylistLevelType",function(){return p});var R;(function(x){x.MANIFEST="manifest",x.LEVEL="level",x.AUDIO_TRACK="audioTrack",x.SUBTITLE_TRACK="subtitleTrack"})(R||(R={}));var p;(function(x){x.MAIN="main",x.AUDIO="audio",x.SUBTITLE="subtitle"})(p||(p={}))},"./src/types/transmuxer.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"ChunkMetadata",function(){return R});var R=function(I,T,L,_,y,D){_===void 0&&(_=0),y===void 0&&(y=-1),D===void 0&&(D=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=p(),this.buffering={audio:p(),video:p(),audiovideo:p()},this.level=I,this.sn=T,this.id=L,this.size=_,this.part=y,this.partial=D};function p(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"AttrList",function(){return x});var R=/^(\d+)x(\d+)$/,p=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,x=function(){function I(L){typeof L=="string"&&(L=I.parseAttrList(L));for(var _ in L)L.hasOwnProperty(_)&&(this[_]=L[_])}var T=I.prototype;return T.decimalInteger=function(_){var y=parseInt(this[_],10);return y>Number.MAX_SAFE_INTEGER?1/0:y},T.hexadecimalInteger=function(_){if(this[_]){var y=(this[_]||"0x").slice(2);y=(y.length&1?"0":"")+y;for(var D=new Uint8Array(y.length/2),A=0;A<y.length/2;A++)D[A]=parseInt(y.slice(A*2,A*2+2),16);return D}else return null},T.hexadecimalIntegerAsNumber=function(_){var y=parseInt(this[_],16);return y>Number.MAX_SAFE_INTEGER?1/0:y},T.decimalFloatingPoint=function(_){return parseFloat(this[_])},T.optionalFloat=function(_,y){var D=this[_];return D?parseFloat(D):y},T.enumeratedString=function(_){return this[_]},T.bool=function(_){return this[_]==="YES"},T.decimalResolution=function(_){var y=R.exec(this[_]);if(y!==null)return{width:parseInt(y[1],10),height:parseInt(y[2],10)}},I.parseAttrList=function(_){var y,D={},A='"';for(p.lastIndex=0;(y=p.exec(_))!==null;){var S=y[2];S.indexOf(A)===0&&S.lastIndexOf(A)===S.length-1&&(S=S.slice(1,-1)),D[y[1]]=S}return D},I}()},"./src/utils/binary-search.ts":function(k,P,s){"use strict";s.r(P);var R={search:function(x,I){for(var T=0,L=x.length-1,_=null,y=null;T<=L;){_=(T+L)/2|0,y=x[_];var D=I(y);if(D>0)T=_+1;else if(D<0)L=_-1;else return y}return null}};P.default=R},"./src/utils/buffer-helper.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"BufferHelper",function(){return x});var R=s("./src/utils/logger.ts"),p={length:0,start:function(){return 0},end:function(){return 0}},x=function(){function I(){}return I.isBuffered=function(L,_){try{if(L){for(var y=I.getBuffered(L),D=0;D<y.length;D++)if(_>=y.start(D)&&_<=y.end(D))return!0}}catch{}return!1},I.bufferInfo=function(L,_,y){try{if(L){var D=I.getBuffered(L),A=[],S;for(S=0;S<D.length;S++)A.push({start:D.start(S),end:D.end(S)});return this.bufferedInfo(A,_,y)}}catch{}return{len:0,start:_,end:_,nextStart:void 0}},I.bufferedInfo=function(L,_,y){_=Math.max(0,_),L.sort(function(t,u){var c=t.start-u.start;return c||u.end-t.end});var D=[];if(y)for(var A=0;A<L.length;A++){var S=D.length;if(S){var g=D[S-1].end;L[A].start-g<y?L[A].end>g&&(D[S-1].end=L[A].end):D.push(L[A])}else D.push(L[A])}else D=L;for(var E=0,a,e=_,o=_,f=0;f<D.length;f++){var n=D[f].start,i=D[f].end;if(_+y>=n&&_<i)e=n,o=i,E=o-_;else if(_+y<n){a=n;break}}return{len:E,start:e||0,end:o||0,nextStart:a}},I.getBuffered=function(L){try{return L.buffered}catch(_){return R.logger.log("failed to get media.buffered",_),p}},I}()},"./src/utils/cea-608-parser.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"Row",function(){return o}),s.d(P,"CaptionScreen",function(){return f});var R=s("./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},x=function(h){var d=h;return p.hasOwnProperty(h)&&(d=p[h]),String.fromCharCode(d)},I=15,T=100,L={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},_={17:2,18:4,21:6,22:8,23:10,19:13,20:15},y={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},D={25:2,26:4,29:6,30:8,31:10,27:13,28:15},A=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],S;(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"})(S||(S={}));var g=function(){function r(){this.time=null,this.verboseLevel=S.ERROR}var h=r.prototype;return h.log=function(l,v){this.verboseLevel>=l&&R.logger.log(this.time+" ["+l+"] "+v)},r}(),E=function(h){for(var d=[],l=0;l<h.length;l++)d.push(h[l].toString(16));return d},a=function(){function r(d,l,v,m,O){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=d||"white",this.underline=l||!1,this.italics=v||!1,this.background=m||"black",this.flash=O||!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 O=v[m];l.hasOwnProperty(O)&&(this[O]=l[O])}},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,O,b){this.uchar=void 0,this.penState=void 0,this.uchar=d||" ",this.penState=new a(l,v,m,O,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<T;l++)this.chars.push(new e);this.logger=d,this.pos=0,this.currPenState=new a}var h=r.prototype;return h.equals=function(l){for(var v=!0,m=0;m<T;m++)if(!this.chars[m].equals(l.chars[m])){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(S.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>T&&(this.logger.log(S.DEBUG,"Too large cursor position "+this.pos),this.pos=T)},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=x(l);if(this.pos>=T){this.logger.log(S.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,m=0;m<T;m++){var O=this.chars[m].uchar;O!==" "&&(v=!1),l.push(O)}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(S.INFO,"setCursor: "+l);var v=this.rows[this.currRow];v.setCursor(l)},h.setPAC=function(l){this.logger.log(S.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 O=this.currRow+1-this.nrRollUpRows,b=this.lastOutputScreen;if(b){var M=b.rows[O].cueStartTime,F=this.logger.time;if(M&&F!==null&&M<F)for(var w=0;w<this.nrRollUpRows;w++)this.rows[v-this.nrRollUpRows+w+1].copy(b.rows[O+w])}}this.currRow=v;var C=this.rows[this.currRow];if(l.indent!==null){var B=l.indent,U=Math.max(B-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(S.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(S.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(S.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(S.INFO,"Rolling up")},h.getDisplayText=function(l){l=l||!1;for(var v=[],m="",O=-1,b=0;b<I;b++){var M=this.rows[b].getTextString();M&&(O=b+1,l?v.push("Row "+O+": '"+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}(),n=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(S.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(S.INFO,m+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(S.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},h.ccRCL=function(){this.logger.log(S.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},h.ccBS=function(){this.logger.log(S.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(S.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},h.ccRU=function(l){this.logger.log(S.INFO,"RU("+l+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(l)},h.ccFON=function(){this.logger.log(S.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},h.ccRDC=function(){this.logger.log(S.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},h.ccTR=function(){this.logger.log(S.INFO,"TR"),this.setMode("MODE_TEXT")},h.ccRTD=function(){this.logger.log(S.INFO,"RTD"),this.setMode("MODE_TEXT")},h.ccEDM=function(){this.logger.log(S.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},h.ccCR=function(){this.logger.log(S.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},h.ccENM=function(){this.logger.log(S.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},h.ccEOC=function(){if(this.logger.log(S.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(S.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},h.ccTO=function(l){this.logger.log(S.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,O=["white","green","blue","cyan","red","yellow","magenta"];v.foreground=O[m]}this.logger.log(S.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 n(d,l,m),new n(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,O,b,M=!1;this.logger.time=l;for(var F=0;F<v.length;F+=2)if(O=v[F]&127,b=v[F+1]&127,!(O===0&&b===0)){if(this.logger.log(S.DATA,"["+E([v[F],v[F+1]])+"] -> ("+E([O,b])+")"),m=this.parseCmd(O,b),m||(m=this.parseMidrow(O,b)),m||(m=this.parsePAC(O,b)),m||(m=this.parseBackgroundAttributes(O,b)),!m&&(M=this.parseChars(O,b),M)){var w=this.currentChannel;if(w&&w>0){var C=this.channels[w];C.insertChars(M)}else this.logger.log(S.WARNING,"No channel found yet. TEXT-MODE?")}!m&&!M&&this.logger.log(S.WARNING,"Couldn't parse cleaned data "+E([O,b])+" orig: "+E([v[F],v[F+1]]))}},h.parseCmd=function(l,v){var m=this.cmdHistory,O=(l===20||l===28||l===21||l===29)&&v>=32&&v<=47,b=(l===23||l===31)&&v>=33&&v<=35;if(!(O||b))return!1;if(u(l,v,m))return t(null,null,m),this.logger.log(S.DEBUG,"Repeated command ("+E([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(S.ERROR,"Mismatch channel in midrow parsing"),!1;var O=this.channels[m];return O?(O.ccMIDROW(v),this.logger.log(S.DEBUG,"MIDROW ("+E([l,v])+")"),!0):!1}return!1},h.parsePAC=function(l,v){var m,O=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,O))return t(null,null,O),!0;var F=l<=23?1:2;v>=64&&v<=95?m=F===1?L[l]:y[l]:m=F===1?_[l]:D[l];var w=this.channels[F];return w?(w.setPAC(this.interpretPAC(m,v)),t(l,v,O),this.currentChannel=F,!0):!1},h.interpretPAC=function(l,v){var m,O={color:null,italics:!1,indent:null,underline:!1,row:l};return v>95?m=v-96:m=v-64,O.underline=(m&1)===1,m<=13?O.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(m/2)]:m<=15?(O.italics=!0,O.color="white"):O.indent=Math.floor((m-16)/2)*4,O},h.parseChars=function(l,v){var m,O=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(S.INFO,"Special char '"+x(M)+"' in channel "+m),O=[M]}else l>=32&&l<=127&&(O=v===0?[l]:[l,v]);if(O){var F=E(O);this.logger.log(S.DEBUG,"Char codes = "+F.join(",")),t(l,v,this.cmdHistory)}return O},h.parseBackgroundAttributes=function(l,v){var m=(l===16||l===24)&&v>=32&&v<=47,O=(l===23||l===31)&&v>=45&&v<=47;if(!(m||O))return!1;var b,M={};l===16||l===24?(b=Math.floor((v-32)/2),M.background=A[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(k,P,s){"use strict";s.r(P),s.d(P,"isCodecType",function(){return p}),s.d(P,"isCodecSupportedInMp4",function(){return x});var R={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function p(I,T){var L=R[T];return!!L&&L[I.slice(0,4)]===!0}function x(I,T){return MediaSource.isTypeSupported((T||"video")+'/mp4;codecs="'+I+'"')}},"./src/utils/cues.ts":function(k,P,s){"use strict";s.r(P);var R=s("./src/utils/vttparser.ts"),p=s("./src/utils/webvtt-parser.ts"),x=s("./src/utils/texttrack-utils.ts"),I=/\s/,T={newCue:function(_,y,D,A){for(var S=[],g,E,a,e,o,f=self.VTTCue||self.TextTrackCue,n=0;n<A.rows.length;n++)if(g=A.rows[n],a=!0,e=0,o="",!g.isEmpty()){for(var i=0;i<g.chars.length;i++)I.test(g.chars[i].uchar)&&a?e++:(o+=g.chars[i].uchar,a=!1);g.cueStartTime=y,y===D&&(D+=1e-4),e>=16?e--:e++;var t=Object(R.fixLineBreaks)(o.trim()),u=Object(p.generateCueId)(y,D,t);(!_||!_.cues||!_.cues.getCueById(u))&&(E=new f(y,D,t),E.id=u,E.line=n+1,E.align="left",E.position=10+Math.min(80,Math.floor(e*8/32)*10),S.push(E))}return _&&S.length&&(S.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}),S.forEach(function(c){return Object(x.addCueToTrack)(_,c)})),S}};P.default=T},"./src/utils/discontinuities.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"findFirstFragWithCC",function(){return I}),s.d(P,"shouldAlignOnDiscontinuities",function(){return T}),s.d(P,"findDiscontinuousReferenceFrag",function(){return L}),s.d(P,"adjustSlidingStart",function(){return y}),s.d(P,"alignStream",function(){return D}),s.d(P,"alignPDT",function(){return S}),s.d(P,"alignFragmentByPDTDelta",function(){return g}),s.d(P,"alignMediaPlaylistByPDT",function(){return E});var R=s("./src/polyfills/number.ts"),p=s("./src/utils/logger.ts"),x=s("./src/controller/level-helper.ts");function I(a,e){for(var o=null,f=0,n=a.length;f<n;f++){var i=a[f];if(i&&i.cc===e){o=i;break}}return o}function T(a,e,o){return!!(e.details&&(o.endCC>o.startCC||a&&a.cc<o.startCC))}function L(a,e){var o=a.fragments,f=e.fragments;if(!f.length||!o.length){p.logger.log("No fragments to align");return}var n=I(o,f[0].cc);if(!n||n&&!n.startPTS){p.logger.log("No frag in previous level to align on");return}return n}function _(a,e){if(a){var o=a.start+e;a.start=a.startPTS=o,a.endPTS=o+a.duration}}function y(a,e){for(var o=e.fragments,f=0,n=o.length;f<n;f++)_(o[f],a);e.fragmentHint&&_(e.fragmentHint,a),e.alignedSliding=!0}function D(a,e,o){!e||(A(a,o,e),!o.alignedSliding&&e.details&&S(o,e.details),!o.alignedSliding&&e.details&&!o.skippedSegments&&Object(x.adjustSliding)(e.details,o))}function A(a,e,o){if(T(a,o,e)){var f=L(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),y(f.start,e))}}function S(a,e){if(!(!e.fragments.length||!a.hasProgramDateTime||!e.hasProgramDateTime)){var o=e.fragments[0].programDateTime,f=a.fragments[0].programDateTime,n=(f-o)/1e3+e.fragments[0].start;n&&Object(R.isFiniteNumber)(n)&&(p.logger.log("Adjusting PTS using programDateTime delta "+(f-o)+"ms, sliding:"+n.toFixed(3)+" "+a.url+" "),y(n,a))}}function g(a,e){var o=a.programDateTime;if(!!o){var f=(o-e)/1e3;a.start=a.startPTS=f,a.endPTS=f+a.duration}}function E(a,e){if(!(!e.fragments.length||!a.hasProgramDateTime||!e.hasProgramDateTime)){var o=e.fragments[0].programDateTime,f=e.fragments[0].start,n=o-f*1e3;a.fragments.forEach(function(i){g(i,n)}),a.fragmentHint&&g(a.fragmentHint,n),a.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":function(k,P,s){"use strict";s.r(P);var R=s("./src/utils/ewma.ts"),p=function(){function x(T,L,_){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=_,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new R.default(T),this.fast_=new R.default(L)}var I=x.prototype;return I.update=function(L,_){var y=this.slow_,D=this.fast_;this.slow_.halfLife!==L&&(this.slow_=new R.default(L,y.getEstimate(),y.getTotalWeight())),this.fast_.halfLife!==_&&(this.fast_=new R.default(_,D.getEstimate(),D.getTotalWeight()))},I.sample=function(L,_){L=Math.max(L,this.minDelayMs_);var y=8*_,D=L/1e3,A=y/D;this.fast_.sample(D,A),this.slow_.sample(D,A)},I.canEstimate=function(){var L=this.fast_;return L&&L.getTotalWeight()>=this.minWeight_},I.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},I.destroy=function(){},x}();P.default=p},"./src/utils/ewma.ts":function(k,P,s){"use strict";s.r(P);var R=function(){function p(I,T,L){T===void 0&&(T=0),L===void 0&&(L=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=I,this.alpha_=I?Math.exp(Math.log(.5)/I):0,this.estimate_=T,this.totalWeight_=L}var x=p.prototype;return x.sample=function(T,L){var _=Math.pow(this.alpha_,T);this.estimate_=L*(1-_)+_*this.estimate_,this.totalWeight_+=T},x.getTotalWeight=function(){return this.totalWeight_},x.getEstimate=function(){if(this.alpha_){var T=1-Math.pow(this.alpha_,this.totalWeight_);if(T)return this.estimate_/T}return this.estimate_},p}();P.default=R},"./src/utils/fetch-loader.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"fetchSupported",function(){return g});var R=s("./src/polyfills/number.ts"),p=s("./src/loader/load-stats.ts"),x=s("./src/demux/chunk-cache.ts");function I(f,n){f.prototype=Object.create(n.prototype),f.prototype.constructor=f,D(f,n)}function T(f){var n=typeof Map=="function"?new Map:void 0;return T=function(t){if(t===null||!y(t))return t;if(typeof t!="function")throw new TypeError("Super expression must either be null or a function");if(typeof n!="undefined"){if(n.has(t))return n.get(t);n.set(t,u)}function u(){return L(t,arguments,A(this).constructor)}return u.prototype=Object.create(t.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),D(u,t)},T(f)}function L(f,n,i){return _()?L=Reflect.construct.bind():L=function(u,c,r){var h=[null];h.push.apply(h,c);var d=Function.bind.apply(u,h),l=new d;return r&&D(l,r.prototype),l},L.apply(null,arguments)}function _(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function y(f){return Function.toString.call(f).indexOf("[native code]")!==-1}function D(f,n){return D=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,u){return t.__proto__=u,t},D(f,n)}function A(f){return A=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},A(f)}function S(){return S=Object.assign?Object.assign.bind():function(f){for(var n=1;n<arguments.length;n++){var i=arguments[n];for(var t in i)Object.prototype.hasOwnProperty.call(i,t)&&(f[t]=i[t])}return f},S.apply(this,arguments)}function g(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var E=function(){function 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 n=f.prototype;return n.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},n.abortInternal=function(){var t=this.response;(!t||!t.ok)&&(this.stats.aborted=!0,this.controller.abort())},n.abort=function(){var t;this.abortInternal(),(t=this.callbacks)!==null&&t!==void 0&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},n.load=function(t,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=a(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(O){if(r.response=r.loader=O,!O.ok){var b=O.status,M=O.statusText;throw new o(M||"fetch, bad network response",b,O)}return h.loading.first=Math.max(self.performance.now(),h.loading.start),h.total=parseInt(O.headers.get("Content-Length")||"0"),l&&Object(R.isFiniteNumber)(u.highWaterMark)?r.loadProgressively(O,h,t,u.highWaterMark,l):v?O.arrayBuffer():O.text()}).then(function(O){var b=r.response;self.clearTimeout(r.requestTimeout),h.loading.end=Math.max(self.performance.now(),h.loading.first),h.loaded=h.total=O[m];var M={url:b.url,data:O};l&&!Object(R.isFiniteNumber)(u.highWaterMark)&&l(h,t,O,b),c.onSuccess(M,h,t,b)}).catch(function(O){if(self.clearTimeout(r.requestTimeout),!h.aborted){var b=O&&O.code||0,M=O?O.message:null;c.onError({code:b,text:M},t,O?O.details:null)}})},n.getCacheAge=function(){var t=null;if(this.response){var u=this.response.headers.get("age");t=u?parseFloat(u):null}return t},n.loadProgressively=function(t,u,c,r,h){r===void 0&&(r=0);var d=new x.default,l=t.body.getReader(),v=function m(){return l.read().then(function(O){if(O.done)return d.dataLength&&h(u,c,d.flush(),t),Promise.resolve(new ArrayBuffer(0));var b=O.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 a(f,n){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:n,headers:new self.Headers(S({},f.headers))};return f.rangeEnd&&i.headers.set("Range","bytes="+f.rangeStart+"-"+String(f.rangeEnd-1)),i}function e(f,n){return new self.Request(f.url,n)}var o=function(f){I(n,f);function n(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 n}(T(Error));P.default=E},"./src/utils/imsc1-ttml-parser.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"IMSC1_CODEC",function(){return y}),s.d(P,"parseIMSC1",function(){return g});var R=s("./src/utils/mp4-tools.ts"),p=s("./src/utils/vttparser.ts"),x=s("./src/utils/vttcue.ts"),I=s("./src/demux/id3.ts"),T=s("./src/utils/timescale-conversion.ts"),L=s("./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 y="stpp.ttml.im1t",D=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,A=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,S={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 O=m.map(function(M){return Object(I.utf8ArrayToStr)(M)}),b=Object(T.toTimescaleFromScale)(h,1,d);try{O.forEach(function(M){return l(E(M,b))})}catch(M){v(M)}}function E(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},O=Object.keys(m).reduce(function(C,B){return C[B]=v.getAttribute("ttp:"+B)||m[B],C},{}),b=v.getAttribute("xml:space")!=="preserve",M=e(a(v,"styling","style")),F=e(a(v,"layout","region")),w=a(v,"body","[begin]");return[].map.call(w,function(C){var B=o(C,b);if(!B||!C.hasAttribute("begin"))return null;var U=t(C.getAttribute("begin"),O),j=t(C.getAttribute("dur"),O),N=t(C.getAttribute("end"),O);if(U===null)throw i(C);if(N===null){if(j===null)throw i(C);N=U+j}var K=new x.default(U-h,N-h,B);K.id=Object(L.generateCueId)(K.startTime,K.endTime,K.text);var H=F[C.getAttribute("region")],V=M[C.getAttribute("style")];K.position=10,K.size=80;var Y=f(H,V,M),Q=Y.textAlign;if(Q){var J=S[Q];J&&(K.lineAlign=J),K.align=Q}return _(K,Y),K}).filter(function(C){return C!==null})}function a(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"],O=r!=null&&r.hasAttribute("style")?r.getAttribute("style"):null;return O&&d.hasOwnProperty(O)&&(v=d[O]),m.reduce(function(b,M){var F=n(h,l,M)||n(r,l,M)||n(v,l,M);return F&&(b[M]=F),b},{})}function n(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&&(D.test(r)?d=u(r,h):A.test(r)&&(d=c(r,h))),d}function u(r,h){var d=D.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=A.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(k,P,s){"use strict";s.r(P),s.d(P,"enableLogs",function(){return L}),s.d(P,"logger",function(){return _});var R=function(){},p={trace:R,debug:R,log:R,warn:R,info:R,error:R},x=p;function I(y){var D=self.console[y];return D?D.bind(self.console,"["+y+"] >"):R}function T(y){for(var D=arguments.length,A=new Array(D>1?D-1:0),S=1;S<D;S++)A[S-1]=arguments[S];A.forEach(function(g){x[g]=y[g]?y[g].bind(y):I(g)})}function L(y){if(self.console&&y===!0||typeof y=="object"){T(y,"debug","log","info","warn","error");try{x.log()}catch{x=p}}else x=p}var _=x},"./src/utils/mediakeys-helper.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"KeySystems",function(){return R}),s.d(P,"requestMediaKeySystemAccess",function(){return p});var R;(function(x){x.WIDEVINE="com.widevine.alpha",x.PLAYREADY="com.microsoft.playready"})(R||(R={}));var p=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"getMediaSource",function(){return R});function R(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"RemuxerTrackIdConfig",function(){return L}),s.d(P,"bin2str",function(){return _}),s.d(P,"readUint16",function(){return y}),s.d(P,"readUint32",function(){return D}),s.d(P,"readSint32",function(){return A}),s.d(P,"writeUint32",function(){return S}),s.d(P,"findBox",function(){return g}),s.d(P,"parseSegmentIndex",function(){return E}),s.d(P,"parseInitSegment",function(){return a}),s.d(P,"getStartDTS",function(){return e}),s.d(P,"getDuration",function(){return o}),s.d(P,"computeRawDurationFromSamples",function(){return f}),s.d(P,"offsetStartDTS",function(){return n}),s.d(P,"segmentValidRange",function(){return i}),s.d(P,"appendUint8Array",function(){return t}),s.d(P,"parseSamples",function(){return u}),s.d(P,"parseSEIMessageFromNALu",function(){return h}),s.d(P,"parseEmsg",function(){return l});var R=s("./src/utils/typed-array.ts"),p=s("./src/loader/fragment.ts"),x=s("./src/demux/id3.ts"),I=Math.pow(2,32)-1,T=[].push,L={video:1,audio:2,id3:3,text:4};function _(v){return String.fromCharCode.apply(null,v)}function y(v,m){var O=v[m]<<8|v[m+1];return O<0?65536+O:O}function D(v,m){var O=A(v,m);return O<0?4294967296+O:O}function A(v,m){return v[m]<<24|v[m+1]<<16|v[m+2]<<8|v[m+3]}function S(v,m,O){v[m]=O>>24,v[m+1]=O>>16&255,v[m+2]=O>>8&255,v[m+3]=O&255}function g(v,m){var O=[];if(!m.length)return O;for(var b=v.byteLength,M=0;M<b;){var F=D(v,M),w=_(v.subarray(M+4,M+8)),C=F>1?M+F:b;if(w===m[0])if(m.length===1)O.push(v.subarray(M+8,C));else{var B=g(v.subarray(M+8,C),m.slice(1));B.length&&T.apply(O,B)}M=C}return O}function E(v){var m=[],O=v[0],b=8,M=D(v,b);b+=4;var F=0,w=0;O===0?b+=8:b+=16,b+=2;var C=v.length+w,B=y(v,b);b+=2;for(var U=0;U<B;U++){var j=b,N=D(v,j);j+=4;var K=N&2147483647,H=(N&2147483648)>>>31;if(H===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var V=D(v,j);j+=4,m.push({referenceSize:K,subsegmentDuration:V,info:{duration:V/M,start:C,end:C+K-1}}),C+=K,j+=4,b=j}return{earliestPresentationTime:F,timescale:M,version:O,referencesCount:B,references:m}}function a(v){for(var m=[],O=g(v,["moov","trak"]),b=0;b<O.length;b++){var M=O[b],F=g(M,["tkhd"])[0];if(F){var w=F[0],C=w===0?12:20,B=D(F,C),U=g(M,["mdia","mdhd"])[0];if(U){w=U[0],C=w===0?12:20;var j=D(U,C),N=g(M,["mdia","hdlr"])[0];if(N){var K=_(N.subarray(8,12)),H={soun:p.ElementaryStreamTypes.AUDIO,vide:p.ElementaryStreamTypes.VIDEO}[K];if(H){var V=g(M,["mdia","minf","stbl","stsd"])[0],Y=void 0;V&&(Y=_(V.subarray(12,16))),m[B]={timescale:j,type:H},m[H]={timescale:j,id:B,codec:Y}}}}}}var Q=g(v,["moov","mvex","trex"]);return Q.forEach(function(J){var z=D(J,4),q=m[z];q&&(q.default={duration:D(J,12),flags:D(J,20)})}),m}function e(v,m){return g(m,["moof","traf"]).reduce(function(O,b){var M=g(b,["tfdt"])[0],F=M[0],w=g(b,["tfhd"]).reduce(function(C,B){var U=D(B,4),j=v[U];if(j){var N=D(M,4);F===1&&(N*=Math.pow(2,32),N+=D(M,8));var K=j.timescale||9e4,H=N/K;if(isFinite(H)&&(C===null||H<C))return H}return C},null);return w!==null&&isFinite(w)&&(O===null||w<O)?w:O},null)||0}function o(v,m){for(var O=0,b=0,M=0,F=g(v,["moof","traf"]),w=0;w<F.length;w++){var C=F[w],B=g(C,["tfhd"])[0],U=D(B,4),j=m[U];if(!!j){var N=j.default,K=D(B,0)|(N==null?void 0:N.flags),H=N==null?void 0:N.duration;K&8&&(K&2?H=D(B,12):H=D(B,8));for(var V=j.timescale||9e4,Y=g(C,["trun"]),Q=0;Q<Y.length;Q++){if(O=f(Y[Q]),!O&&H){var J=D(Y[Q],4);O=H*J}j.type===p.ElementaryStreamTypes.VIDEO?b+=O/V:j.type===p.ElementaryStreamTypes.AUDIO&&(M+=O/V)}}}if(b===0&&M===0){for(var z=0,q=g(v,["sidx"]),re=0;re<q.length;re++){var X=E(q[re]);X!=null&&X.references&&(z+=X.references.reduce(function(le,ne){return le+ne.info.duration||0},0))}return z}return b||M}function f(v){var m=D(v,0),O=8;m&1&&(O+=4),m&4&&(O+=4);for(var b=0,M=D(v,4),F=0;F<M;F++){if(m&256){var w=D(v,O);b+=w,O+=4}m&512&&(O+=4),m&1024&&(O+=4),m&2048&&(O+=4)}return b}function n(v,m,O){g(m,["moof","traf"]).forEach(function(b){g(b,["tfhd"]).forEach(function(M){var F=D(M,4),w=v[F];if(!!w){var C=w.timescale||9e4;g(b,["tfdt"]).forEach(function(B){var U=B[0],j=D(B,4);if(U===0)j-=O*C,j=Math.max(j,0),S(B,4,j);else{j*=Math.pow(2,32),j+=D(B,8),j-=O*C,j=Math.max(j,0);var N=Math.floor(j/(I+1)),K=Math.floor(j%(I+1));S(B,4,N),S(B,8,K)}})}})})}function i(v){var m={valid:null,remainder:null},O=g(v,["moof"]);if(O){if(O.length<2)return m.remainder=v,m}else return m;var b=O[O.length-1];return m.valid=Object(R.sliceUint8)(v,0,b.byteOffset-8),m.remainder=Object(R.sliceUint8)(v,b.byteOffset-8),m}function t(v,m){var O=new Uint8Array(v.length+m.length);return O.set(v),O.set(m,v.length),O}function u(v,m){var O=[],b=m.samples,M=m.timescale,F=m.id,w=!1,C=g(b,["moof"]);return C.map(function(B){var U=B.byteOffset-8,j=g(B,["traf"]);j.map(function(N){var K=g(N,["tfdt"]).map(function(H){var V=H[0],Y=D(H,4);return V===1&&(Y*=Math.pow(2,32),Y+=D(H,8)),Y/M})[0];return K!==void 0&&(v=K),g(N,["tfhd"]).map(function(H){var V=D(H,4),Y=D(H,0)&16777215,Q=(Y&1)!==0,J=(Y&2)!==0,z=(Y&8)!==0,q=0,re=(Y&16)!==0,X=0,le=(Y&32)!==0,ne=8;V===F&&(Q&&(ne+=8),J&&(ne+=4),z&&(q=D(H,ne),ne+=4),re&&(X=D(H,ne),ne+=4),le&&(ne+=4),m.type==="video"&&(w=c(m.codec)),g(N,["trun"]).map(function(te){var ee=te[0],$=D(te,0)&16777215,Z=($&1)!==0,ue=0,he=($&4)!==0,se=($&256)!==0,pe=0,ye=($&512)!==0,Te=0,ae=($&1024)!==0,fe=($&2048)!==0,ge=0,ve=D(te,4),xe=8;Z&&(ue=D(te,xe),xe+=4),he&&(xe+=4);for(var _e=ue+U,be=0;be<ve;be++){if(se?(pe=D(te,xe),xe+=4):pe=q,ye?(Te=D(te,xe),xe+=4):Te=X,ae&&(xe+=4),fe&&(ee===0?ge=D(te,xe):ge=A(te,xe),xe+=4),m.type===p.ElementaryStreamTypes.VIDEO)for(var Se=0;Se<Te;){var Ee=D(b,_e);_e+=4;var W=b[_e]&31;if(r(w,W)){var G=b.subarray(_e,_e+Ee);h(G,v+ge/M,O)}_e+=Ee,Se+=Ee+4}v+=pe/M}}))})})}),O}function c(v){if(!v)return!1;var m=v.indexOf("."),O=m<0?v:v.substring(0,m);return O==="hvc1"||O==="hev1"||O==="dvh1"||O==="dvhe"}function r(v,m){return v?m===39||m===40:m===6}function h(v,m,O){var b=d(v),M=0;M++;for(var F=0,w=0,C=!1,B=0;M<b.length;){F=0;do{if(M>=b.length)break;B=b[M++],F+=B}while(B===255);w=0;do{if(M>=b.length)break;B=b[M++],w+=B}while(B===255);var U=b.length-M;if(!C&&F===4&&M<b.length){C=!0;var j=b[M++];if(j===181){var N=y(b,M);if(M+=2,N===49){var K=D(b,M);if(M+=4,K===1195456820){var H=b[M++];if(H===3){var V=b[M++],Y=31&V,Q=64&V,J=Q?2+Y*3:0,z=new Uint8Array(J);if(Q){z[0]=V;for(var q=1;q<J;q++)z[q]=b[M++]}O.push({type:H,payloadType:F,pts:m,bytes:z})}}}}}else if(F===5&&w<U){if(C=!0,w>16){for(var re=[],X=0;X<16;X++){var le=b[M++].toString(16);re.push(le.length==1?"0"+le:le),(X===3||X===5||X===7||X===9)&&re.push("-")}for(var ne=w-16,te=new Uint8Array(ne),ee=0;ee<ne;ee++)te[ee]=b[M++];O.push({payloadType:F,pts:m,uuid:re.join(""),userData:Object(x.utf8ArrayToStr)(te),userDataBytes:te})}}else if(w<U)M+=w;else if(w>U)break}}function d(v){for(var m=v.byteLength,O=[],b=1;b<m-2;)v[b]===0&&v[b+1]===0&&v[b+2]===3?(O.push(b+2),b+=2):b++;if(O.length===0)return v;var M=m-O.length,F=new Uint8Array(M),w=0;for(b=0;b<M;w++,b++)w===O[0]&&(w++,O.shift()),F[b]=v[w];return F}function l(v){var m=v[0],O="",b="",M=0,F=0,w=0,C=0,B=0,U=0;if(m===0){for(;_(v.subarray(U,U+1))!=="\0";)O+=_(v.subarray(U,U+1)),U+=1;for(O+=_(v.subarray(U,U+1)),U+=1;_(v.subarray(U,U+1))!=="\0";)b+=_(v.subarray(U,U+1)),U+=1;b+=_(v.subarray(U,U+1)),U+=1,M=D(v,12),F=D(v,16),C=D(v,20),B=D(v,24),U=28}else if(m===1){U+=4,M=D(v,U),U+=4;var j=D(v,U);U+=4;var N=D(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=D(v,U),U+=4,B=D(v,U),U+=4;_(v.subarray(U,U+1))!=="\0";)O+=_(v.subarray(U,U+1)),U+=1;for(O+=_(v.subarray(U,U+1)),U+=1;_(v.subarray(U,U+1))!=="\0";)b+=_(v.subarray(U,U+1)),U+=1;b+=_(v.subarray(U,U+1)),U+=1}var K=v.subarray(U,v.byteLength);return{schemeIdUri:O,value:b,timeScale:M,presentationTime:w,presentationTimeDelta:F,eventDuration:C,id:B,payload:K}}},"./src/utils/output-filter.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"default",function(){return R});var R=function(){function p(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 x=p.prototype;return x.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},x.newCue=function(T,L,_){(this.startTime===null||this.startTime>T)&&(this.startTime=T),this.endTime=L,this.screen=_,this.timelineController.createCaptionsTrack(this.trackName)},x.reset=function(){this.cueRanges=[],this.startTime=null},p}()},"./src/utils/texttrack-utils.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"sendAddTrackEvent",function(){return p}),s.d(P,"addCueToTrack",function(){return x}),s.d(P,"clearCurrentCues",function(){return I}),s.d(P,"removeCuesInRange",function(){return T}),s.d(P,"getCuesInRange",function(){return _});var R=s("./src/utils/logger.ts");function p(y,D){var A;try{A=new Event("addtrack")}catch{A=document.createEvent("Event"),A.initEvent("addtrack",!1,!1)}A.track=y,D.dispatchEvent(A)}function x(y,D){var A=y.mode;if(A==="disabled"&&(y.mode="hidden"),y.cues&&!y.cues.getCueById(D.id))try{if(y.addCue(D),!y.cues.getCueById(D.id))throw new Error("addCue is failed for: "+D)}catch(g){R.logger.debug("[texttrack-utils]: "+g);var S=new self.TextTrackCue(D.startTime,D.endTime,D.text);S.id=D.id,y.addCue(S)}A==="disabled"&&(y.mode=A)}function I(y){var D=y.mode;if(D==="disabled"&&(y.mode="hidden"),y.cues)for(var A=y.cues.length;A--;)y.removeCue(y.cues[A]);D==="disabled"&&(y.mode=D)}function T(y,D,A,S){var g=y.mode;if(g==="disabled"&&(y.mode="hidden"),y.cues&&y.cues.length>0)for(var E=_(y.cues,D,A),a=0;a<E.length;a++)(!S||S(E[a]))&&y.removeCue(E[a]);g==="disabled"&&(y.mode=g)}function L(y,D){if(D<y[0].startTime)return 0;var A=y.length-1;if(D>y[A].endTime)return-1;for(var S=0,g=A;S<=g;){var E=Math.floor((g+S)/2);if(D<y[E].startTime)g=E-1;else if(D>y[E].startTime&&S<A)S=E+1;else return E}return y[S].startTime-D<D-y[g].startTime?S:g}function _(y,D,A){var S=[],g=L(y,D);if(g>-1)for(var E=g,a=y.length;E<a;E++){var e=y[E];if(e.startTime>=D&&e.endTime<=A)S.push(e);else if(e.startTime>A)return S}return S}},"./src/utils/time-ranges.ts":function(k,P,s){"use strict";s.r(P);var R={toString:function(x){for(var I="",T=x.length,L=0;L<T;L++)I+="["+x.start(L).toFixed(3)+","+x.end(L).toFixed(3)+"]";return I}};P.default=R},"./src/utils/timescale-conversion.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"toTimescaleFromBase",function(){return p}),s.d(P,"toTimescaleFromScale",function(){return x}),s.d(P,"toMsFromMpegTsClock",function(){return I}),s.d(P,"toMpegTsClockFromTimescale",function(){return T});var R=9e4;function p(L,_,y,D){y===void 0&&(y=1),D===void 0&&(D=!1);var A=L*_*y;return D?Math.round(A):A}function x(L,_,y,D){return y===void 0&&(y=1),D===void 0&&(D=!1),p(L,_,1/y,D)}function I(L,_){return _===void 0&&(_=!1),p(L,1e3,1/R,_)}function T(L,_){return _===void 0&&(_=1),p(L,R,1/_)}},"./src/utils/typed-array.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"sliceUint8",function(){return R});function R(p,x,I){return Uint8Array.prototype.slice?p.slice(x,I):new Uint8Array(Array.prototype.slice.call(p,x,I))}},"./src/utils/vttcue.ts":function(k,P,s){"use strict";s.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 x(y,D){if(typeof D!="string"||!Array.isArray(y))return!1;var A=D.toLowerCase();return~y.indexOf(A)?A:!1}function I(y){return x(R,y)}function T(y){return x(p,y)}function L(y){for(var D=arguments.length,A=new Array(D>1?D-1:0),S=1;S<D;S++)A[S-1]=arguments[S];for(var g=1;g<arguments.length;g++){var E=arguments[g];for(var a in E)y[a]=E[a]}return y}function _(y,D,A){var S=this,g={enumerable:!0};S.hasBeenReset=!1;var E="",a=!1,e=y,o=D,f=A,n=null,i="",t=!0,u="auto",c="start",r=50,h="middle",d=50,l="middle";Object.defineProperty(S,"id",L({},g,{get:function(){return E},set:function(m){E=""+m}})),Object.defineProperty(S,"pauseOnExit",L({},g,{get:function(){return a},set:function(m){a=!!m}})),Object.defineProperty(S,"startTime",L({},g,{get:function(){return e},set:function(m){if(typeof m!="number")throw new TypeError("Start time must be set to a number.");e=m,this.hasBeenReset=!0}})),Object.defineProperty(S,"endTime",L({},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(S,"text",L({},g,{get:function(){return f},set:function(m){f=""+m,this.hasBeenReset=!0}})),Object.defineProperty(S,"region",L({},g,{get:function(){return n},set:function(m){n=m,this.hasBeenReset=!0}})),Object.defineProperty(S,"vertical",L({},g,{get:function(){return i},set:function(m){var O=I(m);if(O===!1)throw new SyntaxError("An invalid or illegal string was specified.");i=O,this.hasBeenReset=!0}})),Object.defineProperty(S,"snapToLines",L({},g,{get:function(){return t},set:function(m){t=!!m,this.hasBeenReset=!0}})),Object.defineProperty(S,"line",L({},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(S,"lineAlign",L({},g,{get:function(){return c},set:function(m){var O=T(m);if(!O)throw new SyntaxError("An invalid or illegal string was specified.");c=O,this.hasBeenReset=!0}})),Object.defineProperty(S,"position",L({},g,{get:function(){return r},set:function(m){if(m<0||m>100)throw new Error("Position must be between 0 and 100.");r=m,this.hasBeenReset=!0}})),Object.defineProperty(S,"positionAlign",L({},g,{get:function(){return h},set:function(m){var O=T(m);if(!O)throw new SyntaxError("An invalid or illegal string was specified.");h=O,this.hasBeenReset=!0}})),Object.defineProperty(S,"size",L({},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(S,"align",L({},g,{get:function(){return l},set:function(m){var O=T(m);if(!O)throw new SyntaxError("An invalid or illegal string was specified.");l=O,this.hasBeenReset=!0}})),S.displayState=void 0}return _.prototype.getCueAsHTML=function(){var y=self.WebVTT;return y.convertCueToDOMTree(self,this.text)},_}()},"./src/utils/vttparser.ts":function(k,P,s){"use strict";s.r(P),s.d(P,"parseTimeStamp",function(){return x}),s.d(P,"fixLineBreaks",function(){return D}),s.d(P,"VTTParser",function(){return A});var R=s("./src/utils/vttcue.ts"),p=function(){function S(){}var g=S.prototype;return g.decode=function(a,e){if(!a)return"";if(typeof a!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(a))},S}();function x(S){function g(a,e,o,f){return(a|0)*3600+(e|0)*60+(o|0)+parseFloat(f||0)}var E=S.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return E?parseFloat(E[2])>59?g(E[2],E[3],0,E[4]):g(E[1],E[2],E[3],E[4]):null}var I=function(){function S(){this.values=Object.create(null)}var g=S.prototype;return g.set=function(a,e){!this.get(a)&&e!==""&&(this.values[a]=e)},g.get=function(a,e,o){return o?this.has(a)?this.values[a]:e[o]:this.has(a)?this.values[a]:e},g.has=function(a){return a in this.values},g.alt=function(a,e,o){for(var f=0;f<o.length;++f)if(e===o[f]){this.set(a,e);break}},g.integer=function(a,e){/^-?\d+$/.test(e)&&this.set(a,parseInt(e,10))},g.percent=function(a,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){var o=parseFloat(e);if(o>=0&&o<=100)return this.set(a,o),!0}return!1},S}();function T(S,g,E,a){var e=a?S.split(a):[S];for(var o in e)if(typeof e[o]=="string"){var f=e[o].split(E);if(f.length===2){var n=f[0],i=f[1];g(n,i)}}}var L=new R.default(0,0,""),_=L.align==="middle"?"middle":"center";function y(S,g,E){var a=S;function e(){var n=x(S);if(n===null)throw new Error("Malformed timestamp: "+a);return S=S.replace(/^[^\sa-zA-Z-]+/,""),n}function o(n,i){var t=new I;T(n,function(r,h){var d;switch(r){case"region":for(var l=E.length-1;l>=0;l--)if(E[l].id===h){t.set(r,E[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"&&L.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"&&L.position===50&&(c=i.align==="start"||i.align==="left"?0:i.align==="end"||i.align==="right"?100:50),i.position=c}function f(){S=S.replace(/^\s+/,"")}if(f(),g.startTime=e(),f(),S.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+a);S=S.slice(3),f(),g.endTime=e(),f(),o(S,g)}function D(S){return S.replace(/<br(?: \/)?>/gi,`
|
|
21
|
-
`)}var
|
|
22
|
-
`;)++
|
|
23
|
-
`&&++
|
|
24
|
-
`),e.cue.text+=
|
|
18
|
+
timeOffset: `+T+`
|
|
19
|
+
initSegmentChange: `+Z);var ie=new M.TransmuxConfig(h,g,s,o,n);this.configureTransmuxer(ie)}if(this.frag=i,this.part=r,S)S.postMessage({cmd:"demux",data:e,decryptdata:I,chunkMeta:t,state:q},e instanceof ArrayBuffer?[e]:[]);else if(v){var ne=v.push(e,I,t,q);Object(M.isPromise)(ne)?ne.then(function(ae){d.handleTransmuxComplete(ae)}):this.handleTransmuxComplete(ne)}},p.flush=function(e){var s=this;e.transmuxing.start=self.performance.now();var h=this.transmuxer,g=this.worker;if(g)g.postMessage({cmd:"flush",chunkMeta:e});else if(h){var i=h.flush(e);Object(M.isPromise)(i)?i.then(function(r){s.handleFlushResult(r,e)}):this.handleFlushResult(i,e)}},p.handleFlushResult=function(e,s){var h=this;e.forEach(function(g){h.handleTransmuxComplete(g)}),this.onFlush(s)},p.onWorkerMessage=function(e){var s=e.data,h=this.hls;switch(s.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(s.data);break}case"flush":{this.onFlush(s.data);break}case"workerLog":O.logger[s.data.logType]&&O.logger[s.data.logType](s.data.message);break;default:{s.data=s.data||{},s.data.frag=this.frag,s.data.id=this.id,h.trigger(s.event,s.data);break}}},p.configureTransmuxer=function(e){var s=this.worker,h=this.transmuxer;s?s.postMessage({cmd:"configure",config:e}):h&&h.configure(e)},p.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},m}()},"./src/demux/transmuxer-worker.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return b});var P=l("./src/demux/transmuxer.ts"),L=l("./src/events.ts"),A=l("./src/utils/logger.ts"),M=l("./node_modules/eventemitter3/index.js"),O=l.n(M);function b(E){var m=new M.EventEmitter,p=function(s,h){E.postMessage({event:s,data:h})};m.on(L.Events.FRAG_DECRYPTED,p),m.on(L.Events.ERROR,p);var f=function(){var s=function(i){var r=function(c){p("workerLog",{logType:i,message:c})};A.logger[i]=r};for(var h in A.logger)s(h)};E.addEventListener("message",function(e){var s=e.data;switch(s.cmd){case"init":{var h=JSON.parse(s.config);E.transmuxer=new P.default(m,s.typeSupported,h,s.vendor,s.id),Object(A.enableLogs)(h.debug),f(),p("init",null);break}case"configure":{E.transmuxer.configure(s.config);break}case"demux":{var g=E.transmuxer.push(s.data,s.decryptdata,s.chunkMeta,s.state);Object(P.isPromise)(g)?g.then(function(o){_(E,o)}):_(E,g);break}case"flush":{var i=s.chunkMeta,r=E.transmuxer.flush(i);Object(P.isPromise)(r)?r.then(function(o){x(E,o,i)}):x(E,r,i);break}default:break}})}function _(E,m){if(D(m.remuxResult))return!1;var p=[],f=m.remuxResult,e=f.audio,s=f.video;return e&&y(p,e),s&&y(p,s),E.postMessage({event:"transmuxComplete",data:m},p),!0}function y(E,m){m.data1&&E.push(m.data1.buffer),m.data2&&E.push(m.data2.buffer)}function x(E,m,p){var f=m.reduce(function(e,s){return _(E,s)||e},!1);f||E.postMessage({event:"transmuxComplete",data:m[0]}),E.postMessage({event:"flush",data:p})}function D(E){return!E.audio&&!E.video&&!E.text&&!E.id3&&!E.initSegment}},"./src/demux/transmuxer.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return p}),l.d(R,"isPromise",function(){return s}),l.d(R,"TransmuxConfig",function(){return h}),l.d(R,"TransmuxState",function(){return g});var P=l("./src/events.ts"),L=l("./src/errors.ts"),A=l("./src/crypt/decrypter.ts"),M=l("./src/demux/aacdemuxer.ts"),O=l("./src/demux/mp4demuxer.ts"),b=l("./src/demux/tsdemuxer.ts"),_=l("./src/demux/mp3demuxer.ts"),y=l("./src/remux/mp4-remuxer.ts"),x=l("./src/remux/passthrough-remuxer.ts"),D=l("./src/utils/logger.ts"),E;try{E=self.performance.now.bind(self.performance)}catch{D.logger.debug("Unable to use Performance API on this environment"),E=self.Date.now}var m=[{demux:b.default,remux:y.default},{demux:O.default,remux:x.default},{demux:M.default,remux:y.default},{demux:_.default,remux:y.default}],p=function(){function i(o,c,t,n,u){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=o,this.typeSupported=c,this.config=t,this.vendor=n,this.id=u}var r=i.prototype;return r.configure=function(c){this.transmuxConfig=c,this.decrypter&&this.decrypter.reset()},r.push=function(c,t,n,u){var a=this,d=n.transmuxing;d.executeStart=E();var v=new Uint8Array(c),S=this.config,T=this.currentTransmuxState,I=this.transmuxConfig;u&&(this.currentTransmuxState=u);var k=u||T,B=k.contiguous,U=k.discontinuity,W=k.trackSwitch,G=k.accurateTimeOffset,z=k.timeOffset,Y=k.initSegmentChange,$=I.audioCodec,Z=I.videoCodec,q=I.defaultInitPts,ie=I.duration,ne=I.initSegmentData;(U||W||Y)&&this.resetInitSegment(ne,$,Z,ie),(U||Y)&&this.resetInitialTimestamp(q),B||this.resetContiguity();var ae=f(v,t);if(ae&&ae.method==="AES-128"){var te=this.getDecrypter();if(S.enableSoftwareAES){var fe=te.softwareDecrypt(v,ae.key.buffer,ae.iv.buffer);if(!fe)return d.executeEnd=E(),e(n);v=new Uint8Array(fe)}else return this.decryptionPromise=te.webCryptoDecrypt(v,ae.key.buffer,ae.iv.buffer).then(function(Ee){var me=a.push(Ee,null,n);return a.decryptionPromise=null,me}),this.decryptionPromise}this.needsProbing(v,U,W)&&this.configureTransmuxer(v,I);var de=this.transmux(v,ae,z,G,n),re=this.currentTransmuxState;return re.contiguous=!0,re.discontinuity=!1,re.trackSwitch=!1,d.executeEnd=E(),de},r.flush=function(c){var t=this,n=c.transmuxing;n.executeStart=E();var u=this.decrypter,a=this.currentTransmuxState,d=this.decryptionPromise;if(d)return d.then(function(){return t.flush(c)});var v=[],S=a.timeOffset;if(u){var T=u.flush();T&&v.push(this.push(T,null,c))}var I=this.demuxer,k=this.remuxer;if(!I||!k)return this.observer.emit(P.Events.ERROR,P.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),n.executeEnd=E(),[e(c)];var B=I.flush(S);return s(B)?B.then(function(U){return t.flushRemux(v,U,c),v}):(this.flushRemux(v,B,c),v)},r.flushRemux=function(c,t,n){var u=t.audioTrack,a=t.videoTrack,d=t.id3Track,v=t.textTrack,S=this.currentTransmuxState,T=S.accurateTimeOffset,I=S.timeOffset;D.logger.log("[transmuxer.ts]: Flushed fragment "+n.sn+(n.part>-1?" p: "+n.part:"")+" of level "+n.level);var k=this.remuxer.remux(u,a,d,v,I,T,!0,this.id);c.push({remuxResult:k,chunkMeta:n}),n.transmuxing.executeEnd=E()},r.resetInitialTimestamp=function(c){var t=this.demuxer,n=this.remuxer;!t||!n||(t.resetTimeStamp(c),n.resetTimeStamp(c))},r.resetContiguity=function(){var c=this.demuxer,t=this.remuxer;!c||!t||(c.resetContiguity(),t.resetNextTimestamp())},r.resetInitSegment=function(c,t,n,u){var a=this.demuxer,d=this.remuxer;!a||!d||(a.resetInitSegment(c,t,n,u),d.resetInitSegment(c,t,n))},r.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},r.transmux=function(c,t,n,u,a){var d;return t&&t.method==="SAMPLE-AES"?d=this.transmuxSampleAes(c,t,n,u,a):d=this.transmuxUnencrypted(c,n,u,a),d},r.transmuxUnencrypted=function(c,t,n,u){var a=this.demuxer.demux(c,t,!1,!this.config.progressive),d=a.audioTrack,v=a.videoTrack,S=a.id3Track,T=a.textTrack,I=this.remuxer.remux(d,v,S,T,t,n,!1,this.id);return{remuxResult:I,chunkMeta:u}},r.transmuxSampleAes=function(c,t,n,u,a){var d=this;return this.demuxer.demuxSampleAes(c,t,n).then(function(v){var S=d.remuxer.remux(v.audioTrack,v.videoTrack,v.id3Track,v.textTrack,n,u,!1,d.id);return{remuxResult:S,chunkMeta:a}})},r.configureTransmuxer=function(c,t){for(var n=this.config,u=this.observer,a=this.typeSupported,d=this.vendor,v=t.audioCodec,S=t.defaultInitPts,T=t.duration,I=t.initSegmentData,k=t.videoCodec,B,U=0,W=m.length;U<W;U++)if(m[U].demux.probe(c)){B=m[U];break}B||(D.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),B={demux:O.default,remux:x.default});var G=this.demuxer,z=this.remuxer,Y=B.remux,$=B.demux;(!z||!(z instanceof Y))&&(this.remuxer=new Y(u,n,a,d)),(!G||!(G instanceof $))&&(this.demuxer=new $(u,n,a),this.probe=$.probe),this.resetInitSegment(I,v,k,T),this.resetInitialTimestamp(S)},r.needsProbing=function(c,t,n){return!this.demuxer||!this.remuxer||t||n},r.getDecrypter=function(){var c=this.decrypter;return c||(c=this.decrypter=new A.default(this.observer,this.config)),c},i}();function f(i,r){var o=null;return i.byteLength>0&&r!=null&&r.key!=null&&r.iv!==null&&r.method!=null&&(o=r),o}var e=function(r){return{remuxResult:{},chunkMeta:r}};function s(i){return"then"in i&&i.then instanceof Function}var h=function(r,o,c,t,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=r,this.videoCodec=o,this.initSegmentData=c,this.duration=t,this.defaultInitPts=n},g=function(r,o,c,t,n,u){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=r,this.contiguous=o,this.accurateTimeOffset=c,this.trackSwitch=t,this.timeOffset=n,this.initSegmentChange=u}},"./src/demux/tsdemuxer.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"discardEPB",function(){return h});var P=l("./src/demux/adts.ts"),L=l("./src/demux/mpegaudio.ts"),A=l("./src/demux/exp-golomb.ts"),M=l("./src/demux/sample-aes.ts"),O=l("./src/events.ts"),b=l("./src/utils/mp4-tools.ts"),_=l("./src/utils/logger.ts"),y=l("./src/errors.ts"),x=l("./src/types/demuxer.ts");function D(){return D=Object.assign?Object.assign.bind():function(g){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(g[o]=r[o])}return g},D.apply(this,arguments)}var E=function(){function g(r,o,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=r,this.config=o,this.typeSupported=c}g.probe=function(o){return o[0]===71&&o[188]===71},g.createTrack=function(o,c){return{container:o==="video"||o==="audio"?"video/mp2t":void 0,type:o,id:b.RemuxerTrackIdConfig[o],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:o==="audio"?c:void 0}};var i=g.prototype;return i.resetInitSegment=function(o,c,t,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=g.createTrack("video"),this._audioTrack=g.createTrack("audio",n),this._id3Track=g.createTrack("id3"),this._txtTrack=g.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=c,this.videoCodec=t,this._duration=n},i.resetTimeStamp=function(){},i.resetContiguity=function(){var o=this._audioTrack,c=this._avcTrack,t=this._id3Track;o&&(o.pesData=null),c&&(c.pesData=null),t&&(t.pesData=null),this.aacOverFlow=null},i.demux=function(o,c,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1),t||(this.sampleAes=null);var u,a=this._avcTrack,d=this._audioTrack,v=this._id3Track,S=this._txtTrack,T=a.pid,I=a.pesData,k=d.pid,B=v.pid,U=d.pesData,W=v.pesData,G=null,z=this.pmtParsed,Y=this._pmtId,$=o.length;if(this.remainderData&&(o=Object(b.appendUint8Array)(this.remainderData,o),$=o.length,this.remainderData=null),$<188&&!n)return this.remainderData=o,{audioTrack:d,videoTrack:a,id3Track:v,textTrack:S};$-=$%188,$<o.byteLength&&!n&&(this.remainderData=new Uint8Array(o.buffer,$,o.buffer.byteLength-$));for(var Z=0,q=0;q<$;q+=188)if(o[q]===71){var ie=!!(o[q+1]&64),ne=((o[q+1]&31)<<8)+o[q+2],ae=(o[q+3]&48)>>4,te=void 0;if(ae>1){if(te=q+5+o[q+4],te===q+188)continue}else te=q+4;switch(ne){case T:ie&&(I&&(u=e(I))&&this.parseAVCPES(a,S,u,!1),I={data:[],size:0}),I&&(I.data.push(o.subarray(te,q+188)),I.size+=q+188-te);break;case k:if(ie){if(U&&(u=e(U)))switch(d.segmentCodec){case"aac":this.parseAACPES(d,u);break;case"mp3":this.parseMPEGPES(d,u);break}U={data:[],size:0}}U&&(U.data.push(o.subarray(te,q+188)),U.size+=q+188-te);break;case B:ie&&(W&&(u=e(W))&&this.parseID3PES(v,u),W={data:[],size:0}),W&&(W.data.push(o.subarray(te,q+188)),W.size+=q+188-te);break;case 0:ie&&(te+=o[te]+1),Y=this._pmtId=p(o,te);break;case Y:{ie&&(te+=o[te]+1);var fe=f(o,te,this.typeSupported,t);T=fe.avc,T>0&&(a.pid=T),k=fe.audio,k>0&&(d.pid=k,d.segmentCodec=fe.segmentCodec),B=fe.id3,B>0&&(v.pid=B),G!==null&&!z&&(_.logger.log("unknown PID '"+G+"' in TS found"),G=null),z=this.pmtParsed=!0;break}case 17:case 8191:break;default:G=ne;break}}else Z++;Z>0&&this.observer.emit(O.Events.ERROR,O.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+Z+" TS packet/s that do not start with 0x47"}),a.pesData=I,d.pesData=U,v.pesData=W;var de={audioTrack:d,videoTrack:a,id3Track:v,textTrack:S};return n&&this.extractRemainingSamples(de),de},i.flush=function(){var o=this.remainderData;this.remainderData=null;var c;return o?c=this.demux(o,-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(o){var c=o.audioTrack,t=o.videoTrack,n=o.id3Track,u=o.textTrack,a=t.pesData,d=c.pesData,v=n.pesData,S;if(a&&(S=e(a))?(this.parseAVCPES(t,u,S,!0),t.pesData=null):t.pesData=a,d&&(S=e(d))){switch(c.segmentCodec){case"aac":this.parseAACPES(c,S);break;case"mp3":this.parseMPEGPES(c,S);break}c.pesData=null}else d!=null&&d.size&&_.logger.log("last AAC PES packet truncated,might overlap between fragments"),c.pesData=d;v&&(S=e(v))?(this.parseID3PES(n,S),n.pesData=null):n.pesData=v},i.demuxSampleAes=function(o,c,t){var n=this.demux(o,t,!0,!this.config.progressive),u=this.sampleAes=new M.default(this.observer,this.config,c);return this.decrypt(n,u)},i.decrypt=function(o,c){return new Promise(function(t){var n=o.audioTrack,u=o.videoTrack;n.samples&&n.segmentCodec==="aac"?c.decryptAacSamples(n.samples,0,function(){u.samples?c.decryptAvcSamples(u.samples,0,0,function(){t(o)}):t(o)}):u.samples&&c.decryptAvcSamples(u.samples,0,0,function(){t(o)})})},i.destroy=function(){this._duration=0},i.parseAVCPES=function(o,c,t,n){var u=this,a=this.parseAVCNALu(o,t.data),d=!1,v=this.avcSample,S,T=!1;t.data=null,v&&a.length&&!o.audFound&&(s(v,o),v=this.avcSample=m(!1,t.pts,t.dts,"")),a.forEach(function(I){switch(I.type){case 1:{S=!0,v||(v=u.avcSample=m(!0,t.pts,t.dts,"")),d&&(v.debug+="NDR "),v.frame=!0;var k=I.data;if(T&&k.length>4){var B=new A.default(k).readSliceType();(B===2||B===4||B===7||B===9)&&(v.key=!0)}break}case 5:S=!0,v||(v=u.avcSample=m(!0,t.pts,t.dts,"")),d&&(v.debug+="IDR "),v.key=!0,v.frame=!0;break;case 6:{S=!0,d&&v&&(v.debug+="SEI "),Object(b.parseSEIMessageFromNALu)(h(I.data),t.pts,c.samples);break}case 7:if(S=!0,T=!0,d&&v&&(v.debug+="SPS "),!o.sps){var U=new A.default(I.data),W=U.readSPS();o.width=W.width,o.height=W.height,o.pixelRatio=W.pixelRatio,o.sps=[I.data],o.duration=u._duration;for(var G=I.data.subarray(1,4),z="avc1.",Y=0;Y<3;Y++){var $=G[Y].toString(16);$.length<2&&($="0"+$),z+=$}o.codec=z}break;case 8:S=!0,d&&v&&(v.debug+="PPS "),o.pps||(o.pps=[I.data]);break;case 9:S=!1,o.audFound=!0,v&&s(v,o),v=u.avcSample=m(!1,t.pts,t.dts,d?"AUD ":"");break;case 12:S=!0;break;default:S=!1,v&&(v.debug+="unknown NAL "+I.type+" ");break}if(v&&S){var Z=v.units;Z.push(I)}}),n&&v&&(s(v,o),this.avcSample=null)},i.getLastNalUnit=function(o){var c,t=this.avcSample,n;if((!t||t.units.length===0)&&(t=o[o.length-1]),(c=t)!==null&&c!==void 0&&c.units){var u=t.units;n=u[u.length-1]}return n},i.parseAVCNALu=function(o,c){var t=c.byteLength,n=o.naluState||0,u=n,a=[],d=0,v,S,T,I=-1,k=0;for(n===-1&&(I=0,k=c[0]&31,n=0,d=1);d<t;){if(v=c[d++],!n){n=v?0:1;continue}if(n===1){n=v?0:2;continue}if(!v)n=3;else if(v===1){if(I>=0){var B={data:c.subarray(I,d-n-1),type:k};a.push(B)}else{var U=this.getLastNalUnit(o.samples);if(U&&(u&&d<=4-u&&U.state&&(U.data=U.data.subarray(0,U.data.byteLength-u)),S=d-n-1,S>0)){var W=new Uint8Array(U.data.byteLength+S);W.set(U.data,0),W.set(c.subarray(0,S),U.data.byteLength),U.data=W,U.state=0}}d<t?(T=c[d]&31,I=d,k=T,n=0):n=-1}else n=0}if(I>=0&&n>=0){var G={data:c.subarray(I,t),type:k,state:n};a.push(G)}if(a.length===0){var z=this.getLastNalUnit(o.samples);if(z){var Y=new Uint8Array(z.data.byteLength+c.byteLength);Y.set(z.data,0),Y.set(c,z.data.byteLength),z.data=Y}}return o.naluState=n,a},i.parseAACPES=function(o,c){var t=0,n=this.aacOverFlow,u=c.data;if(n){this.aacOverFlow=null;var a=n.missing,d=n.sample.unit.byteLength;if(a===-1){var v=new Uint8Array(d+u.byteLength);v.set(n.sample.unit,0),v.set(u,d),u=v}else{var S=d-a;n.sample.unit.set(u.subarray(0,a),S),o.samples.push(n.sample),t=n.missing}}var T,I;for(T=t,I=u.length;T<I-1&&!P.isHeader(u,T);T++);if(T!==t){var k,B;if(T<I-1?(k="AAC PES did not start with ADTS header,offset:"+T,B=!1):(k="no ADTS header found in AAC PES",B=!0),_.logger.warn("parsing error:"+k),this.observer.emit(O.Events.ERROR,O.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:B,reason:k}),B)return}P.initTrackConfig(o,this.observer,u,T,this.audioCodec);var U;if(c.pts!==void 0)U=c.pts;else if(n){var W=P.getFrameDuration(o.samplerate);U=n.sample.pts+W}else{_.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var G=0,z;T<I;)if(z=P.appendFrame(o,u,T,U,G),T+=z.length,z.missing){this.aacOverFlow=z;break}else for(G++;T<I-1&&!P.isHeader(u,T);T++);},i.parseMPEGPES=function(o,c){var t=c.data,n=t.length,u=0,a=0,d=c.pts;if(d===void 0){_.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<n;)if(L.isHeader(t,a)){var v=L.appendFrame(o,t,a,d,u);if(v)a+=v.length,u++;else break}else a++},i.parseID3PES=function(o,c){if(c.pts===void 0){_.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var t=D({},c,{type:this._avcTrack?x.MetadataSchema.emsg:x.MetadataSchema.audioId3});o.samples.push(t)},g}();function m(g,i,r,o){return{key:g,frame:!1,pts:i,dts:r,units:[],debug:o,length:0}}function p(g,i){return(g[i+10]&31)<<8|g[i+11]}function f(g,i,r,o){var c={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},t=(g[i+1]&15)<<8|g[i+2],n=i+3+t-4,u=(g[i+10]&15)<<8|g[i+11];for(i+=12+u;i<n;){var a=(g[i+1]&31)<<8|g[i+2];switch(g[i]){case 207:if(!o){_.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:c.audio===-1&&(c.audio=a);break;case 21:c.id3===-1&&(c.id3=a);break;case 219:if(!o){_.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:c.avc===-1&&(c.avc=a);break;case 3:case 4:r.mpeg!==!0&&r.mp3!==!0?_.logger.log("MPEG audio found, not supported in this browser"):c.audio===-1&&(c.audio=a,c.segmentCodec="mp3");break;case 36:_.logger.warn("Unsupported HEVC stream type found");break;default:break}i+=((g[i+3]&15)<<8|g[i+4])+5}return c}function e(g){var i=0,r,o,c,t,n,u=g.data;if(!g||g.size===0)return null;for(;u[0].length<19&&u.length>1;){var a=new Uint8Array(u[0].length+u[1].length);a.set(u[0]),a.set(u[1],u[0].length),u[0]=a,u.splice(1,1)}r=u[0];var d=(r[0]<<16)+(r[1]<<8)+r[2];if(d===1){if(o=(r[4]<<8)+r[5],o&&o>g.size-6)return null;var v=r[7];v&192&&(t=(r[9]&14)*536870912+(r[10]&255)*4194304+(r[11]&254)*16384+(r[12]&255)*128+(r[13]&254)/2,v&64?(n=(r[14]&14)*536870912+(r[15]&255)*4194304+(r[16]&254)*16384+(r[17]&255)*128+(r[18]&254)/2,t-n>60*9e4&&(_.logger.warn(Math.round((t-n)/9e4)+"s delta between PTS and DTS, align them"),t=n)):n=t),c=r[8];var S=c+9;if(g.size<=S)return null;g.size-=S;for(var T=new Uint8Array(g.size),I=0,k=u.length;I<k;I++){r=u[I];var B=r.byteLength;if(S)if(S>B){S-=B;continue}else r=r.subarray(S),B-=S,S=0;T.set(r,i),i+=B}return o&&(o-=c+3),{data:T,pts:t,dts:n,len:o}}return null}function s(g,i){if(g.units.length&&g.frame){if(g.pts===void 0){var r=i.samples,o=r.length;if(o){var c=r[o-1];g.pts=c.pts,g.dts=c.dts}else{i.dropped++;return}}i.samples.push(g)}g.debug.length&&_.logger.log(g.pts+"/"+g.dts+":"+g.debug)}function h(g){for(var i=g.byteLength,r=[],o=1;o<i-2;)g[o]===0&&g[o+1]===0&&g[o+2]===3?(r.push(o+2),o+=2):o++;if(r.length===0)return g;var c=i-r.length,t=new Uint8Array(c),n=0;for(o=0;o<c;n++,o++)n===r[0]&&(n++,r.shift()),t[o]=g[n];return t}R.default=E},"./src/errors.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"ErrorTypes",function(){return P}),l.d(R,"ErrorDetails",function(){return L});var P;(function(A){A.NETWORK_ERROR="networkError",A.MEDIA_ERROR="mediaError",A.KEY_SYSTEM_ERROR="keySystemError",A.MUX_ERROR="muxError",A.OTHER_ERROR="otherError"})(P||(P={}));var L;(function(A){A.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",A.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",A.KEY_SYSTEM_NO_SESSION="keySystemNoSession",A.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",A.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",A.MANIFEST_LOAD_ERROR="manifestLoadError",A.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",A.MANIFEST_PARSING_ERROR="manifestParsingError",A.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",A.LEVEL_EMPTY_ERROR="levelEmptyError",A.LEVEL_LOAD_ERROR="levelLoadError",A.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",A.LEVEL_SWITCH_ERROR="levelSwitchError",A.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",A.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",A.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",A.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",A.FRAG_LOAD_ERROR="fragLoadError",A.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",A.FRAG_DECRYPT_ERROR="fragDecryptError",A.FRAG_PARSING_ERROR="fragParsingError",A.REMUX_ALLOC_ERROR="remuxAllocError",A.KEY_LOAD_ERROR="keyLoadError",A.KEY_LOAD_TIMEOUT="keyLoadTimeOut",A.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",A.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",A.BUFFER_APPEND_ERROR="bufferAppendError",A.BUFFER_APPENDING_ERROR="bufferAppendingError",A.BUFFER_STALLED_ERROR="bufferStalledError",A.BUFFER_FULL_ERROR="bufferFullError",A.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",A.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",A.INTERNAL_EXCEPTION="internalException",A.INTERNAL_ABORTED="aborted",A.UNKNOWN="unknown"})(L||(L={}))},"./src/events.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"Events",function(){return P});var P;(function(L){L.MEDIA_ATTACHING="hlsMediaAttaching",L.MEDIA_ATTACHED="hlsMediaAttached",L.MEDIA_DETACHING="hlsMediaDetaching",L.MEDIA_DETACHED="hlsMediaDetached",L.BUFFER_RESET="hlsBufferReset",L.BUFFER_CODECS="hlsBufferCodecs",L.BUFFER_CREATED="hlsBufferCreated",L.BUFFER_APPENDING="hlsBufferAppending",L.BUFFER_APPENDED="hlsBufferAppended",L.BUFFER_EOS="hlsBufferEos",L.BUFFER_FLUSHING="hlsBufferFlushing",L.BUFFER_FLUSHED="hlsBufferFlushed",L.MANIFEST_LOADING="hlsManifestLoading",L.MANIFEST_LOADED="hlsManifestLoaded",L.MANIFEST_PARSED="hlsManifestParsed",L.LEVEL_SWITCHING="hlsLevelSwitching",L.LEVEL_SWITCHED="hlsLevelSwitched",L.LEVEL_LOADING="hlsLevelLoading",L.LEVEL_LOADED="hlsLevelLoaded",L.LEVEL_UPDATED="hlsLevelUpdated",L.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",L.LEVELS_UPDATED="hlsLevelsUpdated",L.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",L.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",L.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",L.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",L.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",L.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",L.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",L.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",L.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",L.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",L.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",L.CUES_PARSED="hlsCuesParsed",L.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",L.INIT_PTS_FOUND="hlsInitPtsFound",L.FRAG_LOADING="hlsFragLoading",L.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",L.FRAG_LOADED="hlsFragLoaded",L.FRAG_DECRYPTED="hlsFragDecrypted",L.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",L.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",L.FRAG_PARSING_METADATA="hlsFragParsingMetadata",L.FRAG_PARSED="hlsFragParsed",L.FRAG_BUFFERED="hlsFragBuffered",L.FRAG_CHANGED="hlsFragChanged",L.FPS_DROP="hlsFpsDrop",L.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",L.ERROR="hlsError",L.DESTROYING="hlsDestroying",L.KEY_LOADING="hlsKeyLoading",L.KEY_LOADED="hlsKeyLoaded",L.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",L.BACK_BUFFER_REACHED="hlsBackBufferReached"})(P||(P={}))},"./src/hls.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return i});var P=l("./node_modules/url-toolkit/src/url-toolkit.js"),L=l.n(P),A=l("./src/loader/playlist-loader.ts"),M=l("./src/loader/key-loader.ts"),O=l("./src/controller/id3-track-controller.ts"),b=l("./src/controller/latency-controller.ts"),_=l("./src/controller/level-controller.ts"),y=l("./src/controller/fragment-tracker.ts"),x=l("./src/controller/stream-controller.ts"),D=l("./src/is-supported.ts"),E=l("./src/utils/logger.ts"),m=l("./src/config.ts"),p=l("./node_modules/eventemitter3/index.js"),f=l.n(p),e=l("./src/events.ts"),s=l("./src/errors.ts");function h(r,o){for(var c=0;c<o.length;c++){var t=o[c];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,t.key,t)}}function g(r,o,c){return o&&h(r.prototype,o),c&&h(r,c),Object.defineProperty(r,"prototype",{writable:!1}),r}var i=function(){r.isSupported=function(){return Object(D.isSupported)()};function r(c){c===void 0&&(c={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new p.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var t=this.config=Object(m.mergeConfig)(r.DefaultConfig,c);this.userConfig=c,Object(E.enableLogs)(t.debug),this._autoLevelCapping=-1,t.progressive&&Object(m.enableStreamingMode)(t);var n=t.abrController,u=t.bufferController,a=t.capLevelController,d=t.fpsController,v=this.abrController=new n(this),S=this.bufferController=new u(this),T=this.capLevelController=new a(this),I=new d(this),k=new A.default(this),B=new M.default(this),U=new O.default(this),W=this.levelController=new _.default(this),G=new y.FragmentTracker(this),z=this.streamController=new x.default(this,G);T.setStreamController(z),I.setStreamController(z);var Y=[k,B,W,z];this.networkControllers=Y;var $=[v,S,T,I,U,G];this.audioTrackController=this.createController(t.audioTrackController,null,Y),this.createController(t.audioStreamController,G,Y),this.subtitleTrackController=this.createController(t.subtitleTrackController,null,Y),this.createController(t.subtitleStreamController,G,Y),this.createController(t.timelineController,null,$),this.emeController=this.createController(t.emeController,null,$),this.cmcdController=this.createController(t.cmcdController,null,$),this.latencyController=this.createController(b.default,null,$),this.coreComponents=$}var o=r.prototype;return o.createController=function(t,n,u){if(t){var a=n?new t(this,n):new t(this);return u&&u.push(a),a}return null},o.on=function(t,n,u){u===void 0&&(u=this),this._emitter.on(t,n,u)},o.once=function(t,n,u){u===void 0&&(u=this),this._emitter.once(t,n,u)},o.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},o.off=function(t,n,u,a){u===void 0&&(u=this),this._emitter.off(t,n,u,a)},o.listeners=function(t){return this._emitter.listeners(t)},o.emit=function(t,n,u){return this._emitter.emit(t,n,u)},o.trigger=function(t,n){if(this.config.debug)return this.emit(t,t,n);try{return this.emit(t,t,n)}catch(u){E.logger.error("An internal error happened while handling event "+t+'. Error message: "'+u.message+'". Here is a stacktrace:',u),this.trigger(e.Events.ERROR,{type:s.ErrorTypes.OTHER_ERROR,details:s.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:t,error:u})}return!1},o.listenerCount=function(t){return this._emitter.listenerCount(t)},o.destroy=function(){E.logger.log("destroy"),this.trigger(e.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(t){return t.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(t){return t.destroy()}),this.coreComponents.length=0},o.attachMedia=function(t){E.logger.log("attachMedia"),this._media=t,this.trigger(e.Events.MEDIA_ATTACHING,{media:t})},o.detachMedia=function(){E.logger.log("detachMedia"),this.trigger(e.Events.MEDIA_DETACHING,void 0),this._media=null},o.loadSource=function(t){this.stopLoad();var n=this.media,u=this.url,a=this.url=P.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});E.logger.log("loadSource:"+a),n&&u&&u!==a&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(n)),this.trigger(e.Events.MANIFEST_LOADING,{url:t})},o.startLoad=function(t){t===void 0&&(t=-1),E.logger.log("startLoad("+t+")"),this.networkControllers.forEach(function(n){n.startLoad(t)})},o.stopLoad=function(){E.logger.log("stopLoad"),this.networkControllers.forEach(function(t){t.stopLoad()})},o.swapAudioCodec=function(){E.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},o.recoverMediaError=function(){E.logger.log("recoverMediaError");var t=this._media;this.detachMedia(),t&&this.attachMedia(t)},o.removeLevel=function(t,n){n===void 0&&(n=0),this.levelController.removeLevel(t,n)},g(r,[{key:"levels",get:function(){var t=this.levelController.levels;return t||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){E.logger.log("set currentLevel:"+t),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){E.logger.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){E.logger.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(t){this.levelController.nextLoadLevel=t}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(t){E.logger.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(t){E.logger.log("set startLevel:"+t),t!==-1&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(t){var n=!!t;n!==this.config.capLevelToPlayerSize&&(n?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=n)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(t){this._autoLevelCapping!==t&&(E.logger.log("set autoLevelCapping:"+t),this._autoLevelCapping=t)}},{key:"bandwidthEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var t=this.levels,n=this.config.minAutoBitrate;if(!t)return 0;for(var u=t.length,a=0;a<u;a++)if(t[a].maxBitrate>=n)return a;return 0}},{key:"maxAutoLevel",get:function(){var t=this.levels,n=this.autoLevelCapping,u;return n===-1&&t&&t.length?u=t.length-1:u=n,u}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"audioTracks",get:function(){var t=this.audioTrackController;return t?t.audioTracks:[]}},{key:"audioTrack",get:function(){var t=this.audioTrackController;return t?t.audioTrack:-1},set:function(t){var n=this.audioTrackController;n&&(n.audioTrack=t)}},{key:"subtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1},set:function(t){var n=this.subtitleTrackController;n&&(n.subtitleTrack=t)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var t=this.subtitleTrackController;return t?t.subtitleDisplay:!1},set:function(t){var n=this.subtitleTrackController;n&&(n.subtitleDisplay=t)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(t){this.config.lowLatencyMode=t}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.2.3"}},{key:"Events",get:function(){return e.Events}},{key:"ErrorTypes",get:function(){return s.ErrorTypes}},{key:"ErrorDetails",get:function(){return s.ErrorDetails}},{key:"DefaultConfig",get:function(){return r.defaultConfig?r.defaultConfig:m.hlsDefaultConfig},set:function(t){r.defaultConfig=t}}]),r}();i.defaultConfig=void 0},"./src/is-supported.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"isSupported",function(){return A}),l.d(R,"changeTypeSupported",function(){return M});var P=l("./src/utils/mediasource-helper.ts");function L(){return self.SourceBuffer||self.WebKitSourceBuffer}function A(){var O=Object(P.getMediaSource)();if(!O)return!1;var b=L(),_=O&&typeof O.isTypeSupported=="function"&&O.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),y=!b||b.prototype&&typeof b.prototype.appendBuffer=="function"&&typeof b.prototype.remove=="function";return!!_&&!!y}function M(){var O,b=L();return typeof(b==null||(O=b.prototype)===null||O===void 0?void 0:O.changeType)=="function"}},"./src/loader/date-range.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"DateRangeAttribute",function(){return _}),l.d(R,"DateRange",function(){return y});var P=l("./src/polyfills/number.ts"),L=l("./src/utils/attr-list.ts"),A=l("./src/utils/logger.ts");function M(){return M=Object.assign?Object.assign.bind():function(x){for(var D=1;D<arguments.length;D++){var E=arguments[D];for(var m in E)Object.prototype.hasOwnProperty.call(E,m)&&(x[m]=E[m])}return x},M.apply(this,arguments)}function O(x,D){for(var E=0;E<D.length;E++){var m=D[E];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(x,m.key,m)}}function b(x,D,E){return D&&O(x.prototype,D),E&&O(x,E),Object.defineProperty(x,"prototype",{writable:!1}),x}var _;(function(x){x.ID="ID",x.CLASS="CLASS",x.START_DATE="START-DATE",x.DURATION="DURATION",x.END_DATE="END-DATE",x.END_ON_NEXT="END-ON-NEXT",x.PLANNED_DURATION="PLANNED-DURATION",x.SCTE35_OUT="SCTE35-OUT",x.SCTE35_IN="SCTE35-IN"})(_||(_={}));var y=function(){function x(D,E){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,E){var m=E.attr;for(var p in m)if(Object.prototype.hasOwnProperty.call(D,p)&&D[p]!==m[p]){A.logger.warn('DATERANGE tag attribute: "'+p+'" does not match for tags with ID: "'+D.ID+'"'),this._badValueForSameId=p;break}D=M(new L.AttrList({}),m,D)}if(this.attr=D,this._startDate=new Date(D[_.START_DATE]),_.END_DATE in this.attr){var f=new Date(this.attr[_.END_DATE]);Object(P.isFiniteNumber)(f.getTime())&&(this._endDate=f)}}return b(x,[{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 E=this.duration;return E!==null?new Date(this._startDate.getTime()+E*1e3):null}},{key:"duration",get:function(){if(_.DURATION in this.attr){var E=this.attr.decimalFloatingPoint(_.DURATION);if(Object(P.isFiniteNumber)(E))return E}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(P.isFiniteNumber)(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),x}()},"./src/loader/fragment-loader.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return E}),l.d(R,"LoadError",function(){return p});var P=l("./src/polyfills/number.ts"),L=l("./src/errors.ts");function A(f,e){f.prototype=Object.create(e.prototype),f.prototype.constructor=f,y(f,e)}function M(f){var e=typeof Map=="function"?new Map:void 0;return M=function(h){if(h===null||!_(h))return h;if(typeof h!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e!="undefined"){if(e.has(h))return e.get(h);e.set(h,g)}function g(){return O(h,arguments,x(this).constructor)}return g.prototype=Object.create(h.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),y(g,h)},M(f)}function O(f,e,s){return b()?O=Reflect.construct.bind():O=function(g,i,r){var o=[null];o.push.apply(o,i);var c=Function.bind.apply(g,o),t=new c;return r&&y(t,r.prototype),t},O.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 _(f){return Function.toString.call(f).indexOf("[native code]")!==-1}function y(f,e){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(h,g){return h.__proto__=g,h},y(f,e)}function x(f){return x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(s){return s.__proto__||Object.getPrototypeOf(s)},x(f)}var D=Math.pow(2,17),E=function(){function f(s){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=s}var e=f.prototype;return e.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},e.abort=function(){this.loader&&this.loader.abort()},e.load=function(h,g){var i=this,r=h.url;if(!r)return Promise.reject(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,networkDetails:null},"Fragment does not have a "+(r?"part list":"url")));this.abort();var o=this.config,c=o.fLoader,t=o.loader;return new Promise(function(n,u){i.loader&&i.loader.destroy();var a=i.loader=h.loader=c?new c(o):new t(o),d=m(h),v={timeout:o.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:o.fragLoadingMaxRetryTimeout,highWaterMark:h.sn==="initSegment"?1/0:D};h.stats=a.stats,a.load(d,v,{onSuccess:function(T,I,k,B){i.resetLoader(h,a),n({frag:h,part:null,payload:T.data,networkDetails:B})},onError:function(T,I,k){i.resetLoader(h,a),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,response:T,networkDetails:k}))},onAbort:function(T,I,k){i.resetLoader(h,a),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,networkDetails:k}))},onTimeout:function(T,I,k){i.resetLoader(h,a),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,networkDetails:k}))},onProgress:function(T,I,k,B){g&&g({frag:h,part:null,payload:k,networkDetails:B})}})})},e.loadPart=function(h,g,i){var r=this;this.abort();var o=this.config,c=o.fLoader,t=o.loader;return new Promise(function(n,u){r.loader&&r.loader.destroy();var a=r.loader=h.loader=c?new c(o):new t(o),d=m(h,g),v={timeout:o.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:o.fragLoadingMaxRetryTimeout,highWaterMark:D};g.stats=a.stats,a.load(d,v,{onSuccess:function(T,I,k,B){r.resetLoader(h,a),r.updateStatsFromPart(h,g);var U={frag:h,part:g,payload:T.data,networkDetails:B};i(U),n(U)},onError:function(T,I,k){r.resetLoader(h,a),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,part:g,response:T,networkDetails:k}))},onAbort:function(T,I,k){h.stats.aborted=g.stats.aborted,r.resetLoader(h,a),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,part:g,networkDetails:k}))},onTimeout:function(T,I,k){r.resetLoader(h,a),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,part:g,networkDetails:k}))}})})},e.updateStatsFromPart=function(h,g){var i=h.stats,r=g.stats,o=r.total;if(i.loaded+=r.loaded,o){var c=Math.round(h.duration/g.duration),t=Math.min(Math.round(i.loaded/o),c),n=c-t,u=n*Math.round(i.loaded/t);i.total=i.loaded+u}else i.total=Math.max(i.loaded,i.total);var a=i.loading,d=r.loading;a.start?a.first+=d.first-d.start:(a.start=d.start,a.first=d.first),a.end=d.end},e.resetLoader=function(h,g){h.loader=null,this.loader===g&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),g.destroy()},f}();function m(f,e){e===void 0&&(e=null);var s=e||f,h={frag:f,part:e,responseType:"arraybuffer",url:s.url,headers:{},rangeStart:0,rangeEnd:0},g=s.byteRangeStartOffset,i=s.byteRangeEndOffset;return Object(P.isFiniteNumber)(g)&&Object(P.isFiniteNumber)(i)&&(h.rangeStart=g,h.rangeEnd=i),h}var p=function(f){A(e,f);function e(s){for(var h,g=arguments.length,i=new Array(g>1?g-1:0),r=1;r<g;r++)i[r-1]=arguments[r];return h=f.call.apply(f,[this].concat(i))||this,h.data=void 0,h.data=s,h}return e}(M(Error))},"./src/loader/fragment.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"ElementaryStreamTypes",function(){return E}),l.d(R,"BaseSegment",function(){return m}),l.d(R,"Fragment",function(){return p}),l.d(R,"Part",function(){return f});var P=l("./src/polyfills/number.ts"),L=l("./node_modules/url-toolkit/src/url-toolkit.js"),A=l.n(L),M=l("./src/utils/logger.ts"),O=l("./src/loader/level-key.ts"),b=l("./src/loader/load-stats.ts");function _(e,s){e.prototype=Object.create(s.prototype),e.prototype.constructor=e,y(e,s)}function y(e,s){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,i){return g.__proto__=i,g},y(e,s)}function x(e,s){for(var h=0;h<s.length;h++){var g=s[h];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(e,g.key,g)}}function D(e,s,h){return s&&x(e.prototype,s),h&&x(e,h),Object.defineProperty(e,"prototype",{writable:!1}),e}var E;(function(e){e.AUDIO="audio",e.VIDEO="video",e.AUDIOVIDEO="audiovideo"})(E||(E={}));var m=function(){function e(h){var g;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(g={},g[E.AUDIO]=null,g[E.VIDEO]=null,g[E.AUDIOVIDEO]=null,g),this.baseurl=h}var s=e.prototype;return s.setByteRange=function(g,i){var r=g.split("@",2),o=[];r.length===1?o[0]=i?i.byteRangeEndOffset:0:o[0]=parseInt(r[1]),o[1]=parseInt(r[0])+o[0],this._byteRange=o},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(L.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(g){this._url=g}}]),e}(),p=function(e){_(s,e);function s(g,i){var r;return r=e.call(this,i)||this,r._decryptdata=null,r.rawProgramDateTime=null,r.programDateTime=null,r.tagList=[],r.duration=0,r.sn=0,r.levelkey=void 0,r.type=void 0,r.loader=null,r.level=-1,r.cc=0,r.startPTS=void 0,r.endPTS=void 0,r.appendedPTS=void 0,r.startDTS=void 0,r.endDTS=void 0,r.start=0,r.deltaPTS=void 0,r.maxStartPTS=void 0,r.minEndPTS=void 0,r.stats=new b.LoadStats,r.urlId=0,r.data=void 0,r.bitrateTest=!1,r.title=null,r.initSegment=null,r.type=g,r}var h=s.prototype;return h.createInitializationVector=function(i){for(var r=new Uint8Array(16),o=12;o<16;o++)r[o]=i>>8*(15-o)&255;return r},h.setDecryptDataFromLevelKey=function(i,r){var o=i;return(i==null?void 0:i.method)==="AES-128"&&i.uri&&!i.iv&&(o=O.LevelKey.fromURI(i.uri),o.method=i.method,o.iv=this.createInitializationVector(r),o.keyFormat="identity"),o},h.setElementaryStreamInfo=function(i,r,o,c,t,n){n===void 0&&(n=!1);var u=this.elementaryStreams,a=u[i];if(!a){u[i]={startPTS:r,endPTS:o,startDTS:c,endDTS:t,partial:n};return}a.startPTS=Math.min(a.startPTS,r),a.endPTS=Math.max(a.endPTS,o),a.startDTS=Math.min(a.startDTS,c),a.endDTS=Math.max(a.endDTS,t)},h.clearElementaryStreamInfo=function(){var i=this.elementaryStreams;i[E.AUDIO]=null,i[E.VIDEO]=null,i[E.AUDIOVIDEO]=null},D(s,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var i=this.sn;typeof i!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&M.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(P.isFiniteNumber)(this.programDateTime))return null;var i=Object(P.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+i*1e3}},{key:"encrypted",get:function(){var i;return!!((i=this.decryptdata)!==null&&i!==void 0&&i.keyFormat&&this.decryptdata.uri)}}]),s}(m),f=function(e){_(s,e);function s(h,g,i,r,o){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=h.decimalFloatingPoint("DURATION"),c.gap=h.bool("GAP"),c.independent=h.bool("INDEPENDENT"),c.relurl=h.enumeratedString("URI"),c.fragment=g,c.index=r;var t=h.enumeratedString("BYTERANGE");return t&&c.setByteRange(t,o),o&&(c.fragOffset=o.fragOffset+o.duration),c}return D(s,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var g=this.elementaryStreams;return!!(g.audio||g.video||g.audiovideo)}}]),s}(m)},"./src/loader/key-loader.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return M});var P=l("./src/events.ts"),L=l("./src/errors.ts"),A=l("./src/utils/logger.ts"),M=function(){function O(_){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=_,this.registerListeners()}var b=O.prototype;return b.startLoad=function(y){},b.stopLoad=function(){this.destroyInternalLoaders()},b.registerListeners=function(){this.hls.on(P.Events.KEY_LOADING,this.onKeyLoading,this)},b.unregisterListeners=function(){this.hls.off(P.Events.KEY_LOADING,this.onKeyLoading)},b.destroyInternalLoaders=function(){for(var y in this.loaders){var x=this.loaders[y];x&&x.destroy()}this.loaders={}},b.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},b.onKeyLoading=function(y,x){var D=x.frag,E=D.type,m=this.loaders[E];if(!D.decryptdata){A.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var p=D.decryptdata.uri;if(p!==this.decrypturl||this.decryptkey===null){var f=this.hls.config;if(m&&(A.logger.warn("abort previous key loader for type:"+E),m.abort()),!p){A.logger.warn("key uri is falsy");return}var e=f.loader,s=D.loader=this.loaders[E]=new e(f);this.decrypturl=p,this.decryptkey=null;var h={url:p,frag:D,responseType:"arraybuffer"},g={timeout:f.fragLoadingTimeOut,maxRetry:0,retryDelay:f.fragLoadingRetryDelay,maxRetryDelay:f.fragLoadingMaxRetryTimeout,highWaterMark:0},i={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};s.load(h,g,i)}else this.decryptkey&&(D.decryptdata.key=this.decryptkey,this.hls.trigger(P.Events.KEY_LOADED,{frag:D}))},b.loadsuccess=function(y,x,D){var E=D.frag;if(!E.decryptdata){A.logger.error("after key load, decryptdata unset");return}this.decryptkey=E.decryptdata.key=new Uint8Array(y.data),E.loader=null,delete this.loaders[E.type],this.hls.trigger(P.Events.KEY_LOADED,{frag:E})},b.loaderror=function(y,x){var D=x.frag,E=D.loader;E&&E.abort(),delete this.loaders[D.type],this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:D,response:y})},b.loadtimeout=function(y,x){var D=x.frag,E=D.loader;E&&E.abort(),delete this.loaders[D.type],this.hls.trigger(P.Events.ERROR,{type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:D})},O}()},"./src/loader/level-details.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"LevelDetails",function(){return O});var P=l("./src/polyfills/number.ts");function L(b,_){for(var y=0;y<_.length;y++){var x=_[y];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(b,x.key,x)}}function A(b,_,y){return _&&L(b.prototype,_),y&&L(b,y),Object.defineProperty(b,"prototype",{writable:!1}),b}var M=10,O=function(){function b(y){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.needSidxRanges=!1,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.fragments=[],this.dateRanges={},this.url=y}var _=b.prototype;return _.reloaded=function(x){if(!x){this.advanced=!0,this.updated=!0;return}var D=this.lastPartSn-x.lastPartSn,E=this.lastPartIndex-x.lastPartIndex;this.updated=this.endSN!==x.endSN||!!E||!!D,this.advanced=this.endSN>x.endSN||D>0||D===0&&E>0,this.updated||this.advanced?this.misses=Math.floor(x.misses*.6):this.misses=x.misses+1,this.availabilityDelay=x.availabilityDelay},A(b,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(P.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||M}},{key:"drift",get:function(){var x=this.driftEndTime-this.driftStartTime;if(x>0){var D=this.driftEnd-this.driftStart;return D*1e3/x}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var x;return(x=this.partList)!==null&&x!==void 0&&x.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var x;return(x=this.fragments)!==null&&x!==void 0&&x.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 x;return(x=this.partList)!==null&&x!==void 0&&x.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var x;return(x=this.partList)!==null&&x!==void 0&&x.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),b}()},"./src/loader/level-key.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"LevelKey",function(){return O});var P=l("./node_modules/url-toolkit/src/url-toolkit.js"),L=l.n(P);function A(b,_){for(var y=0;y<_.length;y++){var x=_[y];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(b,x.key,x)}}function M(b,_,y){return _&&A(b.prototype,_),y&&A(b,y),Object.defineProperty(b,"prototype",{writable:!1}),b}var O=function(){b.fromURL=function(y,x){return new b(y,x)},b.fromURI=function(y){return new b(y)};function b(_,y){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,y?this._uri=Object(P.buildAbsoluteURL)(_,y,{alwaysNormalize:!0}):this._uri=_}return M(b,[{key:"uri",get:function(){return this._uri}}]),b}()},"./src/loader/load-stats.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"LoadStats",function(){return P});var P=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(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return h});var P=l("./src/polyfills/number.ts"),L=l("./node_modules/url-toolkit/src/url-toolkit.js"),A=l.n(L),M=l("./src/loader/date-range.ts"),O=l("./src/loader/fragment.ts"),b=l("./src/loader/level-details.ts"),_=l("./src/loader/level-key.ts"),y=l("./src/utils/attr-list.ts"),x=l("./src/utils/logger.ts"),D=l("./src/utils/codecs.ts"),E=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,m=/#EXT-X-MEDIA:(.*)/g,p=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),f=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),e=/\.(mp4|m4s|m4v|m4a)$/i;function s(t){var n,u;return e.test((n=(u=L.parseURL(t))===null||u===void 0?void 0:u.path)!=null?n:"")}var h=function(){function t(){}return t.findGroup=function(u,a){for(var d=0;d<u.length;d++){var v=u[d];if(v.id===a)return v}},t.convertAVC1ToAVCOTI=function(u){var a=u.split(".");if(a.length>2){var d=a.shift()+".";return d+=parseInt(a.shift()).toString(16),d+=("000"+parseInt(a.shift()).toString(16)).slice(-4),d}return u},t.resolve=function(u,a){return L.buildAbsoluteURL(a,u,{alwaysNormalize:!0})},t.parseMasterPlaylist=function(u,a){var d=[],v={},S=!1;E.lastIndex=0;for(var T;(T=E.exec(u))!=null;)if(T[1]){var I=new y.AttrList(T[1]),k={attrs:I,bitrate:I.decimalInteger("AVERAGE-BANDWIDTH")||I.decimalInteger("BANDWIDTH"),name:I.NAME,url:t.resolve(T[2],a)},B=I.decimalResolution("RESOLUTION");B&&(k.width=B.width,k.height=B.height),g((I.CODECS||"").split(/[ ,]+/).filter(function(W){return W}),k),k.videoCodec&&k.videoCodec.indexOf("avc1")!==-1&&(k.videoCodec=t.convertAVC1ToAVCOTI(k.videoCodec)),d.push(k)}else if(T[3]){var U=new y.AttrList(T[3]);U["DATA-ID"]&&(S=!0,v[U["DATA-ID"]]=U)}return{levels:d,sessionData:S?v:null}},t.parseMasterPlaylistMedia=function(u,a,d,v){v===void 0&&(v=[]);var S,T=[],I=0;for(m.lastIndex=0;(S=m.exec(u))!==null;){var k=new y.AttrList(S[1]);if(k.TYPE===d){var B={attrs:k,bitrate:0,id:I++,groupId:k["GROUP-ID"],instreamId:k["INSTREAM-ID"],name:k.NAME||k.LANGUAGE||"",type:d,default:k.bool("DEFAULT"),autoselect:k.bool("AUTOSELECT"),forced:k.bool("FORCED"),lang:k.LANGUAGE,url:k.URI?t.resolve(k.URI,a):""};if(v.length){var U=t.findGroup(v,B.groupId)||v[0];i(B,U,"audioCodec"),i(B,U,"textCodec")}T.push(B)}}return T},t.parseLevelPlaylist=function(u,a,d,v,S){var T=new b.LevelDetails(a),I=T.fragments,k=null,B=0,U=0,W=0,G=0,z=null,Y=new O.Fragment(v,a),$,Z,q,ie=-1,ne=!1;for(p.lastIndex=0,T.m3u8=u;($=p.exec(u))!==null;){ne&&(ne=!1,Y=new O.Fragment(v,a),Y.start=W,Y.sn=B,Y.cc=G,Y.level=d,k&&(Y.initSegment=k,Y.rawProgramDateTime=k.rawProgramDateTime,k.rawProgramDateTime=null));var ae=$[1];if(ae){Y.duration=parseFloat(ae);var te=(" "+$[2]).slice(1);Y.title=te||null,Y.tagList.push(te?["INF",ae,te]:["INF",ae])}else if($[3])Object(P.isFiniteNumber)(Y.duration)&&(Y.start=W,q&&(Y.levelkey=q),Y.sn=B,Y.level=d,Y.cc=G,Y.urlId=S,I.push(Y),Y.relurl=(" "+$[3]).slice(1),o(Y,z),z=Y,W+=Y.duration,B++,U=0,ne=!0);else if($[4]){var fe=(" "+$[4]).slice(1);z?Y.setByteRange(fe,z):Y.setByteRange(fe)}else if($[5])Y.rawProgramDateTime=(" "+$[5]).slice(1),Y.tagList.push(["PROGRAM-DATE-TIME",Y.rawProgramDateTime]),ie===-1&&(ie=I.length);else{if($=$[0].match(f),!$){x.logger.warn("No matches on slow regex match for level playlist!");continue}for(Z=1;Z<$.length&&typeof $[Z]=="undefined";Z++);var de=(" "+$[Z]).slice(1),re=(" "+$[Z+1]).slice(1),Ee=$[Z+2]?(" "+$[Z+2]).slice(1):"";switch(de){case"PLAYLIST-TYPE":T.type=re.toUpperCase();break;case"MEDIA-SEQUENCE":B=T.startSN=parseInt(re);break;case"SKIP":{var me=new y.AttrList(re),Te=me.decimalInteger("SKIPPED-SEGMENTS");if(Object(P.isFiniteNumber)(Te)){T.skippedSegments=Te;for(var Me=Te;Me--;)I.unshift(null);B+=Te}var _e=me.enumeratedString("RECENTLY-REMOVED-DATERANGES");_e&&(T.recentlyRemovedDateranges=_e.split(" "));break}case"TARGETDURATION":T.targetduration=parseFloat(re);break;case"VERSION":T.version=parseInt(re);break;case"EXTM3U":break;case"ENDLIST":T.live=!1;break;case"#":(re||Ee)&&Y.tagList.push(Ee?[re,Ee]:[re]);break;case"DISCONTINUITY":G++,Y.tagList.push(["DIS"]);break;case"GAP":Y.tagList.push([de]);break;case"BITRATE":Y.tagList.push([de,re]);break;case"DATERANGE":{var ke=new y.AttrList(re),Ie=new M.DateRange(ke,T.dateRanges[ke.ID]);Ie.isValid||T.skippedSegments?T.dateRanges[Ie.id]=Ie:x.logger.warn('Ignoring invalid DATERANGE tag: "'+re+'"'),Y.tagList.push(["EXT-X-DATERANGE",re]);break}case"DISCONTINUITY-SEQUENCE":G=parseInt(re);break;case"KEY":{var Be,be=new y.AttrList(re),Ue=be.enumeratedString("METHOD"),Ke=be.URI,je=be.hexadecimalInteger("IV"),Ne=be.enumeratedString("KEYFORMATVERSIONS"),qe=be.enumeratedString("KEYID"),Fe=(Be=be.enumeratedString("KEYFORMAT"))!=null?Be:"identity",et=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(et.indexOf(Fe)>-1){x.logger.warn("Keyformat "+Fe+" is not supported from the manifest");continue}else if(Fe!=="identity")continue;Ue&&(q=_.LevelKey.fromURL(a,Ke),Ke&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(Ue)>=0&&(q.method=Ue,q.keyFormat=Fe,qe&&(q.keyID=qe),Ne&&(q.keyFormatVersions=Ne),q.iv=je));break}case"START":{var Oe=new y.AttrList(re),Pe=Oe.decimalFloatingPoint("TIME-OFFSET");Object(P.isFiniteNumber)(Pe)&&(T.startTimeOffset=Pe);break}case"MAP":{var Ve=new y.AttrList(re);if(Y.duration){var Ce=new O.Fragment(v,a);c(Ce,Ve,d,q),k=Ce,Y.initSegment=k,k.rawProgramDateTime&&!Y.rawProgramDateTime&&(Y.rawProgramDateTime=k.rawProgramDateTime)}else c(Y,Ve,d,q),k=Y,ne=!0;break}case"SERVER-CONTROL":{var Le=new y.AttrList(re);T.canBlockReload=Le.bool("CAN-BLOCK-RELOAD"),T.canSkipUntil=Le.optionalFloat("CAN-SKIP-UNTIL",0),T.canSkipDateRanges=T.canSkipUntil>0&&Le.bool("CAN-SKIP-DATERANGES"),T.partHoldBack=Le.optionalFloat("PART-HOLD-BACK",0),T.holdBack=Le.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var it=new y.AttrList(re);T.partTarget=it.decimalFloatingPoint("PART-TARGET");break}case"PART":{var We=T.partList;We||(We=T.partList=[]);var ot=U>0?We[We.length-1]:void 0,gt=U++,Xe=new O.Part(new y.AttrList(re),Y,a,gt,ot);We.push(Xe),Y.duration+=Xe.duration;break}case"PRELOAD-HINT":{var Dt=new y.AttrList(re);T.preloadHint=Dt;break}case"RENDITION-REPORT":{var mt=new y.AttrList(re);T.renditionReports=T.renditionReports||[],T.renditionReports.push(mt);break}default:x.logger.warn("line parsed but not handled: "+$);break}}}z&&!z.relurl?(I.pop(),W-=z.duration,T.partList&&(T.fragmentHint=z)):T.partList&&(o(Y,z),Y.cc=G,T.fragmentHint=Y);var nt=I.length,lt=I[0],at=I[nt-1];if(W+=T.skippedSegments*T.targetduration,W>0&&nt&&at){T.averagetargetduration=W/nt;var pt=at.sn;T.endSN=pt!=="initSegment"?pt:0,lt&&(T.startCC=lt.cc,lt.initSegment||T.fragments.every(function(vt){return vt.relurl&&s(vt.relurl)})&&(x.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),Y=new O.Fragment(v,a),Y.relurl=at.relurl,Y.level=d,Y.sn="initSegment",lt.initSegment=Y,T.needSidxRanges=!0))}else T.endSN=0,T.startCC=0;return T.fragmentHint&&(W+=T.fragmentHint.duration),T.totalduration=W,T.endCC=G,ie>0&&r(I,ie),T},t}();function g(t,n){["video","audio","text"].forEach(function(u){var a=t.filter(function(v){return Object(D.isCodecType)(v,u)});if(a.length){var d=a.filter(function(v){return v.lastIndexOf("avc1",0)===0||v.lastIndexOf("mp4a",0)===0});n[u+"Codec"]=d.length>0?d[0]:a[0],t=t.filter(function(v){return a.indexOf(v)===-1})}}),n.unknownCodecs=t}function i(t,n,u){var a=n[u];a&&(t[u]=a)}function r(t,n){for(var u=t[n],a=n;a--;){var d=t[a];if(!d)return;d.programDateTime=u.programDateTime-d.duration*1e3,u=d}}function o(t,n){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):n!=null&&n.programDateTime&&(t.programDateTime=n.endProgramDateTime),Object(P.isFiniteNumber)(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}function c(t,n,u,a){t.relurl=n.URI,n.BYTERANGE&&t.setByteRange(n.BYTERANGE),t.level=u,t.sn="initSegment",a&&(t.levelkey=a),t.initSegment=null}},"./src/loader/playlist-loader.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/polyfills/number.ts"),L=l("./src/events.ts"),A=l("./src/errors.ts"),M=l("./src/utils/logger.ts"),O=l("./src/utils/mp4-tools.ts"),b=l("./src/loader/m3u8-parser.ts"),_=l("./src/types/loader.ts"),y=l("./src/utils/attr-list.ts");function x(m){var p=m.type;switch(p){case _.PlaylistContextType.AUDIO_TRACK:return _.PlaylistLevelType.AUDIO;case _.PlaylistContextType.SUBTITLE_TRACK:return _.PlaylistLevelType.SUBTITLE;default:return _.PlaylistLevelType.MAIN}}function D(m,p){var f=m.url;return(f===void 0||f.indexOf("data:")===0)&&(f=p.url),f}var E=function(){function m(f){this.hls=void 0,this.loaders=Object.create(null),this.hls=f,this.registerListeners()}var p=m.prototype;return p.startLoad=function(e){},p.stopLoad=function(){this.destroyInternalLoaders()},p.registerListeners=function(){var e=this.hls;e.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(L.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(L.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(L.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.unregisterListeners=function(){var e=this.hls;e.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(L.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(L.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(L.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.createInternalLoader=function(e){var s=this.hls.config,h=s.pLoader,g=s.loader,i=h||g,r=new i(s);return e.loader=r,this.loaders[e.type]=r,r},p.getInternalLoader=function(e){return this.loaders[e.type]},p.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},p.destroyInternalLoaders=function(){for(var e in this.loaders){var s=this.loaders[e];s&&s.destroy(),this.resetInternalLoader(e)}},p.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},p.onManifestLoading=function(e,s){var h=s.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:_.PlaylistContextType.MANIFEST,url:h,deliveryDirectives:null})},p.onLevelLoading=function(e,s){var h=s.id,g=s.level,i=s.url,r=s.deliveryDirectives;this.load({id:h,groupId:null,level:g,responseType:"text",type:_.PlaylistContextType.LEVEL,url:i,deliveryDirectives:r})},p.onAudioTrackLoading=function(e,s){var h=s.id,g=s.groupId,i=s.url,r=s.deliveryDirectives;this.load({id:h,groupId:g,level:null,responseType:"text",type:_.PlaylistContextType.AUDIO_TRACK,url:i,deliveryDirectives:r})},p.onSubtitleTrackLoading=function(e,s){var h=s.id,g=s.groupId,i=s.url,r=s.deliveryDirectives;this.load({id:h,groupId:g,level:null,responseType:"text",type:_.PlaylistContextType.SUBTITLE_TRACK,url:i,deliveryDirectives:r})},p.load=function(e){var s,h=this.hls.config,g=this.getInternalLoader(e);if(g){var i=g.context;if(i&&i.url===e.url){M.logger.trace("[playlist-loader]: playlist request ongoing");return}M.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),g.abort()}var r,o,c,t;switch(e.type){case _.PlaylistContextType.MANIFEST:r=h.manifestLoadingMaxRetry,o=h.manifestLoadingTimeOut,c=h.manifestLoadingRetryDelay,t=h.manifestLoadingMaxRetryTimeout;break;case _.PlaylistContextType.LEVEL:case _.PlaylistContextType.AUDIO_TRACK:case _.PlaylistContextType.SUBTITLE_TRACK:r=0,o=h.levelLoadingTimeOut;break;default:r=h.levelLoadingMaxRetry,o=h.levelLoadingTimeOut,c=h.levelLoadingRetryDelay,t=h.levelLoadingMaxRetryTimeout;break}if(g=this.createInternalLoader(e),(s=e.deliveryDirectives)!==null&&s!==void 0&&s.part){var n;if(e.type===_.PlaylistContextType.LEVEL&&e.level!==null?n=this.hls.levels[e.level].details:e.type===_.PlaylistContextType.AUDIO_TRACK&&e.id!==null?n=this.hls.audioTracks[e.id].details:e.type===_.PlaylistContextType.SUBTITLE_TRACK&&e.id!==null&&(n=this.hls.subtitleTracks[e.id].details),n){var u=n.partTarget,a=n.targetduration;u&&a&&(o=Math.min(Math.max(u*3,a*.8)*1e3,o))}}var d={timeout:o,maxRetry:r,retryDelay:c,maxRetryDelay:t,highWaterMark:0},v={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};g.load(e,d,v)},p.loadsuccess=function(e,s,h,g){if(g===void 0&&(g=null),h.isSidxRequest){this.handleSidxRequest(e,h),this.handlePlaylistLoaded(e,s,h,g);return}this.resetInternalLoader(h.type);var i=e.data;if(i.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(e,h,"no EXTM3U delimiter",g);return}s.parsing.start=performance.now(),i.indexOf("#EXTINF:")>0||i.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,s,h,g):this.handleMasterPlaylist(e,s,h,g)},p.loaderror=function(e,s,h){h===void 0&&(h=null),this.handleNetworkError(s,h,!1,e)},p.loadtimeout=function(e,s,h){h===void 0&&(h=null),this.handleNetworkError(s,h,!0)},p.handleMasterPlaylist=function(e,s,h,g){var i=this.hls,r=e.data,o=D(e,h),c=b.default.parseMasterPlaylist(r,o),t=c.levels,n=c.sessionData;if(!t.length){this.handleManifestParsingError(e,h,"no level found in manifest",g);return}var u=t.map(function(I){return{id:I.attrs.AUDIO,audioCodec:I.audioCodec}}),a=t.map(function(I){return{id:I.attrs.SUBTITLES,textCodec:I.textCodec}}),d=b.default.parseMasterPlaylistMedia(r,o,"AUDIO",u),v=b.default.parseMasterPlaylistMedia(r,o,"SUBTITLES",a),S=b.default.parseMasterPlaylistMedia(r,o,"CLOSED-CAPTIONS");if(d.length){var T=d.some(function(I){return!I.url});!T&&t[0].audioCodec&&!t[0].attrs.AUDIO&&(M.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),d.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new y.AttrList({}),bitrate:0,url:""}))}i.trigger(L.Events.MANIFEST_LOADED,{levels:t,audioTracks:d,subtitles:v,captions:S,url:o,stats:s,networkDetails:g,sessionData:n})},p.handleTrackOrLevelPlaylist=function(e,s,h,g){var i=this.hls,r=h.id,o=h.level,c=h.type,t=D(e,h),n=Object(P.isFiniteNumber)(r)?r:0,u=Object(P.isFiniteNumber)(o)?o:n,a=x(h),d=b.default.parseLevelPlaylist(e.data,t,u,a,n);if(!d.fragments.length){i.trigger(L.Events.ERROR,{type:A.ErrorTypes.NETWORK_ERROR,details:A.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:t,reason:"no fragments found in level",level:typeof h.level=="number"?h.level:void 0});return}if(c===_.PlaylistContextType.MANIFEST){var v={attrs:new y.AttrList({}),bitrate:0,details:d,name:"",url:t};i.trigger(L.Events.MANIFEST_LOADED,{levels:[v],audioTracks:[],url:t,stats:s,networkDetails:g,sessionData:null})}if(s.parsing.end=performance.now(),d.needSidxRanges){var S,T=(S=d.fragments[0].initSegment)===null||S===void 0?void 0:S.url;this.load({url:T,isSidxRequest:!0,type:c,level:o,levelDetails:d,id:r,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}h.levelDetails=d,this.handlePlaylistLoaded(e,s,h,g)},p.handleSidxRequest=function(e,s){var h=new Uint8Array(e.data),g=Object(O.findBox)(h,["sidx"])[0];if(!!g){var i=Object(O.parseSegmentIndex)(g);if(!!i){var r=i.references,o=s.levelDetails;r.forEach(function(c,t){var n=c.info,u=o.fragments[t];if(u.byteRange.length===0&&u.setByteRange(String(1+n.end-n.start)+"@"+String(n.start)),u.initSegment){var a=Object(O.findBox)(h,["moov"])[0],d=a?a.length:null;u.initSegment.setByteRange(String(d)+"@0")}})}}},p.handleManifestParsingError=function(e,s,h,g){this.hls.trigger(L.Events.ERROR,{type:A.ErrorTypes.NETWORK_ERROR,details:A.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:s.type===_.PlaylistContextType.MANIFEST,url:e.url,reason:h,response:e,context:s,networkDetails:g})},p.handleNetworkError=function(e,s,h,g){h===void 0&&(h=!1),M.logger.warn("[playlist-loader]: A network "+(h?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var i=A.ErrorDetails.UNKNOWN,r=!1,o=this.getInternalLoader(e);switch(e.type){case _.PlaylistContextType.MANIFEST:i=h?A.ErrorDetails.MANIFEST_LOAD_TIMEOUT:A.ErrorDetails.MANIFEST_LOAD_ERROR,r=!0;break;case _.PlaylistContextType.LEVEL:i=h?A.ErrorDetails.LEVEL_LOAD_TIMEOUT:A.ErrorDetails.LEVEL_LOAD_ERROR,r=!1;break;case _.PlaylistContextType.AUDIO_TRACK:i=h?A.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:A.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,r=!1;break;case _.PlaylistContextType.SUBTITLE_TRACK:i=h?A.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:A.ErrorDetails.SUBTITLE_LOAD_ERROR,r=!1;break}o&&this.resetInternalLoader(e.type);var c={type:A.ErrorTypes.NETWORK_ERROR,details:i,fatal:r,url:e.url,loader:o,context:e,networkDetails:s};g&&(c.response=g),this.hls.trigger(L.Events.ERROR,c)},p.handlePlaylistLoaded=function(e,s,h,g){var i=h.type,r=h.level,o=h.id,c=h.groupId,t=h.loader,n=h.levelDetails,u=h.deliveryDirectives;if(!(n!=null&&n.targetduration)){this.handleManifestParsingError(e,h,"invalid target duration",g);return}if(!!t)switch(n.live&&(t.getCacheAge&&(n.ageHeader=t.getCacheAge()||0),(!t.getCacheAge||isNaN(n.ageHeader))&&(n.ageHeader=0)),i){case _.PlaylistContextType.MANIFEST:case _.PlaylistContextType.LEVEL:this.hls.trigger(L.Events.LEVEL_LOADED,{details:n,level:r||0,id:o||0,stats:s,networkDetails:g,deliveryDirectives:u});break;case _.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(L.Events.AUDIO_TRACK_LOADED,{details:n,id:o||0,groupId:c||"",stats:s,networkDetails:g,deliveryDirectives:u});break;case _.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(L.Events.SUBTITLE_TRACK_LOADED,{details:n,id:o||0,groupId:c||"",stats:s,networkDetails:g,deliveryDirectives:u});break}},m}();R.default=E},"./src/polyfills/number.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"isFiniteNumber",function(){return P}),l.d(R,"MAX_SAFE_INTEGER",function(){return L});var P=Number.isFinite||function(A){return typeof A=="number"&&isFinite(A)},L=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(j,R,l){"use strict";l.r(R);var P=function(){function L(){}return L.getSilentFrame=function(M,O){switch(M){case"mp4a.40.2":if(O===1)return new Uint8Array([0,200,0,128,35,128]);if(O===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(O===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(O===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(O===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(O===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(O===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(O===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(O===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}},L}();R.default=P},"./src/remux/mp4-generator.ts":function(j,R,l){"use strict";l.r(R);var P=Math.pow(2,32)-1,L=function(){function A(){}return A.init=function(){A.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 O;for(O in A.types)A.types.hasOwnProperty(O)&&(A.types[O]=[O.charCodeAt(0),O.charCodeAt(1),O.charCodeAt(2),O.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]);A.HDLR_TYPES={video:b,audio:_};var y=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),x=new Uint8Array([0,0,0,0,0,0,0,0]);A.STTS=A.STSC=A.STCO=x,A.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),A.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),A.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),A.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var D=new Uint8Array([105,115,111,109]),E=new Uint8Array([97,118,99,49]),m=new Uint8Array([0,0,0,1]);A.FTYP=A.box(A.types.ftyp,D,m,D,E),A.DINF=A.box(A.types.dinf,A.box(A.types.dref,y))},A.box=function(O){for(var b=8,_=arguments.length,y=new Array(_>1?_-1:0),x=1;x<_;x++)y[x-1]=arguments[x];for(var D=y.length,E=D;D--;)b+=y[D].byteLength;var m=new Uint8Array(b);for(m[0]=b>>24&255,m[1]=b>>16&255,m[2]=b>>8&255,m[3]=b&255,m.set(O,4),D=0,b=8;D<E;D++)m.set(y[D],b),b+=y[D].byteLength;return m},A.hdlr=function(O){return A.box(A.types.hdlr,A.HDLR_TYPES[O])},A.mdat=function(O){return A.box(A.types.mdat,O)},A.mdhd=function(O,b){b*=O;var _=Math.floor(b/(P+1)),y=Math.floor(b%(P+1));return A.box(A.types.mdhd,new Uint8Array([1,0,0,0,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,_>>24,_>>16&255,_>>8&255,_&255,y>>24,y>>16&255,y>>8&255,y&255,85,196,0,0]))},A.mdia=function(O){return A.box(A.types.mdia,A.mdhd(O.timescale,O.duration),A.hdlr(O.type),A.minf(O))},A.mfhd=function(O){return A.box(A.types.mfhd,new Uint8Array([0,0,0,0,O>>24,O>>16&255,O>>8&255,O&255]))},A.minf=function(O){return O.type==="audio"?A.box(A.types.minf,A.box(A.types.smhd,A.SMHD),A.DINF,A.stbl(O)):A.box(A.types.minf,A.box(A.types.vmhd,A.VMHD),A.DINF,A.stbl(O))},A.moof=function(O,b,_){return A.box(A.types.moof,A.mfhd(O),A.traf(_,b))},A.moov=function(O){for(var b=O.length,_=[];b--;)_[b]=A.trak(O[b]);return A.box.apply(null,[A.types.moov,A.mvhd(O[0].timescale,O[0].duration)].concat(_).concat(A.mvex(O)))},A.mvex=function(O){for(var b=O.length,_=[];b--;)_[b]=A.trex(O[b]);return A.box.apply(null,[A.types.mvex].concat(_))},A.mvhd=function(O,b){b*=O;var _=Math.floor(b/(P+1)),y=Math.floor(b%(P+1)),x=new Uint8Array([1,0,0,0,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,_>>24,_>>16&255,_>>8&255,_&255,y>>24,y>>16&255,y>>8&255,y&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return A.box(A.types.mvhd,x)},A.sdtp=function(O){var b=O.samples||[],_=new Uint8Array(4+b.length),y,x;for(y=0;y<b.length;y++)x=b[y].flags,_[y+4]=x.dependsOn<<4|x.isDependedOn<<2|x.hasRedundancy;return A.box(A.types.sdtp,_)},A.stbl=function(O){return A.box(A.types.stbl,A.stsd(O),A.box(A.types.stts,A.STTS),A.box(A.types.stsc,A.STSC),A.box(A.types.stsz,A.STSZ),A.box(A.types.stco,A.STCO))},A.avc1=function(O){var b=[],_=[],y,x,D;for(y=0;y<O.sps.length;y++)x=O.sps[y],D=x.byteLength,b.push(D>>>8&255),b.push(D&255),b=b.concat(Array.prototype.slice.call(x));for(y=0;y<O.pps.length;y++)x=O.pps[y],D=x.byteLength,_.push(D>>>8&255),_.push(D&255),_=_.concat(Array.prototype.slice.call(x));var E=A.box(A.types.avcC,new Uint8Array([1,b[3],b[4],b[5],255,224|O.sps.length].concat(b).concat([O.pps.length]).concat(_))),m=O.width,p=O.height,f=O.pixelRatio[0],e=O.pixelRatio[1];return A.box(A.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,m>>8&255,m&255,p>>8&255,p&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),E,A.box(A.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),A.box(A.types.pasp,new Uint8Array([f>>24,f>>16&255,f>>8&255,f&255,e>>24,e>>16&255,e>>8&255,e&255])))},A.esds=function(O){var b=O.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(O.config).concat([6,1,2]))},A.mp4a=function(O){var b=O.samplerate;return A.box(A.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,O.channelCount,0,16,0,0,0,0,b>>8&255,b&255,0,0]),A.box(A.types.esds,A.esds(O)))},A.mp3=function(O){var b=O.samplerate;return A.box(A.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,O.channelCount,0,16,0,0,0,0,b>>8&255,b&255,0,0]))},A.stsd=function(O){return O.type==="audio"?O.segmentCodec==="mp3"&&O.codec==="mp3"?A.box(A.types.stsd,A.STSD,A.mp3(O)):A.box(A.types.stsd,A.STSD,A.mp4a(O)):A.box(A.types.stsd,A.STSD,A.avc1(O))},A.tkhd=function(O){var b=O.id,_=O.duration*O.timescale,y=O.width,x=O.height,D=Math.floor(_/(P+1)),E=Math.floor(_%(P+1));return A.box(A.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,E>>24,E>>16&255,E>>8&255,E&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,y>>8&255,y&255,0,0,x>>8&255,x&255,0,0]))},A.traf=function(O,b){var _=A.sdtp(O),y=O.id,x=Math.floor(b/(P+1)),D=Math.floor(b%(P+1));return A.box(A.types.traf,A.box(A.types.tfhd,new Uint8Array([0,0,0,0,y>>24,y>>16&255,y>>8&255,y&255])),A.box(A.types.tfdt,new Uint8Array([1,0,0,0,x>>24,x>>16&255,x>>8&255,x&255,D>>24,D>>16&255,D>>8&255,D&255])),A.trun(O,_.length+16+20+8+16+8+8),_)},A.trak=function(O){return O.duration=O.duration||4294967295,A.box(A.types.trak,A.tkhd(O),A.mdia(O))},A.trex=function(O){var b=O.id;return A.box(A.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]))},A.trun=function(O,b){var _=O.samples||[],y=_.length,x=12+16*y,D=new Uint8Array(x),E,m,p,f,e,s;for(b+=8+x,D.set([O.type==="video"?1:0,0,15,1,y>>>24&255,y>>>16&255,y>>>8&255,y&255,b>>>24&255,b>>>16&255,b>>>8&255,b&255],0),E=0;E<y;E++)m=_[E],p=m.duration,f=m.size,e=m.flags,s=m.cts,D.set([p>>>24&255,p>>>16&255,p>>>8&255,p&255,f>>>24&255,f>>>16&255,f>>>8&255,f&255,e.isLeading<<2|e.dependsOn,e.isDependedOn<<6|e.hasRedundancy<<4|e.paddingValue<<1|e.isNonSync,e.degradPrio&240<<8,e.degradPrio&15,s>>>24&255,s>>>16&255,s>>>8&255,s&255],12+16*E);return A.box(A.types.trun,D)},A.initSegment=function(O){A.types||A.init();var b=A.moov(O),_=new Uint8Array(A.FTYP.byteLength+b.byteLength);return _.set(A.FTYP),_.set(b,A.FTYP.byteLength),_},A}();L.types=void 0,L.HDLR_TYPES=void 0,L.STTS=void 0,L.STSC=void 0,L.STCO=void 0,L.STSZ=void 0,L.VMHD=void 0,L.SMHD=void 0,L.STSD=void 0,L.FTYP=void 0,L.DINF=void 0,R.default=L},"./src/remux/mp4-remuxer.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return e}),l.d(R,"normalizePts",function(){return s}),l.d(R,"flushTextTrackMetadataCueSamples",function(){return g}),l.d(R,"flushTextTrackUserdataCueSamples",function(){return i});var P=l("./src/polyfills/number.ts"),L=l("./src/remux/aac-helper.ts"),A=l("./src/remux/mp4-generator.ts"),M=l("./src/events.ts"),O=l("./src/errors.ts"),b=l("./src/utils/logger.ts"),_=l("./src/types/loader.ts"),y=l("./src/utils/timescale-conversion.ts");function x(){return x=Object.assign?Object.assign.bind():function(c){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var u in n)Object.prototype.hasOwnProperty.call(n,u)&&(c[u]=n[u])}return c},x.apply(this,arguments)}var D=10*1e3,E=1024,m=1152,p=null,f=null,e=function(){function c(n,u,a,d){if(d===void 0&&(d=""),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=n,this.config=u,this.typeSupported=a,this.ISGenerated=!1,p===null){var v=navigator.userAgent||"",S=v.match(/Chrome\/(\d+)/i);p=S?parseInt(S[1]):0}if(f===null){var T=navigator.userAgent.match(/Safari\/(\d+)/i);f=T?parseInt(T[1]):0}}var t=c.prototype;return t.destroy=function(){},t.resetTimeStamp=function(u){b.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=u},t.resetNextTimestamp=function(){b.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},t.resetInitSegment=function(){b.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},t.getVideoStartPts=function(u){var a=!1,d=u.reduce(function(v,S){var T=S.pts-v;return T<-4294967296?(a=!0,s(v,S.pts)):T>0?v:S.pts},u[0].pts);return a&&b.logger.debug("PTS rollover detected"),d},t.remux=function(u,a,d,v,S,T,I,k){var B,U,W,G,z,Y,$=S,Z=S,q=u.pid>-1,ie=a.pid>-1,ne=a.samples.length,ae=u.samples.length>0,te=I&&ne>0||ne>1,fe=(!q||ae)&&(!ie||te)||this.ISGenerated||I;if(fe){this.ISGenerated||(W=this.generateIS(u,a,S));var de=this.isVideoContiguous,re=-1,Ee;if(te&&(re=h(a.samples),!de&&this.config.forceKeyFrameOnDiscontinuity))if(Y=!0,re>0){b.logger.warn("[mp4-remuxer]: Dropped "+re+" out of "+ne+" video samples due to a missing keyframe");var me=this.getVideoStartPts(a.samples);a.samples=a.samples.slice(re),a.dropped+=re,Z+=(a.samples[0].pts-me)/a.inputTimeScale,Ee=Z}else re===-1&&(b.logger.warn("[mp4-remuxer]: No keyframe found out of "+ne+" video samples"),Y=!1);if(this.ISGenerated){if(ae&&te){var Te=this.getVideoStartPts(a.samples),Me=s(u.samples[0].pts,Te)-Te,_e=Me/a.inputTimeScale;$+=Math.max(0,_e),Z+=Math.max(0,-_e)}if(ae){if(u.samplerate||(b.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),W=this.generateIS(u,a,S)),U=this.remuxAudio(u,$,this.isAudioContiguous,T,ie||te||k===_.PlaylistLevelType.AUDIO?Z:void 0),te){var ke=U?U.endPTS-U.startPTS:0;a.inputTimeScale||(b.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),W=this.generateIS(u,a,S)),B=this.remuxVideo(a,Z,de,ke)}}else te&&(B=this.remuxVideo(a,Z,de,0));B&&(B.firstKeyFrame=re,B.independent=re!==-1,B.firstKeyFramePTS=Ee)}}return this.ISGenerated&&(d.samples.length&&(z=g(d,S,this._initPTS,this._initDTS)),v.samples.length&&(G=i(v,S,this._initPTS))),{audio:U,video:B,initSegment:W,independent:Y,text:G,id3:z}},t.generateIS=function(u,a,d){var v=u.samples,S=a.samples,T=this.typeSupported,I={},k=!Object(P.isFiniteNumber)(this._initPTS),B="audio/mp4",U,W,G;if(k&&(U=W=1/0),u.config&&v.length){switch(u.timescale=u.samplerate,u.segmentCodec){case"mp3":T.mpeg?(B="audio/mpeg",u.codec=""):T.mp3&&(u.codec="mp3");break}I.audio={id:"audio",container:B,codec:u.codec,initSegment:u.segmentCodec==="mp3"&&T.mpeg?new Uint8Array(0):A.default.initSegment([u]),metadata:{channelCount:u.channelCount}},k&&(G=u.inputTimeScale,U=W=v[0].pts-Math.round(G*d))}if(a.sps&&a.pps&&S.length&&(a.timescale=a.inputTimeScale,I.video={id:"main",container:"video/mp4",codec:a.codec,initSegment:A.default.initSegment([a]),metadata:{width:a.width,height:a.height}},k)){G=a.inputTimeScale;var z=this.getVideoStartPts(S),Y=Math.round(G*d);W=Math.min(W,s(S[0].dts,z)-Y),U=Math.min(U,z-Y)}if(Object.keys(I).length)return this.ISGenerated=!0,k&&(this._initPTS=U,this._initDTS=W),{tracks:I,initPTS:U,timescale:G}},t.remuxVideo=function(u,a,d,v){var S=u.inputTimeScale,T=u.samples,I=[],k=T.length,B=this._initPTS,U=this.nextAvcDts,W=8,G=this.videoSampleDuration,z,Y,$=Number.POSITIVE_INFINITY,Z=Number.NEGATIVE_INFINITY,q=!1;if(!d||U===null){var ie=a*S,ne=T[0].pts-s(T[0].dts,T[0].pts);U=ie-ne}for(var ae=0;ae<k;ae++){var te=T[ae];te.pts=s(te.pts-B,U),te.dts=s(te.dts-B,U),te.dts<T[ae>0?ae-1:ae].dts&&(q=!0)}q&&T.sort(function(Lt,Xt){var Et=Lt.dts-Xt.dts,fr=Lt.pts-Xt.pts;return Et||fr}),z=T[0].dts,Y=T[T.length-1].dts;var fe=Y-z,de=fe?Math.round(fe/(k-1)):G||u.inputTimeScale/30;if(d){var re=z-U,Ee=re>de,me=re<-1;if(Ee||me){Ee?b.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(re,!0)+" ms ("+re+"dts) hole between fragments detected, filling it"):b.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(-re,!0)+" ms ("+re+"dts) overlapping between fragments detected"),z=U;var Te=T[0].pts-re;T[0].dts=z,T[0].pts=Te,b.logger.log("Video: First PTS/DTS adjusted: "+Object(y.toMsFromMpegTsClock)(Te,!0)+"/"+Object(y.toMsFromMpegTsClock)(z,!0)+", delta: "+Object(y.toMsFromMpegTsClock)(re,!0)+" ms")}}z=Math.max(0,z);for(var Me=0,_e=0,ke=0;ke<k;ke++){for(var Ie=T[ke],Be=Ie.units,be=Be.length,Ue=0,Ke=0;Ke<be;Ke++)Ue+=Be[Ke].data.length;_e+=Ue,Me+=be,Ie.length=Ue,Ie.dts=Math.max(Ie.dts,z),$=Math.min(Ie.pts,$),Z=Math.max(Ie.pts,Z)}Y=T[k-1].dts;var je=_e+4*Me+8,Ne;try{Ne=new Uint8Array(je)}catch{this.observer.emit(M.Events.ERROR,M.Events.ERROR,{type:O.ErrorTypes.MUX_ERROR,details:O.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:je,reason:"fail allocating video mdat "+je});return}var qe=new DataView(Ne.buffer);qe.setUint32(0,je),Ne.set(A.default.types.mdat,4);for(var Fe=!1,et=Number.POSITIVE_INFINITY,Oe=Number.POSITIVE_INFINITY,Pe=Number.NEGATIVE_INFINITY,Ve=Number.NEGATIVE_INFINITY,Ce=0;Ce<k;Ce++){for(var Le=T[Ce],it=Le.units,We=0,ot=0,gt=it.length;ot<gt;ot++){var Xe=it[ot],Dt=Xe.data,mt=Xe.data.byteLength;qe.setUint32(W,mt),W+=4,Ne.set(Dt,W),W+=mt,We+=4+mt}var nt=void 0;if(Ce<k-1)G=T[Ce+1].dts-Le.dts,nt=T[Ce+1].pts-Le.pts;else{var lt=this.config,at=Ce>0?Le.dts-T[Ce-1].dts:de;if(nt=Ce>0?Le.pts-T[Ce-1].pts:de,lt.stretchShortVideoTrack&&this.nextAudioPts!==null){var pt=Math.floor(lt.maxBufferHole*S),vt=(v?$+v*S:this.nextAudioPts)-Le.pts;vt>pt?(G=vt-at,G<0?G=at:Fe=!0,b.logger.log("[mp4-remuxer]: It is approximately "+vt/90+" ms to the next segment; using duration "+G/90+" ms for the last video frame.")):G=at}else G=at}var or=Math.round(Le.pts-Le.dts);et=Math.min(et,G),Pe=Math.max(Pe,G),Oe=Math.min(Oe,nt),Ve=Math.max(Ve,nt),I.push(new r(Le.key,G,We,or))}if(I.length){if(p){if(p<70){var Pt=I[0].flags;Pt.dependsOn=2,Pt.isNonSync=0}}else if(f&&Ve-Oe<Pe-et&&de/Pe<.025&&I[0].cts===0){b.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var At=z,Qe=0,Yt=I.length;Qe<Yt;Qe++){var Ct=At+I[Qe].duration,zt=At+I[Qe].cts;if(Qe<Yt-1){var Mt=Ct+I[Qe+1].cts;I[Qe].duration=Mt-zt}else I[Qe].duration=Qe?I[Qe-1].duration:de;I[Qe].cts=0,At=Ct}}}console.assert(G!==null,"mp4SampleDuration must be computed"),G=Fe||!G?de:G,this.nextAvcDts=U=Y+G,this.videoSampleDuration=G,this.isVideoContiguous=!0;var lr=A.default.moof(u.sequenceNumber++,z,x({},u,{samples:I})),ur="video",st={data1:lr,data2:Ne,startPTS:$/S,endPTS:(Z+G)/S,startDTS:z/S,endDTS:U/S,type:ur,hasAudio:!1,hasVideo:!0,nb:I.length,dropped:u.dropped};return u.samples=[],u.dropped=0,console.assert(Ne.length,"MDAT length must not be zero"),st},t.remuxAudio=function(u,a,d,v,S){var T=u.inputTimeScale,I=u.samplerate?u.samplerate:T,k=T/I,B=u.segmentCodec==="aac"?E:m,U=B*k,W=this._initPTS,G=u.segmentCodec==="mp3"&&this.typeSupported.mpeg,z=[],Y=S!==void 0,$=u.samples,Z=G?0:8,q=this.nextAudioPts||-1,ie=a*T;if(this.isAudioContiguous=d=d||$.length&&q>0&&(v&&Math.abs(ie-q)<9e3||Math.abs(s($[0].pts-W,ie)-q)<20*U),$.forEach(function(Xe){Xe.pts=s(Xe.pts-W,ie)}),!d||q<0){if($=$.filter(function(Xe){return Xe.pts>=0}),!$.length)return;S===0?q=0:v&&!Y?q=Math.max(0,ie):q=$[0].pts}if(u.segmentCodec==="aac")for(var ne=this.config.maxAudioFramesDrift,ae=0,te=q;ae<$.length;ae++){var fe=$[ae],de=fe.pts,re=de-te,Ee=Math.abs(1e3*re/T);if(re<=-ne*U&&Y)ae===0&&(b.logger.warn("Audio frame @ "+(de/T).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*re/T)+" ms."),this.nextAudioPts=q=te=de);else if(re>=ne*U&&Ee<D&&Y){var me=Math.round(re/U);te=de-me*U,te<0&&(me--,te+=U),ae===0&&(this.nextAudioPts=q=te),b.logger.warn("[mp4-remuxer]: Injecting "+me+" audio frame @ "+(te/T).toFixed(3)+"s due to "+Math.round(1e3*re/T)+" ms gap.");for(var Te=0;Te<me;Te++){var Me=Math.max(te,0),_e=L.default.getSilentFrame(u.manifestCodec||u.codec,u.channelCount);_e||(b.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),_e=fe.unit.subarray()),$.splice(ae,0,{unit:_e,pts:Me}),te+=U,ae++}}fe.pts=te,te+=U}for(var ke=null,Ie=null,Be,be=0,Ue=$.length;Ue--;)be+=$[Ue].unit.byteLength;for(var Ke=0,je=$.length;Ke<je;Ke++){var Ne=$[Ke],qe=Ne.unit,Fe=Ne.pts;if(Ie!==null){var et=z[Ke-1];et.duration=Math.round((Fe-Ie)/k)}else if(d&&u.segmentCodec==="aac"&&(Fe=q),ke=Fe,be>0){be+=Z;try{Be=new Uint8Array(be)}catch{this.observer.emit(M.Events.ERROR,M.Events.ERROR,{type:O.ErrorTypes.MUX_ERROR,details:O.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:be,reason:"fail allocating audio mdat "+be});return}if(!G){var Oe=new DataView(Be.buffer);Oe.setUint32(0,be),Be.set(A.default.types.mdat,4)}}else return;Be.set(qe,Z);var Pe=qe.byteLength;Z+=Pe,z.push(new r(!0,B,Pe,0)),Ie=Fe}var Ve=z.length;if(!!Ve){var Ce=z[z.length-1];this.nextAudioPts=q=Ie+k*Ce.duration;var Le=G?new Uint8Array(0):A.default.moof(u.sequenceNumber++,ke/k,x({},u,{samples:z}));u.samples=[];var it=ke/T,We=q/T,ot="audio",gt={data1:Le,data2:Be,startPTS:it,endPTS:We,startDTS:it,endDTS:We,type:ot,hasAudio:!0,hasVideo:!1,nb:Ve};return this.isAudioContiguous=!0,console.assert(Be.length,"MDAT length must not be zero"),gt}},t.remuxEmptyAudio=function(u,a,d,v){var S=u.inputTimeScale,T=u.samplerate?u.samplerate:S,I=S/T,k=this.nextAudioPts,B=(k!==null?k:v.startDTS*S)+this._initDTS,U=v.endDTS*S+this._initDTS,W=I*E,G=Math.ceil((U-B)/W),z=L.default.getSilentFrame(u.manifestCodec||u.codec,u.channelCount);if(b.logger.warn("[mp4-remuxer]: remux empty Audio"),!z){b.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var Y=[],$=0;$<G;$++){var Z=B+$*W;Y.push({unit:z,pts:Z,dts:Z})}return u.samples=Y,this.remuxAudio(u,a,d,!1)},c}();function s(c,t){var n;if(t===null)return c;for(t<c?n=-8589934592:n=8589934592;Math.abs(c-t)>4294967296;)c+=n;return c}function h(c){for(var t=0;t<c.length;t++)if(c[t].key)return t;return-1}function g(c,t,n,u){var a=c.samples.length;if(!!a){for(var d=c.inputTimeScale,v=0;v<a;v++){var S=c.samples[v];S.pts=s(S.pts-n,t*d)/d,S.dts=s(S.dts-u,t*d)/d}var T=c.samples;return c.samples=[],{samples:T}}}function i(c,t,n){var u=c.samples.length;if(!!u){for(var a=c.inputTimeScale,d=0;d<u;d++){var v=c.samples[d];v.pts=s(v.pts-n,t*a)/a}c.samples.sort(function(T,I){return T.pts-I.pts});var S=c.samples;return c.samples=[],{samples:S}}}var r=function(t,n,u,a){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=n,this.size=u,this.cts=a,this.flags=new o(t)},o=function(t){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=t?2:1,this.isNonSync=t?0:1}},"./src/remux/passthrough-remuxer.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/polyfills/number.ts"),L=l("./src/remux/mp4-remuxer.ts"),A=l("./src/utils/mp4-tools.ts"),M=l("./src/loader/fragment.ts"),O=l("./src/utils/logger.ts"),b=function(){function y(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndTime=null}var x=y.prototype;return x.destroy=function(){},x.resetTimeStamp=function(E){this.initPTS=E,this.lastEndTime=null},x.resetNextTimestamp=function(){this.lastEndTime=null},x.resetInitSegment=function(E,m,p){this.audioCodec=m,this.videoCodec=p,this.generateInitSegment(E),this.emitInitSegment=!0},x.generateInitSegment=function(E){var m=this.audioCodec,p=this.videoCodec;if(!E||!E.byteLength){this.initTracks=void 0,this.initData=void 0;return}var f=this.initData=Object(A.parseInitSegment)(E);m||(m=_(f.audio,M.ElementaryStreamTypes.AUDIO)),p||(p=_(f.video,M.ElementaryStreamTypes.VIDEO));var e={};f.audio&&f.video?e.audiovideo={container:"video/mp4",codec:m+","+p,initSegment:E,id:"main"}:f.audio?e.audio={container:"audio/mp4",codec:m,initSegment:E,id:"audio"}:f.video?e.video={container:"video/mp4",codec:p,initSegment:E,id:"main"}:O.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=e},x.remux=function(E,m,p,f,e){var s,h=this.initPTS,g=this.lastEndTime,i={audio:void 0,video:void 0,text:f,id3:p,initSegment:void 0};Object(P.isFiniteNumber)(g)||(g=this.lastEndTime=e||0);var r=m.samples;if(!r||!r.length)return i;var o={initPTS:void 0,timescale:1},c=this.initData;if((!c||!c.length)&&(this.generateInitSegment(r),c=this.initData),!c||!c.length)return O.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),i;this.emitInitSegment&&(o.tracks=this.initTracks,this.emitInitSegment=!1);var t=Object(A.getStartDTS)(c,r);Object(P.isFiniteNumber)(h)||(this.initPTS=o.initPTS=h=t-e);var n=Object(A.getDuration)(r,c),u=E?t-h:g,a=u+n;Object(A.offsetStartDTS)(c,r,h),n>0?this.lastEndTime=a:(O.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var d=!!c.audio,v=!!c.video,S="";d&&(S+="audio"),v&&(S+="video");var T={data1:r,startPTS:u,startDTS:u,endPTS:a,endDTS:a,type:S,hasAudio:d,hasVideo:v,nb:1,dropped:0};i.audio=T.type==="audio"?T:void 0,i.video=T.type!=="audio"?T:void 0,i.initSegment=o;var I=(s=this.initPTS)!=null?s:0;return i.id3=Object(L.flushTextTrackMetadataCueSamples)(p,e,I,I),f.samples.length&&(i.text=Object(L.flushTextTrackUserdataCueSamples)(f,e,I)),i},y}();function _(y,x){var D=y==null?void 0:y.codec;return D&&D.length>4?D:D==="hvc1"||D==="hev1"?"hvc1.1.c.L120.90":D==="av01"?"av01.0.04M.08":D==="avc1"||x===M.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}R.default=b},"./src/task-loop.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return P});var P=function(){function L(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var A=L.prototype;return A.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},A.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},A.onHandlerDestroyed=function(){},A.hasInterval=function(){return!!this._tickInterval},A.hasNextTick=function(){return!!this._tickTimer},A.setInterval=function(O){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,O),!0)},A.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},A.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},A.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},A.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},A.doTick=function(){},L}()},"./src/types/cmcd.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"CMCDVersion",function(){return P}),l.d(R,"CMCDObjectType",function(){return L}),l.d(R,"CMCDStreamingFormat",function(){return A}),l.d(R,"CMCDStreamType",function(){return M});var P=1,L;(function(O){O.MANIFEST="m",O.AUDIO="a",O.VIDEO="v",O.MUXED="av",O.INIT="i",O.CAPTION="c",O.TIMED_TEXT="tt",O.KEY="k",O.OTHER="o"})(L||(L={}));var A;(function(O){O.DASH="d",O.HLS="h",O.SMOOTH="s",O.OTHER="o"})(A||(A={}));var M;(function(O){O.VOD="v",O.LIVE="l"})(M||(M={}))},"./src/types/demuxer.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"MetadataSchema",function(){return P});var P;(function(L){L.audioId3="org.id3",L.dateRange="com.apple.quicktime.HLS",L.emsg="https://aomedia.org/emsg/ID3"})(P||(P={}))},"./src/types/level.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"HlsSkip",function(){return A}),l.d(R,"getSkipValue",function(){return M}),l.d(R,"HlsUrlParameters",function(){return O}),l.d(R,"Level",function(){return b});function P(_,y){for(var x=0;x<y.length;x++){var D=y[x];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(_,D.key,D)}}function L(_,y,x){return y&&P(_.prototype,y),x&&P(_,x),Object.defineProperty(_,"prototype",{writable:!1}),_}var A;(function(_){_.No="",_.Yes="YES",_.v2="v2"})(A||(A={}));function M(_,y){var x=_.canSkipUntil,D=_.canSkipDateRanges,E=_.endSN,m=y!==void 0?y-E:0;return x&&m<x?D?A.v2:A.Yes:A.No}var O=function(){function _(x,D,E){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=x,this.part=D,this.skip=E}var y=_.prototype;return y.addDirectives=function(D){var E=new self.URL(D);return this.msn!==void 0&&E.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&E.searchParams.set("_HLS_part",this.part.toString()),this.skip&&E.searchParams.set("_HLS_skip",this.skip),E.toString()},_}(),b=function(){function _(y){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[y.url],this.attrs=y.attrs,this.bitrate=y.bitrate,y.details&&(this.details=y.details),this.id=y.id||0,this.name=y.name,this.width=y.width||0,this.height=y.height||0,this.audioCodec=y.audioCodec,this.videoCodec=y.videoCodec,this.unknownCodecs=y.unknownCodecs,this.codecSet=[y.videoCodec,y.audioCodec].filter(function(x){return x}).join(",").replace(/\.[^.,]+/g,"")}return L(_,[{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(x){var D=x%this.url.length;this._urlId!==D&&(this.details=void 0,this._urlId=D)}}]),_}()},"./src/types/loader.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"PlaylistContextType",function(){return P}),l.d(R,"PlaylistLevelType",function(){return L});var P;(function(A){A.MANIFEST="manifest",A.LEVEL="level",A.AUDIO_TRACK="audioTrack",A.SUBTITLE_TRACK="subtitleTrack"})(P||(P={}));var L;(function(A){A.MAIN="main",A.AUDIO="audio",A.SUBTITLE="subtitle"})(L||(L={}))},"./src/types/transmuxer.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"ChunkMetadata",function(){return P});var P=function(M,O,b,_,y,x){_===void 0&&(_=0),y===void 0&&(y=-1),x===void 0&&(x=!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=L(),this.buffering={audio:L(),video:L(),audiovideo:L()},this.level=M,this.sn=O,this.id=b,this.size=_,this.part=y,this.partial=x};function L(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"AttrList",function(){return A});var P=/^(\d+)x(\d+)$/,L=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,A=function(){function M(b){typeof b=="string"&&(b=M.parseAttrList(b));for(var _ in b)b.hasOwnProperty(_)&&(this[_]=b[_])}var O=M.prototype;return O.decimalInteger=function(_){var y=parseInt(this[_],10);return y>Number.MAX_SAFE_INTEGER?1/0:y},O.hexadecimalInteger=function(_){if(this[_]){var y=(this[_]||"0x").slice(2);y=(y.length&1?"0":"")+y;for(var x=new Uint8Array(y.length/2),D=0;D<y.length/2;D++)x[D]=parseInt(y.slice(D*2,D*2+2),16);return x}else return null},O.hexadecimalIntegerAsNumber=function(_){var y=parseInt(this[_],16);return y>Number.MAX_SAFE_INTEGER?1/0:y},O.decimalFloatingPoint=function(_){return parseFloat(this[_])},O.optionalFloat=function(_,y){var x=this[_];return x?parseFloat(x):y},O.enumeratedString=function(_){return this[_]},O.bool=function(_){return this[_]==="YES"},O.decimalResolution=function(_){var y=P.exec(this[_]);if(y!==null)return{width:parseInt(y[1],10),height:parseInt(y[2],10)}},M.parseAttrList=function(_){var y,x={},D='"';for(L.lastIndex=0;(y=L.exec(_))!==null;){var E=y[2];E.indexOf(D)===0&&E.lastIndexOf(D)===E.length-1&&(E=E.slice(1,-1)),x[y[1]]=E}return x},M}()},"./src/utils/binary-search.ts":function(j,R,l){"use strict";l.r(R);var P={search:function(A,M){for(var O=0,b=A.length-1,_=null,y=null;O<=b;){_=(O+b)/2|0,y=A[_];var x=M(y);if(x>0)O=_+1;else if(x<0)b=_-1;else return y}return null}};R.default=P},"./src/utils/buffer-helper.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"BufferHelper",function(){return A});var P=l("./src/utils/logger.ts"),L={length:0,start:function(){return 0},end:function(){return 0}},A=function(){function M(){}return M.isBuffered=function(b,_){try{if(b){for(var y=M.getBuffered(b),x=0;x<y.length;x++)if(_>=y.start(x)&&_<=y.end(x))return!0}}catch{}return!1},M.bufferInfo=function(b,_,y){try{if(b){var x=M.getBuffered(b),D=[],E;for(E=0;E<x.length;E++)D.push({start:x.start(E),end:x.end(E)});return this.bufferedInfo(D,_,y)}}catch{}return{len:0,start:_,end:_,nextStart:void 0}},M.bufferedInfo=function(b,_,y){_=Math.max(0,_),b.sort(function(r,o){var c=r.start-o.start;return c||o.end-r.end});var x=[];if(y)for(var D=0;D<b.length;D++){var E=x.length;if(E){var m=x[E-1].end;b[D].start-m<y?b[D].end>m&&(x[E-1].end=b[D].end):x.push(b[D])}else x.push(b[D])}else x=b;for(var p=0,f,e=_,s=_,h=0;h<x.length;h++){var g=x[h].start,i=x[h].end;if(_+y>=g&&_<i)e=g,s=i,p=s-_;else if(_+y<g){f=g;break}}return{len:p,start:e||0,end:s||0,nextStart:f}},M.getBuffered=function(b){try{return b.buffered}catch(_){return P.logger.log("failed to get media.buffered",_),L}},M}()},"./src/utils/cea-608-parser.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"Row",function(){return s}),l.d(R,"CaptionScreen",function(){return h});var P=l("./src/utils/logger.ts"),L={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},A=function(n){var u=n;return L.hasOwnProperty(n)&&(u=L[n]),String.fromCharCode(u)},M=15,O=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},y={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},x={25:2,26:4,29:6,30:8,31:10,27:13,28:15},D=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],E;(function(t){t[t.ERROR=0]="ERROR",t[t.TEXT=1]="TEXT",t[t.WARNING=2]="WARNING",t[t.INFO=2]="INFO",t[t.DEBUG=3]="DEBUG",t[t.DATA=3]="DATA"})(E||(E={}));var m=function(){function t(){this.time=null,this.verboseLevel=E.ERROR}var n=t.prototype;return n.log=function(a,d){this.verboseLevel>=a&&P.logger.log(this.time+" ["+a+"] "+d)},t}(),p=function(n){for(var u=[],a=0;a<n.length;a++)u.push(n[a].toString(16));return u},f=function(){function t(u,a,d,v,S){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=u||"white",this.underline=a||!1,this.italics=d||!1,this.background=v||"black",this.flash=S||!1}var n=t.prototype;return n.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},n.setStyles=function(a){for(var d=["foreground","underline","italics","background","flash"],v=0;v<d.length;v++){var S=d[v];a.hasOwnProperty(S)&&(this[S]=a[S])}},n.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},n.equals=function(a){return this.foreground===a.foreground&&this.underline===a.underline&&this.italics===a.italics&&this.background===a.background&&this.flash===a.flash},n.copy=function(a){this.foreground=a.foreground,this.underline=a.underline,this.italics=a.italics,this.background=a.background,this.flash=a.flash},n.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},t}(),e=function(){function t(u,a,d,v,S,T){this.uchar=void 0,this.penState=void 0,this.uchar=u||" ",this.penState=new f(a,d,v,S,T)}var n=t.prototype;return n.reset=function(){this.uchar=" ",this.penState.reset()},n.setChar=function(a,d){this.uchar=a,this.penState.copy(d)},n.setPenState=function(a){this.penState.copy(a)},n.equals=function(a){return this.uchar===a.uchar&&this.penState.equals(a.penState)},n.copy=function(a){this.uchar=a.uchar,this.penState.copy(a.penState)},n.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},t}(),s=function(){function t(u){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var a=0;a<O;a++)this.chars.push(new e);this.logger=u,this.pos=0,this.currPenState=new f}var n=t.prototype;return n.equals=function(a){for(var d=!0,v=0;v<O;v++)if(!this.chars[v].equals(a.chars[v])){d=!1;break}return d},n.copy=function(a){for(var d=0;d<O;d++)this.chars[d].copy(a.chars[d])},n.isEmpty=function(){for(var a=!0,d=0;d<O;d++)if(!this.chars[d].isEmpty()){a=!1;break}return a},n.setCursor=function(a){this.pos!==a&&(this.pos=a),this.pos<0?(this.logger.log(E.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>O&&(this.logger.log(E.DEBUG,"Too large cursor position "+this.pos),this.pos=O)},n.moveCursor=function(a){var d=this.pos+a;if(a>1)for(var v=this.pos+1;v<d+1;v++)this.chars[v].setPenState(this.currPenState);this.setCursor(d)},n.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},n.insertChar=function(a){a>=144&&this.backSpace();var d=A(a);if(this.pos>=O){this.logger.log(E.ERROR,"Cannot insert "+a.toString(16)+" ("+d+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(d,this.currPenState),this.moveCursor(1)},n.clearFromPos=function(a){var d;for(d=a;d<O;d++)this.chars[d].reset()},n.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},n.clearToEndOfRow=function(){this.clearFromPos(this.pos)},n.getTextString=function(){for(var a=[],d=!0,v=0;v<O;v++){var S=this.chars[v].uchar;S!==" "&&(d=!1),a.push(S)}return d?"":a.join("")},n.setPenStyles=function(a){this.currPenState.setStyles(a);var d=this.chars[this.pos];d.setPenState(this.currPenState)},t}(),h=function(){function t(u){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var a=0;a<M;a++)this.rows.push(new s(u));this.logger=u,this.currRow=M-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var n=t.prototype;return n.reset=function(){for(var a=0;a<M;a++)this.rows[a].clear();this.currRow=M-1},n.equals=function(a){for(var d=!0,v=0;v<M;v++)if(!this.rows[v].equals(a.rows[v])){d=!1;break}return d},n.copy=function(a){for(var d=0;d<M;d++)this.rows[d].copy(a.rows[d])},n.isEmpty=function(){for(var a=!0,d=0;d<M;d++)if(!this.rows[d].isEmpty()){a=!1;break}return a},n.backSpace=function(){var a=this.rows[this.currRow];a.backSpace()},n.clearToEndOfRow=function(){var a=this.rows[this.currRow];a.clearToEndOfRow()},n.insertChar=function(a){var d=this.rows[this.currRow];d.insertChar(a)},n.setPen=function(a){var d=this.rows[this.currRow];d.setPenStyles(a)},n.moveCursor=function(a){var d=this.rows[this.currRow];d.moveCursor(a)},n.setCursor=function(a){this.logger.log(E.INFO,"setCursor: "+a);var d=this.rows[this.currRow];d.setCursor(a)},n.setPAC=function(a){this.logger.log(E.INFO,"pacData = "+JSON.stringify(a));var d=a.row-1;if(this.nrRollUpRows&&d<this.nrRollUpRows-1&&(d=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==d){for(var v=0;v<M;v++)this.rows[v].clear();var S=this.currRow+1-this.nrRollUpRows,T=this.lastOutputScreen;if(T){var I=T.rows[S].cueStartTime,k=this.logger.time;if(I&&k!==null&&I<k)for(var B=0;B<this.nrRollUpRows;B++)this.rows[d-this.nrRollUpRows+B+1].copy(T.rows[S+B])}}this.currRow=d;var U=this.rows[this.currRow];if(a.indent!==null){var W=a.indent,G=Math.max(W-1,0);U.setCursor(a.indent),a.color=U.chars[G].penState.foreground}var z={foreground:a.color,underline:a.underline,italics:a.italics,background:"black",flash:!1};this.setPen(z)},n.setBkgData=function(a){this.logger.log(E.INFO,"bkgData = "+JSON.stringify(a)),this.backSpace(),this.setPen(a),this.insertChar(32)},n.setRollUpRows=function(a){this.nrRollUpRows=a},n.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(E.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(E.TEXT,this.getDisplayText());var a=this.currRow+1-this.nrRollUpRows,d=this.rows.splice(a,1)[0];d.clear(),this.rows.splice(this.currRow,0,d),this.logger.log(E.INFO,"Rolling up")},n.getDisplayText=function(a){a=a||!1;for(var d=[],v="",S=-1,T=0;T<M;T++){var I=this.rows[T].getTextString();I&&(S=T+1,a?d.push("Row "+S+": '"+I+"'"):d.push(I.trim()))}return d.length>0&&(a?v="["+d.join(" | ")+"]":v=d.join(`
|
|
20
|
+
`)),v},n.getTextAndFormat=function(){return this.rows},t}(),g=function(){function t(u,a,d){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=u,this.outputFilter=a,this.mode=null,this.verbose=0,this.displayedMemory=new h(d),this.nonDisplayedMemory=new h(d),this.lastOutputScreen=new h(d),this.currRollUpRow=this.displayedMemory.rows[M-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=d}var n=t.prototype;return n.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[M-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},n.getHandler=function(){return this.outputFilter},n.setHandler=function(a){this.outputFilter=a},n.setPAC=function(a){this.writeScreen.setPAC(a)},n.setBkgData=function(a){this.writeScreen.setBkgData(a)},n.setMode=function(a){a!==this.mode&&(this.mode=a,this.logger.log(E.INFO,"MODE="+a),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=a)},n.insertChars=function(a){for(var d=0;d<a.length;d++)this.writeScreen.insertChar(a[d]);var v=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(E.INFO,v+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(E.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},n.ccRCL=function(){this.logger.log(E.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},n.ccBS=function(){this.logger.log(E.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},n.ccAOF=function(){},n.ccAON=function(){},n.ccDER=function(){this.logger.log(E.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},n.ccRU=function(a){this.logger.log(E.INFO,"RU("+a+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(a)},n.ccFON=function(){this.logger.log(E.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},n.ccRDC=function(){this.logger.log(E.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},n.ccTR=function(){this.logger.log(E.INFO,"TR"),this.setMode("MODE_TEXT")},n.ccRTD=function(){this.logger.log(E.INFO,"RTD"),this.setMode("MODE_TEXT")},n.ccEDM=function(){this.logger.log(E.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},n.ccCR=function(){this.logger.log(E.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},n.ccENM=function(){this.logger.log(E.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},n.ccEOC=function(){if(this.logger.log(E.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var a=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=a,this.writeScreen=this.nonDisplayedMemory,this.logger.log(E.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},n.ccTO=function(a){this.logger.log(E.INFO,"TO("+a+") - Tab Offset"),this.writeScreen.moveCursor(a)},n.ccMIDROW=function(a){var d={flash:!1};if(d.underline=a%2===1,d.italics=a>=46,d.italics)d.foreground="white";else{var v=Math.floor(a/2)-16,S=["white","green","blue","cyan","red","yellow","magenta"];d.foreground=S[v]}this.logger.log(E.INFO,"MIDROW: "+JSON.stringify(d)),this.writeScreen.setPen(d)},n.outputDataUpdate=function(a){a===void 0&&(a=!1);var d=this.logger.time;d!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=d:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,d,this.lastOutputScreen),a&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:d),this.lastOutputScreen.copy(this.displayedMemory))},n.cueSplitAtTime=function(a){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,a,this.displayedMemory),this.cueStartTime=a))},t}(),i=function(){function t(u,a,d){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var v=new m;this.channels=[null,new g(u,a,v),new g(u+1,d,v)],this.cmdHistory=c(),this.logger=v}var n=t.prototype;return n.getHandler=function(a){return this.channels[a].getHandler()},n.setHandler=function(a,d){this.channels[a].setHandler(d)},n.addData=function(a,d){var v,S,T,I=!1;this.logger.time=a;for(var k=0;k<d.length;k+=2)if(S=d[k]&127,T=d[k+1]&127,!(S===0&&T===0)){if(this.logger.log(E.DATA,"["+p([d[k],d[k+1]])+"] -> ("+p([S,T])+")"),v=this.parseCmd(S,T),v||(v=this.parseMidrow(S,T)),v||(v=this.parsePAC(S,T)),v||(v=this.parseBackgroundAttributes(S,T)),!v&&(I=this.parseChars(S,T),I)){var B=this.currentChannel;if(B&&B>0){var U=this.channels[B];U.insertChars(I)}else this.logger.log(E.WARNING,"No channel found yet. TEXT-MODE?")}!v&&!I&&this.logger.log(E.WARNING,"Couldn't parse cleaned data "+p([S,T])+" orig: "+p([d[k],d[k+1]]))}},n.parseCmd=function(a,d){var v=this.cmdHistory,S=(a===20||a===28||a===21||a===29)&&d>=32&&d<=47,T=(a===23||a===31)&&d>=33&&d<=35;if(!(S||T))return!1;if(o(a,d,v))return r(null,null,v),this.logger.log(E.DEBUG,"Repeated command ("+p([a,d])+") is dropped"),!0;var I=a===20||a===21||a===23?1:2,k=this.channels[I];return a===20||a===21||a===28||a===29?d===32?k.ccRCL():d===33?k.ccBS():d===34?k.ccAOF():d===35?k.ccAON():d===36?k.ccDER():d===37?k.ccRU(2):d===38?k.ccRU(3):d===39?k.ccRU(4):d===40?k.ccFON():d===41?k.ccRDC():d===42?k.ccTR():d===43?k.ccRTD():d===44?k.ccEDM():d===45?k.ccCR():d===46?k.ccENM():d===47&&k.ccEOC():k.ccTO(d-32),r(a,d,v),this.currentChannel=I,!0},n.parseMidrow=function(a,d){var v=0;if((a===17||a===25)&&d>=32&&d<=47){if(a===17?v=1:v=2,v!==this.currentChannel)return this.logger.log(E.ERROR,"Mismatch channel in midrow parsing"),!1;var S=this.channels[v];return S?(S.ccMIDROW(d),this.logger.log(E.DEBUG,"MIDROW ("+p([a,d])+")"),!0):!1}return!1},n.parsePAC=function(a,d){var v,S=this.cmdHistory,T=(a>=17&&a<=23||a>=25&&a<=31)&&d>=64&&d<=127,I=(a===16||a===24)&&d>=64&&d<=95;if(!(T||I))return!1;if(o(a,d,S))return r(null,null,S),!0;var k=a<=23?1:2;d>=64&&d<=95?v=k===1?b[a]:y[a]:v=k===1?_[a]:x[a];var B=this.channels[k];return B?(B.setPAC(this.interpretPAC(v,d)),r(a,d,S),this.currentChannel=k,!0):!1},n.interpretPAC=function(a,d){var v,S={color:null,italics:!1,indent:null,underline:!1,row:a};return d>95?v=d-96:v=d-64,S.underline=(v&1)===1,v<=13?S.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(v/2)]:v<=15?(S.italics=!0,S.color="white"):S.indent=Math.floor((v-16)/2)*4,S},n.parseChars=function(a,d){var v,S=null,T=null;if(a>=25?(v=2,T=a-8):(v=1,T=a),T>=17&&T<=19){var I;T===17?I=d+80:T===18?I=d+112:I=d+144,this.logger.log(E.INFO,"Special char '"+A(I)+"' in channel "+v),S=[I]}else a>=32&&a<=127&&(S=d===0?[a]:[a,d]);if(S){var k=p(S);this.logger.log(E.DEBUG,"Char codes = "+k.join(",")),r(a,d,this.cmdHistory)}return S},n.parseBackgroundAttributes=function(a,d){var v=(a===16||a===24)&&d>=32&&d<=47,S=(a===23||a===31)&&d>=45&&d<=47;if(!(v||S))return!1;var T,I={};a===16||a===24?(T=Math.floor((d-32)/2),I.background=D[T],d%2===1&&(I.background=I.background+"_semi")):d===45?I.background="transparent":(I.foreground="black",d===47&&(I.underline=!0));var k=a<=23?1:2,B=this.channels[k];return B.setBkgData(I),r(a,d,this.cmdHistory),!0},n.reset=function(){for(var a=0;a<Object.keys(this.channels).length;a++){var d=this.channels[a];d&&d.reset()}this.cmdHistory=c()},n.cueSplitAtTime=function(a){for(var d=0;d<this.channels.length;d++){var v=this.channels[d];v&&v.cueSplitAtTime(a)}},t}();function r(t,n,u){u.a=t,u.b=n}function o(t,n,u){return u.a===t&&u.b===n}function c(){return{a:null,b:null}}R.default=i},"./src/utils/codecs.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"isCodecType",function(){return L}),l.d(R,"isCodecSupportedInMp4",function(){return A});var P={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 L(M,O){var b=P[O];return!!b&&b[M.slice(0,4)]===!0}function A(M,O){return MediaSource.isTypeSupported((O||"video")+'/mp4;codecs="'+M+'"')}},"./src/utils/cues.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/utils/vttparser.ts"),L=l("./src/utils/webvtt-parser.ts"),A=l("./src/utils/texttrack-utils.ts"),M=/\s/,O={newCue:function(_,y,x,D){for(var E=[],m,p,f,e,s,h=self.VTTCue||self.TextTrackCue,g=0;g<D.rows.length;g++)if(m=D.rows[g],f=!0,e=0,s="",!m.isEmpty()){for(var i=0;i<m.chars.length;i++)M.test(m.chars[i].uchar)&&f?e++:(s+=m.chars[i].uchar,f=!1);m.cueStartTime=y,y===x&&(x+=1e-4),e>=16?e--:e++;var r=Object(P.fixLineBreaks)(s.trim()),o=Object(L.generateCueId)(y,x,r);(!_||!_.cues||!_.cues.getCueById(o))&&(p=new h(y,x,r),p.id=o,p.line=g+1,p.align="left",p.position=10+Math.min(80,Math.floor(e*8/32)*10),E.push(p))}return _&&E.length&&(E.sort(function(c,t){return c.line==="auto"||t.line==="auto"?0:c.line>8&&t.line>8?t.line-c.line:c.line-t.line}),E.forEach(function(c){return Object(A.addCueToTrack)(_,c)})),E}};R.default=O},"./src/utils/discontinuities.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"findFirstFragWithCC",function(){return M}),l.d(R,"shouldAlignOnDiscontinuities",function(){return O}),l.d(R,"findDiscontinuousReferenceFrag",function(){return b}),l.d(R,"adjustSlidingStart",function(){return y}),l.d(R,"alignStream",function(){return x}),l.d(R,"alignPDT",function(){return E}),l.d(R,"alignFragmentByPDTDelta",function(){return m}),l.d(R,"alignMediaPlaylistByPDT",function(){return p});var P=l("./src/polyfills/number.ts"),L=l("./src/utils/logger.ts"),A=l("./src/controller/level-helper.ts");function M(f,e){for(var s=null,h=0,g=f.length;h<g;h++){var i=f[h];if(i&&i.cc===e){s=i;break}}return s}function O(f,e,s){return!!(e.details&&(s.endCC>s.startCC||f&&f.cc<s.startCC))}function b(f,e){var s=f.fragments,h=e.fragments;if(!h.length||!s.length){L.logger.log("No fragments to align");return}var g=M(s,h[0].cc);if(!g||g&&!g.startPTS){L.logger.log("No frag in previous level to align on");return}return g}function _(f,e){if(f){var s=f.start+e;f.start=f.startPTS=s,f.endPTS=s+f.duration}}function y(f,e){for(var s=e.fragments,h=0,g=s.length;h<g;h++)_(s[h],f);e.fragmentHint&&_(e.fragmentHint,f),e.alignedSliding=!0}function x(f,e,s){!e||(D(f,s,e),!s.alignedSliding&&e.details&&E(s,e.details),!s.alignedSliding&&e.details&&!s.skippedSegments&&Object(A.adjustSliding)(e.details,s))}function D(f,e,s){if(O(f,s,e)){var h=b(s.details,e);h&&Object(P.isFiniteNumber)(h.start)&&(L.logger.log("Adjusting PTS using last level due to CC increase within current level "+e.url),y(h.start,e))}}function E(f,e){if(!(!e.fragments.length||!f.hasProgramDateTime||!e.hasProgramDateTime)){var s=e.fragments[0].programDateTime,h=f.fragments[0].programDateTime,g=(h-s)/1e3+e.fragments[0].start;g&&Object(P.isFiniteNumber)(g)&&(L.logger.log("Adjusting PTS using programDateTime delta "+(h-s)+"ms, sliding:"+g.toFixed(3)+" "+f.url+" "),y(g,f))}}function m(f,e){var s=f.programDateTime;if(!!s){var h=(s-e)/1e3;f.start=f.startPTS=h,f.endPTS=h+f.duration}}function p(f,e){if(!(!e.fragments.length||!f.hasProgramDateTime||!e.hasProgramDateTime)){var s=e.fragments[0].programDateTime,h=e.fragments[0].start,g=s-h*1e3;f.fragments.forEach(function(i){m(i,g)}),f.fragmentHint&&m(f.fragmentHint,g),f.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/utils/ewma.ts"),L=function(){function A(O,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 P.default(O),this.fast_=new P.default(b)}var M=A.prototype;return M.update=function(b,_){var y=this.slow_,x=this.fast_;this.slow_.halfLife!==b&&(this.slow_=new P.default(b,y.getEstimate(),y.getTotalWeight())),this.fast_.halfLife!==_&&(this.fast_=new P.default(_,x.getEstimate(),x.getTotalWeight()))},M.sample=function(b,_){b=Math.max(b,this.minDelayMs_);var y=8*_,x=b/1e3,D=y/x;this.fast_.sample(x,D),this.slow_.sample(x,D)},M.canEstimate=function(){var b=this.fast_;return b&&b.getTotalWeight()>=this.minWeight_},M.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},M.destroy=function(){},A}();R.default=L},"./src/utils/ewma.ts":function(j,R,l){"use strict";l.r(R);var P=function(){function L(M,O,b){O===void 0&&(O=0),b===void 0&&(b=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=M,this.alpha_=M?Math.exp(Math.log(.5)/M):0,this.estimate_=O,this.totalWeight_=b}var A=L.prototype;return A.sample=function(O,b){var _=Math.pow(this.alpha_,O);this.estimate_=b*(1-_)+_*this.estimate_,this.totalWeight_+=O},A.getTotalWeight=function(){return this.totalWeight_},A.getEstimate=function(){if(this.alpha_){var O=1-Math.pow(this.alpha_,this.totalWeight_);if(O)return this.estimate_/O}return this.estimate_},L}();R.default=P},"./src/utils/fetch-loader.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"fetchSupported",function(){return m});var P=l("./src/polyfills/number.ts"),L=l("./src/loader/load-stats.ts"),A=l("./src/demux/chunk-cache.ts");function M(h,g){h.prototype=Object.create(g.prototype),h.prototype.constructor=h,x(h,g)}function O(h){var g=typeof Map=="function"?new Map:void 0;return O=function(r){if(r===null||!y(r))return r;if(typeof r!="function")throw new TypeError("Super expression must either be null or a function");if(typeof g!="undefined"){if(g.has(r))return g.get(r);g.set(r,o)}function o(){return b(r,arguments,D(this).constructor)}return o.prototype=Object.create(r.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),x(o,r)},O(h)}function b(h,g,i){return _()?b=Reflect.construct.bind():b=function(o,c,t){var n=[null];n.push.apply(n,c);var u=Function.bind.apply(o,n),a=new u;return t&&x(a,t.prototype),a},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 y(h){return Function.toString.call(h).indexOf("[native code]")!==-1}function x(h,g){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},x(h,g)}function D(h){return D=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},D(h)}function E(){return E=Object.assign?Object.assign.bind():function(h){for(var g=1;g<arguments.length;g++){var i=arguments[g];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(h[r]=i[r])}return h},E.apply(this,arguments)}function m(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var p=function(){function h(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 L.LoadStats}var g=h.prototype;return g.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},g.abortInternal=function(){var r=this.response;(!r||!r.ok)&&(this.stats.aborted=!0,this.controller.abort())},g.abort=function(){var r;this.abortInternal(),(r=this.callbacks)!==null&&r!==void 0&&r.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},g.load=function(r,o,c){var t=this,n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();var u=f(r,this.controller.signal),a=c.onProgress,d=r.responseType==="arraybuffer",v=d?"byteLength":"length";this.context=r,this.config=o,this.callbacks=c,this.request=this.fetchSetup(r,u),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){t.abortInternal(),c.onTimeout(n,r,t.response)},o.timeout),self.fetch(this.request).then(function(S){if(t.response=t.loader=S,!S.ok){var T=S.status,I=S.statusText;throw new s(I||"fetch, bad network response",T,S)}return n.loading.first=Math.max(self.performance.now(),n.loading.start),n.total=parseInt(S.headers.get("Content-Length")||"0"),a&&Object(P.isFiniteNumber)(o.highWaterMark)?t.loadProgressively(S,n,r,o.highWaterMark,a):d?S.arrayBuffer():S.text()}).then(function(S){var T=t.response;self.clearTimeout(t.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first),n.loaded=n.total=S[v];var I={url:T.url,data:S};a&&!Object(P.isFiniteNumber)(o.highWaterMark)&&a(n,r,S,T),c.onSuccess(I,n,r,T)}).catch(function(S){if(self.clearTimeout(t.requestTimeout),!n.aborted){var T=S&&S.code||0,I=S?S.message:null;c.onError({code:T,text:I},r,S?S.details:null)}})},g.getCacheAge=function(){var r=null;if(this.response){var o=this.response.headers.get("age");r=o?parseFloat(o):null}return r},g.loadProgressively=function(r,o,c,t,n){t===void 0&&(t=0);var u=new A.default,a=r.body.getReader(),d=function v(){return a.read().then(function(S){if(S.done)return u.dataLength&&n(o,c,u.flush(),r),Promise.resolve(new ArrayBuffer(0));var T=S.value,I=T.length;return o.loaded+=I,I<t||u.dataLength?(u.push(T),u.dataLength>=t&&n(o,c,u.flush(),r)):n(o,c,T,r),v()}).catch(function(){return Promise.reject()})};return d()},h}();function f(h,g){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:g,headers:new self.Headers(E({},h.headers))};return h.rangeEnd&&i.headers.set("Range","bytes="+h.rangeStart+"-"+String(h.rangeEnd-1)),i}function e(h,g){return new self.Request(h.url,g)}var s=function(h){M(g,h);function g(i,r,o){var c;return c=h.call(this,i)||this,c.code=void 0,c.details=void 0,c.code=r,c.details=o,c}return g}(O(Error));R.default=p},"./src/utils/imsc1-ttml-parser.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"IMSC1_CODEC",function(){return y}),l.d(R,"parseIMSC1",function(){return m});var P=l("./src/utils/mp4-tools.ts"),L=l("./src/utils/vttparser.ts"),A=l("./src/utils/vttcue.ts"),M=l("./src/demux/id3.ts"),O=l("./src/utils/timescale-conversion.ts"),b=l("./src/utils/webvtt-parser.ts");function _(){return _=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var u=arguments[n];for(var a in u)Object.prototype.hasOwnProperty.call(u,a)&&(t[a]=u[a])}return t},_.apply(this,arguments)}var y="stpp.ttml.im1t",x=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,D=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,E={left:"start",center:"center",right:"end",start:"start",end:"end"};function m(t,n,u,a,d){var v=Object(P.findBox)(new Uint8Array(t),["mdat"]);if(v.length===0){d(new Error("Could not parse IMSC1 mdat"));return}var S=v.map(function(I){return Object(M.utf8ArrayToStr)(I)}),T=Object(O.toTimescaleFromScale)(n,1,u);try{S.forEach(function(I){return a(p(I,T))})}catch(I){d(I)}}function p(t,n){var u=new DOMParser,a=u.parseFromString(t,"text/xml"),d=a.getElementsByTagName("tt")[0];if(!d)throw new Error("Invalid ttml");var v={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},S=Object.keys(v).reduce(function(U,W){return U[W]=d.getAttribute("ttp:"+W)||v[W],U},{}),T=d.getAttribute("xml:space")!=="preserve",I=e(f(d,"styling","style")),k=e(f(d,"layout","region")),B=f(d,"body","[begin]");return[].map.call(B,function(U){var W=s(U,T);if(!W||!U.hasAttribute("begin"))return null;var G=r(U.getAttribute("begin"),S),z=r(U.getAttribute("dur"),S),Y=r(U.getAttribute("end"),S);if(G===null)throw i(U);if(Y===null){if(z===null)throw i(U);Y=G+z}var $=new A.default(G-n,Y-n,W);$.id=Object(b.generateCueId)($.startTime,$.endTime,$.text);var Z=k[U.getAttribute("region")],q=I[U.getAttribute("style")];$.position=10,$.size=80;var ie=h(Z,q,I),ne=ie.textAlign;if(ne){var ae=E[ne];ae&&($.lineAlign=ae),$.align=ne}return _($,ie),$}).filter(function(U){return U!==null})}function f(t,n,u){var a=t.getElementsByTagName(n)[0];return a?[].slice.call(a.querySelectorAll(u)):[]}function e(t){return t.reduce(function(n,u){var a=u.getAttribute("xml:id");return a&&(n[a]=u),n},{})}function s(t,n){return[].slice.call(t.childNodes).reduce(function(u,a,d){var v;return a.nodeName==="br"&&d?u+`
|
|
21
|
+
`:(v=a.childNodes)!==null&&v!==void 0&&v.length?s(a,n):n?u+a.textContent.trim().replace(/\s+/g," "):u+a.textContent},"")}function h(t,n,u){var a="http://www.w3.org/ns/ttml#styling",d=null,v=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],S=t!=null&&t.hasAttribute("style")?t.getAttribute("style"):null;return S&&u.hasOwnProperty(S)&&(d=u[S]),v.reduce(function(T,I){var k=g(n,a,I)||g(t,a,I)||g(d,a,I);return k&&(T[I]=k),T},{})}function g(t,n,u){return t&&t.hasAttributeNS(n,u)?t.getAttributeNS(n,u):null}function i(t){return new Error("Could not parse ttml timestamp "+t)}function r(t,n){if(!t)return null;var u=Object(L.parseTimeStamp)(t);return u===null&&(x.test(t)?u=o(t,n):D.test(t)&&(u=c(t,n))),u}function o(t,n){var u=x.exec(t),a=(u[4]|0)+(u[5]|0)/n.subFrameRate;return(u[1]|0)*3600+(u[2]|0)*60+(u[3]|0)+a/n.frameRate}function c(t,n){var u=D.exec(t),a=Number(u[1]),d=u[2];switch(d){case"h":return a*3600;case"m":return a*60;case"ms":return a*1e3;case"f":return a/n.frameRate;case"t":return a/n.tickRate}return a}},"./src/utils/logger.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"enableLogs",function(){return b}),l.d(R,"logger",function(){return _});var P=function(){},L={trace:P,debug:P,log:P,warn:P,info:P,error:P},A=L;function M(y){var x=self.console[y];return x?x.bind(self.console,"["+y+"] >"):P}function O(y){for(var x=arguments.length,D=new Array(x>1?x-1:0),E=1;E<x;E++)D[E-1]=arguments[E];D.forEach(function(m){A[m]=y[m]?y[m].bind(y):M(m)})}function b(y){if(self.console&&y===!0||typeof y=="object"){O(y,"debug","log","info","warn","error");try{A.log()}catch{A=L}}else A=L}var _=A},"./src/utils/mediakeys-helper.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"KeySystems",function(){return P}),l.d(R,"requestMediaKeySystemAccess",function(){return L});var P;(function(A){A.WIDEVINE="com.widevine.alpha",A.PLAYREADY="com.microsoft.playready"})(P||(P={}));var L=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"getMediaSource",function(){return P});function P(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"RemuxerTrackIdConfig",function(){return b}),l.d(R,"bin2str",function(){return _}),l.d(R,"readUint16",function(){return y}),l.d(R,"readUint32",function(){return x}),l.d(R,"readSint32",function(){return D}),l.d(R,"writeUint32",function(){return E}),l.d(R,"findBox",function(){return m}),l.d(R,"parseSegmentIndex",function(){return p}),l.d(R,"parseInitSegment",function(){return f}),l.d(R,"getStartDTS",function(){return e}),l.d(R,"getDuration",function(){return s}),l.d(R,"computeRawDurationFromSamples",function(){return h}),l.d(R,"offsetStartDTS",function(){return g}),l.d(R,"segmentValidRange",function(){return i}),l.d(R,"appendUint8Array",function(){return r}),l.d(R,"parseSamples",function(){return o}),l.d(R,"parseSEIMessageFromNALu",function(){return n}),l.d(R,"parseEmsg",function(){return a});var P=l("./src/utils/typed-array.ts"),L=l("./src/loader/fragment.ts"),A=l("./src/demux/id3.ts"),M=Math.pow(2,32)-1,O=[].push,b={video:1,audio:2,id3:3,text:4};function _(d){return String.fromCharCode.apply(null,d)}function y(d,v){var S=d[v]<<8|d[v+1];return S<0?65536+S:S}function x(d,v){var S=D(d,v);return S<0?4294967296+S:S}function D(d,v){return d[v]<<24|d[v+1]<<16|d[v+2]<<8|d[v+3]}function E(d,v,S){d[v]=S>>24,d[v+1]=S>>16&255,d[v+2]=S>>8&255,d[v+3]=S&255}function m(d,v){var S=[];if(!v.length)return S;for(var T=d.byteLength,I=0;I<T;){var k=x(d,I),B=_(d.subarray(I+4,I+8)),U=k>1?I+k:T;if(B===v[0])if(v.length===1)S.push(d.subarray(I+8,U));else{var W=m(d.subarray(I+8,U),v.slice(1));W.length&&O.apply(S,W)}I=U}return S}function p(d){var v=[],S=d[0],T=8,I=x(d,T);T+=4;var k=0,B=0;S===0?T+=8:T+=16,T+=2;var U=d.length+B,W=y(d,T);T+=2;for(var G=0;G<W;G++){var z=T,Y=x(d,z);z+=4;var $=Y&2147483647,Z=(Y&2147483648)>>>31;if(Z===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var q=x(d,z);z+=4,v.push({referenceSize:$,subsegmentDuration:q,info:{duration:q/I,start:U,end:U+$-1}}),U+=$,z+=4,T=z}return{earliestPresentationTime:k,timescale:I,version:S,referencesCount:W,references:v}}function f(d){for(var v=[],S=m(d,["moov","trak"]),T=0;T<S.length;T++){var I=S[T],k=m(I,["tkhd"])[0];if(k){var B=k[0],U=B===0?12:20,W=x(k,U),G=m(I,["mdia","mdhd"])[0];if(G){B=G[0],U=B===0?12:20;var z=x(G,U),Y=m(I,["mdia","hdlr"])[0];if(Y){var $=_(Y.subarray(8,12)),Z={soun:L.ElementaryStreamTypes.AUDIO,vide:L.ElementaryStreamTypes.VIDEO}[$];if(Z){var q=m(I,["mdia","minf","stbl","stsd"])[0],ie=void 0;q&&(ie=_(q.subarray(12,16))),v[W]={timescale:z,type:Z},v[Z]={timescale:z,id:W,codec:ie}}}}}}var ne=m(d,["moov","mvex","trex"]);return ne.forEach(function(ae){var te=x(ae,4),fe=v[te];fe&&(fe.default={duration:x(ae,12),flags:x(ae,20)})}),v}function e(d,v){return m(v,["moof","traf"]).reduce(function(S,T){var I=m(T,["tfdt"])[0],k=I[0],B=m(T,["tfhd"]).reduce(function(U,W){var G=x(W,4),z=d[G];if(z){var Y=x(I,4);k===1&&(Y*=Math.pow(2,32),Y+=x(I,8));var $=z.timescale||9e4,Z=Y/$;if(isFinite(Z)&&(U===null||Z<U))return Z}return U},null);return B!==null&&isFinite(B)&&(S===null||B<S)?B:S},null)||0}function s(d,v){for(var S=0,T=0,I=0,k=m(d,["moof","traf"]),B=0;B<k.length;B++){var U=k[B],W=m(U,["tfhd"])[0],G=x(W,4),z=v[G];if(!!z){var Y=z.default,$=x(W,0)|(Y==null?void 0:Y.flags),Z=Y==null?void 0:Y.duration;$&8&&($&2?Z=x(W,12):Z=x(W,8));for(var q=z.timescale||9e4,ie=m(U,["trun"]),ne=0;ne<ie.length;ne++){if(S=h(ie[ne]),!S&&Z){var ae=x(ie[ne],4);S=Z*ae}z.type===L.ElementaryStreamTypes.VIDEO?T+=S/q:z.type===L.ElementaryStreamTypes.AUDIO&&(I+=S/q)}}}if(T===0&&I===0){for(var te=0,fe=m(d,["sidx"]),de=0;de<fe.length;de++){var re=p(fe[de]);re!=null&&re.references&&(te+=re.references.reduce(function(Ee,me){return Ee+me.info.duration||0},0))}return te}return T||I}function h(d){var v=x(d,0),S=8;v&1&&(S+=4),v&4&&(S+=4);for(var T=0,I=x(d,4),k=0;k<I;k++){if(v&256){var B=x(d,S);T+=B,S+=4}v&512&&(S+=4),v&1024&&(S+=4),v&2048&&(S+=4)}return T}function g(d,v,S){m(v,["moof","traf"]).forEach(function(T){m(T,["tfhd"]).forEach(function(I){var k=x(I,4),B=d[k];if(!!B){var U=B.timescale||9e4;m(T,["tfdt"]).forEach(function(W){var G=W[0],z=x(W,4);if(G===0)z-=S*U,z=Math.max(z,0),E(W,4,z);else{z*=Math.pow(2,32),z+=x(W,8),z-=S*U,z=Math.max(z,0);var Y=Math.floor(z/(M+1)),$=Math.floor(z%(M+1));E(W,4,Y),E(W,8,$)}})}})})}function i(d){var v={valid:null,remainder:null},S=m(d,["moof"]);if(S){if(S.length<2)return v.remainder=d,v}else return v;var T=S[S.length-1];return v.valid=Object(P.sliceUint8)(d,0,T.byteOffset-8),v.remainder=Object(P.sliceUint8)(d,T.byteOffset-8),v}function r(d,v){var S=new Uint8Array(d.length+v.length);return S.set(d),S.set(v,d.length),S}function o(d,v){var S=[],T=v.samples,I=v.timescale,k=v.id,B=!1,U=m(T,["moof"]);return U.map(function(W){var G=W.byteOffset-8,z=m(W,["traf"]);z.map(function(Y){var $=m(Y,["tfdt"]).map(function(Z){var q=Z[0],ie=x(Z,4);return q===1&&(ie*=Math.pow(2,32),ie+=x(Z,8)),ie/I})[0];return $!==void 0&&(d=$),m(Y,["tfhd"]).map(function(Z){var q=x(Z,4),ie=x(Z,0)&16777215,ne=(ie&1)!==0,ae=(ie&2)!==0,te=(ie&8)!==0,fe=0,de=(ie&16)!==0,re=0,Ee=(ie&32)!==0,me=8;q===k&&(ne&&(me+=8),ae&&(me+=4),te&&(fe=x(Z,me),me+=4),de&&(re=x(Z,me),me+=4),Ee&&(me+=4),v.type==="video"&&(B=c(v.codec)),m(Y,["trun"]).map(function(Te){var Me=Te[0],_e=x(Te,0)&16777215,ke=(_e&1)!==0,Ie=0,Be=(_e&4)!==0,be=(_e&256)!==0,Ue=0,Ke=(_e&512)!==0,je=0,Ne=(_e&1024)!==0,qe=(_e&2048)!==0,Fe=0,et=x(Te,4),Oe=8;ke&&(Ie=x(Te,Oe),Oe+=4),Be&&(Oe+=4);for(var Pe=Ie+G,Ve=0;Ve<et;Ve++){if(be?(Ue=x(Te,Oe),Oe+=4):Ue=fe,Ke?(je=x(Te,Oe),Oe+=4):je=re,Ne&&(Oe+=4),qe&&(Me===0?Fe=x(Te,Oe):Fe=D(Te,Oe),Oe+=4),v.type===L.ElementaryStreamTypes.VIDEO)for(var Ce=0;Ce<je;){var Le=x(T,Pe);Pe+=4;var it=T[Pe]&31;if(t(B,it)){var We=T.subarray(Pe,Pe+Le);n(We,d+Fe/I,S)}Pe+=Le,Ce+=Le+4}d+=Ue/I}}))})})}),S}function c(d){if(!d)return!1;var v=d.indexOf("."),S=v<0?d:d.substring(0,v);return S==="hvc1"||S==="hev1"||S==="dvh1"||S==="dvhe"}function t(d,v){return d?v===39||v===40:v===6}function n(d,v,S){var T=u(d),I=0;I++;for(var k=0,B=0,U=!1,W=0;I<T.length;){k=0;do{if(I>=T.length)break;W=T[I++],k+=W}while(W===255);B=0;do{if(I>=T.length)break;W=T[I++],B+=W}while(W===255);var G=T.length-I;if(!U&&k===4&&I<T.length){U=!0;var z=T[I++];if(z===181){var Y=y(T,I);if(I+=2,Y===49){var $=x(T,I);if(I+=4,$===1195456820){var Z=T[I++];if(Z===3){var q=T[I++],ie=31&q,ne=64&q,ae=ne?2+ie*3:0,te=new Uint8Array(ae);if(ne){te[0]=q;for(var fe=1;fe<ae;fe++)te[fe]=T[I++]}S.push({type:Z,payloadType:k,pts:v,bytes:te})}}}}}else if(k===5&&B<G){if(U=!0,B>16){for(var de=[],re=0;re<16;re++){var Ee=T[I++].toString(16);de.push(Ee.length==1?"0"+Ee:Ee),(re===3||re===5||re===7||re===9)&&de.push("-")}for(var me=B-16,Te=new Uint8Array(me),Me=0;Me<me;Me++)Te[Me]=T[I++];S.push({payloadType:k,pts:v,uuid:de.join(""),userData:Object(A.utf8ArrayToStr)(Te),userDataBytes:Te})}}else if(B<G)I+=B;else if(B>G)break}}function u(d){for(var v=d.byteLength,S=[],T=1;T<v-2;)d[T]===0&&d[T+1]===0&&d[T+2]===3?(S.push(T+2),T+=2):T++;if(S.length===0)return d;var I=v-S.length,k=new Uint8Array(I),B=0;for(T=0;T<I;B++,T++)B===S[0]&&(B++,S.shift()),k[T]=d[B];return k}function a(d){var v=d[0],S="",T="",I=0,k=0,B=0,U=0,W=0,G=0;if(v===0){for(;_(d.subarray(G,G+1))!=="\0";)S+=_(d.subarray(G,G+1)),G+=1;for(S+=_(d.subarray(G,G+1)),G+=1;_(d.subarray(G,G+1))!=="\0";)T+=_(d.subarray(G,G+1)),G+=1;T+=_(d.subarray(G,G+1)),G+=1,I=x(d,12),k=x(d,16),U=x(d,20),W=x(d,24),G=28}else if(v===1){G+=4,I=x(d,G),G+=4;var z=x(d,G);G+=4;var Y=x(d,G);for(G+=4,B=Math.pow(2,32)*z+Y,Number.isSafeInteger(B)||(B=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),U=x(d,G),G+=4,W=x(d,G),G+=4;_(d.subarray(G,G+1))!=="\0";)S+=_(d.subarray(G,G+1)),G+=1;for(S+=_(d.subarray(G,G+1)),G+=1;_(d.subarray(G,G+1))!=="\0";)T+=_(d.subarray(G,G+1)),G+=1;T+=_(d.subarray(G,G+1)),G+=1}var $=d.subarray(G,d.byteLength);return{schemeIdUri:S,value:T,timeScale:I,presentationTime:B,presentationTimeDelta:k,eventDuration:U,id:W,payload:$}}},"./src/utils/output-filter.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"default",function(){return P});var P=function(){function L(M,O){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=M,this.trackName=O}var A=L.prototype;return A.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},A.newCue=function(O,b,_){(this.startTime===null||this.startTime>O)&&(this.startTime=O),this.endTime=b,this.screen=_,this.timelineController.createCaptionsTrack(this.trackName)},A.reset=function(){this.cueRanges=[],this.startTime=null},L}()},"./src/utils/texttrack-utils.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"sendAddTrackEvent",function(){return L}),l.d(R,"addCueToTrack",function(){return A}),l.d(R,"clearCurrentCues",function(){return M}),l.d(R,"removeCuesInRange",function(){return O}),l.d(R,"getCuesInRange",function(){return _});var P=l("./src/utils/logger.ts");function L(y,x){var D;try{D=new Event("addtrack")}catch{D=document.createEvent("Event"),D.initEvent("addtrack",!1,!1)}D.track=y,x.dispatchEvent(D)}function A(y,x){var D=y.mode;if(D==="disabled"&&(y.mode="hidden"),y.cues&&!y.cues.getCueById(x.id))try{if(y.addCue(x),!y.cues.getCueById(x.id))throw new Error("addCue is failed for: "+x)}catch(m){P.logger.debug("[texttrack-utils]: "+m);var E=new self.TextTrackCue(x.startTime,x.endTime,x.text);E.id=x.id,y.addCue(E)}D==="disabled"&&(y.mode=D)}function M(y){var x=y.mode;if(x==="disabled"&&(y.mode="hidden"),y.cues)for(var D=y.cues.length;D--;)y.removeCue(y.cues[D]);x==="disabled"&&(y.mode=x)}function O(y,x,D,E){var m=y.mode;if(m==="disabled"&&(y.mode="hidden"),y.cues&&y.cues.length>0)for(var p=_(y.cues,x,D),f=0;f<p.length;f++)(!E||E(p[f]))&&y.removeCue(p[f]);m==="disabled"&&(y.mode=m)}function b(y,x){if(x<y[0].startTime)return 0;var D=y.length-1;if(x>y[D].endTime)return-1;for(var E=0,m=D;E<=m;){var p=Math.floor((m+E)/2);if(x<y[p].startTime)m=p-1;else if(x>y[p].startTime&&E<D)E=p+1;else return p}return y[E].startTime-x<x-y[m].startTime?E:m}function _(y,x,D){var E=[],m=b(y,x);if(m>-1)for(var p=m,f=y.length;p<f;p++){var e=y[p];if(e.startTime>=x&&e.endTime<=D)E.push(e);else if(e.startTime>D)return E}return E}},"./src/utils/time-ranges.ts":function(j,R,l){"use strict";l.r(R);var P={toString:function(A){for(var M="",O=A.length,b=0;b<O;b++)M+="["+A.start(b).toFixed(3)+","+A.end(b).toFixed(3)+"]";return M}};R.default=P},"./src/utils/timescale-conversion.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"toTimescaleFromBase",function(){return L}),l.d(R,"toTimescaleFromScale",function(){return A}),l.d(R,"toMsFromMpegTsClock",function(){return M}),l.d(R,"toMpegTsClockFromTimescale",function(){return O});var P=9e4;function L(b,_,y,x){y===void 0&&(y=1),x===void 0&&(x=!1);var D=b*_*y;return x?Math.round(D):D}function A(b,_,y,x){return y===void 0&&(y=1),x===void 0&&(x=!1),L(b,_,1/y,x)}function M(b,_){return _===void 0&&(_=!1),L(b,1e3,1/P,_)}function O(b,_){return _===void 0&&(_=1),L(b,P,1/_)}},"./src/utils/typed-array.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"sliceUint8",function(){return P});function P(L,A,M){return Uint8Array.prototype.slice?L.slice(A,M):new Uint8Array(Array.prototype.slice.call(L,A,M))}},"./src/utils/vttcue.ts":function(j,R,l){"use strict";l.r(R),R.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var P=["","lr","rl"],L=["start","middle","end","left","right"];function A(y,x){if(typeof x!="string"||!Array.isArray(y))return!1;var D=x.toLowerCase();return~y.indexOf(D)?D:!1}function M(y){return A(P,y)}function O(y){return A(L,y)}function b(y){for(var x=arguments.length,D=new Array(x>1?x-1:0),E=1;E<x;E++)D[E-1]=arguments[E];for(var m=1;m<arguments.length;m++){var p=arguments[m];for(var f in p)y[f]=p[f]}return y}function _(y,x,D){var E=this,m={enumerable:!0};E.hasBeenReset=!1;var p="",f=!1,e=y,s=x,h=D,g=null,i="",r=!0,o="auto",c="start",t=50,n="middle",u=50,a="middle";Object.defineProperty(E,"id",b({},m,{get:function(){return p},set:function(v){p=""+v}})),Object.defineProperty(E,"pauseOnExit",b({},m,{get:function(){return f},set:function(v){f=!!v}})),Object.defineProperty(E,"startTime",b({},m,{get:function(){return e},set:function(v){if(typeof v!="number")throw new TypeError("Start time must be set to a number.");e=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"endTime",b({},m,{get:function(){return s},set:function(v){if(typeof v!="number")throw new TypeError("End time must be set to a number.");s=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"text",b({},m,{get:function(){return h},set:function(v){h=""+v,this.hasBeenReset=!0}})),Object.defineProperty(E,"region",b({},m,{get:function(){return g},set:function(v){g=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"vertical",b({},m,{get:function(){return i},set:function(v){var S=M(v);if(S===!1)throw new SyntaxError("An invalid or illegal string was specified.");i=S,this.hasBeenReset=!0}})),Object.defineProperty(E,"snapToLines",b({},m,{get:function(){return r},set:function(v){r=!!v,this.hasBeenReset=!0}})),Object.defineProperty(E,"line",b({},m,{get:function(){return o},set:function(v){if(typeof v!="number"&&v!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");o=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"lineAlign",b({},m,{get:function(){return c},set:function(v){var S=O(v);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");c=S,this.hasBeenReset=!0}})),Object.defineProperty(E,"position",b({},m,{get:function(){return t},set:function(v){if(v<0||v>100)throw new Error("Position must be between 0 and 100.");t=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"positionAlign",b({},m,{get:function(){return n},set:function(v){var S=O(v);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");n=S,this.hasBeenReset=!0}})),Object.defineProperty(E,"size",b({},m,{get:function(){return u},set:function(v){if(v<0||v>100)throw new Error("Size must be between 0 and 100.");u=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"align",b({},m,{get:function(){return a},set:function(v){var S=O(v);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");a=S,this.hasBeenReset=!0}})),E.displayState=void 0}return _.prototype.getCueAsHTML=function(){var y=self.WebVTT;return y.convertCueToDOMTree(self,this.text)},_}()},"./src/utils/vttparser.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"parseTimeStamp",function(){return A}),l.d(R,"fixLineBreaks",function(){return x}),l.d(R,"VTTParser",function(){return D});var P=l("./src/utils/vttcue.ts"),L=function(){function E(){}var m=E.prototype;return m.decode=function(f,e){if(!f)return"";if(typeof f!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(f))},E}();function A(E){function m(f,e,s,h){return(f|0)*3600+(e|0)*60+(s|0)+parseFloat(h||0)}var p=E.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return p?parseFloat(p[2])>59?m(p[2],p[3],0,p[4]):m(p[1],p[2],p[3],p[4]):null}var M=function(){function E(){this.values=Object.create(null)}var m=E.prototype;return m.set=function(f,e){!this.get(f)&&e!==""&&(this.values[f]=e)},m.get=function(f,e,s){return s?this.has(f)?this.values[f]:e[s]:this.has(f)?this.values[f]:e},m.has=function(f){return f in this.values},m.alt=function(f,e,s){for(var h=0;h<s.length;++h)if(e===s[h]){this.set(f,e);break}},m.integer=function(f,e){/^-?\d+$/.test(e)&&this.set(f,parseInt(e,10))},m.percent=function(f,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){var s=parseFloat(e);if(s>=0&&s<=100)return this.set(f,s),!0}return!1},E}();function O(E,m,p,f){var e=f?E.split(f):[E];for(var s in e)if(typeof e[s]=="string"){var h=e[s].split(p);if(h.length===2){var g=h[0],i=h[1];m(g,i)}}}var b=new P.default(0,0,""),_=b.align==="middle"?"middle":"center";function y(E,m,p){var f=E;function e(){var g=A(E);if(g===null)throw new Error("Malformed timestamp: "+f);return E=E.replace(/^[^\sa-zA-Z-]+/,""),g}function s(g,i){var r=new M;O(g,function(t,n){var u;switch(t){case"region":for(var a=p.length-1;a>=0;a--)if(p[a].id===n){r.set(t,p[a].region);break}break;case"vertical":r.alt(t,n,["rl","lr"]);break;case"line":u=n.split(","),r.integer(t,u[0]),r.percent(t,u[0])&&r.set("snapToLines",!1),r.alt(t,u[0],["auto"]),u.length===2&&r.alt("lineAlign",u[1],["start",_,"end"]);break;case"position":u=n.split(","),r.percent(t,u[0]),u.length===2&&r.alt("positionAlign",u[1],["start",_,"end","line-left","line-right","auto"]);break;case"size":r.percent(t,n);break;case"align":r.alt(t,n,["start",_,"end","left","right"]);break}},/:/,/\s/),i.region=r.get("region",null),i.vertical=r.get("vertical","");var o=r.get("line","auto");o==="auto"&&b.line===-1&&(o=-1),i.line=o,i.lineAlign=r.get("lineAlign","start"),i.snapToLines=r.get("snapToLines",!0),i.size=r.get("size",100),i.align=r.get("align",_);var c=r.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 h(){E=E.replace(/^\s+/,"")}if(h(),m.startTime=e(),h(),E.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+f);E=E.slice(3),h(),m.endTime=e(),h(),s(E,m)}function x(E){return E.replace(/<br(?: \/)?>/gi,`
|
|
22
|
+
`)}var D=function(){function E(){this.state="INITIAL",this.buffer="",this.decoder=new L,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var m=E.prototype;return m.parse=function(f){var e=this;f&&(e.buffer+=e.decoder.decode(f,{stream:!0}));function s(){var c=e.buffer,t=0;for(c=x(c);t<c.length&&c[t]!=="\r"&&c[t]!==`
|
|
23
|
+
`;)++t;var n=c.slice(0,t);return c[t]==="\r"&&++t,c[t]===`
|
|
24
|
+
`&&++t,e.buffer=c.slice(t),n}function h(c){O(c,function(t,n){},/:/)}try{var g="";if(e.state==="INITIAL"){if(!/\r\n|\n/.test(e.buffer))return this;g=s();var i=g.match(/^()?WEBVTT([ \t].*)?$/);if(!i||!i[0])throw new Error("Malformed WebVTT signature.");e.state="HEADER"}for(var r=!1;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(r?r=!1:g=s(),e.state){case"HEADER":/:/.test(g)?h(g):g||(e.state="ID");continue;case"NOTE":g||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(g)){e.state="NOTE";break}if(!g)continue;if(e.cue=new P.default(0,0,""),e.state="CUE",g.indexOf("-->")===-1){e.cue.id=g;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{y(g,e.cue,e.regionList)}catch{e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":{var o=g.indexOf("-->")!==-1;if(!g||o&&(r=!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+=`
|
|
25
|
+
`),e.cue.text+=g}continue;case"BADCUE":g||(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},m.flush=function(){var f=this;try{if((f.cue||f.state==="HEADER")&&(f.buffer+=`
|
|
25
26
|
|
|
26
|
-
`,
|
|
27
|
+
`,f.parse()),f.state==="INITIAL"||f.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){f.onparsingerror&&f.onparsingerror(e)}return f.onflush&&f.onflush(),this},E}()},"./src/utils/webvtt-parser.ts":function(j,R,l){"use strict";l.r(R),l.d(R,"generateCueId",function(){return D}),l.d(R,"parseWebVTT",function(){return m});var P=l("./src/polyfills/number.ts"),L=l("./src/utils/vttparser.ts"),A=l("./src/demux/id3.ts"),M=l("./src/utils/timescale-conversion.ts"),O=l("./src/remux/mp4-remuxer.ts"),b=/\r\n|\n\r|\n|\r/g,_=function(f,e,s){return s===void 0&&(s=0),f.slice(s,s+e.length)===e},y=function(f){var e=parseInt(f.slice(-3)),s=parseInt(f.slice(-6,-4)),h=parseInt(f.slice(-9,-7)),g=f.length>9?parseInt(f.substring(0,f.indexOf(":"))):0;if(!Object(P.isFiniteNumber)(e)||!Object(P.isFiniteNumber)(s)||!Object(P.isFiniteNumber)(h)||!Object(P.isFiniteNumber)(g))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+f);return e+=1e3*s,e+=60*1e3*h,e+=60*60*1e3*g,e},x=function(f){for(var e=5381,s=f.length;s;)e=e*33^f.charCodeAt(--s);return(e>>>0).toString()};function D(p,f,e){return x(p.toString())+x(f.toString())+x(e)}var E=function(f,e,s){var h=f[e],g=f[h.prevCC];if(!g||!g.new&&h.new){f.ccOffset=f.presentationOffset=h.start,h.new=!1;return}for(;(i=g)!==null&&i!==void 0&&i.new;){var i;f.ccOffset+=h.start-g.start,h.new=!1,h=g,g=f[h.prevCC]}f.presentationOffset=s};function m(p,f,e,s,h,g,i,r){var o=new L.VTTParser,c=Object(A.utf8ArrayToStr)(new Uint8Array(p)).trim().replace(b,`
|
|
27
28
|
`).split(`
|
|
28
|
-
`),
|
|
29
|
-
`)}),u.flush()}},"./src/utils/xhr-loader.ts":function(k,P,s){"use strict";s.r(P);var R=s("./src/utils/logger.ts"),p=s("./src/loader/load-stats.ts"),x=/^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 p.LoadStats,this.retryDelay=0}var L=T.prototype;return L.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},L.abortInternal=function(){var y=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),y&&(y.onreadystatechange=null,y.onprogress=null,y.readyState!==4&&(this.stats.aborted=!0,y.abort()))},L.abort=function(){var y;this.abortInternal(),(y=this.callbacks)!==null&&y!==void 0&&y.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},L.load=function(y,D,A){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=y,this.config=D,this.callbacks=A,this.retryDelay=D.retryDelay,this.loadInternal()},L.loadInternal=function(){var y=this.config,D=this.context;if(!!y){var A=this.loader=new self.XMLHttpRequest,S=this.stats;S.loading.first=0,S.loaded=0;var g=this.xhrSetup;try{if(g)try{g(A,D.url)}catch{A.open("GET",D.url,!0),g(A,D.url)}A.readyState||A.open("GET",D.url,!0);var E=this.context.headers;if(E)for(var a in E)A.setRequestHeader(a,E[a])}catch(e){this.callbacks.onError({code:A.status,text:e.message},D,A);return}D.rangeEnd&&A.setRequestHeader("Range","bytes="+D.rangeStart+"-"+(D.rangeEnd-1)),A.onreadystatechange=this.readystatechange.bind(this),A.onprogress=this.loadprogress.bind(this),A.responseType=D.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),y.timeout),A.send()}},L.readystatechange=function(){var y=this.context,D=this.loader,A=this.stats;if(!(!y||!D)){var S=D.readyState,g=this.config;if(!A.aborted&&S>=2)if(self.clearTimeout(this.requestTimeout),A.loading.first===0&&(A.loading.first=Math.max(self.performance.now(),A.loading.start)),S===4){D.onreadystatechange=null,D.onprogress=null;var E=D.status;if(E>=200&&E<300){A.loading.end=Math.max(self.performance.now(),A.loading.first);var a,e;if(y.responseType==="arraybuffer"?(a=D.response,e=a.byteLength):(a=D.responseText,e=a.length),A.loaded=A.total=e,!this.callbacks)return;var o=this.callbacks.onProgress;if(o&&o(A,y,a,D),!this.callbacks)return;var f={url:D.responseURL,data:a};this.callbacks.onSuccess(f,A,y,D)}else A.retry>=g.maxRetry||E>=400&&E<499?(R.logger.error(E+" while loading "+y.url),this.callbacks.onError({code:E,text:D.statusText},y,D)):(R.logger.warn(E+" while loading "+y.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,g.maxRetryDelay),A.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),g.timeout)}},L.loadtimeout=function(){R.logger.warn("timeout while loading "+this.context.url);var y=this.callbacks;y&&(this.abortInternal(),y.onTimeout(this.stats,this.context,this.loader))},L.loadprogress=function(y){var D=this.stats;D.loaded=y.loaded,y.lengthComputable&&(D.total=y.total)},L.getCacheAge=function(){var y=null;if(this.loader&&x.test(this.loader.getAllResponseHeaders())){var D=this.loader.getResponseHeader("age");y=D?parseFloat(D):null}return y},T}();P.default=I}}).default})});var He=class{addEventListener(){}removeEventListener(){}dispatchEvent(P){return!0}};if(typeof DocumentFragment=="undefined"){class k extends He{}globalThis.DocumentFragment=k}var et=class extends He{},St=class extends He{},gr={get(k){},define(k,P,s){},upgrade(k){},whenDefined(k){return Promise.resolve(et)}},tt,Dt=class{constructor(P,s={}){qe(this,tt,void 0);vt(this,tt,s==null?void 0:s.detail)}get detail(){return ht(this,tt)}initCustomEvent(){}};tt=new WeakMap;function mr(k,P){return new et}var kt={document:{createElement:mr},DocumentFragment,customElements:gr,CustomEvent:Dt,EventTarget:He,HTMLElement:et,HTMLVideoElement:St},Nt=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Ie=Nt?kt:globalThis,At=Nt?kt.document:globalThis.document;var Mt=ct(jt(),1),Ue=ct(pt(),1),bt=ct(pt(),1),Ve=ct(pt(),1),it=class extends Error{constructor(k,P=it.MEDIA_ERR_CUSTOM,s){var R;super(k),this.name="MediaError",this.code=P,this.fatal=s!=null?s:P>=it.MEDIA_ERR_NETWORK&&P<=it.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(R=it.defaultMessages[this.code])!=null?R:"")}},Pe=it;Pe.MEDIA_ERR_ABORTED=1,Pe.MEDIA_ERR_NETWORK=2,Pe.MEDIA_ERR_DECODE=3,Pe.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Pe.MEDIA_ERR_ENCRYPTED=5,Pe.MEDIA_ERR_CUSTOM=100,Pe.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 Yt=(k,P)=>k in P,Rt={ANY:"any",MUTED:"muted"},yt={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},ke={MSE:"mse",NATIVE:"native"},Ye={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},Pt={HLS:Ye.M3U8},Wr=Object.keys(Pt),Gr=[...Object.values(Ye),"hls","HLS"],nt=(k,P,s,R)=>{k.addEventListener(P,s,R),k.addEventListener("teardown",()=>{k.removeEventListener(P,s)},{once:!0})};function pr(k,P,s){P&&s>P&&(s=P);for(let R=0;R<k.length;R++)if(k.start(R)<=s&&k.end(R)>=s)return!0;return!1}var yr=k=>{let P=k.indexOf("?");if(P<0)return[k];let s=k.slice(0,P),R=k.slice(P);return[s,R]},zt=k=>{let P=k.type;if(P){let R=P.toUpperCase();return Yt(R,Pt)?Pt[R]:P}let{src:s}=k;return s?Er(s):""},Er=k=>{let P="";try{P=new URL(k).pathname}catch{console.error("invalid url")}let s=P.lastIndexOf(".");if(s<0)return"";let R=P.slice(s+1).toUpperCase();return Yt(R,Ye)?Ye[R]:""},Tr=Object.values(Rt),Kt=k=>typeof k=="boolean"||typeof k=="string"&&Tr.includes(k),xr=({autoplay:k},P,s)=>{if(!P)return()=>{};let R=!1,p=!1,x=Kt(k)?k:!!k,I=()=>{R||nt(P,"playing",()=>{R=!0},{once:!0})};if(I(),nt(P,"loadstart",()=>{R=!1,I(),Ot(P,x)},{once:!0}),nt(P,"loadstart",()=>{s||(p=!Number.isFinite(P.duration)),Ot(P,x)},{once:!0}),s&&s.once(bt.default.Events.LEVEL_LOADED,(T,L)=>{var _;p=(_=L.details.live)!=null?_:!1}),!x){let T=()=>{!p||(s!=null&&s.liveSyncPosition?P.currentTime=s.liveSyncPosition:Number.isFinite(P.seekable.end(0))&&(P.currentTime=P.seekable.end(0)))};s&&nt(P,"play",()=>{P.preload==="metadata"?s.once(bt.default.Events.LEVEL_UPDATED,T):T()},{once:!0})}return T=>{R||(x=Kt(T)?T:!!T,Ot(P,x))}},Ot=(k,P)=>{if(!P)return;let s=k.muted,R=()=>k.muted=s;switch(P){case Rt.ANY:k.play().catch(()=>{k.muted=!0,k.play().catch(R)});break;case Rt.MUTED:k.muted=!0,k.play().catch(R);break;default:k.play().catch(()=>{});break}},Sr=({preload:k,src:P},s,R)=>{if(!s)return()=>{};let p=D=>{D!=null&&["","none","metadata","auto"].includes(D)?s.setAttribute("preload",D):s.removeAttribute("preload")};if(!R)return p(k),p;let x=!1,I=!1,T=R.config.maxBufferLength,L=R.config.maxBufferSize,_=D=>{p(D);let A=D!=null?D:s.preload;I||A==="none"||(A==="metadata"?(R.config.maxBufferLength=1,R.config.maxBufferSize=1):(R.config.maxBufferLength=T,R.config.maxBufferSize=L),y())},y=()=>{!x&&P&&(x=!0,R.loadSource(P))};return nt(s,"play",()=>{I=!0,R.config.maxBufferLength=T,R.config.maxBufferSize=L,y()},{once:!0}),_(k),_};function Dr(k,P){P.on(Ve.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(p,{tracks:x})=>{x.forEach(I=>{var T;let L=(T=I.subtitleTrack)!=null?T:I.closedCaptions,_=P.subtitleTracks.findIndex(({lang:y,name:D,type:A})=>y==(L==null?void 0:L.lang)&&D===I.label&&A.toLowerCase()===I.kind);Ar(k,I.kind,I.label,L==null?void 0:L.lang,`${I.kind}${_}`)})});let s=()=>{var p;if(!P.subtitleTracks.length)return;let x=Array.from(k.textTracks).find(T=>T.id&&T.mode==="showing"&&["subtitles","captions"].includes(T.kind)),I=`${(p=P.subtitleTracks[P.subtitleTrack])==null?void 0:p.type.toLowerCase()}${P.subtitleTrack}`;if(x&&(P.subtitleTrack<0||(x==null?void 0:x.id)!==I)){let T=P.subtitleTracks.findIndex(({lang:L,name:_,type:y})=>L==x.language&&_===x.label&&y.toLowerCase()===x.kind);P.subtitleTrack=T}x&&(x==null?void 0:x.id)===I&&x.cues&&Array.from(x.cues).forEach(T=>{x.addCue(T)})};k.textTracks.addEventListener("change",s),P.on(Ve.default.Events.CUES_PARSED,(p,{track:x,cues:I})=>{let T=k.textTracks.getTrackById(x);if(!T)return;let L=T.mode==="disabled";L&&(T.mode="hidden"),I.forEach(_=>{var y;(y=T.cues)!=null&&y.getCueById(_.id)||T.addCue(_)}),L&&(T.mode="disabled")}),P.once(Ve.default.Events.DESTROYING,()=>{k.textTracks.removeEventListener("change",s),k.querySelectorAll("track[data-removeondestroy]").forEach(p=>{p.remove()})});let R=()=>{Array.from(k.textTracks).forEach(p=>{var x,I;if(!["subtitles","caption"].includes(p.kind)&&p.label==="thumbnails"){if(!((x=p.cues)!=null&&x.length)){let T=k.querySelector('track[label="thumbnails"]'),L=(I=T==null?void 0:T.getAttribute("src"))!=null?I:"";T==null||T.removeAttribute("src"),setTimeout(()=>{T==null||T.setAttribute("src",L)},0)}p.mode!=="hidden"&&(p.mode="hidden")}})};P.once(Ve.default.Events.MANIFEST_LOADED,R),P.once(Ve.default.Events.MEDIA_ATTACHED,R)}function Ar(k,P,s,R,p){let x=document.createElement("track");return x.kind=P,x.label=s,R&&(x.srclang=R),p&&(x.id=p),x.track.mode="disabled",x.setAttribute("data-removeondestroy",""),k.append(x),x.track}var Wt,Gt,_r=(Gt=(Wt=globalThis==null?void 0:globalThis.navigator)==null?void 0:Wt.userAgent)!=null?Gt:"",Lr=_r.toLowerCase().indexOf("android")!==-1,at=new WeakMap,Xt="mux.com",Ht,Vt,Qt=(Vt=(Ht=Ue.default).isSupported)==null?void 0:Vt.call(Ht),Or=Lr,Jt=()=>Mt.default.utils.now(),$t=(k,{domain:P=Xt}={})=>{if(!k)return;let[s,R=""]=yr(k);return`https://stream.${P}/${s}.m3u8${R}`};var Zt=(k,P,s)=>{Ct(P,s),at.set(P,{});let R=br(k,P);Ir(k,P,R),Mr(k,P,R);let p=xr(k,P,R),x=Sr(k,P,R);return{engine:R,setAutoplay:p,setPreload:x}},Ct=(k,P)=>{let s=P==null?void 0:P.engine;s&&(s.detachMedia(),s.destroy()),(k==null?void 0:k.mux)&&!k.mux.deleted&&(k.mux.destroy(),delete k.mux),k&&(k.removeAttribute("src"),k.load(),k.removeEventListener("error",tr),k.removeEventListener("error",It),k.removeEventListener("durationchange",er),at.delete(k),k.dispatchEvent(new Event("teardown")))};function qt(k,P){var s;let R=zt(k);if(R!==Ye.M3U8)return!0;let p=!R||((s=P==null?void 0:P.canPlayType(R))!=null?s:!0),{preferPlayback:x}=k,I=x===ke.MSE,T=x===ke.NATIVE;return p&&(T||!(Qt&&(I||Or)))}var br=(k,P)=>{let{debug:s,streamType:R,startTime:p=-1}=k,x=zt(k)===Ye.M3U8,I=qt(k,P);if(x&&!I&&Qt){let T={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},L=Rr(R);return new Ue.default({debug:s,startPosition:p,...T,...L})}},Rr=k=>[yt.LIVE,yt.DVR].includes(k)?{backBufferLength:8}:[yt.LL_LIVE,yt.LL_DVR].includes(k)?{backBufferLength:4,maxFragLookUpTolerance:.001}:{},Pr=({playbackId:k,src:P,customDomain:s})=>{if(k)return!0;if(typeof P!="string")return!1;let R=window==null?void 0:window.location.href,p=new URL(P,R).hostname.toLocaleLowerCase();return p.includes(Xt)||!!s&&p.includes(s.toLocaleLowerCase())},Ir=(k,P,s)=>{let{envKey:R}=k,p=Pr(k);if((R||p)&&P){let{playerInitTime:x,playerSoftwareName:I,playerSoftwareVersion:T,beaconCollectionDomain:L,metadata:_,debug:y}=k,D=A=>typeof A.player_error_code=="string"?!1:typeof k.errorTranslator=="function"?k.errorTranslator(A):A;Mt.default.monitor(P,{debug:y,beaconCollectionDomain:L,hlsjs:s,Hls:s?Ue.default:void 0,automaticErrorTracking:!1,errorTranslator:D,data:{...R?{env_key:R}:{},player_software_name:I,player_software:I,player_software_version:T,player_init_time:x,..._}})}},Mr=(k,P,s)=>{var R;if(!P){console.warn("attempting to load media before mediaEl exists");return}let p=qt(k,P),{src:x}=k;P&&p?(typeof x=="string"?(P.setAttribute("src",x),k.startTime&&(((R=at.get(P))!=null?R:{}).startTime=k.startTime,P.addEventListener("durationchange",er,{once:!0}))):P.removeAttribute("src"),P.addEventListener("error",tr),P.addEventListener("error",It)):s&&x?(s.on(Ue.default.Events.ERROR,(I,T)=>{let L={[Ue.default.ErrorTypes.NETWORK_ERROR]:Pe.MEDIA_ERR_NETWORK,[Ue.default.ErrorTypes.MEDIA_ERROR]:Pe.MEDIA_ERR_DECODE},_=new Pe("",L[T.type]);_.fatal=T.fatal,_.data=T,P.dispatchEvent(new CustomEvent("error",{detail:_}))}),P.addEventListener("error",It),Dr(P,s),s.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 er(k){var P;let s=k.target,R=(P=at.get(s))==null?void 0:P.startTime;if(!!R&&pr(s.seekable,s.duration,R)){let p=s.preload==="auto";p&&(s.preload="none"),s.currentTime=R,p&&(s.preload="auto")}}async function tr(k){if(!k.isTrusted)return;k.stopImmediatePropagation();let P=k.target;if(!(P!=null&&P.error))return;let{message:s,code:R}=P.error,p=new Pe(s,R);if(P.src&&(R!==Pe.MEDIA_ERR_DECODE||R!==void 0))try{let{status:x}=await fetch(P.src);p.data={response:{code:x}}}catch{}P.dispatchEvent(new CustomEvent("error",{detail:p}))}function It(k){var P,s;if(!(k instanceof CustomEvent)||!(k.detail instanceof Pe))return;let R=k.target,p=k.detail;!p||!p.fatal||(((P=at.get(R))!=null?P:{}).error=p,(s=R.mux)==null||s.emit("error",{player_error_code:p.code,player_error_message:p.message}))}var Cr=()=>{try{return"0.7.0"}catch{}return"UNKNOWN"},Fr=Cr(),rr=()=>Fr;var ir=["abort","canplay","canplaythrough","durationchange","emptied","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting"],nr=At.createElement("template");nr.innerHTML=`
|
|
29
|
+
`),t=[],n=Object(M.toMpegTsClockFromTimescale)(f,e),u="00:00.000",a=0,d=0,v,S=!0;o.oncue=function(T){var I=s[h],k=s.ccOffset,B=(a-n)/9e4;I!=null&&I.new&&(d!==void 0?k=s.ccOffset=I.start:E(s,h,B)),B&&(k=B-s.presentationOffset);var U=T.endTime-T.startTime,W=Object(O.normalizePts)((T.startTime+k-d)*9e4,g*9e4)/9e4;T.startTime=Math.max(W,0),T.endTime=Math.max(W+U,0);var G=T.text.trim();T.text=decodeURIComponent(encodeURIComponent(G)),T.id||(T.id=D(T.startTime,T.endTime,G)),T.endTime>0&&t.push(T)},o.onparsingerror=function(T){v=T},o.onflush=function(){if(v){r(v);return}i(t)},c.forEach(function(T){if(S)if(_(T,"X-TIMESTAMP-MAP=")){S=!1,T.slice(16).split(",").forEach(function(I){_(I,"LOCAL:")?u=I.slice(6):_(I,"MPEGTS:")&&(a=parseInt(I.slice(7)))});try{d=y(u)/1e3}catch(I){v=I}return}else T===""&&(S=!1);o.parse(T+`
|
|
30
|
+
`)}),o.flush()}},"./src/utils/xhr-loader.ts":function(j,R,l){"use strict";l.r(R);var P=l("./src/utils/logger.ts"),L=l("./src/loader/load-stats.ts"),A=/^age:\s*[\d.]+\s*$/m,M=function(){function O(_){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 L.LoadStats,this.retryDelay=0}var b=O.prototype;return b.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},b.abortInternal=function(){var y=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),y&&(y.onreadystatechange=null,y.onprogress=null,y.readyState!==4&&(this.stats.aborted=!0,y.abort()))},b.abort=function(){var y;this.abortInternal(),(y=this.callbacks)!==null&&y!==void 0&&y.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},b.load=function(y,x,D){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=y,this.config=x,this.callbacks=D,this.retryDelay=x.retryDelay,this.loadInternal()},b.loadInternal=function(){var y=this.config,x=this.context;if(!!y){var D=this.loader=new self.XMLHttpRequest,E=this.stats;E.loading.first=0,E.loaded=0;var m=this.xhrSetup;try{if(m)try{m(D,x.url)}catch{D.open("GET",x.url,!0),m(D,x.url)}D.readyState||D.open("GET",x.url,!0);var p=this.context.headers;if(p)for(var f in p)D.setRequestHeader(f,p[f])}catch(e){this.callbacks.onError({code:D.status,text:e.message},x,D);return}x.rangeEnd&&D.setRequestHeader("Range","bytes="+x.rangeStart+"-"+(x.rangeEnd-1)),D.onreadystatechange=this.readystatechange.bind(this),D.onprogress=this.loadprogress.bind(this),D.responseType=x.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),y.timeout),D.send()}},b.readystatechange=function(){var y=this.context,x=this.loader,D=this.stats;if(!(!y||!x)){var E=x.readyState,m=this.config;if(!D.aborted&&E>=2)if(self.clearTimeout(this.requestTimeout),D.loading.first===0&&(D.loading.first=Math.max(self.performance.now(),D.loading.start)),E===4){x.onreadystatechange=null,x.onprogress=null;var p=x.status;if(p>=200&&p<300){D.loading.end=Math.max(self.performance.now(),D.loading.first);var f,e;if(y.responseType==="arraybuffer"?(f=x.response,e=f.byteLength):(f=x.responseText,e=f.length),D.loaded=D.total=e,!this.callbacks)return;var s=this.callbacks.onProgress;if(s&&s(D,y,f,x),!this.callbacks)return;var h={url:x.responseURL,data:f};this.callbacks.onSuccess(h,D,y,x)}else D.retry>=m.maxRetry||p>=400&&p<499?(P.logger.error(p+" while loading "+y.url),this.callbacks.onError({code:p,text:x.statusText},y,x)):(P.logger.warn(p+" while loading "+y.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,m.maxRetryDelay),D.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),m.timeout)}},b.loadtimeout=function(){P.logger.warn("timeout while loading "+this.context.url);var y=this.callbacks;y&&(this.abortInternal(),y.onTimeout(this.stats,this.context,this.loader))},b.loadprogress=function(y){var x=this.stats;x.loaded=y.loaded,y.lengthComputable&&(x.total=y.total)},b.getCacheAge=function(){var y=null;if(this.loader&&A.test(this.loader.getAllResponseHeaders())){var x=this.loader.getResponseHeader("age");y=x?parseFloat(x):null}return y},O}();R.default=M}}).default})});var bt=class{addEventListener(){}removeEventListener(){}dispatchEvent(R){return!0}};if(typeof DocumentFragment=="undefined"){class j extends bt{}globalThis.DocumentFragment=j}var Ut=class extends bt{},yr=class extends bt{},Ji={get(j){},define(j,R,l){},upgrade(j){},whenDefined(j){return Promise.resolve(Ut)}},Nt,Tr=class{constructor(R,l={}){Bt(this,Nt,void 0);er(this,Nt,l==null?void 0:l.detail)}get detail(){return qt(this,Nt)}initCustomEvent(){}};Nt=new WeakMap;function Zi(j,R){return new Ut}var jr={document:{createElement:Zi},DocumentFragment,customElements:Ji,CustomEvent:Tr,EventTarget:bt,HTMLElement:Ut,HTMLVideoElement:yr},Wr=typeof window=="undefined"||typeof globalThis.customElements=="undefined",ht=Wr?jr:globalThis,xr=Wr?jr.document:globalThis.document;var ar=Zt(Gr(),1),Tt=Zt(ir(),1),Lr=Zt(ir(),1),Ot=Zt(ir(),1),jt=class extends Error{constructor(j,R=jt.MEDIA_ERR_CUSTOM,l){var P;super(j),this.name="MediaError",this.code=R,this.fatal=l!=null?l:R>=jt.MEDIA_ERR_NETWORK&&R<=jt.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(P=jt.defaultMessages[this.code])!=null?P:"")}},ze=jt;ze.MEDIA_ERR_ABORTED=1,ze.MEDIA_ERR_NETWORK=2,ze.MEDIA_ERR_DECODE=3,ze.MEDIA_ERR_SRC_NOT_SUPPORTED=4,ze.MEDIA_ERR_ENCRYPTED=5,ze.MEDIA_ERR_CUSTOM=100,ze.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 Qr=(j,R)=>j in R,_r={ANY:"any",MUTED:"muted"},nr={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},xt={MSE:"mse",NATIVE:"native"},Rt={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},br={HLS:Rt.M3U8},bn=Object.keys(br),On=[...Object.values(Rt),"hls","HLS"],Wt=(j,R,l,P)=>{j.addEventListener(R,l,P),j.addEventListener("teardown",()=>{j.removeEventListener(R,l)},{once:!0})};function qi(j,R,l){R&&l>R&&(l=R);for(let P=0;P<j.length;P++)if(j.start(P)<=l&&j.end(P)>=l)return!0;return!1}var en=j=>{let R=j.indexOf("?");if(R<0)return[j];let l=j.slice(0,R),P=j.slice(R);return[l,P]},$r=j=>{let R=j.type;if(R){let P=R.toUpperCase();return Qr(P,br)?br[P]:R}let{src:l}=j;return l?tn(l):""},tn=j=>{let R="";try{R=new URL(j).pathname}catch{console.error("invalid url")}let l=R.lastIndexOf(".");if(l<0)return"";let P=R.slice(l+1).toUpperCase();return Qr(P,Rt)?Rt[P]:""},rn=Object.values(_r),Hr=j=>typeof j=="boolean"||typeof j=="string"&&rn.includes(j),nn=({autoplay:j},R,l)=>{if(!R)return()=>{};let P=!1,L=!1,A=Hr(j)?j:!!j,M=()=>{P||Wt(R,"playing",()=>{P=!0},{once:!0})};if(M(),Wt(R,"loadstart",()=>{P=!1,M(),Ar(R,A)},{once:!0}),Wt(R,"loadstart",()=>{l||(L=!Number.isFinite(R.duration)),Ar(R,A)},{once:!0}),l&&l.once(Lr.default.Events.LEVEL_LOADED,(O,b)=>{var _;L=(_=b.details.live)!=null?_:!1}),!A){let O=()=>{!L||(l!=null&&l.liveSyncPosition?R.currentTime=l.liveSyncPosition:Number.isFinite(R.seekable.end(0))&&(R.currentTime=R.seekable.end(0)))};l&&Wt(R,"play",()=>{R.preload==="metadata"?l.once(Lr.default.Events.LEVEL_UPDATED,O):O()},{once:!0})}return O=>{P||(A=Hr(O)?O:!!O,Ar(R,A))}},Ar=(j,R)=>{if(!R)return;let l=j.muted,P=()=>j.muted=l;switch(R){case _r.ANY:j.play().catch(()=>{j.muted=!0,j.play().catch(P)});break;case _r.MUTED:j.muted=!0,j.play().catch(P);break;default:j.play().catch(()=>{});break}},an=({preload:j,src:R},l,P)=>{if(!l)return()=>{};let L=x=>{x!=null&&["","none","metadata","auto"].includes(x)?l.setAttribute("preload",x):l.removeAttribute("preload")};if(!P)return L(j),L;let A=!1,M=!1,O=P.config.maxBufferLength,b=P.config.maxBufferSize,_=x=>{L(x);let D=x!=null?x:l.preload;M||D==="none"||(D==="metadata"?(P.config.maxBufferLength=1,P.config.maxBufferSize=1):(P.config.maxBufferLength=O,P.config.maxBufferSize=b),y())},y=()=>{!A&&R&&(A=!0,P.loadSource(R))};return Wt(l,"play",()=>{M=!0,P.config.maxBufferLength=O,P.config.maxBufferSize=b,y()},{once:!0}),_(j),_};function sn(j,R){R.on(Ot.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(L,{tracks:A})=>{A.forEach(M=>{var O;let b=(O=M.subtitleTrack)!=null?O:M.closedCaptions,_=R.subtitleTracks.findIndex(({lang:y,name:x,type:D})=>y==(b==null?void 0:b.lang)&&x===M.label&&D.toLowerCase()===M.kind);on(j,M.kind,M.label,b==null?void 0:b.lang,`${M.kind}${_}`)})});let l=()=>{var L;if(!R.subtitleTracks.length)return;let A=Array.from(j.textTracks).find(O=>O.id&&O.mode==="showing"&&["subtitles","captions"].includes(O.kind)),M=`${(L=R.subtitleTracks[R.subtitleTrack])==null?void 0:L.type.toLowerCase()}${R.subtitleTrack}`;if(A&&(R.subtitleTrack<0||(A==null?void 0:A.id)!==M)){let O=R.subtitleTracks.findIndex(({lang:b,name:_,type:y})=>b==A.language&&_===A.label&&y.toLowerCase()===A.kind);R.subtitleTrack=O}A&&(A==null?void 0:A.id)===M&&A.cues&&Array.from(A.cues).forEach(O=>{A.addCue(O)})};j.textTracks.addEventListener("change",l),R.on(Ot.default.Events.CUES_PARSED,(L,{track:A,cues:M})=>{let O=j.textTracks.getTrackById(A);if(!O)return;let b=O.mode==="disabled";b&&(O.mode="hidden"),M.forEach(_=>{var y;(y=O.cues)!=null&&y.getCueById(_.id)||O.addCue(_)}),b&&(O.mode="disabled")}),R.once(Ot.default.Events.DESTROYING,()=>{j.textTracks.removeEventListener("change",l),j.querySelectorAll("track[data-removeondestroy]").forEach(L=>{L.remove()})});let P=()=>{Array.from(j.textTracks).forEach(L=>{var A,M;if(!["subtitles","caption"].includes(L.kind)&&L.label==="thumbnails"){if(!((A=L.cues)!=null&&A.length)){let O=j.querySelector('track[label="thumbnails"]'),b=(M=O==null?void 0:O.getAttribute("src"))!=null?M:"";O==null||O.removeAttribute("src"),setTimeout(()=>{O==null||O.setAttribute("src",b)},0)}L.mode!=="hidden"&&(L.mode="hidden")}})};R.once(Ot.default.Events.MANIFEST_LOADED,P),R.once(Ot.default.Events.MEDIA_ATTACHED,P)}function on(j,R,l,P,L){let A=document.createElement("track");return A.kind=R,A.label=l,P&&(A.srclang=P),L&&(A.id=L),A.track.mode="disabled",A.setAttribute("data-removeondestroy",""),j.append(A),A.track}var Vr,Yr,ln=(Yr=(Vr=globalThis==null?void 0:globalThis.navigator)==null?void 0:Vr.userAgent)!=null?Yr:"",un=ln.toLowerCase().indexOf("android")!==-1,Gt=new WeakMap,Jr="mux.com",zr,Xr,Zr=(Xr=(zr=Tt.default).isSupported)==null?void 0:Xr.call(zr),fn=un,qr=()=>ar.default.utils.now(),ei=ar.default.utils.generateUUID,ti=(j,{domain:R=Jr}={})=>{if(!j)return;let[l,P=""]=en(j);return`https://stream.${R}/${l}.m3u8${P}`},dn=j=>{if(!j)return;let[R]=j.split("?");return R||void 0},cn=j=>{if(!j||!j.startsWith("https://stream."))return;let[R]=new URL(j).pathname.slice(1).split(".m3u8");return R||void 0},hn=j=>{var R,l,P;return(R=j==null?void 0:j.metadata)!=null&&R.video_id?j.metadata.video_id:ni(j)&&(P=(l=dn(j.playbackId))!=null?l:cn(j.src))!=null?P:ei()};var ri=(j,R,l)=>{Rr(R,l);let{metadata:P={}}=j,{view_session_id:L=ei()}=P,A=hn(j);P.view_session_id=L,P.video_id=A,j.metadata=P,Gt.set(R,{});let M=vn(j,R);mn(j,R,M),pn(j,R,M);let O=nn(j,R,M),b=an(j,R,M);return{engine:M,setAutoplay:O,setPreload:b}},Rr=(j,R)=>{let l=R==null?void 0:R.engine;l&&(l.detachMedia(),l.destroy()),(j==null?void 0:j.mux)&&!j.mux.deleted&&(j.mux.destroy(),delete j.mux),j&&(j.removeAttribute("src"),j.load(),j.removeEventListener("error",si),j.removeEventListener("error",Or),j.removeEventListener("durationchange",ai),Gt.delete(j),j.dispatchEvent(new Event("teardown")))};function ii(j,R){var l;let P=$r(j);if(P!==Rt.M3U8)return!0;let L=!P||((l=R==null?void 0:R.canPlayType(P))!=null?l:!0),{preferPlayback:A}=j,M=A===xt.MSE,O=A===xt.NATIVE;return L&&(O||!(Zr&&(M||fn)))}var vn=(j,R)=>{let{debug:l,streamType:P,startTime:L=-1,metadata:A,experimentalCmcd:M}=j,O=$r(j)===Rt.M3U8,b=ii(j,R);if(O&&!b&&Zr){let _={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},y=gn(P),x=M?{useHeaders:!0,sessionId:A.view_session_id,contentId:A.video_id}:void 0;return new Tt.default({debug:l,startPosition:L,cmcd:x,..._,...y})}},gn=j=>[nr.LIVE,nr.DVR].includes(j)?{backBufferLength:8}:[nr.LL_LIVE,nr.LL_DVR].includes(j)?{backBufferLength:4,maxFragLookUpTolerance:.001}:{},ni=({playbackId:j,src:R,customDomain:l})=>{if(j)return!0;if(typeof R!="string")return!1;let P=window==null?void 0:window.location.href,L=new URL(R,P).hostname.toLocaleLowerCase();return L.includes(Jr)||!!l&&L.includes(l.toLocaleLowerCase())},mn=(j,R,l)=>{var P;let{envKey:L}=j,A=ni(j);if((L||A)&&R){let{playerInitTime:M,playerSoftwareName:O,playerSoftwareVersion:b,beaconCollectionDomain:_,debug:y,disableCookies:x}=j,D={...j.metadata,video_title:((P=j==null?void 0:j.metadata)==null?void 0:P.video_title)||void 0},E=m=>typeof m.player_error_code=="string"?!1:typeof j.errorTranslator=="function"?j.errorTranslator(m):m;ar.default.monitor(R,{debug:y,beaconCollectionDomain:_,hlsjs:l,Hls:l?Tt.default:void 0,automaticErrorTracking:!1,errorTranslator:E,disableCookies:x,data:{...L?{env_key:L}:{},player_software_name:O,player_software:O,player_software_version:b,player_init_time:M,...D}})}},pn=(j,R,l)=>{var P;if(!R){console.warn("attempting to load media before mediaEl exists");return}let L=ii(j,R),{src:A}=j;R&&L?(typeof A=="string"?(R.setAttribute("src",A),j.startTime&&(((P=Gt.get(R))!=null?P:{}).startTime=j.startTime,R.addEventListener("durationchange",ai,{once:!0}))):R.removeAttribute("src"),R.addEventListener("error",si),R.addEventListener("error",Or)):l&&A?(l.on(Tt.default.Events.ERROR,(M,O)=>{let b={[Tt.default.ErrorTypes.NETWORK_ERROR]:ze.MEDIA_ERR_NETWORK,[Tt.default.ErrorTypes.MEDIA_ERROR]:ze.MEDIA_ERR_DECODE},_=new ze("",b[O.type]);_.fatal=O.fatal,_.data=O,R.dispatchEvent(new CustomEvent("error",{detail:_}))}),R.addEventListener("error",Or),sn(R,l),l.attachMedia(R)):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 ai(j){var R;let l=j.target,P=(R=Gt.get(l))==null?void 0:R.startTime;if(!!P&&qi(l.seekable,l.duration,P)){let L=l.preload==="auto";L&&(l.preload="none"),l.currentTime=P,L&&(l.preload="auto")}}async function si(j){if(!j.isTrusted)return;j.stopImmediatePropagation();let R=j.target;if(!(R!=null&&R.error))return;let{message:l,code:P}=R.error,L=new ze(l,P);if(R.src&&(P!==ze.MEDIA_ERR_DECODE||P!==void 0))try{let{status:A}=await fetch(R.src);L.data={response:{code:A}}}catch{}R.dispatchEvent(new CustomEvent("error",{detail:L}))}function Or(j){var R,l;if(!(j instanceof CustomEvent)||!(j.detail instanceof ze))return;let P=j.target,L=j.detail;!L||!L.fatal||(((R=Gt.get(P))!=null?R:{}).error=L,(l=P.mux)==null||l.emit("error",{player_error_code:L.code,player_error_message:L.message}))}var En=()=>{try{return"0.8.0"}catch{}return"UNKNOWN"},yn=En(),oi=()=>yn;var li=["abort","canplay","canplaythrough","durationchange","emptied","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting"],ui=xr.createElement("template");ui.innerHTML=`
|
|
30
31
|
<style>
|
|
31
32
|
:host {
|
|
32
33
|
/* display:inline (like the native el) makes it so you can't fill
|
|
@@ -49,5 +50,17 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
49
50
|
|
|
50
51
|
<audio part="audio" crossorigin></audio>
|
|
51
52
|
<slot></slot>
|
|
52
|
-
`;var
|
|
53
|
+
`;var Ht,It,sr,St=class extends ht.HTMLElement{constructor(){super();Bt(this,It);Bt(this,Ht,void 0);this.attachShadow({mode:"open"}),this.isConnected&&tr(this,It,sr).call(this)}static get observedAttributes(){let l=[];Object.getOwnPropertyNames(this.prototype).forEach(L=>{let A=!1;try{typeof this.prototype[L]=="function"&&(A=!0)}catch{}!A&&L!==L.toUpperCase()&&l.push(L.toLowerCase())});let P=Object.getPrototypeOf(this).observedAttributes;return P&&(l=l.concat(P)),l}attributeChangedCallback(l,P,L){tr(this,It,sr).call(this),this.forwardAttribute(l,P,L)}forwardAttribute(l,P,L){let A=Object.getOwnPropertyNames(Object.getPrototypeOf(this)),M=xn(A,l),O=Object.getPrototypeOf(this.constructor).toString().indexOf("function HTMLElement")===0;M&&!O?typeof this[M]=="boolean"?L===null?this[M]=!1:this[M]=!0:this[M]=L:L===null?this.nativeEl.removeAttribute(l):["id","class"].indexOf(l)===-1&&this.nativeEl.setAttribute(l,L)}connectedCallback(){tr(this,It,sr).call(this)}};Ht=new WeakMap,It=new WeakSet,sr=function(){if(qt(this,Ht))return;er(this,Ht,!0),this.shadowRoot.append(ui.content.cloneNode(!0));let l=this.nativeEl=this.shadowRoot.querySelector("audio");li.forEach(L=>{l.addEventListener(L,A=>{this.dispatchEvent(new CustomEvent(A.type,{detail:A.detail}))})});let P=this.shadowRoot.querySelector("slot");P.addEventListener("slotchange",()=>{P.assignedElements().forEach(L=>{!["track","source"].includes(L.localName)||l.append(L)})}),Array.from(this.attributes).forEach(L=>{this.forwardAttribute(L.name,null,L.value)}),l.defaultMuted&&(l.muted=!0)};var fi=[],di=xr.createElement("audio"),Tn=["webkitDisplayingFullscreen","webkitSupportsFullscreen"];for(let j=Object.getPrototypeOf(di);j&&j!==ht.HTMLElement.prototype;j=Object.getPrototypeOf(j))Object.keys(j).forEach(R=>{Tn.indexOf(R)===-1&&fi.push(R)});fi.forEach(j=>{if(typeof di[j]=="function")St.prototype[j]=function(){return this.nativeEl[j].apply(this.nativeEl,arguments)};else{let l={get(){return this.nativeEl[j]}};j!==j.toUpperCase()&&(l.set=function(P){this.nativeEl[j]=P}),Object.defineProperty(St.prototype,j,l)}});function xn(j,R){let l=null;return j.forEach(P=>{P.toLowerCase()==R.toLowerCase()&&(l=P)}),l}ht.customElements.get("custom-audio")||(ht.customElements.define("custom-audio",St),ht.CustomAudioElement=St);var Ir=St;var De={ENV_KEY:"env-key",DEBUG:"debug",PLAYBACK_ID:"playback-id",METADATA_URL:"metadata-url",PREFER_PLAYBACK:"prefer-playback",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",DISABLE_COOKIES:"disable-cookies",TYPE:"type",STREAM_TYPE:"stream-type",START_TIME:"start-time"},Sn=Object.values(De),Dn=oi(),An="mux-audio",Vt=class extends Ir{constructor(){super();this.__metadata={};this.__playerInitTime=qr()}static get observedAttributes(){var l;return[...Sn,...(l=Ir.observedAttributes)!=null?l:[]]}get playerInitTime(){return this.__playerInitTime}get playerSoftwareName(){return An}get playerSoftwareVersion(){return Dn}get _hls(){var l;return(l=this.__core)==null?void 0:l.engine}get mux(){return this.nativeEl.mux}get src(){return this.getAttribute("src")}set src(l){l!==this.src&&(l==null?this.removeAttribute("src"):this.setAttribute("src",l))}get preload(){let l=this.getAttribute("preload");return l===""?"auto":["none","metadata","auto"].includes(l)?l:super.preload}set preload(l){l!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(l)?this.setAttribute("preload",l):this.removeAttribute("preload"))}get debug(){return this.getAttribute(De.DEBUG)!=null}set debug(l){l!==this.debug&&(l?this.setAttribute(De.DEBUG,""):this.removeAttribute(De.DEBUG))}get disableCookies(){return this.hasAttribute(De.DISABLE_COOKIES)}set disableCookies(l){l!==this.disableCookies&&(l?this.setAttribute(De.DISABLE_COOKIES,""):this.removeAttribute(De.DISABLE_COOKIES))}get startTime(){let l=this.getAttribute(De.START_TIME);if(l==null)return;let P=+l;return Number.isNaN(P)?void 0:P}set startTime(l){l!==this.startTime&&(l==null?this.removeAttribute(De.START_TIME):this.setAttribute(De.START_TIME,`${l}`))}get playbackId(){var l;return(l=this.getAttribute(De.PLAYBACK_ID))!=null?l:void 0}set playbackId(l){l!==this.playbackId&&(l?this.setAttribute(De.PLAYBACK_ID,l):this.removeAttribute(De.PLAYBACK_ID))}get envKey(){var l;return(l=this.getAttribute(De.ENV_KEY))!=null?l:void 0}set envKey(l){l!==this.envKey&&(l?this.setAttribute(De.ENV_KEY,l):this.removeAttribute(De.ENV_KEY))}get beaconCollectionDomain(){var l;return(l=this.getAttribute(De.BEACON_COLLECTION_DOMAIN))!=null?l:void 0}set beaconCollectionDomain(l){l!==this.beaconCollectionDomain&&(l?this.setAttribute(De.BEACON_COLLECTION_DOMAIN,l):this.removeAttribute(De.BEACON_COLLECTION_DOMAIN))}get streamType(){var l;return(l=this.getAttribute(De.STREAM_TYPE))!=null?l:void 0}set streamType(l){l!==this.streamType&&(l?this.setAttribute(De.STREAM_TYPE,l):this.removeAttribute(De.STREAM_TYPE))}get preferPlayback(){let l=this.getAttribute(De.PREFER_PLAYBACK);if(l===xt.MSE||l===xt.NATIVE)return l}set preferPlayback(l){l!==this.preferPlayback&&(l===xt.MSE||l===xt.NATIVE?this.setAttribute(De.PREFER_PLAYBACK,l):this.removeAttribute(De.PREFER_PLAYBACK))}get metadata(){return this.__metadata}set metadata(l){this.__metadata=l!=null?l:{},this.mux&&(console.info("Some metadata values may not be overridable at this time. Make sure you set all metadata to override before setting the src."),this.mux.emit("hb",this.__metadata))}load(){this.__core=ri(this,this.nativeEl,this.__core)}unload(){Rr(this.nativeEl,this.__core),this.__core=void 0}attributeChangedCallback(l,P,L){var A,M;switch(super.attributeChangedCallback(l,P,L),l){case"src":{let O=!!P,b=!!L;!O&&b?this.load():O&&!b?this.unload():O&&b&&(this.unload(),this.load());break}case"autoplay":if(L===P)break;(A=this.__core)==null||A.setAutoplay(this.autoplay);break;case"preload":if(L===P)break;(M=this.__core)==null||M.setPreload(L);break;case De.PLAYBACK_ID:this.src=ti(L!=null?L:void 0);break;case De.DEBUG:{let O=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=O);break}case De.METADATA_URL:L&&fetch(L).then(O=>O.json()).then(O=>this.metadata=O).catch(O=>console.error(`Unable to load or parse metadata JSON from metadata-url ${L}!`));break;default:break}}disconnectedCallback(){this.unload()}};ht.customElements.get("mux-audio")||(ht.customElements.define("mux-audio",Vt),ht.MuxAudioElement=Vt);var Wn=Vt;export{li as AudioEvents,ze as MediaError,Wn as default};
|
|
54
|
+
/*!
|
|
55
|
+
* JavaScript Cookie v2.1.3
|
|
56
|
+
* https://github.com/js-cookie/js-cookie
|
|
57
|
+
*
|
|
58
|
+
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
|
|
59
|
+
* Released under the MIT license
|
|
60
|
+
*/
|
|
61
|
+
/*!
|
|
62
|
+
* mux-embed
|
|
63
|
+
* @version 4.14.0
|
|
64
|
+
* @copyright 2022 Mux, Inc
|
|
65
|
+
*/
|
|
53
66
|
//# sourceMappingURL=mux-audio.mjs.map
|