@mux/playback-core 0.7.1-canary.0-556dabf
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/CHANGELOG.md +91 -0
- package/README.md +9 -0
- package/dist/index.cjs.js +2 -0
- package/dist/index.cjs.js.map +7 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +7 -0
- package/dist/playback-core.js +30 -0
- package/dist/playback-core.js.map +7 -0
- package/dist/playback-core.mjs +30 -0
- package/dist/playback-core.mjs.map +7 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/autoplay.d.ts +15 -0
- package/dist/types/errors.d.ts +14 -0
- package/dist/types/index.d.ts +70 -0
- package/dist/types/tracks.d.ts +2 -0
- package/dist/types/util.d.ts +3 -0
- package/dist/types-ts3.4/autoplay.d.ts +15 -0
- package/dist/types-ts3.4/errors.d.ts +14 -0
- package/dist/types-ts3.4/index.d.ts +73 -0
- package/dist/types-ts3.4/tracks.d.ts +2 -0
- package/dist/types-ts3.4/util.d.ts +3 -0
- package/package.json +61 -0
- package/src/autoplay.ts +167 -0
- package/src/errors.ts +33 -0
- package/src/index.ts +503 -0
- package/src/tracks.ts +132 -0
- package/src/util.ts +6 -0
- package/tsconfig.json +22 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
var Mt=Object.create;var rt=Object.defineProperty;var Ct=Object.getOwnPropertyDescriptor;var Ft=Object.getOwnPropertyNames;var Bt=Object.getPrototypeOf,Ut=Object.prototype.hasOwnProperty;var wt=k=>rt(k,"__esModule",{value:!0});var pt=(k,b)=>()=>(b||k((b={exports:{}}).exports,b),b.exports);var kt=(k,b,c)=>{if(b&&typeof b=="object"||typeof b=="function")for(let R of Ft(b))!Ut.call(k,R)&&R!=="default"&&rt(k,R,{get:()=>b[R],enumerable:!(c=Ct(b,R))||c.enumerable});return k},Xe=k=>kt(wt(rt(k!=null?Mt(Bt(k)):{},"default",k&&k.__esModule&&"default"in k?{get:()=>k.default,enumerable:!0}:{value:k,enumerable:!0})),k);var yt=(k,b,c)=>{if(!b.has(k))throw TypeError("Cannot "+c)};var Et=(k,b,c)=>(yt(k,b,"read from private field"),c?c.call(k):b.get(k)),Tt=(k,b,c)=>{if(b.has(k))throw TypeError("Cannot add the same private member more than once");b instanceof WeakSet?b.add(k):b.set(k,c)},xt=(k,b,c,R)=>(yt(k,b,"write to private field"),R?R.call(k,c):b.set(k,c),c);var At=pt((ze,it)=>{(function(){var k=!1;(function(b,c){typeof ze=="object"&&typeof it=="object"?it.exports=c():typeof k=="function"&&k.amd?k("mux",[],c):typeof ze=="object"?ze.mux=c():b.mux=c()})(typeof self!="undefined"?self:this,function(){return function(b){function c(y){if(R[y])return R[y].exports;var x=R[y]={i:y,l:!1,exports:{}};return b[y].call(x.exports,x,x.exports,c),x.l=!0,x.exports}var R={};return c.m=b,c.c=R,c.d=function(y,x,I){c.o(y,x)||Object.defineProperty(y,x,{configurable:!1,enumerable:!0,get:I})},c.n=function(y){var x=y&&y.__esModule?function(){return y.default}:function(){return y};return c.d(x,"a",x),x},c.o=function(y,x){return Object.prototype.hasOwnProperty.call(y,x)},c.p="",c(c.s=18)}([function(b,c,R){(function(y){var x;x=typeof window!="undefined"?window:y!==void 0?y:typeof self!="undefined"?self:{},b.exports=x}).call(c,R(20))},function(b,c){function R(C,U,w){switch(w.length){case 0:return C.call(U);case 1:return C.call(U,w[0]);case 2:return C.call(U,w[0],w[1]);case 3:return C.call(U,w[0],w[1],w[2])}return C.apply(U,w)}function y(C,U){for(var w=-1,N=Array(C);++w<C;)N[w]=U(w);return N}function x(C,U){var w=F(C)||v(C)?y(C.length,String):[],N=w.length,j=!!N;for(var K in C)!U&&!o.call(C,K)||j&&(K=="length"||g(K,N))||w.push(K);return w}function I(C,U,w){var N=C[U];o.call(C,U)&&S(N,w)&&(w!==void 0||U in C)||(C[U]=w)}function T(C){if(!L(C))return O(C);var U=[];for(var w in Object(C))o.call(C,w)&&w!="constructor"&&U.push(w);return U}function D(C,U){return U=P(U===void 0?C.length-1:U,0),function(){for(var w=arguments,N=-1,j=P(w.length-U,0),K=Array(j);++N<j;)K[N]=w[U+N];N=-1;for(var G=Array(U+1);++N<U;)G[N]=w[N];return G[U]=K,R(C,this,G)}}function _(C,U,w,N){w||(w={});for(var j=-1,K=U.length;++j<K;){var G=U[j],Y=N?N(w[G],C[G],G,w,C):void 0;I(w,G,Y===void 0?C[G]:Y)}return w}function g(C,U){return!!(U=U==null?n:U)&&(typeof C=="number"||f.test(C))&&C>-1&&C%1==0&&C<U}function A(C,U,w){if(!t(w))return!1;var N=typeof U;return!!(N=="number"?p(w)&&g(U,w.length):N=="string"&&U in w)&&S(w[U],C)}function L(C){var U=C&&C.constructor;return C===(typeof U=="function"&&U.prototype||l)}function S(C,U){return C===U||C!==C&&U!==U}function v(C){return s(C)&&o.call(C,"callee")&&(!m.call(C,"callee")||E.call(C)==h)}function p(C){return C!=null&&i(C.length)&&!e(C)}function s(C){return r(C)&&p(C)}function e(C){var U=t(C)?E.call(C):"";return U==d||U==u}function i(C){return typeof C=="number"&&C>-1&&C%1==0&&C<=n}function t(C){var U=typeof C;return!!C&&(U=="object"||U=="function")}function r(C){return!!C&&typeof C=="object"}function a(C){return p(C)?x(C):T(C)}var n=9007199254740991,h="[object Arguments]",d="[object Function]",u="[object GeneratorFunction]",f=/^(?:0|[1-9]\d*)$/,l=Object.prototype,o=l.hasOwnProperty,E=l.toString,m=l.propertyIsEnumerable,O=function(C,U){return function(w){return C(U(w))}}(Object.keys,Object),P=Math.max,M=!m.call({valueOf:1},"valueOf"),F=Array.isArray,B=function(C){return D(function(U,w){var N=-1,j=w.length,K=j>1?w[j-1]:void 0,G=j>2?w[2]:void 0;for(K=C.length>3&&typeof K=="function"?(j--,K):void 0,G&&A(w[0],w[1],G)&&(K=j<3?void 0:K,j=1),U=Object(U);++N<j;){var Y=w[N];Y&&C(U,Y,N,K)}return U})}(function(C,U){if(M||L(U)||p(U))return void _(U,a(U),C);for(var w in U)o.call(U,w)&&I(C,w,U[w])});b.exports=B},function(b,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y=R(0),x=function(T){return T&&T.__esModule?T:{default:T}}(y),I={};I.now=function(){var T=x.default.performance,D=T&&T.timing;return D&&typeof D.navigationStart=="number"&&typeof T.now=="function"?D.navigationStart+T.now():Date.now()},c.default=I},function(b,c,R){"use strict";function y(x,I,T){T=T===void 0?1:T,x[I]=x[I]||0,x[I]+=T}Object.defineProperty(c,"__esModule",{value:!0}),c.default=y},function(b,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y=R(21),x=function(T){return T&&T.__esModule?T:{default:T}}(y),I=x.default.methodFactory;x.default.methodFactory=function(T,D,_){var g=I(T,D,_);return function(){for(var A=["[mux]"],L=0;L<arguments.length;L++)A.push(arguments[L]);g.apply(void 0,A)}},x.default.setLevel(x.default.getLevel()),c.default=x.default},function(b,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y=function(T){return I(T)[0]},x=function(T){return I(T)[1]},I=function(T){if(typeof T!="string"||T==="")return["localhost"];var D=/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,_=T.match(D)||[],g=_[4],A=void 0;return g&&(A=(g.match(/[^\.]+\.[^\.]+$/)||[])[0]),[g,A]};c.extractHostnameAndDomain=I,c.extractHostname=y,c.extractDomain=x},function(b,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y=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)};c.generateUUID=y,c.generateShortID=x},function(b,c,R){"use strict";function y(I){I=I||"";var T={};return I.trim().split(/[\r\n]+/).forEach(function(D){if(D){var _=D.split(": "),g=_.shift();g&&(x.indexOf(g.toLowerCase())>=0||g.toLowerCase().indexOf("x-litix-")===0)&&(T[g]=_.join(": "))}}),T}Object.defineProperty(c,"__esModule",{value:!0}),c.default=y;var x=["x-cdn","content-type"]},function(b,c,R){"use strict";var y=SyntaxError,x=Function,I=TypeError,T=function(o){try{return x('"use strict"; return ('+o+").constructor;")()}catch{}},D=Object.getOwnPropertyDescriptor;if(D)try{D({},"")}catch{D=null}var _=function(){throw new I},g=D?function(){try{return arguments.callee,_}catch{try{return D(arguments,"callee").get}catch{return _}}}():_,A=R(43)(),L=Object.getPrototypeOf||function(o){return o.__proto__},S={},v=typeof Uint8Array=="undefined"?void 0:L(Uint8Array),p={"%AggregateError%":typeof AggregateError=="undefined"?void 0:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer=="undefined"?void 0:ArrayBuffer,"%ArrayIteratorPrototype%":A?L([][Symbol.iterator]()):void 0,"%AsyncFromSyncIteratorPrototype%":void 0,"%AsyncFunction%":S,"%AsyncGenerator%":S,"%AsyncGeneratorFunction%":S,"%AsyncIteratorPrototype%":S,"%Atomics%":typeof Atomics=="undefined"?void 0:Atomics,"%BigInt%":typeof BigInt=="undefined"?void 0:BigInt,"%Boolean%":Boolean,"%DataView%":typeof DataView=="undefined"?void 0:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array=="undefined"?void 0:Float32Array,"%Float64Array%":typeof Float64Array=="undefined"?void 0:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry=="undefined"?void 0:FinalizationRegistry,"%Function%":x,"%GeneratorFunction%":S,"%Int8Array%":typeof Int8Array=="undefined"?void 0:Int8Array,"%Int16Array%":typeof Int16Array=="undefined"?void 0:Int16Array,"%Int32Array%":typeof Int32Array=="undefined"?void 0:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":A?L(L([][Symbol.iterator]())):void 0,"%JSON%":typeof JSON=="object"?JSON:void 0,"%Map%":typeof Map=="undefined"?void 0:Map,"%MapIteratorPrototype%":typeof Map!="undefined"&&A?L(new Map()[Symbol.iterator]()):void 0,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise=="undefined"?void 0:Promise,"%Proxy%":typeof Proxy=="undefined"?void 0:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect=="undefined"?void 0:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set=="undefined"?void 0:Set,"%SetIteratorPrototype%":typeof Set!="undefined"&&A?L(new Set()[Symbol.iterator]()):void 0,"%SharedArrayBuffer%":typeof SharedArrayBuffer=="undefined"?void 0:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":A?L(""[Symbol.iterator]()):void 0,"%Symbol%":A?Symbol:void 0,"%SyntaxError%":y,"%ThrowTypeError%":g,"%TypedArray%":v,"%TypeError%":I,"%Uint8Array%":typeof Uint8Array=="undefined"?void 0:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray=="undefined"?void 0:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array=="undefined"?void 0:Uint16Array,"%Uint32Array%":typeof Uint32Array=="undefined"?void 0:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap=="undefined"?void 0:WeakMap,"%WeakRef%":typeof WeakRef=="undefined"?void 0:WeakRef,"%WeakSet%":typeof WeakSet=="undefined"?void 0:WeakSet},s=function o(E){var m;if(E==="%AsyncFunction%")m=T("async function () {}");else if(E==="%GeneratorFunction%")m=T("function* () {}");else if(E==="%AsyncGeneratorFunction%")m=T("async function* () {}");else if(E==="%AsyncGenerator%"){var O=o("%AsyncGeneratorFunction%");O&&(m=O.prototype)}else if(E==="%AsyncIteratorPrototype%"){var P=o("%AsyncGenerator%");P&&(m=L(P.prototype))}return p[E]=m,m},e={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},i=R(9),t=R(46),r=i.call(Function.call,Array.prototype.concat),a=i.call(Function.apply,Array.prototype.splice),n=i.call(Function.call,String.prototype.replace),h=i.call(Function.call,String.prototype.slice),d=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,u=/\\(\\)?/g,f=function(o){var E=h(o,0,1),m=h(o,-1);if(E==="%"&&m!=="%")throw new y("invalid intrinsic syntax, expected closing `%`");if(m==="%"&&E!=="%")throw new y("invalid intrinsic syntax, expected opening `%`");var O=[];return n(o,d,function(P,M,F,B){O[O.length]=F?n(B,u,"$1"):M||P}),O},l=function(o,E){var m,O=o;if(t(e,O)&&(m=e[O],O="%"+m[0]+"%"),t(p,O)){var P=p[O];if(P===S&&(P=s(O)),P===void 0&&!E)throw new I("intrinsic "+o+" exists, but is not available. Please file an issue!");return{alias:m,name:O,value:P}}throw new y("intrinsic "+o+" does not exist!")};b.exports=function(o,E){if(typeof o!="string"||o.length===0)throw new I("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof E!="boolean")throw new I('"allowMissing" argument must be a boolean');var m=f(o),O=m.length>0?m[0]:"",P=l("%"+O+"%",E),M=P.name,F=P.value,B=!1,C=P.alias;C&&(O=C[0],a(m,r([0,1],C)));for(var U=1,w=!0;U<m.length;U+=1){var N=m[U],j=h(N,0,1),K=h(N,-1);if((j==='"'||j==="'"||j==="`"||K==='"'||K==="'"||K==="`")&&j!==K)throw new y("property names with quotes must have matching quotes");if(N!=="constructor"&&w||(B=!0),O+="."+N,M="%"+O+"%",t(p,M))F=p[M];else if(F!=null){if(!(N in F)){if(!E)throw new I("base intrinsic for "+o+" exists, but the property is not available.");return}if(D&&U+1>=m.length){var G=D(F,N);w=!!G,F=w&&"get"in G&&!("originalValue"in G.get)?G.get:F[N]}else w=t(F,N),F=F[N];w&&!B&&(p[M]=F)}}return F}},function(b,c,R){"use strict";var y=R(45);b.exports=Function.prototype.bind||y},function(b,c,R){"use strict";var y=String.prototype.replace,x=/%20/g,I={RFC1738:"RFC1738",RFC3986:"RFC3986"};b.exports={default:I.RFC3986,formatters:{RFC1738:function(T){return y.call(T,x,"+")},RFC3986:function(T){return String(T)}},RFC1738:I.RFC1738,RFC3986:I.RFC3986}},function(b,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0}),c.findMediaElement=c.getMuxPlayerId=void 0;var y=R(6),x=function(T){return T&&T.nodeName!==void 0?(T.muxId||(T.muxId=T.id||(0,y.generateShortID)()),T.muxId):T},I=function(T){var D=void 0;return T&&T.nodeName!==void 0?(D=T,T=x(D)):D=document.querySelector(T),[D,T,D&&D.nodeName?D.nodeName.toLowerCase():""]};c.getMuxPlayerId=x,c.findMediaElement=I},function(b,c,R){"use strict";function y(){return(I.default.doNotTrack||I.default.navigator&&(I.default.navigator.doNotTrack||I.default.navigator.msDoNotTrack))==="1"}Object.defineProperty(c,"__esModule",{value:!0}),c.default=y;var x=R(0),I=function(T){return T&&T.__esModule?T:{default:T}}(x)},function(b,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y=R(0),x=function(T){return T&&T.__esModule?T:{default:T}}(y),I={};I.exists=function(){var T=x.default.performance;return(T&&T.timing)!==void 0},I.domContentLoadedEventEnd=function(){var T=x.default.performance,D=T&&T.timing;return D&&D.domContentLoadedEventEnd},I.navigationStart=function(){var T=x.default.performance,D=T&&T.timing;return D&&D.navigationStart},c.default=I},function(b,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y=function(x){var I={};for(var T in x){var D=x[T];D["DATA-ID"].search("io.litix.data.")!==-1&&(I[D["DATA-ID"].replace("io.litix.data.","")]=D.VALUE)}return I};c.default=y},function(b,c,R){"use strict";var y=R(41),x=R(51),I=R(10);b.exports={formats:I,parse:x,stringify:y}},function(b,c,R){"use strict";var y=R(10),x=Object.prototype.hasOwnProperty,I=Array.isArray,T=function(){for(var t=[],r=0;r<256;++r)t.push("%"+((r<16?"0":"")+r.toString(16)).toUpperCase());return t}(),D=function(t){for(;t.length>1;){var r=t.pop(),a=r.obj[r.prop];if(I(a)){for(var n=[],h=0;h<a.length;++h)a[h]!==void 0&&n.push(a[h]);r.obj[r.prop]=n}}},_=function(t,r){for(var a=r&&r.plainObjects?Object.create(null):{},n=0;n<t.length;++n)t[n]!==void 0&&(a[n]=t[n]);return a},g=function t(r,a,n){if(!a)return r;if(typeof a!="object"){if(I(r))r.push(a);else{if(!r||typeof r!="object")return[r,a];(n&&(n.plainObjects||n.allowPrototypes)||!x.call(Object.prototype,a))&&(r[a]=!0)}return r}if(!r||typeof r!="object")return[r].concat(a);var h=r;return I(r)&&!I(a)&&(h=_(r,n)),I(r)&&I(a)?(a.forEach(function(d,u){if(x.call(r,u)){var f=r[u];f&&typeof f=="object"&&d&&typeof d=="object"?r[u]=t(f,d,n):r.push(d)}else r[u]=d}),r):Object.keys(a).reduce(function(d,u){var f=a[u];return x.call(d,u)?d[u]=t(d[u],f,n):d[u]=f,d},h)},A=function(t,r){return Object.keys(r).reduce(function(a,n){return a[n]=r[n],a},t)},L=function(t,r,a){var n=t.replace(/\+/g," ");if(a==="iso-8859-1")return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch{return n}},S=function(t,r,a,n,h){if(t.length===0)return t;var d=t;if(typeof t=="symbol"?d=Symbol.prototype.toString.call(t):typeof t!="string"&&(d=String(t)),a==="iso-8859-1")return escape(d).replace(/%u[0-9a-f]{4}/gi,function(o){return"%26%23"+parseInt(o.slice(2),16)+"%3B"});for(var u="",f=0;f<d.length;++f){var l=d.charCodeAt(f);l===45||l===46||l===95||l===126||l>=48&&l<=57||l>=65&&l<=90||l>=97&&l<=122||h===y.RFC1738&&(l===40||l===41)?u+=d.charAt(f):l<128?u+=T[l]:l<2048?u+=T[192|l>>6]+T[128|63&l]:l<55296||l>=57344?u+=T[224|l>>12]+T[128|l>>6&63]+T[128|63&l]:(f+=1,l=65536+((1023&l)<<10|1023&d.charCodeAt(f)),u+=T[240|l>>18]+T[128|l>>12&63]+T[128|l>>6&63]+T[128|63&l])}return u},v=function(t){for(var r=[{obj:{o:t},prop:"o"}],a=[],n=0;n<r.length;++n)for(var h=r[n],d=h.obj[h.prop],u=Object.keys(d),f=0;f<u.length;++f){var l=u[f],o=d[l];typeof o=="object"&&o!==null&&a.indexOf(o)===-1&&(r.push({obj:d,prop:l}),a.push(o))}return D(r),t},p=function(t){return Object.prototype.toString.call(t)==="[object RegExp]"},s=function(t){return!(!t||typeof t!="object")&&!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},e=function(t,r){return[].concat(t,r)},i=function(t,r){if(I(t)){for(var a=[],n=0;n<t.length;n+=1)a.push(r(t[n]));return a}return r(t)};b.exports={arrayToObject:_,assign:A,combine:e,compact:v,decode:L,encode:S,isBuffer:s,isRegExp:p,maybeMap:i,merge:g}},function(b,c,R){"use strict";function y(p){return p&&p.__esModule?p:{default:p}}function x(p){var s={};for(var e in p)p.hasOwnProperty(e)&&(s[p[e]]=e);return s}function I(p){var s={},e={};return Object.keys(p).forEach(function(i){var t=!1;if(p.hasOwnProperty(i)&&p[i]!==void 0){var r=i.split("_"),a=r[0],n=L[a];n||(D.default.info("Data key word `"+r[0]+"` not expected in "+i),n=a+"_"),r.splice(1).forEach(function(h){h==="url"&&(t=!0),v[h]?n+=v[h]:Number(h)&&Math.floor(Number(h))===Number(h)?n+=h:(D.default.info("Data key word `"+h+"` not expected in "+i),n+="_"+h+"_")}),t?e[n]=p[i]:s[n]=p[i]}}),(0,g.default)(s,e)}Object.defineProperty(c,"__esModule",{value:!0}),c.default=I;var T=R(4),D=y(T),_=R(1),g=y(_),A={a:"env",b:"beacon",c:"custom",d:"ad",e:"event",f:"experiment",i:"internal",m:"mux",n:"response",p:"player",q:"request",r:"retry",s:"session",t:"timestamp",u:"viewer",v:"video",w:"page",x:"view",y:"sub"},L=x(A),S={ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",ca:"cached",cb:"cancel",cd:"code",cg:"category",ch:"changed",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ep:"experiments",fi:"first",fm:"family",ft:"format",fq:"frequency",fr:"frame",fs:"fullscreen",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"},v=x(S)},function(b,c,R){"use strict";b.exports=R(19).default},function(b,c,R){"use strict";function y(u){return u&&u.__esModule?u:{default:u}}Object.defineProperty(c,"__esModule",{value:!0});var x=function(){function u(f,l){var o=[],E=!0,m=!1,O=void 0;try{for(var P,M=f[Symbol.iterator]();!(E=(P=M.next()).done)&&(o.push(P.value),!l||o.length!==l);E=!0);}catch(F){m=!0,O=F}finally{try{!E&&M.return&&M.return()}finally{if(m)throw O}}return o}return function(f,l){if(Array.isArray(f))return f;if(Symbol.iterator in Object(f))return u(f,l);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),I=R(0),T=y(I),D=R(11),_=R(4),g=y(_),A=R(12),L=y(A),S=R(2),v=y(S),p=R(22),s=y(p),e=R(58),i=y(e),t=R(59),r=y(t),a=R(64),n=y(a),h={},d=function u(f){var l=arguments;typeof f=="string"?u.hasOwnProperty(f)?T.default.setTimeout(function(){l=Array.prototype.splice.call(l,1),u[f].apply(null,l)},0):g.default.warn("`"+f+"` is an unknown task"):typeof f=="function"?T.default.setTimeout(function(){f(u)},0):g.default.warn("`"+f+"` is invalid.")};d.loaded=v.default.now(),d.NAME="mux-embed",d.VERSION="4.8.0",d.API_VERSION="2.1",d.PLAYER_TRACKED=!1,d.monitor=function(u,f){return(0,i.default)(d,u,f)},d.destroyMonitor=function(u){var f=(0,D.findMediaElement)(u),l=x(f,1),o=l[0];o&&o.mux&&typeof o.mux.destroy=="function"?o.mux.destroy():g.default.error("A video element monitor for `"+u+"` has not been initialized via `mux.monitor`.")},d.addHLSJS=function(u,f){var l=(0,D.getMuxPlayerId)(u);h[l]?h[l].addHLSJS(f):g.default.error("A monitor for `"+l+"` has not been initialized.")},d.addDashJS=function(u,f){var l=(0,D.getMuxPlayerId)(u);h[l]?h[l].addDashJS(f):g.default.error("A monitor for `"+l+"` has not been initialized.")},d.removeHLSJS=function(u){var f=(0,D.getMuxPlayerId)(u);h[f]?h[f].removeHLSJS():g.default.error("A monitor for `"+f+"` has not been initialized.")},d.removeDashJS=function(u){var f=(0,D.getMuxPlayerId)(u);h[f]?h[f].removeDashJS():g.default.error("A monitor for `"+f+"` has not been initialized.")},d.init=function(u,f){(0,L.default)()&&f&&f.respectDoNotTrack&&g.default.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var l=(0,D.getMuxPlayerId)(u);h[l]=new s.default(d,l,f)},d.emit=function(u,f,l){var o=(0,D.getMuxPlayerId)(u);h[o]?(h[o].emit(f,l),f==="destroy"&&delete h[o]):g.default.error("A monitor for `"+o+"` has not been initialized.")},T.default!==void 0&&typeof T.default.addEventListener=="function"&&T.default.addEventListener("pagehide",function(u){u.persisted||(d.WINDOW_UNLOADING=!0)},!1),d.checkDoNotTrack=L.default,d.log=g.default,d.utils=r.default,d.events=n.default,c.default=d},function(b,c){var R;R=function(){return this}();try{R=R||Function("return this")()||(0,eval)("this")}catch{typeof window=="object"&&(R=window)}b.exports=R},function(b,c,R){var y,x;(function(I,T){"use strict";y=T,(x=typeof y=="function"?y.call(c,R,c,b):y)!==void 0&&(b.exports=x)})(0,function(){"use strict";function I(r,a){var n=r[a];if(typeof n.bind=="function")return n.bind(r);try{return Function.prototype.bind.call(n,r)}catch{return function(){return Function.prototype.apply.apply(n,[r,arguments])}}}function T(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function D(r){return r==="debug"&&(r="log"),typeof console!==v&&(r==="trace"&&p?T:console[r]!==void 0?I(console,r):console.log!==void 0?I(console,"log"):S)}function _(r,a){for(var n=0;n<s.length;n++){var h=s[n];this[h]=n<r?S:this.methodFactory(h,r,a)}this.log=this.debug}function g(r,a,n){return function(){typeof console!==v&&(_.call(this,a,n),this[r].apply(this,arguments))}}function A(r,a,n){return D(r)||g.apply(this,arguments)}function L(r,a,n){function h(m){var O=(s[m]||"silent").toUpperCase();if(typeof window!==v&&o){try{return void(window.localStorage[o]=O)}catch{}try{window.document.cookie=encodeURIComponent(o)+"="+O+";"}catch{}}}function d(){var m;if(typeof window!==v&&o){try{m=window.localStorage[o]}catch{}if(typeof m===v)try{var O=window.document.cookie,P=O.indexOf(encodeURIComponent(o)+"=");P!==-1&&(m=/^([^;]+)/.exec(O.slice(P))[1])}catch{}return l.levels[m]===void 0&&(m=void 0),m}}function u(){if(typeof window!==v&&o){try{return void window.localStorage.removeItem(o)}catch{}try{window.document.cookie=encodeURIComponent(o)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}var f,l=this;a=a==null?"WARN":a;var o="loglevel";typeof r=="string"?o+=":"+r:typeof r=="symbol"&&(o=void 0),l.name=r,l.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},l.methodFactory=n||A,l.getLevel=function(){return f},l.setLevel=function(m,O){if(typeof m=="string"&&l.levels[m.toUpperCase()]!==void 0&&(m=l.levels[m.toUpperCase()]),!(typeof m=="number"&&m>=0&&m<=l.levels.SILENT))throw"log.setLevel() called with invalid level: "+m;if(f=m,O!==!1&&h(m),_.call(l,m,r),typeof console===v&&m<l.levels.SILENT)return"No console available for logging"},l.setDefaultLevel=function(m){a=m,d()||l.setLevel(m,!1)},l.resetLevel=function(){l.setLevel(a,!1),u()},l.enableAll=function(m){l.setLevel(l.levels.TRACE,m)},l.disableAll=function(m){l.setLevel(l.levels.SILENT,m)};var E=d();E==null&&(E=a),l.setLevel(E,!1)}var S=function(){},v="undefined",p=typeof window!==v&&typeof window.navigator!==v&&/Trident\/|MSIE /.test(window.navigator.userAgent),s=["trace","debug","info","warn","error"],e=new L,i={};e.getLogger=function(r){if(typeof r!="symbol"&&typeof r!="string"||r==="")throw new TypeError("You must supply a name when creating a logger.");var a=i[r];return a||(a=i[r]=new L(r,e.getLevel(),e.methodFactory)),a};var t=typeof window!==v?window.log:void 0;return e.noConflict=function(){return typeof window!==v&&window.log===e&&(window.log=t),e},e.getLoggers=function(){return i},e.default=e,e})},function(b,c,R){"use strict";function y(J){return J&&J.__esModule?J:{default:J}}Object.defineProperty(c,"__esModule",{value:!0});var x=function(){function J($,Q){var se=[],he=!0,ue=!1,fe=void 0;try{for(var ge,Ee=$[Symbol.iterator]();!(he=(ge=Ee.next()).done)&&(se.push(ge.value),!Q||se.length!==Q);he=!0);}catch(oe){ue=!0,fe=oe}finally{try{!he&&Ee.return&&Ee.return()}finally{if(ue)throw fe}}return se}return function($,Q){if(Array.isArray($))return $;if(Symbol.iterator in Object($))return J($,Q);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),I=R(4),T=y(I),D=R(1),_=y(D),g=R(6),A=R(5),L=R(0),S=y(L),v=R(13),p=y(v),s=R(3),e=y(s),i=R(23),t=R(24),r=R(25),a=y(r),n=R(26),h=y(n),d=R(27),u=y(d),f=R(28),l=y(f),o=R(29),E=y(o),m=R(30),O=y(m),P=R(31),M=y(P),F=R(32),B=y(F),C=R(33),U=y(C),w=R(34),N=y(w),j=R(35),K=y(j),G=R(36),Y=y(G),V=R(37),Z=y(V),z=R(38),ie=y(z),X=R(39),ee=y(X),ce=R(57),ae=y(ce),ve=["viewstart","ended","loadstart","pause","play","playing","ratechange","waiting","adplay","adpause","adended","aderror","adplaying","adrequest","adresponse","adbreakstart","adbreakend","adfirstquartile","admidpoint","adthirdquartile","rebufferstart","rebufferend","seeked","error","hb","requestcompleted","requestfailed","requestcanceled","renditionchange"],q=function(J,$,Q){var se=this;this.DOM_CONTENT_LOADED_EVENT_END=p.default.domContentLoadedEventEnd(),this.NAVIGATION_START=p.default.navigationStart();var he={debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(oe){return oe}};this.mux=J,this.id=$,Q=(0,_.default)(he,Q),Q.data=Q.data||{},Q.data.property_key&&(Q.data.env_key=Q.data.property_key,delete Q.data.property_key),T.default.setLevel(Q.debug?"debug":"warn"),this.getPlayheadTime=Q.getPlayheadTime,this.getStateData=Q.getStateData||function(){},this.getAdData=Q.getAdData||function(){},this.minimumRebufferDuration=Q.minimumRebufferDuration,this.sustainedRebufferThreshold=Q.sustainedRebufferThreshold,this.playbackHeartbeatTime=Q.playbackHeartbeatTime,this.disableRebufferTracking=Q.disableRebufferTracking,this.disableRebufferTracking&&this.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."),this.errorTranslator=Q.errorTranslator,this.playbackEventDispatcher=new ee.default(J,Q.data.env_key,Q),this.data={player_instance_id:(0,g.generateUUID)(),mux_sample_rate:Q.sampleRate,beacon_domain:Q.beaconCollectionDomain?Q.beaconCollectionDomain:Q.beaconDomain},this.data.view_sequence_number=1,this.data.player_sequence_number=1,this.oldEmit=this.emit,this.emit=function(oe,le){le=(0,_.default)({viewer_time:this.mux.utils.now()},le),this.oldEmit(oe,le)};var ue=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(this);this.on("viewinit",function(oe,le){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),(0,_.default)(this.data,le),this._initializeViewData(),this.one("play",ue),this.one("adbreakstart",ue)});var fe=function(oe){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",oe)}.bind(this);if(this.on("videochange",function(oe,le){fe(le)}),this.on("programchange",function(oe,le){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),fe((0,_.default)(le,{view_program_changed:!0})),ue(),this.emit("play"),this.emit("playing")}),this.on("fragmentchange",function(oe,le){this.currentFragmentPDT=le.currentFragmentPDT,this.currentFragmentStart=le.currentFragmentStart}),this.on("destroy",this.destroy),S.default!==void 0&&typeof S.default.addEventListener=="function"&&typeof S.default.removeEventListener=="function"){var ge=function(oe){oe.persisted||se.destroy()};S.default.addEventListener("pagehide",ge,!1),this.on("destroy",function(){S.default.removeEventListener("pagehide",ge)})}this.on("playerready",function(oe,le){(0,_.default)(this.data,le)}),ve.forEach(function(oe){se.on(oe,function(le,Te){oe.indexOf("ad")!==0&&this._updateStateData(),(0,_.default)(this.data,Te),this._sanitizeData()}),se.on("after"+oe,function(){(oe!=="error"||this.viewErrored)&&this.send(oe)})}),this.on("viewend",function(oe,le){(0,_.default)(se.data,le)});var Ee=function(oe){var le=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=le-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time};this.one("playerready",Ee),u.default.apply(this),ie.default.apply(this),K.default.apply(this),O.default.apply(this),h.default.apply(this),N.default.apply(this),l.default.apply(this),E.default.apply(this),Y.default.apply(this),M.default.apply(this),B.default.apply(this),U.default.apply(this),Z.default.apply(this),ae.default.apply(this),Q.hlsjs&&this.addHLSJS(Q),Q.dashjs&&this.addDashJS(Q),this.emit("viewinit",Q.data)};(0,_.default)(q.prototype,a.default.prototype),(0,_.default)(q.prototype,O.default.prototype),(0,_.default)(q.prototype,K.default.prototype),(0,_.default)(q.prototype,h.default.prototype),(0,_.default)(q.prototype,l.default.prototype),(0,_.default)(q.prototype,E.default.prototype),(0,_.default)(q.prototype,Y.default.prototype),(0,_.default)(q.prototype,B.default.prototype),(0,_.default)(q.prototype,U.default.prototype),q.prototype.destroy=function(){this._destroyed||(this._destroyed=!0,this.data.view_start!==void 0&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),S.default.clearTimeout(this._heartBeatTimeout))},q.prototype.send=function(J){var $=(0,_.default)({},this.data),Q=["player_program_time","player_manifest_newest_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"];if($.video_source_is_live===void 0&&($.player_source_duration===1/0||$.video_source_duration===1/0?$.video_source_is_live=!0:($.player_source_duration>0||$.video_source_duration>0)&&($.video_source_is_live=!1)),$.video_source_is_live||Q.forEach(function(ge){$[ge]=void 0}),$.video_source_url=$.video_source_url||$.player_source_url,$.video_source_url){var se=(0,A.extractHostnameAndDomain)($.video_source_url),he=x(se,2),ue=he[0],fe=he[1];$.video_source_domain=fe,$.video_source_hostname=ue}delete $.ad_request_id,this.playbackEventDispatcher.send(J,$),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()},q.prototype._updateStateData=function(){(0,_.default)(this.data,this.getStateData()),this._updatePlayheadTime(),this._sanitizeData()},q.prototype._sanitizeData=function(){var J=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function($){var Q=parseInt(J.data[$],10);J.data[$]=isNaN(Q)?void 0:Q}),["player_source_url","video_source_url"].forEach(function($){if(J.data[$]){var Q=J.data[$].toLowerCase();Q.indexOf("data:")!==0&&Q.indexOf("blob:")!==0||(J.data[$]="MSE style URL")}})},q.prototype._resetVideoData=function(J,$){var Q=this;Object.keys(this.data).forEach(function(se){se.indexOf("video_")===0&&delete Q.data[se]})},q.prototype._resetViewData=function(){var J=this;Object.keys(this.data).forEach(function($){$.indexOf("view_")===0&&delete J.data[$]}),this.data.view_sequence_number=1},q.prototype._resetErrorData=function(J,$){delete this.data.player_error_code,delete this.data.player_error_message},q.prototype._initializeViewData=function(){var J=this,$=this.data.view_id=(0,g.generateUUID)(),Q=function(){$===J.data.view_id&&(0,e.default)(J.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",Q):Q()},q.prototype._restartHeartBeat=function(){var J=this;S.default.clearTimeout(this._heartBeatTimeout),this.viewErrored||(this._heartBeatTimeout=S.default.setTimeout(function(){J.data.player_is_paused||J.emit("hb")},1e4))},q.prototype.addHLSJS=function(J){return J.hlsjs?this.hlsjs?void this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=J.hlsjs,void(0,i.monitorHlsJs)(this.mux,this.id,J.hlsjs,{},J.Hls||S.default.Hls)):void this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")},q.prototype.removeHLSJS=function(){this.hlsjs&&((0,i.stopMonitoringHlsJs)(this.hlsjs),this.hlsjs=void 0)},q.prototype.addDashJS=function(J){return J.dashjs?this.dashjs?void this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=J.dashjs,void(0,t.monitorDashJS)(this.mux,this.id,J.dashjs)):void this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")},q.prototype.removeDashJS=function(){this.dashjs&&((0,t.stopMonitoringDashJS)(this.dashjs),this.dashjs=void 0)},c.default=q},function(b,c,R){"use strict";function y(s){return s&&s.__esModule?s:{default:s}}Object.defineProperty(c,"__esModule",{value:!0}),c.stopMonitoringHlsJs=c.monitorHlsJs=void 0;var x=R(7),I=y(x),T=R(13),D=y(T),_=R(5),g=R(14),A=y(g),L=function(s){if(!s)return{};var e=D.default.navigationStart(),i=s.loading,t=i?i.start:s.trequest,r=i?i.first:s.tfirst,a=i?i.end:s.tload;return{bytesLoaded:s.total,requestStart:Math.round(e+t),responseStart:Math.round(e+r),responseEnd:Math.round(e+a)}},S=function(s){if(s&&typeof s.getAllResponseHeaders=="function")return(0,I.default)(s.getAllResponseHeaders())},v=function(s,e,i){var t=(arguments.length>3&&arguments[3]!==void 0&&arguments[3],arguments[4]),r=s.log,a=s.utils.secondsToMs,n=function(P){var M=parseInt(t.version),F=void 0;return M===1&&P.programDateTime!==null&&(F=P.programDateTime),M===0&&P.pdt!==null&&(F=P.pdt),F};if(!D.default.exists())return void r.warn("performance timing not supported. Not tracking HLS.js.");var h=function(P,M){return s.emit(e,P,M)},d=function(P,M){var F=M.levels,B=M.audioTracks,C=M.url,U=M.stats,w=M.networkDetails,N=M.sessionData,j={},K={},G={};G=(0,A.default)(N),F.forEach(function(X,ee){j[ee]={width:X.width,height:X.height,bitrate:X.bitrate,attrs:X.attrs}}),B.forEach(function(X,ee){K[ee]={name:X.name,language:X.lang,bitrate:X.bitrate}});var Y=L(U),V=Y.bytesLoaded,Z=Y.requestStart,z=Y.responseStart,ie=Y.responseEnd;G.request_event_type=P,G.request_bytes_loaded=V,G.request_start=Z,G.request_response_start=z,G.request_response_end=ie,G.request_type="manifest",G.request_hostname=(0,_.extractHostname)(C),G.request_response_headers=S(w),G.request_rendition_lists={media:j,audio:K,video:{}},h("requestcompleted",G)};i.on(t.Events.MANIFEST_LOADED,d);var u=function(P,M){var F=M.details,B=M.level,C=M.networkDetails,U=M.stats,w=L(U),N=w.bytesLoaded,j=w.requestStart,K=w.responseStart,G=w.responseEnd,Y=F.fragments[F.fragments.length-1],V=n(Y)+a(Y.duration);h("requestcompleted",{request_event_type:P,request_bytes_loaded:N,request_start:j,request_response_start:K,request_response_end:G,request_current_level:B,request_type:"manifest",request_hostname:(0,_.extractHostname)(F.url),request_response_headers:S(C),video_holdback:F.holdBack&&a(F.holdBack),video_part_holdback:F.partHoldBack&&a(F.partHoldBack),video_part_target_duration:F.partTarget&&a(F.partTarget),video_target_duration:F.targetduration&&a(F.targetduration),video_source_is_live:F.live,player_manifest_newest_program_time:isNaN(V)?void 0:V})};i.on(t.Events.LEVEL_LOADED,u);var f=function(P,M){var F=M.details,B=M.networkDetails,C=M.stats,U=L(C),w=U.bytesLoaded,N=U.requestStart,j=U.responseStart,K=U.responseEnd;h("requestcompleted",{request_event_type:P,request_bytes_loaded:w,request_start:N,request_response_start:j,request_response_end:K,request_type:"manifest",request_hostname:(0,_.extractHostname)(F.url),request_response_headers:S(B)})};i.on(t.Events.AUDIO_TRACK_LOADED,f);var l=function(P,M){var F=M.stats,B=M.networkDetails,C=M.frag,U=L(F),w=U.bytesLoaded,N=U.requestStart,j=U.responseStart,K=U.responseEnd,G={request_event_type:P,request_bytes_loaded:w,request_start:N,request_response_start:j,request_response_end:K,request_hostname:B?(0,_.extractHostname)(B.responseURL):void 0,request_response_headers:S(B),request_media_duration:C.duration};C.type==="main"?(G.request_type="media",G.request_current_level=C.level,G.request_video_width=(i.levels[C.level]||{}).width,G.request_video_height=(i.levels[C.level]||{}).height):G.request_type=C.type,h("requestcompleted",G)};i.on(t.Events.FRAG_LOADED,l);var o=function(P,M){var F=M.frag,B=F.start,C=n(F),U={currentFragmentPDT:C,currentFragmentStart:a(B)};h("fragmentchange",U)};i.on(t.Events.FRAG_CHANGED,o);var E=function(P,M){var F=M.type,B=M.details,C=M.response,U=M.fatal,w=M.context,N=M.frag;if(B===t.ErrorDetails.MANIFEST_LOAD_ERROR||B===t.ErrorDetails.MANIFEST_LOAD_TIMEOUT||B===t.ErrorDetails.FRAG_LOAD_ERROR||B===t.ErrorDetails.FRAG_LOAD_TIMEOUT||B===t.ErrorDetails.LEVEL_LOAD_ERROR||B===t.ErrorDetails.LEVEL_LOAD_TIMEOUT){var j=N&&N.url||w&&w.url||"";h("requestfailed",{request_error:B,request_url:j,request_hostname:(0,_.extractHostname)(j),request_type:B===t.ErrorDetails.FRAG_LOAD_ERROR||B===t.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:C&&C.code,request_error_text:C&&C.text})}U&&h("error",{player_error_code:F,player_error_message:B})};i.on(t.Events.ERROR,E);var m=function(P,M){var F=M.frag,B=F&&F._url||"";h("requestcanceled",{request_cancel:P,request_url:B,request_type:"media",request_hostname:(0,_.extractHostname)(B)})};i.on(t.Events.FRAG_LOAD_EMERGENCY_ABORTED,m);var O=function(P,M){var F=M.level,B=i.levels[F];if(B&&B.attrs&&B.attrs.BANDWIDTH){var C=B.attrs.BANDWIDTH;C?h("renditionchange",{video_source_bitrate:C,video_source_width:B.width,video_source_height:B.height}):r.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};i.on(t.Events.LEVEL_SWITCHED,O),i._stopMuxMonitor=function(){i.off(t.Events.MANIFEST_LOADED,d),i.off(t.Events.LEVEL_LOADED,u),i.off(t.Events.AUDIO_TRACK_LOADED,f),i.off(t.Events.FRAG_LOADED,l),i.off(t.Events.FRAG_CHANGED,o),i.off(t.Events.ERROR,E),i.off(t.Events.FRAG_LOAD_EMERGENCY_ABORTED,m),i.off(t.Events.LEVEL_SWITCHED,O),i.off(t.Events.DESTROYING,i._stopMuxMonitor),delete i._stopMuxMonitor},i.on(t.Events.DESTROYING,i._stopMuxMonitor)},p=function(s){s&&typeof s._stopMuxMonitor=="function"&&s._stopMuxMonitor()};c.monitorHlsJs=v,c.stopMonitoringHlsJs=p},function(b,c,R){"use strict";function y(v){return v&&v.__esModule?v:{default:v}}Object.defineProperty(c,"__esModule",{value:!0}),c.stopMonitoringDashJS=c.monitorDashJS=void 0;var x=R(0),I=y(x),T=R(7),D=y(T),_=R(5),g=function(v,p){if(!v||typeof v.getRequests!="function")return{};var s=v.getRequests({state:"executed"});if(s.length===0)return{};var e=s[s.length-1],i=(0,_.extractHostname)(e.url),t=e.bytesLoaded,r=new Date(e.requestStartDate).getTime(),a=new Date(e.firstByteDate).getTime(),n=new Date(e.requestEndDate).getTime(),h=isNaN(e.duration)?0:e.duration,d=typeof p.getMetricsFor=="function"?p.getMetricsFor(e.mediaType).HttpList:p.getDashMetrics().getHttpRequests(e.mediaType),u=void 0;return d.length>0&&(u=(0,D.default)(d[d.length-1]._responseHeaders||"")),{requestStart:r,requestResponseStart:a,requestResponseEnd:n,requestBytesLoaded:t,requestResponseHeaders:u,requestMediaDuration:h,requestHostname:i}},A=function(v,p){var s=p.getQualityFor(v),e=p.getCurrentTrackFor(v),i=e.bitrateList;return i?{currentLevel:s,renditionWidth:i[s].width||null,renditionHeight:i[s].height||null,renditionBitrate:i[s].bandwidth}:{}},L=function(v,p,s){var e=(arguments.length>3&&arguments[3]!==void 0&&arguments[3],v.log);if(!s||!s.on)return void e.warn("Invalid dash.js player reference. Monitoring blocked.");var i=function(l,o){return v.emit(p,l,o)},t=function(l){var o=l.type,E=l.data,m=E||{},O=m.url;i("requestcompleted",{request_event_type:o,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:(0,_.extractHostname)(O)})};s.on("manifestLoaded",t);var r={},a=function(l){var o=l.type,E=l.fragmentModel,m=l.chunk,O=m||{},P=O.mediaInfo,M=P||{},F=M.type,B=M.bitrateList;B=B||[];var C={};B.forEach(function(V,Z){C[Z]={},C[Z].width=V.width,C[Z].height=V.height,C[Z].bitrate=V.bandwidth,C[Z].attrs={}}),F==="video"?r.video=C:F==="audio"?r.audio=C:r.media=C;var U=g(E,s),w=U.requestStart,N=U.requestResponseStart,j=U.requestResponseEnd,K=U.requestResponseHeaders,G=U.requestMediaDuration,Y=U.requestHostname;i("requestcompleted",{request_event_type:o,request_start:w,request_response_start:N,request_response_end:j,request_bytes_loaded:-1,request_type:F+"_init",request_response_headers:K,request_hostname:Y,request_media_duration:G,request_rendition_lists:r})};s.on("initFragmentLoaded",a);var n=function(l){var o=l.type,E=l.fragmentModel,m=l.chunk,O=m||{},P=O.mediaInfo,M=O.start,F=P||{},B=F.type,C=g(E,s),U=C.requestStart,w=C.requestResponseStart,N=C.requestResponseEnd,j=C.requestBytesLoaded,K=C.requestResponseHeaders,G=C.requestMediaDuration,Y=C.requestHostname,V=A(B,s),Z=V.currentLevel,z=V.renditionWidth,ie=V.renditionHeight,X=V.renditionBitrate;i("requestcompleted",{request_event_type:o,request_start:U,request_response_start:w,request_response_end:N,request_bytes_loaded:j,request_type:B,request_response_headers:K,request_hostname:Y,request_media_start_time:M,request_media_duration:G,request_current_level:Z,request_labeled_bitrate:X,request_video_width:z,request_video_height:ie})};s.on("mediaFragmentLoaded",n);var h={video:void 0,audio:void 0,totalBitrate:void 0},d=function(){if(h.video&&typeof h.video.bitrate=="number"){if(!h.video.width||!h.video.height)return void e.warn("have bitrate info for video but missing width/height");var l=h.video.bitrate;return h.audio&&typeof h.audio.bitrate=="number"&&(l+=h.audio.bitrate),l!==h.totalBitrate?(h.totalBitrate=l,{video_source_bitrate:l,video_source_height:h.video.height,video_source_width:h.video.width}):void 0}},u=function(l,o,E){if(typeof l.newQuality!="number")return void e.warn("missing evt.newQuality in qualityChangeRendered event",l);var m=l.mediaType;if(m==="audio"||m==="video"){var O=s.getBitrateInfoListFor(m).find(function(M){return M.qualityIndex===l.newQuality});if(!O||typeof O.bitrate!="number")return void e.warn("missing bitrate info for "+m);h[m]=O;var P=d();P&&i("renditionchange",P)}};s.on("qualityChangeRendered",u);var f=function(l){var o=l.error,E=l.event;E=E||{};var m=E.request||{},O=I.default.event&&I.default.event.currentTarget||{};i("requestfailed",{request_error:o+"_"+E.id+"_"+m.type,request_url:E.url,request_hostname:(0,_.extractHostname)(E.url),request_type:m.mediaType,request_error_code:O.status,request_error_type:O.statusText})};s.on("error",f),s._stopMuxMonitor=function(){s.off("manifestLoaded",t),s.off("initFragmentLoaded",a),s.off("mediaFragmentLoaded",n),s.off("qualityChangeRendered",u),s.off("error",f),delete s._stopMuxMonitor}},S=function(v){v&&typeof v._stopMuxMonitor=="function"&&v._stopMuxMonitor()};c.monitorDashJS=L,c.stopMonitoringDashJS=S},function(b,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y=function(){},x=0;y.prototype.on=function(I,T,D){return T._eventEmitterGuid=T._eventEmitterGuid||++x,this._listeners=this._listeners||{},this._listeners[I]=this._listeners[I]||[],D&&(T=T.bind(D)),this._listeners[I].push(T),T},y.prototype.off=function(I,T){var D=this._listeners&&this._listeners[I];D&&D.forEach(function(_,g){_._eventEmitterGuid===T._eventEmitterGuid&&D.splice(g,1)})},y.prototype.one=function(I,T,D){var _=this;T._eventEmitterGuid=T._eventEmitterGuid||++x;var g=function A(){_.off(I,A),T.apply(D||this,arguments)};g._eventEmitterGuid=T._eventEmitterGuid,this.on(I,g)},y.prototype.emit=function(I,T){var D=this;if(this._listeners){T=T||{};var _=this._listeners["before*"]||[],g=this._listeners[I]||[],A=this._listeners["after"+I]||[],L=function(S,v){S=S.slice(),S.forEach(function(p){p.call(D,{type:I},v)})};L(_,T),L(g,T),L(A,T)}},c.default=y},function(b,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y=R(0),x=function(T){return T&&T.__esModule?T:{default:T}}(y),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,D){this._playbackHeartbeatInterval!==null&&(x.default.clearInterval(this._playbackHeartbeatInterval),this.emit("playbackheartbeatend",{viewer_time:D.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)},c.default=I},function(b,c,R){"use strict";function y(){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(c,"__esModule",{value:!0}),c.default=y},function(b,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y=R(3),x=function(T){return T&&T.__esModule?T:{default:T}}(y),I=function(){this._watchTimeTrackerLastCheckedTime=null,this.on("playbackheartbeat",this._updateWatchTime),this.on("playbackheartbeatend",this._clearWatchTimeState)};I.prototype._updateWatchTime=function(T,D){var _=D.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=_),(0,x.default)(this.data,"view_watch_time",_-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=_},I.prototype._clearWatchTimeState=function(T,D){this._updateWatchTime(T,D),this._watchTimeTrackerLastCheckedTime=null},c.default=I},function(b,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y=R(3),x=function(T){return T&&T.__esModule?T:{default:T}}(y),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 D=T-this._playbackTimeTrackerLastPlayheadPosition;D<=1e3&&(0,x.default)(this.data,"view_content_playback_time",D)}this._playbackTimeTrackerLastPlayheadPosition=T},I.prototype._clearPlaybackTimeState=function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1},c.default=I},function(b,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y=function(){this.on("playbackheartbeat",this._updatePlayheadTime),this.on("playbackheartbeatend",this._updatePlayheadTime),this.on("timeupdate",this._updatePlayheadTime),this.on("destroy",function(){this.off("timeupdate",this._updatePlayheadTime)})};y.prototype._updateMaxPlayheadPosition=function(){this.data.view_max_playhead_position=this.data.view_max_playhead_position===void 0?this.data.player_playhead_time:Math.max(this.data.view_max_playhead_position,this.data.player_playhead_time)},y.prototype._updatePlayheadTime=function(x,I){var T=this,D=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,D(),this._updateMaxPlayheadPosition();else if(this.getPlayheadTime){var _=this.getPlayheadTime();_!==void 0&&(this.data.player_playhead_time=_,D(),this._updateMaxPlayheadPosition())}},c.default=y},function(b,c,R){"use strict";function y(){var T=this;if(!this.disableRebufferTracking){var D=void 0,_=function(){if(D){var g=T.data.viewer_time-D;(0,I.default)(T.data,"view_rebuffer_duration",g),D=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(){D||((0,I.default)(T.data,"view_rebuffer_count",1),D=T.data.viewer_time,T.one("rebufferend",function(){_(),D=void 0}))})}}Object.defineProperty(c,"__esModule",{value:!0}),c.default=y;var x=R(3),I=function(T){return T&&T.__esModule?T:{default:T}}(x)},function(b,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y=R(2),x=function(T){return T&&T.__esModule?T:{default:T}}(y),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,D){return this.isSeeking||this.isAdBreak||!this._playheadShouldBeProgressing?void this._cleanupRebufferTracker(T,D):this._lastCheckedTime===null?void this._prepareRebufferTrackerState(D.viewer_time):this._lastPlayheadTime!==this.data.player_playhead_time?void this._cleanupRebufferTracker(T,D,!0):(D.viewer_time-this._lastPlayheadTimeUpdatedTime>=this.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),void(this._lastCheckedTime=D.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,D){var _=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.emit("rebufferend",{viewer_time:D.viewer_time});else{if(this._lastCheckedTime===null)return;var g=this.data.player_playhead_time-this._lastPlayheadTime,A=D.viewer_time-this._lastPlayheadTimeUpdatedTime;g>0&&A-g>this.minimumRebufferDuration&&(this.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+A-g}))}_?this._prepareRebufferTrackerState(D.viewer_time):this._clearRebufferTrackerState()},c.default=I},function(b,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y=R(2),x=function(T){return T&&T.__esModule?T:{default:T}}(y),I=function(){this.on("viewinit",function(){var T=this.data,D=T.view_id;if(!T.view_program_changed){var _=function(g,A){var L=A.viewer_time;g.type==="playing"&&this.data.view_time_to_first_frame===void 0?this.calculateTimeToFirstFrame(L||x.default.now(),D):g.type!=="adplaying"||this.data.view_time_to_first_frame!==void 0&&!this.inPrerollPosition()||this.calculateTimeToFirstFrame(L||x.default.now(),D)};this.one("playing",_),this.one("adplaying",_),this.one("viewend",function(){this.off("playing",_),this.off("adplaying",_)})}})};I.prototype.calculateTimeToFirstFrame=function(T,D){D===this.data.view_id&&(this._updateWatchTime(null,{viewer_time:T}),this.data.view_time_to_first_frame=this.data.view_watch_time,(this.data.player_autoplay_on||this.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.data.view_aggregate_startup_time=this.data.view_start+this.data.view_watch_time-this.NAVIGATION_START))},c.default=I},function(b,c,R){"use strict";function y(){var T=this;this.on("viewinit",function(){this._lastPlayheadPosition=-1});var D=["pause","rebufferstart","seeking","error","adbreakstart","hb"],_=["playing","hb"];D.forEach(function(g){T.on(g,function(){if(this._lastPlayheadPosition>=0&&this.data.player_playhead_time>=0&&this._lastPlayerWidth>=0&&this._lastSourceWidth>0&&this._lastPlayerHeight>=0&&this._lastSourceHeight>0){var A=this.data.player_playhead_time-this._lastPlayheadPosition;if(A<0)return void(this._lastPlayheadPosition=-1);var L=Math.min(this._lastPlayerWidth/this._lastSourceWidth,this._lastPlayerHeight/this._lastSourceHeight),S=Math.max(0,L-1),v=Math.max(0,1-L);this.data.view_max_upscale_percentage=Math.max(this.data.view_max_upscale_percentage||0,S),this.data.view_max_downscale_percentage=Math.max(this.data.view_max_downscale_percentage||0,v),(0,I.default)(this.data,"view_total_content_playback_time",A),(0,I.default)(this.data,"view_total_upscaling",S*A),(0,I.default)(this.data,"view_total_downscaling",v*A)}this._lastPlayheadPosition=-1})}),_.forEach(function(g){T.on(g,function(){this._lastPlayheadPosition=this.data.player_playhead_time,this._lastPlayerWidth=this.data.player_width,this._lastPlayerHeight=this.data.player_height,this._lastSourceWidth=this.data.video_source_width,this._lastSourceHeight=this.data.video_source_height})})}Object.defineProperty(c,"__esModule",{value:!0}),c.default=y;var x=R(3),I=function(T){return T&&T.__esModule?T:{default:T}}(x)},function(b,c,R){"use strict";function y(L){return L&&L.__esModule?L:{default:L}}function x(){this.isSeeking=!1,this.on("seeking",function(L,S){(0,A.default)(this.data,S),this._lastSeekingTime=T.default.now(),this.isSeeking===!1&&(this.isSeeking=!0,this.send("seeking"))}),this.on("seeked",function(){this.isSeeking=!1;var L=this._lastSeekingTime||T.default.now(),S=T.default.now()-L;(0,_.default)(this.data,"view_seek_count",1),(0,_.default)(this.data,"view_seek_duration",S);var v=this.data.view_max_seek_time||0;this.data.view_max_seek_time=Math.max(v,S)}),this.on("viewend",function(){this.isSeeking=!1})}Object.defineProperty(c,"__esModule",{value:!0}),c.default=x;var I=R(2),T=y(I),D=R(3),_=y(D),g=R(1),A=y(g)},function(b,c,R){"use strict";function y(v){return v&&v.__esModule?v:{default:v}}Object.defineProperty(c,"__esModule",{value:!0});var x=function(){function v(p,s){var e=[],i=!0,t=!1,r=void 0;try{for(var a,n=p[Symbol.iterator]();!(i=(a=n.next()).done)&&(e.push(a.value),!s||e.length!==s);i=!0);}catch(h){t=!0,r=h}finally{try{!i&&n.return&&n.return()}finally{if(t)throw r}}return e}return function(p,s){if(Array.isArray(p))return p;if(Symbol.iterator in Object(p))return v(p,s);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),I=R(3),T=y(I),D=R(5),_=R(1),g=y(_),A=function(v,p){v.push(p),v.sort(function(s,e){return s.viewer_time-e.viewer_time})},L=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],S=function(){var v=this;this.on("viewinit",function(){this.isAdBreak=!1,this._currentAdRequestNumber=0,this._currentAdResponseNumber=0,this._adRequests=[],this._adResponses=[],this._adHasPlayed=!1,this._wouldBeNewAdPlay=!0,this._prerollPlayTime=void 0}),L.forEach(function(s){return v.on(s,v._updateAdData)});var p=function(){v.isAdBreak=!1};this.on("adbreakstart",function(){this.isAdBreak=!0}),this.on("play",p),this.on("playing",p),this.on("viewend",p),this.on("adrequest",function(s,e){e=(0,g.default)({ad_request_id:"generatedAdRequestId"+this._currentAdRequestNumber++},e),A(this._adRequests,e),(0,T.default)(this.data,"view_ad_request_count"),this.inPrerollPosition()&&(this.data.view_preroll_requested=!0,this._adHasPlayed||(0,T.default)(this.data,"view_preroll_request_count"))}),this.on("adresponse",function(s,e){e=(0,g.default)({ad_request_id:"generatedAdRequestId"+this._currentAdResponseNumber++},e),A(this._adResponses,e);var i=this.findAdRequest(e.ad_request_id);i&&(0,T.default)(this.data,"view_ad_request_time",Math.max(0,e.viewer_time-i.viewer_time))}),this.on("adplay",function(s,e){this._adHasPlayed=!0,this._wouldBeNewAdPlay&&(this._wouldBeNewAdPlay=!1,(0,T.default)(this.data,"view_ad_played_count")),this.inPrerollPosition()&&!this.data.view_preroll_played&&(this.data.view_preroll_played=!0,this._adRequests.length>0&&(this.data.view_preroll_request_time=Math.max(0,e.viewer_time-this._adRequests[0].viewer_time)),this.data.view_start&&(this.data.view_startup_preroll_request_time=Math.max(0,e.viewer_time-this.data.view_start)),this._prerollPlayTime=e.viewer_time)}),this.on("adplaying",function(s,e){this.inPrerollPosition()&&this.data.view_preroll_load_time===void 0&&this._prerollPlayTime!==void 0&&(this.data.view_preroll_load_time=e.viewer_time-this._prerollPlayTime,this.data.view_startup_preroll_load_time=e.viewer_time-this._prerollPlayTime)}),this.on("adended",function(){this._wouldBeNewAdPlay=!0}),this.on("aderror",function(){this._wouldBeNewAdPlay=!0})};S.prototype.inPrerollPosition=function(){return this.data.view_content_playback_time===void 0||this.data.view_content_playback_time<=1e3},S.prototype.findAdRequest=function(v){for(var p=0;p<this._adRequests.length;p++)if(this._adRequests[p].ad_request_id===v)return this._adRequests[p]},S.prototype._updateAdData=function(v,p){if(this.inPrerollPosition()){if(!this.data.view_preroll_ad_tag_hostname&&p.ad_tag_url){var s=(0,D.extractHostnameAndDomain)(p.ad_tag_url),e=x(s,2),i=e[0],t=e[1];this.data.view_preroll_ad_tag_domain=t,this.data.view_preroll_ad_tag_hostname=i}if(!this.data.view_preroll_ad_asset_hostname&&p.ad_asset_url){var r=(0,D.extractHostnameAndDomain)(p.ad_asset_url),a=x(r,2),n=a[0],h=a[1];this.data.view_preroll_ad_asset_domain=h,this.data.view_preroll_ad_asset_hostname=n}}},c.default=S},function(b,c,R){"use strict";function y(g){return g&&g.__esModule?g:{default:g}}function x(){var g=this,A=void 0,L=void 0,S=function(){g.disableRebufferTracking||((0,_.default)(g.data,"view_waiting_rebuffer_count",1),A=T.default.now(),L=window.setInterval(function(){if(A){var i=T.default.now();(0,_.default)(g.data,"view_waiting_rebuffer_duration",i-A),A=i}},250))},v=function(){g.disableRebufferTracking||A&&((0,_.default)(g.data,"view_waiting_rebuffer_duration",T.default.now()-A),A=!1,window.clearInterval(L))},p=!1,s=function(){p=!0},e=function(){p=!1,v()};this.on("waiting",function(){p&&S()}),this.on("playing",function(){v(),s()}),this.on("pause",e),this.on("seeking",e)}Object.defineProperty(c,"__esModule",{value:!0}),c.default=x;var I=R(2),T=y(I),D=R(3),_=y(D)},function(b,c,R){"use strict";function y(L){return L&&L.__esModule?L:{default:L}}function x(){var L=this;this.one("playbackheartbeat",g),this.on("playbackheartbeatend",function(){L.off("before*",A),L.one("playbackheartbeat",g)})}Object.defineProperty(c,"__esModule",{value:!0}),c.default=x;var I=R(1),T=y(I),D=R(2),_=y(D),g=function(){this.lastWallClockTime=_.default.now(),this.on("before*",A)},A=function(L){var S=_.default.now(),v=this.lastWallClockTime;this.lastWallClockTime=S,S-v>3e4&&(this.emit("devicesleep",{viewer_time:v}),(0,T.default)(this.data,{viewer_time:v}),this.send("devicesleep"),this.emit("devicewake",{viewer_time:S}),(0,T.default)(this.data,{viewer_time:S}),this.send("devicewake"))}},function(b,c,R){"use strict";function y(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(c,"__esModule",{value:!0});var x=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o){return typeof o}:function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},I=R(0),T=y(I),D=R(40),_=R(4),g=y(_),A=R(53),L=y(A),S=R(12),v=y(S),p=R(54),s=y(p),e=R(17),i=y(e),t=R(55),r=y(t),a=R(1),n=y(a),h=["env_key","view_id","view_sequence_number","player_sequence_number","beacon_domain","player_playhead_time","viewer_time","mux_api_version","event","video_id","player_instance_id"],d=["viewstart","error","ended","viewend"],u=function(o,E){var m=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.mux=o,this.envKey=E,this.eventQueue=new r.default((0,L.default)(E,m)),this.previousBeaconData=null,this.lastEventTime=null,this.sampleRate=m.sampleRate,this.disableCookies=m.disableCookies,this.respectDoNotTrack=m.respectDoNotTrack;var O=m.platform||{};this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:O.name,viewer_application_version:O.version,viewer_application_engine:O.layout,viewer_device_name:O.product,viewer_device_category:"",viewer_device_manufacturer:O.manufacturer,viewer_os_family:O.os&&O.os.family,viewer_os_architecture:O.os&&O.os.architecture,viewer_os_version:O.os&&O.os.version};var P=(0,s.default)();P&&(this.pageLevelData=(0,n.default)(this.pageLevelData,{viewer_connection_type:P})),T.default!==void 0&&T.default.location&&T.default.location.href&&(this.pageLevelData.page_url=T.default.location.href),this.viewerData=this.disableCookies?{}:(0,D.getAndUpdateViewerData)()};u.prototype.send=function(o,E){if(o){if(this.respectDoNotTrack&&(0,v.default)())return g.default.info("Not sending `"+o+"` because Do Not Track is enabled");if(!E||(E===void 0?"undefined":x(E))!=="object")return g.default.error("A data object was expected in send() but was not provided");var m=this.disableCookies?{}:(0,D.getAndUpdateSessionData)(),O={};(0,n.default)(O,this.pageLevelData),(0,n.default)(O,E),(0,n.default)(O,m),(0,n.default)(O,this.viewerData),O.event=o,O.env_key=this.envKey,O.user_id&&(O.viewer_user_id=O.user_id,delete O.user_id);var P=O.mux_sample_number>=this.sampleRate,M=this._deduplicateBeaconData(o,O),F=(0,i.default)(M);if(this.lastEventTime=this.mux.utils.now(),P)return g.default.info("Not sending event due to sample rate restriction",o,O,F);if(this.envKey||g.default.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",o,O,F),!this.rateLimited){if(g.default.info("Sending event",o,O,F),this.rateLimited=!this.eventQueue.queueEvent(o,F),this.mux.WINDOW_UNLOADING&&o==="viewend")this.eventQueue.destroy(!0);else if((d.indexOf(o)>=0||this.mux.WINDOW_VISIBLE===!1&&o==="hb")&&this.eventQueue.flushEvents(),this.rateLimited)return O.event="eventrateexceeded",F=(0,i.default)(O),this.eventQueue.queueEvent(O.event,F),g.default.error("Beaconing disabled due to rate limit.")}}},u.prototype.destroy=function(){this.eventQueue.destroy(!1)};var f=function(o,E,m,O){return!(!o||E.indexOf("request_")!==0)&&(E==="request_response_headers"||(m===void 0?"undefined":x(m))!=="object"||(O===void 0?"undefined":x(O))!=="object"||Object.keys(m||{}).length!==Object.keys(O||{}).length)},l=function(o,E){return o==="renditionchange"&&E.indexOf("video_source_")===0};u.prototype._deduplicateBeaconData=function(o,E){var m=this,O={},P=E.view_id;if(!P||o==="viewstart"||o==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)O=(0,n.default)({},E),P&&(this.previousBeaconData=O),P&&o==="viewend"&&(this.previousBeaconData=null);else{var M=o.indexOf("request")===0;Object.keys(E).forEach(function(F){var B=E[F];(B!==m.previousBeaconData[F]||h.indexOf(F)>-1||f(M,F,B,m.previousBeaconData[F])||l(o,F))&&(O[F]=B,m.previousBeaconData[F]=B)})}return O},c.default=u},function(b,c,R){"use strict";function y(s){return s&&s.__esModule?s:{default:s}}Object.defineProperty(c,"__esModule",{value:!0}),c.getAndUpdateSessionData=c.getAndUpdateViewerData=void 0;var x=R(15),I=y(x),T=R(52),D=y(T),_=R(6),g=R(2),A=y(g),L=function(){var s=void 0;try{s=I.default.parse(D.default.get("muxData")||"")}catch{s={}}return s},S=function(s){try{D.default.set("muxData",I.default.stringify(s),{expires:7300})}catch{}},v=function(){var s=L();return s.mux_viewer_id=s.mux_viewer_id||(0,_.generateUUID)(),s.msn=s.msn||Math.random(),S(s),{mux_viewer_id:s.mux_viewer_id,mux_sample_number:s.msn}},p=function(){var s=L(),e=A.default.now();return s.session_start&&(s.sst=s.session_start,delete s.session_start),s.session_id&&(s.sid=s.session_id,delete s.session_id),s.session_expires&&(s.sex=s.session_expires,delete s.session_expires),(!s.sex||s.sex<e)&&(s.sid=(0,_.generateUUID)(),s.sst=e),s.sex=e+15e5,S(s),{session_id:s.sid,session_start:s.sst,session_expires:s.sex}};c.getAndUpdateViewerData=v,c.getAndUpdateSessionData=p},function(b,c,R){"use strict";var y=R(42),x=R(16),I=R(10),T=Object.prototype.hasOwnProperty,D={brackets:function(r){return r+"[]"},comma:"comma",indices:function(r,a){return r+"["+a+"]"},repeat:function(r){return r}},_=Array.isArray,g=String.prototype.split,A=Array.prototype.push,L=function(r,a){A.apply(r,_(a)?a:[a])},S=Date.prototype.toISOString,v=I.default,p={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:x.encode,encodeValuesOnly:!1,format:v,formatter:I.formatters[v],indices:!1,serializeDate:function(r){return S.call(r)},skipNulls:!1,strictNullHandling:!1},s=function(r){return typeof r=="string"||typeof r=="number"||typeof r=="boolean"||typeof r=="symbol"||typeof r=="bigint"},e={},i=function r(a,n,h,d,u,f,l,o,E,m,O,P,M,F,B){for(var C=a,U=B,w=0,N=!1;(U=U.get(e))!==void 0&&!N;){var j=U.get(a);if(w+=1,j!==void 0){if(j===w)throw new RangeError("Cyclic object value");N=!0}U.get(e)===void 0&&(w=0)}if(typeof l=="function"?C=l(n,C):C instanceof Date?C=m(C):h==="comma"&&_(C)&&(C=x.maybeMap(C,function(q){return q instanceof Date?m(q):q})),C===null){if(d)return f&&!M?f(n,p.encoder,F,"key",O):n;C=""}if(s(C)||x.isBuffer(C)){if(f){var K=M?n:f(n,p.encoder,F,"key",O);if(h==="comma"&&M){for(var G=g.call(String(C),","),Y="",V=0;V<G.length;++V)Y+=(V===0?"":",")+P(f(G[V],p.encoder,F,"value",O));return[P(K)+"="+Y]}return[P(K)+"="+P(f(C,p.encoder,F,"value",O))]}return[P(n)+"="+P(String(C))]}var Z=[];if(C===void 0)return Z;var z;if(h==="comma"&&_(C))z=[{value:C.length>0?C.join(",")||null:void 0}];else if(_(l))z=l;else{var ie=Object.keys(C);z=o?ie.sort(o):ie}for(var X=0;X<z.length;++X){var ee=z[X],ce=typeof ee=="object"&&ee.value!==void 0?ee.value:C[ee];if(!u||ce!==null){var ae=_(C)?typeof h=="function"?h(n,ee):n:n+(E?"."+ee:"["+ee+"]");B.set(a,w);var ve=y();ve.set(e,B),L(Z,r(ce,ae,h,d,u,f,l,o,E,m,O,P,M,F,ve))}}return Z},t=function(r){if(!r)return p;if(r.encoder!==null&&r.encoder!==void 0&&typeof r.encoder!="function")throw new TypeError("Encoder has to be a function.");var a=r.charset||p.charset;if(r.charset!==void 0&&r.charset!=="utf-8"&&r.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=I.default;if(r.format!==void 0){if(!T.call(I.formatters,r.format))throw new TypeError("Unknown format option provided.");n=r.format}var h=I.formatters[n],d=p.filter;return(typeof r.filter=="function"||_(r.filter))&&(d=r.filter),{addQueryPrefix:typeof r.addQueryPrefix=="boolean"?r.addQueryPrefix:p.addQueryPrefix,allowDots:r.allowDots===void 0?p.allowDots:!!r.allowDots,charset:a,charsetSentinel:typeof r.charsetSentinel=="boolean"?r.charsetSentinel:p.charsetSentinel,delimiter:r.delimiter===void 0?p.delimiter:r.delimiter,encode:typeof r.encode=="boolean"?r.encode:p.encode,encoder:typeof r.encoder=="function"?r.encoder:p.encoder,encodeValuesOnly:typeof r.encodeValuesOnly=="boolean"?r.encodeValuesOnly:p.encodeValuesOnly,filter:d,format:n,formatter:h,serializeDate:typeof r.serializeDate=="function"?r.serializeDate:p.serializeDate,skipNulls:typeof r.skipNulls=="boolean"?r.skipNulls:p.skipNulls,sort:typeof r.sort=="function"?r.sort:null,strictNullHandling:typeof r.strictNullHandling=="boolean"?r.strictNullHandling:p.strictNullHandling}};b.exports=function(r,a){var n,h,d=r,u=t(a);typeof u.filter=="function"?(h=u.filter,d=h("",d)):_(u.filter)&&(h=u.filter,n=h);var f=[];if(typeof d!="object"||d===null)return"";var l;l=a&&a.arrayFormat in D?a.arrayFormat:a&&"indices"in a?a.indices?"indices":"repeat":"indices";var o=D[l];n||(n=Object.keys(d)),u.sort&&n.sort(u.sort);for(var E=y(),m=0;m<n.length;++m){var O=n[m];u.skipNulls&&d[O]===null||L(f,i(d[O],O,o,u.strictNullHandling,u.skipNulls,u.encode?u.encoder:null,u.filter,u.sort,u.allowDots,u.serializeDate,u.format,u.formatter,u.encodeValuesOnly,u.charset,E))}var P=f.join(u.delimiter),M=u.addQueryPrefix===!0?"?":"";return u.charsetSentinel&&(u.charset==="iso-8859-1"?M+="utf8=%26%2310003%3B&":M+="utf8=%E2%9C%93&"),P.length>0?M+P:""}},function(b,c,R){"use strict";var y=R(8),x=R(47),I=R(49),T=y("%TypeError%"),D=y("%WeakMap%",!0),_=y("%Map%",!0),g=x("WeakMap.prototype.get",!0),A=x("WeakMap.prototype.set",!0),L=x("WeakMap.prototype.has",!0),S=x("Map.prototype.get",!0),v=x("Map.prototype.set",!0),p=x("Map.prototype.has",!0),s=function(r,a){for(var n,h=r;(n=h.next)!==null;h=n)if(n.key===a)return h.next=n.next,n.next=r.next,r.next=n,n},e=function(r,a){var n=s(r,a);return n&&n.value},i=function(r,a,n){var h=s(r,a);h?h.value=n:r.next={key:a,next:r.next,value:n}},t=function(r,a){return!!s(r,a)};b.exports=function(){var r,a,n,h={assert:function(d){if(!h.has(d))throw new T("Side channel does not contain "+I(d))},get:function(d){if(D&&d&&(typeof d=="object"||typeof d=="function")){if(r)return g(r,d)}else if(_){if(a)return S(a,d)}else if(n)return e(n,d)},has:function(d){if(D&&d&&(typeof d=="object"||typeof d=="function")){if(r)return L(r,d)}else if(_){if(a)return p(a,d)}else if(n)return t(n,d);return!1},set:function(d,u){D&&d&&(typeof d=="object"||typeof d=="function")?(r||(r=new D),A(r,d,u)):_?(a||(a=new _),v(a,d,u)):(n||(n={key:{},next:null}),i(n,d,u))}};return h}},function(b,c,R){"use strict";var y=typeof Symbol!="undefined"&&Symbol,x=R(44);b.exports=function(){return typeof y=="function"&&typeof Symbol=="function"&&typeof y("foo")=="symbol"&&typeof Symbol("bar")=="symbol"&&x()}},function(b,c,R){"use strict";b.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var y={},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;y[x]=42;for(x in y)return!1;if(typeof Object.keys=="function"&&Object.keys(y).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(y).length!==0)return!1;var T=Object.getOwnPropertySymbols(y);if(T.length!==1||T[0]!==x||!Object.prototype.propertyIsEnumerable.call(y,x))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var D=Object.getOwnPropertyDescriptor(y,x);if(D.value!==42||D.enumerable!==!0)return!1}return!0}},function(b,c,R){"use strict";var y=Array.prototype.slice,x=Object.prototype.toString;b.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 D,_=y.call(arguments,1),g=function(){if(this instanceof D){var p=T.apply(this,_.concat(y.call(arguments)));return Object(p)===p?p:this}return T.apply(I,_.concat(y.call(arguments)))},A=Math.max(0,T.length-_.length),L=[],S=0;S<A;S++)L.push("$"+S);if(D=Function("binder","return function ("+L.join(",")+"){ return binder.apply(this,arguments); }")(g),T.prototype){var v=function(){};v.prototype=T.prototype,D.prototype=new v,v.prototype=null}return D}},function(b,c,R){"use strict";var y=R(9);b.exports=y.call(Function.call,Object.prototype.hasOwnProperty)},function(b,c,R){"use strict";var y=R(8),x=R(48),I=x(y("String.prototype.indexOf"));b.exports=function(T,D){var _=y(T,!!D);return typeof _=="function"&&I(T,".prototype.")>-1?x(_):_}},function(b,c,R){"use strict";var y=R(9),x=R(8),I=x("%Function.prototype.apply%"),T=x("%Function.prototype.call%"),D=x("%Reflect.apply%",!0)||y.call(T,I),_=x("%Object.getOwnPropertyDescriptor%",!0),g=x("%Object.defineProperty%",!0),A=x("%Math.max%");if(g)try{g({},"a",{value:1})}catch{g=null}b.exports=function(S){var v=D(y,T,arguments);return _&&g&&_(v,"length").configurable&&g(v,"length",{value:1+A(0,S.length-(arguments.length-1))}),v};var L=function(){return D(y,I,arguments)};g?g(b.exports,"apply",{value:L}):b.exports.apply=L},function(b,c,R){function y(W,H){if(W===1/0||W===-1/0||W!==W||W&&W>-1e3&&W<1e3||se.call(/e/,H))return H;var re=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof W=="number"){var ne=W<0?-ge(-W):ge(W);if(ne!==W){var me=String(ne),pe=q.call(H,me.length+1);return J.call(me,re,"$&_")+"."+J.call(J.call(pe,/([0-9]{3})/g,"$&_"),/_$/,"")}}return J.call(H,re,"$&_")}function x(W,H,re){var ne=(re.quoteStyle||H)==="double"?'"':"'";return ne+W+ne}function I(W){return J.call(String(W),/"/g,""")}function T(W){return!(e(W)!=="[object Array]"||de&&typeof W=="object"&&de in W)}function D(W){return!(e(W)!=="[object Date]"||de&&typeof W=="object"&&de in W)}function _(W){return!(e(W)!=="[object RegExp]"||de&&typeof W=="object"&&de in W)}function g(W){return!(e(W)!=="[object Error]"||de&&typeof W=="object"&&de in W)}function A(W){return!(e(W)!=="[object String]"||de&&typeof W=="object"&&de in W)}function L(W){return!(e(W)!=="[object Number]"||de&&typeof W=="object"&&de in W)}function S(W){return!(e(W)!=="[object Boolean]"||de&&typeof W=="object"&&de in W)}function v(W){if(Te)return W&&typeof W=="object"&&W instanceof Symbol;if(typeof W=="symbol")return!0;if(!W||typeof W!="object"||!le)return!1;try{return le.call(W),!0}catch{}return!1}function p(W){if(!W||typeof W!="object"||!Ee)return!1;try{return Ee.call(W),!0}catch{}return!1}function s(W,H){return Oe.call(W,H)}function e(W){return ce.call(W)}function i(W){if(W.name)return W.name;var H=ve.call(ae.call(W),/^function\s*([\w$]+)/);return H?H[1]:null}function t(W,H){if(W.indexOf)return W.indexOf(H);for(var re=0,ne=W.length;re<ne;re++)if(W[re]===H)return re;return-1}function r(W){if(!U||!W||typeof W!="object")return!1;try{U.call(W);try{K.call(W)}catch{return!0}return W instanceof Map}catch{}return!1}function a(W){if(!V||!W||typeof W!="object")return!1;try{V.call(W,V);try{z.call(W,z)}catch{return!0}return W instanceof WeakMap}catch{}return!1}function n(W){if(!X||!W||typeof W!="object")return!1;try{return X.call(W),!0}catch{}return!1}function h(W){if(!K||!W||typeof W!="object")return!1;try{K.call(W);try{U.call(W)}catch{return!0}return W instanceof Set}catch{}return!1}function d(W){if(!z||!W||typeof W!="object")return!1;try{z.call(W,z);try{V.call(W,V)}catch{return!0}return W instanceof WeakSet}catch{}return!1}function u(W){return!(!W||typeof W!="object")&&(typeof HTMLElement!="undefined"&&W instanceof HTMLElement||typeof W.nodeName=="string"&&typeof W.getAttribute=="function")}function f(W,H){if(W.length>H.maxStringLength){var re=W.length-H.maxStringLength,ne="... "+re+" more character"+(re>1?"s":"");return f(q.call(W,0,H.maxStringLength),H)+ne}return x(J.call(J.call(W,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,l),"single",H)}function l(W){var H=W.charCodeAt(0),re={8:"b",9:"t",10:"n",12:"f",13:"r"}[H];return re?"\\"+re:"\\x"+(H<16?"0":"")+$.call(H.toString(16))}function o(W){return"Object("+W+")"}function E(W){return W+" { ? }"}function m(W,H,re,ne){return W+" ("+H+") {"+(ne?M(re,ne):ue.call(re,", "))+"}"}function O(W){for(var H=0;H<W.length;H++)if(t(W[H],`
|
|
2
|
+
`)>=0)return!1;return!0}function P(W,H){var re;if(W.indent===" ")re=" ";else{if(!(typeof W.indent=="number"&&W.indent>0))return null;re=ue.call(Array(W.indent+1)," ")}return{base:re,prev:ue.call(Array(H+1),re)}}function M(W,H){if(W.length===0)return"";var re=`
|
|
3
|
+
`+H.prev+H.base;return re+ue.call(W,","+re)+`
|
|
4
|
+
`+H.prev}function F(W,H){var re=T(W),ne=[];if(re){ne.length=W.length;for(var me=0;me<W.length;me++)ne[me]=s(W,me)?H(W[me],W):""}var pe,te=typeof oe=="function"?oe(W):[];if(Te){pe={};for(var Ae=0;Ae<te.length;Ae++)pe["$"+te[Ae]]=te[Ae]}for(var xe in W)s(W,xe)&&(re&&String(Number(xe))===xe&&xe<W.length||Te&&pe["$"+xe]instanceof Symbol||(se.call(/[^\w$]/,xe)?ne.push(H(xe,W)+": "+H(W[xe],W)):ne.push(xe+": "+H(W[xe],W))));if(typeof oe=="function")for(var Re=0;Re<te.length;Re++)Le.call(W,te[Re])&&ne.push("["+H(te[Re])+"]: "+H(W[te[Re]],W));return ne}var B=typeof Map=="function"&&Map.prototype,C=Object.getOwnPropertyDescriptor&&B?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,U=B&&C&&typeof C.get=="function"?C.get:null,w=B&&Map.prototype.forEach,N=typeof Set=="function"&&Set.prototype,j=Object.getOwnPropertyDescriptor&&N?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,K=N&&j&&typeof j.get=="function"?j.get:null,G=N&&Set.prototype.forEach,Y=typeof WeakMap=="function"&&WeakMap.prototype,V=Y?WeakMap.prototype.has:null,Z=typeof WeakSet=="function"&&WeakSet.prototype,z=Z?WeakSet.prototype.has:null,ie=typeof WeakRef=="function"&&WeakRef.prototype,X=ie?WeakRef.prototype.deref:null,ee=Boolean.prototype.valueOf,ce=Object.prototype.toString,ae=Function.prototype.toString,ve=String.prototype.match,q=String.prototype.slice,J=String.prototype.replace,$=String.prototype.toUpperCase,Q=String.prototype.toLowerCase,se=RegExp.prototype.test,he=Array.prototype.concat,ue=Array.prototype.join,fe=Array.prototype.slice,ge=Math.floor,Ee=typeof BigInt=="function"?BigInt.prototype.valueOf:null,oe=Object.getOwnPropertySymbols,le=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Te=typeof Symbol=="function"&&typeof Symbol.iterator=="object",de=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Te?"object":"symbol")?Symbol.toStringTag:null,Le=Object.prototype.propertyIsEnumerable,ye=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(W){return W.__proto__}:null),Se=R(50).custom,De=Se&&v(Se)?Se:null;b.exports=function W(H,re,ne,me){function pe(Ce,Ye,It){if(Ye&&(me=fe.call(me),me.push(Ye)),It){var mt={depth:te.depth};return s(te,"quoteStyle")&&(mt.quoteStyle=te.quoteStyle),W(Ce,mt,ne+1,me)}return W(Ce,te,ne+1,me)}var te=re||{};if(s(te,"quoteStyle")&&te.quoteStyle!=="single"&&te.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(s(te,"maxStringLength")&&(typeof te.maxStringLength=="number"?te.maxStringLength<0&&te.maxStringLength!==1/0:te.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var Ae=!s(te,"customInspect")||te.customInspect;if(typeof Ae!="boolean"&&Ae!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(s(te,"indent")&&te.indent!==null&&te.indent!==" "&&!(parseInt(te.indent,10)===te.indent&&te.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(s(te,"numericSeparator")&&typeof te.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var xe=te.numericSeparator;if(H===void 0)return"undefined";if(H===null)return"null";if(typeof H=="boolean")return H?"true":"false";if(typeof H=="string")return f(H,te);if(typeof H=="number"){if(H===0)return 1/0/H>0?"0":"-0";var Re=String(H);return xe?y(H,Re):Re}if(typeof H=="bigint"){var we=String(H)+"n";return xe?y(H,we):we}var He=te.depth===void 0?5:te.depth;if(ne===void 0&&(ne=0),ne>=He&&He>0&&typeof H=="object")return T(H)?"[Array]":"[Object]";var Pe=P(te,ne);if(me===void 0)me=[];else if(t(me,H)>=0)return"[Circular]";if(typeof H=="function"){var Ge=i(H),Ie=F(H,pe);return"[Function"+(Ge?": "+Ge:" (anonymous)")+"]"+(Ie.length>0?" { "+ue.call(Ie,", ")+" }":"")}if(v(H)){var ke=Te?J.call(String(H),/^(Symbol\(.*\))_[^)]*$/,"$1"):le.call(H);return typeof H!="object"||Te?ke:o(ke)}if(u(H)){for(var Me="<"+Q.call(String(H.nodeName)),Ne=H.attributes||[],Ve=0;Ve<Ne.length;Ve++)Me+=" "+Ne[Ve].name+"="+x(I(Ne[Ve].value),"double",te);return Me+=">",H.childNodes&&H.childNodes.length&&(Me+="..."),Me+="</"+Q.call(String(H.nodeName))+">"}if(T(H)){if(H.length===0)return"[]";var $e=F(H,pe);return Pe&&!O($e)?"["+M($e,Pe)+"]":"[ "+ue.call($e,", ")+" ]"}if(g(H)){var Ze=F(H,pe);return"cause"in H&&!Le.call(H,"cause")?"{ ["+String(H)+"] "+ue.call(he.call("[cause]: "+pe(H.cause),Ze),", ")+" }":Ze.length===0?"["+String(H)+"]":"{ ["+String(H)+"] "+ue.call(Ze,", ")+" }"}if(typeof H=="object"&&Ae){if(De&&typeof H[De]=="function")return H[De]();if(Ae!=="symbol"&&typeof H.inspect=="function")return H.inspect()}if(r(H)){var ct=[];return w.call(H,function(Ce,Ye){ct.push(pe(Ye,H,!0)+" => "+pe(Ce,H))}),m("Map",U.call(H),ct,Pe)}if(h(H)){var ht=[];return G.call(H,function(Ce){ht.push(pe(Ce,H))}),m("Set",K.call(H),ht,Pe)}if(a(H))return E("WeakMap");if(d(H))return E("WeakSet");if(n(H))return E("WeakRef");if(L(H))return o(pe(Number(H)));if(p(H))return o(pe(Ee.call(H)));if(S(H))return o(ee.call(H));if(A(H))return o(pe(String(H)));if(!D(H)&&!_(H)){var qe=F(H,pe),vt=ye?ye(H)===Object.prototype:H instanceof Object||H.constructor===Object,et=H instanceof Object?"":"null prototype",gt=!vt&&de&&Object(H)===H&&de in H?q.call(e(H),8,-1):et?"Object":"",bt=vt||typeof H.constructor!="function"?"":H.constructor.name?H.constructor.name+" ":"",tt=bt+(gt||et?"["+ue.call(he.call([],gt||[],et||[]),": ")+"] ":"");return qe.length===0?tt+"{}":Pe?tt+"{"+M(qe,Pe)+"}":tt+"{ "+ue.call(qe,", ")+" }"}return String(H)};var Oe=Object.prototype.hasOwnProperty||function(W){return W in this}},function(b,c){},function(b,c,R){"use strict";var y=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:y.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},D=function(v){return v.replace(/&#(\d+);/g,function(p,s){return String.fromCharCode(parseInt(s,10))})},_=function(v,p){return v&&typeof v=="string"&&p.comma&&v.indexOf(",")>-1?v.split(","):v},g=function(v,p){var s,e={},i=p.ignoreQueryPrefix?v.replace(/^\?/,""):v,t=p.parameterLimit===1/0?void 0:p.parameterLimit,r=i.split(p.delimiter,t),a=-1,n=p.charset;if(p.charsetSentinel)for(s=0;s<r.length;++s)r[s].indexOf("utf8=")===0&&(r[s]==="utf8=%E2%9C%93"?n="utf-8":r[s]==="utf8=%26%2310003%3B"&&(n="iso-8859-1"),a=s,s=r.length);for(s=0;s<r.length;++s)if(s!==a){var h,d,u=r[s],f=u.indexOf("]="),l=f===-1?u.indexOf("="):f+1;l===-1?(h=p.decoder(u,T.decoder,n,"key"),d=p.strictNullHandling?null:""):(h=p.decoder(u.slice(0,l),T.decoder,n,"key"),d=y.maybeMap(_(u.slice(l+1),p),function(o){return p.decoder(o,T.decoder,n,"value")})),d&&p.interpretNumericEntities&&n==="iso-8859-1"&&(d=D(d)),u.indexOf("[]=")>-1&&(d=I(d)?[d]:d),x.call(e,h)?e[h]=y.combine(e[h],d):e[h]=d}return e},A=function(v,p,s,e){for(var i=e?p:_(p,s),t=v.length-1;t>=0;--t){var r,a=v[t];if(a==="[]"&&s.parseArrays)r=[].concat(i);else{r=s.plainObjects?Object.create(null):{};var n=a.charAt(0)==="["&&a.charAt(a.length-1)==="]"?a.slice(1,-1):a,h=parseInt(n,10);s.parseArrays||n!==""?!isNaN(h)&&a!==n&&String(h)===n&&h>=0&&s.parseArrays&&h<=s.arrayLimit?(r=[],r[h]=i):n!=="__proto__"&&(r[n]=i):r={0:i}}i=r}return i},L=function(v,p,s,e){if(v){var i=s.allowDots?v.replace(/\.([^.[]+)/g,"[$1]"):v,t=/(\[[^[\]]*])/,r=/(\[[^[\]]*])/g,a=s.depth>0&&t.exec(i),n=a?i.slice(0,a.index):i,h=[];if(n){if(!s.plainObjects&&x.call(Object.prototype,n)&&!s.allowPrototypes)return;h.push(n)}for(var d=0;s.depth>0&&(a=r.exec(i))!==null&&d<s.depth;){if(d+=1,!s.plainObjects&&x.call(Object.prototype,a[1].slice(1,-1))&&!s.allowPrototypes)return;h.push(a[1])}return a&&h.push("["+i.slice(a.index)+"]"),A(h,p,s,e)}},S=function(v){if(!v)return T;if(v.decoder!==null&&v.decoder!==void 0&&typeof v.decoder!="function")throw new TypeError("Decoder has to be a function.");if(v.charset!==void 0&&v.charset!=="utf-8"&&v.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var p=v.charset===void 0?T.charset:v.charset;return{allowDots:v.allowDots===void 0?T.allowDots:!!v.allowDots,allowPrototypes:typeof v.allowPrototypes=="boolean"?v.allowPrototypes:T.allowPrototypes,allowSparse:typeof v.allowSparse=="boolean"?v.allowSparse:T.allowSparse,arrayLimit:typeof v.arrayLimit=="number"?v.arrayLimit:T.arrayLimit,charset:p,charsetSentinel:typeof v.charsetSentinel=="boolean"?v.charsetSentinel:T.charsetSentinel,comma:typeof v.comma=="boolean"?v.comma:T.comma,decoder:typeof v.decoder=="function"?v.decoder:T.decoder,delimiter:typeof v.delimiter=="string"||y.isRegExp(v.delimiter)?v.delimiter:T.delimiter,depth:typeof v.depth=="number"||v.depth===!1?+v.depth:T.depth,ignoreQueryPrefix:v.ignoreQueryPrefix===!0,interpretNumericEntities:typeof v.interpretNumericEntities=="boolean"?v.interpretNumericEntities:T.interpretNumericEntities,parameterLimit:typeof v.parameterLimit=="number"?v.parameterLimit:T.parameterLimit,parseArrays:v.parseArrays!==!1,plainObjects:typeof v.plainObjects=="boolean"?v.plainObjects:T.plainObjects,strictNullHandling:typeof v.strictNullHandling=="boolean"?v.strictNullHandling:T.strictNullHandling}};b.exports=function(v,p){var s=S(p);if(v===""||v===null||v===void 0)return s.plainObjects?Object.create(null):{};for(var e=typeof v=="string"?g(v,s):v,i=s.plainObjects?Object.create(null):{},t=Object.keys(e),r=0;r<t.length;++r){var a=t[r],n=L(a,e[a],s,typeof v=="string");i=y.merge(i,n,s)}return s.allowSparse===!0?i:y.compact(i)}},function(b,c,R){"use strict";var y,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 D=!1;if(y=T,(x=typeof y=="function"?y.call(c,R,c,b):y)!==void 0&&(b.exports=x),D=!0,I(c)==="object"&&(b.exports=T(),D=!0),!D){var _=window.Cookies,g=window.Cookies=T();g.noConflict=function(){return window.Cookies=_,g}}})(function(){function T(_){function g(A,L,S){var v;if(typeof document!="undefined"){if(arguments.length>1){if(S=D({path:"/"},g.defaults,S),typeof S.expires=="number"){var p=new Date;p.setMilliseconds(p.getMilliseconds()+864e5*S.expires),S.expires=p}try{v=JSON.stringify(L),/^[\{\[]/.test(v)&&(L=v)}catch{}return L=_.write?_.write(L,A):encodeURIComponent(String(L)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),A=encodeURIComponent(String(A)),A=A.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),A=A.replace(/[\(\)]/g,escape),document.cookie=[A,"=",L,S.expires?"; expires="+S.expires.toUTCString():"",S.path?"; path="+S.path:"",S.domain?"; domain="+S.domain:"",S.secure?"; secure":""].join("")}A||(v={});for(var s=document.cookie?document.cookie.split("; "):[],e=/(%[0-9A-Z]{2})+/g,i=0;i<s.length;i++){var t=s[i].split("="),r=t.slice(1).join("=");r.charAt(0)==='"'&&(r=r.slice(1,-1));try{var a=t[0].replace(e,decodeURIComponent);if(r=_.read?_.read(r,a):_(r,a)||r.replace(e,decodeURIComponent),this.json)try{r=JSON.parse(r)}catch{}if(A===a){v=r;break}A||(v[a]=r)}catch{}}return v}}return g.set=g,g.get=function(A){return g.call(g,A)},g.getJSON=function(){return g.apply({json:!0},[].slice.call(arguments))},g.defaults={},g.remove=function(A,L){g(A,"",D(L,{expires:-1}))},g.withConverter=T,g}var D=function(){for(var _=0,g={};_<arguments.length;_++){var A=arguments[_];for(var L in A)g[L]=A[L]}return g};return T(function(){})})},function(b,c,R){"use strict";function y(x,I){var T=I.beaconCollectionDomain,D=I.beaconDomain;if(T)return"https://"+T;x=x||"inferred";var _=D||"litix.io";return x.match(/^[a-z0-9]+$/)?"https://"+x+"."+_:"https://img.litix.io/a.gif"}Object.defineProperty(c,"__esModule",{value:!0}),c.default=y},function(b,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y=R(0),x=function(D){return D&&D.__esModule?D:{default:D}}(y),I=function(){var D=void 0;switch(T()){case"cellular":D="cellular";break;case"ethernet":D="wired";break;case"wifi":D="wifi";break;case void 0:break;default:D="other"}return D},T=function(){var D=x.default.navigator,_=D&&(D.connection||D.mozConnection||D.webkitConnection);return _&&_.type};c.default=I},function(b,c,R){"use strict";function y(r){return r&&r.__esModule?r:{default:r}}Object.defineProperty(c,"__esModule",{value:!0});var x=R(0),I=y(x),T=R(4),D=y(T),_=R(56),g=y(_),A=R(1),L=y(A),S=R(17),v=y(S),p=R(2),s=y(p),e=!!I.default.XMLHttpRequest&&"withCredentials"in new I.default.XMLHttpRequest,i={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4},t=function(r,a){this._beaconUrl=r||"https://img.litix.io",this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=(0,L.default)({},i,a)};t.prototype.queueEvent=function(r,a){var n=(0,L.default)({},a);return e?(this._eventQueue.length<=this._options.maxQueueLength||r==="eventrateexceeded")&&(this._eventQueue.push(n),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength):(g.default.send(this._beaconUrl,n),!0)},t.prototype.flushEvents=function(){e&&(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},t.prototype.destroy=function(){var r=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,r?this._clearBeaconQueue():this.flushEvents(),I.default.clearTimeout(this._sendTimeout)},t.prototype._clearBeaconQueue=function(){var r=I.default.navigator,a=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,n=this._eventQueue.slice(a);a>0&&(0,L.default)(n[n.length-1],(0,v.default)({mux_view_message:"event queue truncated"}));var h=this._createPayload(n);if(r.sendBeacon)r.sendBeacon(this._beaconUrl,h);else if(I.default.XMLHttpRequest){var d=new I.default.XMLHttpRequest;d.open("POST",this._beaconUrl),d.setRequestHeader("Content-Type","application/json"),d.send(h)}else g.default.send(this._beaconUrl,n[n.length-1])},t.prototype._sendBeaconQueue=function(){var r=this;if(I.default.XMLHttpRequest&&!this._postInFlight){var a=new I.default.XMLHttpRequest,n=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0,a.onreadystatechange=function(){a.readyState===4&&(a.status!==200?(r._eventQueue=n.concat(r._eventQueue),r._failureCount+=1,D.default.info("Error sending beacon: "+a.status),D.default.info(a.responseText)):r._failureCount=0,r._roundTripTime=s.default.now()-d,r._postInFlight=!1)},a.open("POST",this._beaconUrl),a.setRequestHeader("Content-Type","application/json");var h=this._createPayload(n),d=s.default.now();a.send(h)}},t.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var r=Math.pow(2,this._failureCount-1);return(1+(r*=Math.random()))*this._options.baseTimeBetweenBeacons},t.prototype._startBeaconSending=function(){var r=this;I.default.clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=I.default.setTimeout(function(){r._eventQueue.length&&r._sendBeaconQueue(),r._startBeaconSending()},this._getNextBeaconTime()))},t.prototype._createPayload=function(r){var a={transmission_timestamp:Math.round(s.default.now())};return this._roundTripTime&&(a.rtt_ms=Math.round(this._roundTripTime)),JSON.stringify({metadata:a,events:r})},c.default=t},function(b,c,R){"use strict";function y(g){return g&&g.__esModule?g:{default:g}}Object.defineProperty(c,"__esModule",{value:!0});var x=R(15),I=y(x),T=R(0),D=y(T),_={};_.send=function(g,A){function L(){S.src=p+(v?"&rc="+v:"")}var S=new Image,v=0,p=g+"?"+I.default.stringify(A);return S.addEventListener("error",function(){v>3||D.default.setTimeout(function(){v++,L()},5e3*v)}),L(),S},c.default=_},function(b,c,R){"use strict";function y(){function x(p,s){var e=s.request_start,i=s.request_response_start,t=s.request_response_end,r=s.request_bytes_loaded;A++;var a=void 0,n=void 0;if(i?(a=i-e,n=t-i):n=t-e,n>0&&r>0){var h=r/n*8e3;L++,_+=r,g+=n,this.data.view_min_request_throughput=Math.min(this.data.view_min_request_throughput||1/0,h),this.data.view_average_request_throughput=_/g*8e3,this.data.view_request_count=A,a>0&&(D+=a,this.data.view_max_request_latency=Math.max(this.data.view_max_request_latency||0,a),this.data.view_average_request_latency=D/L)}}function I(p,s){A++,S++,this.data.view_request_count=A,this.data.view_request_failed_count=S}function T(p,s){A++,v++,this.data.view_request_count=A,this.data.view_request_canceled_count=v}var D=0,_=0,g=0,A=0,L=0,S=0,v=0;this.on("requestcompleted",x),this.on("requestfailed",I),this.on("requestcanceled",T)}Object.defineProperty(c,"__esModule",{value:!0}),c.default=y},function(b,c,R){"use strict";function y(L,S,v){var p=(0,_.findMediaElement)(S),s=I(p,3),e=s[0],i=s[1],t=s[2],r=L.log,a=L.utils.getComputedStyle,n=L.utils.secondsToMs,h={automaticErrorTracking:!0};if(!e)return r.error("No element was found with the `"+i+"` query selector.");if(t!=="video"&&t!=="audio")return r.error("The element of `"+i+"` was not a media element.");v=(0,D.default)(h,v),v.data=(0,D.default)({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:"4.8.0"},v.data),v.getPlayheadTime=function(){return n(e.currentTime)},v.getStateData=function(){var u=this.hlsjs&&this.hlsjs.url,f=this.dashjs&&x(this.dashjs.getSource==="function")&&this.dashjs.getSource();return{player_is_paused:e.paused,player_playhead_time:n(e.currentTime),player_width:parseInt(a(e,"width")),player_height:parseInt(a(e,"height")),player_autoplay_on:e.autoplay,player_preload_on:e.preload,video_poster_url:e.poster,video_source_url:u||f||e.currentSrc,video_source_duration:n(e.duration),video_source_height:e.videoHeight,video_source_width:e.videoWidth}},e.mux=e.mux||{},e.mux.deleted=!1,e.mux.emit=function(u,f){L.emit(i,u,f)};var d=function(){r.error("The monitor for this video element has already been destroyed.")};e.mux.destroy=function(){Object.keys(e.mux.listeners).forEach(function(u){e.removeEventListener(u,e.mux.listeners[u],!1)}),delete e.mux.listeners,e.mux.destroy=d,e.mux.swapElement=d,e.mux.emit=d,e.mux.addHLSJS=d,e.mux.addDashJS=d,e.mux.removeHLSJS=d,e.mux.removeDashJS=d,e.mux.deleted=!0,L.emit(i,"destroy")},e.mux.swapElement=function(u){var f=(0,_.findMediaElement)(u),l=I(f,3),o=l[0],E=l[1],m=l[2];return o?m!=="video"&&m!=="audio"?L.log.error("The element of `"+E+"` was not a media element."):(o.muxId=e.muxId,delete e.muxId,o.mux=o.mux||{},o.mux.listeners=(0,D.default)({},e.mux.listeners),delete e.mux.listeners,Object.keys(o.mux.listeners).forEach(function(O){e.removeEventListener(O,o.mux.listeners[O],!1),o.addEventListener(O,o.mux.listeners[O],!1)}),o.mux.swapElement=e.mux.swapElement,o.mux.destroy=e.mux.destroy,delete e.mux,void(e=o)):L.log.error("No element was found with the `"+E+"` query selector.")},e.mux.addHLSJS=function(u){L.addHLSJS(i,u)},e.mux.addDashJS=function(u){L.addDashJS(i,u)},e.mux.removeHLSJS=function(){L.removeHLSJS(i)},e.mux.removeDashJS=function(){L.removeDashJS(i)},L.init(i,v),L.emit(i,"playerready"),e.paused||(L.emit(i,"play"),e.readyState>2&&L.emit(i,"playing")),e.mux.listeners={},g.forEach(function(u){(u!=="error"||v.automaticErrorTracking)&&(e.mux.listeners[u]=function(){var f={};if(u==="error"){if(!e.error||e.error.code===1)return;f.player_error_code=e.error.code,f.player_error_message=A[e.error.code]||e.error.message}L.emit(i,u,f)},e.addEventListener(u,e.mux.listeners[u],!1))})}Object.defineProperty(c,"__esModule",{value:!0});var x=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(L){return typeof L}:function(L){return L&&typeof Symbol=="function"&&L.constructor===Symbol&&L!==Symbol.prototype?"symbol":typeof L},I=function(){function L(S,v){var p=[],s=!0,e=!1,i=void 0;try{for(var t,r=S[Symbol.iterator]();!(s=(t=r.next()).done)&&(p.push(t.value),!v||p.length!==v);s=!0);}catch(a){e=!0,i=a}finally{try{!s&&r.return&&r.return()}finally{if(e)throw i}}return p}return function(S,v){if(Array.isArray(S))return S;if(Symbol.iterator in Object(S))return L(S,v);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();c.default=y;var T=R(1),D=function(L){return L&&L.__esModule?L:{default:L}}(T),_=R(11),g=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],A={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"}},function(b,c,R){"use strict";function y(h){return h&&h.__esModule?h:{default:h}}Object.defineProperty(c,"__esModule",{value:!0});var x=R(60),I=y(x),T=R(3),D=y(T),_=R(61),g=y(_),A=R(62),L=y(A),S=R(1),v=y(S),p=R(7),s=y(p),e=R(5),i=R(2),t=y(i),r=R(63),a=y(r),n={};n.safeCall=I.default,n.safeIncrement=D.default,n.getComputedStyle=g.default,n.secondsToMs=L.default,n.assign=v.default,n.headersStringToObject=s.default,n.extractHostnameAndDomain=e.extractHostnameAndDomain,n.extractHostname=e.extractHostname,n.now=t.default.now,n.manifestParser=a.default,c.default=n},function(b,c,R){"use strict";function y(T,D,_,g){var A=g;if(T&&typeof T[D]=="function")try{A=T[D].apply(T,_)}catch(L){I.default.info("safeCall error",L)}return A}Object.defineProperty(c,"__esModule",{value:!0}),c.default=y;var x=R(4),I=function(T){return T&&T.__esModule?T:{default:T}}(x)},function(b,c,R){"use strict";function y(D,_){if(D&&_&&I.default&&typeof I.default.getComputedStyle=="function"){var g=void 0;return T&&T.has(D)&&(g=T.get(D)),g||(g=I.default.getComputedStyle(D,null),T&&T.set(D,g)),g.getPropertyValue(_)}}Object.defineProperty(c,"__esModule",{value:!0}),c.default=y;var x=R(0),I=function(D){return D&&D.__esModule?D:{default:D}}(x),T=void 0;I.default&&I.default.WeakMap&&(T=new WeakMap)},function(b,c,R){"use strict";function y(x){return Math.floor(1e3*x)}Object.defineProperty(c,"__esModule",{value:!0}),c.default=y},function(b,c,R){"use strict";function y(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(c,"__esModule",{value:!0});var x=R(1),I=y(x),T=R(14),D=y(T),_={TARGET_DURATION:"#EXT-X-TARGETDURATION",PART_INF:"#EXT-X-PART-INF",SERVER_CONTROL:"#EXT-X-SERVER-CONTROL",INF:"#EXTINF",PROGRAM_DATE_TIME:"#EXT-X-PROGRAM-DATE-TIME",VERSION:"#EXT-X-VERSION",SESSION_DATA:"#EXT-X-SESSION-DATA"},g=function(t){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(t),this.manifest};g.prototype.process=function(t){var r=void 0;for(this.buffer+=t,r=this.buffer.indexOf(`
|
|
5
|
+
`);r>-1;r=this.buffer.indexOf(`
|
|
6
|
+
`))this.processLine(this.buffer.substring(0,r)),this.buffer=this.buffer.substring(r+1)},g.prototype.processLine=function(t){var r=t.indexOf(":"),a=e(t,r),n=a[0],h=a.length===2?S(a[1]):void 0;if(n[0]!=="#")this.currentUri.uri=n,this.manifest.segments.push(this.currentUri),!this.manifest.targetDuration||"duration"in this.currentUri||(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(n){case _.TARGET_DURATION:if(!isFinite(h)||h<0)return;this.manifest.targetDuration=h,this.setHoldBack();break;case _.PART_INF:A(this.manifest,a),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case _.SERVER_CONTROL:A(this.manifest,a),this.setHoldBack();break;case _.INF:h===0?this.currentUri.duration=.01:h>0&&(this.currentUri.duration=h);break;case _.PROGRAM_DATE_TIME:var d=h,u=new Date(d);this.manifest.dateTimeString||(this.manifest.dateTimeString=d,this.manifest.dateTimeObject=u),this.currentUri.dateTimeString=d,this.currentUri.dateTimeObject=u;break;case _.VERSION:A(this.manifest,a);break;case _.SESSION_DATA:var f=i(a[1]),l=(0,D.default)(f);(0,I.default)(this.manifest.sessionData,l)}},g.prototype.setHoldBack=function(){var t=this.manifest,r=t.serverControl,a=t.targetDuration,n=t.partTargetDuration;if(r){var h="holdBack",d="partHoldBack",u=a&&3*a,f=n&&2*n;a&&!r.hasOwnProperty(h)&&(r[h]=u),u&&r[h]<u&&(r[h]=u),n&&!r.hasOwnProperty(d)&&(r[d]=3*n),n&&r[d]<f&&(r[d]=f)}};var A=function(t,r){var a=L(r[0].replace("#EXT-X-","")),n=void 0;s(r[1])?(n={},n=(0,I.default)(p(r[1]),n)):n=S(r[1]),t[a]=n},L=function(t){return t.toLowerCase().replace(/-(\w)/g,function(r){return r[1].toUpperCase()})},S=function(t){if(t.toLowerCase()==="yes"||t.toLowerCase()==="no")return t.toLowerCase()==="yes";var r=t.indexOf(":")!==-1?t:parseFloat(t);return isNaN(r)?t:r},v=function(t){var r={},a=t.split("=");return a.length>1&&(r[L(a[0])]=S(a[1])),r},p=function(t){for(var r=t.split(","),a={},n=0;r.length>n;n++){var h=r[n],d=v(h);a=(0,I.default)(d,a)}return a},s=function(t){return t.indexOf("=")>-1},e=function(t,r){return r===-1?[t]:[t.substring(0,r),t.substring(r+1)]},i=function(t){var r={};if(t){var a=t.search(",");return[t.slice(0,a),t.slice(a+1)].forEach(function(n,h){for(var d=n.replace(/['"]+/g,"").split("="),u=0;u<d.length;u++)d[u]==="DATA-ID"&&(r["DATA-ID"]=d[1-u]),d[u]==="VALUE"&&(r.VALUE=d[1-u])}),{data:r}}};c.default=g},function(b,c,R){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var y={PLAYER_READY:"playerready",VIEW_INIT:"viewinit",VIDEO_CHANGE:"videochange",PLAY:"play",PAUSE:"pause",PLAYING:"playing",TIME_UPDATE:"timeupdate",SEEKING:"seeking",SEEKED:"seeked",REBUFFER_START:"rebufferstart",REBUFFER_END:"rebufferend",ERROR:"error",ENDED:"ended",RENDITION_CHANGE:"renditionchange",ORIENTATION_CHANGE:"orientationchange",AD_REQUEST:"adrequest",AD_RESPONSE:"adresponse",AD_BREAK_START:"adbreakstart",AD_PLAY:"adplay",AD_PLAYING:"adplaying",AD_PAUSE:"adpause",AD_FIRST_QUARTILE:"adfirstquartile",AD_MID_POINT:"admidpoint",AD_THIRD_QUARTILE:"adthirdquartile",AD_ENDED:"adended",AD_BREAK_END:"adbreakend",AD_ERROR:"aderror",REQUEST_COMPLETED:"requestcompleted",REQUEST_FAILED:"requestfailed",REQUEST_CANCELLED:"requestcanceled"};c.default=y}])})})()});var Qe=pt((je,nt)=>{typeof window!="undefined"&&function(b,c){typeof je=="object"&&typeof nt=="object"?nt.exports=c():typeof define=="function"&&define.amd?define([],c):typeof je=="object"?je.Hls=c():b.Hls=c()}(je,function(){return function(k){var b={};function c(R){if(b[R])return b[R].exports;var y=b[R]={i:R,l:!1,exports:{}};return k[R].call(y.exports,y,y.exports,c),y.l=!0,y.exports}return c.m=k,c.c=b,c.d=function(R,y,x){c.o(R,y)||Object.defineProperty(R,y,{enumerable:!0,get:x})},c.r=function(R){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(R,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(R,"__esModule",{value:!0})},c.t=function(R,y){if(y&1&&(R=c(R)),y&8||y&4&&typeof R=="object"&&R&&R.__esModule)return R;var x=Object.create(null);if(c.r(x),Object.defineProperty(x,"default",{enumerable:!0,value:R}),y&2&&typeof R!="string")for(var I in R)c.d(x,I,function(T){return R[T]}.bind(null,I));return x},c.n=function(R){var y=R&&R.__esModule?function(){return R.default}:function(){return R};return c.d(y,"a",y),y},c.o=function(R,y){return Object.prototype.hasOwnProperty.call(R,y)},c.p="/dist/",c(c.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(k,b,c){"use strict";var R=Object.prototype.hasOwnProperty,y="~";function x(){}Object.create&&(x.prototype=Object.create(null),new x().__proto__||(y=!1));function I(g,A,L){this.fn=g,this.context=A,this.once=L||!1}function T(g,A,L,S,v){if(typeof L!="function")throw new TypeError("The listener must be a function");var p=new I(L,S||g,v),s=y?y+A:A;return g._events[s]?g._events[s].fn?g._events[s]=[g._events[s],p]:g._events[s].push(p):(g._events[s]=p,g._eventsCount++),g}function D(g,A){--g._eventsCount==0?g._events=new x:delete g._events[A]}function _(){this._events=new x,this._eventsCount=0}_.prototype.eventNames=function(){var A=[],L,S;if(this._eventsCount===0)return A;for(S in L=this._events)R.call(L,S)&&A.push(y?S.slice(1):S);return Object.getOwnPropertySymbols?A.concat(Object.getOwnPropertySymbols(L)):A},_.prototype.listeners=function(A){var L=y?y+A:A,S=this._events[L];if(!S)return[];if(S.fn)return[S.fn];for(var v=0,p=S.length,s=new Array(p);v<p;v++)s[v]=S[v].fn;return s},_.prototype.listenerCount=function(A){var L=y?y+A:A,S=this._events[L];return S?S.fn?1:S.length:0},_.prototype.emit=function(A,L,S,v,p,s){var e=y?y+A:A;if(!this._events[e])return!1;var i=this._events[e],t=arguments.length,r,a;if(i.fn){switch(i.once&&this.removeListener(A,i.fn,void 0,!0),t){case 1:return i.fn.call(i.context),!0;case 2:return i.fn.call(i.context,L),!0;case 3:return i.fn.call(i.context,L,S),!0;case 4:return i.fn.call(i.context,L,S,v),!0;case 5:return i.fn.call(i.context,L,S,v,p),!0;case 6:return i.fn.call(i.context,L,S,v,p,s),!0}for(a=1,r=new Array(t-1);a<t;a++)r[a-1]=arguments[a];i.fn.apply(i.context,r)}else{var n=i.length,h;for(a=0;a<n;a++)switch(i[a].once&&this.removeListener(A,i[a].fn,void 0,!0),t){case 1:i[a].fn.call(i[a].context);break;case 2:i[a].fn.call(i[a].context,L);break;case 3:i[a].fn.call(i[a].context,L,S);break;case 4:i[a].fn.call(i[a].context,L,S,v);break;default:if(!r)for(h=1,r=new Array(t-1);h<t;h++)r[h-1]=arguments[h];i[a].fn.apply(i[a].context,r)}}return!0},_.prototype.on=function(A,L,S){return T(this,A,L,S,!1)},_.prototype.once=function(A,L,S){return T(this,A,L,S,!0)},_.prototype.removeListener=function(A,L,S,v){var p=y?y+A:A;if(!this._events[p])return this;if(!L)return D(this,p),this;var s=this._events[p];if(s.fn)s.fn===L&&(!v||s.once)&&(!S||s.context===S)&&D(this,p);else{for(var e=0,i=[],t=s.length;e<t;e++)(s[e].fn!==L||v&&!s[e].once||S&&s[e].context!==S)&&i.push(s[e]);i.length?this._events[p]=i.length===1?i[0]:i:D(this,p)}return this},_.prototype.removeAllListeners=function(A){var L;return A?(L=y?y+A:A,this._events[L]&&D(this,L)):(this._events=new x,this._eventsCount=0),this},_.prototype.off=_.prototype.removeListener,_.prototype.addListener=_.prototype.on,_.prefixed=y,_.EventEmitter=_,k.exports=_},"./node_modules/url-toolkit/src/url-toolkit.js":function(k,b,c){(function(R){var y=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,x=/^([^\/?#]*)([^]*)$/,I=/(?:\/|^)\.(?=\/)/g,T=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,D={buildAbsoluteURL:function(_,g,A){if(A=A||{},_=_.trim(),g=g.trim(),!g){if(!A.alwaysNormalize)return _;var L=D.parseURL(_);if(!L)throw new Error("Error trying to parse base URL.");return L.path=D.normalizePath(L.path),D.buildURLFromParts(L)}var S=D.parseURL(g);if(!S)throw new Error("Error trying to parse relative URL.");if(S.scheme)return A.alwaysNormalize?(S.path=D.normalizePath(S.path),D.buildURLFromParts(S)):g;var v=D.parseURL(_);if(!v)throw new Error("Error trying to parse base URL.");if(!v.netLoc&&v.path&&v.path[0]!=="/"){var p=x.exec(v.path);v.netLoc=p[1],v.path=p[2]}v.netLoc&&!v.path&&(v.path="/");var s={scheme:v.scheme,netLoc:S.netLoc,path:null,params:S.params,query:S.query,fragment:S.fragment};if(!S.netLoc&&(s.netLoc=v.netLoc,S.path[0]!=="/"))if(!S.path)s.path=v.path,S.params||(s.params=v.params,S.query||(s.query=v.query));else{var e=v.path,i=e.substring(0,e.lastIndexOf("/")+1)+S.path;s.path=D.normalizePath(i)}return s.path===null&&(s.path=A.alwaysNormalize?D.normalizePath(S.path):S.path),D.buildURLFromParts(s)},parseURL:function(_){var g=y.exec(_);return g?{scheme:g[1]||"",netLoc:g[2]||"",path:g[3]||"",params:g[4]||"",query:g[5]||"",fragment:g[6]||""}:null},normalizePath:function(_){for(_=_.split("").reverse().join("").replace(I,"");_.length!==(_=_.replace(T,"")).length;);return _.split("").reverse().join("")},buildURLFromParts:function(_){return _.scheme+_.netLoc+_.path+_.params+_.query+_.fragment}};k.exports=D})(this)},"./node_modules/webworkify-webpack/index.js":function(k,b,c){function R(A){var L={};function S(p){if(L[p])return L[p].exports;var s=L[p]={i:p,l:!1,exports:{}};return A[p].call(s.exports,s,s.exports,S),s.l=!0,s.exports}S.m=A,S.c=L,S.i=function(p){return p},S.d=function(p,s,e){S.o(p,s)||Object.defineProperty(p,s,{configurable:!1,enumerable:!0,get:e})},S.r=function(p){Object.defineProperty(p,"__esModule",{value:!0})},S.n=function(p){var s=p&&p.__esModule?function(){return p.default}:function(){return p};return S.d(s,"a",s),s},S.o=function(p,s){return Object.prototype.hasOwnProperty.call(p,s)},S.p="/",S.oe=function(p){throw console.error(p),p};var v=S(S.s=ENTRY_MODULE);return v.default||v}var y="[\\.|\\-|\\+|\\w|/|@]+",x="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+y+").*?\\)";function I(A){return(A+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function T(A){return!isNaN(1*A)}function D(A,L,S){var v={};v[S]=[];var p=L.toString(),s=p.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!s)return v;for(var e=s[1],i=new RegExp("(\\\\n|\\W)"+I(e)+x,"g"),t;t=i.exec(p);)t[3]!=="dll-reference"&&v[S].push(t[3]);for(i=new RegExp("\\("+I(e)+'\\("(dll-reference\\s('+y+'))"\\)\\)'+x,"g");t=i.exec(p);)A[t[2]]||(v[S].push(t[1]),A[t[2]]=c(t[1]).m),v[t[2]]=v[t[2]]||[],v[t[2]].push(t[4]);for(var r=Object.keys(v),a=0;a<r.length;a++)for(var n=0;n<v[r[a]].length;n++)T(v[r[a]][n])&&(v[r[a]][n]=1*v[r[a]][n]);return v}function _(A){var L=Object.keys(A);return L.reduce(function(S,v){return S||A[v].length>0},!1)}function g(A,L){for(var S={main:[L]},v={main:[]},p={main:{}};_(S);)for(var s=Object.keys(S),e=0;e<s.length;e++){var i=s[e],t=S[i],r=t.pop();if(p[i]=p[i]||{},!(p[i][r]||!A[i][r])){p[i][r]=!0,v[i]=v[i]||[],v[i].push(r);for(var a=D(A,A[i][r],i),n=Object.keys(a),h=0;h<n.length;h++)S[n[h]]=S[n[h]]||[],S[n[h]]=S[n[h]].concat(a[n[h]])}}return v}k.exports=function(A,L){L=L||{};var S={main:c.m},v=L.all?{main:Object.keys(S.main)}:g(S,A),p="";Object.keys(v).filter(function(r){return r!=="main"}).forEach(function(r){for(var a=0;v[r][a];)a++;v[r].push(a),S[r][a]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",p=p+"var "+r+" = ("+R.toString().replace("ENTRY_MODULE",JSON.stringify(a))+")({"+v[r].map(function(n){return""+JSON.stringify(n)+": "+S[r][n].toString()}).join(",")+`});
|
|
7
|
+
`}),p=p+"new (("+R.toString().replace("ENTRY_MODULE",JSON.stringify(A))+")({"+v.main.map(function(r){return""+JSON.stringify(r)+": "+S.main[r].toString()}).join(",")+"}))(self);";var s=new window.Blob([p],{type:"text/javascript"});if(L.bare)return s;var e=window.URL||window.webkitURL||window.mozURL||window.msURL,i=e.createObjectURL(s),t=new window.Worker(i);return t.objectURL=i,t}},"./src/config.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"hlsDefaultConfig",function(){return h}),c.d(b,"mergeConfig",function(){return u}),c.d(b,"enableStreamingMode",function(){return f});var R=c("./src/controller/abr-controller.ts"),y=c("./src/controller/audio-stream-controller.ts"),x=c("./src/controller/audio-track-controller.ts"),I=c("./src/controller/subtitle-stream-controller.ts"),T=c("./src/controller/subtitle-track-controller.ts"),D=c("./src/controller/buffer-controller.ts"),_=c("./src/controller/timeline-controller.ts"),g=c("./src/controller/cap-level-controller.ts"),A=c("./src/controller/fps-controller.ts"),L=c("./src/controller/eme-controller.ts"),S=c("./src/controller/cmcd-controller.ts"),v=c("./src/utils/xhr-loader.ts"),p=c("./src/utils/fetch-loader.ts"),s=c("./src/utils/cues.ts"),e=c("./src/utils/mediakeys-helper.ts"),i=c("./src/utils/logger.ts");function t(){return t=Object.assign||function(l){for(var o=1;o<arguments.length;o++){var E=arguments[o];for(var m in E)Object.prototype.hasOwnProperty.call(E,m)&&(l[m]=E[m])}return l},t.apply(this,arguments)}function r(l,o){var E=Object.keys(l);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(l);o&&(m=m.filter(function(O){return Object.getOwnPropertyDescriptor(l,O).enumerable})),E.push.apply(E,m)}return E}function a(l){for(var o=1;o<arguments.length;o++){var E=arguments[o]!=null?arguments[o]:{};o%2?r(Object(E),!0).forEach(function(m){n(l,m,E[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(E)):r(Object(E)).forEach(function(m){Object.defineProperty(l,m,Object.getOwnPropertyDescriptor(E,m))})}return l}function n(l,o,E){return o in l?Object.defineProperty(l,o,{value:E,enumerable:!0,configurable:!0,writable:!0}):l[o]=E,l}var h=a(a({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:v.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:R.default,bufferController:D.default,capLevelController:g.default,fpsController:A.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:e.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},d()),{},{subtitleStreamController:I.SubtitleStreamController,subtitleTrackController:T.default,timelineController:_.TimelineController,audioStreamController:y.default,audioTrackController:x.default,emeController:L.default,cmcdController:S.default});function d(){return{cueHandler:s.default,enableCEA708Captions:!0,enableWebVTT:!0,enableIMSC1:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function u(l,o){if((o.liveSyncDurationCount||o.liveMaxLatencyDurationCount)&&(o.liveSyncDuration||o.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(o.liveMaxLatencyDurationCount!==void 0&&(o.liveSyncDurationCount===void 0||o.liveMaxLatencyDurationCount<=o.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(o.liveMaxLatencyDuration!==void 0&&(o.liveSyncDuration===void 0||o.liveMaxLatencyDuration<=o.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return t({},l,o)}function f(l){var o=l.loader;if(o!==p.default&&o!==v.default)i.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),l.progressive=!1;else{var E=Object(p.fetchSupported)();E&&(l.loader=p.default,l.progressive=!0,l.enableSoftwareAES=!0,i.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(k,b,c){"use strict";c.r(b);var R=c("./src/polyfills/number.ts"),y=c("./src/utils/ewma-bandwidth-estimator.ts"),x=c("./src/events.ts"),I=c("./src/utils/buffer-helper.ts"),T=c("./src/errors.ts"),D=c("./src/types/loader.ts"),_=c("./src/utils/logger.ts");function g(S,v){for(var p=0;p<v.length;p++){var s=v[p];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(S,s.key,s)}}function A(S,v,p){return v&&g(S.prototype,v),p&&g(S,p),S}var L=function(){function S(p){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=p;var s=p.config;this.bwEstimator=new y.default(s.abrEwmaSlowVoD,s.abrEwmaFastVoD,s.abrEwmaDefaultEstimate),this.registerListeners()}var v=S.prototype;return v.registerListeners=function(){var s=this.hls;s.on(x.Events.FRAG_LOADING,this.onFragLoading,this),s.on(x.Events.FRAG_LOADED,this.onFragLoaded,this),s.on(x.Events.FRAG_BUFFERED,this.onFragBuffered,this),s.on(x.Events.LEVEL_LOADED,this.onLevelLoaded,this),s.on(x.Events.ERROR,this.onError,this)},v.unregisterListeners=function(){var s=this.hls;s.off(x.Events.FRAG_LOADING,this.onFragLoading,this),s.off(x.Events.FRAG_LOADED,this.onFragLoaded,this),s.off(x.Events.FRAG_BUFFERED,this.onFragBuffered,this),s.off(x.Events.LEVEL_LOADED,this.onLevelLoaded,this),s.off(x.Events.ERROR,this.onError,this)},v.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},v.onFragLoading=function(s,e){var i=e.frag;if(i.type===D.PlaylistLevelType.MAIN&&!this.timer){var t;this.fragCurrent=i,this.partCurrent=(t=e.part)!=null?t:null,this.timer=self.setInterval(this.onCheck,100)}},v.onLevelLoaded=function(s,e){var i=this.hls.config;e.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD)},v._abandonRulesCheck=function(){var s=this.fragCurrent,e=this.partCurrent,i=this.hls,t=i.autoLevelEnabled,r=i.config,a=i.media;if(!(!s||!a)){var n=e?e.stats:s.stats,h=e?e.duration:s.duration;if(n.aborted){_.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!(!t||a.paused||!a.playbackRate||!a.readyState)){var d=performance.now()-n.loading.start,u=Math.abs(a.playbackRate);if(!(d<=500*h/u)){var f=i.levels,l=i.minAutoLevel,o=f[s.level],E=n.total||Math.max(n.loaded,Math.round(h*o.maxBitrate/8)),m=Math.max(1,n.bwEstimate?n.bwEstimate/8:n.loaded*1e3/d),O=(E-n.loaded)/m,P=a.currentTime,M=(I.BufferHelper.bufferInfo(a,P,r.maxBufferHole).end-P)/u;if(!(M>=2*h/u||O<=M)){var F=Number.POSITIVE_INFINITY,B;for(B=s.level-1;B>l;B--){var C=f[B].maxBitrate;if(F=h*C/(8*.8*m),F<M)break}if(!(F>=O)){var U=this.bwEstimator.getEstimate();_.logger.warn("Fragment "+s.sn+(e?" part "+e.index:"")+" of level "+s.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+B+`
|
|
8
|
+
Current BW estimate: `+(Object(R.isFiniteNumber)(U)?(U/1024).toFixed(3):"Unknown")+` Kb/s
|
|
9
|
+
Estimated load time for current fragment: `+O.toFixed(3)+` s
|
|
10
|
+
Estimated load time for the next fragment: `+F.toFixed(3)+` s
|
|
11
|
+
Time to underbuffer: `+M.toFixed(3)+" s"),i.nextLoadLevel=B,this.bwEstimator.sample(d,n.loaded),this.clearTimer(),s.loader&&(this.fragCurrent=this.partCurrent=null,s.loader.abort()),i.trigger(x.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:s,part:e,stats:n})}}}}}},v.onFragLoaded=function(s,e){var i=e.frag,t=e.part;if(i.type===D.PlaylistLevelType.MAIN&&Object(R.isFiniteNumber)(i.sn)){var r=t?t.stats:i.stats,a=t?t.duration:i.duration;if(this.clearTimer(),this.lastLoadedFragLevel=i.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var n=this.hls.levels[i.level],h=(n.loaded?n.loaded.bytes:0)+r.loaded,d=(n.loaded?n.loaded.duration:0)+a;n.loaded={bytes:h,duration:d},n.realBitrate=Math.round(8*h/d)}if(i.bitrateTest){var u={stats:r,frag:i,part:t,id:i.type};this.onFragBuffered(x.Events.FRAG_BUFFERED,u),i.bitrateTest=!1}}},v.onFragBuffered=function(s,e){var i=e.frag,t=e.part,r=t?t.stats:i.stats;if(!r.aborted&&!(i.type!==D.PlaylistLevelType.MAIN||i.sn==="initSegment")){var a=r.parsing.end-r.loading.start;this.bwEstimator.sample(a,r.loaded),r.bwEstimate=this.bwEstimator.getEstimate(),i.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}},v.onError=function(s,e){switch(e.details){case T.ErrorDetails.FRAG_LOAD_ERROR:case T.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},v.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},v.getNextABRAutoLevel=function(){var s=this.fragCurrent,e=this.partCurrent,i=this.hls,t=i.maxAutoLevel,r=i.config,a=i.minAutoLevel,n=i.media,h=e?e.duration:s?s.duration:0,d=n?n.currentTime:0,u=n&&n.playbackRate!==0?Math.abs(n.playbackRate):1,f=this.bwEstimator?this.bwEstimator.getEstimate():r.abrEwmaDefaultEstimate,l=(I.BufferHelper.bufferInfo(n,d,r.maxBufferHole).end-d)/u,o=this.findBestLevel(f,a,t,l,r.abrBandWidthFactor,r.abrBandWidthUpFactor);if(o>=0)return o;_.logger.trace((l?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var E=h?Math.min(h,r.maxStarvationDelay):r.maxStarvationDelay,m=r.abrBandWidthFactor,O=r.abrBandWidthUpFactor;if(!l){var P=this.bitrateTestDelay;if(P){var M=h?Math.min(h,r.maxLoadingDelay):r.maxLoadingDelay;E=M-P,_.logger.trace("bitrate test took "+Math.round(1e3*P)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*E)+" ms"),m=O=1}}return o=this.findBestLevel(f,a,t,l+E,m,O),Math.max(o,0)},v.findBestLevel=function(s,e,i,t,r,a){for(var n,h=this.fragCurrent,d=this.partCurrent,u=this.lastLoadedFragLevel,f=this.hls.levels,l=f[u],o=!!(l!=null&&(n=l.details)!==null&&n!==void 0&&n.live),E=l==null?void 0:l.codecSet,m=d?d.duration:h?h.duration:0,O=i;O>=e;O--){var P=f[O];if(!(!P||E&&P.codecSet!==E)){var M=P.details,F=(d?M==null?void 0:M.partTarget:M==null?void 0:M.averagetargetduration)||m,B=void 0;O<=u?B=r*s:B=a*s;var C=f[O].maxBitrate,U=C*F/B;if(_.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+O+"/"+Math.round(B)+"/"+C+"/"+F+"/"+t+"/"+U),B>C&&(!U||o&&!this.bitrateTestDelay||U<t))return O}}return-1},A(S,[{key:"nextAutoLevel",get:function(){var s=this._nextAutoLevel,e=this.bwEstimator;if(s!==-1&&(!e||!e.canEstimate()))return s;var i=this.getNextABRAutoLevel();return s!==-1&&(i=Math.min(s,i)),i},set:function(s){this._nextAutoLevel=s}}]),S}();b.default=L},"./src/controller/audio-stream-controller.ts":function(k,b,c){"use strict";c.r(b);var R=c("./src/polyfills/number.ts"),y=c("./src/controller/base-stream-controller.ts"),x=c("./src/events.ts"),I=c("./src/utils/buffer-helper.ts"),T=c("./src/controller/fragment-tracker.ts"),D=c("./src/types/level.ts"),_=c("./src/types/loader.ts"),g=c("./src/loader/fragment.ts"),A=c("./src/demux/chunk-cache.ts"),L=c("./src/demux/transmuxer-interface.ts"),S=c("./src/types/transmuxer.ts"),v=c("./src/controller/fragment-finders.ts"),p=c("./src/utils/discontinuities.ts"),s=c("./src/errors.ts"),e=c("./src/utils/logger.ts");function i(){return i=Object.assign||function(h){for(var d=1;d<arguments.length;d++){var u=arguments[d];for(var f in u)Object.prototype.hasOwnProperty.call(u,f)&&(h[f]=u[f])}return h},i.apply(this,arguments)}function t(h,d){h.prototype=Object.create(d.prototype),h.prototype.constructor=h,r(h,d)}function r(h,d){return r=Object.setPrototypeOf||function(f,l){return f.__proto__=l,f},r(h,d)}var a=100,n=function(h){t(d,h);function d(f,l){var o;return o=h.call(this,f,l,"[audio-stream-controller]")||this,o.videoBuffer=null,o.videoTrackCC=-1,o.waitingVideoCC=-1,o.audioSwitch=!1,o.trackId=-1,o.waitingData=null,o.mainDetails=null,o.bufferFlushed=!1,o._registerListeners(),o}var u=d.prototype;return u.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},u._registerListeners=function(){var l=this.hls;l.on(x.Events.MEDIA_ATTACHED,this.onMediaAttached,this),l.on(x.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.on(x.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.on(x.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.on(x.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),l.on(x.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),l.on(x.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),l.on(x.Events.ERROR,this.onError,this),l.on(x.Events.BUFFER_RESET,this.onBufferReset,this),l.on(x.Events.BUFFER_CREATED,this.onBufferCreated,this),l.on(x.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),l.on(x.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),l.on(x.Events.FRAG_BUFFERED,this.onFragBuffered,this)},u._unregisterListeners=function(){var l=this.hls;l.off(x.Events.MEDIA_ATTACHED,this.onMediaAttached,this),l.off(x.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.off(x.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.off(x.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.off(x.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),l.off(x.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),l.off(x.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),l.off(x.Events.ERROR,this.onError,this),l.off(x.Events.BUFFER_RESET,this.onBufferReset,this),l.off(x.Events.BUFFER_CREATED,this.onBufferCreated,this),l.off(x.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),l.off(x.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),l.off(x.Events.FRAG_BUFFERED,this.onFragBuffered,this)},u.onInitPtsFound=function(l,o){var E=o.frag,m=o.id,O=o.initPTS;if(m==="main"){var P=E.cc;this.initPTS[E.cc]=O,this.log("InitPTS for cc: "+P+" found from main: "+O),this.videoTrackCC=P,this.state===y.State.WAITING_INIT_PTS&&this.tick()}},u.startLoad=function(l){if(!this.levels){this.startPosition=l,this.state=y.State.STOPPED;return}var o=this.lastCurrentTime;this.stopLoad(),this.setInterval(a),this.fragLoadError=0,o>0&&l===-1?(this.log("Override startPosition with lastCurrentTime @"+o.toFixed(3)),this.state=y.State.IDLE):(this.loadedmetadata=!1,this.state=y.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=l,this.tick()},u.doTick=function(){switch(this.state){case y.State.IDLE:this.doTickIdle();break;case y.State.WAITING_TRACK:{var l,o=this.levels,E=this.trackId,m=o==null||(l=o[E])===null||l===void 0?void 0:l.details;if(m){if(this.waitForCdnTuneIn(m))break;this.state=y.State.WAITING_INIT_PTS}break}case y.State.FRAG_LOADING_WAITING_RETRY:{var O,P=performance.now(),M=this.retryDate;(!M||P>=M||(O=this.media)!==null&&O!==void 0&&O.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=y.State.IDLE);break}case y.State.WAITING_INIT_PTS:{var F=this.waitingData;if(F){var B=F.frag,C=F.part,U=F.cache,w=F.complete;if(this.initPTS[B.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=y.State.FRAG_LOADING;var N=U.flush(),j={frag:B,part:C,payload:N,networkDetails:null};this._handleFragmentLoadProgress(j),w&&h.prototype._handleFragmentLoadComplete.call(this,j)}else if(this.videoTrackCC!==this.waitingVideoCC)e.logger.log("Waiting fragment cc ("+B.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var K=this.getLoadPosition(),G=I.BufferHelper.bufferInfo(this.mediaBuffer,K,this.config.maxBufferHole),Y=Object(v.fragmentWithinToleranceTest)(G.end,this.config.maxFragLookUpTolerance,B);Y<0&&(e.logger.log("Waiting fragment cc ("+B.cc+") @ "+B.start+" cancelled because another fragment at "+G.end+" is needed"),this.clearWaitingFragment())}}else this.state=y.State.IDLE}}this.onTickEnd()},u.clearWaitingFragment=function(){var l=this.waitingData;l&&(this.fragmentTracker.removeFragment(l.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=y.State.IDLE)},u.onTickEnd=function(){var l=this.media;if(!(!l||!l.readyState)){var o=this.mediaBuffer?this.mediaBuffer:l,E=o.buffered;!this.loadedmetadata&&E.length&&(this.loadedmetadata=!0),this.lastCurrentTime=l.currentTime}},u.doTickIdle=function(){var l,o,E=this.hls,m=this.levels,O=this.media,P=this.trackId,M=E.config;if(!(!m||!m[P])&&!(!O&&(this.startFragRequested||!M.startFragPrefetch))){var F=m[P],B=F.details;if(!B||B.live&&this.levelLastLoaded!==P||this.waitForCdnTuneIn(B)){this.state=y.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,g.ElementaryStreamTypes.AUDIO,_.PlaylistLevelType.AUDIO));var C=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,_.PlaylistLevelType.AUDIO);if(C!==null){var U=C.len,w=this.getMaxBufferLength(),N=this.audioSwitch;if(!(U>=w&&!N)){if(!N&&this._streamEnded(C,B)){E.trigger(x.Events.BUFFER_EOS,{type:"audio"}),this.state=y.State.ENDED;return}var j=B.fragments,K=j[0].start,G=C.end;if(N){var Y=this.getLoadPosition();G=Y,B.PTSKnown&&Y<K&&(C.end>K||C.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),O.currentTime=K+.05)}var V=this.getNextFragment(G,B);if(!V){this.bufferFlushed=!0;return}((l=V.decryptdata)===null||l===void 0?void 0:l.keyFormat)==="identity"&&!((o=V.decryptdata)!==null&&o!==void 0&&o.key)?this.loadKey(V,B):this.loadFragment(V,B,G)}}}},u.getMaxBufferLength=function(){var l=h.prototype.getMaxBufferLength.call(this),o=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,_.PlaylistLevelType.MAIN);return o===null?l:Math.max(l,o.len)},u.onMediaDetaching=function(){this.videoBuffer=null,h.prototype.onMediaDetaching.call(this)},u.onAudioTracksUpdated=function(l,o){var E=o.audioTracks;this.resetTransmuxer(),this.levels=E.map(function(m){return new D.Level(m)})},u.onAudioTrackSwitching=function(l,o){var E=!!o.url;this.trackId=o.id;var m=this.fragCurrent;m!=null&&m.loader&&m.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),E?this.setInterval(a):this.resetTransmuxer(),E?(this.audioSwitch=!0,this.state=y.State.IDLE):this.state=y.State.STOPPED,this.tick()},u.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},u.onLevelLoaded=function(l,o){this.mainDetails=o.details},u.onAudioTrackLoaded=function(l,o){var E,m=this.levels,O=o.details,P=o.id;if(!m){this.warn("Audio tracks were reset while loading level "+P);return}this.log("Track "+P+" loaded ["+O.startSN+","+O.endSN+"],duration:"+O.totalduration);var M=m[P],F=0;if(O.live||(E=M.details)!==null&&E!==void 0&&E.live){var B=this.mainDetails;if(O.fragments[0]||(O.deltaUpdateFailed=!0),O.deltaUpdateFailed||!B)return;!M.details&&O.hasProgramDateTime&&B.hasProgramDateTime?(Object(p.alignMediaPlaylistByPDT)(O,B),F=O.fragments[0].start):F=this.alignPlaylists(O,M.details)}M.details=O,this.levelLastLoaded=P,!this.startFragRequested&&(this.mainDetails||!O.live)&&this.setStartPosition(M.details,F),this.state===y.State.WAITING_TRACK&&!this.waitForCdnTuneIn(O)&&(this.state=y.State.IDLE),this.tick()},u._handleFragmentLoadProgress=function(l){var o,E=l.frag,m=l.part,O=l.payload,P=this.config,M=this.trackId,F=this.levels;if(!F){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+E.sn+" of level "+E.level+" will not be buffered");return}var B=F[M];console.assert(B,"Audio track is defined on fragment load progress");var C=B.details;console.assert(C,"Audio track details are defined on fragment load progress");var U=P.defaultAudioCodec||B.audioCodec||"mp4a.40.2",w=this.transmuxer;w||(w=this.transmuxer=new L.default(this.hls,_.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var N=this.initPTS[E.cc],j=(o=E.initSegment)===null||o===void 0?void 0:o.data;if(N!==void 0){var K=!1,G=m?m.index:-1,Y=G!==-1,V=new S.ChunkMetadata(E.level,E.sn,E.stats.chunkCount,O.byteLength,G,Y);w.push(O,j,U,"",E,m,C.totalduration,K,V,N)}else{e.logger.log("Unknown video PTS for cc "+E.cc+", waiting for video PTS before demuxing audio frag "+E.sn+" of ["+C.startSN+" ,"+C.endSN+"],track "+M);var Z=this.waitingData=this.waitingData||{frag:E,part:m,cache:new A.default,complete:!1},z=Z.cache;z.push(new Uint8Array(O)),this.waitingVideoCC=this.videoTrackCC,this.state=y.State.WAITING_INIT_PTS}},u._handleFragmentLoadComplete=function(l){if(this.waitingData){this.waitingData.complete=!0;return}h.prototype._handleFragmentLoadComplete.call(this,l)},u.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},u.onBufferCreated=function(l,o){var E=o.tracks.audio;E&&(this.mediaBuffer=E.buffer),o.tracks.video&&(this.videoBuffer=o.tracks.video.buffer)},u.onFragBuffered=function(l,o){var E=o.frag,m=o.part;if(E.type===_.PlaylistLevelType.AUDIO){if(this.fragContextChanged(E)){this.warn("Fragment "+E.sn+(m?" p: "+m.index:"")+" of level "+E.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}E.sn!=="initSegment"&&(this.fragPrevious=E,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(x.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(E,m)}},u.onError=function(l,o){switch(o.details){case s.ErrorDetails.FRAG_LOAD_ERROR:case s.ErrorDetails.FRAG_LOAD_TIMEOUT:case s.ErrorDetails.KEY_LOAD_ERROR:case s.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_.PlaylistLevelType.AUDIO,o);break;case s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==y.State.ERROR&&this.state!==y.State.STOPPED&&(this.state=o.fatal?y.State.ERROR:y.State.IDLE,this.warn(o.details+" while loading frag, switching to "+this.state+" state"));break;case s.ErrorDetails.BUFFER_FULL_ERROR:if(o.parent==="audio"&&(this.state===y.State.PARSING||this.state===y.State.PARSED)){var E=!0,m=this.getFwdBufferInfo(this.mediaBuffer,_.PlaylistLevelType.AUDIO);m&&m.len>.5&&(E=!this.reduceMaxBufferLength(m.len)),E&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,h.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},u.onBufferFlushed=function(l,o){var E=o.type;E===g.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},u._handleTransmuxComplete=function(l){var o,E="audio",m=this.hls,O=l.remuxResult,P=l.chunkMeta,M=this.getCurrentContext(P);if(!M){this.warn("The loading context changed while buffering fragment "+P.sn+" of level "+P.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(P.level);return}var F=M.frag,B=M.part,C=O.audio,U=O.text,w=O.id3,N=O.initSegment;if(!this.fragContextChanged(F)){if(this.state=y.State.PARSING,this.audioSwitch&&C&&this.completeAudioSwitch(),N!=null&&N.tracks&&(this._bufferInitSegment(N.tracks,F,P),m.trigger(x.Events.FRAG_PARSING_INIT_SEGMENT,{frag:F,id:E,tracks:N.tracks})),C){var j=C.startPTS,K=C.endPTS,G=C.startDTS,Y=C.endDTS;B&&(B.elementaryStreams[g.ElementaryStreamTypes.AUDIO]={startPTS:j,endPTS:K,startDTS:G,endDTS:Y}),F.setElementaryStreamInfo(g.ElementaryStreamTypes.AUDIO,j,K,G,Y),this.bufferFragmentData(C,F,B,P)}if(w!=null&&(o=w.samples)!==null&&o!==void 0&&o.length){var V=i({frag:F,id:E},w);m.trigger(x.Events.FRAG_PARSING_METADATA,V)}if(U){var Z=i({frag:F,id:E},U);m.trigger(x.Events.FRAG_PARSING_USERDATA,Z)}}},u._bufferInitSegment=function(l,o,E){if(this.state===y.State.PARSING){l.video&&delete l.video;var m=l.audio;if(!!m){m.levelCodec=m.codec,m.id="audio",this.log("Init audio buffer, container:"+m.container+", codecs[parsed]=["+m.codec+"]"),this.hls.trigger(x.Events.BUFFER_CODECS,l);var O=m.initSegment;if(O!=null&&O.byteLength){var P={type:"audio",frag:o,part:null,chunkMeta:E,parent:o.type,data:O};this.hls.trigger(x.Events.BUFFER_APPENDING,P)}this.tick()}}},u.loadFragment=function(l,o,E){var m=this.fragmentTracker.getState(l);this.fragCurrent=l,(this.audioSwitch||m===T.FragmentState.NOT_LOADED||m===T.FragmentState.PARTIAL)&&(l.sn==="initSegment"?this._loadInitSegment(l):o.live&&!Object(R.isFiniteNumber)(this.initPTS[l.cc])?(this.log("Waiting for video PTS in continuity counter "+l.cc+" of live stream before loading audio fragment "+l.sn+" of level "+this.trackId),this.state=y.State.WAITING_INIT_PTS):(this.startFragRequested=!0,h.prototype.loadFragment.call(this,l,o,E)))},u.completeAudioSwitch=function(){var l=this.hls,o=this.media,E=this.trackId;o&&(this.log("Switching audio track : flushing all audio"),h.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,l.trigger(x.Events.AUDIO_TRACK_SWITCHED,{id:E})},d}(y.default);b.default=n},"./src/controller/audio-track-controller.ts":function(k,b,c){"use strict";c.r(b);var R=c("./src/events.ts"),y=c("./src/errors.ts"),x=c("./src/controller/base-playlist-controller.ts"),I=c("./src/types/loader.ts");function T(L,S){for(var v=0;v<S.length;v++){var p=S[v];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(L,p.key,p)}}function D(L,S,v){return S&&T(L.prototype,S),v&&T(L,v),L}function _(L,S){L.prototype=Object.create(S.prototype),L.prototype.constructor=L,g(L,S)}function g(L,S){return g=Object.setPrototypeOf||function(p,s){return p.__proto__=s,p},g(L,S)}var A=function(L){_(S,L);function S(p){var s;return s=L.call(this,p,"[audio-track-controller]")||this,s.tracks=[],s.groupId=null,s.tracksInGroup=[],s.trackId=-1,s.trackName="",s.selectDefaultTrack=!0,s.registerListeners(),s}var v=S.prototype;return v.registerListeners=function(){var s=this.hls;s.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),s.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),s.on(R.Events.LEVEL_LOADING,this.onLevelLoading,this),s.on(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),s.on(R.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),s.on(R.Events.ERROR,this.onError,this)},v.unregisterListeners=function(){var s=this.hls;s.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),s.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),s.off(R.Events.LEVEL_LOADING,this.onLevelLoading,this),s.off(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),s.off(R.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),s.off(R.Events.ERROR,this.onError,this)},v.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,L.prototype.destroy.call(this)},v.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},v.onManifestParsed=function(s,e){this.tracks=e.audioTracks||[]},v.onAudioTrackLoaded=function(s,e){var i=e.id,t=e.details,r=this.tracksInGroup[i];if(!r){this.warn("Invalid audio track id "+i);return}var a=r.details;r.details=e.details,this.log("audioTrack "+i+" loaded ["+t.startSN+"-"+t.endSN+"]"),i===this.trackId&&(this.retryCount=0,this.playlistLoaded(i,e,a))},v.onLevelLoading=function(s,e){this.switchLevel(e.level)},v.onLevelSwitching=function(s,e){this.switchLevel(e.level)},v.switchLevel=function(s){var e=this.hls.levels[s];if(!!(e!=null&&e.audioGroupIds)){var i=e.audioGroupIds[e.urlId];if(this.groupId!==i){this.groupId=i;var t=this.tracks.filter(function(a){return!i||a.groupId===i});this.selectDefaultTrack&&!t.some(function(a){return a.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=t;var r={audioTracks:t};this.log("Updating audio tracks, "+t.length+' track(s) found in "'+i+'" group-id'),this.hls.trigger(R.Events.AUDIO_TRACKS_UPDATED,r),this.selectInitialTrack()}}},v.onError=function(s,e){L.prototype.onError.call(this,s,e),!(e.fatal||!e.context)&&e.context.type===I.PlaylistContextType.AUDIO_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.retryLoadingOrFail(e)},v.setAudioTrack=function(s){var e=this.tracksInGroup;if(s<0||s>=e.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var i=e[this.trackId];this.log("Now switching to audio-track index "+s);var t=e[s],r=t.id,a=t.groupId,n=a===void 0?"":a,h=t.name,d=t.type,u=t.url;if(this.trackId=s,this.trackName=h,this.selectDefaultTrack=!1,this.hls.trigger(R.Events.AUDIO_TRACK_SWITCHING,{id:r,groupId:n,name:h,type:d,url:u}),!(t.details&&!t.details.live)){var f=this.switchParams(t.url,i==null?void 0:i.details);this.loadPlaylist(f)}},v.selectInitialTrack=function(){var s=this.tracksInGroup;console.assert(s.length,"Initial audio track should be selected when tracks are known");var e=this.trackName,i=this.findTrackId(e)||this.findTrackId();i!==-1?this.setAudioTrack(i):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(R.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},v.findTrackId=function(s){for(var e=this.tracksInGroup,i=0;i<e.length;i++){var t=e[i];if((!this.selectDefaultTrack||t.default)&&(!s||s===t.name))return t.id}return-1},v.loadPlaylist=function(s){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var i=e.id,t=e.groupId,r=e.url;if(s)try{r=s.addDirectives(r)}catch(a){this.warn("Could not construct new URL with HLS Delivery Directives: "+a)}this.log("loading audio-track playlist for id: "+i),this.clearTimer(),this.hls.trigger(R.Events.AUDIO_TRACK_LOADING,{url:r,id:i,groupId:t,deliveryDirectives:s||null})}},D(S,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(s){this.selectDefaultTrack=!1,this.setAudioTrack(s)}}]),S}(x.default);b.default=A},"./src/controller/base-playlist-controller.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"default",function(){return D});var R=c("./src/polyfills/number.ts"),y=c("./src/types/level.ts"),x=c("./src/controller/level-helper.ts"),I=c("./src/utils/logger.ts"),T=c("./src/errors.ts"),D=function(){function _(A,L){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,L+":"),this.warn=I.logger.warn.bind(I.logger,L+":"),this.hls=A}var g=_.prototype;return g.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},g.onError=function(L,S){S.fatal&&S.type===T.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},g.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},g.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},g.stopLoad=function(){this.canLoad=!1,this.clearTimer()},g.switchParams=function(L,S){var v=S==null?void 0:S.renditionReports;if(v)for(var p=0;p<v.length;p++){var s=v[p],e=""+s.URI;if(e===L.substr(-e.length)){var i=parseInt(s["LAST-MSN"]),t=parseInt(s["LAST-PART"]);if(S&&this.hls.config.lowLatencyMode){var r=Math.min(S.age-S.partTarget,S.targetduration);t!==void 0&&r>S.partTarget&&(t+=1)}if(Object(R.isFiniteNumber)(i))return new y.HlsUrlParameters(i,Object(R.isFiniteNumber)(t)?t:void 0,y.HlsSkip.No)}}},g.loadPlaylist=function(L){},g.shouldLoadTrack=function(L){return this.canLoad&&L&&!!L.url&&(!L.details||L.details.live)},g.playlistLoaded=function(L,S,v){var p=this,s=S.details,e=S.stats,i=e.loading.end?Math.max(0,self.performance.now()-e.loading.end):0;if(s.advancedDateTime=Date.now()-i,s.live||v!=null&&v.live){if(s.reloaded(v),v&&this.log("live playlist "+L+" "+(s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:"MISSED")),v&&s.fragments.length>0&&Object(x.mergeDetails)(v,s),!this.canLoad||!s.live)return;var t,r=void 0,a=void 0;if(s.canBlockReload&&s.endSN&&s.advanced){var n=this.hls.config.lowLatencyMode,h=s.lastPartSn,d=s.endSN,u=s.lastPartIndex,f=u!==-1,l=h===d,o=n?0:u;f?(r=l?d+1:h,a=l?o:u+1):r=d+1;var E=s.age,m=E+s.ageHeader,O=Math.min(m-s.partTarget,s.targetduration*1.5);if(O>0){if(v&&O>v.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+v.tuneInGoal+" to: "+O+" with playlist age: "+s.age),O=0;else{var P=Math.floor(O/s.targetduration);if(r+=P,a!==void 0){var M=Math.round(O%s.targetduration/s.partTarget);a+=M}this.log("CDN Tune-in age: "+s.ageHeader+"s last advanced "+E.toFixed(2)+"s goal: "+O+" skip sn "+P+" to part "+a)}s.tuneInGoal=O}if(t=this.getDeliveryDirectives(s,S.deliveryDirectives,r,a),n||!l){this.loadPlaylist(t);return}}else t=this.getDeliveryDirectives(s,S.deliveryDirectives,r,a);var F=Object(x.computeReloadInterval)(s,e);r!==void 0&&s.canBlockReload&&(F-=s.partTarget||1),this.log("reload live playlist "+L+" in "+Math.round(F)+" ms"),this.timer=self.setTimeout(function(){return p.loadPlaylist(t)},F)}else this.clearTimer()},g.getDeliveryDirectives=function(L,S,v,p){var s=Object(y.getSkipValue)(L,v);return S!=null&&S.skip&&L.deltaUpdateFailed&&(v=S.msn,p=S.part,s=y.HlsSkip.No),new y.HlsUrlParameters(v,p,s)},g.retryLoadingOrFail=function(L){var S=this,v=this.hls.config,p=this.retryCount<v.levelLoadingMaxRetry;if(p){var s;if(this.retryCount++,L.details.indexOf("LoadTimeOut")>-1&&(s=L.context)!==null&&s!==void 0&&s.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+L.details+'"'),this.loadPlaylist();else{var e=Math.min(Math.pow(2,this.retryCount)*v.levelLoadingRetryDelay,v.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return S.loadPlaylist()},e),this.warn("retry playlist loading #"+this.retryCount+" in "+e+' ms after "'+L.details+'"')}}else this.warn('cannot recover from error "'+L.details+'"'),this.clearTimer(),L.fatal=!0;return p},_}()},"./src/controller/base-stream-controller.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"State",function(){return d}),c.d(b,"default",function(){return u});var R=c("./src/polyfills/number.ts"),y=c("./src/task-loop.ts"),x=c("./src/controller/fragment-tracker.ts"),I=c("./src/utils/buffer-helper.ts"),T=c("./src/utils/logger.ts"),D=c("./src/events.ts"),_=c("./src/errors.ts"),g=c("./src/types/transmuxer.ts"),A=c("./src/utils/mp4-tools.ts"),L=c("./src/utils/discontinuities.ts"),S=c("./src/controller/fragment-finders.ts"),v=c("./src/controller/level-helper.ts"),p=c("./src/loader/fragment-loader.ts"),s=c("./src/crypt/decrypter.ts"),e=c("./src/utils/time-ranges.ts"),i=c("./src/types/loader.ts");function t(f,l){for(var o=0;o<l.length;o++){var E=l[o];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(f,E.key,E)}}function r(f,l,o){return l&&t(f.prototype,l),o&&t(f,o),f}function a(f){if(f===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return f}function n(f,l){f.prototype=Object.create(l.prototype),f.prototype.constructor=f,h(f,l)}function h(f,l){return h=Object.setPrototypeOf||function(E,m){return E.__proto__=m,E},h(f,l)}var d={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",BACKTRACKING:"BACKTRACKING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},u=function(f){n(l,f);function l(E,m,O){var P;return P=f.call(this)||this,P.hls=void 0,P.fragPrevious=null,P.fragCurrent=null,P.fragmentTracker=void 0,P.transmuxer=null,P._state=d.STOPPED,P.media=void 0,P.mediaBuffer=void 0,P.config=void 0,P.bitrateTest=!1,P.lastCurrentTime=0,P.nextLoadPosition=0,P.startPosition=0,P.loadedmetadata=!1,P.fragLoadError=0,P.retryDate=0,P.levels=null,P.fragmentLoader=void 0,P.levelLastLoaded=null,P.startFragRequested=!1,P.decrypter=void 0,P.initPTS=[],P.onvseeking=null,P.onvended=null,P.logPrefix="",P.log=void 0,P.warn=void 0,P.logPrefix=O,P.log=T.logger.log.bind(T.logger,O+":"),P.warn=T.logger.warn.bind(T.logger,O+":"),P.hls=E,P.fragmentLoader=new p.default(E.config),P.fragmentTracker=m,P.config=E.config,P.decrypter=new s.default(E,E.config),E.on(D.Events.KEY_LOADED,P.onKeyLoaded,a(P)),P}var o=l.prototype;return o.doTick=function(){this.onTickEnd()},o.onTickEnd=function(){},o.startLoad=function(m){},o.stopLoad=function(){this.fragmentLoader.abort();var m=this.fragCurrent;m&&this.fragmentTracker.removeFragment(m),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=d.STOPPED},o._streamEnded=function(m,O){var P=this.fragCurrent,M=this.fragmentTracker;if(!O.live&&P&&P.sn>=O.endSN&&!m.nextStart){var F=O.partList;if(F!=null&&F.length){var B=F[F.length-1],C=I.BufferHelper.isBuffered(this.media,B.start+B.duration/2);return C}var U=M.getState(P);return U===x.FragmentState.PARTIAL||U===x.FragmentState.OK}return!1},o.onMediaAttached=function(m,O){var P=this.media=this.mediaBuffer=O.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),P.addEventListener("seeking",this.onvseeking),P.addEventListener("ended",this.onvended);var M=this.config;this.levels&&M.autoStartLoad&&this.state===d.STOPPED&&this.startLoad(M.startPosition)},o.onMediaDetaching=function(){var m=this.media;m!=null&&m.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),m&&(m.removeEventListener("seeking",this.onvseeking),m.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},o.onMediaSeeking=function(){var m=this.config,O=this.fragCurrent,P=this.media,M=this.mediaBuffer,F=this.state,B=P?P.currentTime:0,C=I.BufferHelper.bufferInfo(M||P,B,m.maxBufferHole);if(this.log("media seeking to "+(Object(R.isFiniteNumber)(B)?B.toFixed(3):B)+", state: "+F),F===d.ENDED)this.resetLoadingState();else if(O&&!C.len){var U=m.maxFragLookUpTolerance,w=O.start-U,N=O.start+O.duration+U,j=B>N;(B<w||j)&&(j&&O.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),O.loader.abort()),this.resetLoadingState())}P&&(this.lastCurrentTime=B),!this.loadedmetadata&&!C.len&&(this.nextLoadPosition=this.startPosition=B),this.tickImmediate()},o.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},o.onKeyLoaded=function(m,O){if(!(this.state!==d.KEY_LOADING||O.frag!==this.fragCurrent||!this.levels)){this.state=d.IDLE;var P=this.levels[O.frag.level].details;P&&this.loadFragment(O.frag,P,O.frag.start)}},o.onHandlerDestroying=function(){this.stopLoad(),f.prototype.onHandlerDestroying.call(this)},o.onHandlerDestroyed=function(){this.state=d.STOPPED,this.hls.off(D.Events.KEY_LOADED,this.onKeyLoaded,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,f.prototype.onHandlerDestroyed.call(this)},o.loadKey=function(m,O){this.log("Loading key for "+m.sn+" of ["+O.startSN+"-"+O.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+m.level),this.state=d.KEY_LOADING,this.fragCurrent=m,this.hls.trigger(D.Events.KEY_LOADING,{frag:m})},o.loadFragment=function(m,O,P){this._loadFragForPlayback(m,O,P)},o._loadFragForPlayback=function(m,O,P){var M=this,F=function(C){if(M.fragContextChanged(m)){M.warn("Fragment "+m.sn+(C.part?" p: "+C.part.index:"")+" of level "+m.level+" was dropped during download."),M.fragmentTracker.removeFragment(m);return}m.stats.chunkCount++,M._handleFragmentLoadProgress(C)};this._doFragLoad(m,O,P,F).then(function(B){if(!!B){M.fragLoadError=0;var C=M.state;if(M.fragContextChanged(m)){(C===d.FRAG_LOADING||C===d.BACKTRACKING||!M.fragCurrent&&C===d.PARSING)&&(M.fragmentTracker.removeFragment(m),M.state=d.IDLE);return}if("payload"in B&&(M.log("Loaded fragment "+m.sn+" of level "+m.level),M.hls.trigger(D.Events.FRAG_LOADED,B),M.state===d.BACKTRACKING)){M.fragmentTracker.backtrack(m,B),M.resetFragmentLoading(m);return}M._handleFragmentLoadComplete(B)}}).catch(function(B){M.warn(B),M.resetFragmentLoading(m)})},o.flushMainBuffer=function(m,O,P){if(P===void 0&&(P=null),!!(m-O)){var M={startOffset:m,endOffset:O,type:P};this.fragLoadError=0,this.hls.trigger(D.Events.BUFFER_FLUSHING,M)}},o._loadInitSegment=function(m){var O=this;this._doFragLoad(m).then(function(P){if(!P||O.fragContextChanged(m)||!O.levels)throw new Error("init load aborted");return P}).then(function(P){var M=O.hls,F=P.payload,B=m.decryptdata;if(F&&F.byteLength>0&&B&&B.key&&B.iv&&B.method==="AES-128"){var C=self.performance.now();return O.decrypter.webCryptoDecrypt(new Uint8Array(F),B.key.buffer,B.iv.buffer).then(function(U){var w=self.performance.now();return M.trigger(D.Events.FRAG_DECRYPTED,{frag:m,payload:U,stats:{tstart:C,tdecrypt:w}}),P.payload=U,P})}return P}).then(function(P){var M=O.fragCurrent,F=O.hls,B=O.levels;if(!B)throw new Error("init load aborted, missing levels");var C=B[m.level].details;console.assert(C,"Level details are defined when init segment is loaded");var U=m.stats;O.state=d.IDLE,O.fragLoadError=0,m.data=new Uint8Array(P.payload),U.parsing.start=U.buffering.start=self.performance.now(),U.parsing.end=U.buffering.end=self.performance.now(),P.frag===M&&F.trigger(D.Events.FRAG_BUFFERED,{stats:U,frag:M,part:null,id:m.type}),O.tick()}).catch(function(P){O.warn(P),O.resetFragmentLoading(m)})},o.fragContextChanged=function(m){var O=this.fragCurrent;return!m||!O||m.level!==O.level||m.sn!==O.sn||m.urlId!==O.urlId},o.fragBufferedComplete=function(m,O){var P=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+m.type+" sn: "+m.sn+(O?" part: "+O.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+m.level+" "+e.default.toString(I.BufferHelper.getBuffered(P))),this.state=d.IDLE,this.tick()},o._handleFragmentLoadComplete=function(m){var O=this.transmuxer;if(!!O){var P=m.frag,M=m.part,F=m.partsLoaded,B=!F||F.length===0||F.some(function(U){return!U}),C=new g.ChunkMetadata(P.level,P.sn,P.stats.chunkCount+1,0,M?M.index:-1,!B);O.flush(C)}},o._handleFragmentLoadProgress=function(m){},o._doFragLoad=function(m,O,P,M){var F=this;if(P===void 0&&(P=null),!this.levels)throw new Error("frag load aborted, missing levels");if(P=Math.max(m.start,P||0),this.config.lowLatencyMode&&O){var B=O.partList;if(B&&M){P>m.end&&O.fragmentHint&&(m=O.fragmentHint);var C=this.getNextPart(B,m,P);if(C>-1){var U=B[C];return this.log("Loading part sn: "+m.sn+" p: "+U.index+" cc: "+m.cc+" of playlist ["+O.startSN+"-"+O.endSN+"] parts [0-"+C+"-"+(B.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+m.level+", target: "+parseFloat(P.toFixed(3))),this.nextLoadPosition=U.start+U.duration,this.state=d.FRAG_LOADING,this.hls.trigger(D.Events.FRAG_LOADING,{frag:m,part:B[C],targetBufferTime:P}),this.doFragPartsLoad(m,B,C,M).catch(function(w){return F.handleFragLoadError(w)})}else if(!m.url||this.loadedEndOfParts(B,P))return Promise.resolve(null)}}return this.log("Loading fragment "+m.sn+" cc: "+m.cc+" "+(O?"of ["+O.startSN+"-"+O.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+m.level+", target: "+parseFloat(P.toFixed(3))),Object(R.isFiniteNumber)(m.sn)&&!this.bitrateTest&&(this.nextLoadPosition=m.start+m.duration),this.state=d.FRAG_LOADING,this.hls.trigger(D.Events.FRAG_LOADING,{frag:m,targetBufferTime:P}),this.fragmentLoader.load(m,M).catch(function(w){return F.handleFragLoadError(w)})},o.doFragPartsLoad=function(m,O,P,M){var F=this;return new Promise(function(B,C){var U=[],w=function N(j){var K=O[j];F.fragmentLoader.loadPart(m,K,M).then(function(G){U[K.index]=G;var Y=G.part;F.hls.trigger(D.Events.FRAG_LOADED,G);var V=O[j+1];if(V&&V.fragment===m)N(j+1);else return B({frag:m,part:Y,partsLoaded:U})}).catch(C)};w(P)})},o.handleFragLoadError=function(m){var O=m.data;return O&&O.details===_.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(O.frag,O.part):this.hls.trigger(D.Events.ERROR,O),null},o._handleTransmuxerFlush=function(m){var O=this.getCurrentContext(m);if(!O||this.state!==d.PARSING){this.fragCurrent||(this.state=d.IDLE);return}var P=O.frag,M=O.part,F=O.level,B=self.performance.now();P.stats.parsing.end=B,M&&(M.stats.parsing.end=B),this.updateLevelTiming(P,M,F,m.partial)},o.getCurrentContext=function(m){var O=this.levels,P=m.level,M=m.sn,F=m.part;if(!O||!O[P])return this.warn("Levels object was unset while buffering fragment "+M+" of level "+P+". The current chunk will not be buffered."),null;var B=O[P],C=F>-1?Object(v.getPartWith)(B,M,F):null,U=C?C.fragment:Object(v.getFragmentWithSN)(B,M,this.fragCurrent);return U?{frag:U,part:C,level:B}:null},o.bufferFragmentData=function(m,O,P,M){if(!(!m||this.state!==d.PARSING)){var F=m.data1,B=m.data2,C=F;if(F&&B&&(C=Object(A.appendUint8Array)(F,B)),!(!C||!C.length)){var U={type:m.type,frag:O,part:P,chunkMeta:M,parent:O.type,data:C};this.hls.trigger(D.Events.BUFFER_APPENDING,U),m.dropped&&m.independent&&!P&&this.flushBufferGap(O)}}},o.flushBufferGap=function(m){var O=this.media;if(!!O){if(!I.BufferHelper.isBuffered(O,O.currentTime)){this.flushMainBuffer(0,m.start);return}var P=O.currentTime,M=I.BufferHelper.bufferInfo(O,P,0),F=m.duration,B=Math.min(this.config.maxFragLookUpTolerance*2,F*.25),C=Math.max(Math.min(m.start-B,M.end-B),P+B);m.start-C>B&&this.flushMainBuffer(C,m.start)}},o.getFwdBufferInfo=function(m,O){var P=this.config,M=this.getLoadPosition();if(!Object(R.isFiniteNumber)(M))return null;var F=I.BufferHelper.bufferInfo(m,M,P.maxBufferHole);if(F.len===0&&F.nextStart!==void 0){var B=this.fragmentTracker.getBufferedFrag(M,O);if(B&&F.nextStart<B.end)return I.BufferHelper.bufferInfo(m,M,Math.max(F.nextStart,P.maxBufferHole))}return F},o.getMaxBufferLength=function(m){var O=this.config,P;return m?P=Math.max(8*O.maxBufferSize/m,O.maxBufferLength):P=O.maxBufferLength,Math.min(P,O.maxMaxBufferLength)},o.reduceMaxBufferLength=function(m){var O=this.config,P=m||O.maxBufferLength;return O.maxMaxBufferLength>=P?(O.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+O.maxMaxBufferLength+"s"),!0):!1},o.getNextFragment=function(m,O){var P,M,F=O.fragments,B=F.length;if(!B)return null;var C=this.config,U=F[0].start,w;if(O.live){var N=C.initialLiveManifestSize;if(B<N)return this.warn("Not enough fragments to start playback (have: "+B+", need: "+N+")"),null;!O.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(w=this.getInitialLiveFragment(O,F),this.startPosition=w?this.hls.liveSyncPosition||w.start:m)}else m<=U&&(w=F[0]);if(!w){var j=C.lowLatencyMode?O.partEnd:O.fragmentEnd;w=this.getFragmentAtPosition(m,j,O)}return(P=w)!==null&&P!==void 0&&P.initSegment&&!((M=w)!==null&&M!==void 0&&M.initSegment.data)&&!this.bitrateTest&&(w=w.initSegment),w},o.getNextPart=function(m,O,P){for(var M=-1,F=!1,B=!0,C=0,U=m.length;C<U;C++){var w=m[C];if(B=B&&!w.independent,M>-1&&P<w.start)break;var N=w.loaded;!N&&(F||w.independent||B)&&w.fragment===O&&(M=C),F=N}return M},o.loadedEndOfParts=function(m,O){var P=m[m.length-1];return P&&O>P.start&&P.loaded},o.getInitialLiveFragment=function(m,O){var P=this.fragPrevious,M=null;if(P){if(m.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+P.programDateTime),M=Object(S.findFragmentByPDT)(O,P.endProgramDateTime,this.config.maxFragLookUpTolerance)),!M){var F=P.sn+1;if(F>=m.startSN&&F<=m.endSN){var B=O[F-m.startSN];P.cc===B.cc&&(M=B,this.log("Live playlist, switching playlist, load frag with next SN: "+M.sn))}M||(M=Object(S.findFragWithCC)(O,P.cc),M&&this.log("Live playlist, switching playlist, load frag with same CC: "+M.sn))}}else{var C=this.hls.liveSyncPosition;C!==null&&(M=this.getFragmentAtPosition(C,this.bitrateTest?m.fragmentEnd:m.edge,m))}return M},o.getFragmentAtPosition=function(m,O,P){var M=this.config,F=this.fragPrevious,B=P.fragments,C=P.endSN,U=P.fragmentHint,w=M.maxFragLookUpTolerance,N=!!(M.lowLatencyMode&&P.partList&&U);N&&U&&!this.bitrateTest&&(B=B.concat(U),C=U.sn);var j;if(m<O){var K=m>O-w?0:w;j=Object(S.findFragmentByPTS)(F,B,m,K)}else j=B[B.length-1];if(j){var G=j.sn-P.startSN,Y=F&&j.level===F.level,V=B[G+1],Z=this.fragmentTracker.getState(j);if(Z===x.FragmentState.BACKTRACKED){j=null;for(var z=G;B[z]&&this.fragmentTracker.getState(B[z])===x.FragmentState.BACKTRACKED;)F?j=B[z--]:j=B[--z];j||(j=V)}else F&&j.sn===F.sn&&!N&&Y&&(j.sn<C&&this.fragmentTracker.getState(V)!==x.FragmentState.OK?(this.log("SN "+j.sn+" just loaded, load next one: "+V.sn),j=V):j=null)}return j},o.synchronizeToLiveEdge=function(m){var O=this.config,P=this.media;if(!!P){var M=this.hls.liveSyncPosition,F=P.currentTime,B=m.fragments[0].start,C=m.edge,U=F>=B-O.maxFragLookUpTolerance&&F<=C;if(M!==null&&P.duration>M&&(F<M||!U)){var w=O.liveMaxLatencyDuration!==void 0?O.liveMaxLatencyDuration:O.liveMaxLatencyDurationCount*m.targetduration;(!U&&P.readyState<4||F<C-w)&&(this.loadedmetadata||(this.nextLoadPosition=M),P.readyState&&(this.warn("Playback: "+F.toFixed(3)+" is located too far from the end of live sliding playlist: "+C+", reset currentTime to : "+M.toFixed(3)),P.currentTime=M))}}},o.alignPlaylists=function(m,O){var P=this.levels,M=this.levelLastLoaded,F=this.fragPrevious,B=M!==null?P[M]:null,C=m.fragments.length;if(!C)return this.warn("No fragments in live playlist"),0;var U=m.fragments[0].start,w=!O,N=m.alignedSliding&&Object(R.isFiniteNumber)(U);if(w||!N&&!U){Object(L.alignStream)(F,B,m);var j=m.fragments[0].start;return this.log("Live playlist sliding: "+j.toFixed(2)+" start-sn: "+(O?O.startSN:"na")+"->"+m.startSN+" prev-sn: "+(F?F.sn:"na")+" fragments: "+C),j}return U},o.waitForCdnTuneIn=function(m){var O=3;return m.live&&m.canBlockReload&&m.tuneInGoal>Math.max(m.partHoldBack,m.partTarget*O)},o.setStartPosition=function(m,O){var P=this.startPosition;if(P<O&&(P=-1),P===-1||this.lastCurrentTime===-1){var M=m.startTimeOffset;Object(R.isFiniteNumber)(M)?(P=O+M,M<0&&(P+=m.totalduration),P=Math.min(Math.max(O,P),O+m.totalduration),this.log("Start time offset "+M+" found in playlist, adjust startPosition to "+P),this.startPosition=P):m.live?P=this.hls.liveSyncPosition||O:this.startPosition=P=0,this.lastCurrentTime=P}this.nextLoadPosition=P},o.getLoadPosition=function(){var m=this.media,O=0;return this.loadedmetadata&&m?O=m.currentTime:this.nextLoadPosition&&(O=this.nextLoadPosition),O},o.handleFragLoadAborted=function(m,O){this.transmuxer&&m.sn!=="initSegment"&&m.stats.aborted&&(this.warn("Fragment "+m.sn+(O?" part"+O.index:"")+" of level "+m.level+" was aborted"),this.resetFragmentLoading(m))},o.resetFragmentLoading=function(m){(!this.fragCurrent||!this.fragContextChanged(m))&&(this.state=d.IDLE)},o.onFragmentOrKeyLoadError=function(m,O){if(!O.fatal){var P=O.frag;if(!(!P||P.type!==m)){var M=this.fragCurrent;console.assert(M&&P.sn===M.sn&&P.level===M.level&&P.urlId===M.urlId,"Frag load error must match current frag to retry");var F=this.config;if(this.fragLoadError+1<=F.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(P.level))return;var B=Math.min(Math.pow(2,this.fragLoadError)*F.fragLoadingRetryDelay,F.fragLoadingMaxRetryTimeout);this.warn("Fragment "+P.sn+" of "+m+" "+P.level+" failed to load, retrying in "+B+"ms"),this.retryDate=self.performance.now()+B,this.fragLoadError++,this.state=d.FRAG_LOADING_WAITING_RETRY}else O.levelRetry?(m===i.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=d.IDLE):(T.logger.error(O.details+" reaches max retry, redispatch as fatal ..."),O.fatal=!0,this.hls.stopLoad(),this.state=d.ERROR)}}},o.afterBufferFlushed=function(m,O,P){if(!!m){var M=I.BufferHelper.getBuffered(m);this.fragmentTracker.detectEvictedFragments(O,M,P),this.state===d.ENDED&&this.resetLoadingState()}},o.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=d.IDLE},o.resetLiveStartWhenNotLoaded=function(m){if(!this.loadedmetadata){this.startFragRequested=!1;var O=this.levels?this.levels[m].details:null;if(O!=null&&O.live)return this.startPosition=-1,this.setStartPosition(O,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},o.updateLevelTiming=function(m,O,P,M){var F=this,B=P.details;console.assert(!!B,"level.details must be defined");var C=Object.keys(m.elementaryStreams).reduce(function(U,w){var N=m.elementaryStreams[w];if(N){var j=N.endPTS-N.startPTS;if(j<=0)return F.warn("Could not parse fragment "+m.sn+" "+w+" duration reliably ("+j+") resetting transmuxer to fallback to playlist timing"),F.resetTransmuxer(),U||!1;var K=M?0:Object(v.updateFragPTSDTS)(B,m,N.startPTS,N.endPTS,N.startDTS,N.endDTS);return F.hls.trigger(D.Events.LEVEL_PTS_UPDATED,{details:B,level:P,drift:K,type:w,frag:m,start:N.startPTS,end:N.endPTS}),!0}return U},!1);C?(this.state=d.PARSED,this.hls.trigger(D.Events.FRAG_PARSED,{frag:m,part:O})):this.resetLoadingState()},o.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},r(l,[{key:"state",get:function(){return this._state},set:function(m){var O=this._state;O!==m&&(this._state=m,this.log(O+"->"+m))}}]),l}(y.default)},"./src/controller/buffer-controller.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"default",function(){return S});var R=c("./src/polyfills/number.ts"),y=c("./src/events.ts"),x=c("./src/utils/logger.ts"),I=c("./src/errors.ts"),T=c("./src/utils/buffer-helper.ts"),D=c("./src/utils/mediasource-helper.ts"),_=c("./src/loader/fragment.ts"),g=c("./src/controller/buffer-operation-queue.ts"),A=Object(D.getMediaSource)(),L=/([ha]vc.)(?:\.[^.,]+)+/,S=function(){function v(s){var e=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var i=e.hls,t=e.media,r=e.mediaSource;x.logger.log("[buffer-controller]: Media source opened"),t&&(e.updateMediaElementDuration(),i.trigger(y.Events.MEDIA_ATTACHED,{media:t})),r&&r.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){x.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){x.logger.log("[buffer-controller]: Media source ended")},this.hls=s,this._initSourceBuffer(),this.registerListeners()}var p=v.prototype;return p.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},p.destroy=function(){this.unregisterListeners(),this.details=null},p.registerListeners=function(){var e=this.hls;e.on(y.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(y.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.Events.BUFFER_RESET,this.onBufferReset,this),e.on(y.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(y.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(y.Events.BUFFER_EOS,this.onBufferEos,this),e.on(y.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(y.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(y.Events.FRAG_PARSED,this.onFragParsed,this),e.on(y.Events.FRAG_CHANGED,this.onFragChanged,this)},p.unregisterListeners=function(){var e=this.hls;e.off(y.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(y.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.Events.BUFFER_RESET,this.onBufferReset,this),e.off(y.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(y.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(y.Events.BUFFER_EOS,this.onBufferEos,this),e.off(y.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(y.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(y.Events.FRAG_PARSED,this.onFragParsed,this),e.off(y.Events.FRAG_CHANGED,this.onFragChanged,this)},p._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new g.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},p.onManifestParsed=function(e,i){var t=2;(i.audio&&!i.video||!i.altAudio)&&(t=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=t,this.details=null,x.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},p.onMediaAttaching=function(e,i){var t=this.media=i.media;if(t&&A){var r=this.mediaSource=new A;r.addEventListener("sourceopen",this._onMediaSourceOpen),r.addEventListener("sourceended",this._onMediaSourceEnded),r.addEventListener("sourceclose",this._onMediaSourceClose),t.src=self.URL.createObjectURL(r),this._objectUrl=t.src}},p.onMediaDetaching=function(){var e=this.media,i=this.mediaSource,t=this._objectUrl;if(i){if(x.logger.log("[buffer-controller]: media source detaching"),i.readyState==="open")try{i.endOfStream()}catch(r){x.logger.warn("[buffer-controller]: onMediaDetaching: "+r.message+" while calling endOfStream")}this.onBufferReset(),i.removeEventListener("sourceopen",this._onMediaSourceOpen),i.removeEventListener("sourceended",this._onMediaSourceEnded),i.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(t&&self.URL.revokeObjectURL(t),e.src===t?(e.removeAttribute("src"),e.load()):x.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(y.Events.MEDIA_DETACHED,void 0)},p.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(i){var t=e.sourceBuffer[i];try{t&&(e.removeBufferListeners(i),e.mediaSource&&e.mediaSource.removeSourceBuffer(t),e.sourceBuffer[i]=void 0)}catch(r){x.logger.warn("[buffer-controller]: Failed to reset the "+i+" buffer",r)}}),this._initSourceBuffer()},p.onBufferCodecs=function(e,i){var t=this,r=this.getSourceBufferTypes().length;Object.keys(i).forEach(function(a){if(r){var n=t.tracks[a];if(n&&typeof n.buffer.changeType=="function"){var h=i[a],d=h.codec,u=h.levelCodec,f=h.container,l=(n.levelCodec||n.codec).replace(L,"$1"),o=(u||d).replace(L,"$1");if(l!==o){var E=f+";codecs="+(u||d);t.appendChangeType(a,E)}}}else t.pendingTracks[a]=i[a]}),!r&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},p.appendChangeType=function(e,i){var t=this,r=this.operationQueue,a={execute:function(){var h=t.sourceBuffer[e];h&&(x.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+i),h.changeType(i)),r.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(h){x.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",h)}};r.append(a,e)},p.onBufferAppending=function(e,i){var t=this,r=this.hls,a=this.operationQueue,n=this.tracks,h=i.data,d=i.type,u=i.frag,f=i.part,l=i.chunkMeta,o=l.buffering[d],E=self.performance.now();o.start=E;var m=u.stats.buffering,O=f?f.stats.buffering:null;m.start===0&&(m.start=E),O&&O.start===0&&(O.start=E);var P=n.audio,M=d==="audio"&&l.id===1&&(P==null?void 0:P.container)==="audio/mpeg",F={execute:function(){if(o.executeStart=self.performance.now(),M){var C=t.sourceBuffer[d];if(C){var U=u.start-C.timestampOffset;Math.abs(U)>=.1&&(x.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+u.start+" (delta: "+U+") sn: "+u.sn+")"),C.timestampOffset=u.start)}}t.appendExecutor(h,d)},onStart:function(){},onComplete:function(){var C=self.performance.now();o.executeEnd=o.end=C,m.first===0&&(m.first=C),O&&O.first===0&&(O.first=C);var U=t.sourceBuffer,w={};for(var N in U)w[N]=T.BufferHelper.getBuffered(U[N]);t.appendError=0,t.hls.trigger(y.Events.BUFFER_APPENDED,{type:d,frag:u,part:f,chunkMeta:l,parent:u.type,timeRanges:w})},onError:function(C){x.logger.error("[buffer-controller]: Error encountered while trying to append to the "+d+" SourceBuffer",C);var U={type:I.ErrorTypes.MEDIA_ERROR,parent:u.type,details:I.ErrorDetails.BUFFER_APPEND_ERROR,err:C,fatal:!1};C.code===DOMException.QUOTA_EXCEEDED_ERR?U.details=I.ErrorDetails.BUFFER_FULL_ERROR:(t.appendError++,U.details=I.ErrorDetails.BUFFER_APPEND_ERROR,t.appendError>r.config.appendErrorMaxRetry&&(x.logger.error("[buffer-controller]: Failed "+r.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),U.fatal=!0)),r.trigger(y.Events.ERROR,U)}};a.append(F,d)},p.onBufferFlushing=function(e,i){var t=this,r=this.operationQueue,a=function(h){return{execute:t.removeExecutor.bind(t,h,i.startOffset,i.endOffset),onStart:function(){},onComplete:function(){t.hls.trigger(y.Events.BUFFER_FLUSHED,{type:h})},onError:function(u){x.logger.warn("[buffer-controller]: Failed to remove from "+h+" SourceBuffer",u)}}};i.type?r.append(a(i.type),i.type):this.getSourceBufferTypes().forEach(function(n){r.append(a(n),n)})},p.onFragParsed=function(e,i){var t=this,r=i.frag,a=i.part,n=[],h=a?a.elementaryStreams:r.elementaryStreams;h[_.ElementaryStreamTypes.AUDIOVIDEO]?n.push("audiovideo"):(h[_.ElementaryStreamTypes.AUDIO]&&n.push("audio"),h[_.ElementaryStreamTypes.VIDEO]&&n.push("video"));var d=function(){var f=self.performance.now();r.stats.buffering.end=f,a&&(a.stats.buffering.end=f);var l=a?a.stats:r.stats;t.hls.trigger(y.Events.FRAG_BUFFERED,{frag:r,part:a,stats:l,id:r.type})};n.length===0&&x.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+r.type+" level: "+r.level+" sn: "+r.sn),this.blockBuffers(d,n)},p.onFragChanged=function(e,i){this.flushBackBuffer()},p.onBufferEos=function(e,i){var t=this,r=this.getSourceBufferTypes().reduce(function(a,n){var h=t.sourceBuffer[n];return(!i.type||i.type===n)&&h&&!h.ended&&(h.ended=!0,x.logger.log("[buffer-controller]: "+n+" sourceBuffer now EOS")),a&&!!(!h||h.ended)},!0);r&&this.blockBuffers(function(){var a=t.mediaSource;!a||a.readyState!=="open"||a.endOfStream()})},p.onLevelUpdated=function(e,i){var t=i.details;!t.fragments.length||(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},p.flushBackBuffer=function(){var e=this.hls,i=this.details,t=this.media,r=this.sourceBuffer;if(!(!t||i===null)){var a=this.getSourceBufferTypes();if(!!a.length){var n=i.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(!(!Object(R.isFiniteNumber)(n)||n<0)){var h=t.currentTime,d=i.levelTargetDuration,u=Math.max(n,d),f=Math.floor(h/d)*d-u;a.forEach(function(l){var o=r[l];if(o){var E=T.BufferHelper.getBuffered(o);E.length>0&&f>E.start(0)&&(e.trigger(y.Events.BACK_BUFFER_REACHED,{bufferEnd:f}),i.live&&e.trigger(y.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:f}),e.trigger(y.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:f,type:l}))}})}}}},p.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var e=this.details,i=this.hls,t=this.media,r=this.mediaSource,a=e.fragments[0].start+e.totalduration,n=t.duration,h=Object(R.isFiniteNumber)(r.duration)?r.duration:0;e.live&&i.config.liveDurationInfinity?(x.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),r.duration=1/0,this.updateSeekableRange(e)):(a>h&&a>n||!Object(R.isFiniteNumber)(n))&&(x.logger.log("[buffer-controller]: Updating Media Source duration to "+a.toFixed(3)),r.duration=a)}},p.updateSeekableRange=function(e){var i=this.mediaSource,t=e.fragments,r=t.length;if(r&&e.live&&i!==null&&i!==void 0&&i.setLiveSeekableRange){var a=Math.max(0,t[0].start),n=Math.max(a,a+e.totalduration);i.setLiveSeekableRange(a,n)}},p.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,i=this.operationQueue,t=this.pendingTracks,r=Object.keys(t).length;if(r&&!e||r===2){this.createSourceBuffers(t),this.pendingTracks={};var a=this.getSourceBufferTypes();if(a.length===0){this.hls.trigger(y.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}a.forEach(function(n){i.executeNext(n)})}},p.createSourceBuffers=function(e){var i=this.sourceBuffer,t=this.mediaSource;if(!t)throw Error("createSourceBuffers called when mediaSource was null");var r=0;for(var a in e)if(!i[a]){var n=e[a];if(!n)throw Error("source buffer exists for track "+a+", however track does not");var h=n.levelCodec||n.codec,d=n.container+";codecs="+h;x.logger.log("[buffer-controller]: creating sourceBuffer("+d+")");try{var u=i[a]=t.addSourceBuffer(d),f=a;this.addBufferListener(f,"updatestart",this._onSBUpdateStart),this.addBufferListener(f,"updateend",this._onSBUpdateEnd),this.addBufferListener(f,"error",this._onSBUpdateError),this.tracks[a]={buffer:u,codec:h,container:n.container,levelCodec:n.levelCodec,id:n.id},r++}catch(l){x.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+l.message),this.hls.trigger(y.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:l,mimeType:d})}}r&&this.hls.trigger(y.Events.BUFFER_CREATED,{tracks:this.tracks})},p._onSBUpdateStart=function(e){var i=this.operationQueue,t=i.current(e);t.onStart()},p._onSBUpdateEnd=function(e){var i=this.operationQueue,t=i.current(e);t.onComplete(),i.shiftAndExecuteNext(e)},p._onSBUpdateError=function(e,i){x.logger.error("[buffer-controller]: "+e+" SourceBuffer error",i),this.hls.trigger(y.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var t=this.operationQueue.current(e);t&&t.onError(i)},p.removeExecutor=function(e,i,t){var r=this.media,a=this.mediaSource,n=this.operationQueue,h=this.sourceBuffer,d=h[e];if(!r||!a||!d){x.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),n.shiftAndExecuteNext(e);return}var u=Object(R.isFiniteNumber)(r.duration)?r.duration:1/0,f=Object(R.isFiniteNumber)(a.duration)?a.duration:1/0,l=Math.max(0,i),o=Math.min(t,u,f);o>l?(x.logger.log("[buffer-controller]: Removing ["+l+","+o+"] from the "+e+" SourceBuffer"),console.assert(!d.updating,e+" sourceBuffer must not be updating"),d.remove(l,o)):n.shiftAndExecuteNext(e)},p.appendExecutor=function(e,i){var t=this.operationQueue,r=this.sourceBuffer,a=r[i];if(!a){x.logger.warn("[buffer-controller]: Attempting to append to the "+i+" SourceBuffer, but it does not exist"),t.shiftAndExecuteNext(i);return}a.ended=!1,console.assert(!a.updating,i+" sourceBuffer must not be updating"),a.appendBuffer(e)},p.blockBuffers=function(e,i){var t=this;if(i===void 0&&(i=this.getSourceBufferTypes()),!i.length){x.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(e);return}var r=this.operationQueue,a=i.map(function(n){return r.appendBlocker(n)});Promise.all(a).then(function(){e(),i.forEach(function(n){var h=t.sourceBuffer[n];(!h||!h.updating)&&r.shiftAndExecuteNext(n)})})},p.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},p.addBufferListener=function(e,i,t){var r=this.sourceBuffer[e];if(!!r){var a=t.bind(this,e);this.listeners[e].push({event:i,listener:a}),r.addEventListener(i,a)}},p.removeBufferListeners=function(e){var i=this.sourceBuffer[e];!i||this.listeners[e].forEach(function(t){i.removeEventListener(t.event,t.listener)})},v}()},"./src/controller/buffer-operation-queue.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"default",function(){return y});var R=c("./src/utils/logger.ts"),y=function(){function x(T){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=T}var I=x.prototype;return I.append=function(D,_){var g=this.queues[_];g.push(D),g.length===1&&this.buffers[_]&&this.executeNext(_)},I.insertAbort=function(D,_){var g=this.queues[_];g.unshift(D),this.executeNext(_)},I.appendBlocker=function(D){var _,g=new Promise(function(L){_=L}),A={execute:_,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(A,D),g},I.executeNext=function(D){var _=this.buffers,g=this.queues,A=_[D],L=g[D];if(L.length){var S=L[0];try{S.execute()}catch(v){R.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),S.onError(v),(!A||!A.updating)&&(L.shift(),this.executeNext(D))}}},I.shiftAndExecuteNext=function(D){this.queues[D].shift(),this.executeNext(D)},I.current=function(D){return this.queues[D][0]},x}()},"./src/controller/cap-level-controller.ts":function(k,b,c){"use strict";c.r(b);var R=c("./src/events.ts");function y(T,D){for(var _=0;_<D.length;_++){var g=D[_];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(T,g.key,g)}}function x(T,D,_){return D&&y(T.prototype,D),_&&y(T,_),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 D=T.prototype;return D.setStreamController=function(g){this.streamController=g},D.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},D.registerListeners=function(){var g=this.hls;g.on(R.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),g.on(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),g.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),g.on(R.Events.BUFFER_CODECS,this.onBufferCodecs,this),g.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},D.unregisterListener=function(){var g=this.hls;g.off(R.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),g.off(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),g.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),g.off(R.Events.BUFFER_CODECS,this.onBufferCodecs,this),g.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},D.onFpsDropLevelCapping=function(g,A){T.isLevelAllowed(A.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(A.droppedLevel)},D.onMediaAttaching=function(g,A){this.media=A.media instanceof HTMLVideoElement?A.media:null},D.onManifestParsed=function(g,A){var L=this.hls;this.restrictedLevels=[],this.firstLevel=A.firstLevel,L.config.capLevelToPlayerSize&&A.video&&this.startCapping()},D.onBufferCodecs=function(g,A){var L=this.hls;L.config.capLevelToPlayerSize&&A.video&&this.startCapping()},D.onMediaDetaching=function(){this.stopCapping()},D.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var g=this.hls.levels;if(g.length){var A=this.hls;A.autoLevelCapping=this.getMaxLevel(g.length-1),A.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=A.autoLevelCapping}}},D.getMaxLevel=function(g){var A=this,L=this.hls.levels;if(!L.length)return-1;var S=L.filter(function(v,p){return T.isLevelAllowed(p,A.restrictedLevels)&&p<=g});return this.clientRect=null,T.getMaxLevelByMediaSize(S,this.mediaWidth,this.mediaHeight)},D.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())},D.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},D.getDimensions=function(){if(this.clientRect)return this.clientRect;var g=this.media,A={width:0,height:0};if(g){var L=g.getBoundingClientRect();A.width=L.width,A.height=L.height,!A.width&&!A.height&&(A.width=L.right-L.left||g.width||0,A.height=L.bottom-L.top||g.height||0)}return this.clientRect=A,A},T.isLevelAllowed=function(g,A){return A===void 0&&(A=[]),A.indexOf(g)===-1},T.getMaxLevelByMediaSize=function(g,A,L){if(!g||!g.length)return-1;for(var S=function(i,t){return t?i.width!==t.width||i.height!==t.height:!0},v=g.length-1,p=0;p<g.length;p+=1){var s=g[p];if((s.width>=A||s.height>=L)&&S(s,g[p+1])){v=p;break}}return v},x(T,[{key:"mediaWidth",get:function(){return this.getDimensions().width*T.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*T.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var g=1;try{g=self.devicePixelRatio}catch{}return g}}]),T}();b.default=I},"./src/controller/cmcd-controller.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"default",function(){return S});var R=c("./src/events.ts"),y=c("./src/types/cmcd.ts"),x=c("./src/utils/buffer-helper.ts"),I=c("./src/utils/logger.ts");function T(v,p){for(var s=0;s<p.length;s++){var e=p[s];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(v,e.key,e)}}function D(v,p,s){return p&&T(v.prototype,p),s&&T(v,s),v}function _(v,p){var s=typeof Symbol!="undefined"&&v[Symbol.iterator]||v["@@iterator"];if(s)return(s=s.call(v)).next.bind(s);if(Array.isArray(v)||(s=g(v))||p&&v&&typeof v.length=="number"){s&&(v=s);var e=0;return function(){return e>=v.length?{done:!0}:{done:!1,value:v[e++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
12
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function g(v,p){if(!!v){if(typeof v=="string")return A(v,p);var s=Object.prototype.toString.call(v).slice(8,-1);if(s==="Object"&&v.constructor&&(s=v.constructor.name),s==="Map"||s==="Set")return Array.from(v);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return A(v,p)}}function A(v,p){(p==null||p>v.length)&&(p=v.length);for(var s=0,e=new Array(p);s<p;s++)e[s]=v[s];return e}function L(){return L=Object.assign||function(v){for(var p=1;p<arguments.length;p++){var s=arguments[p];for(var e in s)Object.prototype.hasOwnProperty.call(s,e)&&(v[e]=s[e])}return v},L.apply(this,arguments)}var S=function(){function v(s){var e=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){e.initialized&&(e.starved=!0),e.buffering=!0},this.onPlaying=function(){e.initialized||(e.initialized=!0),e.buffering=!1},this.applyPlaylistData=function(r){try{e.apply(r,{ot:y.CMCDObjectType.MANIFEST,su:!e.initialized})}catch(a){I.logger.warn("Could not generate manifest CMCD data.",a)}},this.applyFragmentData=function(r){try{var a=r.frag,n=e.hls.levels[a.level],h=e.getObjectType(a),d={d:a.duration*1e3,ot:h};(h===y.CMCDObjectType.VIDEO||h===y.CMCDObjectType.AUDIO||h==y.CMCDObjectType.MUXED)&&(d.br=n.bitrate/1e3,d.tb=e.getTopBandwidth(h)/1e3,d.bl=e.getBufferLength(h)),e.apply(r,d)}catch(u){I.logger.warn("Could not generate segment CMCD data.",u)}},this.hls=s;var i=this.config=s.config,t=i.cmcd;t!=null&&(i.pLoader=this.createPlaylistLoader(),i.fLoader=this.createFragmentLoader(),this.sid=t.sessionId||v.uuid(),this.cid=t.contentId,this.useHeaders=t.useHeaders===!0,this.registerListeners())}var p=v.prototype;return p.registerListeners=function(){var e=this.hls;e.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(R.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(R.Events.BUFFER_CREATED,this.onBufferCreated,this)},p.unregisterListeners=function(){var e=this.hls;e.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(R.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(R.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},p.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},p.onMediaAttached=function(e,i){this.media=i.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},p.onMediaDetached=function(){!this.media||(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},p.onBufferCreated=function(e,i){var t,r;this.audioBuffer=(t=i.tracks.audio)===null||t===void 0?void 0:t.buffer,this.videoBuffer=(r=i.tracks.video)===null||r===void 0?void 0:r.buffer},p.createData=function(){var e;return{v:y.CMCDVersion,sf:y.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)===null||e===void 0?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},p.apply=function(e,i){i===void 0&&(i={}),L(i,this.createData());var t=i.ot===y.CMCDObjectType.INIT||i.ot===y.CMCDObjectType.VIDEO||i.ot===y.CMCDObjectType.MUXED;if(this.starved&&t&&(i.bs=!0,i.su=!0,this.starved=!1),i.su==null&&(i.su=this.buffering),this.useHeaders){var r=v.toHeaders(i);if(!Object.keys(r).length)return;e.headers||(e.headers={}),L(e.headers,r)}else{var a=v.toQuery(i);if(!a)return;e.url=v.appendQueryToUri(e.url,a)}},p.getObjectType=function(e){var i=e.type;if(i==="subtitle")return y.CMCDObjectType.TIMED_TEXT;if(e.sn==="initSegment")return y.CMCDObjectType.INIT;if(i==="audio")return y.CMCDObjectType.AUDIO;if(i==="main")return this.hls.audioTracks.length?y.CMCDObjectType.VIDEO:y.CMCDObjectType.MUXED},p.getTopBandwidth=function(e){var i=0,t,r=this.hls;if(e===y.CMCDObjectType.AUDIO)t=r.audioTracks;else{var a=r.maxAutoLevel,n=a>-1?a+1:r.levels.length;t=r.levels.slice(0,n)}for(var h=_(t),d;!(d=h()).done;){var u=d.value;u.bitrate>i&&(i=u.bitrate)}return i>0?i:NaN},p.getBufferLength=function(e){var i=this.hls.media,t=e===y.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!t||!i)return NaN;var r=x.BufferHelper.bufferInfo(t,i.currentTime,this.config.maxBufferHole);return r.len*1e3},p.createPlaylistLoader=function(){var e=this.config.pLoader,i=this.applyPlaylistData,t=e||this.config.loader;return function(){function r(n){this.loader=void 0,this.loader=new t(n)}var a=r.prototype;return a.destroy=function(){this.loader.destroy()},a.abort=function(){this.loader.abort()},a.load=function(h,d,u){i(h),this.loader.load(h,d,u)},D(r,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),r}()},p.createFragmentLoader=function(){var e=this.config.fLoader,i=this.applyFragmentData,t=e||this.config.loader;return function(){function r(n){this.loader=void 0,this.loader=new t(n)}var a=r.prototype;return a.destroy=function(){this.loader.destroy()},a.abort=function(){this.loader.abort()},a.load=function(h,d,u){i(h),this.loader.load(h,d,u)},D(r,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),r}()},v.uuid=function(){var e=URL.createObjectURL(new Blob),i=e.toString();return URL.revokeObjectURL(e),i.substr(i.lastIndexOf("/")+1)},v.serialize=function(e){for(var i=[],t=function(M){return!Number.isNaN(M)&&M!=null&&M!==""&&M!==!1},r=function(M){return Math.round(M)},a=function(M){return r(M/100)*100},n=function(M){return encodeURIComponent(M)},h={br:r,d:r,bl:a,dl:a,mtp:a,nor:n,rtp:a,tb:r},d=Object.keys(e||{}).sort(),u=_(d),f;!(f=u()).done;){var l=f.value,o=e[l];if(!!t(o)&&!(l==="v"&&o===1)&&!(l=="pr"&&o===1)){var E=h[l];E&&(o=E(o));var m=typeof o,O=void 0;l==="ot"||l==="sf"||l==="st"?O=l+"="+o:m==="boolean"?O=l:m==="number"?O=l+"="+o:O=l+"="+JSON.stringify(o),i.push(O)}}return i.join(",")},v.toHeaders=function(e){for(var i=Object.keys(e),t={},r=["Object","Request","Session","Status"],a=[{},{},{},{}],n={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},h=0,d=i;h<d.length;h++){var u=d[h],f=n[u]!=null?n[u]:1;a[f][u]=e[u]}for(var l=0;l<a.length;l++){var o=v.serialize(a[l]);o&&(t["CMCD-"+r[l]]=o)}return t},v.toQuery=function(e){return"CMCD="+encodeURIComponent(v.serialize(e))},v.appendQueryToUri=function(e,i){if(!i)return e;var t=e.includes("?")?"&":"?";return""+e+t+i},v}()},"./src/controller/eme-controller.ts":function(k,b,c){"use strict";c.r(b);var R=c("./src/events.ts"),y=c("./src/errors.ts"),x=c("./src/utils/logger.ts"),I=c("./src/utils/mediakeys-helper.ts");function T(S,v){for(var p=0;p<v.length;p++){var s=v[p];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(S,s.key,s)}}function D(S,v,p){return v&&T(S.prototype,v),p&&T(S,p),S}var _=3,g=function(v,p,s){var e={audioCapabilities:[],videoCapabilities:[]};return v.forEach(function(i){e.audioCapabilities.push({contentType:'audio/mp4; codecs="'+i+'"',robustness:s.audioRobustness||""})}),p.forEach(function(i){e.videoCapabilities.push({contentType:'video/mp4; codecs="'+i+'"',robustness:s.videoRobustness||""})}),[e]},A=function(v,p,s,e){switch(v){case I.KeySystems.WIDEVINE:return g(p,s,e);default:throw new Error("Unknown key-system: "+v)}},L=function(){function S(p){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=p,this._config=p.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var v=S.prototype;return v.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},v._registerListeners=function(){this.hls.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(R.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this)},v._unregisterListeners=function(){this.hls.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(R.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this)},v.getLicenseServerUrl=function(s){switch(s){case I.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+s+'"')},v._attemptKeySystemAccess=function(s,e,i){var t=this,r=A(s,e,i,this._drmSystemOptions);x.logger.log("Requesting encrypted media key-system access");var a=this.requestMediaKeySystemAccess(s,r);this.mediaKeysPromise=a.then(function(n){return t._onMediaKeySystemAccessObtained(s,n)}),a.catch(function(n){x.logger.error('Failed to obtain key-system "'+s+'" access:',n)})},v._onMediaKeySystemAccessObtained=function(s,e){var i=this;x.logger.log('Access for key-system "'+s+'" obtained');var t={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:e,mediaKeySystemDomain:s};this._mediaKeysList.push(t);var r=Promise.resolve().then(function(){return e.createMediaKeys()}).then(function(a){return t.mediaKeys=a,x.logger.log('Media-keys created for key-system "'+s+'"'),i._onMediaKeysCreated(),a});return r.catch(function(a){x.logger.error("Failed to create media-keys:",a)}),r},v._onMediaKeysCreated=function(){var s=this;this._mediaKeysList.forEach(function(e){e.mediaKeysSession||(e.mediaKeysSession=e.mediaKeys.createSession(),s._onNewMediaKeySession(e.mediaKeysSession))})},v._onNewMediaKeySession=function(s){var e=this;x.logger.log("New key-system session "+s.sessionId),s.addEventListener("message",function(i){e._onKeySessionMessage(s,i.message)},!1)},v._onKeySessionMessage=function(s,e){x.logger.log("Got EME message event, creating license request"),this._requestLicense(e,function(i){x.logger.log("Received license data (length: "+(i&&i.byteLength)+"), updating key-session"),s.update(i)})},v.onMediaEncrypted=function(s){var e=this;if(x.logger.log('Media is encrypted using "'+s.initDataType+'" init data type'),!this.mediaKeysPromise){x.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(R.Events.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var i=function(r){!e._media||(e._attemptSetMediaKeys(r),e._generateRequestWithPreferredKeySession(s.initDataType,s.initData))};this.mediaKeysPromise.then(i).catch(i)},v._attemptSetMediaKeys=function(s){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var e=this._mediaKeysList[0];if(!e||!e.mediaKeys){x.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(R.Events.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}x.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}},v._generateRequestWithPreferredKeySession=function(s,e){var i=this,t=this._mediaKeysList[0];if(!t){x.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(R.Events.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(t.mediaKeysSessionInitialized){x.logger.warn("Key-Session already initialized but requested again");return}var r=t.mediaKeysSession;if(!r){x.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(R.Events.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!e){x.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(R.Events.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}x.logger.log('Generating key-session request for "'+s+'" init data type'),t.mediaKeysSessionInitialized=!0,r.generateRequest(s,e).then(function(){x.logger.debug("Key-session generation succeeded")}).catch(function(a){x.logger.error("Error generating key-session request:",a),i.hls.trigger(R.Events.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},v._createLicenseXhr=function(s,e,i){var t=new XMLHttpRequest;t.responseType="arraybuffer",t.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,t,s,e,i);var r=this._licenseXhrSetup;if(r)try{r.call(this.hls,t,s),r=void 0}catch(a){x.logger.error(a)}try{t.readyState||t.open("POST",s,!0),r&&r.call(this.hls,t,s)}catch(a){throw new Error("issue setting up KeySystem license XHR "+a)}return t},v._onLicenseRequestReadyStageChange=function(s,e,i,t){switch(s.readyState){case 4:if(s.status===200){this._requestLicenseFailureCount=0,x.logger.log("License request succeeded");var r=s.response,a=this._licenseResponseCallback;if(a)try{r=a.call(this.hls,s,e)}catch(h){x.logger.error(h)}t(r)}else{if(x.logger.error("License Request XHR failed ("+e+"). Status: "+s.status+" ("+s.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>_){this.hls.trigger(R.Events.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var n=_-this._requestLicenseFailureCount+1;x.logger.warn("Retrying license request, "+n+" attempts left"),this._requestLicense(i,t)}break}},v._generateLicenseRequestChallenge=function(s,e){switch(s.mediaKeySystemDomain){case I.KeySystems.WIDEVINE:return e}throw new Error("unsupported key-system: "+s.mediaKeySystemDomain)},v._requestLicense=function(s,e){x.logger.log("Requesting content license for key-system");var i=this._mediaKeysList[0];if(!i){x.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(R.Events.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var t=this.getLicenseServerUrl(i.mediaKeySystemDomain),r=this._createLicenseXhr(t,s,e);x.logger.log("Sending license request to URL: "+t);var a=this._generateLicenseRequestChallenge(i,s);r.send(a)}catch(n){x.logger.error("Failure requesting DRM license: "+n),this.hls.trigger(R.Events.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},v.onMediaAttached=function(s,e){if(!!this._emeEnabled){var i=e.media;this._media=i,i.addEventListener("encrypted",this._onMediaEncrypted)}},v.onMediaDetached=function(){var s=this._media,e=this._mediaKeysList;!s||(s.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(e.map(function(i){if(i.mediaKeysSession)return i.mediaKeysSession.close().catch(function(){})})).then(function(){return s.setMediaKeys(null)}).catch(function(){}))},v.onManifestParsed=function(s,e){if(!!this._emeEnabled){var i=e.levels.map(function(r){return r.audioCodec}).filter(function(r){return!!r}),t=e.levels.map(function(r){return r.videoCodec}).filter(function(r){return!!r});this._attemptKeySystemAccess(I.KeySystems.WIDEVINE,i,t)}},D(S,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),S}();b.default=L},"./src/controller/fps-controller.ts":function(k,b,c){"use strict";c.r(b);var R=c("./src/events.ts"),y=c("./src/utils/logger.ts"),x=function(){function I(D){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=D,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(_,g){var A=this.hls.config;if(A.capLevelOnFPSDrop){var L=g.media instanceof self.HTMLVideoElement?g.media:null;this.media=L,L&&typeof L.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),A.fpsDroppedMonitoringPeriod)}},T.checkFPS=function(_,g,A){var L=performance.now();if(g){if(this.lastTime){var S=L-this.lastTime,v=A-this.lastDroppedFrames,p=g-this.lastDecodedFrames,s=1e3*v/S,e=this.hls;if(e.trigger(R.Events.FPS_DROP,{currentDropped:v,currentDecoded:p,totalDroppedFrames:A}),s>0&&v>e.config.fpsDroppedMonitoringThreshold*p){var i=e.currentLevel;y.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+i),i>0&&(e.autoLevelCapping===-1||e.autoLevelCapping>=i)&&(i=i-1,e.trigger(R.Events.FPS_DROP_LEVEL_CAPPING,{level:i,droppedLevel:e.currentLevel}),e.autoLevelCapping=i,this.streamController.nextLevelSwitch())}}this.lastTime=L,this.lastDroppedFrames=A,this.lastDecodedFrames=g}},T.checkFPSInterval=function(){var _=this.media;if(_)if(this.isVideoPlaybackQualityAvailable){var g=_.getVideoPlaybackQuality();this.checkFPS(_,g.totalVideoFrames,g.droppedVideoFrames)}else this.checkFPS(_,_.webkitDecodedFrameCount,_.webkitDroppedFrameCount)},I}();b.default=x},"./src/controller/fragment-finders.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"findFragmentByPDT",function(){return x}),c.d(b,"findFragmentByPTS",function(){return I}),c.d(b,"fragmentWithinToleranceTest",function(){return T}),c.d(b,"pdtWithinToleranceTest",function(){return D}),c.d(b,"findFragWithCC",function(){return _});var R=c("./src/polyfills/number.ts"),y=c("./src/utils/binary-search.ts");function x(g,A,L){if(A===null||!Array.isArray(g)||!g.length||!Object(R.isFiniteNumber)(A))return null;var S=g[0].programDateTime;if(A<(S||0))return null;var v=g[g.length-1].endProgramDateTime;if(A>=(v||0))return null;L=L||0;for(var p=0;p<g.length;++p){var s=g[p];if(D(A,L,s))return s}return null}function I(g,A,L,S){L===void 0&&(L=0),S===void 0&&(S=0);var v=null;if(g?v=A[g.sn-A[0].sn+1]||null:L===0&&A[0].start===0&&(v=A[0]),v&&T(L,S,v)===0)return v;var p=y.default.search(A,T.bind(null,L,S));return p||v}function T(g,A,L){g===void 0&&(g=0),A===void 0&&(A=0);var S=Math.min(A,L.duration+(L.deltaPTS?L.deltaPTS:0));return L.start+L.duration-S<=g?1:L.start-S>g&&L.start?-1:0}function D(g,A,L){var S=Math.min(A,L.duration+(L.deltaPTS?L.deltaPTS:0))*1e3,v=L.endProgramDateTime||0;return v-S>g}function _(g,A){return y.default.search(g,function(L){return L.cc<A?1:L.cc>A?-1:0})}},"./src/controller/fragment-tracker.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"FragmentState",function(){return x}),c.d(b,"FragmentTracker",function(){return I});var R=c("./src/events.ts"),y=c("./src/types/loader.ts"),x;(function(_){_.NOT_LOADED="NOT_LOADED",_.BACKTRACKED="BACKTRACKED",_.APPENDING="APPENDING",_.PARTIAL="PARTIAL",_.OK="OK"})(x||(x={}));var I=function(){function _(A){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=A,this._registerListeners()}var g=_.prototype;return g._registerListeners=function(){var L=this.hls;L.on(R.Events.BUFFER_APPENDED,this.onBufferAppended,this),L.on(R.Events.FRAG_BUFFERED,this.onFragBuffered,this),L.on(R.Events.FRAG_LOADED,this.onFragLoaded,this)},g._unregisterListeners=function(){var L=this.hls;L.off(R.Events.BUFFER_APPENDED,this.onBufferAppended,this),L.off(R.Events.FRAG_BUFFERED,this.onFragBuffered,this),L.off(R.Events.FRAG_LOADED,this.onFragLoaded,this)},g.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},g.getAppendedFrag=function(L,S){if(S===y.PlaylistLevelType.MAIN){var v=this.activeFragment,p=this.activeParts;if(!v)return null;if(p)for(var s=p.length;s--;){var e=p[s],i=e?e.end:v.appendedPTS;if(e.start<=L&&i!==void 0&&L<=i)return s>9&&(this.activeParts=p.slice(s-9)),e}else if(v.start<=L&&v.appendedPTS!==void 0&&L<=v.appendedPTS)return v}return this.getBufferedFrag(L,S)},g.getBufferedFrag=function(L,S){for(var v=this.fragments,p=Object.keys(v),s=p.length;s--;){var e=v[p[s]];if((e==null?void 0:e.body.type)===S&&e.buffered){var i=e.body;if(i.start<=L&&L<=i.end)return i}}return null},g.detectEvictedFragments=function(L,S,v){var p=this;Object.keys(this.fragments).forEach(function(s){var e=p.fragments[s];if(!!e){if(!e.buffered){e.body.type===v&&p.removeFragment(e.body);return}var i=e.range[L];!i||i.time.some(function(t){var r=!p.isTimeBuffered(t.startPTS,t.endPTS,S);return r&&p.removeFragment(e.body),r})}})},g.detectPartialFragments=function(L){var S=this,v=this.timeRanges,p=L.frag,s=L.part;if(!(!v||p.sn==="initSegment")){var e=D(p),i=this.fragments[e];!i||(Object.keys(v).forEach(function(t){var r=p.elementaryStreams[t];if(!!r){var a=v[t],n=s!==null||r.partial===!0;i.range[t]=S.getBufferedTimes(p,s,n,a)}}),i.backtrack=i.loaded=null,Object.keys(i.range).length?i.buffered=!0:this.removeFragment(i.body))}},g.fragBuffered=function(L){var S=D(L),v=this.fragments[S];v&&(v.backtrack=v.loaded=null,v.buffered=!0)},g.getBufferedTimes=function(L,S,v,p){for(var s={time:[],partial:v},e=S?S.start:L.start,i=S?S.end:L.end,t=L.minEndPTS||i,r=L.maxStartPTS||e,a=0;a<p.length;a++){var n=p.start(a)-this.bufferPadding,h=p.end(a)+this.bufferPadding;if(r>=n&&t<=h){s.time.push({startPTS:Math.max(e,p.start(a)),endPTS:Math.min(i,p.end(a))});break}else if(e<h&&i>n)s.partial=!0,s.time.push({startPTS:Math.max(e,p.start(a)),endPTS:Math.min(i,p.end(a))});else if(i<=n)break}return s},g.getPartialFragment=function(L){var S=null,v,p,s,e=0,i=this.bufferPadding,t=this.fragments;return Object.keys(t).forEach(function(r){var a=t[r];!a||T(a)&&(p=a.body.start-i,s=a.body.end+i,L>=p&&L<=s&&(v=Math.min(L-p,s-L),e<=v&&(S=a.body,e=v)))}),S},g.getState=function(L){var S=D(L),v=this.fragments[S];return v?v.buffered?T(v)?x.PARTIAL:x.OK:v.backtrack?x.BACKTRACKED:x.APPENDING:x.NOT_LOADED},g.backtrack=function(L,S){var v=D(L),p=this.fragments[v];if(!p||p.backtrack)return null;var s=p.backtrack=S||p.loaded;return p.loaded=null,s},g.getBacktrackData=function(L){var S=D(L),v=this.fragments[S];if(v){var p,s=v.backtrack;if(s!=null&&(p=s.payload)!==null&&p!==void 0&&p.byteLength)return s;this.removeFragment(L)}return null},g.isTimeBuffered=function(L,S,v){for(var p,s,e=0;e<v.length;e++){if(p=v.start(e)-this.bufferPadding,s=v.end(e)+this.bufferPadding,L>=p&&S<=s)return!0;if(S<=p)return!1}return!1},g.onFragLoaded=function(L,S){var v=S.frag,p=S.part;if(!(v.sn==="initSegment"||v.bitrateTest||p)){var s=D(v);this.fragments[s]={body:v,loaded:S,backtrack:null,buffered:!1,range:Object.create(null)}}},g.onBufferAppended=function(L,S){var v=this,p=S.frag,s=S.part,e=S.timeRanges;if(p.type===y.PlaylistLevelType.MAIN)if(this.activeFragment=p,s){var i=this.activeParts;i||(this.activeParts=i=[]),i.push(s)}else this.activeParts=null;this.timeRanges=e,Object.keys(e).forEach(function(t){var r=e[t];if(v.detectEvictedFragments(t,r),!s)for(var a=0;a<r.length;a++)p.appendedPTS=Math.max(r.end(a),p.appendedPTS||0)})},g.onFragBuffered=function(L,S){this.detectPartialFragments(S)},g.hasFragment=function(L){var S=D(L);return!!this.fragments[S]},g.removeFragmentsInRange=function(L,S,v){var p=this;Object.keys(this.fragments).forEach(function(s){var e=p.fragments[s];if(!!e&&e.buffered){var i=e.body;i.type===v&&i.start<S&&i.end>L&&p.removeFragment(i)}})},g.removeFragment=function(L){var S=D(L);L.stats.loaded=0,L.clearElementaryStreamInfo(),delete this.fragments[S]},g.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},_}();function T(_){var g,A;return _.buffered&&(((g=_.range.video)===null||g===void 0?void 0:g.partial)||((A=_.range.audio)===null||A===void 0?void 0:A.partial))}function D(_){return _.type+"_"+_.level+"_"+_.urlId+"_"+_.sn}},"./src/controller/gap-controller.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"STALL_MINIMUM_DURATION_MS",function(){return T}),c.d(b,"MAX_START_GAP_JUMP",function(){return D}),c.d(b,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return _}),c.d(b,"SKIP_BUFFER_RANGE_START",function(){return g}),c.d(b,"default",function(){return A});var R=c("./src/utils/buffer-helper.ts"),y=c("./src/errors.ts"),x=c("./src/events.ts"),I=c("./src/utils/logger.ts"),T=250,D=2,_=.1,g=.05,A=function(){function L(v,p,s,e){this.config=void 0,this.media=void 0,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=v,this.media=p,this.fragmentTracker=s,this.hls=e}var S=L.prototype;return S.destroy=function(){this.hls=this.fragmentTracker=this.media=null},S.poll=function(p){var s=this.config,e=this.media,i=this.stalled,t=e.currentTime,r=e.seeking,a=this.seeking&&!r,n=!this.seeking&&r;if(this.seeking=r,t!==p){if(this.moved=!0,i!==null){if(this.stallReported){var h=self.performance.now()-i;I.logger.warn("playback not stuck anymore @"+t+", after "+Math.round(h)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((n||a)&&(this.stalled=null),!(e.paused||e.ended||e.playbackRate===0||!R.BufferHelper.getBuffered(e).length)){var d=R.BufferHelper.bufferInfo(e,t,0),u=d.len>0,f=d.nextStart||0;if(!(!u&&!f)){if(r){var l=d.len>D,o=!f||f-t>D&&!this.fragmentTracker.getPartialFragment(t);if(l||o)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var E,m=Math.max(f,d.start||0)-t,O=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,P=O==null||(E=O.details)===null||E===void 0?void 0:E.live,M=P?O.details.targetduration*2:D;if(m>0&&m<=M){this._trySkipBufferHole(null);return}}var F=self.performance.now();if(i===null){this.stalled=F;return}var B=F-i;!r&&B>=T&&this._reportStall(d.len);var C=R.BufferHelper.bufferInfo(e,t,s.maxBufferHole);this._tryFixBufferStall(C,B)}}},S._tryFixBufferStall=function(p,s){var e=this.config,i=this.fragmentTracker,t=this.media,r=t.currentTime,a=i.getPartialFragment(r);if(a){var n=this._trySkipBufferHole(a);if(n)return}p.len>e.maxBufferHole&&s>e.highBufferWatchdogPeriod*1e3&&(I.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},S._reportStall=function(p){var s=this.hls,e=this.media,i=this.stallReported;i||(this.stallReported=!0,I.logger.warn("Playback stalling at @"+e.currentTime+" due to low buffer (buffer="+p+")"),s.trigger(x.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:p}))},S._trySkipBufferHole=function(p){for(var s=this.config,e=this.hls,i=this.media,t=i.currentTime,r=0,a=R.BufferHelper.getBuffered(i),n=0;n<a.length;n++){var h=a.start(n);if(t+s.maxBufferHole>=r&&t<h){var d=Math.max(h+g,i.currentTime+_);return I.logger.warn("skipping hole, adjusting currentTime from "+t+" to "+d),this.moved=!0,this.stalled=null,i.currentTime=d,p&&e.trigger(x.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+t+" to "+d,frag:p}),d}r=a.end(n)}return 0},S._tryNudgeBuffer=function(){var p=this.config,s=this.hls,e=this.media,i=e.currentTime,t=(this.nudgeRetry||0)+1;if(this.nudgeRetry=t,t<p.nudgeMaxRetry){var r=i+t*p.nudgeOffset;I.logger.warn("Nudging 'currentTime' from "+i+" to "+r),e.currentTime=r,s.trigger(x.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else I.logger.error("Playhead still not moving while enough data buffered @"+i+" after "+p.nudgeMaxRetry+" nudges"),s.trigger(x.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},L}()},"./src/controller/id3-track-controller.ts":function(k,b,c){"use strict";c.r(b);var R=c("./src/events.ts"),y=c("./src/utils/texttrack-utils.ts"),x=c("./src/demux/id3.ts"),I=.25,T=function(){function D(g){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=g,this._registerListeners()}var _=D.prototype;return _.destroy=function(){this._unregisterListeners()},_._registerListeners=function(){var A=this.hls;A.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),A.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),A.on(R.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),A.on(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},_._unregisterListeners=function(){var A=this.hls;A.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),A.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),A.off(R.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),A.off(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},_.onMediaAttached=function(A,L){this.media=L.media},_.onMediaDetaching=function(){!this.id3Track||(Object(y.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null)},_.getID3Track=function(A){if(!!this.media){for(var L=0;L<A.length;L++){var S=A[L];if(S.kind==="metadata"&&S.label==="id3")return Object(y.sendAddTrackEvent)(S,this.media),S}return this.media.addTextTrack("metadata","id3")}},_.onFragParsingMetadata=function(A,L){if(!!this.media){var S=L.frag,v=L.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var p=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,s=0;s<v.length;s++){var e=x.getID3Frames(v[s].data);if(e){var i=v[s].pts,t=s<v.length-1?v[s+1].pts:S.end,r=t-i;r<=0&&(t=i+I);for(var a=0;a<e.length;a++){var n=e[a];if(!x.isTimeStampFrame(n)){var h=new p(i,t,"");h.value=n,this.id3Track.addCue(h)}}}}}},_.onBufferFlushing=function(A,L){var S=L.startOffset,v=L.endOffset,p=L.type;if(!p||p==="audio"){var s=this.id3Track;s&&Object(y.removeCuesInRange)(s,S,v)}},D}();b.default=T},"./src/controller/latency-controller.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"default",function(){return D});var R=c("./src/errors.ts"),y=c("./src/events.ts"),x=c("./src/utils/logger.ts");function I(_,g){for(var A=0;A<g.length;A++){var L=g[A];L.enumerable=L.enumerable||!1,L.configurable=!0,"value"in L&&(L.writable=!0),Object.defineProperty(_,L.key,L)}}function T(_,g,A){return g&&I(_.prototype,g),A&&I(_,A),_}var D=function(){function _(A){var L=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 L.timeupdate()},this.hls=A,this.config=A.config,this.registerListeners()}var g=_.prototype;return g.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},g.registerListeners=function(){this.hls.on(y.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(y.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(y.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(y.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(y.Events.ERROR,this.onError,this)},g.unregisterListeners=function(){this.hls.off(y.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(y.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(y.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(y.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(y.Events.ERROR,this.onError)},g.onMediaAttached=function(L,S){this.media=S.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},g.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},g.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},g.onLevelUpdated=function(L,S){var v=S.details;this.levelDetails=v,v.advanced&&this.timeupdate(),!v.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},g.onError=function(L,S){S.details===R.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,x.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},g.timeupdate=function(){var L=this.media,S=this.levelDetails;if(!(!L||!S)){this.currentTime=L.currentTime;var v=this.computeLatency();if(v!==null){this._latency=v;var p=this.config,s=p.lowLatencyMode,e=p.maxLiveSyncPlaybackRate;if(!(!s||e===1)){var i=this.targetLatency;if(i!==null){var t=v-i,r=Math.min(this.maxLatency,i+S.targetduration),a=t<r;if(S.live&&a&&t>.05&&this.forwardBufferLength>1){var n=Math.min(2,Math.max(1,e)),h=Math.round(2/(1+Math.exp(-.75*t-this.edgeStalled))*20)/20;L.playbackRate=Math.min(n,Math.max(1,h))}else L.playbackRate!==1&&L.playbackRate!==0&&(L.playbackRate=1)}}}}},g.estimateLiveEdge=function(){var L=this.levelDetails;return L===null?null:L.edge+L.age},g.computeLatency=function(){var L=this.estimateLiveEdge();return L===null?null:L-this.currentTime},T(_,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var L=this.config,S=this.levelDetails;return L.liveMaxLatencyDuration!==void 0?L.liveMaxLatencyDuration:S?L.liveMaxLatencyDurationCount*S.targetduration:0}},{key:"targetLatency",get:function(){var L=this.levelDetails;if(L===null)return null;var S=L.holdBack,v=L.partHoldBack,p=L.targetduration,s=this.config,e=s.liveSyncDuration,i=s.liveSyncDurationCount,t=s.lowLatencyMode,r=this.hls.userConfig,a=t&&v||S;(r.liveSyncDuration||r.liveSyncDurationCount||a===0)&&(a=e!==void 0?e:i*p);var n=p,h=1;return a+Math.min(this.stallCount*h,n)}},{key:"liveSyncPosition",get:function(){var L=this.estimateLiveEdge(),S=this.targetLatency,v=this.levelDetails;if(L===null||S===null||v===null)return null;var p=v.edge,s=L-S-this.edgeStalled,e=p-v.totalduration,i=p-(this.config.lowLatencyMode&&v.partTarget||v.targetduration);return Math.min(Math.max(e,s),i)}},{key:"drift",get:function(){var L=this.levelDetails;return L===null?1:L.drift}},{key:"edgeStalled",get:function(){var L=this.levelDetails;if(L===null)return 0;var S=(this.config.lowLatencyMode&&L.partTarget||L.targetduration)*3;return Math.max(L.age-S,0)}},{key:"forwardBufferLength",get:function(){var L=this.media,S=this.levelDetails;if(!L||!S)return 0;var v=L.buffered.length;return v?L.buffered.end(v-1):S.edge-this.currentTime}}]),_}()},"./src/controller/level-controller.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"default",function(){return s});var R=c("./src/types/level.ts"),y=c("./src/events.ts"),x=c("./src/errors.ts"),I=c("./src/utils/codecs.ts"),T=c("./src/controller/level-helper.ts"),D=c("./src/controller/base-playlist-controller.ts"),_=c("./src/types/loader.ts");function g(){return g=Object.assign||function(e){for(var i=1;i<arguments.length;i++){var t=arguments[i];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},g.apply(this,arguments)}function A(e,i){for(var t=0;t<i.length;t++){var r=i[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function L(e,i,t){return i&&A(e.prototype,i),t&&A(e,t),e}function S(e,i){e.prototype=Object.create(i.prototype),e.prototype.constructor=e,v(e,i)}function v(e,i){return v=Object.setPrototypeOf||function(r,a){return r.__proto__=a,r},v(e,i)}var p=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),s=function(e){S(i,e);function i(r){var a;return a=e.call(this,r,"[level-controller]")||this,a._levels=[],a._firstLevel=-1,a._startLevel=void 0,a.currentLevelIndex=-1,a.manualLevelIndex=-1,a.onParsedComplete=void 0,a._registerListeners(),a}var t=i.prototype;return t._registerListeners=function(){var a=this.hls;a.on(y.Events.MANIFEST_LOADED,this.onManifestLoaded,this),a.on(y.Events.LEVEL_LOADED,this.onLevelLoaded,this),a.on(y.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),a.on(y.Events.FRAG_LOADED,this.onFragLoaded,this),a.on(y.Events.ERROR,this.onError,this)},t._unregisterListeners=function(){var a=this.hls;a.off(y.Events.MANIFEST_LOADED,this.onManifestLoaded,this),a.off(y.Events.LEVEL_LOADED,this.onLevelLoaded,this),a.off(y.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),a.off(y.Events.FRAG_LOADED,this.onFragLoaded,this),a.off(y.Events.ERROR,this.onError,this)},t.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,e.prototype.destroy.call(this)},t.startLoad=function(){var a=this._levels;a.forEach(function(n){n.loadError=0}),e.prototype.startLoad.call(this)},t.onManifestLoaded=function(a,n){var h=[],d=[],u=[],f,l={},o,E=!1,m=!1,O=!1;if(n.levels.forEach(function(B){var C=B.attrs;E=E||!!(B.width&&B.height),m=m||!!B.videoCodec,O=O||!!B.audioCodec,p&&B.audioCodec&&B.audioCodec.indexOf("mp4a.40.34")!==-1&&(B.audioCodec=void 0);var U=B.bitrate+"-"+B.attrs.RESOLUTION+"-"+B.attrs.CODECS;o=l[U],o?o.url.push(B.url):(o=new R.Level(B),l[U]=o,h.push(o)),C&&(C.AUDIO&&Object(T.addGroupId)(o,"audio",C.AUDIO),C.SUBTITLES&&Object(T.addGroupId)(o,"text",C.SUBTITLES))}),(E||m)&&O&&(h=h.filter(function(B){var C=B.videoCodec,U=B.width,w=B.height;return!!C||!!(U&&w)})),h=h.filter(function(B){var C=B.audioCodec,U=B.videoCodec;return(!C||Object(I.isCodecSupportedInMp4)(C,"audio"))&&(!U||Object(I.isCodecSupportedInMp4)(U,"video"))}),n.audioTracks&&(d=n.audioTracks.filter(function(B){return!B.audioCodec||Object(I.isCodecSupportedInMp4)(B.audioCodec,"audio")}),Object(T.assignTrackIdsByGroup)(d)),n.subtitles&&(u=n.subtitles,Object(T.assignTrackIdsByGroup)(u)),h.length>0){f=h[0].bitrate,h.sort(function(B,C){return B.bitrate-C.bitrate}),this._levels=h;for(var P=0;P<h.length;P++)if(h[P].bitrate===f){this._firstLevel=P,this.log("manifest loaded, "+h.length+" level(s) found, first bitrate: "+f);break}var M=O&&!m,F={levels:h,audioTracks:d,subtitleTracks:u,firstLevel:this._firstLevel,stats:n.stats,audio:O,video:m,altAudio:!M&&d.some(function(B){return!!B.url})};this.hls.trigger(y.Events.MANIFEST_PARSED,F),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(y.Events.ERROR,{type:x.ErrorTypes.MEDIA_ERROR,details:x.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:n.url,reason:"no level with compatible codecs found in manifest"})},t.onError=function(a,n){if(e.prototype.onError.call(this,a,n),!n.fatal){var h=n.context,d=this._levels[this.currentLevelIndex];if(h&&(h.type===_.PlaylistContextType.AUDIO_TRACK&&d.audioGroupIds&&h.groupId===d.audioGroupIds[d.urlId]||h.type===_.PlaylistContextType.SUBTITLE_TRACK&&d.textGroupIds&&h.groupId===d.textGroupIds[d.urlId])){this.redundantFailover(this.currentLevelIndex);return}var u=!1,f=!0,l;switch(n.details){case x.ErrorDetails.FRAG_LOAD_ERROR:case x.ErrorDetails.FRAG_LOAD_TIMEOUT:case x.ErrorDetails.KEY_LOAD_ERROR:case x.ErrorDetails.KEY_LOAD_TIMEOUT:if(n.frag){var o=this._levels[n.frag.level];o?(o.fragmentError++,o.fragmentError>this.hls.config.fragLoadingMaxRetry&&(l=n.frag.level)):l=n.frag.level}break;case x.ErrorDetails.LEVEL_LOAD_ERROR:case x.ErrorDetails.LEVEL_LOAD_TIMEOUT:h&&(h.deliveryDirectives&&(f=!1),l=h.level),u=!0;break;case x.ErrorDetails.REMUX_ALLOC_ERROR:l=n.level,u=!0;break}l!==void 0&&this.recoverLevel(n,l,u,f)}},t.recoverLevel=function(a,n,h,d){var u=a.details,f=this._levels[n];if(f.loadError++,h){var l=this.retryLoadingOrFail(a);if(l)a.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(d){var o=f.url.length;if(o>1&&f.loadError<o)a.levelRetry=!0,this.redundantFailover(n);else if(this.manualLevelIndex===-1){var E=n===0?this._levels.length-1:n-1;this.currentLevelIndex!==E&&this._levels[E].loadError===0&&(this.warn(u+": switch to "+E),a.levelRetry=!0,this.hls.nextAutoLevel=E)}}},t.redundantFailover=function(a){var n=this._levels[a],h=n.url.length;if(h>1){var d=(n.urlId+1)%h;this.warn("Switching to redundant URL-id "+d),this._levels.forEach(function(u){u.urlId=d}),this.level=a}},t.onFragLoaded=function(a,n){var h=n.frag;if(h!==void 0&&h.type===_.PlaylistLevelType.MAIN){var d=this._levels[h.level];d!==void 0&&(d.fragmentError=0,d.loadError=0)}},t.onLevelLoaded=function(a,n){var h,d=n.level,u=n.details,f=this._levels[d];if(!f){var l;this.warn("Invalid level index "+d),(l=n.deliveryDirectives)!==null&&l!==void 0&&l.skip&&(u.deltaUpdateFailed=!0);return}d===this.currentLevelIndex?(f.fragmentError===0&&(f.loadError=0,this.retryCount=0),this.playlistLoaded(d,n,f.details)):(h=n.deliveryDirectives)!==null&&h!==void 0&&h.skip&&(u.deltaUpdateFailed=!0)},t.onAudioTrackSwitched=function(a,n){var h=this.hls.levels[this.currentLevelIndex];if(!!h&&h.audioGroupIds){for(var d=-1,u=this.hls.audioTracks[n.id].groupId,f=0;f<h.audioGroupIds.length;f++)if(h.audioGroupIds[f]===u){d=f;break}d!==h.urlId&&(h.urlId=d,this.startLoad())}},t.loadPlaylist=function(a){var n=this.currentLevelIndex,h=this._levels[n];if(this.canLoad&&h&&h.url.length>0){var d=h.urlId,u=h.url[d];if(a)try{u=a.addDirectives(u)}catch(f){this.warn("Could not construct new URL with HLS Delivery Directives: "+f)}this.log("Attempt loading level index "+n+(a?" at sn "+a.msn+" part "+a.part:"")+" with URL-id "+d+" "+u),this.clearTimer(),this.hls.trigger(y.Events.LEVEL_LOADING,{url:u,level:n,id:d,deliveryDirectives:a||null})}},t.removeLevel=function(a,n){var h=function(f,l){return l!==n},d=this._levels.filter(function(u,f){return f!==a?!0:u.url.length>1&&n!==void 0?(u.url=u.url.filter(h),u.audioGroupIds&&(u.audioGroupIds=u.audioGroupIds.filter(h)),u.textGroupIds&&(u.textGroupIds=u.textGroupIds.filter(h)),u.urlId=0,!0):!1}).map(function(u,f){var l=u.details;return l!=null&&l.fragments&&l.fragments.forEach(function(o){o.level=f}),u});this._levels=d,this.hls.trigger(y.Events.LEVELS_UPDATED,{levels:d})},L(i,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(a){var n,h=this._levels;if(h.length!==0&&!(this.currentLevelIndex===a&&(n=h[a])!==null&&n!==void 0&&n.details)){if(a<0||a>=h.length){var d=a<0;if(this.hls.trigger(y.Events.ERROR,{type:x.ErrorTypes.OTHER_ERROR,details:x.ErrorDetails.LEVEL_SWITCH_ERROR,level:a,fatal:d,reason:"invalid level idx"}),d)return;a=Math.min(a,h.length-1)}this.clearTimer();var u=this.currentLevelIndex,f=h[u],l=h[a];this.log("switching to level "+a+" from "+u),this.currentLevelIndex=a;var o=g({},l,{level:a,maxBitrate:l.maxBitrate,uri:l.uri,urlId:l.urlId});delete o._urlId,this.hls.trigger(y.Events.LEVEL_SWITCHING,o);var E=l.details;if(!E||E.live){var m=this.switchParams(l.uri,f==null?void 0:f.details);this.loadPlaylist(m)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(a){this.manualLevelIndex=a,this._startLevel===void 0&&(this._startLevel=a),a!==-1&&(this.level=a)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(a){this._firstLevel=a}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var a=this.hls.config.startLevel;return a!==void 0?a:this._firstLevel}else return this._startLevel},set:function(a){this._startLevel=a}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(a){this.level=a,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=a)}}]),i}(D.default)},"./src/controller/level-helper.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"addGroupId",function(){return x}),c.d(b,"assignTrackIdsByGroup",function(){return I}),c.d(b,"updatePTS",function(){return T}),c.d(b,"updateFragPTSDTS",function(){return _}),c.d(b,"mergeDetails",function(){return g}),c.d(b,"mapPartIntersection",function(){return A}),c.d(b,"mapFragmentIntersection",function(){return L}),c.d(b,"adjustSliding",function(){return S}),c.d(b,"addSliding",function(){return v}),c.d(b,"computeReloadInterval",function(){return p}),c.d(b,"getFragmentWithSN",function(){return s}),c.d(b,"getPartWith",function(){return e});var R=c("./src/polyfills/number.ts"),y=c("./src/utils/logger.ts");function x(i,t,r){switch(t){case"audio":i.audioGroupIds||(i.audioGroupIds=[]),i.audioGroupIds.push(r);break;case"text":i.textGroupIds||(i.textGroupIds=[]),i.textGroupIds.push(r);break}}function I(i){var t={};i.forEach(function(r){var a=r.groupId||"";r.id=t[a]=t[a]||0,t[a]++})}function T(i,t,r){var a=i[t],n=i[r];D(a,n)}function D(i,t){var r=t.startPTS;if(Object(R.isFiniteNumber)(r)){var a=0,n;t.sn>i.sn?(a=r-i.start,n=i):(a=i.start-r,n=t),n.duration!==a&&(n.duration=a)}else if(t.sn>i.sn){var h=i.cc===t.cc;h&&i.minEndPTS?t.start=i.start+(i.minEndPTS-i.start):t.start=i.start+i.duration}else t.start=Math.max(i.start-t.duration,0)}function _(i,t,r,a,n,h){var d=a-r;d<=0&&(y.logger.warn("Fragment should have a positive duration",t),a=r+t.duration,h=n+t.duration);var u=r,f=a,l=t.startPTS,o=t.endPTS;if(Object(R.isFiniteNumber)(l)){var E=Math.abs(l-r);Object(R.isFiniteNumber)(t.deltaPTS)?t.deltaPTS=Math.max(E,t.deltaPTS):t.deltaPTS=E,u=Math.max(r,l),r=Math.min(r,l),n=Math.min(n,t.startDTS),f=Math.min(a,o),a=Math.max(a,o),h=Math.max(h,t.endDTS)}t.duration=a-r;var m=r-t.start;t.appendedPTS=a,t.start=t.startPTS=r,t.maxStartPTS=u,t.startDTS=n,t.endPTS=a,t.minEndPTS=f,t.endDTS=h;var O=t.sn;if(!i||O<i.startSN||O>i.endSN)return 0;var P,M=O-i.startSN,F=i.fragments;for(F[M]=t,P=M;P>0;P--)D(F[P],F[P-1]);for(P=M;P<F.length-1;P++)D(F[P],F[P+1]);return i.fragmentHint&&D(F[F.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,m}function g(i,t){for(var r=null,a=i.fragments,n=a.length-1;n>=0;n--){var h=a[n].initSegment;if(h){r=h;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;var d=0,u;if(L(i,t,function(P,M){P.relurl&&(d=P.cc-M.cc),Object(R.isFiniteNumber)(P.startPTS)&&Object(R.isFiniteNumber)(P.endPTS)&&(M.start=M.startPTS=P.startPTS,M.startDTS=P.startDTS,M.appendedPTS=P.appendedPTS,M.maxStartPTS=P.maxStartPTS,M.endPTS=P.endPTS,M.endDTS=P.endDTS,M.minEndPTS=P.minEndPTS,M.duration=P.endPTS-P.startPTS,M.duration&&(u=M),t.PTSKnown=t.alignedSliding=!0),M.elementaryStreams=P.elementaryStreams,M.loader=P.loader,M.stats=P.stats,M.urlId=P.urlId,P.initSegment&&(M.initSegment=P.initSegment,r=P.initSegment)}),r){var f=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments;f.forEach(function(P){var M;(!P.initSegment||P.initSegment.relurl===((M=r)===null||M===void 0?void 0:M.relurl))&&(P.initSegment=r)})}if(t.skippedSegments&&(t.deltaUpdateFailed=t.fragments.some(function(P){return!P}),t.deltaUpdateFailed)){y.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var l=t.skippedSegments;l--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}var o=t.fragments;if(d){y.logger.warn("discontinuity sliding from playlist, take drift into account");for(var E=0;E<o.length;E++)o[E].cc+=d}t.skippedSegments&&(t.startCC=t.fragments[0].cc),A(i.partList,t.partList,function(P,M){M.elementaryStreams=P.elementaryStreams,M.stats=P.stats}),u?_(t,u,u.startPTS,u.endPTS,u.startDTS,u.endDTS):S(i,t),o.length&&(t.totalduration=t.edge-o[0].start),t.driftStartTime=i.driftStartTime,t.driftStart=i.driftStart;var m=t.advancedDateTime;if(t.advanced&&m){var O=t.edge;t.driftStart||(t.driftStartTime=m,t.driftStart=O),t.driftEndTime=m,t.driftEnd=O}else t.driftEndTime=i.driftEndTime,t.driftEnd=i.driftEnd,t.advancedDateTime=i.advancedDateTime}function A(i,t,r){if(i&&t)for(var a=0,n=0,h=i.length;n<=h;n++){var d=i[n],u=t[n+a];d&&u&&d.index===u.index&&d.fragment.sn===u.fragment.sn?r(d,u):a--}}function L(i,t,r){for(var a=t.skippedSegments,n=Math.max(i.startSN,t.startSN)-t.startSN,h=(i.fragmentHint?1:0)+(a?t.endSN:Math.min(i.endSN,t.endSN))-t.startSN,d=t.startSN-i.startSN,u=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,f=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,l=n;l<=h;l++){var o=f[d+l],E=u[l];a&&!E&&l<a&&(E=t.fragments[l]=o),o&&E&&r(o,E)}}function S(i,t){var r=t.startSN+t.skippedSegments-i.startSN,a=i.fragments;r<0||r>=a.length||v(t,a[r].start)}function v(i,t){if(t){for(var r=i.fragments,a=i.skippedSegments;a<r.length;a++)r[a].start+=t;i.fragmentHint&&(i.fragmentHint.start+=t)}}function p(i,t){var r=1e3*i.levelTargetDuration,a=r/2,n=i.age,h=n>0&&n<r*3,d=t.loading.end-t.loading.start,u,f=i.availabilityDelay;if(i.updated===!1)if(h){var l=333*i.misses;u=Math.max(Math.min(a,d*2),l),i.availabilityDelay=(i.availabilityDelay||0)+u}else u=a;else h?(f=Math.min(f||r/2,n),i.availabilityDelay=f,u=f+r-n):u=r-d;return Math.round(u)}function s(i,t,r){if(!i||!i.details)return null;var a=i.details,n=a.fragments[t-a.startSN];return n||(n=a.fragmentHint,n&&n.sn===t)?n:t<a.startSN&&r&&r.sn===t?r:null}function e(i,t,r){if(!i||!i.details)return null;var a=i.details.partList;if(a)for(var n=a.length;n--;){var h=a[n];if(h.index===r&&h.fragment.sn===t)return h}return null}},"./src/controller/stream-controller.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"default",function(){return a});var R=c("./src/polyfills/number.ts"),y=c("./src/controller/base-stream-controller.ts"),x=c("./src/is-supported.ts"),I=c("./src/events.ts"),T=c("./src/utils/buffer-helper.ts"),D=c("./src/controller/fragment-tracker.ts"),_=c("./src/types/loader.ts"),g=c("./src/loader/fragment.ts"),A=c("./src/demux/transmuxer-interface.ts"),L=c("./src/types/transmuxer.ts"),S=c("./src/controller/gap-controller.ts"),v=c("./src/errors.ts"),p=c("./src/utils/logger.ts");function s(n,h){for(var d=0;d<h.length;d++){var u=h[d];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(n,u.key,u)}}function e(n,h,d){return h&&s(n.prototype,h),d&&s(n,d),n}function i(n,h){n.prototype=Object.create(h.prototype),n.prototype.constructor=n,t(n,h)}function t(n,h){return t=Object.setPrototypeOf||function(u,f){return u.__proto__=f,u},t(n,h)}var r=100,a=function(n){i(h,n);function h(u,f){var l;return l=n.call(this,u,f,"[stream-controller]")||this,l.audioCodecSwap=!1,l.gapController=null,l.level=-1,l._forceStartLoad=!1,l.altAudio=!1,l.audioOnly=!1,l.fragPlaying=null,l.onvplaying=null,l.onvseeked=null,l.fragLastKbps=0,l.stalled=!1,l.couldBacktrack=!1,l.audioCodecSwitch=!1,l.videoBuffer=null,l._registerListeners(),l}var d=h.prototype;return d._registerListeners=function(){var f=this.hls;f.on(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),f.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),f.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),f.on(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),f.on(I.Events.LEVEL_LOADING,this.onLevelLoading,this),f.on(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),f.on(I.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),f.on(I.Events.ERROR,this.onError,this),f.on(I.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),f.on(I.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),f.on(I.Events.BUFFER_CREATED,this.onBufferCreated,this),f.on(I.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),f.on(I.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),f.on(I.Events.FRAG_BUFFERED,this.onFragBuffered,this)},d._unregisterListeners=function(){var f=this.hls;f.off(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),f.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),f.off(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),f.off(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),f.off(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),f.off(I.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),f.off(I.Events.ERROR,this.onError,this),f.off(I.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),f.off(I.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),f.off(I.Events.BUFFER_CREATED,this.onBufferCreated,this),f.off(I.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),f.off(I.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),f.off(I.Events.FRAG_BUFFERED,this.onFragBuffered,this)},d.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},d.startLoad=function(f){if(this.levels){var l=this.lastCurrentTime,o=this.hls;if(this.stopLoad(),this.setInterval(r),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var E=o.startLevel;E===-1&&(o.config.testBandwidth?(E=0,this.bitrateTest=!0):E=o.nextAutoLevel),this.level=o.nextLoadLevel=E,this.loadedmetadata=!1}l>0&&f===-1&&(this.log("Override startPosition with lastCurrentTime @"+l.toFixed(3)),f=l),this.state=y.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=f,this.tick()}else this._forceStartLoad=!0,this.state=y.State.STOPPED},d.stopLoad=function(){this._forceStartLoad=!1,n.prototype.stopLoad.call(this)},d.doTick=function(){switch(this.state){case y.State.IDLE:this.doTickIdle();break;case y.State.WAITING_LEVEL:{var f,l=this.levels,o=this.level,E=l==null||(f=l[o])===null||f===void 0?void 0:f.details;if(E&&(!E.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(E))break;this.state=y.State.IDLE;break}break}case y.State.FRAG_LOADING_WAITING_RETRY:{var m,O=self.performance.now(),P=this.retryDate;(!P||O>=P||(m=this.media)!==null&&m!==void 0&&m.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=y.State.IDLE)}break;default:break}this.onTickEnd()},d.onTickEnd=function(){n.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},d.doTickIdle=function(){var f,l,o=this.hls,E=this.levelLastLoaded,m=this.levels,O=this.media,P=o.config,M=o.nextLoadLevel;if(!(E===null||!O&&(this.startFragRequested||!P.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!m||!m[M])){var F=m[M];this.level=o.nextLoadLevel=M;var B=F.details;if(!B||this.state===y.State.WAITING_LEVEL||B.live&&this.levelLastLoaded!==M){this.state=y.State.WAITING_LEVEL;return}var C=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:O,_.PlaylistLevelType.MAIN);if(C!==null){var U=C.len,w=this.getMaxBufferLength(F.maxBitrate);if(!(U>=w)){if(this._streamEnded(C,B)){var N={};this.altAudio&&(N.type="video"),this.hls.trigger(I.Events.BUFFER_EOS,N),this.state=y.State.ENDED;return}var j=C.end,K=this.getNextFragment(j,B);if(this.couldBacktrack&&!this.fragPrevious&&K&&K.sn!=="initSegment"){var G=K.sn-B.startSN;G>1&&(K=B.fragments[G-1],this.fragmentTracker.removeFragment(K))}if(K&&this.fragmentTracker.getState(K)===D.FragmentState.OK&&this.nextLoadPosition>j){var Y=this.audioOnly&&!this.altAudio?g.ElementaryStreamTypes.AUDIO:g.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(O,Y,_.PlaylistLevelType.MAIN),K=this.getNextFragment(this.nextLoadPosition,B)}!K||(K.initSegment&&!K.initSegment.data&&!this.bitrateTest&&(K=K.initSegment),((f=K.decryptdata)===null||f===void 0?void 0:f.keyFormat)==="identity"&&!((l=K.decryptdata)!==null&&l!==void 0&&l.key)?this.loadKey(K,B):this.loadFragment(K,B,j))}}}},d.loadFragment=function(f,l,o){var E,m=this.fragmentTracker.getState(f);if(this.fragCurrent=f,m===D.FragmentState.BACKTRACKED){var O=this.fragmentTracker.getBacktrackData(f);if(O){this._handleFragmentLoadProgress(O),this._handleFragmentLoadComplete(O);return}else m=D.FragmentState.NOT_LOADED}m===D.FragmentState.NOT_LOADED||m===D.FragmentState.PARTIAL?f.sn==="initSegment"?this._loadInitSegment(f):this.bitrateTest?(f.bitrateTest=!0,this.log("Fragment "+f.sn+" of level "+f.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(f)):(this.startFragRequested=!0,n.prototype.loadFragment.call(this,f,l,o)):m===D.FragmentState.APPENDING?this.reduceMaxBufferLength(f.duration)&&this.fragmentTracker.removeFragment(f):((E=this.media)===null||E===void 0?void 0:E.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},d.getAppendedFrag=function(f){var l=this.fragmentTracker.getAppendedFrag(f,_.PlaylistLevelType.MAIN);return l&&"fragment"in l?l.fragment:l},d.getBufferedFrag=function(f){return this.fragmentTracker.getBufferedFrag(f,_.PlaylistLevelType.MAIN)},d.followingBufferedFrag=function(f){return f?this.getBufferedFrag(f.end+.5):null},d.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},d.nextLevelSwitch=function(){var f=this.levels,l=this.media;if(l!=null&&l.readyState){var o,E=this.getAppendedFrag(l.currentTime);if(E&&E.start>1&&this.flushMainBuffer(0,E.start-1),!l.paused&&f){var m=this.hls.nextLoadLevel,O=f[m],P=this.fragLastKbps;P&&this.fragCurrent?o=this.fragCurrent.duration*O.maxBitrate/(1e3*P)+1:o=0}else o=0;var M=this.getBufferedFrag(l.currentTime+o);if(M){var F=this.followingBufferedFrag(M);if(F){this.abortCurrentFrag();var B=F.maxStartPTS?F.maxStartPTS:F.start,C=F.duration,U=Math.max(M.end,B+Math.min(Math.max(C-this.config.maxFragLookUpTolerance,C*.5),C*.75));this.flushMainBuffer(U,Number.POSITIVE_INFINITY)}}}},d.abortCurrentFrag=function(){var f=this.fragCurrent;this.fragCurrent=null,f!=null&&f.loader&&f.loader.abort(),this.state===y.State.KEY_LOADING&&(this.state=y.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},d.flushMainBuffer=function(f,l){n.prototype.flushMainBuffer.call(this,f,l,this.altAudio?"video":null)},d.onMediaAttached=function(f,l){n.prototype.onMediaAttached.call(this,f,l);var o=l.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),o.addEventListener("playing",this.onvplaying),o.addEventListener("seeked",this.onvseeked),this.gapController=new S.default(this.config,o,this.fragmentTracker,this.hls)},d.onMediaDetaching=function(){var f=this.media;f&&(f.removeEventListener("playing",this.onvplaying),f.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),n.prototype.onMediaDetaching.call(this)},d.onMediaPlaying=function(){this.tick()},d.onMediaSeeked=function(){var f=this.media,l=f?f.currentTime:null;Object(R.isFiniteNumber)(l)&&this.log("Media seeked to "+l.toFixed(3)),this.tick()},d.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(I.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},d.onManifestParsed=function(f,l){var o=!1,E=!1,m;l.levels.forEach(function(O){m=O.audioCodec,m&&(m.indexOf("mp4a.40.2")!==-1&&(o=!0),m.indexOf("mp4a.40.5")!==-1&&(E=!0))}),this.audioCodecSwitch=o&&E&&!Object(x.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=l.levels,this.startFragRequested=!1},d.onLevelLoading=function(f,l){var o=this.levels;if(!(!o||this.state!==y.State.IDLE)){var E=o[l.level];(!E.details||E.details.live&&this.levelLastLoaded!==l.level||this.waitForCdnTuneIn(E.details))&&(this.state=y.State.WAITING_LEVEL)}},d.onLevelLoaded=function(f,l){var o,E=this.levels,m=l.level,O=l.details,P=O.totalduration;if(!E){this.warn("Levels were reset while loading level "+m);return}this.log("Level "+m+" loaded ["+O.startSN+","+O.endSN+"], cc ["+O.startCC+", "+O.endCC+"] duration:"+P);var M=this.fragCurrent;M&&(this.state===y.State.FRAG_LOADING||this.state===y.State.FRAG_LOADING_WAITING_RETRY)&&M.level!==l.level&&M.loader&&(this.state=y.State.IDLE,M.loader.abort());var F=E[m],B=0;if(O.live||(o=F.details)!==null&&o!==void 0&&o.live){if(O.fragments[0]||(O.deltaUpdateFailed=!0),O.deltaUpdateFailed)return;B=this.alignPlaylists(O,F.details)}if(F.details=O,this.levelLastLoaded=m,this.hls.trigger(I.Events.LEVEL_UPDATED,{details:O,level:m}),this.state===y.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(O))return;this.state=y.State.IDLE}this.startFragRequested?O.live&&this.synchronizeToLiveEdge(O):this.setStartPosition(O,B),this.tick()},d._handleFragmentLoadProgress=function(f){var l,o=f.frag,E=f.part,m=f.payload,O=this.levels;if(!O){this.warn("Levels were reset while fragment load was in progress. Fragment "+o.sn+" of level "+o.level+" will not be buffered");return}var P=O[o.level],M=P.details;if(!M){this.warn("Dropping fragment "+o.sn+" of level "+o.level+" after level details were reset");return}var F=P.videoCodec,B=M.PTSKnown||!M.live,C=(l=o.initSegment)===null||l===void 0?void 0:l.data,U=this._getAudioCodec(P),w=this.transmuxer=this.transmuxer||new A.default(this.hls,_.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),N=E?E.index:-1,j=N!==-1,K=new L.ChunkMetadata(o.level,o.sn,o.stats.chunkCount,m.byteLength,N,j),G=this.initPTS[o.cc];w.push(m,C,U,F,o,E,M.totalduration,B,K,G)},d.onAudioTrackSwitching=function(f,l){var o=this.altAudio,E=!!l.url,m=l.id;if(!E){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var O=this.fragCurrent;O!=null&&O.loader&&(this.log("Switching to main audio track, cancel main fragment load"),O.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var P=this.hls;o&&P.trigger(I.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),P.trigger(I.Events.AUDIO_TRACK_SWITCHED,{id:m})}},d.onAudioTrackSwitched=function(f,l){var o=l.id,E=!!this.hls.audioTracks[o].url;if(E){var m=this.videoBuffer;m&&this.mediaBuffer!==m&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=m)}this.altAudio=E,this.tick()},d.onBufferCreated=function(f,l){var o=l.tracks,E,m,O=!1;for(var P in o){var M=o[P];if(M.id==="main"){if(m=P,E=M,P==="video"){var F=o[P];F&&(this.videoBuffer=F.buffer)}}else O=!0}O&&E?(this.log("Alternate track found, use "+m+".buffered to schedule main fragment loading"),this.mediaBuffer=E.buffer):this.mediaBuffer=this.media},d.onFragBuffered=function(f,l){var o=l.frag,E=l.part;if(!(o&&o.type!==_.PlaylistLevelType.MAIN)){if(this.fragContextChanged(o)){this.warn("Fragment "+o.sn+(E?" p: "+E.index:"")+" of level "+o.level+" finished buffering, but was aborted. state: "+this.state),this.state===y.State.PARSED&&(this.state=y.State.IDLE);return}var m=E?E.stats:o.stats;this.fragLastKbps=Math.round(8*m.total/(m.buffering.end-m.loading.first)),o.sn!=="initSegment"&&(this.fragPrevious=o),this.fragBufferedComplete(o,E)}},d.onError=function(f,l){switch(l.details){case v.ErrorDetails.FRAG_LOAD_ERROR:case v.ErrorDetails.FRAG_LOAD_TIMEOUT:case v.ErrorDetails.KEY_LOAD_ERROR:case v.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_.PlaylistLevelType.MAIN,l);break;case v.ErrorDetails.LEVEL_LOAD_ERROR:case v.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==y.State.ERROR&&(l.fatal?(this.warn(""+l.details),this.state=y.State.ERROR):!l.levelRetry&&this.state===y.State.WAITING_LEVEL&&(this.state=y.State.IDLE));break;case v.ErrorDetails.BUFFER_FULL_ERROR:if(l.parent==="main"&&(this.state===y.State.PARSING||this.state===y.State.PARSED)){var o=!0,E=this.getFwdBufferInfo(this.media,_.PlaylistLevelType.MAIN);E&&E.len>.5&&(o=!this.reduceMaxBufferLength(E.len)),o&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},d.checkBuffer=function(){var f=this.media,l=this.gapController;if(!(!f||!l||!f.readyState)){var o=T.BufferHelper.getBuffered(f);!this.loadedmetadata&&o.length?(this.loadedmetadata=!0,this.seekToStartPos()):l.poll(this.lastCurrentTime),this.lastCurrentTime=f.currentTime}},d.onFragLoadEmergencyAborted=function(){this.state=y.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},d.onBufferFlushed=function(f,l){var o=l.type;if(o!==g.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var E=(o===g.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(E,o,_.PlaylistLevelType.MAIN)}},d.onLevelsUpdated=function(f,l){this.levels=l.levels},d.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},d.seekToStartPos=function(){var f=this.media,l=f.currentTime,o=this.startPosition;if(o>=0&&l<o){if(f.seeking){p.logger.log("could not seek to "+o+", already seeking at "+l);return}var E=T.BufferHelper.getBuffered(f),m=E.length?E.start(0):0,O=m-o;O>0&&(O<this.config.maxBufferHole||O<this.config.maxFragLookUpTolerance)&&(p.logger.log("adjusting start position by "+O+" to match buffer start"),o+=O,this.startPosition=o),this.log("seek to target start position "+o+" from current time "+l),f.currentTime=o}},d._getAudioCodec=function(f){var l=this.config.defaultAudioCodec||f.audioCodec;return this.audioCodecSwap&&l&&(this.log("Swapping audio codec"),l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5"),l},d._loadBitrateTestFrag=function(f){var l=this;this._doFragLoad(f).then(function(o){var E=l.hls;if(!(!o||E.nextLoadLevel||l.fragContextChanged(f))){l.fragLoadError=0,l.state=y.State.IDLE,l.startFragRequested=!1,l.bitrateTest=!1;var m=f.stats;m.parsing.start=m.parsing.end=m.buffering.start=m.buffering.end=self.performance.now(),E.trigger(I.Events.FRAG_LOADED,o)}})},d._handleTransmuxComplete=function(f){var l,o="main",E=this.hls,m=f.remuxResult,O=f.chunkMeta,P=this.getCurrentContext(O);if(!P){this.warn("The loading context changed while buffering fragment "+O.sn+" of level "+O.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(O.level);return}var M=P.frag,F=P.part,B=P.level,C=m.video,U=m.text,w=m.id3,N=m.initSegment,j=this.altAudio?void 0:m.audio;if(!this.fragContextChanged(M)){if(this.state=y.State.PARSING,N){N.tracks&&(this._bufferInitSegment(B,N.tracks,M,O),E.trigger(I.Events.FRAG_PARSING_INIT_SEGMENT,{frag:M,id:o,tracks:N.tracks}));var K=N.initPTS,G=N.timescale;Object(R.isFiniteNumber)(K)&&(this.initPTS[M.cc]=K,E.trigger(I.Events.INIT_PTS_FOUND,{frag:M,id:o,initPTS:K,timescale:G}))}if(C&&m.independent!==!1){if(B.details){var Y=C.startPTS,V=C.endPTS,Z=C.startDTS,z=C.endDTS;if(F)F.elementaryStreams[C.type]={startPTS:Y,endPTS:V,startDTS:Z,endDTS:z};else if(C.firstKeyFrame&&C.independent&&(this.couldBacktrack=!0),C.dropped&&C.independent){var ie=this.getLoadPosition()+this.config.maxBufferHole;if(ie<Y){this.backtrack(M);return}M.setElementaryStreamInfo(C.type,M.start,V,M.start,z,!0)}M.setElementaryStreamInfo(C.type,Y,V,Z,z),this.bufferFragmentData(C,M,F,O)}}else if(m.independent===!1){this.backtrack(M);return}if(j){var X=j.startPTS,ee=j.endPTS,ce=j.startDTS,ae=j.endDTS;F&&(F.elementaryStreams[g.ElementaryStreamTypes.AUDIO]={startPTS:X,endPTS:ee,startDTS:ce,endDTS:ae}),M.setElementaryStreamInfo(g.ElementaryStreamTypes.AUDIO,X,ee,ce,ae),this.bufferFragmentData(j,M,F,O)}if(w!=null&&(l=w.samples)!==null&&l!==void 0&&l.length){var ve={frag:M,id:o,samples:w.samples};E.trigger(I.Events.FRAG_PARSING_METADATA,ve)}if(U){var q={frag:M,id:o,samples:U.samples};E.trigger(I.Events.FRAG_PARSING_USERDATA,q)}}},d._bufferInitSegment=function(f,l,o,E){var m=this;if(this.state===y.State.PARSING){this.audioOnly=!!l.audio&&!l.video,this.altAudio&&!this.audioOnly&&delete l.audio;var O=l.audio,P=l.video,M=l.audiovideo;if(O){var F=f.audioCodec,B=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(F&&(F.indexOf("mp4a.40.5")!==-1?F="mp4a.40.2":F="mp4a.40.5"),O.metadata.channelCount!==1&&B.indexOf("firefox")===-1&&(F="mp4a.40.5")),B.indexOf("android")!==-1&&O.container!=="audio/mpeg"&&(F="mp4a.40.2",this.log("Android: force audio codec to "+F)),f.audioCodec&&f.audioCodec!==F&&this.log('Swapping manifest audio codec "'+f.audioCodec+'" for "'+F+'"'),O.levelCodec=F,O.id="main",this.log("Init audio buffer, container:"+O.container+", codecs[selected/level/parsed]=["+(F||"")+"/"+(f.audioCodec||"")+"/"+O.codec+"]")}P&&(P.levelCodec=f.videoCodec,P.id="main",this.log("Init video buffer, container:"+P.container+", codecs[level/parsed]=["+(f.videoCodec||"")+"/"+P.codec+"]")),M&&this.log("Init audiovideo buffer, container:"+M.container+", codecs[level/parsed]=["+(f.attrs.CODECS||"")+"/"+M.codec+"]"),this.hls.trigger(I.Events.BUFFER_CODECS,l),Object.keys(l).forEach(function(C){var U=l[C],w=U.initSegment;w!=null&&w.byteLength&&m.hls.trigger(I.Events.BUFFER_APPENDING,{type:C,data:w,frag:o,part:null,chunkMeta:E,parent:o.type})}),this.tick()}},d.backtrack=function(f){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(f);var l=this.fragmentTracker.backtrack(f);this.fragPrevious=null,this.nextLoadPosition=f.start,l?this.resetFragmentLoading(f):this.state=y.State.BACKTRACKING},d.checkFragmentChanged=function(){var f=this.media,l=null;if(f&&f.readyState>1&&f.seeking===!1){var o=f.currentTime;if(T.BufferHelper.isBuffered(f,o)?l=this.getAppendedFrag(o):T.BufferHelper.isBuffered(f,o+.1)&&(l=this.getAppendedFrag(o+.1)),l){var E=this.fragPlaying,m=l.level;(!E||l.sn!==E.sn||E.level!==m||l.urlId!==E.urlId)&&(this.hls.trigger(I.Events.FRAG_CHANGED,{frag:l}),(!E||E.level!==m)&&this.hls.trigger(I.Events.LEVEL_SWITCHED,{level:m}),this.fragPlaying=l)}}},e(h,[{key:"nextLevel",get:function(){var f=this.nextBufferedFrag;return f?f.level:-1}},{key:"currentLevel",get:function(){var f=this.media;if(f){var l=this.getAppendedFrag(f.currentTime);if(l)return l.level}return-1}},{key:"nextBufferedFrag",get:function(){var f=this.media;if(f){var l=this.getAppendedFrag(f.currentTime);return this.followingBufferedFrag(l)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),h}(y.default)},"./src/controller/subtitle-stream-controller.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"SubtitleStreamController",function(){return e});var R=c("./src/events.ts"),y=c("./src/utils/buffer-helper.ts"),x=c("./src/controller/fragment-finders.ts"),I=c("./src/utils/discontinuities.ts"),T=c("./src/controller/level-helper.ts"),D=c("./src/controller/fragment-tracker.ts"),_=c("./src/controller/base-stream-controller.ts"),g=c("./src/types/loader.ts"),A=c("./src/types/level.ts");function L(i,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(i,a.key,a)}}function S(i,t,r){return t&&L(i.prototype,t),r&&L(i,r),i}function v(i,t){i.prototype=Object.create(t.prototype),i.prototype.constructor=i,p(i,t)}function p(i,t){return p=Object.setPrototypeOf||function(a,n){return a.__proto__=n,a},p(i,t)}var s=500,e=function(i){v(t,i);function t(a,n){var h;return h=i.call(this,a,n,"[subtitle-stream-controller]")||this,h.levels=[],h.currentTrackId=-1,h.tracksBuffered=[],h.mainDetails=null,h._registerListeners(),h}var r=t.prototype;return r.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},r._registerListeners=function(){var n=this.hls;n.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.on(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.on(R.Events.ERROR,this.onError,this),n.on(R.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),n.on(R.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),n.on(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),n.on(R.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),n.on(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},r._unregisterListeners=function(){var n=this.hls;n.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.off(R.Events.ERROR,this.onError,this),n.off(R.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),n.off(R.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),n.off(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),n.off(R.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),n.off(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},r.startLoad=function(){this.stopLoad(),this.state=_.State.IDLE,this.setInterval(s),this.tick()},r.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},r.onLevelLoaded=function(n,h){this.mainDetails=h.details},r.onSubtitleFragProcessed=function(n,h){var d=h.frag,u=h.success;if(this.fragPrevious=d,this.state=_.State.IDLE,!!u){var f=this.tracksBuffered[this.currentTrackId];if(!!f){for(var l,o=d.start,E=0;E<f.length;E++)if(o>=f[E].start&&o<=f[E].end){l=f[E];break}var m=d.start+d.duration;l?l.end=m:(l={start:o,end:m},f.push(l)),this.fragmentTracker.fragBuffered(d)}}},r.onBufferFlushing=function(n,h){var d=h.startOffset,u=h.endOffset;if(d===0&&u!==Number.POSITIVE_INFINITY){var f=this.currentTrackId,l=this.levels;if(!l.length||!l[f]||!l[f].details)return;var o=l[f].details,E=o.targetduration,m=u-E;if(m<=0)return;h.endOffsetSubtitles=Math.max(0,m),this.tracksBuffered.forEach(function(O){for(var P=0;P<O.length;){if(O[P].end<=m){O.shift();continue}else if(O[P].start<m)O[P].start=m;else break;P++}}),this.fragmentTracker.removeFragmentsInRange(d,m,g.PlaylistLevelType.SUBTITLE)}},r.onError=function(n,h){var d,u=h.frag;!u||u.type!==g.PlaylistLevelType.SUBTITLE||((d=this.fragCurrent)!==null&&d!==void 0&&d.loader&&this.fragCurrent.loader.abort(),this.state=_.State.IDLE)},r.onSubtitleTracksUpdated=function(n,h){var d=this,u=h.subtitleTracks;this.tracksBuffered=[],this.levels=u.map(function(f){return new A.Level(f)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(f){d.tracksBuffered[f.id]=[]}),this.mediaBuffer=null},r.onSubtitleTrackSwitch=function(n,h){if(this.currentTrackId=h.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var d=this.levels[this.currentTrackId];d!=null&&d.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,d&&this.setInterval(s)},r.onSubtitleTrackLoaded=function(n,h){var d,u=h.details,f=h.id,l=this.currentTrackId,o=this.levels;if(!!o.length){var E=o[l];if(!(f>=o.length||f!==l||!E)){if(this.mediaBuffer=this.mediaBufferTimeRanges,u.live||(d=E.details)!==null&&d!==void 0&&d.live){var m=this.mainDetails;if(u.deltaUpdateFailed||!m)return;var O=m.fragments[0];if(!E.details)u.hasProgramDateTime&&m.hasProgramDateTime?Object(I.alignMediaPlaylistByPDT)(u,m):O&&Object(T.addSliding)(u,O.start);else{var P=this.alignPlaylists(u,E.details);P===0&&O&&Object(T.addSliding)(u,O.start)}}if(E.details=u,this.levelLastLoaded=f,this.tick(),u.live&&!this.fragCurrent&&this.media&&this.state===_.State.IDLE){var M=Object(x.findFragmentByPTS)(null,u.fragments,this.media.currentTime,0);M||(this.warn("Subtitle playlist not aligned with playback"),E.details=void 0)}}}},r._handleFragmentLoadComplete=function(n){var h=n.frag,d=n.payload,u=h.decryptdata,f=this.hls;if(!this.fragContextChanged(h)&&d&&d.byteLength>0&&u&&u.key&&u.iv&&u.method==="AES-128"){var l=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(d),u.key.buffer,u.iv.buffer).then(function(o){var E=performance.now();f.trigger(R.Events.FRAG_DECRYPTED,{frag:h,payload:o,stats:{tstart:l,tdecrypt:E}})})}},r.doTick=function(){if(!this.media){this.state=_.State.IDLE;return}if(this.state===_.State.IDLE){var n,h=this.currentTrackId,d=this.levels;if(!d.length||!d[h]||!d[h].details)return;var u=d[h].details,f=u.targetduration,l=this.config,o=this.media,E=y.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,o.currentTime-f,l.maxBufferHole),m=E.end,O=E.len,P=this.getMaxBufferLength()+f;if(O>P)return;console.assert(u,"Subtitle track details are defined on idle subtitle stream controller tick");var M=u.fragments,F=M.length,B=u.edge,C,U=this.fragPrevious;if(m<B){var w=l.maxFragLookUpTolerance;C=Object(x.findFragmentByPTS)(U,M,m,w),!C&&U&&U.start<M[0].start&&(C=M[0])}else C=M[F-1];(n=C)!==null&&n!==void 0&&n.encrypted?this.loadKey(C,u):C&&this.fragmentTracker.getState(C)===D.FragmentState.NOT_LOADED&&this.loadFragment(C,u,m)}},r.loadFragment=function(n,h,d){this.fragCurrent=n,i.prototype.loadFragment.call(this,n,h,d)},S(t,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),t}(_.default)},"./src/controller/subtitle-track-controller.ts":function(k,b,c){"use strict";c.r(b);var R=c("./src/events.ts"),y=c("./src/utils/texttrack-utils.ts"),x=c("./src/controller/base-playlist-controller.ts"),I=c("./src/types/loader.ts");function T(S,v){for(var p=0;p<v.length;p++){var s=v[p];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(S,s.key,s)}}function D(S,v,p){return v&&T(S.prototype,v),p&&T(S,p),S}function _(S,v){S.prototype=Object.create(v.prototype),S.prototype.constructor=S,g(S,v)}function g(S,v){return g=Object.setPrototypeOf||function(s,e){return s.__proto__=e,s},g(S,v)}var A=function(S){_(v,S);function v(s){var e;return e=S.call(this,s,"[subtitle-track-controller]")||this,e.media=null,e.tracks=[],e.groupId=null,e.tracksInGroup=[],e.trackId=-1,e.selectDefaultTrack=!0,e.queuedDefaultTrack=-1,e.trackChangeListener=function(){return e.onTextTracksChanged()},e.asyncPollTrackChange=function(){return e.pollTrackChange(0)},e.useTextTrackPolling=!1,e.subtitlePollingInterval=-1,e.subtitleDisplay=!0,e.registerListeners(),e}var p=v.prototype;return p.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,S.prototype.destroy.call(this)},p.registerListeners=function(){var e=this.hls;e.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(R.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(R.Events.ERROR,this.onError,this)},p.unregisterListeners=function(){var e=this.hls;e.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(R.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(R.Events.ERROR,this.onError,this)},p.onMediaAttached=function(e,i){this.media=i.media,!!this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},p.pollTrackChange=function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)},p.onMediaDetaching=function(){if(!!this.media){self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var e=L(this.media.textTracks);e.forEach(function(i){Object(y.clearCurrentCues)(i)}),this.subtitleTrack=-1,this.media=null}},p.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},p.onManifestParsed=function(e,i){this.tracks=i.subtitleTracks},p.onSubtitleTrackLoaded=function(e,i){var t=i.id,r=i.details,a=this.trackId,n=this.tracksInGroup[a];if(!n){this.warn("Invalid subtitle track id "+t);return}var h=n.details;n.details=i.details,this.log("subtitle track "+t+" loaded ["+r.startSN+"-"+r.endSN+"]"),t===this.trackId&&(this.retryCount=0,this.playlistLoaded(t,i,h))},p.onLevelLoading=function(e,i){this.switchLevel(i.level)},p.onLevelSwitching=function(e,i){this.switchLevel(i.level)},p.switchLevel=function(e){var i=this.hls.levels[e];if(!!(i!=null&&i.textGroupIds)){var t=i.textGroupIds[i.urlId];if(this.groupId!==t){var r=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,a=this.tracks.filter(function(d){return!t||d.groupId===t});this.tracksInGroup=a;var n=this.findTrackId(r==null?void 0:r.name)||this.findTrackId();this.groupId=t;var h={subtitleTracks:a};this.log("Updating subtitle tracks, "+a.length+' track(s) found in "'+t+'" group-id'),this.hls.trigger(R.Events.SUBTITLE_TRACKS_UPDATED,h),n!==-1&&this.setSubtitleTrack(n,r)}}},p.findTrackId=function(e){for(var i=this.tracksInGroup,t=0;t<i.length;t++){var r=i[t];if((!this.selectDefaultTrack||r.default)&&(!e||e===r.name))return r.id}return-1},p.onError=function(e,i){S.prototype.onError.call(this,e,i),!(i.fatal||!i.context)&&i.context.type===I.PlaylistContextType.SUBTITLE_TRACK&&i.context.id===this.trackId&&i.context.groupId===this.groupId&&this.retryLoadingOrFail(i)},p.loadPlaylist=function(e){var i=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(i)){var t=i.id,r=i.groupId,a=i.url;if(e)try{a=e.addDirectives(a)}catch(n){this.warn("Could not construct new URL with HLS Delivery Directives: "+n)}this.log("Loading subtitle playlist for id "+t),this.hls.trigger(R.Events.SUBTITLE_TRACK_LOADING,{url:a,id:t,groupId:r,deliveryDirectives:e||null})}},p.toggleTrackModes=function(e){var i=this,t=this.media,r=this.subtitleDisplay,a=this.trackId;if(!!t){var n=L(t.textTracks),h=n.filter(function(f){return f.groupId===i.groupId});if(e===-1)[].slice.call(n).forEach(function(f){f.mode="disabled"});else{var d=h[a];d&&(d.mode="disabled")}var u=h[e];u&&(u.mode=r?"showing":"hidden")}},p.setSubtitleTrack=function(e,i){var t,r=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),!(this.trackId===e&&(e===-1||(t=r[e])!==null&&t!==void 0&&t.details)||e<-1||e>=r.length)){this.clearTimer();var a=r[e];if(this.log("Switching to subtitle track "+e),this.trackId=e,a){var n=a.id,h=a.groupId,d=h===void 0?"":h,u=a.name,f=a.type,l=a.url;this.hls.trigger(R.Events.SUBTITLE_TRACK_SWITCH,{id:n,groupId:d,name:u,type:f,url:l});var o=this.switchParams(a.url,i==null?void 0:i.details);this.loadPlaylist(o)}else this.hls.trigger(R.Events.SUBTITLE_TRACK_SWITCH,{id:e})}},p.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!(!this.media||!this.hls.config.renderTextTracksNatively)){for(var e=-1,i=L(this.media.textTracks),t=0;t<i.length;t++)if(i[t].mode==="hidden")e=t;else if(i[t].mode==="showing"){e=t;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}},D(v,[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1;var i=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,i)}}]),v}(x.default);function L(S){for(var v=[],p=0;p<S.length;p++){var s=S[p];s.kind==="subtitles"&&s.label&&v.push(S[p])}return v}b.default=A},"./src/controller/timeline-controller.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"TimelineController",function(){return L});var R=c("./src/polyfills/number.ts"),y=c("./src/events.ts"),x=c("./src/utils/cea-608-parser.ts"),I=c("./src/utils/output-filter.ts"),T=c("./src/utils/webvtt-parser.ts"),D=c("./src/utils/texttrack-utils.ts"),_=c("./src/utils/imsc1-ttml-parser.ts"),g=c("./src/types/loader.ts"),A=c("./src/utils/logger.ts"),L=function(){function s(i){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=p(),this.captionsProperties=void 0,this.hls=i,this.config=i.config,this.Cues=i.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var t=new I.default(this,"textTrack1"),r=new I.default(this,"textTrack2"),a=new I.default(this,"textTrack3"),n=new I.default(this,"textTrack4");this.cea608Parser1=new x.default(1,t,r),this.cea608Parser2=new x.default(3,a,n)}i.on(y.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),i.on(y.Events.MEDIA_DETACHING,this.onMediaDetaching,this),i.on(y.Events.MANIFEST_LOADING,this.onManifestLoading,this),i.on(y.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.on(y.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),i.on(y.Events.FRAG_LOADING,this.onFragLoading,this),i.on(y.Events.FRAG_LOADED,this.onFragLoaded,this),i.on(y.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),i.on(y.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),i.on(y.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),i.on(y.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),i.on(y.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var e=s.prototype;return e.destroy=function(){var t=this.hls;t.off(y.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(y.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(y.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(y.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(y.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(y.Events.FRAG_LOADING,this.onFragLoading,this),t.off(y.Events.FRAG_LOADED,this.onFragLoaded,this),t.off(y.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(y.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(y.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(y.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(y.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},e.addCues=function(t,r,a,n,h){for(var d=!1,u=h.length;u--;){var f=h[u],l=v(f[0],f[1],r,a);if(l>=0&&(f[0]=Math.min(f[0],r),f[1]=Math.max(f[1],a),d=!0,l/(a-r)>.5))return}if(d||h.push([r,a]),this.config.renderTextTracksNatively){var o=this.captionsTracks[t];this.Cues.newCue(o,r,a,n)}else{var E=this.Cues.newCue(null,r,a,n);this.hls.trigger(y.Events.CUES_PARSED,{type:"captions",cues:E,track:t})}},e.onInitPtsFound=function(t,r){var a=this,n=r.frag,h=r.id,d=r.initPTS,u=r.timescale,f=this.unparsedVttFrags;h==="main"&&(this.initPTS[n.cc]=d,this.timescale[n.cc]=u),f.length&&(this.unparsedVttFrags=[],f.forEach(function(l){a.onFragLoaded(y.Events.FRAG_LOADED,l)}))},e.getExistingTrack=function(t){var r=this.media;if(r)for(var a=0;a<r.textTracks.length;a++){var n=r.textTracks[a];if(n[t])return n}return null},e.createCaptionsTrack=function(t){this.config.renderTextTracksNatively?this.createNativeTrack(t):this.createNonNativeTrack(t)},e.createNativeTrack=function(t){if(!this.captionsTracks[t]){var r=this.captionsProperties,a=this.captionsTracks,n=this.media,h=r[t],d=h.label,u=h.languageCode,f=this.getExistingTrack(t);if(f)a[t]=f,Object(D.clearCurrentCues)(a[t]),Object(D.sendAddTrackEvent)(a[t],n);else{var l=this.createTextTrack("captions",d,u);l&&(l[t]=!0,a[t]=l)}}},e.createNonNativeTrack=function(t){if(!this.nonNativeCaptionsTracks[t]){var r=this.captionsProperties[t];if(!!r){var a=r.label,n={_id:t,label:a,kind:"captions",default:r.media?!!r.media.default:!1,closedCaptions:r.media};this.nonNativeCaptionsTracks[t]=n,this.hls.trigger(y.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[n]})}}},e.createTextTrack=function(t,r,a){var n=this.media;if(!!n)return n.addTextTrack(t,r,a)},e.onMediaAttaching=function(t,r){this.media=r.media,this._cleanTracks()},e.onMediaDetaching=function(){var t=this.captionsTracks;Object.keys(t).forEach(function(r){Object(D.clearCurrentCues)(t[r]),delete t[r]}),this.nonNativeCaptionsTracks={}},e.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=p(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},e._cleanTracks=function(){var t=this.media;if(!!t){var r=t.textTracks;if(r)for(var a=0;a<r.length;a++)Object(D.clearCurrentCues)(r[a])}},e.onSubtitleTracksUpdated=function(t,r){var a=this;this.textTracks=[];var n=r.subtitleTracks||[],h=n.some(function(l){return l.textCodec===_.IMSC1_CODEC});if(this.config.enableWebVTT||h&&this.config.enableIMSC1){var d=this.tracks&&n&&this.tracks.length===n.length;if(this.tracks=n||[],this.config.renderTextTracksNatively){var u=this.media?this.media.textTracks:[];this.tracks.forEach(function(l,o){var E;if(o<u.length){for(var m=null,O=0;O<u.length;O++)if(S(u[O],l)){m=u[O];break}m&&(E=m)}E?Object(D.clearCurrentCues)(E):(E=a.createTextTrack("subtitles",l.name,l.lang),E&&(E.mode="disabled")),E&&(E.groupId=l.groupId,a.textTracks.push(E))})}else if(!d&&this.tracks&&this.tracks.length){var f=this.tracks.map(function(l){return{label:l.name,kind:l.type.toLowerCase(),default:l.default,subtitleTrack:l}});this.hls.trigger(y.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:f})}}},e.onManifestLoaded=function(t,r){var a=this;this.config.enableCEA708Captions&&r.captions&&r.captions.forEach(function(n){var h=/(?:CC|SERVICE)([1-4])/.exec(n.instreamId);if(!!h){var d="textTrack"+h[1],u=a.captionsProperties[d];!u||(u.label=n.name,n.lang&&(u.languageCode=n.lang),u.media=n)}})},e.onFragLoading=function(t,r){var a=this.cea608Parser1,n=this.cea608Parser2,h=this.lastSn,d=this.lastPartIndex;if(!(!this.enabled||!(a&&n))&&r.frag.type===g.PlaylistLevelType.MAIN){var u,f,l=r.frag.sn,o=(u=r==null||(f=r.part)===null||f===void 0?void 0:f.index)!=null?u:-1;l===h+1||l===h&&o===d+1||(a.reset(),n.reset()),this.lastSn=l,this.lastPartIndex=o}},e.onFragLoaded=function(t,r){var a=r.frag,n=r.payload,h=this.initPTS,d=this.unparsedVttFrags;if(a.type===g.PlaylistLevelType.SUBTITLE)if(n.byteLength){if(!Object(R.isFiniteNumber)(h[a.cc])){d.push(r),h.length&&this.hls.trigger(y.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:a,error:new Error("Missing initial subtitle PTS")});return}var u=a.decryptdata,f="stats"in r;if(u==null||u.key==null||u.method!=="AES-128"||f){var l=this.tracks[a.level],o=this.vttCCs;o[a.cc]||(o[a.cc]={start:a.start,prevCC:this.prevCC,new:!0},this.prevCC=a.cc),l&&l.textCodec===_.IMSC1_CODEC?this._parseIMSC1(a,n):this._parseVTTs(a,n,o)}}else this.hls.trigger(y.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:a,error:new Error("Empty subtitle payload")})},e._parseIMSC1=function(t,r){var a=this,n=this.hls;Object(_.parseIMSC1)(r,this.initPTS[t.cc],this.timescale[t.cc],function(h){a._appendCues(h,t.level),n.trigger(y.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})},function(h){A.logger.log("Failed to parse IMSC1: "+h),n.trigger(y.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:h})})},e._parseVTTs=function(t,r,a){var n=this,h=this.hls;Object(T.parseWebVTT)(r,this.initPTS[t.cc],this.timescale[t.cc],a,t.cc,t.start,function(d){n._appendCues(d,t.level),h.trigger(y.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})},function(d){n._fallbackToIMSC1(t,r),A.logger.log("Failed to parse VTT cue: "+d),h.trigger(y.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:d})})},e._fallbackToIMSC1=function(t,r){var a=this,n=this.tracks[t.level];n.textCodec||Object(_.parseIMSC1)(r,this.initPTS[t.cc],this.timescale[t.cc],function(){n.textCodec=_.IMSC1_CODEC,a._parseIMSC1(t,r)},function(){n.textCodec="wvtt"})},e._appendCues=function(t,r){var a=this.hls;if(this.config.renderTextTracksNatively){var n=this.textTracks[r];if(n.mode==="disabled")return;t.forEach(function(u){return Object(D.addCueToTrack)(n,u)})}else{var h=this.tracks[r],d=h.default?"default":"subtitles"+r;a.trigger(y.Events.CUES_PARSED,{type:"subtitles",cues:t,track:d})}},e.onFragDecrypted=function(t,r){var a=r.frag;if(a.type===g.PlaylistLevelType.SUBTITLE){if(!Object(R.isFiniteNumber)(this.initPTS[a.cc])){this.unparsedVttFrags.push(r);return}this.onFragLoaded(y.Events.FRAG_LOADED,r)}},e.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},e.onFragParsingUserdata=function(t,r){var a=this.cea608Parser1,n=this.cea608Parser2;if(!(!this.enabled||!(a&&n)))for(var h=0;h<r.samples.length;h++){var d=r.samples[h].bytes;if(d){var u=this.extractCea608Data(d);a.addData(r.samples[h].pts,u[0]),n.addData(r.samples[h].pts,u[1])}}},e.onBufferFlushing=function(t,r){var a=r.startOffset,n=r.endOffset,h=r.endOffsetSubtitles,d=r.type,u=this.media;if(!(!u||u.currentTime<n)){if(!d||d==="video"){var f=this.captionsTracks;Object.keys(f).forEach(function(o){return Object(D.removeCuesInRange)(f[o],a,n)})}if(this.config.renderTextTracksNatively&&a===0&&h!==void 0){var l=this.textTracks;Object.keys(l).forEach(function(o){return Object(D.removeCuesInRange)(l[o],a,h)})}}},e.extractCea608Data=function(t){for(var r=t[0]&31,a=2,n=[[],[]],h=0;h<r;h++){var d=t[a++],u=127&t[a++],f=127&t[a++],l=(4&d)!=0,o=3&d;u===0&&f===0||l&&(o===0||o===1)&&(n[o].push(u),n[o].push(f))}return n},s}();function S(s,e){return s&&s.label===e.name&&!(s.textTrack1||s.textTrack2)}function v(s,e,i,t){return Math.min(e,t)-Math.max(s,i)}function p(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"default",function(){return R});var R=function(){function y(I,T){this.subtle=void 0,this.aesIV=void 0,this.subtle=I,this.aesIV=T}var x=y.prototype;return x.decrypt=function(T,D){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},D,T)},y}()},"./src/crypt/aes-decryptor.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"removePadding",function(){return y}),c.d(b,"default",function(){return x});var R=c("./src/utils/typed-array.ts");function y(I){var T=I.byteLength,D=T&&new DataView(I.buffer).getUint8(T-1);return D?Object(R.sliceUint8)(I,0,T-D):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 g=new DataView(_),A=new Uint32Array(4),L=0;L<4;L++)A[L]=g.getUint32(L*4);return A},T.initTable=function(){var _=this.sBox,g=this.invSBox,A=this.subMix,L=A[0],S=A[1],v=A[2],p=A[3],s=this.invSubMix,e=s[0],i=s[1],t=s[2],r=s[3],a=new Uint32Array(256),n=0,h=0,d=0;for(d=0;d<256;d++)d<128?a[d]=d<<1:a[d]=d<<1^283;for(d=0;d<256;d++){var u=h^h<<1^h<<2^h<<3^h<<4;u=u>>>8^u&255^99,_[n]=u,g[u]=n;var f=a[n],l=a[f],o=a[l],E=a[u]*257^u*16843008;L[n]=E<<24|E>>>8,S[n]=E<<16|E>>>16,v[n]=E<<8|E>>>24,p[n]=E,E=o*16843009^l*65537^f*257^n*16843008,e[u]=E<<24|E>>>8,i[u]=E<<16|E>>>16,t[u]=E<<8|E>>>24,r[u]=E,n?(n=f^a[a[a[o^f]]],h^=a[a[h]]):n=h=1}},T.expandKey=function(_){for(var g=this.uint8ArrayToUint32Array_(_),A=!0,L=0;L<g.length&&A;)A=g[L]===this.key[L],L++;if(!A){this.key=g;var S=this.keySize=g.length;if(S!==4&&S!==6&&S!==8)throw new Error("Invalid aes key size="+S);var v=this.ksRows=(S+6+1)*4,p,s,e=this.keySchedule=new Uint32Array(v),i=this.invKeySchedule=new Uint32Array(v),t=this.sBox,r=this.rcon,a=this.invSubMix,n=a[0],h=a[1],d=a[2],u=a[3],f,l;for(p=0;p<v;p++){if(p<S){f=e[p]=g[p];continue}l=f,p%S==0?(l=l<<8|l>>>24,l=t[l>>>24]<<24|t[l>>>16&255]<<16|t[l>>>8&255]<<8|t[l&255],l^=r[p/S|0]<<24):S>6&&p%S==4&&(l=t[l>>>24]<<24|t[l>>>16&255]<<16|t[l>>>8&255]<<8|t[l&255]),e[p]=f=(e[p-S]^l)>>>0}for(s=0;s<v;s++)p=v-s,s&3?l=e[p]:l=e[p-4],s<4||p<=4?i[s]=l:i[s]=n[t[l>>>24]]^h[t[l>>>16&255]]^d[t[l>>>8&255]]^u[t[l&255]],i[s]=i[s]>>>0}},T.networkToHostOrderSwap=function(_){return _<<24|(_&65280)<<8|(_&16711680)>>8|_>>>24},T.decrypt=function(_,g,A){for(var L=this.keySize+6,S=this.invKeySchedule,v=this.invSBox,p=this.invSubMix,s=p[0],e=p[1],i=p[2],t=p[3],r=this.uint8ArrayToUint32Array_(A),a=r[0],n=r[1],h=r[2],d=r[3],u=new Int32Array(_),f=new Int32Array(u.length),l,o,E,m,O,P,M,F,B,C,U,w,N,j,K=this.networkToHostOrderSwap;g<u.length;){for(B=K(u[g]),C=K(u[g+1]),U=K(u[g+2]),w=K(u[g+3]),O=B^S[0],P=w^S[1],M=U^S[2],F=C^S[3],N=4,j=1;j<L;j++)l=s[O>>>24]^e[P>>16&255]^i[M>>8&255]^t[F&255]^S[N],o=s[P>>>24]^e[M>>16&255]^i[F>>8&255]^t[O&255]^S[N+1],E=s[M>>>24]^e[F>>16&255]^i[O>>8&255]^t[P&255]^S[N+2],m=s[F>>>24]^e[O>>16&255]^i[P>>8&255]^t[M&255]^S[N+3],O=l,P=o,M=E,F=m,N=N+4;l=v[O>>>24]<<24^v[P>>16&255]<<16^v[M>>8&255]<<8^v[F&255]^S[N],o=v[P>>>24]<<24^v[M>>16&255]<<16^v[F>>8&255]<<8^v[O&255]^S[N+1],E=v[M>>>24]<<24^v[F>>16&255]<<16^v[O>>8&255]<<8^v[P&255]^S[N+2],m=v[F>>>24]<<24^v[O>>16&255]<<16^v[P>>8&255]<<8^v[M&255]^S[N+3],f[g]=K(l^a),f[g+1]=K(m^n),f[g+2]=K(E^h),f[g+3]=K(o^d),a=B,n=C,h=U,d=w,g=g+4}return f.buffer},I}()},"./src/crypt/decrypter.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"default",function(){return g});var R=c("./src/crypt/aes-crypto.ts"),y=c("./src/crypt/fast-aes-key.ts"),x=c("./src/crypt/aes-decryptor.ts"),I=c("./src/utils/logger.ts"),T=c("./src/utils/mp4-tools.ts"),D=c("./src/utils/typed-array.ts"),_=16,g=function(){function A(S,v,p){var s=p===void 0?{}:p,e=s.removePKCS7Padding,i=e===void 0?!0:e;if(this.logEnabled=!0,this.observer=void 0,this.config=void 0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.observer=S,this.config=v,this.removePKCS7Padding=i,i)try{var t=self.crypto;t&&(this.subtle=t.subtle||t.webkitSubtle)}catch{}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var L=A.prototype;return L.destroy=function(){this.observer=null},L.isSync=function(){return this.config.enableSoftwareAES},L.flush=function(){var v=this.currentResult;if(!v){this.reset();return}var p=new Uint8Array(v);return this.reset(),this.removePKCS7Padding?Object(x.removePadding)(p):p},L.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},L.decrypt=function(v,p,s,e){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(v),p,s);var i=this.flush();i&&e(i.buffer)}else this.webCryptoDecrypt(new Uint8Array(v),p,s).then(e)},L.softwareDecrypt=function(v,p,s){var e=this.currentIV,i=this.currentResult,t=this.remainderData;this.logOnce("JS AES decrypt"),t&&(v=Object(T.appendUint8Array)(t,v),this.remainderData=null);var r=this.getValidChunk(v);if(!r.length)return null;e&&(s=e);var a=this.softwareDecrypter;a||(a=this.softwareDecrypter=new x.default),a.expandKey(p);var n=i;return this.currentResult=a.decrypt(r.buffer,0,s),this.currentIV=Object(D.sliceUint8)(r,-16).buffer,n||null},L.webCryptoDecrypt=function(v,p,s){var e=this,i=this.subtle;return(this.key!==p||!this.fastAesKey)&&(this.key=p,this.fastAesKey=new y.default(i,p)),this.fastAesKey.expandKey().then(function(t){if(!i)return Promise.reject(new Error("web crypto not initialized"));var r=new R.default(i,s);return r.decrypt(v.buffer,t)}).catch(function(t){return e.onWebCryptoError(t,v,p,s)})},L.onWebCryptoError=function(v,p,s,e){return I.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",v),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(p,s,e)},L.getValidChunk=function(v){var p=v,s=v.length-v.length%_;return s!==v.length&&(p=Object(D.sliceUint8)(v,0,s),this.remainderData=Object(D.sliceUint8)(v,s)),p},L.logOnce=function(v){!this.logEnabled||(I.logger.log("[decrypter.ts]: "+v),this.logEnabled=!1)},A}()},"./src/crypt/fast-aes-key.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"default",function(){return R});var R=function(){function y(I,T){this.subtle=void 0,this.key=void 0,this.subtle=I,this.key=T}var x=y.prototype;return x.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},y}()},"./src/demux/aacdemuxer.ts":function(k,b,c){"use strict";c.r(b);var R=c("./src/demux/base-audio-demuxer.ts"),y=c("./src/demux/adts.ts"),x=c("./src/utils/logger.ts"),I=c("./src/demux/id3.ts");function T(g,A){g.prototype=Object.create(A.prototype),g.prototype.constructor=g,D(g,A)}function D(g,A){return D=Object.setPrototypeOf||function(S,v){return S.__proto__=v,S},D(g,A)}var _=function(g){T(A,g);function A(S,v){var p;return p=g.call(this)||this,p.observer=void 0,p.config=void 0,p.observer=S,p.config=v,p}var L=A.prototype;return L.resetInitSegment=function(v,p,s){g.prototype.resetInitSegment.call(this,v,p,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:v,duration:s,inputTimeScale:9e4,dropped:0}},A.probe=function(v){if(!v)return!1;for(var p=I.getID3Data(v,0)||[],s=p.length,e=v.length;s<e;s++)if(y.probe(v,s))return x.logger.log("ADTS sync word found !"),!0;return!1},L.canParse=function(v,p){return y.canParse(v,p)},L.appendFrame=function(v,p,s){y.initTrackConfig(v,this.observer,p,s,v.manifestCodec);var e=y.appendFrame(v,p,s,this.initPTS,this.frameIndex);if(e&&e.missing===0)return e},A}(R.default);_.minProbeByteLength=9,b.default=_},"./src/demux/adts.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"getAudioConfig",function(){return I}),c.d(b,"isHeaderPattern",function(){return T}),c.d(b,"getHeaderLength",function(){return D}),c.d(b,"getFullFrameLength",function(){return _}),c.d(b,"canGetFrameLength",function(){return g}),c.d(b,"isHeader",function(){return A}),c.d(b,"canParse",function(){return L}),c.d(b,"probe",function(){return S}),c.d(b,"initTrackConfig",function(){return v}),c.d(b,"getFrameDuration",function(){return p}),c.d(b,"parseFrameHeader",function(){return s}),c.d(b,"appendFrame",function(){return e});var R=c("./src/utils/logger.ts"),y=c("./src/errors.ts"),x=c("./src/events.ts");function I(i,t,r,a){var n,h,d,u,f=navigator.userAgent.toLowerCase(),l=a,o=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];n=((t[r+2]&192)>>>6)+1;var E=(t[r+2]&60)>>>2;if(E>o.length-1){i.trigger(x.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+E});return}return d=(t[r+2]&1)<<2,d|=(t[r+3]&192)>>>6,R.logger.log("manifest codec:"+a+", ADTS type:"+n+", samplingIndex:"+E),/firefox/i.test(f)?E>=6?(n=5,u=new Array(4),h=E-3):(n=2,u=new Array(2),h=E):f.indexOf("android")!==-1?(n=2,u=new Array(2),h=E):(n=5,u=new Array(4),a&&(a.indexOf("mp4a.40.29")!==-1||a.indexOf("mp4a.40.5")!==-1)||!a&&E>=6?h=E-3:((a&&a.indexOf("mp4a.40.2")!==-1&&(E>=6&&d===1||/vivaldi/i.test(f))||!a&&d===1)&&(n=2,u=new Array(2)),h=E)),u[0]=n<<3,u[0]|=(E&14)>>1,u[1]|=(E&1)<<7,u[1]|=d<<3,n===5&&(u[1]|=(h&14)>>1,u[2]=(h&1)<<7,u[2]|=2<<2,u[3]=0),{config:u,samplerate:o[E],channelCount:d,codec:"mp4a.40."+n,manifestCodec:l}}function T(i,t){return i[t]===255&&(i[t+1]&246)==240}function D(i,t){return i[t+1]&1?7:9}function _(i,t){return(i[t+3]&3)<<11|i[t+4]<<3|(i[t+5]&224)>>>5}function g(i,t){return t+5<i.length}function A(i,t){return t+1<i.length&&T(i,t)}function L(i,t){return g(i,t)&&T(i,t)&&_(i,t)<=i.length-t}function S(i,t){if(A(i,t)){var r=D(i,t);if(t+r>=i.length)return!1;var a=_(i,t);if(a<=r)return!1;var n=t+a;return n===i.length||A(i,n)}return!1}function v(i,t,r,a,n){if(!i.samplerate){var h=I(t,r,a,n);if(!h)return;i.config=h.config,i.samplerate=h.samplerate,i.channelCount=h.channelCount,i.codec=h.codec,i.manifestCodec=h.manifestCodec,R.logger.log("parsed codec:"+i.codec+", rate:"+h.samplerate+", channels:"+h.channelCount)}}function p(i){return 1024*9e4/i}function s(i,t,r,a,n){var h=D(i,t),d=_(i,t);if(d-=h,d>0){var u=r+a*n;return{headerLength:h,frameLength:d,stamp:u}}}function e(i,t,r,a,n){var h=p(i.samplerate),d=s(t,r,a,n,h);if(d){var u=d.frameLength,f=d.headerLength,l=d.stamp,o=f+u,E=Math.max(0,r+o-t.length),m;E?(m=new Uint8Array(o-f),m.set(t.subarray(r+f,t.length),0)):m=t.subarray(r+f,r+o);var O={unit:m,pts:l};return E||i.samples.push(O),{sample:O,length:o,missing:E}}}},"./src/demux/base-audio-demuxer.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"initPTSFn",function(){return _});var R=c("./src/polyfills/number.ts"),y=c("./src/demux/id3.ts"),x=c("./src/demux/dummy-demuxed-track.ts"),I=c("./src/utils/mp4-tools.ts"),T=c("./src/utils/typed-array.ts"),D=function(){function g(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var A=g.prototype;return A.resetInitSegment=function(S,v,p){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},A.resetTimeStamp=function(){},A.resetContiguity=function(){},A.canParse=function(S,v){return!1},A.appendFrame=function(S,v,p){},A.demux=function(S,v){this.cachedData&&(S=Object(I.appendUint8Array)(this.cachedData,S),this.cachedData=null);var p=y.getID3Data(S,0),s=p?p.length:0,e,i,t=this._audioTrack,r=this._id3Track,a=p?y.getTimeStamp(p):void 0,n=S.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=_(a,v)),p&&p.length>0&&r.samples.push({pts:this.initPTS,dts:this.initPTS,data:p}),i=this.initPTS;s<n;){if(this.canParse(S,s)){var h=this.appendFrame(t,S,s);h?(this.frameIndex++,i=h.sample.pts,s+=h.length,e=s):s=n}else y.canParse(S,s)?(p=y.getID3Data(S,s),r.samples.push({pts:i,dts:i,data:p}),s+=p.length,e=s):s++;if(s===n&&e!==n){var d=Object(T.sliceUint8)(S,e);this.cachedData?this.cachedData=Object(I.appendUint8Array)(this.cachedData,d):this.cachedData=d}}return{audioTrack:t,avcTrack:Object(x.dummyTrack)(),id3Track:r,textTrack:Object(x.dummyTrack)()}},A.demuxSampleAes=function(S,v,p){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},A.flush=function(S){var v=this.cachedData;return v&&(this.cachedData=null,this.demux(v,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(x.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(x.dummyTrack)()}},A.destroy=function(){},g}(),_=function(A,L){return Object(R.isFiniteNumber)(A)?A*90:L*9e4};b.default=D},"./src/demux/chunk-cache.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"default",function(){return R});var R=function(){function x(){this.chunks=[],this.dataLength=0}var I=x.prototype;return I.push=function(D){this.chunks.push(D),this.dataLength+=D.length},I.flush=function(){var D=this.chunks,_=this.dataLength,g;if(D.length)D.length===1?g=D[0]:g=y(D,_);else return new Uint8Array(0);return this.reset(),g},I.reset=function(){this.chunks.length=0,this.dataLength=0},x}();function y(x,I){for(var T=new Uint8Array(I),D=0,_=0;_<x.length;_++){var g=x[_];T.set(g,D),D+=g.length}return T}},"./src/demux/dummy-demuxed-track.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"dummyTrack",function(){return R});function R(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(k,b,c){"use strict";c.r(b);var R=c("./src/utils/logger.ts"),y=function(){function x(T){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=T,this.bytesAvailable=T.byteLength,this.word=0,this.bitsAvailable=0}var I=x.prototype;return I.loadWord=function(){var D=this.data,_=this.bytesAvailable,g=D.byteLength-_,A=new Uint8Array(4),L=Math.min(4,_);if(L===0)throw new Error("no bytes available");A.set(D.subarray(g,g+L)),this.word=new DataView(A.buffer).getUint32(0),this.bitsAvailable=L*8,this.bytesAvailable-=L},I.skipBits=function(D){var _;this.bitsAvailable>D?(this.word<<=D,this.bitsAvailable-=D):(D-=this.bitsAvailable,_=D>>3,D-=_>>3,this.bytesAvailable-=_,this.loadWord(),this.word<<=D,this.bitsAvailable-=D)},I.readBits=function(D){var _=Math.min(this.bitsAvailable,D),g=this.word>>>32-_;return D>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(),_=D-_,_>0&&this.bitsAvailable?g<<_|this.readBits(_):g},I.skipLZ=function(){var D;for(D=0;D<this.bitsAvailable;++D)if((this.word&2147483648>>>D)!=0)return this.word<<=D,this.bitsAvailable-=D,D;return this.loadWord(),D+this.skipLZ()},I.skipUEG=function(){this.skipBits(1+this.skipLZ())},I.skipEG=function(){this.skipBits(1+this.skipLZ())},I.readUEG=function(){var D=this.skipLZ();return this.readBits(D+1)-1},I.readEG=function(){var D=this.readUEG();return 1&D?1+D>>>1:-1*(D>>>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(D){for(var _=8,g=8,A,L=0;L<D;L++)g!==0&&(A=this.readEG(),g=(_+A+256)%256),_=g===0?_:g},I.readSPS=function(){var D=0,_=0,g=0,A=0,L,S,v,p=this.readUByte.bind(this),s=this.readBits.bind(this),e=this.readUEG.bind(this),i=this.readBoolean.bind(this),t=this.skipBits.bind(this),r=this.skipEG.bind(this),a=this.skipUEG.bind(this),n=this.skipScalingList.bind(this);p();var h=p();if(s(5),t(3),p(),a(),h===100||h===110||h===122||h===244||h===44||h===83||h===86||h===118||h===128){var d=e();if(d===3&&t(1),a(),a(),t(1),i())for(S=d!==3?8:12,v=0;v<S;v++)i()&&(v<6?n(16):n(64))}a();var u=e();if(u===0)e();else if(u===1)for(t(1),r(),r(),L=e(),v=0;v<L;v++)r();a(),t(1);var f=e(),l=e(),o=s(1);o===0&&t(1),t(1),i()&&(D=e(),_=e(),g=e(),A=e());var E=[1,1];if(i()&&i()){var m=p();switch(m){case 1:E=[1,1];break;case 2:E=[12,11];break;case 3:E=[10,11];break;case 4:E=[16,11];break;case 5:E=[40,33];break;case 6:E=[24,11];break;case 7:E=[20,11];break;case 8:E=[32,11];break;case 9:E=[80,33];break;case 10:E=[18,11];break;case 11:E=[15,11];break;case 12:E=[64,33];break;case 13:E=[160,99];break;case 14:E=[4,3];break;case 15:E=[3,2];break;case 16:E=[2,1];break;case 255:{E=[p()<<8|p(),p()<<8|p()];break}}}return{width:Math.ceil((f+1)*16-D*2-_*2),height:(2-o)*(l+1)*16-(o?2:4)*(g+A),pixelRatio:E}},I.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},x}();b.default=y},"./src/demux/id3.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"isHeader",function(){return R}),c.d(b,"isFooter",function(){return y}),c.d(b,"getID3Data",function(){return x}),c.d(b,"canParse",function(){return T}),c.d(b,"getTimeStamp",function(){return D}),c.d(b,"isTimeStampFrame",function(){return _}),c.d(b,"getID3Frames",function(){return A}),c.d(b,"decodeFrame",function(){return L}),c.d(b,"utf8ArrayToStr",function(){return e}),c.d(b,"testables",function(){return i});var R=function(n,h){return h+10<=n.length&&n[h]===73&&n[h+1]===68&&n[h+2]===51&&n[h+3]<255&&n[h+4]<255&&n[h+6]<128&&n[h+7]<128&&n[h+8]<128&&n[h+9]<128},y=function(n,h){return h+10<=n.length&&n[h]===51&&n[h+1]===68&&n[h+2]===73&&n[h+3]<255&&n[h+4]<255&&n[h+6]<128&&n[h+7]<128&&n[h+8]<128&&n[h+9]<128},x=function(n,h){for(var d=h,u=0;R(n,h);){u+=10;var f=I(n,h+6);u+=f,y(n,h+10)&&(u+=10),h+=u}if(u>0)return n.subarray(d,d+u)},I=function(n,h){var d=0;return d=(n[h]&127)<<21,d|=(n[h+1]&127)<<14,d|=(n[h+2]&127)<<7,d|=n[h+3]&127,d},T=function(n,h){return R(n,h)&&I(n,h+6)+10<=n.length-h},D=function(n){for(var h=A(n),d=0;d<h.length;d++){var u=h[d];if(_(u))return s(u)}},_=function(n){return n&&n.key==="PRIV"&&n.info==="com.apple.streaming.transportStreamTimestamp"},g=function(n){var h=String.fromCharCode(n[0],n[1],n[2],n[3]),d=I(n,4),u=10;return{type:h,size:d,data:n.subarray(u,u+d)}},A=function(n){for(var h=0,d=[];R(n,h);){var u=I(n,h+6);h+=10;for(var f=h+u;h+8<f;){var l=g(n.subarray(h)),o=L(l);o&&d.push(o),h+=l.size+10}y(n,h)&&(h+=10)}return d},L=function(n){return n.type==="PRIV"?S(n):n.type[0]==="W"?p(n):v(n)},S=function(n){if(!(n.size<2)){var h=e(n.data,!0),d=new Uint8Array(n.data.subarray(h.length+1));return{key:n.type,info:h,data:d.buffer}}},v=function(n){if(!(n.size<2)){if(n.type==="TXXX"){var h=1,d=e(n.data.subarray(h),!0);h+=d.length+1;var u=e(n.data.subarray(h));return{key:n.type,info:d,data:u}}var f=e(n.data.subarray(1));return{key:n.type,data:f}}},p=function(n){if(n.type==="WXXX"){if(n.size<2)return;var h=1,d=e(n.data.subarray(h),!0);h+=d.length+1;var u=e(n.data.subarray(h));return{key:n.type,info:d,data:u}}var f=e(n.data);return{key:n.type,data:f}},s=function(n){if(n.data.byteLength===8){var h=new Uint8Array(n.data),d=h[3]&1,u=(h[4]<<23)+(h[5]<<15)+(h[6]<<7)+h[7];return u/=45,d&&(u+=4772185884e-2),Math.round(u)}},e=function(n,h){h===void 0&&(h=!1);var d=r();if(d){var u=d.decode(n);if(h){var f=u.indexOf("\0");return f!==-1?u.substring(0,f):u}return u.replace(/\0/g,"")}for(var l=n.length,o,E,m,O="",P=0;P<l;){if(o=n[P++],o===0&&h)return O;if(o===0||o===3)continue;switch(o>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:O+=String.fromCharCode(o);break;case 12:case 13:E=n[P++],O+=String.fromCharCode((o&31)<<6|E&63);break;case 14:E=n[P++],m=n[P++],O+=String.fromCharCode((o&15)<<12|(E&63)<<6|(m&63)<<0);break;default:}}return O},i={decodeTextFrame:v},t;function r(){return!t&&typeof self.TextDecoder!="undefined"&&(t=new self.TextDecoder("utf-8")),t}},"./src/demux/mp3demuxer.ts":function(k,b,c){"use strict";c.r(b);var R=c("./src/demux/base-audio-demuxer.ts"),y=c("./src/demux/id3.ts"),x=c("./src/utils/logger.ts"),I=c("./src/demux/mpegaudio.ts");function T(g,A){g.prototype=Object.create(A.prototype),g.prototype.constructor=g,D(g,A)}function D(g,A){return D=Object.setPrototypeOf||function(S,v){return S.__proto__=v,S},D(g,A)}var _=function(g){T(A,g);function A(){return g.apply(this,arguments)||this}var L=A.prototype;return L.resetInitSegment=function(v,p,s){g.prototype.resetInitSegment.call(this,v,p,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:v,duration:s,inputTimeScale:9e4,dropped:0}},A.probe=function(v){if(!v)return!1;for(var p=y.getID3Data(v,0)||[],s=p.length,e=v.length;s<e;s++)if(I.probe(v,s))return x.logger.log("MPEG Audio sync word found !"),!0;return!1},L.canParse=function(v,p){return I.canParse(v,p)},L.appendFrame=function(v,p,s){if(this.initPTS!==null)return I.appendFrame(v,p,s,this.initPTS,this.frameIndex)},A}(R.default);_.minProbeByteLength=4,b.default=_},"./src/demux/mp4demuxer.ts":function(k,b,c){"use strict";c.r(b);var R=c("./src/utils/mp4-tools.ts"),y=c("./src/demux/dummy-demuxed-track.ts"),x=function(){function I(D,_){this.remainderData=null,this.config=void 0,this.config=_}var T=I.prototype;return T.resetTimeStamp=function(){},T.resetInitSegment=function(){},T.resetContiguity=function(){},I.probe=function(_){return Object(R.findBox)({data:_,start:0,end:Math.min(_.length,16384)},["moof"]).length>0},T.demux=function(_){var g=_,A=Object(y.dummyTrack)();if(this.config.progressive){this.remainderData&&(g=Object(R.appendUint8Array)(this.remainderData,_));var L=Object(R.segmentValidRange)(g);this.remainderData=L.remainder,A.samples=L.valid||new Uint8Array}else A.samples=g;return{audioTrack:Object(y.dummyTrack)(),avcTrack:A,id3Track:Object(y.dummyTrack)(),textTrack:Object(y.dummyTrack)()}},T.flush=function(){var _=Object(y.dummyTrack)();return _.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(y.dummyTrack)(),avcTrack:_,id3Track:Object(y.dummyTrack)(),textTrack:Object(y.dummyTrack)()}},T.demuxSampleAes=function(_,g,A){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},T.destroy=function(){},I}();x.minProbeByteLength=1024,b.default=x},"./src/demux/mpegaudio.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"appendFrame",function(){return D}),c.d(b,"parseHeader",function(){return _}),c.d(b,"isHeaderPattern",function(){return g}),c.d(b,"isHeader",function(){return A}),c.d(b,"canParse",function(){return L}),c.d(b,"probe",function(){return S});var R=null,y=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],x=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],I=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],T=[0,1,1,4];function D(v,p,s,e,i){if(!(s+24>p.length)){var t=_(p,s);if(t&&s+t.frameLength<=p.length){var r=t.samplesPerFrame*9e4/t.sampleRate,a=e+i*r,n={unit:p.subarray(s,s+t.frameLength),pts:a,dts:a};return v.config=[],v.channelCount=t.channelCount,v.samplerate=t.sampleRate,v.samples.push(n),{sample:n,length:t.frameLength,missing:0}}}}function _(v,p){var s=v[p+1]>>3&3,e=v[p+1]>>1&3,i=v[p+2]>>4&15,t=v[p+2]>>2&3;if(s!==1&&i!==0&&i!==15&&t!==3){var r=v[p+2]>>1&1,a=v[p+3]>>6,n=s===3?3-e:e===3?3:4,h=y[n*14+i-1]*1e3,d=s===3?0:s===2?1:2,u=x[d*3+t],f=a===3?1:2,l=I[s][e],o=T[e],E=l*8*o,m=Math.floor(l*h/u+r)*o;if(R===null){var O=navigator.userAgent||"",P=O.match(/Chrome\/(\d+)/i);R=P?parseInt(P[1]):0}var M=!!R&&R<=87;return M&&e===2&&h>=224e3&&a===0&&(v[p+3]=v[p+3]|128),{sampleRate:u,channelCount:f,frameLength:m,samplesPerFrame:E}}}function g(v,p){return v[p]===255&&(v[p+1]&224)==224&&(v[p+1]&6)!=0}function A(v,p){return p+1<v.length&&g(v,p)}function L(v,p){var s=4;return g(v,p)&&s<=v.length-p}function S(v,p){if(p+1<v.length&&g(v,p)){var s=4,e=_(v,p),i=s;e!=null&&e.frameLength&&(i=e.frameLength);var t=p+i;return t===v.length||A(v,t)}return!1}},"./src/demux/sample-aes.ts":function(k,b,c){"use strict";c.r(b);var R=c("./src/crypt/decrypter.ts"),y=c("./src/demux/tsdemuxer.ts"),x=function(){function I(D,_,g){this.keyData=void 0,this.decrypter=void 0,this.keyData=g,this.decrypter=new R.default(D,_,{removePKCS7Padding:!1})}var T=I.prototype;return T.decryptBuffer=function(_,g){this.decrypter.decrypt(_,this.keyData.key.buffer,this.keyData.iv.buffer,g)},T.decryptAacSample=function(_,g,A,L){var S=_[g].unit,v=S.subarray(16,S.length-S.length%16),p=v.buffer.slice(v.byteOffset,v.byteOffset+v.length),s=this;this.decryptBuffer(p,function(e){var i=new Uint8Array(e);S.set(i,16),L||s.decryptAacSamples(_,g+1,A)})},T.decryptAacSamples=function(_,g,A){for(;;g++){if(g>=_.length){A();return}if(!(_[g].unit.length<32)){var L=this.decrypter.isSync();if(this.decryptAacSample(_,g,A,L),!L)return}}},T.getAvcEncryptedData=function(_){for(var g=Math.floor((_.length-48)/160)*16+16,A=new Int8Array(g),L=0,S=32;S<_.length-16;S+=160,L+=16)A.set(_.subarray(S,S+16),L);return A},T.getAvcDecryptedUnit=function(_,g){for(var A=new Uint8Array(g),L=0,S=32;S<_.length-16;S+=160,L+=16)_.set(A.subarray(L,L+16),S);return _},T.decryptAvcSample=function(_,g,A,L,S,v){var p=Object(y.discardEPB)(S.data),s=this.getAvcEncryptedData(p),e=this;this.decryptBuffer(s.buffer,function(i){S.data=e.getAvcDecryptedUnit(p,i),v||e.decryptAvcSamples(_,g,A+1,L)})},T.decryptAvcSamples=function(_,g,A,L){if(_ instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;g++,A=0){if(g>=_.length){L();return}for(var S=_[g].units;!(A>=S.length);A++){var v=S[A];if(!(v.data.length<=48||v.type!==1&&v.type!==5)){var p=this.decrypter.isSync();if(this.decryptAvcSample(_,g,A,L,v,p),!p)return}}}},I}();b.default=x},"./src/demux/transmuxer-interface.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"default",function(){return S});var R=c("./node_modules/webworkify-webpack/index.js"),y=c.n(R),x=c("./src/events.ts"),I=c("./src/demux/transmuxer.ts"),T=c("./src/utils/logger.ts"),D=c("./src/errors.ts"),_=c("./src/utils/mediasource-helper.ts"),g=c("./node_modules/eventemitter3/index.js"),A=c.n(g),L=Object(_.getMediaSource)()||{isTypeSupported:function(){return!1}},S=function(){function v(s,e,i,t){var r=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=s,this.id=e,this.onTransmuxComplete=i,this.onFlush=t;var a=s.config,n=function(l,o){o=o||{},o.frag=r.frag,o.id=r.id,s.trigger(l,o)};this.observer=new g.EventEmitter,this.observer.on(x.Events.FRAG_DECRYPTED,n),this.observer.on(x.Events.ERROR,n);var h={mp4:L.isTypeSupported("video/mp4"),mpeg:L.isTypeSupported("audio/mpeg"),mp3:L.isTypeSupported('audio/mp4; codecs="mp3"')},d=navigator.vendor;if(a.enableWorker&&typeof Worker!="undefined"){T.logger.log("demuxing in webworker");var u;try{u=this.worker=R("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),u.addEventListener("message",this.onwmsg),u.onerror=function(f){s.trigger(x.Events.ERROR,{type:D.ErrorTypes.OTHER_ERROR,details:D.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(f.message+" ("+f.filename+":"+f.lineno+")")})},u.postMessage({cmd:"init",typeSupported:h,vendor:d,id:e,config:JSON.stringify(a)})}catch(f){T.logger.warn("Error in worker:",f),T.logger.error("Error while initializing DemuxerWorker, fallback to inline"),u&&self.URL.revokeObjectURL(u.objectURL),this.transmuxer=new I.default(this.observer,h,a,d,e),this.worker=null}}else this.transmuxer=new I.default(this.observer,h,a,d,e)}var p=v.prototype;return p.destroy=function(){var e=this.worker;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.worker=null;else{var i=this.transmuxer;i&&(i.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.observer=null},p.push=function(e,i,t,r,a,n,h,d,u,f){var l,o,E=this;u.transmuxing.start=self.performance.now();var m=this.transmuxer,O=this.worker,P=n?n.start:a.start,M=a.decryptdata,F=this.frag,B=!(F&&a.cc===F.cc),C=!(F&&u.level===F.level),U=F?u.sn-F.sn:-1,w=this.part?u.part-this.part.index:1,N=!C&&(U===1||U===0&&w===1),j=self.performance.now();(C||U||a.stats.parsing.start===0)&&(a.stats.parsing.start=j),n&&(w||!N)&&(n.stats.parsing.start=j);var K=!(F&&((l=a.initSegment)===null||l===void 0?void 0:l.url)===((o=F.initSegment)===null||o===void 0?void 0:o.url)),G=new I.TransmuxState(B,N,d,C,P,K);if(!N||B||K){T.logger.log("[transmuxer-interface, "+a.type+"]: Starting new transmux session for sn: "+u.sn+" p: "+u.part+" level: "+u.level+" id: "+u.id+`
|
|
13
|
+
discontinuity: `+B+`
|
|
14
|
+
trackSwitch: `+C+`
|
|
15
|
+
contiguous: `+N+`
|
|
16
|
+
accurateTimeOffset: `+d+`
|
|
17
|
+
timeOffset: `+P+`
|
|
18
|
+
initSegmentChange: `+K);var Y=new I.TransmuxConfig(t,r,i,h,f);this.configureTransmuxer(Y)}if(this.frag=a,this.part=n,O)O.postMessage({cmd:"demux",data:e,decryptdata:M,chunkMeta:u,state:G},e instanceof ArrayBuffer?[e]:[]);else if(m){var V=m.push(e,M,u,G);Object(I.isPromise)(V)?V.then(function(Z){E.handleTransmuxComplete(Z)}):this.handleTransmuxComplete(V)}},p.flush=function(e){var i=this;e.transmuxing.start=self.performance.now();var t=this.transmuxer,r=this.worker;if(r)r.postMessage({cmd:"flush",chunkMeta:e});else if(t){var a=t.flush(e);Object(I.isPromise)(a)?a.then(function(n){i.handleFlushResult(n,e)}):this.handleFlushResult(a,e)}},p.handleFlushResult=function(e,i){var t=this;e.forEach(function(r){t.handleTransmuxComplete(r)}),this.onFlush(i)},p.onWorkerMessage=function(e){var i=e.data,t=this.hls;switch(i.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(i.data);break}case"flush":{this.onFlush(i.data);break}default:{i.data=i.data||{},i.data.frag=this.frag,i.data.id=this.id,t.trigger(i.event,i.data);break}}},p.configureTransmuxer=function(e){var i=this.worker,t=this.transmuxer;i?i.postMessage({cmd:"configure",config:e}):t&&t.configure(e)},p.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},v}()},"./src/demux/transmuxer-worker.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"default",function(){return D});var R=c("./src/demux/transmuxer.ts"),y=c("./src/events.ts"),x=c("./src/utils/logger.ts"),I=c("./node_modules/eventemitter3/index.js"),T=c.n(I);function D(S){var v=new I.EventEmitter,p=function(e,i){S.postMessage({event:e,data:i})};v.on(y.Events.FRAG_DECRYPTED,p),v.on(y.Events.ERROR,p),S.addEventListener("message",function(s){var e=s.data;switch(e.cmd){case"init":{var i=JSON.parse(e.config);S.transmuxer=new R.default(v,e.typeSupported,i,e.vendor,e.id),Object(x.enableLogs)(i.debug),p("init",null);break}case"configure":{S.transmuxer.configure(e.config);break}case"demux":{var t=S.transmuxer.push(e.data,e.decryptdata,e.chunkMeta,e.state);Object(R.isPromise)(t)?t.then(function(n){_(S,n)}):_(S,t);break}case"flush":{var r=e.chunkMeta,a=S.transmuxer.flush(r);Object(R.isPromise)(a)?a.then(function(n){A(S,n,r)}):A(S,a,r);break}default:break}})}function _(S,v){if(!L(v.remuxResult)){var p=[],s=v.remuxResult,e=s.audio,i=s.video;e&&g(p,e),i&&g(p,i),S.postMessage({event:"transmuxComplete",data:v},p)}}function g(S,v){v.data1&&S.push(v.data1.buffer),v.data2&&S.push(v.data2.buffer)}function A(S,v,p){v.forEach(function(s){_(S,s)}),S.postMessage({event:"flush",data:p})}function L(S){return!S.audio&&!S.video&&!S.text&&!S.id3&&!S.initSegment}},"./src/demux/transmuxer.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"default",function(){return i}),c.d(b,"isPromise",function(){return a}),c.d(b,"TransmuxConfig",function(){return n}),c.d(b,"TransmuxState",function(){return h});var R=c("./src/events.ts"),y=c("./src/errors.ts"),x=c("./src/crypt/decrypter.ts"),I=c("./src/demux/aacdemuxer.ts"),T=c("./src/demux/mp4demuxer.ts"),D=c("./src/demux/tsdemuxer.ts"),_=c("./src/demux/mp3demuxer.ts"),g=c("./src/remux/mp4-remuxer.ts"),A=c("./src/remux/passthrough-remuxer.ts"),L=c("./src/demux/chunk-cache.ts"),S=c("./src/utils/mp4-tools.ts"),v=c("./src/utils/logger.ts"),p;try{p=self.performance.now.bind(self.performance)}catch{v.logger.debug("Unable to use Performance API on this environment"),p=self.Date.now}var s=[{demux:D.default,remux:g.default},{demux:T.default,remux:A.default},{demux:I.default,remux:g.default},{demux:_.default,remux:g.default}],e=1024;s.forEach(function(d){var u=d.demux;e=Math.max(e,u.minProbeByteLength)});var i=function(){function d(f,l,o,E,m){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.cache=new L.default,this.observer=f,this.typeSupported=l,this.config=o,this.vendor=E,this.id=m}var u=d.prototype;return u.configure=function(l){this.transmuxConfig=l,this.decrypter&&this.decrypter.reset()},u.push=function(l,o,E,m){var O=this,P=E.transmuxing;P.executeStart=p();var M=new Uint8Array(l),F=this.cache,B=this.config,C=this.currentTransmuxState,U=this.transmuxConfig;m&&(this.currentTransmuxState=m);var w=t(M,o);if(w&&w.method==="AES-128"){var N=this.getDecrypter();if(B.enableSoftwareAES){var j=N.softwareDecrypt(M,w.key.buffer,w.iv.buffer);if(!j)return P.executeEnd=p(),r(E);M=new Uint8Array(j)}else return this.decryptionPromise=N.webCryptoDecrypt(M,w.key.buffer,w.iv.buffer).then(function(Q){var se=O.push(Q,null,E);return O.decryptionPromise=null,se}),this.decryptionPromise}var K=m||C,G=K.contiguous,Y=K.discontinuity,V=K.trackSwitch,Z=K.accurateTimeOffset,z=K.timeOffset,ie=K.initSegmentChange,X=U.audioCodec,ee=U.videoCodec,ce=U.defaultInitPts,ae=U.duration,ve=U.initSegmentData;if((Y||V||ie)&&this.resetInitSegment(ve,X,ee,ae),(Y||ie)&&this.resetInitialTimestamp(ce),G||this.resetContiguity(),this.needsProbing(M,Y,V)){if(F.dataLength){var q=F.flush();M=Object(S.appendUint8Array)(q,M)}this.configureTransmuxer(M,U)}var J=this.transmux(M,w,z,Z,E),$=this.currentTransmuxState;return $.contiguous=!0,$.discontinuity=!1,$.trackSwitch=!1,P.executeEnd=p(),J},u.flush=function(l){var o=this,E=l.transmuxing;E.executeStart=p();var m=this.decrypter,O=this.cache,P=this.currentTransmuxState,M=this.decryptionPromise;if(M)return M.then(function(){return o.flush(l)});var F=[],B=P.timeOffset;if(m){var C=m.flush();C&&F.push(this.push(C,null,l))}var U=O.dataLength;O.reset();var w=this.demuxer,N=this.remuxer;if(!w||!N)return U>=e&&this.observer.emit(R.Events.ERROR,R.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),E.executeEnd=p(),[r(l)];var j=w.flush(B);return a(j)?j.then(function(K){return o.flushRemux(F,K,l),F}):(this.flushRemux(F,j,l),F)},u.flushRemux=function(l,o,E){var m=o.audioTrack,O=o.avcTrack,P=o.id3Track,M=o.textTrack,F=this.currentTransmuxState,B=F.accurateTimeOffset,C=F.timeOffset;v.logger.log("[transmuxer.ts]: Flushed fragment "+E.sn+(E.part>-1?" p: "+E.part:"")+" of level "+E.level);var U=this.remuxer.remux(m,O,P,M,C,B,!0,this.id);l.push({remuxResult:U,chunkMeta:E}),E.transmuxing.executeEnd=p()},u.resetInitialTimestamp=function(l){var o=this.demuxer,E=this.remuxer;!o||!E||(o.resetTimeStamp(l),E.resetTimeStamp(l))},u.resetContiguity=function(){var l=this.demuxer,o=this.remuxer;!l||!o||(l.resetContiguity(),o.resetNextTimestamp())},u.resetInitSegment=function(l,o,E,m){var O=this.demuxer,P=this.remuxer;!O||!P||(O.resetInitSegment(o,E,m),P.resetInitSegment(l,o,E))},u.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},u.transmux=function(l,o,E,m,O){var P;return o&&o.method==="SAMPLE-AES"?P=this.transmuxSampleAes(l,o,E,m,O):P=this.transmuxUnencrypted(l,E,m,O),P},u.transmuxUnencrypted=function(l,o,E,m){var O=this.demuxer.demux(l,o,!1,!this.config.progressive),P=O.audioTrack,M=O.avcTrack,F=O.id3Track,B=O.textTrack,C=this.remuxer.remux(P,M,F,B,o,E,!1,this.id);return{remuxResult:C,chunkMeta:m}},u.transmuxSampleAes=function(l,o,E,m,O){var P=this;return this.demuxer.demuxSampleAes(l,o,E).then(function(M){var F=P.remuxer.remux(M.audioTrack,M.avcTrack,M.id3Track,M.textTrack,E,m,!1,P.id);return{remuxResult:F,chunkMeta:O}})},u.configureTransmuxer=function(l,o){for(var E=this.config,m=this.observer,O=this.typeSupported,P=this.vendor,M=o.audioCodec,F=o.defaultInitPts,B=o.duration,C=o.initSegmentData,U=o.videoCodec,w,N=0,j=s.length;N<j;N++)if(s[N].demux.probe(l)){w=s[N];break}w||(v.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),w={demux:T.default,remux:A.default});var K=this.demuxer,G=this.remuxer,Y=w.remux,V=w.demux;(!G||!(G instanceof Y))&&(this.remuxer=new Y(m,E,O,P)),(!K||!(K instanceof V))&&(this.demuxer=new V(m,E,O),this.probe=V.probe),this.resetInitSegment(C,M,U,B),this.resetInitialTimestamp(F)},u.needsProbing=function(l,o,E){return!this.demuxer||!this.remuxer||o||E},u.getDecrypter=function(){var l=this.decrypter;return l||(l=this.decrypter=new x.default(this.observer,this.config)),l},d}();function t(d,u){var f=null;return d.byteLength>0&&u!=null&&u.key!=null&&u.iv!==null&&u.method!=null&&(f=u),f}var r=function(u){return{remuxResult:{},chunkMeta:u}};function a(d){return"then"in d&&d.then instanceof Function}var n=function(u,f,l,o,E){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=u,this.videoCodec=f,this.initSegmentData=l,this.duration=o,this.defaultInitPts=E},h=function(u,f,l,o,E,m){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=u,this.contiguous=f,this.accurateTimeOffset=l,this.trackSwitch=o,this.timeOffset=E,this.initSegmentChange=m}},"./src/demux/tsdemuxer.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"discardEPB",function(){return r});var R=c("./src/demux/adts.ts"),y=c("./src/demux/mpegaudio.ts"),x=c("./src/demux/exp-golomb.ts"),I=c("./src/demux/id3.ts"),T=c("./src/demux/sample-aes.ts"),D=c("./src/events.ts"),_=c("./src/utils/mp4-tools.ts"),g=c("./src/utils/logger.ts"),A=c("./src/errors.ts"),L={video:1,audio:2,id3:3,text:4},S=function(){function a(h,d,u){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this.aacLastPTS=null,this._initPTS=null,this._initDTS=null,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=h,this.config=d,this.typeSupported=u}a.probe=function(d){var u=a.syncOffset(d);return u<0?!1:(u&&g.logger.warn("MPEG2-TS detected but first sync word found @ offset "+u+", junk ahead ?"),!0)},a.syncOffset=function(d){for(var u=Math.min(1e3,d.length-3*188),f=0;f<u;){if(d[f]===71&&d[f+188]===71&&d[f+2*188]===71)return f;f++}return-1},a.createTrack=function(d,u){return{container:d==="video"||d==="audio"?"video/mp2t":void 0,type:d,id:L[d],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:d==="audio"?u:void 0}};var n=a.prototype;return n.resetInitSegment=function(d,u,f){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=a.createTrack("video",f),this._audioTrack=a.createTrack("audio",f),this._id3Track=a.createTrack("id3",f),this._txtTrack=a.createTrack("text",f),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=d,this.videoCodec=u,this._duration=f},n.resetTimeStamp=function(){},n.resetContiguity=function(){var d=this._audioTrack,u=this._avcTrack,f=this._id3Track;d&&(d.pesData=null),u&&(u.pesData=null),f&&(f.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},n.demux=function(d,u,f,l){f===void 0&&(f=!1),l===void 0&&(l=!1),f||(this.sampleAes=null);var o,E=this._avcTrack,m=this._audioTrack,O=this._id3Track,P=E.pid,M=E.pesData,F=m.pid,B=O.pid,C=m.pesData,U=O.pesData,w=!1,N=this.pmtParsed,j=this._pmtId,K=d.length;if(this.remainderData&&(d=Object(_.appendUint8Array)(this.remainderData,d),K=d.length,this.remainderData=null),K<188&&!l)return this.remainderData=d,{audioTrack:m,avcTrack:E,id3Track:O,textTrack:this._txtTrack};var G=Math.max(0,a.syncOffset(d));K-=(K+G)%188,K<d.byteLength&&!l&&(this.remainderData=new Uint8Array(d.buffer,K,d.buffer.byteLength-K));for(var Y=0,V=G;V<K;V+=188)if(d[V]===71){var Z=!!(d[V+1]&64),z=((d[V+1]&31)<<8)+d[V+2],ie=(d[V+3]&48)>>4,X=void 0;if(ie>1){if(X=V+5+d[V+4],X===V+188)continue}else X=V+4;switch(z){case P:Z&&(M&&(o=e(M))&&this.parseAVCPES(o,!1),M={data:[],size:0}),M&&(M.data.push(d.subarray(X,V+188)),M.size+=V+188-X);break;case F:Z&&(C&&(o=e(C))&&(m.isAAC?this.parseAACPES(o):this.parseMPEGPES(o)),C={data:[],size:0}),C&&(C.data.push(d.subarray(X,V+188)),C.size+=V+188-X);break;case B:Z&&(U&&(o=e(U))&&this.parseID3PES(o),U={data:[],size:0}),U&&(U.data.push(d.subarray(X,V+188)),U.size+=V+188-X);break;case 0:Z&&(X+=d[X]+1),j=this._pmtId=p(d,X);break;case j:{Z&&(X+=d[X]+1);var ee=s(d,X,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,f);P=ee.avc,P>0&&(E.pid=P),F=ee.audio,F>0&&(m.pid=F,m.isAAC=ee.isAAC),B=ee.id3,B>0&&(O.pid=B),w&&!N&&(g.logger.log("reparse from beginning"),w=!1,V=G-188),N=this.pmtParsed=!0;break}case 17:case 8191:break;default:w=!0;break}}else Y++;Y>0&&this.observer.emit(D.Events.ERROR,D.Events.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+Y+" TS packet/s that do not start with 0x47"}),E.pesData=M,m.pesData=C,O.pesData=U;var ce={audioTrack:m,avcTrack:E,id3Track:O,textTrack:this._txtTrack};return l&&this.extractRemainingSamples(ce),ce},n.flush=function(){var d=this.remainderData;this.remainderData=null;var u;return d?u=this.demux(d,-1,!1,!0):u={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(u),this.sampleAes?this.decrypt(u,this.sampleAes):u},n.extractRemainingSamples=function(d){var u=d.audioTrack,f=d.avcTrack,l=d.id3Track,o=f.pesData,E=u.pesData,m=l.pesData,O;o&&(O=e(o))?(this.parseAVCPES(O,!0),f.pesData=null):f.pesData=o,E&&(O=e(E))?(u.isAAC?this.parseAACPES(O):this.parseMPEGPES(O),u.pesData=null):(E!=null&&E.size&&g.logger.log("last AAC PES packet truncated,might overlap between fragments"),u.pesData=E),m&&(O=e(m))?(this.parseID3PES(O),l.pesData=null):l.pesData=m},n.demuxSampleAes=function(d,u,f){var l=this.demux(d,f,!0,!this.config.progressive),o=this.sampleAes=new T.default(this.observer,this.config,u);return this.decrypt(l,o)},n.decrypt=function(d,u){return new Promise(function(f){var l=d.audioTrack,o=d.avcTrack;l.samples&&l.isAAC?u.decryptAacSamples(l.samples,0,function(){o.samples?u.decryptAvcSamples(o.samples,0,0,function(){f(d)}):f(d)}):o.samples&&u.decryptAvcSamples(o.samples,0,0,function(){f(d)})})},n.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},n.parseAVCPES=function(d,u){var f=this,l=this._avcTrack,o=this.parseAVCNALu(d.data),E=!1,m=this.avcSample,O,P=!1;d.data=null,m&&o.length&&!l.audFound&&(i(m,l),m=this.avcSample=v(!1,d.pts,d.dts,"")),o.forEach(function(M){switch(M.type){case 1:{O=!0,m||(m=f.avcSample=v(!0,d.pts,d.dts,"")),E&&(m.debug+="NDR "),m.frame=!0;var F=M.data;if(P&&F.length>4){var B=new x.default(F).readSliceType();(B===2||B===4||B===7||B===9)&&(m.key=!0)}break}case 5:O=!0,m||(m=f.avcSample=v(!0,d.pts,d.dts,"")),E&&(m.debug+="IDR "),m.key=!0,m.frame=!0;break;case 6:{O=!0,E&&m&&(m.debug+="SEI ");var C=new x.default(r(M.data));C.readUByte();for(var U=0,w=0,N=!1,j=0;!N&&C.bytesAvailable>1;){U=0;do j=C.readUByte(),U+=j;while(j===255);w=0;do j=C.readUByte(),w+=j;while(j===255);if(U===4&&C.bytesAvailable!==0){N=!0;var K=C.readUByte();if(K===181){var G=C.readUShort();if(G===49){var Y=C.readUInt();if(Y===1195456820){var V=C.readUByte();if(V===3){for(var Z=C.readUByte(),z=C.readUByte(),ie=31&Z,X=[Z,z],ee=0;ee<ie;ee++)X.push(C.readUByte()),X.push(C.readUByte()),X.push(C.readUByte());t(f._txtTrack.samples,{type:3,pts:d.pts,bytes:X})}}}}}else if(U===5&&C.bytesAvailable!==0){if(N=!0,w>16){for(var ce=[],ae=0;ae<16;ae++)ce.push(C.readUByte().toString(16)),(ae===3||ae===5||ae===7||ae===9)&&ce.push("-");for(var ve=w-16,q=new Uint8Array(ve),J=0;J<ve;J++)q[J]=C.readUByte();t(f._txtTrack.samples,{pts:d.pts,payloadType:U,uuid:ce.join(""),userData:Object(I.utf8ArrayToStr)(q),userDataBytes:q})}}else if(w<C.bytesAvailable)for(var $=0;$<w;$++)C.readUByte()}break}case 7:if(O=!0,P=!0,E&&m&&(m.debug+="SPS "),!l.sps){var Q=new x.default(M.data),se=Q.readSPS();l.width=se.width,l.height=se.height,l.pixelRatio=se.pixelRatio,l.sps=[M.data],l.duration=f._duration;for(var he=M.data.subarray(1,4),ue="avc1.",fe=0;fe<3;fe++){var ge=he[fe].toString(16);ge.length<2&&(ge="0"+ge),ue+=ge}l.codec=ue}break;case 8:O=!0,E&&m&&(m.debug+="PPS "),l.pps||(l.pps=[M.data]);break;case 9:O=!1,l.audFound=!0,m&&i(m,l),m=f.avcSample=v(!1,d.pts,d.dts,E?"AUD ":"");break;case 12:O=!1;break;default:O=!1,m&&(m.debug+="unknown NAL "+M.type+" ");break}if(m&&O){var Ee=m.units;Ee.push(M)}}),u&&m&&(i(m,l),this.avcSample=null)},n.getLastNalUnit=function(){var d,u=this.avcSample,f;if(!u||u.units.length===0){var l=this._avcTrack.samples;u=l[l.length-1]}if((d=u)!==null&&d!==void 0&&d.units){var o=u.units;f=o[o.length-1]}return f},n.parseAVCNALu=function(d){var u=d.byteLength,f=this._avcTrack,l=f.naluState||0,o=l,E=[],m=0,O,P,M,F=-1,B=0;for(l===-1&&(F=0,B=d[0]&31,l=0,m=1);m<u;){if(O=d[m++],!l){l=O?0:1;continue}if(l===1){l=O?0:2;continue}if(!O)l=3;else if(O===1){if(F>=0){var C={data:d.subarray(F,m-l-1),type:B};E.push(C)}else{var U=this.getLastNalUnit();if(U&&(o&&m<=4-o&&U.state&&(U.data=U.data.subarray(0,U.data.byteLength-o)),P=m-l-1,P>0)){var w=new Uint8Array(U.data.byteLength+P);w.set(U.data,0),w.set(d.subarray(0,P),U.data.byteLength),U.data=w,U.state=0}}m<u?(M=d[m]&31,F=m,B=M,l=0):l=-1}else l=0}if(F>=0&&l>=0){var N={data:d.subarray(F,u),type:B,state:l};E.push(N)}if(E.length===0){var j=this.getLastNalUnit();if(j){var K=new Uint8Array(j.data.byteLength+d.byteLength);K.set(j.data,0),K.set(d,j.data.byteLength),j.data=K}}return f.naluState=l,E},n.parseAACPES=function(d){var u=0,f=this._audioTrack,l=this.aacOverFlow,o=d.data;if(l){this.aacOverFlow=null;var E=l.sample.unit.byteLength,m=Math.min(l.missing,E),O=E-m;l.sample.unit.set(o.subarray(0,m),O),f.samples.push(l.sample),u=l.missing}var P,M;for(P=u,M=o.length;P<M-1&&!R.isHeader(o,P);P++);if(P!==u){var F,B;if(P<M-1?(F="AAC PES did not start with ADTS header,offset:"+P,B=!1):(F="no ADTS header found in AAC PES",B=!0),g.logger.warn("parsing error:"+F),this.observer.emit(D.Events.ERROR,D.Events.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.FRAG_PARSING_ERROR,fatal:B,reason:F}),B)return}R.initTrackConfig(f,this.observer,o,P,this.audioCodec);var C;if(d.pts!==void 0)C=d.pts;else if(l){var U=R.getFrameDuration(f.samplerate);C=l.sample.pts+U}else{g.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var w=0;P<M;)if(R.isHeader(o,P)){if(P+5<M){var N=R.appendFrame(f,o,P,C,w);if(N)if(N.missing)this.aacOverFlow=N;else{P+=N.length,w++;continue}}break}else P++},n.parseMPEGPES=function(d){var u=d.data,f=u.length,l=0,o=0,E=d.pts;if(E===void 0){g.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;o<f;)if(y.isHeader(u,o)){var m=y.appendFrame(this._audioTrack,u,o,E,l);if(m)o+=m.length,l++;else break}else o++},n.parseID3PES=function(d){if(d.pts===void 0){g.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(d)},a}();S.minProbeByteLength=188;function v(a,n,h,d){return{key:a,frame:!1,pts:n,dts:h,units:[],debug:d,length:0}}function p(a,n){return(a[n+10]&31)<<8|a[n+11]}function s(a,n,h,d){var u={audio:-1,avc:-1,id3:-1,isAAC:!0},f=(a[n+1]&15)<<8|a[n+2],l=n+3+f-4,o=(a[n+10]&15)<<8|a[n+11];for(n+=12+o;n<l;){var E=(a[n+1]&31)<<8|a[n+2];switch(a[n]){case 207:if(!d){g.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:u.audio===-1&&(u.audio=E);break;case 21:u.id3===-1&&(u.id3=E);break;case 219:if(!d){g.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:u.avc===-1&&(u.avc=E);break;case 3:case 4:h?u.audio===-1&&(u.audio=E,u.isAAC=!1):g.logger.log("MPEG audio found, not supported in this browser");break;case 36:g.logger.warn("Unsupported HEVC stream type found");break;default:break}n+=((a[n+3]&15)<<8|a[n+4])+5}return u}function e(a){var n=0,h,d,u,f,l,o=a.data;if(!a||a.size===0)return null;for(;o[0].length<19&&o.length>1;){var E=new Uint8Array(o[0].length+o[1].length);E.set(o[0]),E.set(o[1],o[0].length),o[0]=E,o.splice(1,1)}h=o[0];var m=(h[0]<<16)+(h[1]<<8)+h[2];if(m===1){if(d=(h[4]<<8)+h[5],d&&d>a.size-6)return null;var O=h[7];O&192&&(f=(h[9]&14)*536870912+(h[10]&255)*4194304+(h[11]&254)*16384+(h[12]&255)*128+(h[13]&254)/2,O&64?(l=(h[14]&14)*536870912+(h[15]&255)*4194304+(h[16]&254)*16384+(h[17]&255)*128+(h[18]&254)/2,f-l>60*9e4&&(g.logger.warn(Math.round((f-l)/9e4)+"s delta between PTS and DTS, align them"),f=l)):l=f),u=h[8];var P=u+9;if(a.size<=P)return null;a.size-=P;for(var M=new Uint8Array(a.size),F=0,B=o.length;F<B;F++){h=o[F];var C=h.byteLength;if(P)if(P>C){P-=C;continue}else h=h.subarray(P),C-=P,P=0;M.set(h,n),n+=C}return d&&(d-=u+3),{data:M,pts:f,dts:l,len:d}}return null}function i(a,n){if(a.units.length&&a.frame){if(a.pts===void 0){var h=n.samples,d=h.length;if(d){var u=h[d-1];a.pts=u.pts,a.dts=u.dts}else{n.dropped++;return}}n.samples.push(a)}a.debug.length&&g.logger.log(a.pts+"/"+a.dts+":"+a.debug)}function t(a,n){var h=a.length;if(h>0){if(n.pts>=a[h-1].pts)a.push(n);else for(var d=h-1;d>=0;d--)if(n.pts<a[d].pts){a.splice(d,0,n);break}}else a.push(n)}function r(a){for(var n=a.byteLength,h=[],d=1;d<n-2;)a[d]===0&&a[d+1]===0&&a[d+2]===3?(h.push(d+2),d+=2):d++;if(h.length===0)return a;var u=n-h.length,f=new Uint8Array(u),l=0;for(d=0;d<u;l++,d++)l===h[0]&&(l++,h.shift()),f[d]=a[l];return f}b.default=S},"./src/errors.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"ErrorTypes",function(){return R}),c.d(b,"ErrorDetails",function(){return y});var R;(function(x){x.NETWORK_ERROR="networkError",x.MEDIA_ERROR="mediaError",x.KEY_SYSTEM_ERROR="keySystemError",x.MUX_ERROR="muxError",x.OTHER_ERROR="otherError"})(R||(R={}));var y;(function(x){x.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",x.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",x.KEY_SYSTEM_NO_SESSION="keySystemNoSession",x.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",x.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",x.MANIFEST_LOAD_ERROR="manifestLoadError",x.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",x.MANIFEST_PARSING_ERROR="manifestParsingError",x.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",x.LEVEL_EMPTY_ERROR="levelEmptyError",x.LEVEL_LOAD_ERROR="levelLoadError",x.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",x.LEVEL_SWITCH_ERROR="levelSwitchError",x.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",x.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",x.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",x.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",x.FRAG_LOAD_ERROR="fragLoadError",x.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",x.FRAG_DECRYPT_ERROR="fragDecryptError",x.FRAG_PARSING_ERROR="fragParsingError",x.REMUX_ALLOC_ERROR="remuxAllocError",x.KEY_LOAD_ERROR="keyLoadError",x.KEY_LOAD_TIMEOUT="keyLoadTimeOut",x.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",x.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",x.BUFFER_APPEND_ERROR="bufferAppendError",x.BUFFER_APPENDING_ERROR="bufferAppendingError",x.BUFFER_STALLED_ERROR="bufferStalledError",x.BUFFER_FULL_ERROR="bufferFullError",x.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",x.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",x.INTERNAL_EXCEPTION="internalException",x.INTERNAL_ABORTED="aborted",x.UNKNOWN="unknown"})(y||(y={}))},"./src/events.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"Events",function(){return R});var R;(function(y){y.MEDIA_ATTACHING="hlsMediaAttaching",y.MEDIA_ATTACHED="hlsMediaAttached",y.MEDIA_DETACHING="hlsMediaDetaching",y.MEDIA_DETACHED="hlsMediaDetached",y.BUFFER_RESET="hlsBufferReset",y.BUFFER_CODECS="hlsBufferCodecs",y.BUFFER_CREATED="hlsBufferCreated",y.BUFFER_APPENDING="hlsBufferAppending",y.BUFFER_APPENDED="hlsBufferAppended",y.BUFFER_EOS="hlsBufferEos",y.BUFFER_FLUSHING="hlsBufferFlushing",y.BUFFER_FLUSHED="hlsBufferFlushed",y.MANIFEST_LOADING="hlsManifestLoading",y.MANIFEST_LOADED="hlsManifestLoaded",y.MANIFEST_PARSED="hlsManifestParsed",y.LEVEL_SWITCHING="hlsLevelSwitching",y.LEVEL_SWITCHED="hlsLevelSwitched",y.LEVEL_LOADING="hlsLevelLoading",y.LEVEL_LOADED="hlsLevelLoaded",y.LEVEL_UPDATED="hlsLevelUpdated",y.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",y.LEVELS_UPDATED="hlsLevelsUpdated",y.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",y.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",y.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",y.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",y.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",y.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",y.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",y.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",y.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",y.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",y.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",y.CUES_PARSED="hlsCuesParsed",y.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",y.INIT_PTS_FOUND="hlsInitPtsFound",y.FRAG_LOADING="hlsFragLoading",y.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",y.FRAG_LOADED="hlsFragLoaded",y.FRAG_DECRYPTED="hlsFragDecrypted",y.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",y.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",y.FRAG_PARSING_METADATA="hlsFragParsingMetadata",y.FRAG_PARSED="hlsFragParsed",y.FRAG_BUFFERED="hlsFragBuffered",y.FRAG_CHANGED="hlsFragChanged",y.FPS_DROP="hlsFpsDrop",y.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",y.ERROR="hlsError",y.DESTROYING="hlsDestroying",y.KEY_LOADING="hlsKeyLoading",y.KEY_LOADED="hlsKeyLoaded",y.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",y.BACK_BUFFER_REACHED="hlsBackBufferReached"})(R||(R={}))},"./src/hls.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"default",function(){return a});var R=c("./node_modules/url-toolkit/src/url-toolkit.js"),y=c.n(R),x=c("./src/loader/playlist-loader.ts"),I=c("./src/loader/key-loader.ts"),T=c("./src/controller/id3-track-controller.ts"),D=c("./src/controller/latency-controller.ts"),_=c("./src/controller/level-controller.ts"),g=c("./src/controller/fragment-tracker.ts"),A=c("./src/controller/stream-controller.ts"),L=c("./src/is-supported.ts"),S=c("./src/utils/logger.ts"),v=c("./src/config.ts"),p=c("./node_modules/eventemitter3/index.js"),s=c.n(p),e=c("./src/events.ts"),i=c("./src/errors.ts");function t(n,h){for(var d=0;d<h.length;d++){var u=h[d];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(n,u.key,u)}}function r(n,h,d){return h&&t(n.prototype,h),d&&t(n,d),n}var a=function(){n.isSupported=function(){return Object(L.isSupported)()};function n(d){d===void 0&&(d={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new p.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var u=this.config=Object(v.mergeConfig)(n.DefaultConfig,d);this.userConfig=d,Object(S.enableLogs)(u.debug),this._autoLevelCapping=-1,u.progressive&&Object(v.enableStreamingMode)(u);var f=u.abrController,l=u.bufferController,o=u.capLevelController,E=u.fpsController,m=this.abrController=new f(this),O=this.bufferController=new l(this),P=this.capLevelController=new o(this),M=new E(this),F=new x.default(this),B=new I.default(this),C=new T.default(this),U=this.levelController=new _.default(this),w=new g.FragmentTracker(this),N=this.streamController=new A.default(this,w);P.setStreamController(N),M.setStreamController(N);var j=[U,N];this.networkControllers=j;var K=[F,B,m,O,P,M,C,w];this.audioTrackController=this.createController(u.audioTrackController,null,j),this.createController(u.audioStreamController,w,j),this.subtitleTrackController=this.createController(u.subtitleTrackController,null,j),this.createController(u.subtitleStreamController,w,j),this.createController(u.timelineController,null,K),this.emeController=this.createController(u.emeController,null,K),this.cmcdController=this.createController(u.cmcdController,null,K),this.latencyController=this.createController(D.default,null,K),this.coreComponents=K}var h=n.prototype;return h.createController=function(u,f,l){if(u){var o=f?new u(this,f):new u(this);return l&&l.push(o),o}return null},h.on=function(u,f,l){l===void 0&&(l=this),this._emitter.on(u,f,l)},h.once=function(u,f,l){l===void 0&&(l=this),this._emitter.once(u,f,l)},h.removeAllListeners=function(u){this._emitter.removeAllListeners(u)},h.off=function(u,f,l,o){l===void 0&&(l=this),this._emitter.off(u,f,l,o)},h.listeners=function(u){return this._emitter.listeners(u)},h.emit=function(u,f,l){return this._emitter.emit(u,f,l)},h.trigger=function(u,f){if(this.config.debug)return this.emit(u,u,f);try{return this.emit(u,u,f)}catch(l){S.logger.error("An internal error happened while handling event "+u+'. Error message: "'+l.message+'". Here is a stacktrace:',l),this.trigger(e.Events.ERROR,{type:i.ErrorTypes.OTHER_ERROR,details:i.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:u,error:l})}return!1},h.listenerCount=function(u){return this._emitter.listenerCount(u)},h.destroy=function(){S.logger.log("destroy"),this.trigger(e.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(u){return u.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(u){return u.destroy()}),this.coreComponents.length=0},h.attachMedia=function(u){S.logger.log("attachMedia"),this._media=u,this.trigger(e.Events.MEDIA_ATTACHING,{media:u})},h.detachMedia=function(){S.logger.log("detachMedia"),this.trigger(e.Events.MEDIA_DETACHING,void 0),this._media=null},h.loadSource=function(u){this.stopLoad();var f=this.media,l=this.url,o=this.url=R.buildAbsoluteURL(self.location.href,u,{alwaysNormalize:!0});S.logger.log("loadSource:"+o),f&&l&&l!==o&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(f)),this.trigger(e.Events.MANIFEST_LOADING,{url:u})},h.startLoad=function(u){u===void 0&&(u=-1),S.logger.log("startLoad("+u+")"),this.networkControllers.forEach(function(f){f.startLoad(u)})},h.stopLoad=function(){S.logger.log("stopLoad"),this.networkControllers.forEach(function(u){u.stopLoad()})},h.swapAudioCodec=function(){S.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},h.recoverMediaError=function(){S.logger.log("recoverMediaError");var u=this._media;this.detachMedia(),u&&this.attachMedia(u)},h.removeLevel=function(u,f){f===void 0&&(f=0),this.levelController.removeLevel(u,f)},r(n,[{key:"levels",get:function(){var u=this.levelController.levels;return u||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(u){S.logger.log("set currentLevel:"+u),this.loadLevel=u,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(u){S.logger.log("set nextLevel:"+u),this.levelController.manualLevel=u,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(u){S.logger.log("set loadLevel:"+u),this.levelController.manualLevel=u}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(u){this.levelController.nextLoadLevel=u}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(u){S.logger.log("set firstLevel:"+u),this.levelController.firstLevel=u}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(u){S.logger.log("set startLevel:"+u),u!==-1&&(u=Math.max(u,this.minAutoLevel)),this.levelController.startLevel=u}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(u){var f=!!u;f!==this.config.capLevelToPlayerSize&&(f?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=f)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(u){this._autoLevelCapping!==u&&(S.logger.log("set autoLevelCapping:"+u),this._autoLevelCapping=u)}},{key:"bandwidthEstimate",get:function(){var u=this.abrController.bwEstimator;return u?u.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var u=this.levels,f=this.config.minAutoBitrate;if(!u)return 0;for(var l=u.length,o=0;o<l;o++)if(u[o].maxBitrate>f)return o;return 0}},{key:"maxAutoLevel",get:function(){var u=this.levels,f=this.autoLevelCapping,l;return f===-1&&u&&u.length?l=u.length-1:l=f,l}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(u){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,u)}},{key:"audioTracks",get:function(){var u=this.audioTrackController;return u?u.audioTracks:[]}},{key:"audioTrack",get:function(){var u=this.audioTrackController;return u?u.audioTrack:-1},set:function(u){var f=this.audioTrackController;f&&(f.audioTrack=u)}},{key:"subtitleTracks",get:function(){var u=this.subtitleTrackController;return u?u.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var u=this.subtitleTrackController;return u?u.subtitleTrack:-1},set:function(u){var f=this.subtitleTrackController;f&&(f.subtitleTrack=u)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var u=this.subtitleTrackController;return u?u.subtitleDisplay:!1},set:function(u){var f=this.subtitleTrackController;f&&(f.subtitleDisplay=u)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(u){this.config.lowLatencyMode=u}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.1.5"}},{key:"Events",get:function(){return e.Events}},{key:"ErrorTypes",get:function(){return i.ErrorTypes}},{key:"ErrorDetails",get:function(){return i.ErrorDetails}},{key:"DefaultConfig",get:function(){return n.defaultConfig?n.defaultConfig:v.hlsDefaultConfig},set:function(u){n.defaultConfig=u}}]),n}();a.defaultConfig=void 0},"./src/is-supported.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"isSupported",function(){return x}),c.d(b,"changeTypeSupported",function(){return I});var R=c("./src/utils/mediasource-helper.ts");function y(){return self.SourceBuffer||self.WebKitSourceBuffer}function x(){var T=Object(R.getMediaSource)();if(!T)return!1;var D=y(),_=T&&typeof T.isTypeSupported=="function"&&T.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),g=!D||D.prototype&&typeof D.prototype.appendBuffer=="function"&&typeof D.prototype.remove=="function";return!!_&&!!g}function I(){var T,D=y();return typeof(D==null||(T=D.prototype)===null||T===void 0?void 0:T.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"default",function(){return S}),c.d(b,"LoadError",function(){return p});var R=c("./src/polyfills/number.ts"),y=c("./src/errors.ts");function x(s,e){s.prototype=Object.create(e.prototype),s.prototype.constructor=s,g(s,e)}function I(s){var e=typeof Map=="function"?new Map:void 0;return I=function(t){if(t===null||!_(t))return t;if(typeof t!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e!="undefined"){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return T(t,arguments,A(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),g(r,t)},I(s)}function T(s,e,i){return D()?T=Reflect.construct:T=function(r,a,n){var h=[null];h.push.apply(h,a);var d=Function.bind.apply(r,h),u=new d;return n&&g(u,n.prototype),u},T.apply(null,arguments)}function D(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function _(s){return Function.toString.call(s).indexOf("[native code]")!==-1}function g(s,e){return g=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t},g(s,e)}function A(s){return A=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},A(s)}var L=Math.pow(2,17),S=function(){function s(i){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=i}var e=s.prototype;return e.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},e.abort=function(){this.loader&&this.loader.abort()},e.load=function(t,r){var a=this,n=t.url;if(!n)return Promise.reject(new p({type:y.ErrorTypes.NETWORK_ERROR,details:y.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,networkDetails:null},"Fragment does not have a "+(n?"part list":"url")));this.abort();var h=this.config,d=h.fLoader,u=h.loader;return new Promise(function(f,l){a.loader&&a.loader.destroy();var o=a.loader=t.loader=d?new d(h):new u(h),E=v(t),m={timeout:h.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:h.fragLoadingMaxRetryTimeout,highWaterMark:L};t.stats=o.stats,o.load(E,m,{onSuccess:function(P,M,F,B){a.resetLoader(t,o),f({frag:t,part:null,payload:P.data,networkDetails:B})},onError:function(P,M,F){a.resetLoader(t,o),l(new p({type:y.ErrorTypes.NETWORK_ERROR,details:y.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:P,networkDetails:F}))},onAbort:function(P,M,F){a.resetLoader(t,o),l(new p({type:y.ErrorTypes.NETWORK_ERROR,details:y.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:t,networkDetails:F}))},onTimeout:function(P,M,F){a.resetLoader(t,o),l(new p({type:y.ErrorTypes.NETWORK_ERROR,details:y.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,networkDetails:F}))},onProgress:function(P,M,F,B){r&&r({frag:t,part:null,payload:F,networkDetails:B})}})})},e.loadPart=function(t,r,a){var n=this;this.abort();var h=this.config,d=h.fLoader,u=h.loader;return new Promise(function(f,l){n.loader&&n.loader.destroy();var o=n.loader=t.loader=d?new d(h):new u(h),E=v(t,r),m={timeout:h.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:h.fragLoadingMaxRetryTimeout,highWaterMark:L};r.stats=o.stats,o.load(E,m,{onSuccess:function(P,M,F,B){n.resetLoader(t,o),n.updateStatsFromPart(t,r);var C={frag:t,part:r,payload:P.data,networkDetails:B};a(C),f(C)},onError:function(P,M,F){n.resetLoader(t,o),l(new p({type:y.ErrorTypes.NETWORK_ERROR,details:y.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:r,response:P,networkDetails:F}))},onAbort:function(P,M,F){t.stats.aborted=r.stats.aborted,n.resetLoader(t,o),l(new p({type:y.ErrorTypes.NETWORK_ERROR,details:y.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:t,part:r,networkDetails:F}))},onTimeout:function(P,M,F){n.resetLoader(t,o),l(new p({type:y.ErrorTypes.NETWORK_ERROR,details:y.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:r,networkDetails:F}))}})})},e.updateStatsFromPart=function(t,r){var a=t.stats,n=r.stats,h=n.total;if(a.loaded+=n.loaded,h){var d=Math.round(t.duration/r.duration),u=Math.min(Math.round(a.loaded/h),d),f=d-u,l=f*Math.round(a.loaded/u);a.total=a.loaded+l}else a.total=Math.max(a.loaded,a.total);var o=a.loading,E=n.loading;o.start?o.first+=E.first-E.start:(o.start=E.start,o.first=E.first),o.end=E.end},e.resetLoader=function(t,r){t.loader=null,this.loader===r&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),r.destroy()},s}();function v(s,e){e===void 0&&(e=null);var i=e||s,t={frag:s,part:e,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},r=i.byteRangeStartOffset,a=i.byteRangeEndOffset;return Object(R.isFiniteNumber)(r)&&Object(R.isFiniteNumber)(a)&&(t.rangeStart=r,t.rangeEnd=a),t}var p=function(s){x(e,s);function e(i){for(var t,r=arguments.length,a=new Array(r>1?r-1:0),n=1;n<r;n++)a[n-1]=arguments[n];return t=s.call.apply(s,[this].concat(a))||this,t.data=void 0,t.data=i,t}return e}(I(Error))},"./src/loader/fragment.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"ElementaryStreamTypes",function(){return S}),c.d(b,"BaseSegment",function(){return v}),c.d(b,"Fragment",function(){return p}),c.d(b,"Part",function(){return s});var R=c("./src/polyfills/number.ts"),y=c("./node_modules/url-toolkit/src/url-toolkit.js"),x=c.n(y),I=c("./src/utils/logger.ts"),T=c("./src/loader/level-key.ts"),D=c("./src/loader/load-stats.ts");function _(e,i){e.prototype=Object.create(i.prototype),e.prototype.constructor=e,g(e,i)}function g(e,i){return g=Object.setPrototypeOf||function(r,a){return r.__proto__=a,r},g(e,i)}function A(e,i){for(var t=0;t<i.length;t++){var r=i[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function L(e,i,t){return i&&A(e.prototype,i),t&&A(e,t),e}var S;(function(e){e.AUDIO="audio",e.VIDEO="video",e.AUDIOVIDEO="audiovideo"})(S||(S={}));var v=function(){function e(t){var r;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(r={},r[S.AUDIO]=null,r[S.VIDEO]=null,r[S.AUDIOVIDEO]=null,r),this.baseurl=t}var i=e.prototype;return i.setByteRange=function(r,a){var n=r.split("@",2),h=[];n.length===1?h[0]=a?a.byteRangeEndOffset:0:h[0]=parseInt(n[1]),h[1]=parseInt(n[0])+h[0],this._byteRange=h},L(e,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(y.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(r){this._url=r}}]),e}(),p=function(e){_(i,e);function i(r,a){var n;return n=e.call(this,a)||this,n._decryptdata=null,n.rawProgramDateTime=null,n.programDateTime=null,n.tagList=[],n.duration=0,n.sn=0,n.levelkey=void 0,n.type=void 0,n.loader=null,n.level=-1,n.cc=0,n.startPTS=void 0,n.endPTS=void 0,n.appendedPTS=void 0,n.startDTS=void 0,n.endDTS=void 0,n.start=0,n.deltaPTS=void 0,n.maxStartPTS=void 0,n.minEndPTS=void 0,n.stats=new D.LoadStats,n.urlId=0,n.data=void 0,n.bitrateTest=!1,n.title=null,n.initSegment=null,n.type=r,n}var t=i.prototype;return t.createInitializationVector=function(a){for(var n=new Uint8Array(16),h=12;h<16;h++)n[h]=a>>8*(15-h)&255;return n},t.setDecryptDataFromLevelKey=function(a,n){var h=a;return(a==null?void 0:a.method)==="AES-128"&&a.uri&&!a.iv&&(h=T.LevelKey.fromURI(a.uri),h.method=a.method,h.iv=this.createInitializationVector(n),h.keyFormat="identity"),h},t.setElementaryStreamInfo=function(a,n,h,d,u,f){f===void 0&&(f=!1);var l=this.elementaryStreams,o=l[a];if(!o){l[a]={startPTS:n,endPTS:h,startDTS:d,endDTS:u,partial:f};return}o.startPTS=Math.min(o.startPTS,n),o.endPTS=Math.max(o.endPTS,h),o.startDTS=Math.min(o.startDTS,d),o.endDTS=Math.max(o.endDTS,u)},t.clearElementaryStreamInfo=function(){var a=this.elementaryStreams;a[S.AUDIO]=null,a[S.VIDEO]=null,a[S.AUDIOVIDEO]=null},L(i,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var a=this.sn;typeof a!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&I.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),a=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,a)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!Object(R.isFiniteNumber)(this.programDateTime))return null;var a=Object(R.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+a*1e3}},{key:"encrypted",get:function(){var a;return!!((a=this.decryptdata)!==null&&a!==void 0&&a.keyFormat&&this.decryptdata.uri)}}]),i}(v),s=function(e){_(i,e);function i(t,r,a,n,h){var d;d=e.call(this,a)||this,d.fragOffset=0,d.duration=0,d.gap=!1,d.independent=!1,d.relurl=void 0,d.fragment=void 0,d.index=void 0,d.stats=new D.LoadStats,d.duration=t.decimalFloatingPoint("DURATION"),d.gap=t.bool("GAP"),d.independent=t.bool("INDEPENDENT"),d.relurl=t.enumeratedString("URI"),d.fragment=r,d.index=n;var u=t.enumeratedString("BYTERANGE");return u&&d.setByteRange(u,h),h&&(d.fragOffset=h.fragOffset+h.duration),d}return L(i,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var r=this.elementaryStreams;return!!(r.audio||r.video||r.audiovideo)}}]),i}(v)},"./src/loader/key-loader.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"default",function(){return I});var R=c("./src/events.ts"),y=c("./src/errors.ts"),x=c("./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 D=T.prototype;return D._registerListeners=function(){this.hls.on(R.Events.KEY_LOADING,this.onKeyLoading,this)},D._unregisterListeners=function(){this.hls.off(R.Events.KEY_LOADING,this.onKeyLoading)},D.destroy=function(){this._unregisterListeners();for(var g in this.loaders){var A=this.loaders[g];A&&A.destroy()}this.loaders={}},D.onKeyLoading=function(g,A){var L=A.frag,S=L.type,v=this.loaders[S];if(!L.decryptdata){x.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var p=L.decryptdata.uri;if(p!==this.decrypturl||this.decryptkey===null){var s=this.hls.config;if(v&&(x.logger.warn("abort previous key loader for type:"+S),v.abort()),!p){x.logger.warn("key uri is falsy");return}var e=s.loader,i=L.loader=this.loaders[S]=new e(s);this.decrypturl=p,this.decryptkey=null;var t={url:p,frag:L,responseType:"arraybuffer"},r={timeout:s.fragLoadingTimeOut,maxRetry:0,retryDelay:s.fragLoadingRetryDelay,maxRetryDelay:s.fragLoadingMaxRetryTimeout,highWaterMark:0},a={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};i.load(t,r,a)}else this.decryptkey&&(L.decryptdata.key=this.decryptkey,this.hls.trigger(R.Events.KEY_LOADED,{frag:L}))},D.loadsuccess=function(g,A,L){var S=L.frag;if(!S.decryptdata){x.logger.error("after key load, decryptdata unset");return}this.decryptkey=S.decryptdata.key=new Uint8Array(g.data),S.loader=null,delete this.loaders[S.type],this.hls.trigger(R.Events.KEY_LOADED,{frag:S})},D.loaderror=function(g,A){var L=A.frag,S=L.loader;S&&S.abort(),delete this.loaders[L.type],this.hls.trigger(R.Events.ERROR,{type:y.ErrorTypes.NETWORK_ERROR,details:y.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:L,response:g})},D.loadtimeout=function(g,A){var L=A.frag,S=L.loader;S&&S.abort(),delete this.loaders[L.type],this.hls.trigger(R.Events.ERROR,{type:y.ErrorTypes.NETWORK_ERROR,details:y.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:L})},T}()},"./src/loader/level-details.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"LevelDetails",function(){return T});var R=c("./src/polyfills/number.ts");function y(D,_){for(var g=0;g<_.length;g++){var A=_[g];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(D,A.key,A)}}function x(D,_,g){return _&&y(D.prototype,_),g&&y(D,g),D}var I=10,T=function(){function D(g){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.needSidxRanges=!1,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.fragments=[],this.url=g}var _=D.prototype;return _.reloaded=function(A){if(!A){this.advanced=!0,this.updated=!0;return}var L=this.lastPartSn-A.lastPartSn,S=this.lastPartIndex-A.lastPartIndex;this.updated=this.endSN!==A.endSN||!!S||!!L,this.advanced=this.endSN>A.endSN||L>0||L===0&&S>0,this.updated||this.advanced?this.misses=Math.floor(A.misses*.6):this.misses=A.misses+1,this.availabilityDelay=A.availabilityDelay},x(D,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(R.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||I}},{key:"drift",get:function(){var A=this.driftEndTime-this.driftStartTime;if(A>0){var L=this.driftEnd-this.driftStart;return L*1e3/A}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var A;return(A=this.partList)!==null&&A!==void 0&&A.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var A;return(A=this.fragments)!==null&&A!==void 0&&A.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var A;return(A=this.partList)!==null&&A!==void 0&&A.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var A;return(A=this.partList)!==null&&A!==void 0&&A.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),D}()},"./src/loader/level-key.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"LevelKey",function(){return T});var R=c("./node_modules/url-toolkit/src/url-toolkit.js"),y=c.n(R);function x(D,_){for(var g=0;g<_.length;g++){var A=_[g];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(D,A.key,A)}}function I(D,_,g){return _&&x(D.prototype,_),g&&x(D,g),D}var T=function(){D.fromURL=function(g,A){return new D(g,A)},D.fromURI=function(g){return new D(g)};function D(_,g){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,g?this._uri=Object(R.buildAbsoluteURL)(_,g,{alwaysNormalize:!0}):this._uri=_}return I(D,[{key:"uri",get:function(){return this._uri}}]),D}()},"./src/loader/load-stats.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"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,b,c){"use strict";c.r(b),c.d(b,"default",function(){return i});var R=c("./src/polyfills/number.ts"),y=c("./node_modules/url-toolkit/src/url-toolkit.js"),x=c.n(y),I=c("./src/loader/fragment.ts"),T=c("./src/loader/level-details.ts"),D=c("./src/loader/level-key.ts"),_=c("./src/utils/attr-list.ts"),g=c("./src/utils/logger.ts"),A=c("./src/utils/codecs.ts"),L=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,S=/#EXT-X-MEDIA:(.*)/g,v=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),p=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(PLAYLIST-TYPE):(.+)/.source,/#EXT-X-(MEDIA-SEQUENCE): *(\d+)/.source,/#EXT-X-(SKIP):(.+)/.source,/#EXT-X-(TARGETDURATION): *(\d+)/.source,/#EXT-X-(KEY):(.+)/.source,/#EXT-X-(START):(.+)/.source,/#EXT-X-(ENDLIST)/.source,/#EXT-X-(DISCONTINUITY-SEQ)UENCE: *(\d+)/.source,/#EXT-X-(DIS)CONTINUITY/.source,/#EXT-X-(VERSION):(\d+)/.source,/#EXT-X-(MAP):(.+)/.source,/#EXT-X-(SERVER-CONTROL):(.+)/.source,/#EXT-X-(PART-INF):(.+)/.source,/#EXT-X-(GAP)/.source,/#EXT-X-(BITRATE):\s*(\d+)/.source,/#EXT-X-(PART):(.+)/.source,/#EXT-X-(PRELOAD-HINT):(.+)/.source,/#EXT-X-(RENDITION-REPORT):(.+)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),s=/\.(mp4|m4s|m4v|m4a)$/i;function e(h){var d,u;return s.test((d=(u=y.parseURL(h))===null||u===void 0?void 0:u.path)!=null?d:"")}var i=function(){function h(){}return h.findGroup=function(u,f){for(var l=0;l<u.length;l++){var o=u[l];if(o.id===f)return o}},h.convertAVC1ToAVCOTI=function(u){var f=u.split(".");if(f.length>2){var l=f.shift()+".";return l+=parseInt(f.shift()).toString(16),l+=("000"+parseInt(f.shift()).toString(16)).substr(-4),l}return u},h.resolve=function(u,f){return y.buildAbsoluteURL(f,u,{alwaysNormalize:!0})},h.parseMasterPlaylist=function(u,f){var l=[],o={},E=!1;L.lastIndex=0;for(var m;(m=L.exec(u))!=null;)if(m[1]){var O=new _.AttrList(m[1]),P={attrs:O,bitrate:O.decimalInteger("AVERAGE-BANDWIDTH")||O.decimalInteger("BANDWIDTH"),name:O.NAME,url:h.resolve(m[2],f)},M=O.decimalResolution("RESOLUTION");M&&(P.width=M.width,P.height=M.height),t((O.CODECS||"").split(/[ ,]+/).filter(function(B){return B}),P),P.videoCodec&&P.videoCodec.indexOf("avc1")!==-1&&(P.videoCodec=h.convertAVC1ToAVCOTI(P.videoCodec)),l.push(P)}else if(m[3]){var F=new _.AttrList(m[3]);F["DATA-ID"]&&(E=!0,o[F["DATA-ID"]]=F)}return{levels:l,sessionData:E?o:null}},h.parseMasterPlaylistMedia=function(u,f,l,o){o===void 0&&(o=[]);var E,m=[],O=0;for(S.lastIndex=0;(E=S.exec(u))!==null;){var P=new _.AttrList(E[1]);if(P.TYPE===l){var M={attrs:P,bitrate:0,id:O++,groupId:P["GROUP-ID"],instreamId:P["INSTREAM-ID"],name:P.NAME||P.LANGUAGE||"",type:l,default:P.bool("DEFAULT"),autoselect:P.bool("AUTOSELECT"),forced:P.bool("FORCED"),lang:P.LANGUAGE,url:P.URI?h.resolve(P.URI,f):""};if(o.length){var F=h.findGroup(o,M.groupId)||o[0];r(M,F,"audioCodec"),r(M,F,"textCodec")}m.push(M)}}return m},h.parseLevelPlaylist=function(u,f,l,o,E){var m=new T.LevelDetails(f),O=m.fragments,P=null,M=0,F=0,B=0,C=0,U=null,w=new I.Fragment(o,f),N,j,K,G=-1,Y=!1;for(v.lastIndex=0,m.m3u8=u;(N=v.exec(u))!==null;){Y&&(Y=!1,w=new I.Fragment(o,f),w.start=B,w.sn=M,w.cc=C,w.level=l,P&&(w.initSegment=P,w.rawProgramDateTime=P.rawProgramDateTime));var V=N[1];if(V){w.duration=parseFloat(V);var Z=(" "+N[2]).slice(1);w.title=Z||null,w.tagList.push(Z?["INF",V,Z]:["INF",V])}else if(N[3])Object(R.isFiniteNumber)(w.duration)&&(w.start=B,K&&(w.levelkey=K),w.sn=M,w.level=l,w.cc=C,w.urlId=E,O.push(w),w.relurl=(" "+N[3]).slice(1),n(w,U),U=w,B+=w.duration,M++,F=0,Y=!0);else if(N[4]){var z=(" "+N[4]).slice(1);U?w.setByteRange(z,U):w.setByteRange(z)}else if(N[5])w.rawProgramDateTime=(" "+N[5]).slice(1),w.tagList.push(["PROGRAM-DATE-TIME",w.rawProgramDateTime]),G===-1&&(G=O.length);else{if(N=N[0].match(p),!N){g.logger.warn("No matches on slow regex match for level playlist!");continue}for(j=1;j<N.length&&typeof N[j]=="undefined";j++);var ie=(" "+N[j]).slice(1),X=(" "+N[j+1]).slice(1),ee=N[j+2]?(" "+N[j+2]).slice(1):"";switch(ie){case"PLAYLIST-TYPE":m.type=X.toUpperCase();break;case"MEDIA-SEQUENCE":M=m.startSN=parseInt(X);break;case"SKIP":{var ce=new _.AttrList(X),ae=ce.decimalInteger("SKIPPED-SEGMENTS");if(Object(R.isFiniteNumber)(ae)){m.skippedSegments=ae;for(var ve=ae;ve--;)O.unshift(null);M+=ae}var q=ce.enumeratedString("RECENTLY-REMOVED-DATERANGES");q&&(m.recentlyRemovedDateranges=q.split(" "));break}case"TARGETDURATION":m.targetduration=parseFloat(X);break;case"VERSION":m.version=parseInt(X);break;case"EXTM3U":break;case"ENDLIST":m.live=!1;break;case"#":(X||ee)&&w.tagList.push(ee?[X,ee]:[X]);break;case"DIS":C++;case"GAP":w.tagList.push([ie]);break;case"BITRATE":w.tagList.push([ie,X]);break;case"DISCONTINUITY-SEQ":C=parseInt(X);break;case"KEY":{var J,$=new _.AttrList(X),Q=$.enumeratedString("METHOD"),se=$.URI,he=$.hexadecimalInteger("IV"),ue=$.enumeratedString("KEYFORMATVERSIONS"),fe=$.enumeratedString("KEYID"),ge=(J=$.enumeratedString("KEYFORMAT"))!=null?J:"identity",Ee=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(Ee.indexOf(ge)>-1){g.logger.warn("Keyformat "+ge+" is not supported from the manifest");continue}else if(ge!=="identity")continue;Q&&(K=D.LevelKey.fromURL(f,se),se&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(Q)>=0&&(K.method=Q,K.keyFormat=ge,fe&&(K.keyID=fe),ue&&(K.keyFormatVersions=ue),K.iv=he));break}case"START":{var oe=new _.AttrList(X),le=oe.decimalFloatingPoint("TIME-OFFSET");Object(R.isFiniteNumber)(le)&&(m.startTimeOffset=le);break}case"MAP":{var Te=new _.AttrList(X);w.relurl=Te.URI,Te.BYTERANGE&&w.setByteRange(Te.BYTERANGE),w.level=l,w.sn="initSegment",K&&(w.levelkey=K),w.initSegment=null,P=w,Y=!0;break}case"SERVER-CONTROL":{var de=new _.AttrList(X);m.canBlockReload=de.bool("CAN-BLOCK-RELOAD"),m.canSkipUntil=de.optionalFloat("CAN-SKIP-UNTIL",0),m.canSkipDateRanges=m.canSkipUntil>0&&de.bool("CAN-SKIP-DATERANGES"),m.partHoldBack=de.optionalFloat("PART-HOLD-BACK",0),m.holdBack=de.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var Le=new _.AttrList(X);m.partTarget=Le.decimalFloatingPoint("PART-TARGET");break}case"PART":{var ye=m.partList;ye||(ye=m.partList=[]);var Se=F>0?ye[ye.length-1]:void 0,De=F++,Oe=new I.Part(new _.AttrList(X),w,f,De,Se);ye.push(Oe),w.duration+=Oe.duration;break}case"PRELOAD-HINT":{var W=new _.AttrList(X);m.preloadHint=W;break}case"RENDITION-REPORT":{var H=new _.AttrList(X);m.renditionReports=m.renditionReports||[],m.renditionReports.push(H);break}default:g.logger.warn("line parsed but not handled: "+N);break}}}U&&!U.relurl?(O.pop(),B-=U.duration,m.partList&&(m.fragmentHint=U)):m.partList&&(n(w,U),w.cc=C,m.fragmentHint=w);var re=O.length,ne=O[0],me=O[re-1];if(B+=m.skippedSegments*m.targetduration,B>0&&re&&me){m.averagetargetduration=B/re;var pe=me.sn;m.endSN=pe!=="initSegment"?pe:0,ne&&(m.startCC=ne.cc,ne.initSegment||m.fragments.every(function(te){return te.relurl&&e(te.relurl)})&&(g.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),w=new I.Fragment(o,f),w.relurl=me.relurl,w.level=l,w.sn="initSegment",ne.initSegment=w,m.needSidxRanges=!0))}else m.endSN=0,m.startCC=0;return m.fragmentHint&&(B+=m.fragmentHint.duration),m.totalduration=B,m.endCC=C,G>0&&a(O,G),m},h}();function t(h,d){["video","audio","text"].forEach(function(u){var f=h.filter(function(o){return Object(A.isCodecType)(o,u)});if(f.length){var l=f.filter(function(o){return o.lastIndexOf("avc1",0)===0||o.lastIndexOf("mp4a",0)===0});d[u+"Codec"]=l.length>0?l[0]:f[0],h=h.filter(function(o){return f.indexOf(o)===-1})}}),d.unknownCodecs=h}function r(h,d,u){var f=d[u];f&&(h[u]=f)}function a(h,d){for(var u=h[d],f=d;f--;){var l=h[f];if(!l)return;l.programDateTime=u.programDateTime-l.duration*1e3,u=l}}function n(h,d){h.rawProgramDateTime?h.programDateTime=Date.parse(h.rawProgramDateTime):d!=null&&d.programDateTime&&(h.programDateTime=d.endProgramDateTime),Object(R.isFiniteNumber)(h.programDateTime)||(h.programDateTime=null,h.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(k,b,c){"use strict";c.r(b);var R=c("./src/polyfills/number.ts"),y=c("./src/events.ts"),x=c("./src/errors.ts"),I=c("./src/utils/logger.ts"),T=c("./src/utils/mp4-tools.ts"),D=c("./src/loader/m3u8-parser.ts"),_=c("./src/types/loader.ts"),g=c("./src/utils/attr-list.ts");function A(v){var p=v.type;switch(p){case _.PlaylistContextType.AUDIO_TRACK:return _.PlaylistLevelType.AUDIO;case _.PlaylistContextType.SUBTITLE_TRACK:return _.PlaylistLevelType.SUBTITLE;default:return _.PlaylistLevelType.MAIN}}function L(v,p){var s=v.url;return(s===void 0||s.indexOf("data:")===0)&&(s=p.url),s}var S=function(){function v(s){this.hls=void 0,this.loaders=Object.create(null),this.hls=s,this.registerListeners()}var p=v.prototype;return p.registerListeners=function(){var e=this.hls;e.on(y.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(y.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(y.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.unregisterListeners=function(){var e=this.hls;e.off(y.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(y.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(y.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.createInternalLoader=function(e){var i=this.hls.config,t=i.pLoader,r=i.loader,a=t||r,n=new a(i);return e.loader=n,this.loaders[e.type]=n,n},p.getInternalLoader=function(e){return this.loaders[e.type]},p.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},p.destroyInternalLoaders=function(){for(var e in this.loaders){var i=this.loaders[e];i&&i.destroy(),this.resetInternalLoader(e)}},p.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},p.onManifestLoading=function(e,i){var t=i.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:_.PlaylistContextType.MANIFEST,url:t,deliveryDirectives:null})},p.onLevelLoading=function(e,i){var t=i.id,r=i.level,a=i.url,n=i.deliveryDirectives;this.load({id:t,groupId:null,level:r,responseType:"text",type:_.PlaylistContextType.LEVEL,url:a,deliveryDirectives:n})},p.onAudioTrackLoading=function(e,i){var t=i.id,r=i.groupId,a=i.url,n=i.deliveryDirectives;this.load({id:t,groupId:r,level:null,responseType:"text",type:_.PlaylistContextType.AUDIO_TRACK,url:a,deliveryDirectives:n})},p.onSubtitleTrackLoading=function(e,i){var t=i.id,r=i.groupId,a=i.url,n=i.deliveryDirectives;this.load({id:t,groupId:r,level:null,responseType:"text",type:_.PlaylistContextType.SUBTITLE_TRACK,url:a,deliveryDirectives:n})},p.load=function(e){var i,t=this.hls.config,r=this.getInternalLoader(e);if(r){var a=r.context;if(a&&a.url===e.url){I.logger.trace("[playlist-loader]: playlist request ongoing");return}I.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),r.abort()}var n,h,d,u;switch(e.type){case _.PlaylistContextType.MANIFEST:n=t.manifestLoadingMaxRetry,h=t.manifestLoadingTimeOut,d=t.manifestLoadingRetryDelay,u=t.manifestLoadingMaxRetryTimeout;break;case _.PlaylistContextType.LEVEL:case _.PlaylistContextType.AUDIO_TRACK:case _.PlaylistContextType.SUBTITLE_TRACK:n=0,h=t.levelLoadingTimeOut;break;default:n=t.levelLoadingMaxRetry,h=t.levelLoadingTimeOut,d=t.levelLoadingRetryDelay,u=t.levelLoadingMaxRetryTimeout;break}if(r=this.createInternalLoader(e),(i=e.deliveryDirectives)!==null&&i!==void 0&&i.part){var f;if(e.type===_.PlaylistContextType.LEVEL&&e.level!==null?f=this.hls.levels[e.level].details:e.type===_.PlaylistContextType.AUDIO_TRACK&&e.id!==null?f=this.hls.audioTracks[e.id].details:e.type===_.PlaylistContextType.SUBTITLE_TRACK&&e.id!==null&&(f=this.hls.subtitleTracks[e.id].details),f){var l=f.partTarget,o=f.targetduration;l&&o&&(h=Math.min(Math.max(l*3,o*.8)*1e3,h))}}var E={timeout:h,maxRetry:n,retryDelay:d,maxRetryDelay:u,highWaterMark:0},m={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};r.load(e,E,m)},p.loadsuccess=function(e,i,t,r){if(r===void 0&&(r=null),t.isSidxRequest){this.handleSidxRequest(e,t),this.handlePlaylistLoaded(e,i,t,r);return}this.resetInternalLoader(t.type);var a=e.data;if(a.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(e,t,"no EXTM3U delimiter",r);return}i.parsing.start=performance.now(),a.indexOf("#EXTINF:")>0||a.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,i,t,r):this.handleMasterPlaylist(e,i,t,r)},p.loaderror=function(e,i,t){t===void 0&&(t=null),this.handleNetworkError(i,t,!1,e)},p.loadtimeout=function(e,i,t){t===void 0&&(t=null),this.handleNetworkError(i,t,!0)},p.handleMasterPlaylist=function(e,i,t,r){var a=this.hls,n=e.data,h=L(e,t),d=D.default.parseMasterPlaylist(n,h),u=d.levels,f=d.sessionData;if(!u.length){this.handleManifestParsingError(e,t,"no level found in manifest",r);return}var l=u.map(function(M){return{id:M.attrs.AUDIO,audioCodec:M.audioCodec}}),o=u.map(function(M){return{id:M.attrs.SUBTITLES,textCodec:M.textCodec}}),E=D.default.parseMasterPlaylistMedia(n,h,"AUDIO",l),m=D.default.parseMasterPlaylistMedia(n,h,"SUBTITLES",o),O=D.default.parseMasterPlaylistMedia(n,h,"CLOSED-CAPTIONS");if(E.length){var P=E.some(function(M){return!M.url});!P&&u[0].audioCodec&&!u[0].attrs.AUDIO&&(I.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),E.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new g.AttrList({}),bitrate:0,url:""}))}a.trigger(y.Events.MANIFEST_LOADED,{levels:u,audioTracks:E,subtitles:m,captions:O,url:h,stats:i,networkDetails:r,sessionData:f})},p.handleTrackOrLevelPlaylist=function(e,i,t,r){var a=this.hls,n=t.id,h=t.level,d=t.type,u=L(e,t),f=Object(R.isFiniteNumber)(n)?n:0,l=Object(R.isFiniteNumber)(h)?h:f,o=A(t),E=D.default.parseLevelPlaylist(e.data,u,l,o,f);if(!E.fragments.length){a.trigger(y.Events.ERROR,{type:x.ErrorTypes.NETWORK_ERROR,details:x.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:u,reason:"no fragments found in level",level:typeof t.level=="number"?t.level:void 0});return}if(d===_.PlaylistContextType.MANIFEST){var m={attrs:new g.AttrList({}),bitrate:0,details:E,name:"",url:u};a.trigger(y.Events.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:u,stats:i,networkDetails:r,sessionData:null})}if(i.parsing.end=performance.now(),E.needSidxRanges){var O,P=(O=E.fragments[0].initSegment)===null||O===void 0?void 0:O.url;this.load({url:P,isSidxRequest:!0,type:d,level:h,levelDetails:E,id:n,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}t.levelDetails=E,this.handlePlaylistLoaded(e,i,t,r)},p.handleSidxRequest=function(e,i){var t=Object(T.parseSegmentIndex)(new Uint8Array(e.data));if(!!t){var r=t.references,a=i.levelDetails;r.forEach(function(n,h){var d=n.info,u=a.fragments[h];u.byteRange.length===0&&u.setByteRange(String(1+d.end-d.start)+"@"+String(d.start)),u.initSegment&&u.initSegment.setByteRange(String(t.moovEndOffset)+"@0")})}},p.handleManifestParsingError=function(e,i,t,r){this.hls.trigger(y.Events.ERROR,{type:x.ErrorTypes.NETWORK_ERROR,details:x.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:i.type===_.PlaylistContextType.MANIFEST,url:e.url,reason:t,response:e,context:i,networkDetails:r})},p.handleNetworkError=function(e,i,t,r){t===void 0&&(t=!1),I.logger.warn("[playlist-loader]: A network "+(t?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var a=x.ErrorDetails.UNKNOWN,n=!1,h=this.getInternalLoader(e);switch(e.type){case _.PlaylistContextType.MANIFEST:a=t?x.ErrorDetails.MANIFEST_LOAD_TIMEOUT:x.ErrorDetails.MANIFEST_LOAD_ERROR,n=!0;break;case _.PlaylistContextType.LEVEL:a=t?x.ErrorDetails.LEVEL_LOAD_TIMEOUT:x.ErrorDetails.LEVEL_LOAD_ERROR,n=!1;break;case _.PlaylistContextType.AUDIO_TRACK:a=t?x.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:x.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,n=!1;break;case _.PlaylistContextType.SUBTITLE_TRACK:a=t?x.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:x.ErrorDetails.SUBTITLE_LOAD_ERROR,n=!1;break}h&&this.resetInternalLoader(e.type);var d={type:x.ErrorTypes.NETWORK_ERROR,details:a,fatal:n,url:e.url,loader:h,context:e,networkDetails:i};r&&(d.response=r),this.hls.trigger(y.Events.ERROR,d)},p.handlePlaylistLoaded=function(e,i,t,r){var a=t.type,n=t.level,h=t.id,d=t.groupId,u=t.loader,f=t.levelDetails,l=t.deliveryDirectives;if(!(f!=null&&f.targetduration)){this.handleManifestParsingError(e,t,"invalid target duration",r);return}if(!!u)switch(f.live&&(u.getCacheAge&&(f.ageHeader=u.getCacheAge()||0),(!u.getCacheAge||isNaN(f.ageHeader))&&(f.ageHeader=0)),a){case _.PlaylistContextType.MANIFEST:case _.PlaylistContextType.LEVEL:this.hls.trigger(y.Events.LEVEL_LOADED,{details:f,level:n||0,id:h||0,stats:i,networkDetails:r,deliveryDirectives:l});break;case _.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(y.Events.AUDIO_TRACK_LOADED,{details:f,id:h||0,groupId:d||"",stats:i,networkDetails:r,deliveryDirectives:l});break;case _.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(y.Events.SUBTITLE_TRACK_LOADED,{details:f,id:h||0,groupId:d||"",stats:i,networkDetails:r,deliveryDirectives:l});break}},v}();b.default=S},"./src/polyfills/number.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"isFiniteNumber",function(){return R}),c.d(b,"MAX_SAFE_INTEGER",function(){return y});var R=Number.isFinite||function(x){return typeof x=="number"&&isFinite(x)},y=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(k,b,c){"use strict";c.r(b);var R=function(){function y(){}return y.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}},y}();b.default=R},"./src/remux/mp4-generator.ts":function(k,b,c){"use strict";c.r(b);var R=Math.pow(2,32)-1,y=function(){function x(){}return x.init=function(){x.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var T;for(T in x.types)x.types.hasOwnProperty(T)&&(x.types[T]=[T.charCodeAt(0),T.charCodeAt(1),T.charCodeAt(2),T.charCodeAt(3)]);var D=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:D,audio:_};var g=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),A=new Uint8Array([0,0,0,0,0,0,0,0]);x.STTS=x.STSC=x.STCO=A,x.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),x.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),x.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),x.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var L=new Uint8Array([105,115,111,109]),S=new Uint8Array([97,118,99,49]),v=new Uint8Array([0,0,0,1]);x.FTYP=x.box(x.types.ftyp,L,v,L,S),x.DINF=x.box(x.types.dinf,x.box(x.types.dref,g))},x.box=function(T){for(var D=8,_=arguments.length,g=new Array(_>1?_-1:0),A=1;A<_;A++)g[A-1]=arguments[A];for(var L=g.length,S=L;L--;)D+=g[L].byteLength;var v=new Uint8Array(D);for(v[0]=D>>24&255,v[1]=D>>16&255,v[2]=D>>8&255,v[3]=D&255,v.set(T,4),L=0,D=8;L<S;L++)v.set(g[L],D),D+=g[L].byteLength;return v},x.hdlr=function(T){return x.box(x.types.hdlr,x.HDLR_TYPES[T])},x.mdat=function(T){return x.box(x.types.mdat,T)},x.mdhd=function(T,D){D*=T;var _=Math.floor(D/(R+1)),g=Math.floor(D%(R+1));return x.box(x.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,T>>24&255,T>>16&255,T>>8&255,T&255,_>>24,_>>16&255,_>>8&255,_&255,g>>24,g>>16&255,g>>8&255,g&255,85,196,0,0]))},x.mdia=function(T){return x.box(x.types.mdia,x.mdhd(T.timescale,T.duration),x.hdlr(T.type),x.minf(T))},x.mfhd=function(T){return x.box(x.types.mfhd,new Uint8Array([0,0,0,0,T>>24,T>>16&255,T>>8&255,T&255]))},x.minf=function(T){return T.type==="audio"?x.box(x.types.minf,x.box(x.types.smhd,x.SMHD),x.DINF,x.stbl(T)):x.box(x.types.minf,x.box(x.types.vmhd,x.VMHD),x.DINF,x.stbl(T))},x.moof=function(T,D,_){return x.box(x.types.moof,x.mfhd(T),x.traf(_,D))},x.moov=function(T){for(var D=T.length,_=[];D--;)_[D]=x.trak(T[D]);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 D=T.length,_=[];D--;)_[D]=x.trex(T[D]);return x.box.apply(null,[x.types.mvex].concat(_))},x.mvhd=function(T,D){D*=T;var _=Math.floor(D/(R+1)),g=Math.floor(D%(R+1)),A=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,T>>24&255,T>>16&255,T>>8&255,T&255,_>>24,_>>16&255,_>>8&255,_&255,g>>24,g>>16&255,g>>8&255,g&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return x.box(x.types.mvhd,A)},x.sdtp=function(T){var D=T.samples||[],_=new Uint8Array(4+D.length),g,A;for(g=0;g<D.length;g++)A=D[g].flags,_[g+4]=A.dependsOn<<4|A.isDependedOn<<2|A.hasRedundancy;return x.box(x.types.sdtp,_)},x.stbl=function(T){return x.box(x.types.stbl,x.stsd(T),x.box(x.types.stts,x.STTS),x.box(x.types.stsc,x.STSC),x.box(x.types.stsz,x.STSZ),x.box(x.types.stco,x.STCO))},x.avc1=function(T){var D=[],_=[],g,A,L;for(g=0;g<T.sps.length;g++)A=T.sps[g],L=A.byteLength,D.push(L>>>8&255),D.push(L&255),D=D.concat(Array.prototype.slice.call(A));for(g=0;g<T.pps.length;g++)A=T.pps[g],L=A.byteLength,_.push(L>>>8&255),_.push(L&255),_=_.concat(Array.prototype.slice.call(A));var S=x.box(x.types.avcC,new Uint8Array([1,D[3],D[4],D[5],252|3,224|T.sps.length].concat(D).concat([T.pps.length]).concat(_))),v=T.width,p=T.height,s=T.pixelRatio[0],e=T.pixelRatio[1];return x.box(x.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,v>>8&255,v&255,p>>8&255,p&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),S,x.box(x.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),x.box(x.types.pasp,new Uint8Array([s>>24,s>>16&255,s>>8&255,s&255,e>>24,e>>16&255,e>>8&255,e&255])))},x.esds=function(T){var D=T.config.length;return new Uint8Array([0,0,0,0,3,23+D,0,1,0,4,15+D,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([D]).concat(T.config).concat([6,1,2]))},x.mp4a=function(T){var D=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,D>>8&255,D&255,0,0]),x.box(x.types.esds,x.esds(T)))},x.mp3=function(T){var D=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,D>>8&255,D&255,0,0]))},x.stsd=function(T){return T.type==="audio"?!T.isAAC&&T.codec==="mp3"?x.box(x.types.stsd,x.STSD,x.mp3(T)):x.box(x.types.stsd,x.STSD,x.mp4a(T)):x.box(x.types.stsd,x.STSD,x.avc1(T))},x.tkhd=function(T){var D=T.id,_=T.duration*T.timescale,g=T.width,A=T.height,L=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,D>>24&255,D>>16&255,D>>8&255,D&255,0,0,0,0,L>>24,L>>16&255,L>>8&255,L&255,S>>24,S>>16&255,S>>8&255,S&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,g>>8&255,g&255,0,0,A>>8&255,A&255,0,0]))},x.traf=function(T,D){var _=x.sdtp(T),g=T.id,A=Math.floor(D/(R+1)),L=Math.floor(D%(R+1));return x.box(x.types.traf,x.box(x.types.tfhd,new Uint8Array([0,0,0,0,g>>24,g>>16&255,g>>8&255,g&255])),x.box(x.types.tfdt,new Uint8Array([1,0,0,0,A>>24,A>>16&255,A>>8&255,A&255,L>>24,L>>16&255,L>>8&255,L&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 D=T.id;return x.box(x.types.trex,new Uint8Array([0,0,0,0,D>>24,D>>16&255,D>>8&255,D&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},x.trun=function(T,D){var _=T.samples||[],g=_.length,A=12+16*g,L=new Uint8Array(A),S,v,p,s,e,i;for(D+=8+A,L.set([0,0,15,1,g>>>24&255,g>>>16&255,g>>>8&255,g&255,D>>>24&255,D>>>16&255,D>>>8&255,D&255],0),S=0;S<g;S++)v=_[S],p=v.duration,s=v.size,e=v.flags,i=v.cts,L.set([p>>>24&255,p>>>16&255,p>>>8&255,p&255,s>>>24&255,s>>>16&255,s>>>8&255,s&255,e.isLeading<<2|e.dependsOn,e.isDependedOn<<6|e.hasRedundancy<<4|e.paddingValue<<1|e.isNonSync,e.degradPrio&240<<8,e.degradPrio&15,i>>>24&255,i>>>16&255,i>>>8&255,i&255],12+16*S);return x.box(x.types.trun,L)},x.initSegment=function(T){x.types||x.init();var D=x.moov(T),_=new Uint8Array(x.FTYP.byteLength+D.byteLength);return _.set(x.FTYP),_.set(D,x.FTYP.byteLength),_},x}();y.types=void 0,y.HDLR_TYPES=void 0,y.STTS=void 0,y.STSC=void 0,y.STCO=void 0,y.STSZ=void 0,y.VMHD=void 0,y.SMHD=void 0,y.STSD=void 0,y.FTYP=void 0,y.DINF=void 0,b.default=y},"./src/remux/mp4-remuxer.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"default",function(){return i}),c.d(b,"normalizePts",function(){return t});var R=c("./src/polyfills/number.ts"),y=c("./src/remux/aac-helper.ts"),x=c("./src/remux/mp4-generator.ts"),I=c("./src/events.ts"),T=c("./src/errors.ts"),D=c("./src/utils/logger.ts"),_=c("./src/types/loader.ts"),g=c("./src/utils/timescale-conversion.ts");function A(){return A=Object.assign||function(h){for(var d=1;d<arguments.length;d++){var u=arguments[d];for(var f in u)Object.prototype.hasOwnProperty.call(u,f)&&(h[f]=u[f])}return h},A.apply(this,arguments)}var L=10*1e3,S=1024,v=1152,p=null,s=null,e=!1,i=function(){function h(u,f,l,o){if(o===void 0&&(o=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=u,this.config=f,this.typeSupported=l,this.ISGenerated=!1,p===null){var E=navigator.userAgent||"",m=E.match(/Chrome\/(\d+)/i);p=m?parseInt(m[1]):0}if(s===null){var O=navigator.userAgent.match(/Safari\/(\d+)/i);s=O?parseInt(O[1]):0}e=!!p&&p<75||!!s&&s<600}var d=h.prototype;return d.destroy=function(){},d.resetTimeStamp=function(f){D.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=f},d.resetNextTimestamp=function(){D.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},d.resetInitSegment=function(){D.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},d.getVideoStartPts=function(f){var l=!1,o=f.reduce(function(E,m){var O=m.pts-E;return O<-4294967296?(l=!0,t(E,m.pts)):O>0?E:m.pts},f[0].pts);return l&&D.logger.debug("PTS rollover detected"),o},d.remux=function(f,l,o,E,m,O,P,M){var F,B,C,U,w,N,j=m,K=m,G=f.pid>-1,Y=l.pid>-1,V=l.samples.length,Z=f.samples.length>0,z=V>1,ie=(!G||Z)&&(!Y||z)||this.ISGenerated||P;if(ie){this.ISGenerated||(C=this.generateIS(f,l,m));var X=this.isVideoContiguous,ee=-1;if(z&&(ee=r(l.samples),!X&&this.config.forceKeyFrameOnDiscontinuity))if(N=!0,ee>0){D.logger.warn("[mp4-remuxer]: Dropped "+ee+" out of "+V+" video samples due to a missing keyframe");var ce=this.getVideoStartPts(l.samples);l.samples=l.samples.slice(ee),l.dropped+=ee,K+=(l.samples[0].pts-ce)/(l.timescale||9e4)}else ee===-1&&(D.logger.warn("[mp4-remuxer]: No keyframe found out of "+V+" video samples"),N=!1);if(this.ISGenerated){if(Z&&z){var ae=this.getVideoStartPts(l.samples),ve=t(f.samples[0].pts,ae)-ae,q=ve/l.inputTimeScale;j+=Math.max(0,q),K+=Math.max(0,-q)}if(Z){if(f.samplerate||(D.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),C=this.generateIS(f,l,m)),B=this.remuxAudio(f,j,this.isAudioContiguous,O,Y||z||M===_.PlaylistLevelType.AUDIO?K:void 0),z){var J=B?B.endPTS-B.startPTS:0;l.inputTimeScale||(D.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),C=this.generateIS(f,l,m)),F=this.remuxVideo(l,K,X,J)}}else z&&(F=this.remuxVideo(l,K,X,0));F&&(F.firstKeyFrame=ee,F.independent=ee!==-1)}}return this.ISGenerated&&(o.samples.length&&(w=this.remuxID3(o,m)),E.samples.length&&(U=this.remuxText(E,m))),{audio:B,video:F,initSegment:C,independent:N,text:U,id3:w}},d.generateIS=function(f,l,o){var E=f.samples,m=l.samples,O=this.typeSupported,P={},M=!Object(R.isFiniteNumber)(this._initPTS),F="audio/mp4",B,C,U;if(M&&(B=C=1/0),f.config&&E.length&&(f.timescale=f.samplerate,f.isAAC||(O.mpeg?(F="audio/mpeg",f.codec=""):O.mp3&&(f.codec="mp3")),P.audio={id:"audio",container:F,codec:f.codec,initSegment:!f.isAAC&&O.mpeg?new Uint8Array(0):x.default.initSegment([f]),metadata:{channelCount:f.channelCount}},M&&(U=f.inputTimeScale,B=C=E[0].pts-Math.round(U*o))),l.sps&&l.pps&&m.length&&(l.timescale=l.inputTimeScale,P.video={id:"main",container:"video/mp4",codec:l.codec,initSegment:x.default.initSegment([l]),metadata:{width:l.width,height:l.height}},M)){U=l.inputTimeScale;var w=this.getVideoStartPts(m),N=Math.round(U*o);C=Math.min(C,t(m[0].dts,w)-N),B=Math.min(B,w-N)}if(Object.keys(P).length)return this.ISGenerated=!0,M&&(this._initPTS=B,this._initDTS=C),{tracks:P,initPTS:B,timescale:U}},d.remuxVideo=function(f,l,o,E){var m=f.inputTimeScale,O=f.samples,P=[],M=O.length,F=this._initPTS,B=this.nextAvcDts,C=8,U,w,N,j=Number.POSITIVE_INFINITY,K=Number.NEGATIVE_INFINITY,G=0,Y=!1;if(!o||B===null){var V=l*m,Z=O[0].pts-t(O[0].dts,O[0].pts);B=V-Z}for(var z=0;z<M;z++){var ie=O[z];if(ie.pts=t(ie.pts-F,B),ie.dts=t(ie.dts-F,B),ie.dts>ie.pts){var X=9e4*.2;G=Math.max(Math.min(G,ie.pts-ie.dts),-1*X)}ie.dts<O[z>0?z-1:z].dts&&(Y=!0)}Y&&O.sort(function(Ie,ke){var Me=Ie.dts-ke.dts,Ne=Ie.pts-ke.pts;return Me||Ne}),w=O[0].dts,N=O[O.length-1].dts;var ee=Math.round((N-w)/(M-1));if(G<0){if(G<ee*-2){D.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(g.toMsFromMpegTsClock)(-ee,!0)+" ms");for(var ce=G,ae=0;ae<M;ae++)O[ae].dts=ce=Math.max(ce,O[ae].pts-ee),O[ae].pts=Math.max(ce,O[ae].pts)}else{D.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(g.toMsFromMpegTsClock)(G,!0)+" ms to overcome this issue");for(var ve=0;ve<M;ve++)O[ve].dts=O[ve].dts+G}w=O[0].dts}if(o){var q=w-B,J=q>ee,$=q<-1;if(J||$){J?D.logger.warn("AVC: "+Object(g.toMsFromMpegTsClock)(q,!0)+" ms ("+q+"dts) hole between fragments detected, filling it"):D.logger.warn("AVC: "+Object(g.toMsFromMpegTsClock)(-q,!0)+" ms ("+q+"dts) overlapping between fragments detected"),w=B;var Q=O[0].pts-q;O[0].dts=w,O[0].pts=Q,D.logger.log("Video: First PTS/DTS adjusted: "+Object(g.toMsFromMpegTsClock)(Q,!0)+"/"+Object(g.toMsFromMpegTsClock)(w,!0)+", delta: "+Object(g.toMsFromMpegTsClock)(q,!0)+" ms")}}e&&(w=Math.max(0,w));for(var se=0,he=0,ue=0;ue<M;ue++){for(var fe=O[ue],ge=fe.units,Ee=ge.length,oe=0,le=0;le<Ee;le++)oe+=ge[le].data.length;he+=oe,se+=Ee,fe.length=oe,fe.dts=Math.max(fe.dts,w),fe.pts=Math.max(fe.pts,fe.dts,0),j=Math.min(fe.pts,j),K=Math.max(fe.pts,K)}N=O[M-1].dts;var Te=he+4*se+8,de;try{de=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 Le=new DataView(de.buffer);Le.setUint32(0,Te),de.set(x.default.types.mdat,4);for(var ye=0;ye<M;ye++){for(var Se=O[ye],De=Se.units,Oe=0,W=0,H=De.length;W<H;W++){var re=De[W],ne=re.data,me=re.data.byteLength;Le.setUint32(C,me),C+=4,de.set(ne,C),C+=me,Oe+=4+me}if(ye<M-1)U=O[ye+1].dts-Se.dts;else{var pe=this.config,te=Se.dts-O[ye>0?ye-1:ye].dts;if(pe.stretchShortVideoTrack&&this.nextAudioPts!==null){var Ae=Math.floor(pe.maxBufferHole*m),xe=(E?j+E*m:this.nextAudioPts)-Se.pts;xe>Ae?(U=xe-te,U<0&&(U=te),D.logger.log("[mp4-remuxer]: It is approximately "+xe/90+" ms to the next segment; using duration "+U/90+" ms for the last video frame.")):U=te}else U=te}var Re=Math.round(Se.pts-Se.dts);P.push(new a(Se.key,U,Oe,Re))}if(P.length&&p&&p<70){var we=P[0].flags;we.dependsOn=2,we.isNonSync=0}console.assert(U!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=B=N+U,this.isVideoContiguous=!0;var He=x.default.moof(f.sequenceNumber++,w,A({},f,{samples:P})),Pe="video",Ge={data1:He,data2:de,startPTS:j/m,endPTS:(K+U)/m,startDTS:w/m,endDTS:B/m,type:Pe,hasAudio:!1,hasVideo:!0,nb:P.length,dropped:f.dropped};return f.samples=[],f.dropped=0,console.assert(de.length,"MDAT length must not be zero"),Ge},d.remuxAudio=function(f,l,o,E,m){var O=f.inputTimeScale,P=f.samplerate?f.samplerate:O,M=O/P,F=f.isAAC?S:v,B=F*M,C=this._initPTS,U=!f.isAAC&&this.typeSupported.mpeg,w=[],N=f.samples,j=U?0:8,K=this.nextAudioPts||-1,G=l*O;if(this.isAudioContiguous=o=o||N.length&&K>0&&(E&&Math.abs(G-K)<9e3||Math.abs(t(N[0].pts-C,G)-K)<20*B),N.forEach(function(ne){ne.pts=t(ne.pts-C,G)}),!o||K<0){if(N=N.filter(function(ne){return ne.pts>=0}),!N.length)return;m===0?K=0:E?K=Math.max(0,G):K=N[0].pts}if(f.isAAC)for(var Y=m!==void 0,V=this.config.maxAudioFramesDrift,Z=0,z=K;Z<N.length;Z++){var ie=N[Z],X=ie.pts,ee=X-z,ce=Math.abs(1e3*ee/O);if(ee<=-V*B&&Y)Z===0&&(D.logger.warn("Audio frame @ "+(X/O).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*ee/O)+" ms."),this.nextAudioPts=K=z=X);else if(ee>=V*B&&ce<L&&Y){var ae=Math.round(ee/B);z=X-ae*B,z<0&&(ae--,z+=B),Z===0&&(this.nextAudioPts=K=z),D.logger.warn("[mp4-remuxer]: Injecting "+ae+" audio frame @ "+(z/O).toFixed(3)+"s due to "+Math.round(1e3*ee/O)+" ms gap.");for(var ve=0;ve<ae;ve++){var q=Math.max(z,0),J=y.default.getSilentFrame(f.manifestCodec||f.codec,f.channelCount);J||(D.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),J=ie.unit.subarray()),N.splice(Z,0,{unit:J,pts:q}),z+=B,Z++}}ie.pts=z,z+=B}for(var $=null,Q=null,se,he=0,ue=N.length;ue--;)he+=N[ue].unit.byteLength;for(var fe=0,ge=N.length;fe<ge;fe++){var Ee=N[fe],oe=Ee.unit,le=Ee.pts;if(Q!==null){var Te=w[fe-1];Te.duration=Math.round((le-Q)/M)}else if(o&&f.isAAC&&(le=K),$=le,he>0){he+=j;try{se=new Uint8Array(he)}catch{this.observer.emit(I.Events.ERROR,I.Events.ERROR,{type:T.ErrorTypes.MUX_ERROR,details:T.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:he,reason:"fail allocating audio mdat "+he});return}if(!U){var de=new DataView(se.buffer);de.setUint32(0,he),se.set(x.default.types.mdat,4)}}else return;se.set(oe,j);var Le=oe.byteLength;j+=Le,w.push(new a(!0,F,Le,0)),Q=le}var ye=w.length;if(!!ye){var Se=w[w.length-1];this.nextAudioPts=K=Q+M*Se.duration;var De=U?new Uint8Array(0):x.default.moof(f.sequenceNumber++,$/M,A({},f,{samples:w}));f.samples=[];var Oe=$/O,W=K/O,H="audio",re={data1:De,data2:se,startPTS:Oe,endPTS:W,startDTS:Oe,endDTS:W,type:H,hasAudio:!0,hasVideo:!1,nb:ye};return this.isAudioContiguous=!0,console.assert(se.length,"MDAT length must not be zero"),re}},d.remuxEmptyAudio=function(f,l,o,E){var m=f.inputTimeScale,O=f.samplerate?f.samplerate:m,P=m/O,M=this.nextAudioPts,F=(M!==null?M:E.startDTS*m)+this._initDTS,B=E.endDTS*m+this._initDTS,C=P*S,U=Math.ceil((B-F)/C),w=y.default.getSilentFrame(f.manifestCodec||f.codec,f.channelCount);if(D.logger.warn("[mp4-remuxer]: remux empty Audio"),!w){D.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var N=[],j=0;j<U;j++){var K=F+j*C;N.push({unit:w,pts:K,dts:K})}return f.samples=N,this.remuxAudio(f,l,o,!1)},d.remuxID3=function(f,l){var o=f.samples.length;if(!!o){for(var E=f.inputTimeScale,m=this._initPTS,O=this._initDTS,P=0;P<o;P++){var M=f.samples[P];M.pts=t(M.pts-m,l*E)/E,M.dts=t(M.dts-O,l*E)/E}var F=f.samples;return f.samples=[],{samples:F}}},d.remuxText=function(f,l){var o=f.samples.length;if(!!o){for(var E=f.inputTimeScale,m=this._initPTS,O=0;O<o;O++){var P=f.samples[O];P.pts=t(P.pts-m,l*E)/E}f.samples.sort(function(F,B){return F.pts-B.pts});var M=f.samples;return f.samples=[],{samples:M}}},h}();function t(h,d){var u;if(d===null)return h;for(d<h?u=-8589934592:u=8589934592;Math.abs(h-d)>4294967296;)h+=u;return h}function r(h){for(var d=0;d<h.length;d++)if(h[d].key)return d;return-1}var a=function(d,u,f,l){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=u,this.size=f,this.cts=l,this.flags=new n(d)},n=function(d){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=d?2:1,this.isNonSync=d?0:1}},"./src/remux/passthrough-remuxer.ts":function(k,b,c){"use strict";c.r(b);var R=c("./src/polyfills/number.ts"),y=c("./src/utils/mp4-tools.ts"),x=c("./src/loader/fragment.ts"),I=c("./src/utils/logger.ts"),T=function(){function g(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndDTS=null}var A=g.prototype;return A.destroy=function(){},A.resetTimeStamp=function(S){this.initPTS=S,this.lastEndDTS=null},A.resetNextTimestamp=function(){this.lastEndDTS=null},A.resetInitSegment=function(S,v,p){this.audioCodec=v,this.videoCodec=p,this.generateInitSegment(S),this.emitInitSegment=!0},A.generateInitSegment=function(S){var v=this.audioCodec,p=this.videoCodec;if(!S||!S.byteLength){this.initTracks=void 0,this.initData=void 0;return}var s=this.initData=Object(y.parseInitSegment)(S);v||(v=_(s.audio,x.ElementaryStreamTypes.AUDIO)),p||(p=_(s.video,x.ElementaryStreamTypes.VIDEO));var e={};s.audio&&s.video?e.audiovideo={container:"video/mp4",codec:v+","+p,initSegment:S,id:"main"}:s.audio?e.audio={container:"audio/mp4",codec:v,initSegment:S,id:"audio"}:s.video?e.video={container:"video/mp4",codec:p,initSegment:S,id:"main"}:I.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=e},A.remux=function(S,v,p,s,e){var i=this.initPTS,t=this.lastEndDTS,r={audio:void 0,video:void 0,text:s,id3:p,initSegment:void 0};Object(R.isFiniteNumber)(t)||(t=this.lastEndDTS=e||0);var a=v.samples;if(!a||!a.length)return r;var n={initPTS:void 0,timescale:1},h=this.initData;if((!h||!h.length)&&(this.generateInitSegment(a),h=this.initData),!h||!h.length)return I.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),r;this.emitInitSegment&&(n.tracks=this.initTracks,this.emitInitSegment=!1),Object(R.isFiniteNumber)(i)||(this.initPTS=n.initPTS=i=D(h,a,t));var d=Object(y.getDuration)(a,h),u=t,f=d+u;Object(y.offsetStartDTS)(h,a,i),d>0?this.lastEndDTS=f:(I.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var l=!!h.audio,o=!!h.video,E="";l&&(E+="audio"),o&&(E+="video");var m={data1:a,startPTS:u,startDTS:u,endPTS:f,endDTS:f,type:E,hasAudio:l,hasVideo:o,nb:1,dropped:0};return r.audio=m.type==="audio"?m:void 0,r.video=m.type!=="audio"?m:void 0,r.text=s,r.id3=p,r.initSegment=n,r},g}(),D=function(A,L,S){return Object(y.getStartDTS)(A,L)-S};function _(g,A){var L=g==null?void 0:g.codec;return L&&L.length>4?L:L==="hvc1"?"hvc1.1.c.L120.90":L==="av01"?"av01.0.04M.08":L==="avc1"||A===x.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}b.default=T},"./src/task-loop.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"default",function(){return R});var R=function(){function y(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var x=y.prototype;return x.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},x.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},x.onHandlerDestroyed=function(){},x.hasInterval=function(){return!!this._tickInterval},x.hasNextTick=function(){return!!this._tickTimer},x.setInterval=function(T){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,T),!0)},x.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},x.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},x.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},x.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},x.doTick=function(){},y}()},"./src/types/cmcd.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"CMCDVersion",function(){return R}),c.d(b,"CMCDObjectType",function(){return y}),c.d(b,"CMCDStreamingFormat",function(){return x}),c.d(b,"CMCDStreamType",function(){return I});var R=1,y;(function(T){T.MANIFEST="m",T.AUDIO="a",T.VIDEO="v",T.MUXED="av",T.INIT="i",T.CAPTION="c",T.TIMED_TEXT="tt",T.KEY="k",T.OTHER="o"})(y||(y={}));var x;(function(T){T.DASH="d",T.HLS="h",T.SMOOTH="s",T.OTHER="o"})(x||(x={}));var I;(function(T){T.VOD="v",T.LIVE="l"})(I||(I={}))},"./src/types/level.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"HlsSkip",function(){return x}),c.d(b,"getSkipValue",function(){return I}),c.d(b,"HlsUrlParameters",function(){return T}),c.d(b,"Level",function(){return D});function R(_,g){for(var A=0;A<g.length;A++){var L=g[A];L.enumerable=L.enumerable||!1,L.configurable=!0,"value"in L&&(L.writable=!0),Object.defineProperty(_,L.key,L)}}function y(_,g,A){return g&&R(_.prototype,g),A&&R(_,A),_}var x;(function(_){_.No="",_.Yes="YES",_.v2="v2"})(x||(x={}));function I(_,g){var A=_.canSkipUntil,L=_.canSkipDateRanges,S=_.endSN,v=g!==void 0?g-S:0;return A&&v<A?L?x.v2:x.Yes:x.No}var T=function(){function _(A,L,S){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=A,this.part=L,this.skip=S}var g=_.prototype;return g.addDirectives=function(L){var S=new self.URL(L);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()},_}(),D=function(){function _(g){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[g.url],this.attrs=g.attrs,this.bitrate=g.bitrate,g.details&&(this.details=g.details),this.id=g.id||0,this.name=g.name,this.width=g.width||0,this.height=g.height||0,this.audioCodec=g.audioCodec,this.videoCodec=g.videoCodec,this.unknownCodecs=g.unknownCodecs,this.codecSet=[g.videoCodec,g.audioCodec].filter(function(A){return A}).join(",").replace(/\.[^.,]+/g,"")}return y(_,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(A){var L=A%this.url.length;this._urlId!==L&&(this.details=void 0,this._urlId=L)}}]),_}()},"./src/types/loader.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"PlaylistContextType",function(){return R}),c.d(b,"PlaylistLevelType",function(){return y});var R;(function(x){x.MANIFEST="manifest",x.LEVEL="level",x.AUDIO_TRACK="audioTrack",x.SUBTITLE_TRACK="subtitleTrack"})(R||(R={}));var y;(function(x){x.MAIN="main",x.AUDIO="audio",x.SUBTITLE="subtitle"})(y||(y={}))},"./src/types/transmuxer.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"ChunkMetadata",function(){return R});var R=function(I,T,D,_,g,A){_===void 0&&(_=0),g===void 0&&(g=-1),A===void 0&&(A=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=y(),this.buffering={audio:y(),video:y(),audiovideo:y()},this.level=I,this.sn=T,this.id=D,this.size=_,this.part=g,this.partial=A};function y(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"AttrList",function(){return x});var R=/^(\d+)x(\d+)$/,y=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,x=function(){function I(D){typeof D=="string"&&(D=I.parseAttrList(D));for(var _ in D)D.hasOwnProperty(_)&&(this[_]=D[_])}var T=I.prototype;return T.decimalInteger=function(_){var g=parseInt(this[_],10);return g>Number.MAX_SAFE_INTEGER?1/0:g},T.hexadecimalInteger=function(_){if(this[_]){var g=(this[_]||"0x").slice(2);g=(g.length&1?"0":"")+g;for(var A=new Uint8Array(g.length/2),L=0;L<g.length/2;L++)A[L]=parseInt(g.slice(L*2,L*2+2),16);return A}else return null},T.hexadecimalIntegerAsNumber=function(_){var g=parseInt(this[_],16);return g>Number.MAX_SAFE_INTEGER?1/0:g},T.decimalFloatingPoint=function(_){return parseFloat(this[_])},T.optionalFloat=function(_,g){var A=this[_];return A?parseFloat(A):g},T.enumeratedString=function(_){return this[_]},T.bool=function(_){return this[_]==="YES"},T.decimalResolution=function(_){var g=R.exec(this[_]);if(g!==null)return{width:parseInt(g[1],10),height:parseInt(g[2],10)}},I.parseAttrList=function(_){var g,A={},L='"';for(y.lastIndex=0;(g=y.exec(_))!==null;){var S=g[2];S.indexOf(L)===0&&S.lastIndexOf(L)===S.length-1&&(S=S.slice(1,-1)),A[g[1]]=S}return A},I}()},"./src/utils/binary-search.ts":function(k,b,c){"use strict";c.r(b);var R={search:function(x,I){for(var T=0,D=x.length-1,_=null,g=null;T<=D;){_=(T+D)/2|0,g=x[_];var A=I(g);if(A>0)T=_+1;else if(A<0)D=_-1;else return g}return null}};b.default=R},"./src/utils/buffer-helper.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"BufferHelper",function(){return x});var R=c("./src/utils/logger.ts"),y={length:0,start:function(){return 0},end:function(){return 0}},x=function(){function I(){}return I.isBuffered=function(D,_){try{if(D){for(var g=I.getBuffered(D),A=0;A<g.length;A++)if(_>=g.start(A)&&_<=g.end(A))return!0}}catch{}return!1},I.bufferInfo=function(D,_,g){try{if(D){var A=I.getBuffered(D),L=[],S;for(S=0;S<A.length;S++)L.push({start:A.start(S),end:A.end(S)});return this.bufferedInfo(L,_,g)}}catch{}return{len:0,start:_,end:_,nextStart:void 0}},I.bufferedInfo=function(D,_,g){_=Math.max(0,_),D.sort(function(n,h){var d=n.start-h.start;return d||h.end-n.end});var A=[];if(g)for(var L=0;L<D.length;L++){var S=A.length;if(S){var v=A[S-1].end;D[L].start-v<g?D[L].end>v&&(A[S-1].end=D[L].end):A.push(D[L])}else A.push(D[L])}else A=D;for(var p=0,s,e=_,i=_,t=0;t<A.length;t++){var r=A[t].start,a=A[t].end;if(_+g>=r&&_<a)e=r,i=a,p=i-_;else if(_+g<r){s=r;break}}return{len:p,start:e||0,end:i||0,nextStart:s}},I.getBuffered=function(D){try{return D.buffered}catch(_){return R.logger.log("failed to get media.buffered",_),y}},I}()},"./src/utils/cea-608-parser.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"Row",function(){return i}),c.d(b,"CaptionScreen",function(){return t});var R=c("./src/utils/logger.ts"),y={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},x=function(f){var l=f;return y.hasOwnProperty(f)&&(l=y[f]),String.fromCharCode(l)},I=15,T=100,D={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},_={17:2,18:4,21:6,22:8,23:10,19:13,20:15},g={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},A={25:2,26:4,29:6,30:8,31:10,27:13,28:15},L=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],S;(function(u){u[u.ERROR=0]="ERROR",u[u.TEXT=1]="TEXT",u[u.WARNING=2]="WARNING",u[u.INFO=2]="INFO",u[u.DEBUG=3]="DEBUG",u[u.DATA=3]="DATA"})(S||(S={}));var v=function(){function u(){this.time=null,this.verboseLevel=S.ERROR}var f=u.prototype;return f.log=function(o,E){this.verboseLevel>=o&&R.logger.log(this.time+" ["+o+"] "+E)},u}(),p=function(f){for(var l=[],o=0;o<f.length;o++)l.push(f[o].toString(16));return l},s=function(){function u(l,o,E,m,O){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=l||"white",this.underline=o||!1,this.italics=E||!1,this.background=m||"black",this.flash=O||!1}var f=u.prototype;return f.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},f.setStyles=function(o){for(var E=["foreground","underline","italics","background","flash"],m=0;m<E.length;m++){var O=E[m];o.hasOwnProperty(O)&&(this[O]=o[O])}},f.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},f.equals=function(o){return this.foreground===o.foreground&&this.underline===o.underline&&this.italics===o.italics&&this.background===o.background&&this.flash===o.flash},f.copy=function(o){this.foreground=o.foreground,this.underline=o.underline,this.italics=o.italics,this.background=o.background,this.flash=o.flash},f.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},u}(),e=function(){function u(l,o,E,m,O,P){this.uchar=void 0,this.penState=void 0,this.uchar=l||" ",this.penState=new s(o,E,m,O,P)}var f=u.prototype;return f.reset=function(){this.uchar=" ",this.penState.reset()},f.setChar=function(o,E){this.uchar=o,this.penState.copy(E)},f.setPenState=function(o){this.penState.copy(o)},f.equals=function(o){return this.uchar===o.uchar&&this.penState.equals(o.penState)},f.copy=function(o){this.uchar=o.uchar,this.penState.copy(o.penState)},f.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},u}(),i=function(){function u(l){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var o=0;o<T;o++)this.chars.push(new e);this.logger=l,this.pos=0,this.currPenState=new s}var f=u.prototype;return f.equals=function(o){for(var E=!0,m=0;m<T;m++)if(!this.chars[m].equals(o.chars[m])){E=!1;break}return E},f.copy=function(o){for(var E=0;E<T;E++)this.chars[E].copy(o.chars[E])},f.isEmpty=function(){for(var o=!0,E=0;E<T;E++)if(!this.chars[E].isEmpty()){o=!1;break}return o},f.setCursor=function(o){this.pos!==o&&(this.pos=o),this.pos<0?(this.logger.log(S.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>T&&(this.logger.log(S.DEBUG,"Too large cursor position "+this.pos),this.pos=T)},f.moveCursor=function(o){var E=this.pos+o;if(o>1)for(var m=this.pos+1;m<E+1;m++)this.chars[m].setPenState(this.currPenState);this.setCursor(E)},f.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},f.insertChar=function(o){o>=144&&this.backSpace();var E=x(o);if(this.pos>=T){this.logger.log(S.ERROR,"Cannot insert "+o.toString(16)+" ("+E+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(E,this.currPenState),this.moveCursor(1)},f.clearFromPos=function(o){var E;for(E=o;E<T;E++)this.chars[E].reset()},f.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},f.clearToEndOfRow=function(){this.clearFromPos(this.pos)},f.getTextString=function(){for(var o=[],E=!0,m=0;m<T;m++){var O=this.chars[m].uchar;O!==" "&&(E=!1),o.push(O)}return E?"":o.join("")},f.setPenStyles=function(o){this.currPenState.setStyles(o);var E=this.chars[this.pos];E.setPenState(this.currPenState)},u}(),t=function(){function u(l){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var o=0;o<I;o++)this.rows.push(new i(l));this.logger=l,this.currRow=I-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var f=u.prototype;return f.reset=function(){for(var o=0;o<I;o++)this.rows[o].clear();this.currRow=I-1},f.equals=function(o){for(var E=!0,m=0;m<I;m++)if(!this.rows[m].equals(o.rows[m])){E=!1;break}return E},f.copy=function(o){for(var E=0;E<I;E++)this.rows[E].copy(o.rows[E])},f.isEmpty=function(){for(var o=!0,E=0;E<I;E++)if(!this.rows[E].isEmpty()){o=!1;break}return o},f.backSpace=function(){var o=this.rows[this.currRow];o.backSpace()},f.clearToEndOfRow=function(){var o=this.rows[this.currRow];o.clearToEndOfRow()},f.insertChar=function(o){var E=this.rows[this.currRow];E.insertChar(o)},f.setPen=function(o){var E=this.rows[this.currRow];E.setPenStyles(o)},f.moveCursor=function(o){var E=this.rows[this.currRow];E.moveCursor(o)},f.setCursor=function(o){this.logger.log(S.INFO,"setCursor: "+o);var E=this.rows[this.currRow];E.setCursor(o)},f.setPAC=function(o){this.logger.log(S.INFO,"pacData = "+JSON.stringify(o));var E=o.row-1;if(this.nrRollUpRows&&E<this.nrRollUpRows-1&&(E=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==E){for(var m=0;m<I;m++)this.rows[m].clear();var O=this.currRow+1-this.nrRollUpRows,P=this.lastOutputScreen;if(P){var M=P.rows[O].cueStartTime,F=this.logger.time;if(M&&F!==null&&M<F)for(var B=0;B<this.nrRollUpRows;B++)this.rows[E-this.nrRollUpRows+B+1].copy(P.rows[O+B])}}this.currRow=E;var C=this.rows[this.currRow];if(o.indent!==null){var U=o.indent,w=Math.max(U-1,0);C.setCursor(o.indent),o.color=C.chars[w].penState.foreground}var N={foreground:o.color,underline:o.underline,italics:o.italics,background:"black",flash:!1};this.setPen(N)},f.setBkgData=function(o){this.logger.log(S.INFO,"bkgData = "+JSON.stringify(o)),this.backSpace(),this.setPen(o),this.insertChar(32)},f.setRollUpRows=function(o){this.nrRollUpRows=o},f.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(S.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(S.TEXT,this.getDisplayText());var o=this.currRow+1-this.nrRollUpRows,E=this.rows.splice(o,1)[0];E.clear(),this.rows.splice(this.currRow,0,E),this.logger.log(S.INFO,"Rolling up")},f.getDisplayText=function(o){o=o||!1;for(var E=[],m="",O=-1,P=0;P<I;P++){var M=this.rows[P].getTextString();M&&(O=P+1,o?E.push("Row "+O+": '"+M+"'"):E.push(M.trim()))}return E.length>0&&(o?m="["+E.join(" | ")+"]":m=E.join(`
|
|
19
|
+
`)),m},f.getTextAndFormat=function(){return this.rows},u}(),r=function(){function u(l,o,E){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=l,this.outputFilter=o,this.mode=null,this.verbose=0,this.displayedMemory=new t(E),this.nonDisplayedMemory=new t(E),this.lastOutputScreen=new t(E),this.currRollUpRow=this.displayedMemory.rows[I-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=E}var f=u.prototype;return f.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[I-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},f.getHandler=function(){return this.outputFilter},f.setHandler=function(o){this.outputFilter=o},f.setPAC=function(o){this.writeScreen.setPAC(o)},f.setBkgData=function(o){this.writeScreen.setBkgData(o)},f.setMode=function(o){o!==this.mode&&(this.mode=o,this.logger.log(S.INFO,"MODE="+o),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=o)},f.insertChars=function(o){for(var E=0;E<o.length;E++)this.writeScreen.insertChar(o[E]);var m=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(S.INFO,m+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(S.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},f.ccRCL=function(){this.logger.log(S.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},f.ccBS=function(){this.logger.log(S.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},f.ccAOF=function(){},f.ccAON=function(){},f.ccDER=function(){this.logger.log(S.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},f.ccRU=function(o){this.logger.log(S.INFO,"RU("+o+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(o)},f.ccFON=function(){this.logger.log(S.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},f.ccRDC=function(){this.logger.log(S.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},f.ccTR=function(){this.logger.log(S.INFO,"TR"),this.setMode("MODE_TEXT")},f.ccRTD=function(){this.logger.log(S.INFO,"RTD"),this.setMode("MODE_TEXT")},f.ccEDM=function(){this.logger.log(S.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},f.ccCR=function(){this.logger.log(S.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},f.ccENM=function(){this.logger.log(S.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},f.ccEOC=function(){if(this.logger.log(S.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var o=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=o,this.writeScreen=this.nonDisplayedMemory,this.logger.log(S.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},f.ccTO=function(o){this.logger.log(S.INFO,"TO("+o+") - Tab Offset"),this.writeScreen.moveCursor(o)},f.ccMIDROW=function(o){var E={flash:!1};if(E.underline=o%2==1,E.italics=o>=46,E.italics)E.foreground="white";else{var m=Math.floor(o/2)-16,O=["white","green","blue","cyan","red","yellow","magenta"];E.foreground=O[m]}this.logger.log(S.INFO,"MIDROW: "+JSON.stringify(E)),this.writeScreen.setPen(E)},f.outputDataUpdate=function(o){o===void 0&&(o=!1);var E=this.logger.time;E!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=E:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,E,this.lastOutputScreen),o&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:E),this.lastOutputScreen.copy(this.displayedMemory))},f.cueSplitAtTime=function(o){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,o,this.displayedMemory),this.cueStartTime=o))},u}(),a=function(){function u(l,o,E){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var m=new v;this.channels=[null,new r(l,o,m),new r(l+1,E,m)],this.cmdHistory=d(),this.logger=m}var f=u.prototype;return f.getHandler=function(o){return this.channels[o].getHandler()},f.setHandler=function(o,E){this.channels[o].setHandler(E)},f.addData=function(o,E){var m,O,P,M=!1;this.logger.time=o;for(var F=0;F<E.length;F+=2)if(O=E[F]&127,P=E[F+1]&127,!(O===0&&P===0)){if(this.logger.log(S.DATA,"["+p([E[F],E[F+1]])+"] -> ("+p([O,P])+")"),m=this.parseCmd(O,P),m||(m=this.parseMidrow(O,P)),m||(m=this.parsePAC(O,P)),m||(m=this.parseBackgroundAttributes(O,P)),!m&&(M=this.parseChars(O,P),M)){var B=this.currentChannel;if(B&&B>0){var C=this.channels[B];C.insertChars(M)}else this.logger.log(S.WARNING,"No channel found yet. TEXT-MODE?")}!m&&!M&&this.logger.log(S.WARNING,"Couldn't parse cleaned data "+p([O,P])+" orig: "+p([E[F],E[F+1]]))}},f.parseCmd=function(o,E){var m=this.cmdHistory,O=(o===20||o===28||o===21||o===29)&&E>=32&&E<=47,P=(o===23||o===31)&&E>=33&&E<=35;if(!(O||P))return!1;if(h(o,E,m))return n(null,null,m),this.logger.log(S.DEBUG,"Repeated command ("+p([o,E])+") is dropped"),!0;var M=o===20||o===21||o===23?1:2,F=this.channels[M];return o===20||o===21||o===28||o===29?E===32?F.ccRCL():E===33?F.ccBS():E===34?F.ccAOF():E===35?F.ccAON():E===36?F.ccDER():E===37?F.ccRU(2):E===38?F.ccRU(3):E===39?F.ccRU(4):E===40?F.ccFON():E===41?F.ccRDC():E===42?F.ccTR():E===43?F.ccRTD():E===44?F.ccEDM():E===45?F.ccCR():E===46?F.ccENM():E===47&&F.ccEOC():F.ccTO(E-32),n(o,E,m),this.currentChannel=M,!0},f.parseMidrow=function(o,E){var m=0;if((o===17||o===25)&&E>=32&&E<=47){if(o===17?m=1:m=2,m!==this.currentChannel)return this.logger.log(S.ERROR,"Mismatch channel in midrow parsing"),!1;var O=this.channels[m];return O?(O.ccMIDROW(E),this.logger.log(S.DEBUG,"MIDROW ("+p([o,E])+")"),!0):!1}return!1},f.parsePAC=function(o,E){var m,O=this.cmdHistory,P=(o>=17&&o<=23||o>=25&&o<=31)&&E>=64&&E<=127,M=(o===16||o===24)&&E>=64&&E<=95;if(!(P||M))return!1;if(h(o,E,O))return n(null,null,O),!0;var F=o<=23?1:2;E>=64&&E<=95?m=F===1?D[o]:g[o]:m=F===1?_[o]:A[o];var B=this.channels[F];return B?(B.setPAC(this.interpretPAC(m,E)),n(o,E,O),this.currentChannel=F,!0):!1},f.interpretPAC=function(o,E){var m,O={color:null,italics:!1,indent:null,underline:!1,row:o};return E>95?m=E-96:m=E-64,O.underline=(m&1)==1,m<=13?O.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(m/2)]:m<=15?(O.italics=!0,O.color="white"):O.indent=Math.floor((m-16)/2)*4,O},f.parseChars=function(o,E){var m,O=null,P=null;if(o>=25?(m=2,P=o-8):(m=1,P=o),P>=17&&P<=19){var M;P===17?M=E+80:P===18?M=E+112:M=E+144,this.logger.log(S.INFO,"Special char '"+x(M)+"' in channel "+m),O=[M]}else o>=32&&o<=127&&(O=E===0?[o]:[o,E]);if(O){var F=p(O);this.logger.log(S.DEBUG,"Char codes = "+F.join(",")),n(o,E,this.cmdHistory)}return O},f.parseBackgroundAttributes=function(o,E){var m=(o===16||o===24)&&E>=32&&E<=47,O=(o===23||o===31)&&E>=45&&E<=47;if(!(m||O))return!1;var P,M={};o===16||o===24?(P=Math.floor((E-32)/2),M.background=L[P],E%2==1&&(M.background=M.background+"_semi")):E===45?M.background="transparent":(M.foreground="black",E===47&&(M.underline=!0));var F=o<=23?1:2,B=this.channels[F];return B.setBkgData(M),n(o,E,this.cmdHistory),!0},f.reset=function(){for(var o=0;o<Object.keys(this.channels).length;o++){var E=this.channels[o];E&&E.reset()}this.cmdHistory=d()},f.cueSplitAtTime=function(o){for(var E=0;E<this.channels.length;E++){var m=this.channels[E];m&&m.cueSplitAtTime(o)}},u}();function n(u,f,l){l.a=u,l.b=f}function h(u,f,l){return l.a===u&&l.b===f}function d(){return{a:null,b:null}}b.default=a},"./src/utils/codecs.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"isCodecType",function(){return y}),c.d(b,"isCodecSupportedInMp4",function(){return x});var R={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function y(I,T){var D=R[T];return!!D&&D[I.slice(0,4)]===!0}function x(I,T){return MediaSource.isTypeSupported((T||"video")+'/mp4;codecs="'+I+'"')}},"./src/utils/cues.ts":function(k,b,c){"use strict";c.r(b);var R=c("./src/utils/vttparser.ts"),y=c("./src/utils/webvtt-parser.ts"),x=c("./src/utils/texttrack-utils.ts"),I=/\s/,T={newCue:function(_,g,A,L){for(var S=[],v,p,s,e,i,t=self.VTTCue||self.TextTrackCue,r=0;r<L.rows.length;r++)if(v=L.rows[r],s=!0,e=0,i="",!v.isEmpty()){for(var a=0;a<v.chars.length;a++)I.test(v.chars[a].uchar)&&s?e++:(i+=v.chars[a].uchar,s=!1);v.cueStartTime=g,g===A&&(A+=1e-4),e>=16?e--:e++;var n=Object(R.fixLineBreaks)(i.trim()),h=Object(y.generateCueId)(g,A,n);(!_||!_.cues||!_.cues.getCueById(h))&&(p=new t(g,A,n),p.id=h,p.line=r+1,p.align="left",p.position=10+Math.min(80,Math.floor(e*8/32)*10),S.push(p))}return _&&S.length&&(S.sort(function(d,u){return d.line==="auto"||u.line==="auto"?0:d.line>8&&u.line>8?u.line-d.line:d.line-u.line}),S.forEach(function(d){return Object(x.addCueToTrack)(_,d)})),S}};b.default=T},"./src/utils/discontinuities.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"findFirstFragWithCC",function(){return I}),c.d(b,"shouldAlignOnDiscontinuities",function(){return T}),c.d(b,"findDiscontinuousReferenceFrag",function(){return D}),c.d(b,"adjustSlidingStart",function(){return g}),c.d(b,"alignStream",function(){return A}),c.d(b,"alignPDT",function(){return S}),c.d(b,"alignFragmentByPDTDelta",function(){return v}),c.d(b,"alignMediaPlaylistByPDT",function(){return p});var R=c("./src/polyfills/number.ts"),y=c("./src/utils/logger.ts"),x=c("./src/controller/level-helper.ts");function I(s,e){for(var i=null,t=0,r=s.length;t<r;t++){var a=s[t];if(a&&a.cc===e){i=a;break}}return i}function T(s,e,i){return!!(e.details&&(i.endCC>i.startCC||s&&s.cc<i.startCC))}function D(s,e){var i=s.fragments,t=e.fragments;if(!t.length||!i.length){y.logger.log("No fragments to align");return}var r=I(i,t[0].cc);if(!r||r&&!r.startPTS){y.logger.log("No frag in previous level to align on");return}return r}function _(s,e){if(s){var i=s.start+e;s.start=s.startPTS=i,s.endPTS=i+s.duration}}function g(s,e){for(var i=e.fragments,t=0,r=i.length;t<r;t++)_(i[t],s);e.fragmentHint&&_(e.fragmentHint,s),e.alignedSliding=!0}function A(s,e,i){!e||(L(s,i,e),!i.alignedSliding&&e.details&&S(i,e.details),!i.alignedSliding&&e.details&&!i.skippedSegments&&Object(x.adjustSliding)(e.details,i))}function L(s,e,i){if(T(s,i,e)){var t=D(i.details,e);t&&Object(R.isFiniteNumber)(t.start)&&(y.logger.log("Adjusting PTS using last level due to CC increase within current level "+e.url),g(t.start,e))}}function S(s,e){if(!(!e.fragments.length||!s.hasProgramDateTime||!e.hasProgramDateTime)){var i=e.fragments[0].programDateTime,t=s.fragments[0].programDateTime,r=(t-i)/1e3+e.fragments[0].start;r&&Object(R.isFiniteNumber)(r)&&(y.logger.log("Adjusting PTS using programDateTime delta "+(t-i)+"ms, sliding:"+r.toFixed(3)+" "+s.url+" "),g(r,s))}}function v(s,e){var i=s.programDateTime;if(!!i){var t=(i-e)/1e3;s.start=s.startPTS=t,s.endPTS=t+s.duration}}function p(s,e){if(!(!e.fragments.length||!s.hasProgramDateTime||!e.hasProgramDateTime)){var i=e.fragments[0].programDateTime,t=e.fragments[0].start,r=i-t*1e3;s.fragments.forEach(function(a){v(a,r)}),s.fragmentHint&&v(s.fragmentHint,r),s.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":function(k,b,c){"use strict";c.r(b);var R=c("./src/utils/ewma.ts"),y=function(){function x(T,D,_){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(D)}var I=x.prototype;return I.update=function(D,_){var g=this.slow_,A=this.fast_;this.slow_.halfLife!==D&&(this.slow_=new R.default(D,g.getEstimate(),g.getTotalWeight())),this.fast_.halfLife!==_&&(this.fast_=new R.default(_,A.getEstimate(),A.getTotalWeight()))},I.sample=function(D,_){D=Math.max(D,this.minDelayMs_);var g=8*_,A=D/1e3,L=g/A;this.fast_.sample(A,L),this.slow_.sample(A,L)},I.canEstimate=function(){var D=this.fast_;return D&&D.getTotalWeight()>=this.minWeight_},I.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},I.destroy=function(){},x}();b.default=y},"./src/utils/ewma.ts":function(k,b,c){"use strict";c.r(b);var R=function(){function y(I,T,D){T===void 0&&(T=0),D===void 0&&(D=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_=D}var x=y.prototype;return x.sample=function(T,D){var _=Math.pow(this.alpha_,T);this.estimate_=D*(1-_)+_*this.estimate_,this.totalWeight_+=T},x.getTotalWeight=function(){return this.totalWeight_},x.getEstimate=function(){if(this.alpha_){var T=1-Math.pow(this.alpha_,this.totalWeight_);if(T)return this.estimate_/T}return this.estimate_},y}();b.default=R},"./src/utils/fetch-loader.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"fetchSupported",function(){return v});var R=c("./src/polyfills/number.ts"),y=c("./src/loader/load-stats.ts"),x=c("./src/demux/chunk-cache.ts");function I(t,r){t.prototype=Object.create(r.prototype),t.prototype.constructor=t,A(t,r)}function T(t){var r=typeof Map=="function"?new Map:void 0;return T=function(n){if(n===null||!g(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(typeof r!="undefined"){if(r.has(n))return r.get(n);r.set(n,h)}function h(){return D(n,arguments,L(this).constructor)}return h.prototype=Object.create(n.prototype,{constructor:{value:h,enumerable:!1,writable:!0,configurable:!0}}),A(h,n)},T(t)}function D(t,r,a){return _()?D=Reflect.construct:D=function(h,d,u){var f=[null];f.push.apply(f,d);var l=Function.bind.apply(h,f),o=new l;return u&&A(o,u.prototype),o},D.apply(null,arguments)}function _(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function g(t){return Function.toString.call(t).indexOf("[native code]")!==-1}function A(t,r){return A=Object.setPrototypeOf||function(n,h){return n.__proto__=h,n},A(t,r)}function L(t){return L=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},L(t)}function S(){return S=Object.assign||function(t){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(t[n]=a[n])}return t},S.apply(this,arguments)}function v(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var p=function(){function t(a){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=a.fetchSetup||e,this.controller=new self.AbortController,this.stats=new y.LoadStats}var r=t.prototype;return r.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},r.abortInternal=function(){var n=this.response;(!n||!n.ok)&&(this.stats.aborted=!0,this.controller.abort())},r.abort=function(){var n;this.abortInternal(),(n=this.callbacks)!==null&&n!==void 0&&n.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},r.load=function(n,h,d){var u=this,f=this.stats;if(f.loading.start)throw new Error("Loader can only be used once.");f.loading.start=self.performance.now();var l=s(n,this.controller.signal),o=d.onProgress,E=n.responseType==="arraybuffer",m=E?"byteLength":"length";this.context=n,this.config=h,this.callbacks=d,this.request=this.fetchSetup(n,l),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){u.abortInternal(),d.onTimeout(f,n,u.response)},h.timeout),self.fetch(this.request).then(function(O){if(u.response=u.loader=O,!O.ok){var P=O.status,M=O.statusText;throw new i(M||"fetch, bad network response",P,O)}return f.loading.first=Math.max(self.performance.now(),f.loading.start),f.total=parseInt(O.headers.get("Content-Length")||"0"),o&&Object(R.isFiniteNumber)(h.highWaterMark)?u.loadProgressively(O,f,n,h.highWaterMark,o):E?O.arrayBuffer():O.text()}).then(function(O){var P=u.response;self.clearTimeout(u.requestTimeout),f.loading.end=Math.max(self.performance.now(),f.loading.first),f.loaded=f.total=O[m];var M={url:P.url,data:O};o&&!Object(R.isFiniteNumber)(h.highWaterMark)&&o(f,n,O,P),d.onSuccess(M,f,n,P)}).catch(function(O){if(self.clearTimeout(u.requestTimeout),!f.aborted){var P=O.code||0;d.onError({code:P,text:O.message},n,O.details)}})},r.getCacheAge=function(){var n=null;if(this.response){var h=this.response.headers.get("age");n=h?parseFloat(h):null}return n},r.loadProgressively=function(n,h,d,u,f){u===void 0&&(u=0);var l=new x.default,o=n.body.getReader(),E=function m(){return o.read().then(function(O){if(O.done)return l.dataLength&&f(h,d,l.flush(),n),Promise.resolve(new ArrayBuffer(0));var P=O.value,M=P.length;return h.loaded+=M,M<u||l.dataLength?(l.push(P),l.dataLength>=u&&f(h,d,l.flush(),n)):f(h,d,P,n),m()}).catch(function(){return Promise.reject()})};return E()},t}();function s(t,r){var a={method:"GET",mode:"cors",credentials:"same-origin",signal:r,headers:new self.Headers(S({},t.headers))};return t.rangeEnd&&a.headers.set("Range","bytes="+t.rangeStart+"-"+String(t.rangeEnd-1)),a}function e(t,r){return new self.Request(t.url,r)}var i=function(t){I(r,t);function r(a,n,h){var d;return d=t.call(this,a)||this,d.code=void 0,d.details=void 0,d.code=n,d.details=h,d}return r}(T(Error));b.default=p},"./src/utils/imsc1-ttml-parser.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"IMSC1_CODEC",function(){return g}),c.d(b,"parseIMSC1",function(){return v});var R=c("./src/utils/mp4-tools.ts"),y=c("./src/utils/vttparser.ts"),x=c("./src/utils/vttcue.ts"),I=c("./src/demux/id3.ts"),T=c("./src/utils/timescale-conversion.ts"),D=c("./src/utils/webvtt-parser.ts");function _(){return _=Object.assign||function(u){for(var f=1;f<arguments.length;f++){var l=arguments[f];for(var o in l)Object.prototype.hasOwnProperty.call(l,o)&&(u[o]=l[o])}return u},_.apply(this,arguments)}var g="stpp.ttml.im1t",A=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,L=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,S={left:"start",center:"center",right:"end",start:"start",end:"end"};function v(u,f,l,o,E){var m=Object(R.findBox)(new Uint8Array(u),["mdat"]);if(m.length===0){E(new Error("Could not parse IMSC1 mdat"));return}var O=m[0],P=Object(I.utf8ArrayToStr)(new Uint8Array(u,O.start,O.end-O.start)),M=Object(T.toTimescaleFromScale)(f,1,l);try{o(p(P,M))}catch(F){E(F)}}function p(u,f){var l=new DOMParser,o=l.parseFromString(u,"text/xml"),E=o.getElementsByTagName("tt")[0];if(!E)throw new Error("Invalid ttml");var m={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},O=Object.keys(m).reduce(function(C,U){return C[U]=E.getAttribute("ttp:"+U)||m[U],C},{}),P=E.getAttribute("xml:space")!=="preserve",M=e(s(E,"styling","style")),F=e(s(E,"layout","region")),B=s(E,"body","[begin]");return[].map.call(B,function(C){var U=i(C,P);if(!U||!C.hasAttribute("begin"))return null;var w=n(C.getAttribute("begin"),O),N=n(C.getAttribute("dur"),O),j=n(C.getAttribute("end"),O);if(w===null)throw a(C);if(j===null){if(N===null)throw a(C);j=w+N}var K=new x.default(w-f,j-f,U);K.id=Object(D.generateCueId)(K.startTime,K.endTime,K.text);var G=F[C.getAttribute("region")],Y=M[C.getAttribute("style")];K.position=10,K.size=80;var V=t(G,Y),Z=V.textAlign;if(Z){var z=S[Z];z&&(K.lineAlign=z),K.align=Z}return _(K,V),K}).filter(function(C){return C!==null})}function s(u,f,l){var o=u.getElementsByTagName(f)[0];return o?[].slice.call(o.querySelectorAll(l)):[]}function e(u){return u.reduce(function(f,l){var o=l.getAttribute("xml:id");return o&&(f[o]=l),f},{})}function i(u,f){return[].slice.call(u.childNodes).reduce(function(l,o,E){var m;return o.nodeName==="br"&&E?l+`
|
|
20
|
+
`:(m=o.childNodes)!==null&&m!==void 0&&m.length?i(o,f):f?l+o.textContent.trim().replace(/\s+/g," "):l+o.textContent},"")}function t(u,f){var l="http://www.w3.org/ns/ttml#styling",o=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return o.reduce(function(E,m){var O=r(f,l,m)||r(u,l,m);return O&&(E[m]=O),E},{})}function r(u,f,l){return u.hasAttributeNS(f,l)?u.getAttributeNS(f,l):null}function a(u){return new Error("Could not parse ttml timestamp "+u)}function n(u,f){if(!u)return null;var l=Object(y.parseTimeStamp)(u);return l===null&&(A.test(u)?l=h(u,f):L.test(u)&&(l=d(u,f))),l}function h(u,f){var l=A.exec(u),o=(l[4]|0)+(l[5]|0)/f.subFrameRate;return(l[1]|0)*3600+(l[2]|0)*60+(l[3]|0)+o/f.frameRate}function d(u,f){var l=L.exec(u),o=Number(l[1]),E=l[2];switch(E){case"h":return o*3600;case"m":return o*60;case"ms":return o*1e3;case"f":return o/f.frameRate;case"t":return o/f.tickRate}return o}},"./src/utils/logger.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"enableLogs",function(){return D}),c.d(b,"logger",function(){return _});var R=function(){},y={trace:R,debug:R,log:R,warn:R,info:R,error:R},x=y;function I(g){var A=self.console[g];return A?A.bind(self.console,"["+g+"] >"):R}function T(g){for(var A=arguments.length,L=new Array(A>1?A-1:0),S=1;S<A;S++)L[S-1]=arguments[S];L.forEach(function(v){x[v]=g[v]?g[v].bind(g):I(v)})}function D(g){if(self.console&&g===!0||typeof g=="object"){T(g,"debug","log","info","warn","error");try{x.log()}catch{x=y}}else x=y}var _=x},"./src/utils/mediakeys-helper.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"KeySystems",function(){return R}),c.d(b,"requestMediaKeySystemAccess",function(){return y});var R;(function(x){x.WIDEVINE="com.widevine.alpha",x.PLAYREADY="com.microsoft.playready"})(R||(R={}));var y=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"getMediaSource",function(){return R});function R(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"bin2str",function(){return T}),c.d(b,"readUint16",function(){return D}),c.d(b,"readUint32",function(){return _}),c.d(b,"writeUint32",function(){return g}),c.d(b,"findBox",function(){return A}),c.d(b,"parseSegmentIndex",function(){return L}),c.d(b,"parseInitSegment",function(){return S}),c.d(b,"getStartDTS",function(){return v}),c.d(b,"getDuration",function(){return p}),c.d(b,"computeRawDurationFromSamples",function(){return s}),c.d(b,"offsetStartDTS",function(){return e}),c.d(b,"segmentValidRange",function(){return i}),c.d(b,"appendUint8Array",function(){return t});var R=c("./src/utils/typed-array.ts"),y=c("./src/loader/fragment.ts"),x=Math.pow(2,32)-1,I=[].push;function T(r){return String.fromCharCode.apply(null,r)}function D(r,a){"data"in r&&(a+=r.start,r=r.data);var n=r[a]<<8|r[a+1];return n<0?65536+n:n}function _(r,a){"data"in r&&(a+=r.start,r=r.data);var n=r[a]<<24|r[a+1]<<16|r[a+2]<<8|r[a+3];return n<0?4294967296+n:n}function g(r,a,n){"data"in r&&(a+=r.start,r=r.data),r[a]=n>>24,r[a+1]=n>>16&255,r[a+2]=n>>8&255,r[a+3]=n&255}function A(r,a){var n=[];if(!a.length)return n;var h,d,u;"data"in r?(h=r.data,d=r.start,u=r.end):(h=r,d=0,u=h.byteLength);for(var f=d;f<u;){var l=_(h,f),o=T(h.subarray(f+4,f+8)),E=l>1?f+l:u;if(o===a[0])if(a.length===1)n.push({data:h,start:f+8,end:E});else{var m=A({data:h,start:f+8,end:E},a.slice(1));m.length&&I.apply(n,m)}f=E}return n}function L(r){var a=A(r,["moov"]),n=a[0],h=n?n.end:null,d=A(r,["sidx"]);if(!d||!d[0])return null;var u=[],f=d[0],l=f.data[0],o=l===0?8:16,E=_(f,o);o+=4;var m=0,O=0;l===0?o+=8:o+=16,o+=2;var P=f.end+O,M=D(f,o);o+=2;for(var F=0;F<M;F++){var B=o,C=_(f,B);B+=4;var U=C&2147483647,w=(C&2147483648)>>>31;if(w===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var N=_(f,B);B+=4,u.push({referenceSize:U,subsegmentDuration:N,info:{duration:N/E,start:P,end:P+U-1}}),P+=U,B+=4,o=B}return{earliestPresentationTime:m,timescale:E,version:l,referencesCount:M,references:u,moovEndOffset:h}}function S(r){for(var a=[],n=A(r,["moov","trak"]),h=0;h<n.length;h++){var d=n[h],u=A(d,["tkhd"])[0];if(u){var f=u.data[u.start],l=f===0?12:20,o=_(u,l),E=A(d,["mdia","mdhd"])[0];if(E){f=E.data[E.start],l=f===0?12:20;var m=_(E,l),O=A(d,["mdia","hdlr"])[0];if(O){var P=T(O.data.subarray(O.start+8,O.start+12)),M={soun:y.ElementaryStreamTypes.AUDIO,vide:y.ElementaryStreamTypes.VIDEO}[P];if(M){var F=A(d,["mdia","minf","stbl","stsd"])[0],B=void 0;F&&(B=T(F.data.subarray(F.start+12,F.start+16))),a[o]={timescale:m,type:M},a[M]={timescale:m,id:o,codec:B}}}}}}var C=A(r,["moov","mvex","trex"]);return C.forEach(function(U){var w=_(U,4),N=a[w];N&&(N.default={duration:_(U,12),flags:_(U,20)})}),a}function v(r,a){return A(a,["moof","traf"]).reduce(function(n,h){var d=A(h,["tfdt"])[0],u=d.data[d.start],f=A(h,["tfhd"]).reduce(function(l,o){var E=_(o,4),m=r[E];if(m){var O=_(d,4);u===1&&(O*=Math.pow(2,32),O+=_(d,8));var P=m.timescale||9e4,M=O/P;if(isFinite(M)&&(l===null||M<l))return M}return l},null);return f!==null&&isFinite(f)&&(n===null||f<n)?f:n},null)||0}function p(r,a){for(var n=0,h=0,d=0,u=A(r,["moof","traf"]),f=0;f<u.length;f++){var l=u[f],o=A(l,["tfhd"])[0],E=_(o,4),m=a[E];if(!!m){var O=m.default,P=_(o,0)|(O==null?void 0:O.flags),M=O==null?void 0:O.duration;P&8&&(P&2?M=_(o,12):M=_(o,8));for(var F=m.timescale||9e4,B=A(l,["trun"]),C=0;C<B.length;C++){if(n=s(B[C]),!n&&M){var U=_(B[C],4);n=M*U}m.type===y.ElementaryStreamTypes.VIDEO?h+=n/F:m.type===y.ElementaryStreamTypes.AUDIO&&(d+=n/F)}}}if(h===0&&d===0){var w=L(r);if(w!=null&&w.references)return w.references.reduce(function(N,j){return N+j.info.duration||0},0)}return h||d}function s(r){var a=_(r,0),n=8;a&1&&(n+=4),a&4&&(n+=4);for(var h=0,d=_(r,4),u=0;u<d;u++){if(a&256){var f=_(r,n);h+=f,n+=4}a&512&&(n+=4),a&1024&&(n+=4),a&2048&&(n+=4)}return h}function e(r,a,n){A(a,["moof","traf"]).forEach(function(h){A(h,["tfhd"]).forEach(function(d){var u=_(d,4),f=r[u];if(!!f){var l=f.timescale||9e4;A(h,["tfdt"]).forEach(function(o){var E=o.data[o.start],m=_(o,4);if(E===0)g(o,4,m-n*l);else{m*=Math.pow(2,32),m+=_(o,8),m-=n*l,m=Math.max(m,0);var O=Math.floor(m/(x+1)),P=Math.floor(m%(x+1));g(o,4,O),g(o,8,P)}})}})})}function i(r){var a={valid:null,remainder:null},n=A(r,["moof"]);if(n){if(n.length<2)return a.remainder=r,a}else return a;var h=n[n.length-1];return a.valid=Object(R.sliceUint8)(r,0,h.start-8),a.remainder=Object(R.sliceUint8)(r,h.start-8),a}function t(r,a){var n=new Uint8Array(r.length+a.length);return n.set(r),n.set(a,r.length),n}},"./src/utils/output-filter.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"default",function(){return R});var R=function(){function y(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=y.prototype;return x.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},x.newCue=function(T,D,_){(this.startTime===null||this.startTime>T)&&(this.startTime=T),this.endTime=D,this.screen=_,this.timelineController.createCaptionsTrack(this.trackName)},x.reset=function(){this.cueRanges=[],this.startTime=null},y}()},"./src/utils/texttrack-utils.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"sendAddTrackEvent",function(){return y}),c.d(b,"addCueToTrack",function(){return x}),c.d(b,"clearCurrentCues",function(){return I}),c.d(b,"removeCuesInRange",function(){return T}),c.d(b,"getCuesInRange",function(){return _});var R=c("./src/utils/logger.ts");function y(g,A){var L;try{L=new Event("addtrack")}catch{L=document.createEvent("Event"),L.initEvent("addtrack",!1,!1)}L.track=g,A.dispatchEvent(L)}function x(g,A){var L=g.mode;if(L==="disabled"&&(g.mode="hidden"),g.cues&&!g.cues.getCueById(A.id))try{if(g.addCue(A),!g.cues.getCueById(A.id))throw new Error("addCue is failed for: "+A)}catch(v){R.logger.debug("[texttrack-utils]: "+v);var S=new self.TextTrackCue(A.startTime,A.endTime,A.text);S.id=A.id,g.addCue(S)}L==="disabled"&&(g.mode=L)}function I(g){var A=g.mode;if(A==="disabled"&&(g.mode="hidden"),g.cues)for(var L=g.cues.length;L--;)g.removeCue(g.cues[L]);A==="disabled"&&(g.mode=A)}function T(g,A,L){var S=g.mode;if(S==="disabled"&&(g.mode="hidden"),g.cues&&g.cues.length>0)for(var v=_(g.cues,A,L),p=0;p<v.length;p++)g.removeCue(v[p]);S==="disabled"&&(g.mode=S)}function D(g,A){if(A<g[0].startTime)return 0;var L=g.length-1;if(A>g[L].endTime)return-1;for(var S=0,v=L;S<=v;){var p=Math.floor((v+S)/2);if(A<g[p].startTime)v=p-1;else if(A>g[p].startTime&&S<L)S=p+1;else return p}return g[S].startTime-A<A-g[v].startTime?S:v}function _(g,A,L){var S=[],v=D(g,A);if(v>-1)for(var p=v,s=g.length;p<s;p++){var e=g[p];if(e.startTime>=A&&e.endTime<=L)S.push(e);else if(e.startTime>L)return S}return S}},"./src/utils/time-ranges.ts":function(k,b,c){"use strict";c.r(b);var R={toString:function(x){for(var I="",T=x.length,D=0;D<T;D++)I+="["+x.start(D).toFixed(3)+","+x.end(D).toFixed(3)+"]";return I}};b.default=R},"./src/utils/timescale-conversion.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"toTimescaleFromBase",function(){return y}),c.d(b,"toTimescaleFromScale",function(){return x}),c.d(b,"toMsFromMpegTsClock",function(){return I}),c.d(b,"toMpegTsClockFromTimescale",function(){return T});var R=9e4;function y(D,_,g,A){g===void 0&&(g=1),A===void 0&&(A=!1);var L=D*_*g;return A?Math.round(L):L}function x(D,_,g,A){return g===void 0&&(g=1),A===void 0&&(A=!1),y(D,_,1/g,A)}function I(D,_){return _===void 0&&(_=!1),y(D,1e3,1/R,_)}function T(D,_){return _===void 0&&(_=1),y(D,R,1/_)}},"./src/utils/typed-array.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"sliceUint8",function(){return R});function R(y,x,I){return Uint8Array.prototype.slice?y.slice(x,I):new Uint8Array(Array.prototype.slice.call(y,x,I))}},"./src/utils/vttcue.ts":function(k,b,c){"use strict";c.r(b),b.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var R=["","lr","rl"],y=["start","middle","end","left","right"];function x(g,A){if(typeof A!="string"||!Array.isArray(g))return!1;var L=A.toLowerCase();return~g.indexOf(L)?L:!1}function I(g){return x(R,g)}function T(g){return x(y,g)}function D(g){for(var A=arguments.length,L=new Array(A>1?A-1:0),S=1;S<A;S++)L[S-1]=arguments[S];for(var v=1;v<arguments.length;v++){var p=arguments[v];for(var s in p)g[s]=p[s]}return g}function _(g,A,L){var S=this,v={enumerable:!0};S.hasBeenReset=!1;var p="",s=!1,e=g,i=A,t=L,r=null,a="",n=!0,h="auto",d="start",u=50,f="middle",l=50,o="middle";Object.defineProperty(S,"id",D({},v,{get:function(){return p},set:function(m){p=""+m}})),Object.defineProperty(S,"pauseOnExit",D({},v,{get:function(){return s},set:function(m){s=!!m}})),Object.defineProperty(S,"startTime",D({},v,{get:function(){return e},set:function(m){if(typeof m!="number")throw new TypeError("Start time must be set to a number.");e=m,this.hasBeenReset=!0}})),Object.defineProperty(S,"endTime",D({},v,{get:function(){return i},set:function(m){if(typeof m!="number")throw new TypeError("End time must be set to a number.");i=m,this.hasBeenReset=!0}})),Object.defineProperty(S,"text",D({},v,{get:function(){return t},set:function(m){t=""+m,this.hasBeenReset=!0}})),Object.defineProperty(S,"region",D({},v,{get:function(){return r},set:function(m){r=m,this.hasBeenReset=!0}})),Object.defineProperty(S,"vertical",D({},v,{get:function(){return a},set:function(m){var O=I(m);if(O===!1)throw new SyntaxError("An invalid or illegal string was specified.");a=O,this.hasBeenReset=!0}})),Object.defineProperty(S,"snapToLines",D({},v,{get:function(){return n},set:function(m){n=!!m,this.hasBeenReset=!0}})),Object.defineProperty(S,"line",D({},v,{get:function(){return h},set:function(m){if(typeof m!="number"&&m!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");h=m,this.hasBeenReset=!0}})),Object.defineProperty(S,"lineAlign",D({},v,{get:function(){return d},set:function(m){var O=T(m);if(!O)throw new SyntaxError("An invalid or illegal string was specified.");d=O,this.hasBeenReset=!0}})),Object.defineProperty(S,"position",D({},v,{get:function(){return u},set:function(m){if(m<0||m>100)throw new Error("Position must be between 0 and 100.");u=m,this.hasBeenReset=!0}})),Object.defineProperty(S,"positionAlign",D({},v,{get:function(){return f},set:function(m){var O=T(m);if(!O)throw new SyntaxError("An invalid or illegal string was specified.");f=O,this.hasBeenReset=!0}})),Object.defineProperty(S,"size",D({},v,{get:function(){return l},set:function(m){if(m<0||m>100)throw new Error("Size must be between 0 and 100.");l=m,this.hasBeenReset=!0}})),Object.defineProperty(S,"align",D({},v,{get:function(){return o},set:function(m){var O=T(m);if(!O)throw new SyntaxError("An invalid or illegal string was specified.");o=O,this.hasBeenReset=!0}})),S.displayState=void 0}return _.prototype.getCueAsHTML=function(){var g=self.WebVTT;return g.convertCueToDOMTree(self,this.text)},_}()},"./src/utils/vttparser.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"parseTimeStamp",function(){return x}),c.d(b,"fixLineBreaks",function(){return A}),c.d(b,"VTTParser",function(){return L});var R=c("./src/utils/vttcue.ts"),y=function(){function S(){}var v=S.prototype;return v.decode=function(s,e){if(!s)return"";if(typeof s!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(s))},S}();function x(S){function v(s,e,i,t){return(s|0)*3600+(e|0)*60+(i|0)+parseFloat(t||0)}var p=S.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return p?parseFloat(p[2])>59?v(p[2],p[3],0,p[4]):v(p[1],p[2],p[3],p[4]):null}var I=function(){function S(){this.values=Object.create(null)}var v=S.prototype;return v.set=function(s,e){!this.get(s)&&e!==""&&(this.values[s]=e)},v.get=function(s,e,i){return i?this.has(s)?this.values[s]:e[i]:this.has(s)?this.values[s]:e},v.has=function(s){return s in this.values},v.alt=function(s,e,i){for(var t=0;t<i.length;++t)if(e===i[t]){this.set(s,e);break}},v.integer=function(s,e){/^-?\d+$/.test(e)&&this.set(s,parseInt(e,10))},v.percent=function(s,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){var i=parseFloat(e);if(i>=0&&i<=100)return this.set(s,i),!0}return!1},S}();function T(S,v,p,s){var e=s?S.split(s):[S];for(var i in e)if(typeof e[i]=="string"){var t=e[i].split(p);if(t.length===2){var r=t[0],a=t[1];v(r,a)}}}var D=new R.default(0,0,""),_=D.align==="middle"?"middle":"center";function g(S,v,p){var s=S;function e(){var r=x(S);if(r===null)throw new Error("Malformed timestamp: "+s);return S=S.replace(/^[^\sa-zA-Z-]+/,""),r}function i(r,a){var n=new I;T(r,function(u,f){var l;switch(u){case"region":for(var o=p.length-1;o>=0;o--)if(p[o].id===f){n.set(u,p[o].region);break}break;case"vertical":n.alt(u,f,["rl","lr"]);break;case"line":l=f.split(","),n.integer(u,l[0]),n.percent(u,l[0])&&n.set("snapToLines",!1),n.alt(u,l[0],["auto"]),l.length===2&&n.alt("lineAlign",l[1],["start",_,"end"]);break;case"position":l=f.split(","),n.percent(u,l[0]),l.length===2&&n.alt("positionAlign",l[1],["start",_,"end","line-left","line-right","auto"]);break;case"size":n.percent(u,f);break;case"align":n.alt(u,f,["start",_,"end","left","right"]);break}},/:/,/\s/),a.region=n.get("region",null),a.vertical=n.get("vertical","");var h=n.get("line","auto");h==="auto"&&D.line===-1&&(h=-1),a.line=h,a.lineAlign=n.get("lineAlign","start"),a.snapToLines=n.get("snapToLines",!0),a.size=n.get("size",100),a.align=n.get("align",_);var d=n.get("position","auto");d==="auto"&&D.position===50&&(d=a.align==="start"||a.align==="left"?0:a.align==="end"||a.align==="right"?100:50),a.position=d}function t(){S=S.replace(/^\s+/,"")}if(t(),v.startTime=e(),t(),S.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+s);S=S.substr(3),t(),v.endTime=e(),t(),i(S,v)}function A(S){return S.replace(/<br(?: \/)?>/gi,`
|
|
21
|
+
`)}var L=function(){function S(){this.state="INITIAL",this.buffer="",this.decoder=new y,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var v=S.prototype;return v.parse=function(s){var e=this;s&&(e.buffer+=e.decoder.decode(s,{stream:!0}));function i(){var d=e.buffer,u=0;for(d=A(d);u<d.length&&d[u]!=="\r"&&d[u]!==`
|
|
22
|
+
`;)++u;var f=d.substr(0,u);return d[u]==="\r"&&++u,d[u]===`
|
|
23
|
+
`&&++u,e.buffer=d.substr(u),f}function t(d){T(d,function(u,f){},/:/)}try{var r="";if(e.state==="INITIAL"){if(!/\r\n|\n/.test(e.buffer))return this;r=i();var a=r.match(/^()?WEBVTT([ \t].*)?$/);if(!a||!a[0])throw new Error("Malformed WebVTT signature.");e.state="HEADER"}for(var n=!1;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(n?n=!1:r=i(),e.state){case"HEADER":/:/.test(r)?t(r):r||(e.state="ID");continue;case"NOTE":r||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(r)){e.state="NOTE";break}if(!r)continue;if(e.cue=new R.default(0,0,""),e.state="CUE",r.indexOf("-->")===-1){e.cue.id=r;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{g(r,e.cue,e.regionList)}catch{e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":{var h=r.indexOf("-->")!==-1;if(!r||h&&(n=!0)){e.oncue&&e.cue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}if(e.cue===null)continue;e.cue.text&&(e.cue.text+=`
|
|
24
|
+
`),e.cue.text+=r}continue;case"BADCUE":r||(e.state="ID")}}}catch{e.state==="CUETEXT"&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state=e.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},v.flush=function(){var s=this;try{if((s.cue||s.state==="HEADER")&&(s.buffer+=`
|
|
25
|
+
|
|
26
|
+
`,s.parse()),s.state==="INITIAL"||s.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){s.onparsingerror&&s.onparsingerror(e)}return s.onflush&&s.onflush(),this},S}()},"./src/utils/webvtt-parser.ts":function(k,b,c){"use strict";c.r(b),c.d(b,"generateCueId",function(){return L}),c.d(b,"parseWebVTT",function(){return v});var R=c("./src/polyfills/number.ts"),y=c("./src/utils/vttparser.ts"),x=c("./src/demux/id3.ts"),I=c("./src/utils/timescale-conversion.ts"),T=c("./src/remux/mp4-remuxer.ts"),D=/\r\n|\n\r|\n|\r/g,_=function(s,e,i){return i===void 0&&(i=0),s.substr(i,e.length)===e},g=function(s){var e=parseInt(s.substr(-3)),i=parseInt(s.substr(-6,2)),t=parseInt(s.substr(-9,2)),r=s.length>9?parseInt(s.substr(0,s.indexOf(":"))):0;if(!Object(R.isFiniteNumber)(e)||!Object(R.isFiniteNumber)(i)||!Object(R.isFiniteNumber)(t)||!Object(R.isFiniteNumber)(r))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+s);return e+=1e3*i,e+=60*1e3*t,e+=60*60*1e3*r,e},A=function(s){for(var e=5381,i=s.length;i;)e=e*33^s.charCodeAt(--i);return(e>>>0).toString()};function L(p,s,e){return A(p.toString())+A(s.toString())+A(e)}var S=function(s,e,i){var t=s[e],r=s[t.prevCC];if(!r||!r.new&&t.new){s.ccOffset=s.presentationOffset=t.start,t.new=!1;return}for(;(a=r)!==null&&a!==void 0&&a.new;){var a;s.ccOffset+=t.start-r.start,t.new=!1,t=r,r=s[t.prevCC]}s.presentationOffset=i};function v(p,s,e,i,t,r,a,n){var h=new y.VTTParser,d=Object(x.utf8ArrayToStr)(new Uint8Array(p)).trim().replace(D,`
|
|
27
|
+
`).split(`
|
|
28
|
+
`),u=[],f=Object(I.toMpegTsClockFromTimescale)(s,e),l="00:00.000",o=0,E=0,m,O=!0,P=!1;h.oncue=function(M){var F=i[t],B=i.ccOffset,C=(o-f)/9e4;if(F!=null&&F.new&&(E!==void 0?B=i.ccOffset=F.start:S(i,t,C)),C&&(B=C-i.presentationOffset),P){var U=M.endTime-M.startTime,w=Object(T.normalizePts)((M.startTime+B-E)*9e4,r*9e4)/9e4;M.startTime=w,M.endTime=w+U}var N=M.text.trim();M.text=decodeURIComponent(encodeURIComponent(N)),M.id||(M.id=L(M.startTime,M.endTime,N)),M.endTime>0&&u.push(M)},h.onparsingerror=function(M){m=M},h.onflush=function(){if(m){n(m);return}a(u)},d.forEach(function(M){if(O)if(_(M,"X-TIMESTAMP-MAP=")){O=!1,P=!0,M.substr(16).split(",").forEach(function(F){_(F,"LOCAL:")?l=F.substr(6):_(F,"MPEGTS:")&&(o=parseInt(F.substr(7)))});try{E=g(l)/1e3}catch(F){P=!1,m=F}return}else M===""&&(O=!1);h.parse(M+`
|
|
29
|
+
`)}),h.flush()}},"./src/utils/xhr-loader.ts":function(k,b,c){"use strict";c.r(b);var R=c("./src/utils/logger.ts"),y=c("./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 y.LoadStats,this.retryDelay=0}var D=T.prototype;return D.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},D.abortInternal=function(){var g=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),g&&(g.onreadystatechange=null,g.onprogress=null,g.readyState!==4&&(this.stats.aborted=!0,g.abort()))},D.abort=function(){var g;this.abortInternal(),(g=this.callbacks)!==null&&g!==void 0&&g.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},D.load=function(g,A,L){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=g,this.config=A,this.callbacks=L,this.retryDelay=A.retryDelay,this.loadInternal()},D.loadInternal=function(){var g=this.config,A=this.context;if(!!g){var L=this.loader=new self.XMLHttpRequest,S=this.stats;S.loading.first=0,S.loaded=0;var v=this.xhrSetup;try{if(v)try{v(L,A.url)}catch{L.open("GET",A.url,!0),v(L,A.url)}L.readyState||L.open("GET",A.url,!0);var p=this.context.headers;if(p)for(var s in p)L.setRequestHeader(s,p[s])}catch(e){this.callbacks.onError({code:L.status,text:e.message},A,L);return}A.rangeEnd&&L.setRequestHeader("Range","bytes="+A.rangeStart+"-"+(A.rangeEnd-1)),L.onreadystatechange=this.readystatechange.bind(this),L.onprogress=this.loadprogress.bind(this),L.responseType=A.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),g.timeout),L.send()}},D.readystatechange=function(){var g=this.context,A=this.loader,L=this.stats;if(!(!g||!A)){var S=A.readyState,v=this.config;if(!L.aborted&&S>=2)if(self.clearTimeout(this.requestTimeout),L.loading.first===0&&(L.loading.first=Math.max(self.performance.now(),L.loading.start)),S===4){A.onreadystatechange=null,A.onprogress=null;var p=A.status;if(p>=200&&p<300){L.loading.end=Math.max(self.performance.now(),L.loading.first);var s,e;if(g.responseType==="arraybuffer"?(s=A.response,e=s.byteLength):(s=A.responseText,e=s.length),L.loaded=L.total=e,!this.callbacks)return;var i=this.callbacks.onProgress;if(i&&i(L,g,s,A),!this.callbacks)return;var t={url:A.responseURL,data:s};this.callbacks.onSuccess(t,L,g,A)}else L.retry>=v.maxRetry||p>=400&&p<499?(R.logger.error(p+" while loading "+g.url),this.callbacks.onError({code:p,text:A.statusText},g,A)):(R.logger.warn(p+" while loading "+g.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,v.maxRetryDelay),L.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),v.timeout)}},D.loadtimeout=function(){R.logger.warn("timeout while loading "+this.context.url);var g=this.callbacks;g&&(this.abortInternal(),g.onTimeout(this.stats,this.context,this.loader))},D.loadprogress=function(g){var A=this.stats;A.loaded=g.loaded,g.lengthComputable&&(A.total=g.total)},D.getCacheAge=function(){var g=null;if(this.loader&&x.test(this.loader.getAllResponseHeaders())){var A=this.loader.getResponseHeader("age");g=A?parseFloat(A):null}return g},T}();b.default=I}}).default})});if(typeof DocumentFragment=="undefined"){class k{}globalThis.DocumentFragment=k}globalThis.customElements||(globalThis.customElements={get(k){},define(k,b,c){},upgrade(k){},whenDefined(k){return Promise.resolve(globalThis.HTMLElement)}});var Ke;if(!globalThis.CustomEvent){class k{constructor(c,R={}){Tt(this,Ke,void 0);xt(this,Ke,R==null?void 0:R.detail)}get detail(){Et(this,Ke)}initCustomEvent(c,R,y,x){}}Ke=new WeakMap,globalThis.CustomEvent=k}if(!globalThis.EventTarget){class k{addEventListener(){}removeEventListener(){}dispatchEvent(c){return!0}}globalThis.EventTarget=k}if(!globalThis.HTMLElement){class k extends EventTarget{}globalThis.HTMLElement=k}if(!globalThis.HTMLVideoElement){class k extends EventTarget{}globalThis.HTMLVideoElement=k}var St,_t;if(!((St=globalThis.document)==null?void 0:St.createElement)){let k=(_t=globalThis.document)!=null?_t:{};k.createElement=function(c,R){return new HTMLElement},globalThis.document=k}var ut=Xe(At()),be=Xe(Qe());var at=Xe(Qe()),st={ANY:"any",MUTED:"muted"},Nt=Object.values(st),Lt=k=>typeof k=="boolean"||typeof k=="string"&&Nt.includes(k),Kt=(k,b,c)=>{let R=!1,y=!1,x=Lt(b)?b:!!b,I=()=>{k.addEventListener("playing",()=>{R=!0},{once:!0})};if(I(),k.addEventListener("loadstart",()=>{R=!1,I(),ot(k,x)},{once:!0}),k.addEventListener("loadedmetadata",()=>{c||(y=!Number.isFinite(k.duration)),ot(k,x)},{once:!0}),c&&c.once(at.default.Events.LEVEL_LOADED,(D,_)=>{var g;y=(g=_.details.live)!=null?g:!1}),!x){let D=()=>{!y||((c==null?void 0:c.liveSyncPosition)?k.currentTime=c.liveSyncPosition:Number.isFinite(k.seekable.end(0))&&(k.currentTime=k.seekable.end(0)))};k.addEventListener("play",()=>{c&&k.preload==="metadata"?c.once(at.default.Events.LEVEL_UPDATED,D):c&&D()},{once:!0})}return D=>{R||(x=Lt(D)?D:!!D,ot(k,x))}},ot=(k,b)=>{if(!b)return;let c=k.muted,R=()=>k.muted=c;switch(b){case st.ANY:k.play().catch(y=>{k.muted=!0,k.play().catch(R)});break;case st.MUTED:k.muted=!0,k.play().catch(R);break;default:k.play().catch(()=>{});break}};var Fe=class extends Error{constructor(b,c=Fe.MEDIA_ERR_CUSTOM,R){super(b);var y;this.name="MediaError",this.code=c,this.fatal=R!=null?R:c>=Fe.MEDIA_ERR_NETWORK&&c<=Fe.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(y=Fe.defaultMessages[this.code])!=null?y:"")}},_e=Fe;_e.MEDIA_ERR_ABORTED=1,_e.MEDIA_ERR_NETWORK=2,_e.MEDIA_ERR_DECODE=3,_e.MEDIA_ERR_SRC_NOT_SUPPORTED=4,_e.MEDIA_ERR_ENCRYPTED=5,_e.MEDIA_ERR_CUSTOM=100,_e.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};var Be=Xe(Qe());function Dt(k,b){b.on(Be.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(y,{tracks:x})=>{x.forEach(I=>{var _;let T=(_=I.subtitleTrack)!=null?_:I.closedCaptions,D=b.subtitleTracks.findIndex(({lang:g,name:A,type:L})=>g==(T==null?void 0:T.lang)&&A===I.label&&L.toLowerCase()===I.kind);jt(k,I.kind,I.label,T==null?void 0:T.lang,`${I.kind}${D}`)})});let c=()=>{var I;if(!b.subtitleTracks.length)return;let y=Array.from(k.textTracks).find(T=>T.id&&T.mode==="showing"&&["subtitles","captions"].includes(T.kind)),x=`${(I=b.subtitleTracks[b.subtitleTrack])==null?void 0:I.type.toLowerCase()}${b.subtitleTrack}`;if(y&&(b.subtitleTrack<0||(y==null?void 0:y.id)!==x)){let T=b.subtitleTracks.findIndex(({lang:D,name:_,type:g})=>D==y.language&&_===y.label&&g.toLowerCase()===y.kind);b.subtitleTrack=T}y&&(y==null?void 0:y.id)===x&&y.cues&&Array.from(y.cues).forEach(T=>{y.addCue(T)})};k.textTracks.addEventListener("change",c),b.on(Be.default.Events.CUES_PARSED,(y,{track:x,type:I,cues:T})=>{let D=k.textTracks.getTrackById(x);if(!D)return;let _=D.mode==="disabled";_&&(D.mode="hidden"),T.forEach(g=>{var A;((A=D.cues)==null?void 0:A.getCueById(g.id))||D.addCue(g)}),_&&(D.mode="disabled")}),b.on(Be.default.Events.DESTROYING,()=>{k.textTracks.removeEventListener("change",c),k.querySelectorAll("track").forEach(x=>{!(x.id&&["subtitles","captions"].includes(x.kind))||!b.subtitleTracks.some(({type:I},T)=>x.id===`${I.toLowerCase()}${T}`)||k.removeChild(x)})});let R=()=>{Array.from(k.textTracks).forEach(y=>{var x,I;if(!["subtitles","caption"].includes(y.kind)&&y.label==="thumbnails"){if(!((x=y.cues)==null?void 0:x.length)){let T=k.querySelector('track[label="thumbnails"]'),D=(I=T==null?void 0:T.getAttribute("src"))!=null?I:"";T==null||T.removeAttribute("src"),setTimeout(()=>{T==null||T.setAttribute("src",D)},0)}y.mode!=="hidden"&&(y.mode="hidden")}})};b.once(Be.default.Events.MANIFEST_LOADED,R),b.once(Be.default.Events.MEDIA_ATTACHED,R)}function jt(k,b,c,R,y){let x=document.createElement("track");return x.kind=b,x.label=c,R&&(x.srclang=R),y&&(x.id=y),x.track.mode="disabled",k.appendChild(x),x.track}var lt=(k,b)=>k in b;var Ot="mux.com",hr=()=>ut.default.utils.now(),We={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},Ue={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},ft={HLS:Ue.M3U8},vr=Object.keys(ft),gr=[...Object.values(Ue),"hls","HLS"],Wt=k=>{let b=k.indexOf("?");if(b<0)return[k];let c=k.slice(0,b),R=k.slice(b);return[c,R]},mr=(k,{domain:b=Ot}={})=>{if(!k)return;let[c,R=""]=Wt(k);return`https://stream.${b}/${c}.m3u8${R}`},Ht=k=>{let b="";try{b=new URL(k).pathname}catch{console.error("invalid url")}let c=b.lastIndexOf(".");if(c<0)return"";let y=b.slice(c+1).toUpperCase();return lt(y,Ue)?Ue[y]:""},Rt=k=>{let b=k.type;if(b){let R=b.toUpperCase();return lt(R,ft)?ft[R]:b}let{src:c}=k;return c?Ht(c):""},Gt=k=>{if([We.LIVE,We.LL_LIVE].includes(k)){let b={backBufferLength:12};return k===We.LL_LIVE?{...b,maxFragLookUpTolerance:.001}:b}return{}},Je=new WeakMap,pr=k=>{var b;return(b=Je.get(k))==null?void 0:b.error},Vt=(k,b)=>{b&&(b.detachMedia(),b.destroy()),(k==null?void 0:k.mux)&&!k.mux.deleted&&(k.mux.destroy(),k.mux),k&&(k.removeEventListener("error",Pt),k.removeEventListener("error",dt),Je.delete(k))},Yt=(k,b)=>{var v,p,s;let{debug:c,preferMse:R,streamType:y,startTime:x=-1}=k,I=Rt(k),T=I===Ue.M3U8,D=!I||((v=b==null?void 0:b.canPlayType(I))!=null?v:!0),_=be.default.isSupported(),L=((s=(p=window==null?void 0:window.navigator)==null?void 0:p.userAgent)!=null?s:"").toLowerCase().indexOf("android")!==-1&&y===We.LL_LIVE;if(T&&!(!T||D&&!((R||L)&&_))&&_){let e={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},i=Gt(y);return new be.default({debug:c,startPosition:x,...e,...i})}},Xt=({playbackId:k,src:b,customDomain:c})=>{if(k)return!0;if(typeof b!="string")return!1;let R=new URL(b).hostname.toLocaleLowerCase();return R.includes(Ot)||!!c&&R.includes(c.toLocaleLowerCase())},zt=(k,b,c)=>{let{envKey:R}=k,y=Xt(k);if((R||y)&&b){let{playerInitTime:x,playerSoftwareName:I,playerSoftwareVersion:T,beaconCollectionDomain:D,metadata:_,debug:g}=k,A=L=>typeof L.player_error_code=="string"?!1:typeof k.errorTranslator=="function"?k.errorTranslator(L):L;ut.default.monitor(b,{debug:g,beaconCollectionDomain:D,hlsjs:c,Hls:c?be.default:void 0,automaticErrorTracking:!1,errorTranslator:A,data:{...R?{env_key:R}:{},player_software_name:I,player_software_version:T,player_init_time:x,..._}})}},Qt=(k,b,c)=>{var v,p,s;if(!b){console.warn("attempting to load media before mediaEl exists");return}let{preferMse:R,streamType:y}=k,x=Rt(k),I=x===Ue.M3U8,T=!x||((v=b==null?void 0:b.canPlayType(x))!=null?v:!0),D=be.default.isSupported(),A=((s=(p=window==null?void 0:window.navigator)==null?void 0:p.userAgent)!=null?s:"").toLowerCase().indexOf("android")!==-1&&y===We.LL_LIVE,L=!I||T&&!((R||A)&&D),{src:S}=k;if(b&&T&&L){if(typeof S=="string"){let{startTime:e}=k;if(b.setAttribute("src",S),e){let i=({target:t})=>{t.currentTime=e,t.removeEventListener("loadedmetadata",i)};b.addEventListener("loadedmetadata",i)}}else b.removeAttribute("src");b.addEventListener("error",Pt),b.addEventListener("error",dt)}else if(c&&S){switch(c.on(be.default.Events.ERROR,(e,i)=>{let t={[be.default.ErrorTypes.NETWORK_ERROR]:_e.MEDIA_ERR_NETWORK,[be.default.ErrorTypes.MEDIA_ERROR]:_e.MEDIA_ERR_DECODE},r=new _e("",t[i.type]);r.fatal=i.fatal,r.data=i,b.dispatchEvent(new CustomEvent("error",{detail:r}))}),b.addEventListener("error",dt),Dt(b,c),b.preload){case"none":b.addEventListener("play",()=>c.loadSource(S),{once:!0});break;case"metadata":let e=c.config.maxBufferLength,i=c.config.maxBufferSize;c.config.maxBufferLength=1,c.config.maxBufferSize=1,b.addEventListener("play",()=>{c.config.maxBufferLength=e,c.config.maxBufferSize=i},{once:!0}),c.loadSource(S);break;default:c.loadSource(S)}c.attachMedia(b)}else console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};async function Pt(k){if(!k.isTrusted)return;k.stopImmediatePropagation();let b=k.target;if(!(b==null?void 0:b.error))return;let{message:c,code:R}=b.error,y=new _e(c,R);if(b.src&&(R!==_e.MEDIA_ERR_DECODE||R!==void 0)){let{status:x}=await fetch(b.src);y.data={response:{code:x}}}b.dispatchEvent(new CustomEvent("error",{detail:y}))}function dt(k){var y;if(!(k instanceof CustomEvent)||!(k.detail instanceof _e))return;let b=k.target,c=k.detail;if(!c||!c.fatal)return;let R=Je.get(b);R&&(R.error=c),(y=b.mux)==null||y.emit("error",{player_error_code:c.code,player_error_message:c.message})}var yr=(k,b,c)=>{Vt(b,c),Je.set(b,{});let R=Yt(k,b);return zt(k,b,R),Qt(k,b,R),R};var export_Hls=be.default;var export_mux=ut.default;export{Ue as ExtensionMimeTypeMap,export_Hls as Hls,_e as MediaError,ft as MimeTypeShorthandMap,We as StreamTypes,gr as allMediaTypes,hr as generatePlayerInitTime,pr as getError,Gt as getStreamTypeConfig,Rt as getType,Ht as inferMimeTypeFromURL,yr as initialize,Xt as isMuxVideoSrc,Qt as loadMedia,export_mux as mux,Kt as setupAutoplay,Yt as setupHls,zt as setupMux,vr as shorthandKeys,Vt as teardown,mr as toMuxVideoURL,Wt as toPlaybackIdParts};
|
|
30
|
+
//# sourceMappingURL=playback-core.mjs.map
|